zigbee: Update zigbee grid routing example
This commit is contained in:
@@ -51,6 +51,8 @@ Scope and Limitations
|
||||
- Zigbee Device Object (ZDO)
|
||||
- Application Framework (AF)
|
||||
|
||||
To see a list of |ns3| Zigbee undergoing development efforts check issue `#1165 <https://gitlab.com/nsnam/ns-3-dev/-/issues/1165>`_
|
||||
|
||||
The network layer (NWK)
|
||||
-----------------------
|
||||
|
||||
@@ -301,7 +303,7 @@ All the examples listed here shows scenarios in which a quasi-layer implementati
|
||||
* ``zigbee-direct-join.cc``: An example showing the NWK layer join process of devices using the orphaning procedure (Direct join).
|
||||
* ``zigbee-association-join.cc``: An example showing the NWK layer join process of 3 devices in a zigbee network (MAC association).
|
||||
* ``zigbee-nwk-routing.cc``: Shows a simple topology of 5 router devices sequentially joining a network. Data transmission and/or route discovery also shown in this example
|
||||
* ``zigbee-nwk-routing2.cc``: Shows a complex grid topology of 50 router devices sequentially joining a network. Data transmission and/or route discovery also shown in this example.
|
||||
* ``zigbee-nwk-routing-grid.cc``: Shows a complex grid topology of 50 router devices sequentially joining a network. Data transmission and/or route discovery also shown in this example.
|
||||
|
||||
The following unit test have been developed to ensure the correct behavior of the module:
|
||||
|
||||
|
||||
@@ -2,7 +2,7 @@ set(base_examples
|
||||
zigbee-nwk-direct-join
|
||||
zigbee-nwk-association-join
|
||||
zigbee-nwk-routing
|
||||
zigbee-nwk-routing2
|
||||
zigbee-nwk-routing-grid
|
||||
)
|
||||
|
||||
foreach(
|
||||
|
||||
@@ -9,21 +9,25 @@
|
||||
*/
|
||||
|
||||
/**
|
||||
* This example shows the NWK procedure to perform a route request.
|
||||
* Prior the route request, an association-based join is performed.
|
||||
* The procedure requires a sequence of primitive calls on a specific order in the indicated
|
||||
* devices.
|
||||
*
|
||||
*
|
||||
* Network Extended PAN id: 0X000000000000CA:FE (based on the PAN coordinator address)
|
||||
*
|
||||
*
|
||||
*
|
||||
* Topology:
|
||||
*
|
||||
* Grid Topology
|
||||
* Grid Topology: 50 nodes separated by 30 m around them, 20 nodes per row for
|
||||
* the first two rows
|
||||
*
|
||||
* * * * * * * * * * * * * * * * * * * * *
|
||||
* * * * * * * * * * * * * * * * * * * * *
|
||||
* * * * * * * * * * *
|
||||
*
|
||||
* This example is a more complex version of zigbee-nwk-routing.cc.
|
||||
* The top left node is the coordinator while the rest of the nodes join
|
||||
* the network sequentially and they initiate as routers.
|
||||
*
|
||||
* After all devices join the network there are 3 alternatives for operations:
|
||||
*
|
||||
* 1. Send a data request (data transmission) with route discovery
|
||||
* 2. Send a route discovery
|
||||
* 3. Send a many-to-one route discovery
|
||||
*
|
||||
*/
|
||||
|
||||
@@ -44,8 +48,6 @@ using namespace ns3;
|
||||
using namespace ns3::lrwpan;
|
||||
using namespace ns3::zigbee;
|
||||
|
||||
// NS_LOG_COMPONENT_DEFINE("ZigbeeNwkRouting2");
|
||||
|
||||
ZigbeeStackContainer zigbeeStacks;
|
||||
|
||||
/*static void
|
||||
@@ -192,16 +194,16 @@ int
|
||||
main(int argc, char* argv[])
|
||||
{
|
||||
LogComponentEnableAll(LogLevel(LOG_PREFIX_TIME | LOG_PREFIX_FUNC | LOG_PREFIX_NODE));
|
||||
LogComponentEnable("ZigbeeNwk", LOG_LEVEL_DEBUG);
|
||||
// LogComponentEnable("LrWpanCsmaCa", LOG_LEVEL_DEBUG);
|
||||
// LogComponentEnable("LrWpanMac", LOG_LEVEL_DEBUG);
|
||||
// LogComponentEnable("LrWpanPhy", LOG_LEVEL_DEBUG);
|
||||
// LogComponentEnable("ZigbeeNwk", LOG_LEVEL_DEBUG);
|
||||
// LogComponentEnable("LrWpanCsmaCa", LOG_LEVEL_DEBUG);
|
||||
// LogComponentEnable("LrWpanMac", LOG_LEVEL_DEBUG);
|
||||
// LogComponentEnable("LrWpanPhy", LOG_LEVEL_DEBUG);
|
||||
|
||||
NodeContainer nodes;
|
||||
nodes.Create(50);
|
||||
|
||||
MobilityHelper mobility;
|
||||
mobility.SetMobilityModel("ns3::ConstantPositionMobilityModel");
|
||||
// mobility.SetMobilityModel("ns3::ConstantPositionMobilityModel");
|
||||
mobility.SetPositionAllocator("ns3::GridPositionAllocator",
|
||||
"MinX",
|
||||
DoubleValue(0.0),
|
||||
@@ -302,7 +304,7 @@ main(int argc, char* argv[])
|
||||
}
|
||||
}
|
||||
|
||||
// 5- Find a route and send a packet (data request with route discovery)
|
||||
// 5- Alternative 1: Data request with route discovery
|
||||
Ptr<Packet> p = Create<Packet>(5);
|
||||
NldeDataRequestParams dataReqParams;
|
||||
dataReqParams.m_dstAddrMode = UCST_BCST;
|
||||
@@ -316,7 +318,7 @@ main(int argc, char* argv[])
|
||||
dataReqParams,
|
||||
p);
|
||||
|
||||
// 5- Find a route to the given device short address
|
||||
// 5- Alternative 2: Route discovery without data transmission
|
||||
/* NlmeRouteDiscoveryRequestParams routeDiscParams;
|
||||
routeDiscParams.m_dstAddrMode = UCST_BCST;
|
||||
routeDiscParams.m_dstAddr = Mac16Address("30:56");
|
||||
@@ -326,14 +328,16 @@ main(int argc, char* argv[])
|
||||
zigbeeStacks.Get(0)->GetNwk(),
|
||||
routeDiscParams);
|
||||
|
||||
// make sure the route is formed before using traceroute
|
||||
// Results can be check with the Trace route.
|
||||
// Note: Make sure the route is formed before using traceroute
|
||||
Simulator::Schedule(Seconds(501),
|
||||
&TraceRoute,
|
||||
Mac16Address("00:00"),
|
||||
Mac16Address("30:56"));*/
|
||||
|
||||
/*
|
||||
// 5- Many-To-One route discovery
|
||||
// 5- Alternative 3: Trigger a Many-To-One route discovery with the first node
|
||||
// as the concentrator
|
||||
NlmeRouteDiscoveryRequestParams routeDiscParams;
|
||||
routeDiscParams.m_dstAddrMode = NO_ADDRESS;
|
||||
Simulator::ScheduleWithContext(zigbeeStacks.Get(0)->GetNode()->GetId(),
|
||||
@@ -347,6 +351,8 @@ main(int argc, char* argv[])
|
||||
Mac16Address("b6:24"),
|
||||
Mac16Address("00:00"));*/
|
||||
|
||||
// Printing Tables:
|
||||
|
||||
/*Ptr<OutputStreamWrapper> stream = Create<OutputStreamWrapper>(&std::cout);
|
||||
Simulator::ScheduleWithContext(zigbeeStacks.Get(7)->GetNode()->GetId(),
|
||||
Seconds(502),
|
||||
@@ -1346,13 +1346,12 @@ ZigbeeNwk::MlmeAssociateConfirm(MlmeAssociateConfirmParams params)
|
||||
if (m_nwkNeighborTable.LookUpEntry(m_associateParams.extAddress, entry))
|
||||
{
|
||||
entry->SetPotentialParent(false);
|
||||
// m_nwkNeighborTable.Update(m_associateParams.extAddress, entry);
|
||||
}
|
||||
else
|
||||
{
|
||||
NS_LOG_ERROR("Neighbor not found when discarding as potential parent");
|
||||
}
|
||||
joinConfirmParams.m_status = NwkStatus::NOT_PERMITED;
|
||||
joinConfirmParams.m_status = NwkStatus::NEIGHBOR_TABLE_FULL;
|
||||
break;
|
||||
case MacStatus::NO_ACK:
|
||||
joinConfirmParams.m_status = NwkStatus::NO_ACK;
|
||||
@@ -1565,6 +1564,8 @@ ZigbeeNwk::MlmeGetConfirm(MacStatus status,
|
||||
MacPibAttributeIdentifier id,
|
||||
Ptr<MacPibAttributes> attribute)
|
||||
{
|
||||
NS_LOG_FUNCTION(this);
|
||||
|
||||
if (m_pendPrimitiveNwk == PendingPrimitiveNwk::NLME_NETWORK_FORMATION)
|
||||
{
|
||||
if (id == MacPibAttributeIdentifier::macExtendedAddress && status == MacStatus::SUCCESS)
|
||||
@@ -1651,6 +1652,8 @@ ZigbeeNwk::MlmeGetConfirm(MacStatus status,
|
||||
void
|
||||
ZigbeeNwk::MlmeOrphanIndication(MlmeOrphanIndicationParams params)
|
||||
{
|
||||
NS_LOG_FUNCTION(this);
|
||||
|
||||
Ptr<NeighborTableEntry> entry;
|
||||
MlmeOrphanResponseParams respParams;
|
||||
|
||||
@@ -1690,6 +1693,8 @@ ZigbeeNwk::MlmeOrphanIndication(MlmeOrphanIndicationParams params)
|
||||
void
|
||||
ZigbeeNwk::MlmeCommStatusIndication(MlmeCommStatusIndicationParams params)
|
||||
{
|
||||
NS_LOG_FUNCTION(this);
|
||||
|
||||
// Return the results to the next layer of the router or coordinator
|
||||
// only after a SUCCESSFUL join to the network.
|
||||
if (params.m_status == MacStatus::SUCCESS)
|
||||
@@ -1711,11 +1716,10 @@ ZigbeeNwk::MlmeCommStatusIndication(MlmeCommStatusIndicationParams params)
|
||||
m_pendPrimitiveNwk = NLME_JOIN_INDICATION;
|
||||
UpdateBeaconPayloadLength();
|
||||
}
|
||||
else
|
||||
{
|
||||
NS_FATAL_ERROR("MLME-COMM-Status.Indication: params do not match");
|
||||
}
|
||||
}
|
||||
|
||||
// TODO: Handle other situations for MlmeCommStatusIndication according
|
||||
// to the status and primitive in use.
|
||||
}
|
||||
|
||||
void
|
||||
@@ -2818,6 +2822,8 @@ ZigbeeNwk::GetNwkStatus(MacStatus macStatus) const
|
||||
Mac16Address
|
||||
ZigbeeNwk::AllocateNetworkAddress()
|
||||
{
|
||||
NS_LOG_FUNCTION(this);
|
||||
|
||||
if (m_nwkAddrAlloc == DISTRIBUTED_ALLOC)
|
||||
{
|
||||
NS_FATAL_ERROR("Distributed allocation not supported");
|
||||
@@ -2855,6 +2861,8 @@ ZigbeeNwk::AllocateNetworkAddress()
|
||||
uint8_t
|
||||
ZigbeeNwk::GetLQINonLinearValue(uint8_t lqi) const
|
||||
{
|
||||
NS_LOG_FUNCTION(this);
|
||||
|
||||
uint8_t mappedValue;
|
||||
|
||||
if (lqi > 50)
|
||||
@@ -2892,6 +2900,8 @@ ZigbeeNwk::GetLQINonLinearValue(uint8_t lqi) const
|
||||
uint8_t
|
||||
ZigbeeNwk::GetLinkCost(uint8_t lqi) const
|
||||
{
|
||||
NS_LOG_FUNCTION(this);
|
||||
|
||||
if (m_nwkReportConstantCost)
|
||||
{
|
||||
// Hop count based. Report constant value
|
||||
|
||||
Reference in New Issue
Block a user