A Discrete-Event Network Simulator
API
Loading...
Searching...
No Matches
zigbee-nwk.cc
Go to the documentation of this file.
1/*
2 * Copyright (c) 2024 Tokushima University, Japan
3 *
4 * SPDX-License-Identifier: GPL-2.0-only
5 *
6 * Authors:
7 *
8 * Alberto Gallegos Ramonet <alramonet@is.tokushima-u.ac.jp>
9 * Ryo Okuda <c611901200@tokushima-u.ac.jp>
10 */
11
12#include "zigbee-nwk.h"
13
14#include "zigbee-nwk-tables.h"
15
16#include <ns3/log.h>
17#include <ns3/packet.h>
18#include <ns3/simulator.h>
19
20using namespace ns3::lrwpan;
21
22#undef NS_LOG_APPEND_CONTEXT
23#define NS_LOG_APPEND_CONTEXT \
24 std::clog << "[" << m_nwkNetworkAddress << " | " << m_nwkIeeeAddress << "] ";
25
26namespace ns3
27{
28namespace zigbee
29{
30
31NS_LOG_COMPONENT_DEFINE("ZigbeeNwk");
33
36{
37 static TypeId tid =
38 TypeId("ns3::zigbee::ZigbeeNwk")
40 .SetGroupName("Zigbee")
41 .AddConstructor<ZigbeeNwk>()
42 .AddAttribute("NwkcCoordinatorCapable",
43 "[Constant] Indicates whether the device is capable of becoming a"
44 "Zigbee coordinator.",
45 BooleanValue(true),
48 .AddAttribute("NwkcProtocolVersion",
49 "[Constant] The version of the Zigbee NWK protocol in"
50 "the device (placeholder)",
51 UintegerValue(0x02),
54 .AddAttribute("NwkcRouteDiscoveryTime",
55 "[Constant] The duration until a route discovery expires",
56 TimeValue(MilliSeconds(0x2710)),
59
60 .AddAttribute("NwkcInitialRREQRetries",
61 "[Constant] The number of times the first broadcast transmission"
62 "of a RREQ cmd frame is retried.",
63 UintegerValue(0x03),
66 .AddAttribute("NwkcRREQRetries",
67 "[Constant] The number of times the broadcast transmission of a"
68 "RREQ cmd frame is retried on relay by intermediate router or"
69 "coordinator.",
70 UintegerValue(0x02),
73 .AddAttribute("NwkcRREQRetryInterval",
74 "[Constant] The duration between retries of a broadcast RREQ "
75 "cmd frame.",
79 .AddAttribute("NwkcMinRREQJitter",
80 "[Constant] The minimum jitter for broadcast retransmission "
81 "of a RREQ (msec)",
82 DoubleValue(2),
85 .AddAttribute("NwkcMaxRREQJitter",
86 "[Constant] The duration between retries of a broadcast RREQ (msec)",
87 DoubleValue(128),
90 .AddAttribute("MaxPendingTxQueueSize",
91 "The maximum size of the table storing pending packets awaiting "
92 "to be transmitted after discovering a route to the destination.",
93 UintegerValue(10),
96 .AddTraceSource("RreqRetriesExhausted",
97 "Trace source indicating when a node has "
98 "reached the maximum allowed number of RREQ retries during a "
99 "route discovery request",
101 "ns3::zigbee::ZigbeeNwk::RreqRetriesExhaustedTracedCallback");
102 return tid;
103}
104
109
110void
112{
113 NS_LOG_FUNCTION(this);
114
117 m_uniformRandomVariable->SetAttribute("Min", DoubleValue(0.0));
118 m_uniformRandomVariable->SetAttribute("Max", DoubleValue(255.0));
119
121
122 m_netFormParams = {};
123 m_netFormParamsGen = nullptr;
124 m_beaconPayload = nullptr;
126 m_nwkPanId = 0xffff;
127 m_nwkExtendedPanId = 0xffffffffffffffff;
129
132 m_nwkMaxDepth = 5;
133 m_nwkMaxChildren = 20;
134 m_nwkMaxRouters = 6;
136 m_nwkUseTreeRouting = false;
137
139 m_nwkSymLink = false;
140
143
144 m_nwkIsConcentrator = false;
147
148 // TODO, set according to equation 3.5.2.1?
150
155
157 m_rreqJitter->SetAttribute("Min", DoubleValue(m_nwkcMinRREQJitter));
158 m_rreqJitter->SetAttribute("Max", DoubleValue(m_nwkcMaxRREQJitter));
159
161}
162
167
168void
174
175void
207
208void
210{
211 m_mac = mac;
212 // Update IEEE Nwk Address
213 m_mac->MlmeGetRequest(MacPibAttributeIdentifier::macExtendedAddress);
214}
215
218{
219 return m_mac;
220}
221
222void
224{
225 std::ostream* os = stream->GetStream();
226 std::ios oldState(nullptr);
227 oldState.copyfmt(*os);
228
229 std::ostringstream nwkAddr;
230 std::ostringstream ieeeAddr;
231
232 nwkAddr << m_nwkNetworkAddress;
233 ieeeAddr << m_nwkIeeeAddress;
234
235 *os << std::resetiosflags(std::ios::adjustfield) << std::setiosflags(std::ios::left);
236 *os << "[" << ieeeAddr.str() << " | " << nwkAddr.str() << "] | ";
237 *os << "Time: " << Simulator::Now().As(Time::S) << " | ";
238 m_nwkRoutingTable.Print(stream);
239}
240
241void
243{
244 std::ostream* os = stream->GetStream();
245 std::ios oldState(nullptr);
246 oldState.copyfmt(*os);
247
248 std::ostringstream nwkAddr;
249 std::ostringstream ieeeAddr;
250
251 nwkAddr << m_nwkNetworkAddress;
252 ieeeAddr << m_nwkIeeeAddress;
253
254 *os << std::resetiosflags(std::ios::adjustfield) << std::setiosflags(std::ios::left);
255 *os << "[" << ieeeAddr.str() << " | " << nwkAddr.str() << "] | ";
256 *os << "Time: " << Simulator::Now().As(Time::S) << " | ";
258}
259
260void
262{
263 std::ostream* os = stream->GetStream();
264 std::ios oldState(nullptr);
265 oldState.copyfmt(*os);
266
267 std::ostringstream nwkAddr;
268 std::ostringstream ieeeAddr;
269
270 nwkAddr << m_nwkNetworkAddress;
271 ieeeAddr << m_nwkIeeeAddress;
272
273 *os << std::resetiosflags(std::ios::adjustfield) << std::setiosflags(std::ios::left);
274 *os << "[" << ieeeAddr.str() << " | " << nwkAddr.str() << "] | ";
275 *os << "Time: " << Simulator::Now().As(Time::S) << " | ";
277}
278
279void
281{
282 std::ostream* os = stream->GetStream();
283 std::ios oldState(nullptr);
284 oldState.copyfmt(*os);
285
286 std::ostringstream nwkAddr;
287 std::ostringstream ieeeAddr;
288
289 nwkAddr << m_nwkNetworkAddress;
290 ieeeAddr << m_nwkIeeeAddress;
291
292 *os << std::resetiosflags(std::ios::adjustfield) << std::setiosflags(std::ios::left);
293 *os << "[" << ieeeAddr.str() << " | " << nwkAddr.str() << "] | ";
294 *os << "Time: " << Simulator::Now().As(Time::S) << " | ";
295 m_rreqRetryTable.Print(stream);
296}
297
300{
301 Ptr<NeighborTableEntry> neighborEntry;
302 if (m_nwkNeighborTable.LookUpEntry(dst, neighborEntry))
303 {
304 neighbor = true;
305 return dst;
306 }
307
309 if (m_nwkRoutingTable.LookUpEntry(dst, entry))
310 {
311 if (entry->GetStatus() == ROUTE_ACTIVE)
312 {
313 neighbor = false;
314 return entry->GetNextHopAddr();
315 }
316 }
317
318 neighbor = false;
319 return Mac16Address("FF:FF"); // route not found
320}
321
327
330{
331 return m_nwkIeeeAddress;
332}
333
334void
336{
337 NS_LOG_FUNCTION(this);
338
339 ZigbeeNwkHeader nwkHeader;
340 msdu->RemoveHeader(nwkHeader);
341
342 // Decrease the radius in the network header as it might be retransmitted
343 // to a next hop.
344 uint8_t radius = nwkHeader.GetRadius();
345 nwkHeader.SetRadius(radius - 1);
346
347 // Check if the received frame is from a neighbor and update LQI if necessary
348 Ptr<NeighborTableEntry> neighborEntry;
349 if (m_nwkNeighborTable.LookUpEntry(nwkHeader.GetSrcAddr(), neighborEntry))
350 {
351 neighborEntry->SetLqi(params.m_mpduLinkQuality);
352 neighborEntry->SetOutgoingCost(GetLQINonLinearValue(params.m_mpduLinkQuality));
353 }
354
355 switch (nwkHeader.GetFrameType())
356 {
357 case DATA:
358 if (nwkHeader.IsMulticast())
359 {
360 // DATA MULTICAST
361 NS_FATAL_ERROR("Multicast DATA transmission not supported");
362 }
363 else if (IsBroadcastAddress(nwkHeader.GetDstAddr()))
364 {
365 // DATA BROADCAST
366
368 if (m_btt.LookUpEntry(nwkHeader.GetSeqNum(), btr))
369 {
370 return;
371 }
372
373 // Check the capabilities of the current device
374 CapabilityInformation capability;
376
377 bool rebroadcastFlag = false;
378
379 if (nwkHeader.GetDstAddr() == 0xFFFF ||
380 (nwkHeader.GetDstAddr() == 0xFFFD && capability.IsReceiverOnWhenIdle()) ||
381 (nwkHeader.GetDstAddr() == 0xFFFC && capability.GetDeviceType() != ENDDEVICE))
382 {
383 rebroadcastFlag = true;
384 }
385 else if (nwkHeader.GetDstAddr() == 0xFFFB)
386 {
387 NS_FATAL_ERROR("Broadcast to low power routers not supported");
388 return;
389 }
390
391 if (rebroadcastFlag && nwkHeader.GetRadius() > 0)
392 {
393 Ptr<Packet> rebroadcastPkt = msdu->Copy();
394 rebroadcastPkt->AddHeader(nwkHeader);
395 SendDataBcst(rebroadcastPkt, 0);
396 }
397
398 // Add a new broadcast transaction record to the
399 // broadcasst transaction table
401 nwkHeader.GetSeqNum(),
404 m_btt.AddEntry(btr);
405
407 {
408 NldeDataIndicationParams dataParams;
409 dataParams.m_srcAddr = nwkHeader.GetSrcAddr();
410 dataParams.m_dstAddr = nwkHeader.GetDstAddr();
411 dataParams.m_dstAddrMode = UCST_BCST;
412 dataParams.m_linkQuality = params.m_mpduLinkQuality;
413 dataParams.m_nsduLength = msdu->GetSize();
414 dataParams.m_rxTime = Simulator::Now();
415 dataParams.m_securityUse = false;
416 m_nldeDataIndicationCallback(dataParams, msdu);
417 }
418 }
419 else
420 {
421 // DATA UNICAST
422 if (nwkHeader.GetDstAddr() == m_nwkNetworkAddress)
423 {
424 // Zigbee specification r22.1.0 Sections 3.6.2.2 and 3.6.3.3
426 {
427 NldeDataIndicationParams dataParams;
428 dataParams.m_srcAddr = nwkHeader.GetSrcAddr();
429 dataParams.m_dstAddr = nwkHeader.GetDstAddr();
430 dataParams.m_dstAddrMode = UCST_BCST;
431 dataParams.m_linkQuality = params.m_mpduLinkQuality;
432 dataParams.m_nsduLength = msdu->GetSize();
433 dataParams.m_rxTime = Simulator::Now();
434 dataParams.m_securityUse = false;
435 m_nldeDataIndicationCallback(dataParams, msdu);
436 }
437 }
438 else
439 {
440 // This is not the packet destination,
441 // Add again the network header to the DATA packet and
442 // route the packet to the next hop
443 msdu->AddHeader(nwkHeader);
444 SendDataUcst(msdu, 0);
445 }
446 }
447 break;
448 case NWK_COMMAND: {
449 ZigbeePayloadType payloadType;
450 msdu->RemoveHeader(payloadType);
451
452 if (payloadType.GetCmdType() == ROUTE_REQ_CMD || payloadType.GetCmdType() == ROUTE_REP_CMD)
453 {
454 CapabilityInformation capability;
456 if (capability.GetDeviceType() != ROUTER)
457 {
458 // Received RREQ or RREP but the device
459 // has no routing capabilities
460 return;
461 }
462 }
463 // NOTE: this cover the cases for MESH routing
464 // TREE routing is not supported
465 uint8_t linkCost = GetLinkCost(params.m_mpduLinkQuality);
466
467 if (payloadType.GetCmdType() == ROUTE_REQ_CMD)
468 {
470 msdu->RemoveHeader(payload);
471 // Zigbee specification r22.1.0 Section 3.6.3.5.2
472 ReceiveRREQ(params.m_srcAddr, linkCost, nwkHeader, payload);
473 }
474 else if (payloadType.GetCmdType() == ROUTE_REP_CMD)
475 {
477 msdu->RemoveHeader(payload);
478 // Zigbee specification r22.1.0 Section 3.6.3.5.3
479 ReceiveRREP(params.m_srcAddr, linkCost, nwkHeader, payload);
480 }
481 break;
482 }
483 case INTER_PAN:
484 NS_LOG_ERROR("Inter PAN frame received but not supported");
485 break;
486 default:
487 NS_LOG_ERROR("Unknown frame received in NWK layer");
488 }
489}
490
491void
493 uint8_t linkCost,
494 ZigbeeNwkHeader nwkHeader,
496{
497 NS_LOG_FUNCTION(this);
498
499 if (nwkHeader.GetSrcAddr() == m_nwkNetworkAddress)
500 {
501 // I am the original initiator of the RREQ, ignore request
502 return;
503 }
504
505 // Calculate the pathcost on the RREQ receiving device
506 uint8_t pathCost = linkCost + payload.GetPathCost();
507
508 // Many-to-one routing
509
511 {
512 RouteDiscoveryStatus routeStatus =
513 ProcessManyToOneRoute(macSrcAddr, pathCost, nwkHeader, payload);
514
515 // Update the path cost of the RREQ
516 payload.SetPathCost(pathCost);
517
518 // Note: At this point we already have the updated radius, which was updated as soon
519 // as the frame was received (i.e. In the MCPS-DATA.indication).
520
521 if (routeStatus == MANY_TO_ONE_ROUTE || routeStatus == ROUTE_UPDATED)
522 {
525 this,
526 nwkHeader,
527 payload,
528 0);
531 }
532 return;
533 }
534
535 // Mesh Routing
536
537 Mac16Address nextHop;
538 RouteDiscoveryStatus nextHopStatus =
539 FindNextHop(macSrcAddr, pathCost, nwkHeader, payload, nextHop);
540
541 if (payload.GetDstAddr() == m_nwkNetworkAddress || nextHopStatus == ROUTE_FOUND)
542 {
543 // RREQ is for this device or its children
544 NS_LOG_DEBUG("RREQ is for me or my children, sending a RREP to [" << macSrcAddr << "]");
545
546 SendRREP(macSrcAddr,
547 nwkHeader.GetSrcAddr(),
548 payload.GetDstAddr(),
549 payload.GetRouteReqId(),
550 pathCost);
551 }
552 else if (nextHopStatus == ROUTE_NOT_FOUND || nextHopStatus == ROUTE_UPDATED)
553 {
554 NS_LOG_DEBUG("Route for device [" << payload.GetDstAddr()
555 << "] not found, forwarding RREQ");
556
557 // Update path cost and resend the RREQ
558 payload.SetPathCost(pathCost);
561 this,
562 nwkHeader,
563 payload,
565 }
566}
567
568void
570 uint8_t linkCost,
571 ZigbeeNwkHeader nwkHeader,
573{
574 NS_LOG_FUNCTION(this);
575
576 // RREP received, cancel any ongoing RREQ retry events for that
577 // RREQ ID and remove entry from RREQ retry table.
578 Ptr<RreqRetryTableEntry> rreqRetryTableEntry;
579 if (m_rreqRetryTable.LookUpEntry(payload.GetRouteReqId(), rreqRetryTableEntry))
580 {
581 rreqRetryTableEntry->GetRreqEventId().Cancel();
583 }
584
585 uint8_t pathCost = linkCost + payload.GetPathCost();
586
587 if (payload.GetOrigAddr() == m_nwkNetworkAddress)
588 {
589 // The RREP is destined for this device
592 payload.GetOrigAddr(),
593 discEntry))
594 {
595 Ptr<RoutingTableEntry> routeEntry;
596 if (m_nwkRoutingTable.LookUpEntry(payload.GetRespAddr(), routeEntry))
597 {
598 if (routeEntry->GetStatus() == ROUTE_DISCOVERY_UNDERWAY)
599 {
600 if (routeEntry->IsGroupIdPresent())
601 {
602 routeEntry->SetStatus(ROUTE_VALIDATION_UNDERWAY);
603 }
604 else
605 {
606 routeEntry->SetStatus(ROUTE_ACTIVE);
607 }
608 routeEntry->SetNextHopAddr(macSrcAddr);
609 discEntry->SetResidualCost(pathCost);
610 }
611 else if (routeEntry->GetStatus() == ROUTE_VALIDATION_UNDERWAY ||
612 routeEntry->GetStatus() == ROUTE_ACTIVE)
613 {
614 if (pathCost < discEntry->GetResidualCost())
615 {
616 routeEntry->SetNextHopAddr(macSrcAddr);
617 discEntry->SetResidualCost(pathCost);
618 }
619 }
620
621 NS_LOG_DEBUG("RREP from source [" << payload.GetRespAddr()
622 << "] is for me; received from last hop ["
623 << macSrcAddr << "]");
624
626 {
627 // We only report the result of the route discovery request
628 // with the first RREP received.
631 {
632 NlmeRouteDiscoveryConfirmParams routeDiscConfirmParams;
633 routeDiscConfirmParams.m_status = NwkStatus::SUCCESS;
634 m_nlmeRouteDiscoveryConfirmCallback(routeDiscConfirmParams);
635 }
636 }
637
639 if (!m_pendingTxQueue.empty() &&
640 DequeuePendingTx(payload.GetRespAddr(), pendingTxPkt))
641 {
642 // Buffer a copy of the DATA packet that will be transmitted
643 // for handling after transmission (i.e. NSDE-DATA.confirm)
644 BufferTxPkt(pendingTxPkt->txPkt->Copy(),
646 pendingTxPkt->nsduHandle);
647
648 // There is a pending packet awaiting to be transmitted
649 // to the next hop, send it.
650 McpsDataRequestParams mcpsDataparams;
651 mcpsDataparams.m_txOptions = 0x01; // Acknowledment on.
652 mcpsDataparams.m_dstPanId = m_nwkPanId;
653 mcpsDataparams.m_msduHandle = m_macHandle.GetValue();
654 mcpsDataparams.m_srcAddrMode = SHORT_ADDR;
655 mcpsDataparams.m_dstAddrMode = SHORT_ADDR;
656 mcpsDataparams.m_dstAddr = routeEntry->GetNextHopAddr();
657 m_macHandle++;
658
659 m_mac->McpsDataRequest(mcpsDataparams, pendingTxPkt->txPkt);
660 }
661 }
662 else
663 {
665 }
666 }
667 }
668 else
669 {
670 // The RREP is NOT destined for this device
673 payload.GetOrigAddr(),
674 discEntry))
675 {
676 if (payload.GetPathCost() < discEntry->GetResidualCost())
677 {
678 Ptr<RoutingTableEntry> routeEntry;
679 if (m_nwkRoutingTable.LookUpEntry(payload.GetRespAddr(), routeEntry))
680 {
681 routeEntry->SetNextHopAddr(macSrcAddr);
682 routeEntry->SetStatus(ROUTE_ACTIVE);
683 discEntry->SetResidualCost(pathCost);
684 // Forward route reply to the next hop back to the original route requester
685 SendRREP(discEntry->GetSenderAddr(),
686 payload.GetOrigAddr(),
687 payload.GetRespAddr(),
688 payload.GetRouteReqId(),
689 pathCost);
690 }
691 else
692 {
693 NS_LOG_ERROR("Route discovery entry detected but no corresponding routing "
694 "table entry found");
695 }
696 }
697 }
698 }
699}
700
701bool
703{
704 return address == "FF:FF" || address == "FF:FD" || address == "FF:FC" || address == "FF:FB";
705}
706
709 uint8_t pathCost,
710 ZigbeeNwkHeader nwkHeader,
712 Mac16Address& nextHop)
713{
714 NS_LOG_FUNCTION(this);
715
716 // Mesh routing
717
718 // Check if the destination is our neighbor
719 Ptr<NeighborTableEntry> neighborEntry;
720 if (m_nwkNeighborTable.LookUpEntry(payload.GetDstAddr(), neighborEntry))
721 {
722 nextHop = payload.GetDstAddr();
723 return ROUTE_FOUND;
724 }
725
727 if (m_nwkRoutingTable.LookUpEntry(payload.GetDstAddr(), entry))
728 {
729 if (!(entry->GetStatus() == ROUTE_ACTIVE) &&
730 !(entry->GetStatus() == ROUTE_VALIDATION_UNDERWAY))
731 {
732 // Entry found but is not valid
733 entry->SetStatus(ROUTE_DISCOVERY_UNDERWAY);
734 }
735 else
736 {
737 // Entry found
738 nextHop = entry->GetNextHopAddr();
739 return ROUTE_FOUND;
740 }
741 }
743 {
744 // Check that the max routing capacity has not been reached. If the capacity was reached,
745 // attempt to delete the first found expired entry, if the table persist to be full
746 // then send a route error.
748 {
750
752 {
754 {
756 confirmParams.m_status = ROUTE_ERROR;
759 }
760 return TABLE_FULL;
761 }
762 }
763
764 // Entry not found
765 Ptr<RoutingTableEntry> newRoutingEntry =
768 true, // TODO no route cache
769 false, // TODO: Many to one
770 false, // TODO: Route record
771 false, // TODO: Group id
772 Mac16Address("FF:FF"));
773 newRoutingEntry->SetLifeTime(Simulator::Now() + m_routeExpiryTime);
774
775 m_nwkRoutingTable.AddEntry(newRoutingEntry);
776 }
777 else
778 {
780 {
782 confirmParams.m_status = ROUTE_ERROR;
785 }
786 return NO_DISCOVER_ROUTE;
787 }
788
789 // 2- Find entry in DISCOVERY TABLE
792 nwkHeader.GetSrcAddr(),
793 discEntry))
794 {
795 // Entry Found
796 if (pathCost < discEntry->GetForwardCost())
797 {
798 // More optimal route found, update route discovery values.
799 discEntry->SetSenderAddr(macSrcAddr);
800 discEntry->SetForwardCost(pathCost);
801 discEntry->SetExpTime(Simulator::Now() + m_nwkcRouteDiscoveryTime);
802 return ROUTE_UPDATED;
803 }
804 else
805 {
806 return DISCOVER_UNDERWAY;
807 }
808 }
809 else
810 {
811 // Entry NOT found, add NEW entry to route discovery table.
812 Ptr<RouteDiscoveryTableEntry> newDiscEntry =
814 nwkHeader.GetSrcAddr(),
815 macSrcAddr, // macSrcAddr,
816 pathCost, // payload.GetPathCost(), // Forward cost
817 0xff, // Residual cost
819
820 if (!m_nwkRouteDiscoveryTable.AddEntry(newDiscEntry))
821 {
822 return TABLE_FULL;
823 }
824 }
825 return ROUTE_NOT_FOUND;
826}
827
830 uint8_t pathCost,
831 ZigbeeNwkHeader nwkHeader,
833{
836 nwkHeader.GetSrcAddr(),
837 discEntry))
838 {
839 Ptr<RoutingTableEntry> routeEntry;
840 if (m_nwkRoutingTable.LookUpEntry(nwkHeader.GetSrcAddr(), routeEntry))
841 {
842 if (routeEntry->GetStatus() == ROUTE_VALIDATION_UNDERWAY ||
843 routeEntry->GetStatus() == ROUTE_ACTIVE)
844 {
845 if (pathCost < discEntry->GetForwardCost())
846 {
847 // Update with a better route.
848 routeEntry->SetNextHopAddr(macSrcAddr);
849 discEntry->SetForwardCost(pathCost);
850 discEntry->SetExpTime(Simulator::Now() + m_nwkcRouteDiscoveryTime);
851 return ROUTE_UPDATED;
852 }
853 return NO_ROUTE_CHANGE;
854 }
855 }
856 else
857 {
858 NS_LOG_ERROR("Entry found in the discovery table but not the routing table");
859 return NO_ROUTE_CHANGE;
860 }
861 }
862 else
863 {
864 // Entry NOT found, add NEW entry to route discovery table.
865 Ptr<RouteDiscoveryTableEntry> newDiscEntry =
867 nwkHeader.GetSrcAddr(),
868 macSrcAddr, // previous hop address
869 pathCost, // Forward cost
870 0xff, // Residual cost (not used by Many-to-One)
872
873 // TODO: what to do if route discovery table is full?
875
876 // Define the type of Many-To-One routing (with or without route record)
877 bool routeRecord = false;
879 {
880 routeRecord = true;
881 }
882
883 Ptr<RoutingTableEntry> routeEntry;
884 if (m_nwkRoutingTable.LookUpEntry(nwkHeader.GetSrcAddr(), routeEntry))
885 {
886 if (routeEntry->GetStatus() == ROUTE_VALIDATION_UNDERWAY ||
887 routeEntry->GetStatus() == ROUTE_ACTIVE)
888 {
889 // The entry exist in routing table but it was not in discovery table
890 // Refresh the Route
891 routeEntry->SetNextHopAddr(macSrcAddr);
892 // TODO: other parameters
893 return ROUTE_UPDATED;
894 }
895 return NO_ROUTE_CHANGE;
896 }
897 else
898 {
899 // New routing table entry
900 // Check that the max routing capacity has not been reached. If the capacity was
901 // reached, attempt to delete the first found expired entry, if the table persist to be
902 // full then send a route error.
904 {
906
908 {
910 {
912 confirmParams.m_status = ROUTE_ERROR;
915 }
916 return TABLE_FULL;
917 }
918 }
919
920 Ptr<RoutingTableEntry> newRoutingEntry =
923 true, // TODO no route cache
924 true, // TODO: Many to one
925 routeRecord, // TODO: Route record
926 false, // TODO: Group id
927 macSrcAddr);
928
929 newRoutingEntry->SetLifeTime(Simulator::Now() + m_routeExpiryTime);
930
931 m_nwkRoutingTable.AddEntry(newRoutingEntry);
932 return MANY_TO_ONE_ROUTE;
933 }
934 }
935 return NO_ROUTE_CHANGE;
936}
937
938void
939ZigbeeNwk::SendDataUcst(Ptr<Packet> packet, uint8_t nwkHandle)
940{
941 NS_LOG_FUNCTION(this);
942
943 // Obtain information from the DATA packet
944 ZigbeeNwkHeader nwkHeaderData;
945 packet->PeekHeader(nwkHeaderData);
946
947 // Construct a RREQ network header and payload for possible
948 // route discovery request
949
950 ZigbeeNwkHeader nwkHeaderRreq;
951 nwkHeaderRreq.SetFrameType(NWK_COMMAND);
953 nwkHeaderRreq.SetDiscoverRoute(nwkHeaderData.GetDiscoverRoute());
954 // See r22.1.0, Table 3-69
955 // Set destination to broadcast (all routers and coordinator)
956 nwkHeaderRreq.SetDstAddr(Mac16Address("FF:FC"));
957 nwkHeaderRreq.SetSrcAddr(m_nwkNetworkAddress);
958 nwkHeaderRreq.SetSeqNum(m_nwkSequenceNumber.GetValue());
959 // see Zigbee specification 3.2.2.33.3
960 if (nwkHeaderData.GetRadius() == 0)
961 {
962 nwkHeaderRreq.SetRadius(m_nwkMaxDepth * 2);
963 }
964 else
965 {
966 nwkHeaderRreq.SetRadius(nwkHeaderData.GetRadius());
967 }
968
971 payloadRreq.SetDstAddr(nwkHeaderData.GetDstAddr());
972 payloadRreq.SetPathCost(0);
973
974 Mac16Address nextHop;
975 RouteDiscoveryStatus nextHopStatus =
976 FindNextHop(m_nwkNetworkAddress, 0, nwkHeaderRreq, payloadRreq, nextHop);
977
978 if (nextHopStatus == ROUTE_FOUND)
979 {
980 // Buffer a copy of the DATA packet that will be transmitted
981 // for handling after transmission (i.e. NSDE-DATA.confirm)
982 BufferTxPkt(packet->Copy(), m_macHandle.GetValue(), nwkHandle);
983
984 // Parameters as described in Section 3.6.3.3
985 McpsDataRequestParams mcpsDataparams;
986 mcpsDataparams.m_dstPanId = m_nwkPanId;
987 mcpsDataparams.m_msduHandle = m_macHandle.GetValue();
988 mcpsDataparams.m_txOptions = 0x01; // Acknowledment on.
989 mcpsDataparams.m_srcAddrMode = SHORT_ADDR;
990 mcpsDataparams.m_dstAddrMode = SHORT_ADDR;
991 mcpsDataparams.m_dstAddr = nextHop;
992 m_macHandle++;
993 m_mac->McpsDataRequest(mcpsDataparams, packet);
994 }
995 else if (nextHopStatus == ROUTE_NOT_FOUND)
996 {
997 // Route not found. Route marked as DISCOVER UNDERWAY,
998 // packet added to pending Tx Queue and we initiate route
999 // discovery
1000
1001 EnqueuePendingTx(packet, nwkHandle);
1002
1005 this,
1006 nwkHeaderRreq,
1007 payloadRreq,
1009
1012 }
1013}
1014
1015void
1016ZigbeeNwk::SendDataBcst(Ptr<Packet> packet, uint8_t nwkHandle)
1017{
1018 // Buffer a copy of the DATA packet that will be transmitted
1019 // for handling after transmission (i.e. NSDE-DATA.confirm)
1020 BufferTxPkt(packet->Copy(), m_macHandle.GetValue(), nwkHandle);
1021
1022 // Parameters as described in Section 3.6.5
1023 McpsDataRequestParams mcpsDataparams;
1024 mcpsDataparams.m_dstPanId = m_nwkPanId;
1025 mcpsDataparams.m_msduHandle = m_macHandle.GetValue();
1026 mcpsDataparams.m_srcAddrMode = SHORT_ADDR;
1027 mcpsDataparams.m_dstAddrMode = SHORT_ADDR;
1028 mcpsDataparams.m_dstAddr = Mac16Address("FF:FF");
1029 m_macHandle++;
1030 m_mac->McpsDataRequest(mcpsDataparams, packet);
1031}
1032
1033void
1035{
1036 Ptr<TxPkt> bufferedElement;
1037 if (RetrieveTxPkt(params.m_msduHandle, bufferedElement))
1038 {
1039 ZigbeeNwkHeader nwkHeader;
1040 bufferedElement->txPkt->PeekHeader(nwkHeader);
1041
1042 if (nwkHeader.GetFrameType() == DATA)
1043 {
1044 if (IsBroadcastAddress(nwkHeader.GetDstAddr()))
1045 {
1046 }
1047 else if (nwkHeader.GetSrcAddr() == m_nwkNetworkAddress)
1048 {
1049 // Send the confirmation to next layer after the packet transmission,
1050 // only if packet transmitted was in the initiator of the NLDE-DATA.request
1051
1053 {
1054 // Zigbee Specification r22.1.0, End of Section 3.2.1.1.3
1055 // Report the the results of a request to a transmission of a packet
1056 NldeDataConfirmParams nldeDataConfirmParams;
1057 // nldeDataConfirmParams.m_status =
1058 // static_cast<ZigbeeNwkStatus>(params.m_status);
1059 nldeDataConfirmParams.m_nsduHandle = bufferedElement->nwkHandle;
1060 m_nldeDataConfirmCallback(nldeDataConfirmParams);
1061 }
1062 }
1063 }
1064 }
1065}
1066
1067void
1069{
1070 NS_LOG_FUNCTION(this);
1071
1072 if (m_pendPrimitiveNwk == NLME_NETWORK_FORMATION && params.m_scanType == MLMESCAN_ED)
1073 {
1074 if (params.m_status != MacStatus::SUCCESS)
1075 {
1077 m_netFormParams = {};
1078 m_netFormParamsGen = nullptr;
1079
1081 {
1083 confirmParams.m_status = NwkStatus::STARTUP_FAILURE;
1085 }
1086 }
1087 else
1088 {
1089 // TODO: continue energy scan in other interfaces if supported.
1090
1091 // Filter the channels with unacceptable energy level (channel, energy)
1092 std::vector<uint8_t> energyList = params.m_energyDetList;
1094 uint32_t channelMaskFiltered = 0;
1095 uint32_t countAcceptableChannels = 0;
1096
1097 for (uint32_t i = 11; i <= 26; i++)
1098 {
1099 if ((channelMask >> i) & 1)
1100 {
1101 // Channel found in mask, check energy channel and mark it if acceptable
1102 if (energyList[0] <= m_scanEnergyThreshold)
1103 {
1104 // energy is acceptable, register to filtered list
1105 channelMaskFiltered |= (1 << i);
1106 energyList.erase(energyList.begin());
1107 countAcceptableChannels++;
1108 }
1109 }
1110 }
1111
1112 NS_LOG_DEBUG("[NLME-NETWORK-FORMATION.request]: Energy scan complete, "
1113 << countAcceptableChannels << " acceptable channels found : 0x" << std::hex
1114 << channelMaskFiltered << std::dec);
1115
1116 if (countAcceptableChannels == 0)
1117 {
1119 m_netFormParams = {};
1120 m_netFormParamsGen = nullptr;
1121
1123 {
1125 confirmParams.m_status = NwkStatus::STARTUP_FAILURE;
1127 }
1128 }
1129 else
1130 {
1131 MlmeScanRequestParams mlmeParams;
1132 mlmeParams.m_chPage = (channelMaskFiltered >> 27) & (0x01F);
1133 mlmeParams.m_scanChannels = channelMaskFiltered;
1135 mlmeParams.m_scanType = MLMESCAN_ACTIVE;
1136 m_mac->MlmeScanRequest(mlmeParams);
1137 }
1138 }
1139 }
1140 else if (m_pendPrimitiveNwk == NLME_NETWORK_FORMATION && params.m_scanType == MLMESCAN_ACTIVE)
1141 {
1142 // See Zigbee specification r22.1.0, Section 3.2.2.5.3,
1143 if (params.m_status == MacStatus::NO_BEACON || params.m_status == MacStatus::SUCCESS)
1144 {
1145 uint8_t channel = 0;
1146 uint8_t page = 0;
1147 uint16_t panId = 0;
1148
1149 // TODO: We should scan channels on each interface
1150 // (only possible when more interfaces (nwkMacInterfaceTable) are supported)
1151 // for now, only a single interface is considered.
1152
1153 if (params.m_status == MacStatus::NO_BEACON)
1154 {
1155 // All channels provided in the active scan were acceptable
1156 // (No coordinators found). Take the first channel in the list and
1157 // generate a random panid.
1158 for (uint8_t j = 11; j <= 26; j++)
1159 {
1160 if ((m_netFormParams.m_scanChannelList.channelsField[0] & (1 << j)) != 0)
1161 {
1162 channel = j;
1163 page = (m_netFormParams.m_scanChannelList.channelsField[0] >> 27) & (0x01F);
1164 break;
1165 }
1166 }
1167 //
1168 // Choose a random PAN ID (3.2.2.5.3 , d.ii.)
1169 panId = m_uniformRandomVariable->GetInteger(1, 0xFFF7);
1170 }
1171 else
1172 {
1173 // At least 1 coordinator was found in X channel
1174
1175 // TODO: Choose the channel with the lowest energy within the threshold.
1176 // If no channel is acceptable, return a NLME-NETWORK-FORMATION.confirm with
1177 // START_UP_FAILURE status (3.2.2.5.3 , d and e)
1178 NS_FATAL_ERROR("A coordinator found in active scan, but no channel judgment is "
1179 "supported, cannot complete network formation");
1180 /* uint32_t channelMask = m_netFormParams.m_scanChannelList.channelsField[0];
1181 for (uint32_t i=11; i<=26; i++)
1182 {
1183 if ((channelMask >> i) & 1)
1184 {
1185 // Channel found in mask, check energy channel and mark it if acceptable
1186 if (energyList[0] <= m_scanEnergyThreshold)
1187 {
1188 // energy is acceptable, register to filtered list
1189 channelMaskFiltered |= (1 << i) & (1 << i);
1190 energyList.erase(energyList.begin());
1191 countAcceptableChannels++;
1192 }
1193 }
1194 }*/
1195 }
1196
1197 // store the chosen page, channel and pan Id.
1199 m_netFormParamsGen->page = page;
1200 m_netFormParamsGen->channel = channel;
1201 m_netFormParamsGen->panId = panId;
1202
1203 NS_LOG_DEBUG("[NLME-NETWORK-FORMATION.request]: Active scan complete, page "
1204 << std::dec << static_cast<uint32_t>(page) << ", channel " << std::dec
1205 << static_cast<uint32_t>(channel) << " and PAN ID 0x" << std::hex << panId
1206 << std::dec << " chosen.");
1207
1208 // Set the device short address (3.2.2.5.3 , 6.f)
1211 {
1212 pibAttr->macShortAddress = m_netFormParams.m_distributedNetworkAddress;
1214 }
1215 else
1216 {
1217 pibAttr->macShortAddress = Mac16Address("00:00");
1219 }
1220 // Set Short Address and continue with beacon payload afterwards.
1221 m_mac->MlmeSetRequest(MacPibAttributeIdentifier::macShortAddress, pibAttr);
1222 }
1223 else
1224 {
1225 // Error occurred during network formation active scan
1226 // report to higher layer (Section 3.2.2.5.3, 6.d)
1227
1229 m_netFormParams = {};
1230 m_netFormParamsGen = nullptr;
1231
1233 {
1235 confirmParams.m_status = GetNwkStatus(params.m_status);
1237 }
1238
1239 NS_LOG_ERROR("Unknown error found during network formation");
1240 }
1241 }
1242 else if (m_pendPrimitiveNwk == NLME_NET_DISCV && params.m_scanType == MLMESCAN_ACTIVE)
1243 {
1244 NlmeNetworkDiscoveryConfirmParams netDiscConfirmParams;
1246
1247 if (params.m_status == MacStatus::SUCCESS)
1248 {
1249 NS_LOG_DEBUG("[NLME-NETWORK-DISCOVERY.request]: Active scan, "
1250 << m_networkDescriptorList.size() << " PARENT capable device(s) found");
1251
1252 netDiscConfirmParams.m_netDescList = m_networkDescriptorList;
1253 netDiscConfirmParams.m_networkCount = m_networkDescriptorList.size();
1254 netDiscConfirmParams.m_status = NwkStatus::SUCCESS;
1256 }
1257 else
1258 {
1259 NS_LOG_DEBUG("[NLME-NETWORK-DISCOVERY.request]: Active scan failed with"
1260 " status: "
1261 << static_cast<uint32_t>(GetNwkStatus(params.m_status)));
1262 netDiscConfirmParams.m_status = GetNwkStatus(params.m_status);
1263 }
1264
1266 {
1267 m_nlmeNetworkDiscoveryConfirmCallback(netDiscConfirmParams);
1268 }
1269 }
1270 else if (m_pendPrimitiveNwk == NLME_JOIN && params.m_scanType == MLMESCAN_ORPHAN)
1271 {
1272 // TODO: Add macInterfaceIndex and channelListStructure params when supported
1273 if (params.m_status == MacStatus::SUCCESS)
1274 {
1275 // Orphan scan was successful (Join success), first update the extended
1276 // PAN id and the capability information, then the
1277 // the nwkNetworkAddress with the macShortAddress, this
1278 // will be followed by an update of the m_nwkPanId with macPanId
1279 // and finally the join confirmation
1282 m_mac->MlmeGetRequest(MacPibAttributeIdentifier::macShortAddress);
1283 }
1284 else
1285 {
1287 m_joinParams = {};
1288 NS_LOG_DEBUG("[NLME-JOIN.request]: Orphan scan completed but no networks found");
1289
1291 {
1292 NlmeJoinConfirmParams joinConfirmParams;
1293 joinConfirmParams.m_status = NwkStatus::NO_NETWORKS;
1294 }
1295 }
1296 }
1297}
1298
1299void
1301{
1302 NS_LOG_FUNCTION(this);
1303
1305 {
1306 NlmeJoinConfirmParams joinConfirmParams;
1307 joinConfirmParams.m_extendedPanId = m_joinParams.m_extendedPanId;
1308 joinConfirmParams.m_enhancedBeacon = false; // hardcoded, no support
1309 joinConfirmParams.m_macInterfaceIndex = 0; // hardcoded, no support
1310 joinConfirmParams.m_networkAddress = params.m_assocShortAddr;
1311
1313
1314 if (params.m_status == MacStatus::SUCCESS)
1315 {
1316 joinConfirmParams.m_status = NwkStatus::SUCCESS;
1317 joinConfirmParams.m_networkAddress = params.m_assocShortAddr;
1318
1319 // Update NWK NIB values
1320 m_nwkNetworkAddress = params.m_assocShortAddr;
1323
1324 // Update relationship
1326 {
1327 entry->SetRelationship(NBR_PARENT);
1328 // m_nwkNeighborTable.Update(m_associateParams.extAddress, entry);
1329 NS_LOG_DEBUG("Associated SUCCESSFULLY to PAN ID and Ext PAN ID: "
1330 << "(0x" << std::hex << m_nwkPanId << " | 0x" << m_nwkExtendedPanId
1331 << ")" << std::dec);
1332 }
1333 else
1334 {
1335 NS_LOG_ERROR("Entry not found while updating relationship");
1336 }
1337 // TODO:m_nwkUpdateId
1338 }
1339 else
1340 {
1341 switch (params.m_status)
1342 {
1343 case MacStatus::ACCESS_DENIED:
1344 case MacStatus::FULL_CAPACITY:
1345 // Discard neighbor as potential parent
1347 {
1348 entry->SetPotentialParent(false);
1349 }
1350 else
1351 {
1352 NS_LOG_ERROR("Neighbor not found when discarding as potential parent");
1353 }
1354 joinConfirmParams.m_status = NwkStatus::NEIGHBOR_TABLE_FULL;
1355 break;
1356 case MacStatus::NO_ACK:
1357 joinConfirmParams.m_status = NwkStatus::NO_ACK;
1358 break;
1359 case MacStatus::CHANNEL_ACCESS_FAILURE:
1360 joinConfirmParams.m_status = NwkStatus::CHANNEL_ACCESS_FAILURE;
1361 break;
1362 default:
1363 joinConfirmParams.m_status = NwkStatus::INVALID_REQUEST;
1364 break;
1365 }
1366 }
1367
1369 m_joinParams = {};
1370 m_associateParams = {};
1371
1373 {
1374 m_nlmeJoinConfirmCallback(joinConfirmParams);
1375 }
1376 }
1377}
1378
1379void
1381{
1382 NS_LOG_FUNCTION(this);
1383
1384 NwkStatus nwkConfirmStatus;
1385
1386 switch (params.m_status)
1387 {
1388 case MacStatus::SUCCESS:
1389 nwkConfirmStatus = NwkStatus::SUCCESS;
1390 break;
1391 case MacStatus::NO_SHORT_ADDRESS:
1392 nwkConfirmStatus = NwkStatus::NO_SHORT_ADDRESS;
1393 break;
1394 case MacStatus::SUPERFRAME_OVERLAP:
1395 nwkConfirmStatus = NwkStatus::SUPERFRAME_OVERLAP;
1396 break;
1397 case MacStatus::TRACKING_OFF:
1398 nwkConfirmStatus = NwkStatus::TRACKING_OFF;
1399 break;
1400 case MacStatus::INVALID_PARAMETER:
1401 nwkConfirmStatus = NwkStatus::INVALID_PARAMETER;
1402 break;
1403 case MacStatus::COUNTER_ERROR:
1404 nwkConfirmStatus = NwkStatus::COUNTER_ERROR;
1405 break;
1406 case MacStatus::UNAVAILABLE_KEY:
1407 nwkConfirmStatus = NwkStatus::UNAVAILABLE_KEY;
1408 break;
1409 case MacStatus::UNSUPPORTED_SECURITY:
1410 nwkConfirmStatus = NwkStatus::UNSUPPORTED_SECURITY;
1411 break;
1412 case MacStatus::CHANNEL_ACCESS_FAILURE:
1413 nwkConfirmStatus = NwkStatus::CHANNEL_ACCESS_FAILURE;
1414 break;
1415 case MacStatus::FRAME_TOO_LONG:
1416 nwkConfirmStatus = NwkStatus::FRAME_TOO_LONG;
1417 break;
1418 default:
1419 nwkConfirmStatus = NwkStatus::STARTUP_FAILURE;
1421 m_netFormParams = {};
1422 m_netFormParamsGen = nullptr;
1423 m_nwkExtendedPanId = 0xffffffffffffffed;
1425 m_nwkPanId = 0xffff;
1426 break;
1427 }
1428
1430 {
1431 NS_LOG_DEBUG("[NLME-NETWORK-FORMATION.request]: Complete, Status "
1432 << nwkConfirmStatus << " | Pan Id and ExtPanId: (0x" << std::hex << m_nwkPanId
1433 << " | 0x" << m_nwkExtendedPanId << ")" << std::dec);
1434
1436 m_netFormParams = {};
1437 m_netFormParamsGen = nullptr;
1438
1440 {
1442 confirmParams.m_status = nwkConfirmStatus;
1444 }
1445 }
1447 {
1448 NS_LOG_DEBUG("[NLME-START-ROUTER.request]: Complete, Status "
1449 << nwkConfirmStatus << " | Pan Id and ExtPanId: (0x" << std::hex << m_nwkPanId
1450 << " | 0x" << m_nwkExtendedPanId << ")" << std::dec);
1451
1452 if (nwkConfirmStatus != NwkStatus::SUCCESS)
1453 {
1456 {
1457 NlmeStartRouterConfirmParams confirmParams;
1458 confirmParams.m_status = nwkConfirmStatus;
1459 m_nlmeStartRouterConfirmCallback(confirmParams);
1460 }
1461 }
1462 else
1463 {
1465 }
1466 }
1467}
1468
1469void
1471{
1472 NS_LOG_FUNCTION(this << params.id);
1473
1475 {
1476 if (params.m_status == MacStatus::SUCCESS &&
1477 params.id == MacPibAttributeIdentifier::macShortAddress)
1478 {
1479 // Section (3.2.2.5.3 , 6.g)
1480 // Getting this device MAC extended address using MLME-GET
1481 m_mac->MlmeGetRequest(MacPibAttributeIdentifier::macExtendedAddress);
1482 }
1483 else if (params.m_status == MacStatus::SUCCESS &&
1484 params.id == MacPibAttributeIdentifier::macBeaconPayload)
1485 {
1486 // Finalize Network Formation (Start network)
1487 MlmeStartRequestParams startParams;
1488 startParams.m_logCh = m_netFormParamsGen->channel;
1489 startParams.m_logChPage = m_netFormParamsGen->page;
1490 startParams.m_PanId = m_netFormParamsGen->panId;
1494 startParams.m_coorRealgn = false;
1495 startParams.m_panCoor = true;
1496 m_mac->MlmeStartRequest(startParams);
1497 }
1498 else if (params.m_status == MacStatus::SUCCESS &&
1499 params.id == MacPibAttributeIdentifier::macBeaconPayloadLength)
1500 {
1502 }
1503 else
1504 {
1506 m_netFormParams = {};
1507 m_netFormParamsGen = nullptr;
1508
1510 {
1512 confirmParams.m_status = NwkStatus::STARTUP_FAILURE;
1514 }
1515 }
1516 }
1518 {
1519 if (params.m_status == MacStatus::SUCCESS &&
1520 params.id == MacPibAttributeIdentifier::macBeaconPayloadLength)
1521 {
1523 }
1524 else
1525 {
1527
1529 m_joinIndParams = {};
1530
1532 {
1533 m_nlmeJoinIndicationCallback(joinIndParams);
1534 }
1535 }
1536 }
1538 {
1539 if (params.m_status == MacStatus::SUCCESS &&
1540 params.id == MacPibAttributeIdentifier::macBeaconPayloadLength)
1541 {
1543 }
1544 else if (params.m_status == MacStatus::SUCCESS &&
1545 params.id == MacPibAttributeIdentifier::macBeaconPayload)
1546 {
1549 {
1550 NlmeStartRouterConfirmParams confirmParams;
1551 confirmParams.m_status = NwkStatus::SUCCESS;
1552 m_nlmeStartRouterConfirmCallback(confirmParams);
1553 }
1554 }
1555 else
1556 {
1557 NS_LOG_ERROR("Beacon payload update failed during a NLME-START-ROUTER.request");
1558 }
1559 }
1560}
1561
1562void
1565 Ptr<MacPibAttributes> attribute)
1566{
1567 NS_LOG_FUNCTION(this);
1568
1570 {
1571 if (id == MacPibAttributeIdentifier::macExtendedAddress && status == MacStatus::SUCCESS)
1572 {
1573 // Section (3.2.2.5.3 , 6.g)
1574 // Set nwkExtendedPanId and m_nwkIeeeAddress and nwkPanId
1575 m_nwkIeeeAddress = attribute->macExtendedAddress;
1578
1579 // Configure the capability information of the PAN coordinator
1580 CapabilityInformation capaInfo;
1583
1584 // Set Beacon payload size followed by the beacon payload content
1585 // before starting a network
1586 // See Figure 3-37 Establishing a Network
1587 // See also 3.6.7.
1589 }
1590 else
1591 {
1593 m_netFormParams = {};
1594 m_netFormParamsGen = nullptr;
1595
1597 {
1599 confirmParams.m_status = NwkStatus::STARTUP_FAILURE;
1601 }
1602 }
1603 }
1604 else if (m_pendPrimitiveNwk == PendingPrimitiveNwk::NLME_JOIN && status == MacStatus::SUCCESS)
1605 {
1606 if (id == MacPibAttributeIdentifier::macShortAddress)
1607 {
1608 m_nwkNetworkAddress = attribute->macShortAddress;
1609 m_mac->MlmeGetRequest(MacPibAttributeIdentifier::macPanId);
1610 }
1611 else if (id == MacPibAttributeIdentifier::macPanId)
1612 {
1613 m_nwkPanId = attribute->macPanId;
1614
1615 NlmeJoinConfirmParams joinConfirmParams;
1616 joinConfirmParams.m_channelList = m_joinParams.m_scanChannelList;
1617 joinConfirmParams.m_status = NwkStatus::SUCCESS;
1618 joinConfirmParams.m_networkAddress = m_nwkNetworkAddress;
1619 joinConfirmParams.m_extendedPanId = m_nwkExtendedPanId;
1620 joinConfirmParams.m_enhancedBeacon = false;
1621
1623 m_joinParams = {};
1624
1626 {
1627 m_nlmeJoinConfirmCallback(joinConfirmParams);
1628 }
1629 }
1630 }
1631 else if (status == MacStatus::SUCCESS)
1632 {
1633 if (id == MacPibAttributeIdentifier::macExtendedAddress)
1634 {
1635 m_nwkIeeeAddress = attribute->macExtendedAddress;
1636 }
1637 else if (id == MacPibAttributeIdentifier::macShortAddress)
1638 {
1639 m_nwkNetworkAddress = attribute->macShortAddress;
1640 }
1641 else if (id == MacPibAttributeIdentifier::macPanId)
1642 {
1643 m_nwkPanId = attribute->macPanId;
1644 }
1645 else if (id == MacPibAttributeIdentifier::pCurrentChannel)
1646 {
1647 m_currentChannel = attribute->pCurrentChannel;
1648 }
1649 }
1650}
1651
1652void
1654{
1655 NS_LOG_FUNCTION(this);
1656
1658 MlmeOrphanResponseParams respParams;
1659
1660 if (m_nwkNeighborTable.LookUpEntry(params.m_orphanAddr, entry))
1661 {
1662 respParams.m_assocMember = true;
1663 respParams.m_orphanAddr = params.m_orphanAddr;
1664 respParams.m_shortAddr = entry->GetNwkAddr();
1665
1666 // Temporally store the NLME-JOIN.indications parameters that will be
1667 // returned after the DIRECT_JOIN process concludes.
1668 // (after MLME-COMM-STATUS.indication is received)
1669 CapabilityInformation capability;
1670 capability.SetReceiverOnWhenIdle(entry->IsRxOnWhenIdle());
1671
1672 if (entry->GetDeviceType() == NwkDeviceType::ZIGBEE_ROUTER)
1673 {
1675 }
1676 else if (entry->GetDeviceType() == NwkDeviceType::ZIGBEE_ENDDEVICE)
1677 {
1679 }
1681 m_joinIndParams.m_extendedAddress = params.m_orphanAddr;
1682 m_joinIndParams.m_networkAddress = entry->GetNwkAddr();
1684
1685 NS_LOG_DEBUG("[NLME-JOIN.request]: ["
1686 << params.m_orphanAddr << " | " << entry->GetNwkAddr()
1687 << "] found in neighbor table, responding to orphaned device");
1688
1689 m_mac->MlmeOrphanResponse(respParams);
1690 }
1691}
1692
1693void
1695{
1696 NS_LOG_FUNCTION(this);
1697
1698 // Return the results to the next layer of the router or coordinator
1699 // only after a SUCCESSFUL join to the network.
1700 if (params.m_status == MacStatus::SUCCESS)
1701 {
1702 if (params.m_dstExtAddr == m_joinIndParams.m_extendedAddress &&
1704 {
1706 m_joinIndParams = {};
1707
1709 {
1710 m_nlmeJoinIndicationCallback(joinIndParams);
1711 }
1712 }
1713 else if (params.m_dstExtAddr == m_joinIndParams.m_extendedAddress &&
1715 {
1718 }
1719 }
1720
1721 // TODO: Handle other situations for MlmeCommStatusIndication according
1722 // to the status and primitive in use.
1723}
1724
1725void
1727{
1728 NS_LOG_FUNCTION(this);
1729
1730 // Zigbee specification Section 3.6.1.3
1731 // Update Neighbor Table with information of the beacon payload
1732 // during a network-discovery
1733
1734 if ((params.m_sdu->GetSize() == 0) ||
1735 (params.m_panDescriptor.m_coorAddrMode != lrwpan::AddressMode::SHORT_ADDR))
1736 {
1737 // The beacon do not contain beacon payload or is for a different network
1738 // stop any further process.
1739 return;
1740 }
1741
1742 ZigbeeBeaconPayload beaconPayload;
1743 params.m_sdu->RemoveHeader(beaconPayload);
1744
1745 if (beaconPayload.GetProtocolId() != 0)
1746 {
1747 return;
1748 }
1749
1750 // TODO: Add a Permit to join, stack profile , update id and capability check
1751
1753 {
1754 // Keep a network descriptor list from the information in the beacon
1755 // to later on pass to the next higher layer when the network-discovery
1756 // process is over (NLME-NETWORK-DISCOVERY.confirm)
1757 NetworkDescriptor descriptor;
1758 descriptor.m_extPanId = beaconPayload.GetExtPanId();
1759 descriptor.m_panId = params.m_panDescriptor.m_coorPanId;
1760 descriptor.m_updateId = 0; // TODO: unknown
1761 descriptor.m_logCh = params.m_panDescriptor.m_logCh;
1762 descriptor.m_stackProfile = static_cast<StackProfile>(beaconPayload.GetStackProfile());
1763 descriptor.m_zigbeeVersion = beaconPayload.GetProtocolId();
1764
1765 SuperframeInformation superframe(params.m_panDescriptor.m_superframeSpec);
1766 descriptor.m_beaconOrder = superframe.GetBeaconOrder();
1767 descriptor.m_superframeOrder = superframe.GetFrameOrder();
1768 descriptor.m_permitJoining = superframe.IsAssocPermit();
1769
1770 descriptor.m_routerCapacity = beaconPayload.GetRouterCapacity();
1771 descriptor.m_endDeviceCapacity = beaconPayload.GetEndDevCapacity();
1772 m_networkDescriptorList.emplace_back(descriptor);
1773
1774 // Keep track of the pan id (16 bits) and the extended PAN id for
1775 // future join (association) procedures.
1776 m_panIdTable.AddEntry(descriptor.m_extPanId, descriptor.m_panId);
1777 // NOTE: In Zigbee all PAN coordinators or routers work with a
1778 // SOURCE short address addressing mode, therefore the PAN descriptors only
1779 // contain the short address.
1780 NS_LOG_DEBUG("Received beacon frame from [" << params.m_panDescriptor.m_coorShortAddr
1781 << "]");
1782 }
1783
1785 if (m_nwkNeighborTable.LookUpEntry(params.m_panDescriptor.m_coorShortAddr, entry))
1786 {
1787 // Update Neighbor table with the info of the received beacon
1788
1789 entry->SetNwkAddr(params.m_panDescriptor.m_coorShortAddr);
1790 entry->SetTimeoutCounter(Seconds(15728640));
1792 entry->SetLqi(params.m_panDescriptor.m_linkQuality);
1793 entry->SetOutgoingCost(GetLQINonLinearValue(params.m_panDescriptor.m_linkQuality));
1794 // m_nwkNeighborTable.Update(params.m_panDescriptor.m_coorShortAddr, entry);
1795 // TODO: Update other fields if necessary and
1796 // Additional and optional fields.
1797 }
1798 else
1799 {
1800 // Add a new entry to the neighbor table, information comes from
1801 // the MAC PAN descriptor and the beacon payload received.
1802 NwkDeviceType devType;
1803 if (params.m_panDescriptor.m_coorShortAddr == Mac16Address("00:00"))
1804 {
1806 }
1807 else
1808 {
1810 }
1811
1812 // Create neighbor table entry with the basic fields
1813 Ptr<NeighborTableEntry> newEntry =
1814 Create<NeighborTableEntry>(Mac64Address("FF:FF:FF:FF:FF:FF:FF:FF"),
1815 params.m_panDescriptor.m_coorShortAddr,
1816 devType,
1817 true,
1818 0,
1819 Seconds(15728640),
1821 NBR_NONE,
1822 0,
1823 params.m_panDescriptor.m_linkQuality,
1824 GetLQINonLinearValue(params.m_panDescriptor.m_linkQuality),
1825 0,
1826 false,
1827 0);
1828
1829 // If necessary add information to the
1830 // additional and optional fields. Currently only 2 additional fields are added:
1831 newEntry->SetExtPanId(beaconPayload.GetExtPanId());
1832 newEntry->SetLogicalCh(params.m_panDescriptor.m_logCh);
1833
1834 m_nwkNeighborTable.AddEntry(newEntry);
1835 }
1836}
1837
1838void
1840{
1841 NS_LOG_FUNCTION(this);
1842
1843 // Joining Procedure through Association (Parent procedure)
1844 // Zigbee Specification 3.6.1.4.1
1845
1846 CapabilityInformation receivedCapability(params.capabilityInfo);
1847 auto devType = static_cast<NwkDeviceType>(receivedCapability.GetDeviceType());
1848
1850 if (m_nwkNeighborTable.LookUpEntry(params.m_extDevAddr, entry))
1851 {
1852 if (entry->GetDeviceType() == devType)
1853 {
1854 MlmeAssociateResponseParams responseParams;
1855 responseParams.m_status = MacStatus::SUCCESS;
1856 responseParams.m_assocShortAddr = entry->GetNwkAddr();
1857 responseParams.m_extDevAddr = entry->GetExtAddr();
1858 m_mac->MlmeAssociateResponse(responseParams);
1859 }
1860 else
1861 {
1862 m_nwkNeighborTable.Delete(params.m_extDevAddr);
1864 }
1865 }
1866 else
1867 {
1868 // Device currently do not exist in coordinator,
1869 // allocate an address and add to neighbor table.
1870
1871 Mac16Address allocatedAddr;
1872 if (receivedCapability.IsAllocateAddrOn())
1873 {
1874 allocatedAddr = AllocateNetworkAddress();
1875 }
1876 else
1877 {
1878 // The device is associated but it will only use its
1879 // extended address (EUI-64 also known as IEEE Address)
1880 allocatedAddr = Mac16Address("FF:FE");
1881 }
1882
1883 CapabilityInformation capability(params.capabilityInfo);
1884
1885 Ptr<NeighborTableEntry> newEntry =
1886 Create<NeighborTableEntry>(params.m_extDevAddr,
1887 allocatedAddr,
1888 devType,
1889 capability.IsReceiverOnWhenIdle(),
1890 0,
1891 Seconds(15728640),
1893 NBR_CHILD,
1894 0,
1895 params.lqi,
1896 0,
1897 0,
1898 true,
1899 0);
1900 // Optional parameters
1901 newEntry->SetExtPanId(m_nwkExtendedPanId);
1902
1903 MlmeAssociateResponseParams responseParams;
1904 responseParams.m_extDevAddr = params.m_extDevAddr;
1905
1906 if (m_nwkNeighborTable.AddEntry(newEntry))
1907 {
1908 responseParams.m_status = MacStatus::SUCCESS;
1909 responseParams.m_assocShortAddr = allocatedAddr;
1910
1911 // Temporally store the NLME-JOIN.indications parameters that will be
1912 // returned after the association process concludes.
1913 // (after MLME-COMM-STATUS.indication received and beacon payload updated)
1914 m_joinIndParams.m_capabilityInfo = receivedCapability.GetCapability();
1915 m_joinIndParams.m_extendedAddress = params.m_extDevAddr;
1916 m_joinIndParams.m_networkAddress = allocatedAddr;
1918 }
1919 else
1920 {
1921 responseParams.m_status = MacStatus::FULL_CAPACITY;
1922 responseParams.m_assocShortAddr = Mac16Address("FF:FF");
1923 }
1924
1925 NS_LOG_DEBUG("Storing an Associate response command with the allocated"
1926 " address "
1927 << responseParams.m_assocShortAddr);
1928
1929 m_mac->MlmeAssociateResponse(responseParams);
1930 }
1931}
1932
1933void
1935{
1936 NS_LOG_FUNCTION(this << packet);
1937
1938 if (params.m_dstAddr == m_nwkNetworkAddress)
1939 {
1940 NS_LOG_DEBUG("The source and the destination of the route request are the same!");
1941 return;
1942 }
1943
1944 // Zigbee specification r22.1.0, Section 3.2.1.1.3 and Section 3.6.2.1
1945 // check that we are associated
1946 if (m_nwkNetworkAddress == "FF:FF")
1947 {
1948 NS_LOG_DEBUG("Cannot send data, the device is not currently associated");
1949
1951 {
1952 NldeDataConfirmParams confirmParams;
1953 confirmParams.m_status = NwkStatus::INVALID_REQUEST;
1954 confirmParams.m_txTime = Simulator::Now();
1955 confirmParams.m_nsduHandle = params.m_nsduHandle;
1956 m_nldeDataConfirmCallback(confirmParams);
1957 }
1958 return;
1959 }
1960
1961 // Constructing the NPDU (Zigbee specification r22.1.0, Section 3.2.1.1.3 and Section 3.6.2.1)
1962 ZigbeeNwkHeader nwkHeader;
1963 nwkHeader.SetFrameType(DATA);
1964 nwkHeader.SetProtocolVer(3);
1965 nwkHeader.SetDiscoverRoute(static_cast<DiscoverRouteType>(params.m_discoverRoute));
1966 nwkHeader.SetDstAddr(params.m_dstAddr);
1967
1968 if (params.m_useAlias)
1969 {
1970 nwkHeader.SetSrcAddr(params.m_aliasSrcAddr);
1971 nwkHeader.SetSeqNum(params.m_aliasSeqNumber.GetValue());
1972 }
1973 else
1974 {
1977 }
1978
1979 if (params.m_radius == 0)
1980 {
1981 nwkHeader.SetRadius(m_nwkMaxDepth * 2);
1982 }
1983 else
1984 {
1985 nwkHeader.SetRadius(params.m_radius);
1986 }
1987
1988 if (params.m_securityEnable)
1989 {
1990 // TODO: Secure processing (Section 3.6.2.1)
1991 NS_ABORT_MSG("Security processing is currently not supported");
1992 }
1993
1994 // Check the current device capabilities
1995 CapabilityInformation capability;
1997
1998 if (capability.GetDeviceType() == ENDDEVICE)
1999 {
2000 nwkHeader.SetEndDeviceInitiator();
2001 }
2002
2003 if (params.m_dstAddrMode == MCST)
2004 {
2005 nwkHeader.SetMulticast();
2006 // TODO:
2007 // set the nwkHeader multicast control according to
2008 // the values of the non-member radios parameter
2009 // See 3.2.1.1.3
2010 }
2011
2012 packet->AddHeader(nwkHeader);
2013
2014 if (capability.GetDeviceType() == ROUTER)
2015 {
2016 if (params.m_dstAddrMode == MCST)
2017 {
2018 // The destination is MULTICAST (See 3.6.2)
2019 NS_ABORT_MSG("Multicast is currently not supported");
2020 // TODO
2021 return;
2022 }
2023 else if (IsBroadcastAddress(params.m_dstAddr))
2024 {
2025 // The destination is BROADCAST (See 3.6.5)
2026 SendDataBcst(packet, params.m_nsduHandle);
2027 }
2028 else
2029 {
2030 // The destination is UNICAST (See 3.6.3.3)
2031 SendDataUcst(packet, params.m_nsduHandle);
2032 }
2033 }
2034 else
2035 {
2036 // The device is an END DEVICE
2037 // direct message to its Parent device (Coordinator)
2039 if (m_nwkNeighborTable.GetParent(entry))
2040 {
2041 // Buffer a copy of the DATA packet that will be transmitted
2042 // for handling after transmission (i.e. NSDE-DATA.confirm)
2043 BufferTxPkt(packet->Copy(), m_macHandle.GetValue(), params.m_nsduHandle);
2044
2045 McpsDataRequestParams mcpsDataparams;
2046 mcpsDataparams.m_txOptions = 0x01; // Acknowledment on.
2047 mcpsDataparams.m_dstPanId = m_nwkPanId;
2048 mcpsDataparams.m_msduHandle = m_macHandle.GetValue();
2049 mcpsDataparams.m_srcAddrMode = SHORT_ADDR;
2050 mcpsDataparams.m_dstAddrMode = SHORT_ADDR;
2051 mcpsDataparams.m_dstAddr = entry->GetNwkAddr();
2052 m_macHandle++;
2053 m_mac->McpsDataRequest(mcpsDataparams, packet);
2054 }
2055 else
2056 {
2057 // Section 3.6.3.7.1
2058 // Link failure with Parent device
2059 // TODO
2060 /*
2061 if (!m_nlmeNwkStatusIndicationCallback.IsNull())
2062 {
2063 NlmeNetworkStatusIndication indicationParams;
2064
2065 m_networkStatusCode = PARENT_LINK_FAILURE;
2066 m_nlmeNwkStatusIndicationCallback(confirmParams);
2067 }
2068 */
2069 }
2070 }
2072}
2073
2074void
2076{
2077 NS_LOG_FUNCTION(this);
2078
2081 "channelsField and its channelPageCount size do not match "
2082 "in networkFormationParams");
2083
2085 {
2087 m_netFormParams = {};
2088 m_netFormParamsGen = nullptr;
2089
2091 {
2093 confirmParams.m_status = NwkStatus::INVALID_REQUEST;
2095 }
2096 return;
2097 }
2098
2099 if (params.m_distributedNetwork)
2100 {
2101 // Zigbee Specification r22.1.0, 3.2.2.5 , 3)
2102 // Verify Distributed Network Address is in a valid range.
2103 // TODO: Verify the address is not > 0xFFF7
2104 if (params.m_distributedNetwork == Mac16Address("00:00"))
2105 {
2107 m_netFormParams = {};
2108 m_netFormParamsGen = nullptr;
2109
2111 {
2113 confirmParams.m_status = NwkStatus::INVALID_REQUEST;
2115 }
2116 return;
2117 }
2118 }
2119
2120 // 4. On receipt of this primitive the NLME shall first validate the
2121 // ChannelListStructure parameter according to section 3.2.2.2.2.
2122 // (if nwkMacInterfaceTable support is added)
2123 // If validation fails the NLME-NETWORK-FORMATION.confirm
2124 // primitive shall be issued with a Status parameter set to INVALID_PARAMETER.
2125
2126 if (params.m_scanChannelList.channelPageCount != 1)
2127 {
2128 NS_FATAL_ERROR("Multi page scanning not supported");
2129 }
2130
2131 // Only page 0 is supported (O-QPSK 250 kbps)
2132 // Take 5 MSB bits: b27-b31 to check the page
2133 uint32_t page = (params.m_scanChannelList.channelsField[0] >> 27) & (0x01F);
2134
2135 if (page != 0)
2136 {
2137 NS_FATAL_ERROR("PHY band not supported (Only page 0 is supported)");
2138 }
2139
2140 uint8_t channelsCount = 0;
2141 for (int i = 11; i <= 26; i++)
2142 {
2143 channelsCount += (params.m_scanChannelList.channelsField[0] >> i) & 1;
2144 }
2145
2147 m_netFormParams = params;
2148
2149 if (channelsCount == 1)
2150 {
2151 // There is only 1 channel, skip energy scan and go directly to
2152 // active scan instead
2153 MlmeScanRequestParams mlmeParams;
2154 mlmeParams.m_chPage = page;
2155 mlmeParams.m_scanChannels = params.m_scanChannelList.channelsField[0];
2156 mlmeParams.m_scanDuration = params.m_scanDuration;
2157 mlmeParams.m_scanType = MLMESCAN_ACTIVE;
2158 m_mac->MlmeScanRequest(mlmeParams);
2159 }
2160 else if (channelsCount > 1)
2161 {
2162 MlmeScanRequestParams mlmeParams;
2163 mlmeParams.m_chPage = page;
2164 mlmeParams.m_scanChannels = params.m_scanChannelList.channelsField[0];
2165 mlmeParams.m_scanDuration = params.m_scanDuration;
2166 mlmeParams.m_scanType = MLMESCAN_ED;
2167 m_mac->MlmeScanRequest(mlmeParams);
2168 }
2169}
2170
2171void
2173{
2174 NS_LOG_FUNCTION(this);
2175
2176 if (params.m_dstAddr == m_nwkNetworkAddress && params.m_dstAddrMode == UCST_BCST)
2177 {
2178 NS_FATAL_ERROR("The source and the destination of the route request are the same!");
2179 return;
2180 }
2181
2182 // (See 3.2.2.33.3)
2183 // - Check the device has routing capacity
2184 // - Check the device dstAddrMode != NO_ADDRESS && dst != Broadcast address
2185 if (params.m_dstAddrMode != NO_ADDRESS && IsBroadcastAddress(params.m_dstAddr))
2186 {
2188 {
2189 NlmeRouteDiscoveryConfirmParams confirmParams;
2190 confirmParams.m_status = NwkStatus::INVALID_REQUEST;
2192 }
2193 return;
2194 }
2195
2196 CapabilityInformation capability;
2198 if (capability.GetDeviceType() != ROUTER && params.m_dstAddrMode != NO_ADDRESS)
2199 {
2201 {
2202 NlmeRouteDiscoveryConfirmParams confirmParams;
2203 confirmParams.m_status = NwkStatus::ROUTE_ERROR;
2205 }
2206 return;
2207 }
2208
2210
2211 ZigbeeNwkHeader nwkHeader;
2212 nwkHeader.SetFrameType(NWK_COMMAND);
2215 // See r22.1.0, Table 3-69
2216 // Set destination to broadcast (all routers and coordinator)
2217 nwkHeader.SetDstAddr(Mac16Address("FF:FC"));
2220
2223 payload.SetPathCost(0);
2224
2225 if (params.m_dstAddrMode == UCST_BCST)
2226 {
2227 // Set the rest of the nwkHeader and command payload parameters
2228 // as described in Zigbee specification, Section 3.2.2.33.3
2229 if (params.m_radius == 0)
2230 {
2231 nwkHeader.SetRadius(m_nwkMaxDepth * 2);
2232 }
2233 else
2234 {
2235 nwkHeader.SetRadius(params.m_radius);
2236 }
2237
2238 payload.SetDstAddr(params.m_dstAddr);
2239
2240 Mac16Address nextHop;
2241 RouteDiscoveryStatus routeStatus =
2242 FindNextHop(m_nwkNetworkAddress, 0, nwkHeader, payload, nextHop);
2243
2244 if (routeStatus == ROUTE_FOUND)
2245 {
2247 {
2248 NlmeRouteDiscoveryConfirmParams confirmParams;
2249 confirmParams.m_status = NwkStatus::SUCCESS;
2251 }
2252 }
2253 else if (routeStatus == ROUTE_NOT_FOUND)
2254 {
2255 // Route not found. Route marked as DISCOVER UNDERWAY,
2256 // we initiate route discovery.
2259 this,
2260 nwkHeader,
2261 payload,
2263
2266 }
2267 }
2268 else if (params.m_dstAddrMode == MCST)
2269 {
2270 NS_ABORT_MSG("Multicast Route discovery not supported");
2271 }
2272 else if (params.m_dstAddrMode == NO_ADDRESS)
2273 {
2274 // Many-to-one route discovery.
2275 // (See Last paragraph of Zigbee Specification, Section 3.6.3.5.1)
2276 m_nwkIsConcentrator = true;
2277
2279
2280 payload.SetDstAddr(Mac16Address("FF:FF"));
2281 if (params.m_noRouteCache)
2282 {
2284 }
2285 else
2286 {
2288 }
2289
2290 RouteDiscoveryStatus routeStatus =
2291 ProcessManyToOneRoute(m_nwkNetworkAddress, 0, nwkHeader, payload);
2292
2293 if (routeStatus == MANY_TO_ONE_ROUTE || routeStatus == ROUTE_UPDATED)
2294 {
2295 // TODO if nwkConcentratorDiscoveryTime != 0, schedule
2296 // RREQ every nwkConcentratorDiscovery time.
2297
2300 this,
2301 nwkHeader,
2302 payload,
2303 0);
2306 }
2307 }
2308}
2309
2310void
2312{
2313 NS_LOG_FUNCTION(this);
2314
2315 if (params.m_scanDuration > 14)
2316 {
2317 NS_FATAL_ERROR("Scan duration must be an int between 0 and 14");
2318 }
2319
2320 if (params.m_scanChannelList.channelPageCount != params.m_scanChannelList.channelsField.size())
2321 {
2322 NS_FATAL_ERROR("In scanChannelList parameter, channelPageCount "
2323 "and the channelsField structure size does not match");
2324 }
2325
2326 // TODO: Add support to scan other MAC interfaces, for the moment
2327 // only a single interface and only Page 0 is supported (PHY O-QPSK 250 kbps)
2328
2329 if (params.m_scanChannelList.channelsField.size() != 1)
2330 {
2331 NS_FATAL_ERROR("Only a single MAC interface supported");
2332 }
2333
2334 uint8_t page = (params.m_scanChannelList.channelsField[0] >> 27) & (0x01F);
2335 if (page != 0)
2336 {
2337 NS_FATAL_ERROR("Only Page 0 (O-QPSK 250 kbps) is supported.");
2338 }
2339
2341
2342 MlmeScanRequestParams scanParams;
2343 scanParams.m_chPage = 0; // Only page 0 is supported.
2344 scanParams.m_scanChannels = params.m_scanChannelList.channelsField[0];
2345 scanParams.m_scanDuration = params.m_scanDuration;
2346 scanParams.m_scanType = MLMESCAN_ACTIVE;
2347
2348 NS_LOG_DEBUG("Active scanning started, "
2349 << " on page " << static_cast<uint32_t>(page) << " and channels 0x" << std::hex
2350 << params.m_scanChannelList.channelsField[0] << std::dec);
2351 m_mac->MlmeScanRequest(scanParams);
2352}
2353
2354void
2356{
2357 NS_LOG_FUNCTION(this);
2358
2359 // TODO: Check the device is router or coordinator, send invalid_request
2360 // status otherwise. See 3.6.1.4.3.
2361
2363 if (m_nwkNeighborTable.LookUpEntry(params.m_deviceAddr, entry))
2364 {
2365 NS_LOG_WARN("[NLME-DIRECT-JOIN.request]: "
2366 "Device already present in neighbor table. ");
2367
2369 {
2370 NlmeDirectJoinConfirmParams confirmParams;
2371 confirmParams.m_status = NwkStatus::ALREADY_PRESENT;
2372 confirmParams.m_deviceAddr = params.m_deviceAddr;
2373 m_nlmeDirectJoinConfirmCallback(confirmParams);
2374 }
2375 }
2376 else
2377 {
2378 CapabilityInformation capaInfo;
2379 capaInfo.SetCapability(params.m_capabilityInfo);
2380
2381 Mac16Address allocatedAddr;
2382 if (capaInfo.IsAllocateAddrOn())
2383 {
2384 allocatedAddr = AllocateNetworkAddress();
2385 }
2386 else
2387 {
2388 // The device is associated but it will only use its
2389 // extended address (EUI-64 also known as IEEE Address)
2390 allocatedAddr = Mac16Address("FF:FE");
2391 }
2392
2393 NwkDeviceType devType;
2394 if (capaInfo.GetDeviceType() == MacDeviceType::ROUTER)
2395 {
2397 }
2398 else
2399 {
2401 }
2402
2403 Ptr<NeighborTableEntry> newEntry =
2404 Create<NeighborTableEntry>(params.m_deviceAddr,
2405 allocatedAddr,
2406 devType,
2407 capaInfo.IsReceiverOnWhenIdle(),
2408 0,
2409 Seconds(15728640),
2411 NBR_CHILD,
2412 0,
2413 255,
2414 0,
2415 0,
2416 true,
2417 0);
2418
2419 NlmeDirectJoinConfirmParams confirmParams;
2420
2421 if (m_nwkNeighborTable.AddEntry(newEntry))
2422 {
2423 NS_LOG_DEBUG("Device added to neighbor table (" << m_nwkNeighborTable.GetSize()
2424 << ") with address [" << allocatedAddr
2425 << " | " << params.m_deviceAddr << "]");
2427 {
2428 confirmParams.m_status = NwkStatus::SUCCESS;
2429 confirmParams.m_deviceAddr = params.m_deviceAddr;
2430 m_nlmeDirectJoinConfirmCallback(confirmParams);
2431 }
2432 }
2433 else
2434 {
2435 NS_LOG_WARN("Error, neighbor table is full");
2437 {
2439 confirmParams.m_deviceAddr = params.m_deviceAddr;
2440 m_nlmeDirectJoinConfirmCallback(confirmParams);
2441 }
2442 }
2443 }
2444}
2445
2446void
2448{
2449 NS_LOG_FUNCTION(this);
2450
2451 if (params.m_scanDuration > 14)
2452 {
2453 NS_FATAL_ERROR("Scan duration must be an int between 0 and 14");
2454 }
2455
2456 if (params.m_scanChannelList.channelPageCount != params.m_scanChannelList.channelsField.size())
2457 {
2458 NS_FATAL_ERROR("In scanChannelList parameter, channelPageCount "
2459 "and the channelsField structure size does not match");
2460 }
2461
2462 // TODO: Add support to scan other MAC interfaces, for the moment
2463 // only a single interface and only Page 0 is supported (PHY O-QPSK 250 kbps)
2464
2465 // TODO: Only devices who have not join another network can call JOIN.
2466
2467 if (params.m_scanChannelList.channelsField.size() != 1)
2468 {
2469 NS_FATAL_ERROR("Only a single MAC interface supported");
2470 }
2471
2472 uint8_t page = (params.m_scanChannelList.channelsField[0] >> 27) & (0x01F);
2473 if (page != 0)
2474 {
2475 NS_FATAL_ERROR("Only Page 0 (O-QPSK 250 kbps) is supported.");
2476 }
2477
2479 m_joinParams = params;
2480
2481 if (params.m_rejoinNetwork == DIRECT_OR_REJOIN)
2482 {
2483 // Zigbee specification r22.1.0 Section 3.6.1.4.3.1,
2484 // Child procedure for joining or re-joining a network through
2485 // orphaning (DIRECT JOIN procedure).
2486
2487 MlmeScanRequestParams scanParams;
2488 scanParams.m_chPage = page;
2489 scanParams.m_scanChannels = params.m_scanChannelList.channelsField[0];
2490
2491 // Note: Scan duration is fixed to a macResponseWaitTime in an Orphan scan
2492 // (i.e. It does not use the scanDuration parameter)
2493 scanParams.m_scanType = MLMESCAN_ORPHAN;
2494 NS_LOG_DEBUG("Orphan scanning started, "
2495 << "sending orphan notifications on page " << static_cast<uint32_t>(page)
2496 << " and channels " << std::hex << params.m_scanChannelList.channelsField[0]);
2497 m_mac->MlmeScanRequest(scanParams);
2498 }
2499 else if (params.m_rejoinNetwork == ASSOCIATION)
2500 {
2501 // Check if we have the MAC pan id info recorded during the discovery process
2502 uint16_t panId;
2503 if (!m_panIdTable.GetEntry(params.m_extendedPanId, panId))
2504 {
2505 NS_LOG_ERROR("Error PAN id of neighbor device not found");
2506 }
2507
2508 // Zigbee specification r22.1.0 Section 3.6.1.4.1
2509 // Child procedure for joining a network through ASSOCIATION.
2510
2511 NlmeJoinConfirmParams joinConfirmParams;
2512 Ptr<NeighborTableEntry> bestParentEntry;
2513
2514 if (m_nwkNeighborTable.LookUpForBestParent(params.m_extendedPanId, bestParentEntry))
2515 {
2516 MlmeAssociateRequestParams assocParams;
2517 m_nwkCapabilityInformation = params.m_capabilityInfo;
2518
2519 assocParams.m_chNum = bestParentEntry->GetLogicalCh();
2520 assocParams.m_chPage = 0; // Zigbee assumes Page is always 0
2521 assocParams.m_capabilityInfo = params.m_capabilityInfo;
2522 assocParams.m_coordPanId = panId;
2523
2524 if (bestParentEntry->GetNwkAddr() != Mac16Address("FF:FE"))
2525 {
2527 assocParams.m_coordShortAddr = bestParentEntry->GetNwkAddr();
2528 NS_LOG_DEBUG("Send Assoc. Req. to [" << bestParentEntry->GetNwkAddr()
2529 << "] in PAN id and Ext PAN id: " << std::hex
2530 << "(0x" << panId << " | 0x"
2531 << params.m_extendedPanId << ")" << std::dec);
2532 }
2533 else
2534 {
2536 assocParams.m_coordExtAddr = bestParentEntry->GetExtAddr();
2537 NS_LOG_DEBUG("Send Assoc. Req. to [" << bestParentEntry->GetNwkAddr()
2538 << "] in \nPAN id and Ext PAN id: " << std::hex
2539 << "(0x" << panId << " | 0x"
2540 << params.m_extendedPanId << ")" << std::dec);
2541 }
2542
2544 m_nwkCapabilityInformation = params.m_capabilityInfo;
2545
2546 // Temporally store some associate values until the process concludes
2547 m_associateParams.panId = panId;
2548 m_associateParams.extAddress = bestParentEntry->GetExtAddr();
2549
2550 m_mac->MlmeAssociateRequest(assocParams);
2551 }
2552 else
2553 {
2555 m_joinParams = {};
2556
2558 {
2559 joinConfirmParams.m_extendedPanId = params.m_extendedPanId;
2560 joinConfirmParams.m_networkAddress = Mac16Address("FF:FF");
2561 joinConfirmParams.m_enhancedBeacon = false;
2562 joinConfirmParams.m_macInterfaceIndex = 0;
2563 joinConfirmParams.m_status = NwkStatus::NOT_PERMITED;
2564 m_nlmeJoinConfirmCallback(joinConfirmParams);
2565 }
2566 }
2567 }
2568 else
2569 {
2570 NS_FATAL_ERROR("Joining method not supported");
2571 }
2572}
2573
2574void
2576{
2577 NS_LOG_FUNCTION(this);
2578
2579 NS_ASSERT_MSG(params.m_beaconOrder == 15, "Beacon mode not supported for zigbee");
2580 NS_ASSERT_MSG(params.m_superframeOrder == 15, "Beacon mode not supported for zigbee");
2581
2582 CapabilityInformation capability;
2584
2585 if (capability.GetDeviceType() != MacDeviceType::ROUTER)
2586 {
2588 {
2589 NlmeStartRouterConfirmParams confirmParams;
2590 confirmParams.m_status = NwkStatus::INVALID_REQUEST;
2591 m_nlmeStartRouterConfirmCallback(confirmParams);
2592 }
2593 NS_LOG_ERROR("This device is not a Zigbee Router or is not joined to this network");
2594 }
2595 else
2596 {
2598
2599 // request an update of the current channel in use in the PHY
2600 m_mac->MlmeGetRequest(MacPibAttributeIdentifier::pCurrentChannel);
2601
2602 // TODO: MLME-START.request should be issue to all the interfaces in the
2603 // nwkMacInterfaceTable (currently not supported), for the moment only a single
2604 // interface is supported.
2605 MlmeStartRequestParams startParams;
2606 startParams.m_logCh = m_currentChannel;
2607 startParams.m_logChPage = 0; // In zigbee, only page 0 is supported.
2608 startParams.m_PanId = m_nwkPanId;
2609 startParams.m_bcnOrd = params.m_beaconOrder;
2610 startParams.m_sfrmOrd = params.m_superframeOrder;
2611 startParams.m_battLifeExt = params.m_batteryLifeExt;
2612 startParams.m_coorRealgn = false;
2613 startParams.m_panCoor = false;
2614 m_mac->MlmeStartRequest(startParams);
2615 }
2616}
2617
2618void
2623
2624void
2629
2630void
2635
2636void
2641
2642void
2647
2648void
2653
2654void
2659
2660void
2665
2666void
2671
2672void
2674{
2675 // TODO : PurgeTxQueue();
2677 {
2678 ZigbeeNwkHeader peekedNwkHeader;
2679 p->PeekHeader(peekedNwkHeader);
2680
2681 Ptr<PendingTxPkt> pendingTxPkt = Create<PendingTxPkt>();
2682 pendingTxPkt->dstAddr = peekedNwkHeader.GetDstAddr();
2683 pendingTxPkt->nsduHandle = nsduHandle;
2684 pendingTxPkt->txPkt = p;
2685 // TODO: expiration time here
2686 m_pendingTxQueue.emplace_back(pendingTxPkt);
2687 // TODO: pending trace here
2688 }
2689 else
2690 {
2691 // TODO: Drop trace here
2692 }
2693}
2694
2695bool
2697{
2698 // TODO : PurgeTxQueue();
2699
2700 /* std::erase_if(m_pendingTxQueue, [&dst](Ptr<PendingTxPkt> pkt) {
2701 return pkt->dstAddr == dst;
2702 });*/
2703
2704 for (auto iter = m_pendingTxQueue.begin(); iter != m_pendingTxQueue.end(); iter++)
2705 {
2706 if ((*iter)->dstAddr == dst)
2707 {
2708 *entry = **iter;
2709 // TODO: Dequeue trace if needed here.
2710 m_pendingTxQueue.erase(iter);
2711 return true;
2712 }
2713 }
2714 return false;
2715}
2716
2717void
2719{
2720 for (auto element : m_pendingTxQueue)
2721 {
2722 element = nullptr;
2723 }
2724 m_pendingTxQueue.clear();
2725}
2726
2727void
2728ZigbeeNwk::BufferTxPkt(Ptr<Packet> p, uint8_t macHandle, uint8_t nwkHandle)
2729{
2730 if (m_txBuffer.size() < m_txBufferMaxSize)
2731 {
2732 Ptr<TxPkt> txPkt = Create<TxPkt>();
2733 txPkt->macHandle = macHandle;
2734 txPkt->nwkHandle = nwkHandle;
2735 txPkt->txPkt = p;
2736 m_txBuffer.emplace_back(txPkt);
2737 }
2738 else
2739 {
2740 NS_LOG_DEBUG("Zigbee Tx Buffer is full, packet dropped.");
2741 // TODO : Drop trace for TX buffer
2742 }
2743}
2744
2745bool
2746ZigbeeNwk::RetrieveTxPkt(uint8_t macHandle, Ptr<TxPkt>& txPkt)
2747{
2748 for (auto bufferedPkt : m_txBuffer)
2749 {
2750 if (bufferedPkt->macHandle == macHandle)
2751 {
2752 txPkt = bufferedPkt;
2753
2754 std::erase_if(m_txBuffer,
2755 [&macHandle](Ptr<TxPkt> pkt) { return pkt->macHandle == macHandle; });
2756
2757 return true;
2758 }
2759 }
2760 return false;
2761}
2762
2763void
2765{
2766 for (auto element : m_txBuffer)
2767 {
2768 element = nullptr;
2769 }
2770 m_txBuffer.clear();
2771}
2772
2775{
2776 switch (macStatus)
2777 {
2778 case MacStatus::SUCCESS:
2779 return NwkStatus::SUCCESS;
2780 break;
2781 case MacStatus::NO_SHORT_ADDRESS:
2783 break;
2784 case MacStatus::SUPERFRAME_OVERLAP:
2786 break;
2787 case MacStatus::TRACKING_OFF:
2789 break;
2790 case MacStatus::LIMIT_REACHED:
2792 break;
2793 case MacStatus::NO_BEACON:
2795 break;
2796 case MacStatus::SCAN_IN_PROGRESS:
2798 break;
2799 case MacStatus::COUNTER_ERROR:
2801 break;
2802 case MacStatus::FRAME_TOO_LONG:
2804 break;
2805 case MacStatus::UNAVAILABLE_KEY:
2807 break;
2808 case MacStatus::UNSUPPORTED_SECURITY:
2810 break;
2811 case MacStatus::CHANNEL_ACCESS_FAILURE:
2813 break;
2814 case MacStatus::INVALID_PARAMETER:
2816 break;
2817 default:
2819 }
2820}
2821
2824{
2825 NS_LOG_FUNCTION(this);
2826
2828 {
2829 NS_FATAL_ERROR("Distributed allocation not supported");
2830 return Mac16Address("FF:FF");
2831 }
2832 else if (m_nwkAddrAlloc == STOCHASTIC_ALLOC)
2833 {
2834 // See nwkNetworkAddress valid range Zigbee specification r22.1.0, 3.5.2
2835 // Valid values in the Zigbee specification goes from 1 to 0xFFF7,
2836 // However, the range 0x8000 to 0x9FFF is used for multicast in other networks
2837 // (i.e. IPV6 over IEEE 802.15.4) for this reason, we avoid this range as well.
2838 // See RFC 4944, Section 9
2839 uint16_t rndValue = m_uniformRandomVariable->GetInteger(1, 0x7FFF);
2840 uint16_t rndValue2 = m_uniformRandomVariable->GetInteger(0xA000, 0xFFF7);
2841 uint16_t rndValue3 = m_uniformRandomVariable->GetInteger(1, 2);
2842
2843 Mac16Address allocAddr;
2844 if (rndValue3 == 1)
2845 {
2846 allocAddr = Mac16Address(rndValue);
2847 }
2848 else
2849 {
2850 allocAddr = Mac16Address(rndValue2);
2851 }
2852 return allocAddr;
2853 }
2854 else
2855 {
2856 NS_FATAL_ERROR("Address allocation method not supported");
2857 return Mac16Address("FF:FF");
2858 }
2859}
2860
2861uint8_t
2863{
2864 NS_LOG_FUNCTION(this);
2865
2866 uint8_t mappedValue;
2867
2868 if (lqi > 50)
2869 {
2870 mappedValue = 1;
2871 }
2872 else if ((lqi <= 50) && (lqi > 45))
2873 {
2874 mappedValue = 2;
2875 }
2876 else if ((lqi <= 45) && (lqi > 40))
2877 {
2878 mappedValue = 3;
2879 }
2880 else if ((lqi <= 40) && (lqi > 38))
2881 {
2882 mappedValue = 4;
2883 }
2884 else if ((lqi <= 38) && (lqi > 35))
2885 {
2886 mappedValue = 5;
2887 }
2888 else if ((lqi <= 35) && (lqi > 24))
2889 {
2890 mappedValue = 6;
2891 }
2892 else
2893 {
2894 mappedValue = 7;
2895 }
2896
2897 return mappedValue;
2898}
2899
2900uint8_t
2901ZigbeeNwk::GetLinkCost(uint8_t lqi) const
2902{
2903 NS_LOG_FUNCTION(this);
2904
2906 {
2907 // Hop count based. Report constant value
2908 return 7;
2909 }
2910 else
2911 {
2912 // Based on non-linear mapping of LQI
2913 return GetLQINonLinearValue(lqi);
2914 }
2915}
2916
2917void
2920 uint8_t rreqRetries)
2921{
2922 NS_LOG_FUNCTION(this);
2923
2924 ZigbeePayloadType payloadType(ROUTE_REQ_CMD);
2925
2926 Ptr<Packet> nsdu = Create<Packet>();
2927 nsdu->AddHeader(payload);
2928 nsdu->AddHeader(payloadType);
2929 nsdu->AddHeader(nwkHeader);
2930
2932 nwkHeader.GetRadius() != 0)
2933 {
2934 // Set RREQ RETRIES
2935 Time rreqRetryTime = m_nwkcRREQRetryInterval + MilliSeconds(m_rreqJitter->GetValue());
2936
2937 Ptr<RreqRetryTableEntry> rreqRetryTableEntry;
2938 if (m_rreqRetryTable.LookUpEntry(payload.GetRouteReqId(), rreqRetryTableEntry))
2939 {
2940 if (rreqRetryTableEntry->GetRreqRetryCount() >= rreqRetries)
2941 {
2942 NS_LOG_DEBUG("Maximum RREQ retries reached for dst ["
2943 << payload.GetDstAddr() << "] and rreq ID "
2944 << static_cast<uint32_t>(payload.GetRouteReqId()));
2945 // Note: The value of the maximum number of retries (rreqRetries) is either
2946 // nwkcInitialRREQRetries or nwkcRREQRetries depending on where the RREQ is
2947 // transmitted. See Zigbee specification r22.1.0, Section 3.6.3.5.1 This trace here
2948 // is used to keep track when the maximum RREQ retries is reached.
2950 payload.GetDstAddr(),
2951 rreqRetries);
2952 }
2953 else
2954 {
2955 // Schedule the next RREQ RETRY event and update entry.
2956 EventId rreqRetryEvent = Simulator::Schedule(rreqRetryTime,
2958 this,
2959 nwkHeader,
2960 payload,
2961 rreqRetries);
2962
2963 rreqRetryTableEntry->SetRreqRetryCount(rreqRetryTableEntry->GetRreqRetryCount() +
2964 1);
2965 rreqRetryTableEntry->SetRreqEventId(rreqRetryEvent);
2966 }
2967 }
2968 else
2969 {
2970 // Schedule the next RREQ RETRY and add a new record of the event.
2971 EventId rreqRetryEvent = Simulator::Schedule(rreqRetryTime,
2973 this,
2974 nwkHeader,
2975 payload,
2976 rreqRetries);
2977
2978 Ptr<RreqRetryTableEntry> newEntry =
2979 Create<RreqRetryTableEntry>(payload.GetRouteReqId(), rreqRetryEvent, 0);
2980
2981 m_rreqRetryTable.AddEntry(newEntry);
2982 }
2983 }
2984
2985 // Send the RREQ
2986 // See Section 3.4.1.1 Mac Data Service Requirements for RREQ
2987 if (nwkHeader.GetRadius() != 0)
2988 {
2989 McpsDataRequestParams params;
2990 params.m_dstPanId = m_nwkPanId;
2991 params.m_srcAddrMode = SHORT_ADDR;
2992 params.m_dstAddrMode = SHORT_ADDR;
2993 params.m_dstAddr = Mac16Address::GetBroadcast();
2994 params.m_msduHandle = m_macHandle.GetValue();
2995 m_macHandle++;
2996 m_mac->McpsDataRequest(params, nsdu);
2997 }
2998 else
2999 {
3000 NS_LOG_DEBUG("Maximum radius reached, dropping RREQ");
3001 }
3002}
3003
3004void
3006 Mac16Address originator,
3007 Mac16Address responder,
3008 uint8_t rreqId,
3009 uint8_t pathcost)
3010{
3011 NS_LOG_FUNCTION(this);
3012
3013 ZigbeeNwkHeader nwkHeader;
3014 nwkHeader.SetFrameType(NWK_COMMAND);
3017
3018 nwkHeader.SetDstAddr(nextHop);
3022 // see Zigbee specification 3.4.2.2
3023 // Use the maximum possible radius
3024 nwkHeader.SetRadius(m_nwkMaxDepth * 2);
3025
3026 ZigbeePayloadType payloadType(ROUTE_REP_CMD);
3027
3029 payload.SetRouteReqId(rreqId);
3030 payload.SetOrigAddr(originator);
3031 payload.SetRespAddr(responder);
3032 payload.SetPathCost(pathcost);
3033
3034 // See Section 3.4.2 Mac Data Service Requirements for RREP
3035 McpsDataRequestParams params;
3036 params.m_dstPanId = m_nwkPanId;
3037 params.m_srcAddrMode = SHORT_ADDR;
3038 params.m_dstAddrMode = SHORT_ADDR;
3039 params.m_dstAddr = nextHop;
3040 params.m_msduHandle = m_macHandle.GetValue();
3041 m_macHandle++;
3042
3043 Ptr<Packet> nsdu = Create<Packet>();
3044 nsdu->AddHeader(payload);
3045 nsdu->AddHeader(payloadType);
3046 nsdu->AddHeader(nwkHeader);
3047
3048 m_mac->McpsDataRequest(params, nsdu);
3049}
3050
3051int64_t
3053{
3054 NS_LOG_FUNCTION(this << stream);
3055 m_uniformRandomVariable->SetStream(stream);
3056 return 1;
3057}
3058
3059void
3061{
3062 NS_LOG_FUNCTION(this);
3063
3064 ZigbeeBeaconPayload beaconPayloadHeader;
3065 beaconPayloadHeader.SetStackProfile(static_cast<uint8_t>(m_nwkStackProfile));
3066 beaconPayloadHeader.SetRouterCapacity(m_nwkcCoordinatorCapable);
3067 beaconPayloadHeader.SetDeviceDepth(0); // Not used by stack profile (0x02 =ZIGBEE pro)
3068 beaconPayloadHeader.SetEndDevCapacity(true);
3069 beaconPayloadHeader.SetExtPanId(m_nwkExtendedPanId);
3070 beaconPayloadHeader.SetTxOffset(0xFFFFFF);
3071 // TODO: beaconPayload.SetNwkUpdateId(m_nwkUpdateId);
3072
3073 // Set the beacon payload length in the MAC PIBs and then proceed to
3074 // update the beacon payload
3076 m_beaconPayload->AddHeader(beaconPayloadHeader);
3078 pibAttr->macBeaconPayloadLength = m_beaconPayload->GetSize();
3079 m_mac->MlmeSetRequest(MacPibAttributeIdentifier::macBeaconPayloadLength, pibAttr);
3080}
3081
3082void
3084{
3085 NS_LOG_FUNCTION(this);
3086
3087 // Extract octets from m_beaconPayload and copy them into the
3088 // macBeaconPayload attribute
3090 pibAttr->macBeaconPayload.resize(m_beaconPayload->GetSize());
3091 m_beaconPayload->CopyData(pibAttr->macBeaconPayload.data(), m_beaconPayload->GetSize());
3092 m_beaconPayload = nullptr;
3093 m_mac->MlmeSetRequest(MacPibAttributeIdentifier::macBeaconPayload, pibAttr);
3094}
3095
3096std::ostream&
3097operator<<(std::ostream& os, const NwkStatus& state)
3098{
3099 switch (state)
3100 {
3101 case NwkStatus::SUCCESS:
3102 os << "SUCCESS";
3103 break;
3105 os << "FULL CAPACITY";
3106 break;
3108 os << "ACCESS DENIED";
3109 break;
3111 os << "COUNTER ERROR";
3112 break;
3114 os << "IMPROPER KEY TYPE";
3115 break;
3117 os << "IMPROPER SECURITY LEVEL";
3118 break;
3120 os << "UNSUPPORTED LEGACY";
3121 break;
3123 os << "UNSUPPORTED SECURITY";
3124 break;
3126 os << "BEACON LOSS";
3127 break;
3129 os << "CHANNEL ACCESS FAILURE";
3130 break;
3131 case NwkStatus::DENIED:
3132 os << "DENIED";
3133 break;
3135 os << "DISABLE TRX FAILURE";
3136 break;
3138 os << "SECURITY ERROR";
3139 break;
3141 os << "FRAME TOO LONG";
3142 break;
3144 os << "INVALID GTS";
3145 break;
3147 os << "INVALID HANDLE";
3148 break;
3149 case NwkStatus::NO_ACK:
3150 os << "NO ACKNOLEDGMENT";
3151 break;
3153 os << "NO BEACON";
3154 break;
3155 case NwkStatus::NO_DATA:
3156 os << "NO DATA";
3157 break;
3159 os << "NO SHORT ADDRESS";
3160 break;
3162 os << "OUT OF CAP";
3163 break;
3165 os << "PAN ID CONFLICT";
3166 break;
3168 os << "REALIGMENT";
3169 break;
3171 os << "TRANSACTION EXPIRED";
3172 break;
3174 os << "TRANSACTION OVERFLOW";
3175 break;
3177 os << "TX ACTIVE";
3178 break;
3180 os << "UNAVAILABLE KEY";
3181 break;
3183 os << "INVALID ADDRESS";
3184 break;
3186 os << "ON TIME TOO LONG";
3187 break;
3189 os << "PAST TIME";
3190 break;
3192 os << "TRACKING OFF";
3193 break;
3195 os << "INVALID INDEX";
3196 break;
3198 os << "READ ONLY";
3199 break;
3201 os << "SUPERFRAME OVERLAP";
3202 break;
3204 os << "INVALID PARAMETER";
3205 break;
3207 os << "INVALID REQUEST";
3208 break;
3210 os << "NO PERMITED";
3211 break;
3213 os << "STARTUP FAILURE";
3214 break;
3216 os << "ALREADY PRESENT";
3217 break;
3219 os << "SYNC FAILURE";
3220 break;
3222 os << "NEIGHBOR TABLE FULL";
3223 break;
3225 os << "UNKNOWN DEVICE";
3226 break;
3228 os << "UNSUPPORTED ATTRIBUTE";
3229 break;
3231 os << "NO NETWORKS";
3232 break;
3234 os << "MAX FRAME COUNTER";
3235 break;
3236 case NwkStatus::NO_KEY:
3237 os << "NO KEY";
3238 break;
3240 os << "BAD CCM OUTPUT";
3241 break;
3243 os << "ROUTE DISCOVERY FAILED";
3244 break;
3246 os << "ROUTE ERROR";
3247 break;
3249 os << "BT TABLE FULL";
3250 break;
3252 os << "FRAME NOT BUFFERED";
3253 break;
3255 os << "INVALID INTERFACE";
3256 break;
3258 os << "LIMIT REACHED";
3259 break;
3261 os << "SCAN IN PROGRESS";
3262 break;
3263 }
3264 return os;
3265}
3266
3267} // namespace zigbee
3268} // namespace ns3
AttributeValue implementation for Boolean.
Definition boolean.h:26
bool IsNull() const
Check for null implementation.
Definition callback.h:555
This class can be used to hold variables of floating point type such as 'double' or 'float'.
Definition double.h:31
An identifier for simulation events.
Definition event-id.h:45
This class can contain 16 bit addresses.
static Mac16Address GetBroadcast()
an EUI-64 address
uint64_t ConvertToInt() const
A base class which provides memory management and object aggregation.
Definition object.h:78
virtual void DoInitialize()
Initialize() implementation.
Definition object.cc:440
virtual void DoDispose()
Destructor implementation.
Definition object.cc:433
void AddHeader(const Header &header)
Add header to this packet.
Definition packet.cc:257
uint32_t GetSize() const
Returns the the size in bytes of the packet (including the zero-filled initial payload).
Definition packet.h:850
uint32_t CopyData(uint8_t *buffer, uint32_t size) const
Copy the packet contents to a byte buffer.
Definition packet.cc:389
Smart pointer class similar to boost::intrusive_ptr.
NUMERIC_TYPE GetValue() const
Extracts the numeric value of the sequence number.
static EventId Schedule(const Time &delay, FUNC f, Ts &&... args)
Schedule an event to expire after delay.
Definition simulator.h:560
static Time Now()
Return the current simulation virtual time.
Definition simulator.cc:197
Simulation virtual time values and global simulation resolution.
Definition nstime.h:94
TimeWithUnit As(const Unit unit=Time::AUTO) const
Attach a unit to a Time, to facilitate output in a specific unit.
Definition time.cc:404
@ S
second
Definition nstime.h:105
AttributeValue implementation for Time.
Definition nstime.h:1431
a unique identifier for an interface.
Definition type-id.h:48
TypeId SetParent(TypeId tid)
Set the parent TypeId.
Definition type-id.cc:1001
Hold an unsigned integer type.
Definition uinteger.h:34
void Dispose()
Dispose of all broadcast transaction records (BTR) in the broadcast transaction table(BTT).
bool AddEntry(Ptr< BroadcastTransactionRecord > entry)
Add a broadcast transaction record (BTR) to the broadcast transaction table(BTT).
bool LookUpEntry(uint8_t seq, Ptr< BroadcastTransactionRecord > &entryFound)
Look up for broadcast transaction record in the broadcast transaction table (BTT).
Represent the the Capability Information Bit fields See zigbe Specification r22.1....
uint8_t GetCapability() const
Used to obtain the complete capability information bit map.
void SetCapability(uint8_t capability)
Set the Capability Information bit map.
MacDeviceType GetDeviceType() const
This field will have a value of ROUTER if the joining device is a Zigbee router.
bool IsReceiverOnWhenIdle() const
This field will be set to the value of the lowest-order bit of the RxOnWhenIdle parameter passed to t...
void SetDeviceType(MacDeviceType devType)
Set the device type bit for the capability information field.
void SetReceiverOnWhenIdle(bool value)
Set the Receiver On When Idle bit for the capability information field.
bool IsAllocateAddrOn() const
This field will have a value of true in implementations of this specification, indicating that the jo...
bool GetParent(Ptr< NeighborTableEntry > &entryFound)
Look for this device Parent neighbor (A.K.A coordinator).
void Dispose()
Dispose of the table and all its elements.
bool LookUpForBestParent(uint64_t epid, Ptr< NeighborTableEntry > &entryFound)
Perform a search for the best candidate parent based on some attributes.
bool AddEntry(Ptr< NeighborTableEntry > entry)
Add an entry to the neighbor table.
void Print(Ptr< OutputStreamWrapper > stream) const
Print the neighbor table.
bool LookUpEntry(Mac16Address nwkAddr, Ptr< NeighborTableEntry > &entryFound)
Look and return and entry if exists in the neighbor table.
uint32_t GetSize()
Get the size of the neighbor table.
void Delete(Mac64Address extAddr)
Delete the specified entry from the neighbor table.
bool GetEntry(uint64_t extPanId, uint16_t &panId)
Get the 16 bit MAC PAN id based on the reference extended PAN id.
void AddEntry(uint64_t extPanId, uint16_t panId)
Add an entry to the PAN Id table.
void Dispose()
Dispose of the table and all its elements.
void Dispose()
Dispose of the table and all its elements.
void Delete(uint8_t id, Mac16Address src)
Delete an entry from the route discovery table.
bool AddEntry(Ptr< RouteDiscoveryTableEntry > rt)
Add an entry to the route discovery table, in essence the contents of a RREQ command.
bool LookUpEntry(uint8_t id, Mac16Address src, Ptr< RouteDiscoveryTableEntry > &entryFound)
Look up for a route discovery table entry, the seareched entry must match the id and the src address ...
void Print(Ptr< OutputStreamWrapper > stream)
Print the contents of the route discovery table.
void DeleteExpiredEntry()
Delete the first occrurance of an expired entry (ROUTE_INACTIVE status)
bool AddEntry(Ptr< RoutingTableEntry > rt)
Adds an entry to the routing table.
uint32_t GetMaxTableSize() const
Get the maximum size of the routing table.
void Print(Ptr< OutputStreamWrapper > stream) const
Print the Routing table.
uint32_t GetSize()
Get the size of the routing table.
bool LookUpEntry(Mac16Address dstAddr, Ptr< RoutingTableEntry > &entryFound)
Look for an specific entry in the routing table.
void Dispose()
Dispose of the table and all its elements.
void Print(Ptr< OutputStreamWrapper > stream) const
Print the neighbor table.
void Dispose()
Dispose of the table and all its elements.
bool LookUpEntry(uint8_t rreqId, Ptr< RreqRetryTableEntry > &entryFound)
Look up for an entry in the table.
void Delete(uint8_t rreqId)
Delete an entry from the table using the RREQ ID.
bool AddEntry(Ptr< RreqRetryTableEntry > entry)
Adds an entry to the table.
Represent the Superframe Specification information field.
bool IsAssocPermit() const
Check if the Association Permit bit is enabled.
uint8_t GetFrameOrder() const
Get the Superframe Specification Frame Order field.
uint8_t GetBeaconOrder() const
Get the Superframe Specification Beacon Order field.
Represents the payload portion of a beacon frame.
bool GetRouterCapacity() const
Get the router capacity capability.
void SetDeviceDepth(uint8_t deviceDepth)
Set the cevice depth object.
uint8_t GetProtocolId() const
Get the Protocol Id used.
uint8_t GetStackProfile() const
Get the Stack Profile used.
void SetRouterCapacity(bool routerCapacity)
Set the Router Capacity capability True = The device is able to accept join.request from router-capab...
uint64_t GetExtPanId() const
Get the extended PAN identifier.
void SetStackProfile(uint8_t stackProfile)
Set the network profile identifier.
void SetEndDevCapacity(bool endDevCapacity)
Set the end device Capacity.
bool GetEndDevCapacity() const
Get the end dev capacity.
void SetTxOffset(uint32_t txOffset)
Set the Tx Offset time in symbols.
void SetExtPanId(uint64_t extPanId)
Set the extended PAN id.
Represent the NWK Header with the Frame Control and Routing fields Zigbee Specification r22....
void SetMulticast()
Set to true the value of the multicast flag in the frame control field.
void SetDiscoverRoute(enum DiscoverRouteType discoverRoute)
Suppress or enable route discovery for this frame.
void SetSrcAddr(Mac16Address addr)
Set Source address.
void SetEndDeviceInitiator()
This flag is used by the NWK to indicate if the the initiator device of the message is an end device ...
void SetProtocolVer(uint8_t ver)
Set the Protocol version.
bool IsMulticast() const
Inform whether or not the current frame is used in multicast.
void SetSeqNum(uint8_t seqNum)
Set the Sequence number.
uint8_t GetRadius() const
Get the Radius.
uint8_t GetSeqNum() const
Get the frame Sequence number.
NwkType GetFrameType() const
Set the Frame Control field "Frame Type" bits.
void SetRadius(uint8_t radius)
Set the Radius.
void SetFrameType(enum NwkType nwkType)
Set the Frame type used (Data or Command)
Mac16Address GetDstAddr() const
Get the Destination address.
void SetDstAddr(Mac16Address addr)
Set Destination address.
DiscoverRouteType GetDiscoverRoute() const
Get the status of frame discovery route (suppress or enabled)
Mac16Address GetSrcAddr() const
Get the Source address.
Class that implements the Zigbee Specification Network Layer.
Definition zigbee-nwk.h:682
void SendDataUcst(Ptr< Packet > packet, uint8_t nwkHandle)
Send a data unicast packet, and if necessary look for the next hop route and store the pending data t...
NeighborTable m_nwkNeighborTable
The network layer neighbor table See Zigbee specification r22.1.0, 3.6.1.5.
RouteDiscoveryStatus ProcessManyToOneRoute(Mac16Address macSrcAddr, uint8_t pathCost, ZigbeeNwkHeader nwkHeader, ZigbeePayloadRouteRequestCommand payload)
Process Many-To-One routes.
ZigbeeNwk()
Default constructor.
Mac64Address GetIeeeAddress() const
Obtain this device 64 bit IEEE address (A.K.A.
uint8_t m_nwkConcentratorDiscoveryTime
The time in seconds between concentrator route discoveries.
void DisposePendingTx()
Dispose of all PendingTxPkt accumulated in the pending transmission queue.
uint8_t m_nwkCapabilityInformation
This NIB attribute contains the device capability information established at network joining time.
void MlmeOrphanIndication(lrwpan::MlmeOrphanIndicationParams params)
IEEE 802.15.4-2011 sections 6.2.7.1, Zigbee Specification r22.1.0 Section 3.6.1.4....
void UpdateBeaconPayload()
Updates the content of the beacon payload with the most recent information in the NWK.
TracedCallback< uint8_t, Mac16Address, uint8_t > m_rreqRetriesExhaustedTrace
A trace source that fires when a node has reached the maximum number of RREQ retries allowed.
Mac16Address AllocateNetworkAddress()
Used by a Zigbee coordinator or router to allocate a 16 bit address (A.K.A short address or network a...
void NlmeDirectJoinRequest(NlmeDirectJoinRequestParams params)
Zigbee Specification r22.1.0, section 3.2.2.16 and 3.6.1.4.3 NLME-DIRECT-JOIN.request Allows the next...
RoutingTable m_nwkRoutingTable
The network layer routing table See Zigbee specification r22.1.0, 3.6.3.2.
double m_nwkcMinRREQJitter
Minimum Route request broadcast jitter time (msec).
SequenceNumber8 m_nwkSequenceNumber
The sequence number used to identify outgoing frames See Zigbee specification r22....
NlmeNetworkFormationRequestParams m_netFormParams
The parameters used during a NLME-NETWORK-FORMATION.request.
void McpsDataConfirm(lrwpan::McpsDataConfirmParams params)
IEEE 802.15.4-2011 section 6.3.2 MCPS-DATA.confirm Reports the results of a request to a transfer dat...
Ptr< UniformRandomVariable > m_uniformRandomVariable
Provides uniform random values.
NlmeJoinIndicationParams m_joinIndParams
Temporally store the NLME-JOIN.indication parameters while the join operations (asocciation) conclude...
void PrintRoutingTable(Ptr< OutputStreamWrapper > stream) const
Print the entries in the routing table.
Mac16Address FindRoute(Mac16Address dst, bool &neighbor)
Search for a specific destination in this device neighbor and routing tables.
void SetNlmeJoinConfirmCallback(NlmeJoinConfirmCallback c)
Set the callback as part of the interconnections between the NWK and the APS sublayer (or any other h...
void NlmeStartRouterRequest(NlmeStartRouterRequestParams params)
Zigbee Specification r22.1.0, section 3.2.2.9 NLME-START-ROUTER.request This primitive allows the nex...
void SetNlmeRouteDiscoveryConfirmCallback(NlmeRouteDiscoveryConfirmCallback c)
Set the callback as part of the interconnections between the NWK and the APS sublayer (or any other h...
uint8_t m_currentChannel
Used to store the value of the PHY current channel.
Time m_routeExpiryTime
The expiration time of routing table entry.
static TypeId GetTypeId()
Get the type ID.
Definition zigbee-nwk.cc:35
void NldeDataRequest(NldeDataRequestParams params, Ptr< Packet > packet)
Zigbee Specification r22.1.0, Section 3.2.1.1 NLDE-DATA.request Request to transfer a NSDU.
void SendRREP(Mac16Address nextHop, Mac16Address originator, Mac16Address responder, uint8_t rreqId, uint8_t pathcost)
Construct and send a route reply command.
void PrintNeighborTable(Ptr< OutputStreamWrapper > stream) const
Print the entries in the neighbor table.
void MlmeSetConfirm(lrwpan::MlmeSetConfirmParams params)
IEEE 802.15.4-2011 section 6.2.11.2 MLME-SET.confirm Reports the result of an attempt to change a MAC...
void UpdateBeaconPayloadLength()
Create and store a MAC beacon payload, then updates its registered size in the MAC.
StackProfile m_nwkStackProfile
Describes the current stack profile used in this NWK layer.
NlmeDirectJoinConfirmCallback m_nlmeDirectJoinConfirmCallback
This callback is used by the next layer of a zigbee coordinator or router to be notified of the resul...
bool m_nwkReportConstantCost
If false, the NWK layer shall calculate the link cost from all neighbor nodes using the LQI values re...
Time m_nwkcRREQRetryInterval
Duration between retries of a broadcast route request command frame.
void DoInitialize() override
Initialize() implementation.
NlmeNetworkFormationConfirmCallback m_nlmeNetworkFormationConfirmCallback
This callback is used to to notify the results of a network formation to the APS sublayer making the ...
void MlmeCommStatusIndication(lrwpan::MlmeCommStatusIndicationParams params)
IEEE 802.15.4-2011 section 6.2.4.2 MLME-COMM-STATUS.indication Allows the MAC MLME to indicate a comm...
PanIdTable m_panIdTable
Use to keep track of neighboring 16 bit PAN id.
Mac16Address m_nwkNetworkAddress
The 16-bit address that the device uses to communicate with the PAN.
RouteDiscoveryStatus FindNextHop(Mac16Address macSrcAddr, uint8_t pathCost, ZigbeeNwkHeader nwkHeader, ZigbeePayloadRouteRequestCommand payload, Mac16Address &nextHop)
Find the next hop in route to a destination.
void SetMac(Ptr< lrwpan::LrWpanMacBase > mac)
Set the underlying MAC to use in this Zigbee NWK.
uint8_t m_nwkParentInformation
The behavior depends upon whether the device is a FFD or RFD.
SequenceNumber8 m_macHandle
The handle assigned when doing a transmission request to the MAC layer.
NlmeJoinRequestParams m_joinParams
The parameters used during a NLME-JOIN.request.
void MlmeBeaconNotifyIndication(lrwpan::MlmeBeaconNotifyIndicationParams params)
IEEE 802.15.4-2011, Section 6.2.4.1 MLME-BEACON-NOTIFY.indication Allows the MAC MLME to indicate the...
void SetNlmeJoinIndicationCallback(NlmeJoinIndicationCallback c)
Set the callback as part of the interconnections between the NWK and the APS sublayer (or any other h...
uint8_t m_nwkcInitialRREQRetries
The number of times the first broadcast transmission of a route request command frame is retried.
void SetNlmeNetworkDiscoveryConfirmCallback(NlmeNetworkDiscoveryConfirmCallback c)
Set the callback as part of the interconnections between the NWK and the APS sublayer (or any other h...
void MlmeAssociateConfirm(lrwpan::MlmeAssociateConfirmParams params)
IEEE 802.15.4-2011 section MlME-ASSOCIATE.confirm Report the results of an associate request attempt.
void EnqueuePendingTx(Ptr< Packet > p, uint8_t nsduHandle)
Enqueue a packet in the pending transmission queue until a route is discovered for its destination.
void NlmeNetworkDiscoveryRequest(NlmeNetworkDiscoveryRequestParams params)
Zigbee Specification r22.1.0, section 3.2.2.3 NLME-NETWORK-DISCOVERY.request Allows the next higher l...
Ptr< NetFormPendingParamsGen > m_netFormParamsGen
The values temporally stored as a result of the initial steps of a NLME-NETWORK-FORMATION....
NlmeStartRouterConfirmCallback m_nlmeStartRouterConfirmCallback
This callback is used by the next layer of a zigbee router or device to be notified of the result of ...
NlmeJoinConfirmCallback m_nlmeJoinConfirmCallback
This callback is used by the next layer of a zigbee router or device to be notified of the result of ...
int64_t AssignStreams(int64_t stream)
Assign a fixed random variable stream number to the random variables used by this model.
void NlmeJoinRequest(NlmeJoinRequestParams params)
Zigbee Specification r22.1.0, section 3.2.2.13 NLME-JOIN.request This primitive allows the next highe...
uint8_t m_nwkConcentratorRadius
This NIB attribute indicates the hop count radius for concentrator route discoveries (Used by Many-To...
double m_nwkcMaxRREQJitter
Maximum Route request broadcast jitter time (msec).
Mac64Address m_nwkIeeeAddress
The EUI 64 bit IEEE address of the local device.
void SetNlmeStartRouterConfirmCallback(NlmeStartRouterConfirmCallback c)
Set the callback as part of the interconnections between the NWK and the APS sublayer (or any other h...
void ReceiveRREP(Mac16Address macSrcAddr, uint8_t linkCost, ZigbeeNwkHeader nwkHeader, ZigbeePayloadRouteReplyCommand payload)
Handles the reception of a route reply command.
uint16_t m_nwkPanId
This NIB attribute should, at all times, have the same value as macPANId .
void SetNldeDataConfirmCallback(NldeDataConfirmCallback c)
Set the callback as part of the interconnections between the NWK and the APS sublayer (or any other h...
Ptr< Packet > m_beaconPayload
Points to the beacon payload used during the network formation process.
uint8_t m_countRREQRetries
Count the number of retries this device has transmitted an RREQ.
PendingPrimitiveNwk m_pendPrimitiveNwk
Indicates the current primitive in use in the NWK layer.
bool IsBroadcastAddress(Mac16Address address)
Returns true if the address is a broadcast address according to Zigbee specification r22....
BroadcastTransactionTable m_btt
The broadcast transaction table.
void NotifyConstructionCompleted() override
Notifier called once the ObjectBase is fully constructed.
uint8_t m_nwkMaxBroadcastRetries
The maximum number of retries allowed after a broadcast transmission failure See Zigbe Specification ...
uint32_t m_maxPendingTxQueueSize
The maximum size of the pending transaction queue.
uint8_t m_nwkMaxDepth
The depth a device can have.
AddrAllocMethod m_nwkAddrAlloc
A value that determines the method used to assign addresses.
std::vector< NetworkDescriptor > m_networkDescriptorList
Temporarily store beacons information from POS routers and PAN coordinators during a network-discover...
NldeDataConfirmCallback m_nldeDataConfirmCallback
This callback is used to respond to data PDU (NSDU) transfer request issued by APS sublayer to the NW...
Ptr< lrwpan::LrWpanMacBase > m_mac
Pointer to the underlying MAC connected to this Zigbee NWK.
void MlmeStartConfirm(lrwpan::MlmeStartConfirmParams params)
IEEE 802.15.4-2011 section 7.1.14.2 MLME-START.confirm Reports the results of a network start request...
uint8_t GetLinkCost(uint8_t lqi) const
Obtain the link cost based on the value of the nwkReportConstantCost.
void MlmeAssociateIndication(lrwpan::MlmeAssociateIndicationParams params)
IEEE 802.15.4-2011, Section 6.2.2.2.
void ReceiveRREQ(Mac16Address macSrcAddr, uint8_t linkCost, ZigbeeNwkHeader nwkHeader, ZigbeePayloadRouteRequestCommand payload)
Handles the reception of a route request command.
void PrintRREQRetryTable(Ptr< OutputStreamWrapper > stream) const
Print the entries in the RREQ retry table.
void PrintRouteDiscoveryTable(Ptr< OutputStreamWrapper > stream)
Print the entries in the route discovery table.
Ptr< UniformRandomVariable > m_rreqJitter
Provides uniform random values for the route request jitter.
NwkStatus GetNwkStatus(lrwpan::MacStatus macStatus) const
Cast a Mac layer status to a NWK layer status.
uint16_t m_nwkMaxChildren
The number of children a device is allowed to have on its current network.
uint8_t m_scanEnergyThreshold
The maximum acceptable energy level used in an energy scan.
void MlmeScanConfirm(lrwpan::MlmeScanConfirmParams params)
IEEE 802.15.4-2011 section 6.2.10.2 MLME-SCAN.confirm Reports the results of a scan request.
void NlmeNetworkFormationRequest(NlmeNetworkFormationRequestParams params)
Zigbee Specification r22.1.0, Section 3.2.2.5 and 3.6.1.1 NLME-NETWORK-FORMATION.request Request the ...
SequenceNumber8 m_routeRequestId
The counter used to identify route request commands.
NlmeNetworkDiscoveryConfirmCallback m_nlmeNetworkDiscoveryConfirmCallback
This callback is used to to notify the results of a network formation to the APS sublayer making the ...
uint16_t m_nwkEndDeviceTimeoutDefault
Indicates the index of the requested timeout field that contains the timeout in minutes for any end d...
void DisposeTxPktBuffer()
Dispose of all the entries in the TxPkt Buffer.
bool m_nwkIsConcentrator
This NIB attribute is a flag determining if this device is a concentrator (Use in Many-To-One routing...
Time m_nwkcRouteDiscoveryTime
Indicates the duration until a route discovery expires.
uint8_t m_txBufferMaxSize
The maximum size of the transmission buffer.
void SendRREQ(ZigbeeNwkHeader nwkHeader, ZigbeePayloadRouteRequestCommand payload, uint8_t rreqRetries)
Send a route request command.
AssociateParams m_associateParams
Temporally store parameters during the associate process that take place during a NLME-JOIN....
RreqRetryTable m_rreqRetryTable
Keep track of all the route request retries.
bool m_nwkUseTreeRouting
This NIB attribute indicates whether the NWK layer should assume the ability to use hierarchical rout...
void SetNlmeNetworkFormationConfirmCallback(NlmeNetworkFormationConfirmCallback c)
Set the callback as part of the interconnections between the NWK and the APS sublayer (or any other h...
Time m_nwkNetworkBroadcastDeliveryTime
Time duration that a broadcast message needs to encompass the entire network.
NlmeRouteDiscoveryConfirmCallback m_nlmeRouteDiscoveryConfirmCallback
This callback is used to to notify the results of a network formation to the APS sublayer making the ...
void SetNlmeDirectJoinConfirmCallback(NlmeDirectJoinConfirmCallback c)
Set the callback as part of the interconnections between the NWK and the APS sublayer (or any other h...
bool m_nwkSymLink
Describes the current route symmetry: True: Routes are considered to be symmetric links.
std::deque< Ptr< PendingTxPkt > > m_pendingTxQueue
The pending transaction queue of data packets awaiting to be transmitted until a route to the destina...
uint16_t m_nwkMaxRouters
The number of routers any one device is allowed to have as children.
bool m_nwkcCoordinatorCapable
Indicates whether the device is capable of becoming the ZigBee coordinator Zigbee Specification r22....
void McpsDataIndication(lrwpan::McpsDataIndicationParams params, Ptr< Packet > msdu)
IEEE 802.15.4-2011 section 6.3.3 MCPS-DATA.indication Indicates the reception of an MSDU from MAC to ...
void BufferTxPkt(Ptr< Packet > p, uint8_t macHandle, uint8_t nwkHandle)
Buffer a copy of a DATA frame for post transmission handling (Transmission failure counts,...
bool RetrieveTxPkt(uint8_t macHandle, Ptr< TxPkt > &txPkt)
Retrieves a previously DATA frame buffered in the TxPkt buffer.
void NlmeRouteDiscoveryRequest(NlmeRouteDiscoveryRequestParams params)
Zigbee Specification r22.1.0, section 3.2.2.33.3 and 3.6.3.5 NLME-ROUTE-DISCOVERY....
std::deque< Ptr< TxPkt > > m_txBuffer
The transmission buffer.
Ptr< lrwpan::LrWpanMacBase > GetMac() const
Get the underlying MAC used by the current Zigbee NWK.
uint8_t GetLQINonLinearValue(uint8_t lqi) const
Get a non linear representation of a Link Quality Indicator (LQI).
void SetNldeDataIndicationCallback(NldeDataIndicationCallback c)
Set the callback for the end of a RX, as part of the interconnections between the NWK and the APS sub...
void DoDispose() override
Destructor implementation.
uint8_t m_nwkcRREQRetries
The number of times the broadcast transmission of a route request command frame is retried on relay b...
bool DequeuePendingTx(Mac16Address dst, Ptr< PendingTxPkt > entry)
Dequeue a packet previously enqueued in the pending transmission queue.
uint8_t m_nwkcProtocolVersion
Indicates the version of the ZigBee NWK protocol in the device.
void SendDataBcst(Ptr< Packet > packet, uint8_t nwkHandle)
Send a data broadcast packet, and add a record to the broadcast transaction table (BTT).
Mac16Address GetNetworkAddress() const
Obtain this device 16 bit network address (A.K.A.
void MlmeGetConfirm(lrwpan::MacStatus status, lrwpan::MacPibAttributeIdentifier id, Ptr< lrwpan::MacPibAttributes > attribute)
IEEE 802.15.4-2011 section 6.2.5.1 MLME-GET.confirm Reports the result of an attempt to obtain a MAC ...
NldeDataIndicationCallback m_nldeDataIndicationCallback
This callback is used to notify incoming packets to the APS sublayer.
RouteDiscoveryTable m_nwkRouteDiscoveryTable
The network route discovery table See Zigbee specification r22.1.0, 3.6.3.2.
uint64_t m_nwkExtendedPanId
The extended PAN identifier for the PAN of which the device is a member.
NlmeJoinIndicationCallback m_nlmeJoinIndicationCallback
This callback is used by the next layer of a zigbee coordinator or router to be notified when a new d...
Represent a variable portion of the zigbee payload header that includes the route reply command.
void SetRouteReqId(uint8_t rid)
Set the Route request identifier.
Mac16Address GetRespAddr() const
Get the Responder address.
Mac16Address GetOrigAddr() const
Get the Originator address.
void SetRespAddr(Mac16Address addr)
Set Responder address.
uint8_t GetRouteReqId() const
Get the Route request identifier.
void SetOrigAddr(Mac16Address addr)
Set Originator address.
void SetPathCost(uint8_t cost)
Set the path cost.
Represent a variable portion of the zigbee payload header that includes the route request command.
uint8_t GetRouteReqId() const
Get the Route request identifier.
void SetCmdOptManyToOneField(enum ManyToOne manyToOne)
Set the command option field Many To One.
uint8_t GetCmdOptManyToOneField() const
Get the command option field Many To One.
void SetRouteReqId(uint8_t id)
Set the Route request identifier.
void SetDstAddr(Mac16Address addr)
Set Destination address.
Mac16Address GetDstAddr() const
Get the Destination address.
Represent the static portion of the zigbee payload header that describes the payload command type.
NwkCommandType GetCmdType() const
Get the command frame type.
#define NS_ASSERT_MSG(condition, message)
At runtime, in debugging builds, if this condition is not true, the program prints the message to out...
Definition assert.h:75
Ptr< const AttributeChecker > MakeBooleanChecker()
Definition boolean.cc:113
Ptr< const AttributeAccessor > MakeBooleanAccessor(T1 a1)
Create an AttributeAccessor for a class data member, or a lone class get functor or set method.
Definition boolean.h:70
Ptr< const AttributeChecker > MakeDoubleChecker()
Definition double.h:82
Ptr< const AttributeAccessor > MakeDoubleAccessor(T1 a1)
Create an AttributeAccessor for a class data member, or a lone class get functor or set method.
Definition double.h:32
Ptr< const AttributeAccessor > MakeTimeAccessor(T1 a1)
Create an AttributeAccessor for a class data member, or a lone class get functor or set method.
Definition nstime.h:1432
Ptr< const AttributeChecker > MakeTimeChecker()
Helper to make an unbounded Time checker.
Definition nstime.h:1452
Ptr< const AttributeChecker > MakeUintegerChecker()
Definition uinteger.h:85
Ptr< const AttributeAccessor > MakeUintegerAccessor(T1 a1)
Create an AttributeAccessor for a class data member, or a lone class get functor or set method.
Definition uinteger.h:35
Callback< R, Args... > MakeNullCallback()
Definition callback.h:727
#define NS_FATAL_ERROR(msg)
Report a fatal error with a message and terminate.
#define NS_ABORT_MSG(msg)
Unconditional abnormal program termination with a message.
Definition abort.h:38
#define NS_LOG_ERROR(msg)
Use NS_LOG to output a message of level LOG_ERROR.
Definition log.h:243
#define NS_LOG_COMPONENT_DEFINE(name)
Define a Log component with a specific name.
Definition log.h:191
#define NS_LOG_DEBUG(msg)
Use NS_LOG to output a message of level LOG_DEBUG.
Definition log.h:257
#define NS_LOG_FUNCTION(parameters)
If log level LOG_FUNCTION is enabled, this macro will output all input parameters separated by ",...
#define NS_LOG_WARN(msg)
Use NS_LOG to output a message of level LOG_WARN.
Definition log.h:250
MacPibAttributeIdentifier
IEEE 802.15.4-2006 PHY and MAC PIB Attribute Identifiers Table 23 and Table 86.
MacStatus
The status of a confirm or an indication primitive as a result of a previous request.
Ptr< T > CreateObject(Args &&... args)
Create an object by type, with varying number of constructor parameters.
Definition object.h:619
#define NS_OBJECT_ENSURE_REGISTERED(type)
Register an Object subclass with the TypeId system.
Definition object-base.h:35
Ptr< T > Create(Ts &&... args)
Create class instances by constructors with varying numbers of arguments and return them by Ptr.
Definition ptr.h:436
SequenceNumber< uint8_t, int8_t > SequenceNumber8
8 bit Sequence number.
Time Seconds(double value)
Construct a Time in the indicated unit.
Definition nstime.h:1344
Time Minutes(double value)
Construct a Time in the indicated unit.
Definition nstime.h:1332
Time MilliSeconds(uint64_t value)
Construct a Time in the indicated unit.
Definition nstime.h:1356
Ptr< const TraceSourceAccessor > MakeTraceSourceAccessor(T a)
Create a TraceSourceAccessor which will control access to the underlying trace source.
NwkDeviceType
The network layer device type.
static const double RequestedTimeoutField[15]
Requested Timeout Field See Zigbee Specification r22.1.0, 3.4.11.3.1.
NwkStatus
Network layer status values Combines Zigbee Specification r22.1.0 Table 3-73 and and IEEE 802....
Definition zigbee-nwk.h:150
@ ZIGBEE_COORDINATOR
Zigbee coordinator.
@ ZIGBEE_ENDDEVICE
Zigbee end device.
@ ZIGBEE_ROUTER
Zigbee router.
@ ROUTE_VALIDATION_UNDERWAY
Route discovery validation underway.
@ ROUTE_ACTIVE
Route active.
@ ROUTE_DISCOVERY_UNDERWAY
Route discovery underway.
@ NO_ROUTING_CAPACITY
No routing capacity.
Definition zigbee-nwk.h:230
@ NO_ROUTE_AVAILABLE
No route available.
Definition zigbee-nwk.h:226
@ ENDDEVICE
End device or router treated as an end device.
@ ROUTER
Router device.
@ MCST
Multicast Address mode.
Definition zigbee-nwk.h:76
@ NO_ADDRESS
No destination address.
Definition zigbee-nwk.h:75
@ UCST_BCST
Unicast or Broadcast address mode.
Definition zigbee-nwk.h:77
@ NLME_NET_DISCV
Pending NLME-NETWORK-DISCOVERY.request primitive.
Definition zigbee-nwk.h:62
@ NLME_NETWORK_FORMATION
Pending NLME-NETWORK-FORMATION.request primitive.
Definition zigbee-nwk.h:58
@ NLME_JOIN
Pending NLME-JOIN.request primitive.
Definition zigbee-nwk.h:60
@ NLDE_NLME_NONE
No pending primitive.
Definition zigbee-nwk.h:57
@ NLME_START_ROUTER
Pending NLME-START-ROUTER.request primitive.
Definition zigbee-nwk.h:61
@ NLME_JOIN_INDICATION
Pending NLME-JOIN.indication primitive.
Definition zigbee-nwk.h:63
@ NLME_ROUTE_DISCOVERY
Pending NLME-ROUTE-DISCOVERY.request primitive.
Definition zigbee-nwk.h:64
@ NBR_CHILD
Neighbor is the child.
@ NBR_PARENT
Neighbor is the parent.
@ NBR_NONE
No relationship.
@ BEACON_LOSS
The beacon was lost following a synchronization request.
Definition zigbee-nwk.h:160
@ UNSUPPORTED_LEGACY
Deprecated security used in IEEE 802.15.4-2003.
Definition zigbee-nwk.h:158
@ ALREADY_PRESENT
Already present (Zigbee specification r22.1.0)
Definition zigbee-nwk.h:191
@ READ_ONLY
SET/GET request issued for a read only attribute.
Definition zigbee-nwk.h:184
@ MAX_FRM_COUNTER
Max Frame counter (IEEE 802.15.4, Zigbee specification r22.1.0)
Definition zigbee-nwk.h:197
@ UNSUPPORTED_SECURITY
The security applied is not supported.
Definition zigbee-nwk.h:159
@ DISABLE_TRX_FAILURE
The attempt to disable the transceier has failed.
Definition zigbee-nwk.h:163
@ FULL_CAPACITY
PAN at capacity.
Definition zigbee-nwk.h:153
@ NO_DATA
No response data were available following a request.
Definition zigbee-nwk.h:170
@ IMPROPER_KEY_TYPE
The key is not allowed to be used with that frame type.
Definition zigbee-nwk.h:156
@ TRANSACTION_OVERFLOW
There is no capacity to store the transaction.
Definition zigbee-nwk.h:176
@ SUPERFRAME_OVERLAP
Coordinator sperframe and this device superframe tx overlap.
Definition zigbee-nwk.h:185
@ NOT_PERMITED
Not permitted (Zigbee specification r22.1.0)
Definition zigbee-nwk.h:189
@ INVALID_REQUEST
Invalid request (Zigbee specification r22.1.0)
Definition zigbee-nwk.h:188
@ OUT_OF_CAP
(Deprecated) See IEEE 802.15.4-2003
Definition zigbee-nwk.h:172
@ NO_NETWORKS
No network (Zigbee specification r22.1.0)
Definition zigbee-nwk.h:196
@ SECURITY_ERROR
Cryptographic process of the frame failed(FAILED_SECURITY_CHECK).
Definition zigbee-nwk.h:164
@ UNSUPPORTED_ATTRIBUTE
Unsupported attribute (Zigbee specification r22.1.0)
Definition zigbee-nwk.h:195
@ TRANSACTION_EXPIRED
The transaction expired and its information discarded.
Definition zigbee-nwk.h:175
@ REALIGMENT
A coordinator realigment command has been received.
Definition zigbee-nwk.h:174
@ SUCCESS
The operation was completed successfully.
Definition zigbee-nwk.h:152
@ LIMIT_REACHED
Limit reached during network scan (IEEE 802.15.4-2011)
Definition zigbee-nwk.h:205
@ NO_SHORT_ADDRESS
Failure due to unallocated 16-bit short address.
Definition zigbee-nwk.h:171
@ INVALID_INTERFACE
Invalid interface (Zigbee specification r22.1.0)
Definition zigbee-nwk.h:204
@ INVALID_INDEX
A MAC PIB write failed because specified index is out of range.
Definition zigbee-nwk.h:183
@ UNAVAILABLE_KEY
Unavailable key, unknown or blacklisted.
Definition zigbee-nwk.h:178
@ INVALID_PARAMETER
Invalid Parameter (Zigbee specification r22.1.0)
Definition zigbee-nwk.h:187
@ INVALID_ADDRESS
Invalid source or destination address.
Definition zigbee-nwk.h:179
@ FRAME_NOT_BUFFERED
Frame not buffered (Zigbee specification r22.1.0)
Definition zigbee-nwk.h:203
@ IMPROPER_SECURITY_LEVEL
Insufficient security level expected by the recipient.
Definition zigbee-nwk.h:157
@ INVALID_HANDLE
When purging from TX queue handle was not found.
Definition zigbee-nwk.h:167
@ CHANNEL_ACCESS_FAILURE
A Tx could not take place due to activity in the CH.
Definition zigbee-nwk.h:161
@ TX_ACTIVE
The transceiver was already enabled.
Definition zigbee-nwk.h:177
@ BAD_CCM_OUTPUT
Bad ccm output (IEEE 802.15.4, Zigbee specification r22.1.0)
Definition zigbee-nwk.h:199
@ UNKNOWN_DEVICE
Unknown device (Zigbee specification r22.1.0)
Definition zigbee-nwk.h:194
@ ACCESS_DENIED
PAN access denied.
Definition zigbee-nwk.h:154
@ NEIGHBOR_TABLE_FULL
Neighbor table full (Zigbee specification r22.1.0)
Definition zigbee-nwk.h:193
@ FRAME_TOO_LONG
Frame more than aMaxPHYPacketSize or too large for CAP or GTS.
Definition zigbee-nwk.h:165
@ BT_TABLE_FULL
Bt table full (Zigbee specification r22.1.0)
Definition zigbee-nwk.h:202
@ DENIED
The GTS request has been denied by the PAN coordinator.
Definition zigbee-nwk.h:162
@ ROUTE_DISCOVERY_FAILED
Route discovery failed (Zigbee specification r22.1.0)
Definition zigbee-nwk.h:200
@ SYNC_FAILURE
Sync Failure (Zigbee specification r22.1.0)
Definition zigbee-nwk.h:192
@ TRACKING_OFF
This device is currently not tracking beacons.
Definition zigbee-nwk.h:182
@ COUNTER_ERROR
The frame counter of the received frame is invalid.
Definition zigbee-nwk.h:155
@ NO_ACK
No acknowledgment was received after macMaxFrameRetries.
Definition zigbee-nwk.h:168
@ STARTUP_FAILURE
Startup failure (Zigbee specification r22.1.0)
Definition zigbee-nwk.h:190
@ ON_TIME_TOO_LONG
RX enable request fail due to syms.
Definition zigbee-nwk.h:180
@ NO_BEACON
A scan operation failed to find any network beacons.
Definition zigbee-nwk.h:169
@ SCAN_IN_PROGRESS
The dev was scanning during this call (IEEE 802.5.4)
Definition zigbee-nwk.h:206
@ PAST_TIME
Rx enable request fail due to lack of time in superframe.
Definition zigbee-nwk.h:181
@ PAN_ID_CONFLICT
PAN id conflict detected and informed to the coordinator.
Definition zigbee-nwk.h:173
@ ROUTE_ERROR
Route error (Zigbee specification r22.1.0)
Definition zigbee-nwk.h:201
@ NO_KEY
No Key (Zigbee specification r22.1.0)
Definition zigbee-nwk.h:198
@ INVALID_GTS
Missing GTS transmit or undefined direction.
Definition zigbee-nwk.h:166
@ STOCHASTIC_ALLOC
Stochastic address allocation (Zigbee Specification r22.1.0 Section 3.6.1.7)
Definition zigbee-nwk.h:88
@ DISTRIBUTED_ALLOC
Distributed address allocation (Zigbee Specification r22.1.0 Section 3.6.1.6)
Definition zigbee-nwk.h:86
DiscoverRouteType
Zigbee Specification r22.1.0, Values of the discover route sub-field (Table 3-47)
@ ENABLE_ROUTE_DISCOVERY
Enable route discovery.
@ ASSOCIATION
The device is requesting to join a network through association.
Definition zigbee-nwk.h:107
@ DIRECT_OR_REJOIN
The device is joining directly or rejoining using the orphaning procedure.
Definition zigbee-nwk.h:108
@ NWK_COMMAND
Network command frame type.
@ DATA
Data frame type.
@ INTER_PAN
Inter-Pan frame type.
@ ROUTE_REP_CMD
Route response command.
@ ROUTE_REQ_CMD
Route request command.
StackProfile
Use to describe the identifier of the zigbee stack profile.
Definition zigbee-nwk.h:96
@ ZIGBEE_PRO
Zigbee stack profile 0x02 (Zigbee Pro, also known as r22.1.0, 3.0)
Definition zigbee-nwk.h:98
std::ostream & operator<<(std::ostream &os, const NwkStatus &state)
Overloaded operator to print the value of a NwkStatus.
RouteDiscoveryStatus
The status returned while attempting to find the next hop in route towards a specific destination or ...
Definition zigbee-nwk.h:120
@ NO_DISCOVER_ROUTE
We are currently not allowed to perform a route discovery for this route (RouteDiscover flag in netwo...
Definition zigbee-nwk.h:128
@ ROUTE_NOT_FOUND
The next hop was not found.
Definition zigbee-nwk.h:123
@ MANY_TO_ONE_ROUTE
A new Many-To-One route was created.
Definition zigbee-nwk.h:133
@ ROUTE_FOUND
The next hop toward the destination was found in our routing table or neighbor table (Mesh route).
Definition zigbee-nwk.h:121
@ NO_ROUTE_CHANGE
No route entry was created or updated during a Many-To-One process.
Definition zigbee-nwk.h:134
@ DISCOVER_UNDERWAY
The route was found in the tables but currently has no next hop.
Definition zigbee-nwk.h:130
@ ROUTE_UPDATED
A route was found and updated with a better route (Mesh route or Many-To-One route)
Definition zigbee-nwk.h:126
@ TABLE_FULL
Either the routing or neighbor table are full.
Definition zigbee-nwk.h:125
Every class exported by the ns3 library is enclosed in the ns3 namespace.
AddressMode m_dstAddrMode
Destination address mode.
Mac16Address m_dstAddr
Destination address.
uint16_t m_dstPanId
Destination PAN identifier.
AddressMode m_srcAddrMode
Source address mode.
uint8_t m_txOptions
Tx Options (bitfield)
MLME-ASSOCIATE.confirm params.
MLME-ASSOCIATE.indication params.
MLME-ASSOCIATE.request params.
Mac64Address m_coordExtAddr
The extended address of the coordinator with which to associate.
uint8_t m_coordAddrMode
The coordinator addressing mode for this primitive and subsequent MPDU.
uint8_t m_capabilityInfo
Specifies the operational capabilities of the associating device (bitmap).
Mac16Address m_coordShortAddr
The short address of the coordinator with which to associate.
uint8_t m_chNum
The channel number on which to attempt association.
uint32_t m_chPage
The channel page on which to attempt association.
uint16_t m_coordPanId
The identifier of the PAN with which to associate.
MLME-ASSOCIATE.response params.
Mac16Address m_assocShortAddr
The short address allocated by the coordinator on successful assoc.
MacStatus m_status
The status of the association attempt (As defined on Table 83 IEEE 802.15.4-2006)
Mac64Address m_extDevAddr
The extended address of the device requesting association.
MLME-BEACON-NOTIFY.indication params.
MLME-COMM-STATUS.indication params.
MLME-ORPHAN.indication params.
bool m_assocMember
T = allocated with this coord | F = otherwise.
Mac64Address m_orphanAddr
The address of the orphaned device.
Mac16Address m_shortAddr
The short address allocated.
MlmeScanType m_scanType
Indicates the type of scan performed as described in IEEE 802.15.4-2011 (5.1.2.1).
uint32_t m_scanChannels
The channel numbers to be scanned.
uint8_t m_scanDuration
The factor (0-14) used to calculate the length of time to spend scanning.
uint32_t m_chPage
The channel page on which to perform scan.
bool m_battLifeExt
Flag indicating whether or not the Battery life extension (BLE) features are used.
uint8_t m_logCh
Logical channel on which to start using the new superframe configuration.
uint32_t m_logChPage
Logical channel page on which to start using the new superframe configuration.
bool m_coorRealgn
True if a realignment request command is to be transmitted prior changing the superframe.
uint8_t m_bcnOrd
Beacon Order, Used to calculate the beacon interval, a value of 15 indicates no periodic beacons will...
bool m_panCoor
On true this device will become coordinator.
uint8_t m_sfrmOrd
Superframe Order, indicates the length of the CAP in time slots.
uint16_t m_PanId
Pan Identifier used by the device.
Mac64Address extAddress
The extended address of the device to which the request is send.
Definition zigbee-nwk.h:569
uint16_t panId
The PAN id used by the device to which the association request is send.
Definition zigbee-nwk.h:570
uint8_t channelPageCount
The number of the channel page structures contained in the channel list structure.
Definition zigbee-nwk.h:255
std::vector< uint32_t > channelsField
The set of channels for a given page.
Definition zigbee-nwk.h:257
Network Descriptor, Zigbee Specification r22.1.0, 3.2.2.4, Table 3-12.
Definition zigbee-nwk.h:454
uint16_t m_panId
The 16-bit PAN identifier of the network.
Definition zigbee-nwk.h:456
uint8_t m_updateId
The value of the UpdateID from the NIB.
Definition zigbee-nwk.h:457
uint8_t m_superframeOrder
The superframe order value of the underlying MAC (Determinates the value of the active period)
Definition zigbee-nwk.h:465
bool m_routerCapacity
TRUE = The device is able to accept join requests from router-capable devices.
Definition zigbee-nwk.h:469
bool m_endDeviceCapacity
TRUE= The device is able to accept join request from end devices.
Definition zigbee-nwk.h:471
StackProfile m_stackProfile
The Zigbee stack profile identifier in use in the discovered network.
Definition zigbee-nwk.h:459
uint8_t m_logCh
The current channel number occupied by the network.
Definition zigbee-nwk.h:458
uint8_t m_beaconOrder
The beacon order value of the underlying MAC.
Definition zigbee-nwk.h:463
uint8_t m_zigbeeVersion
The version of the zigbee protocol in use in the discovered network.
Definition zigbee-nwk.h:461
uint64_t m_extPanId
The 64-bit PAN identifier of the network.
Definition zigbee-nwk.h:455
bool m_permitJoining
TRUE = Indicates that at least one zigbee router on the network currently permits joining.
Definition zigbee-nwk.h:467
NLDE-DATA.confirm params.
Definition zigbee-nwk.h:272
uint8_t m_nsduHandle
The handle associated with the NSDU being confirmed.
Definition zigbee-nwk.h:275
NwkStatus m_status
The status of the corresponding request.
Definition zigbee-nwk.h:273
Time m_txTime
The time indication for the transmitted packet based on the local clock.
Definition zigbee-nwk.h:276
NLDE-DATA.indication params.
Definition zigbee-nwk.h:286
AddressMode m_dstAddrMode
Destination address mode.
Definition zigbee-nwk.h:287
Time m_rxTime
A time indication for the received packet based on the local clock.
Definition zigbee-nwk.h:293
uint32_t m_nsduLength
The number of octets comprising the NSDU being indicated.
Definition zigbee-nwk.h:291
uint8_t m_linkQuality
LQI value delivered by the MAC on receipt of this frame.
Definition zigbee-nwk.h:292
bool m_securityUse
An indication of whether the received data is using security.
Definition zigbee-nwk.h:295
Mac16Address m_srcAddr
The individual device address from which the NSDU originated.
Definition zigbee-nwk.h:290
Mac16Address m_dstAddr
The destination address to which the NSDU was sent.
Definition zigbee-nwk.h:289
NLDE-DATA.request params.
Definition zigbee-nwk.h:304
NLME-DIRECT-JOIN.confirm params.
Definition zigbee-nwk.h:428
NwkStatus m_status
The status the corresponding request.
Definition zigbee-nwk.h:429
Mac64Address m_deviceAddr
The IEEE EUI-64 address in the request to which this is a confirmation.
Definition zigbee-nwk.h:431
NLME-DIRECT-JOIN.request params.
Definition zigbee-nwk.h:415
NLME-JOIN.confirm params.
Definition zigbee-nwk.h:518
Mac16Address m_networkAddress
The 16 bit network address that was allocated to this device.
Definition zigbee-nwk.h:521
NwkStatus m_status
The status of the corresponding request.
Definition zigbee-nwk.h:519
uint8_t m_macInterfaceIndex
The value of the MAC index from nwkMacInterfaceTable.
Definition zigbee-nwk.h:529
uint64_t m_extendedPanId
The extended 64 bit PAN ID for the network of which the device is now a member.
Definition zigbee-nwk.h:524
ChannelList m_channelList
The structure indicating the current channel of the network that has been joined.
Definition zigbee-nwk.h:526
bool m_enhancedBeacon
True if using enhanced beacons (placeholder, not supported)
Definition zigbee-nwk.h:528
NLME-JOIN.indication params.
Definition zigbee-nwk.h:550
Mac64Address m_extendedAddress
The EUI-64 bit address of an entity that has been added to the network.
Definition zigbee-nwk.h:553
uint8_t m_capabilityInfo
Specifies the operational capabilities of the joining device.
Definition zigbee-nwk.h:555
JoiningMethod m_rejoinNetwork
This parameter indicates the method used to join the network.
Definition zigbee-nwk.h:557
Mac16Address m_networkAddress
The 16 bit network address of an entity that has been added to the network.
Definition zigbee-nwk.h:551
NLME-JOIN.request params.
Definition zigbee-nwk.h:496
ChannelList m_scanChannelList
The list of all channel pages and the associated channels that shall be scanned.
Definition zigbee-nwk.h:501
uint8_t m_capabilityInfo
The operating capabilities of the device being directly joined (Bit map).
Definition zigbee-nwk.h:505
uint64_t m_extendedPanId
The 64 bit PAN identifier of the the network to join.
Definition zigbee-nwk.h:497
NLME-NETWORK-DISCOVERY.confirm params.
Definition zigbee-nwk.h:481
uint8_t m_networkCount
Gives the number of networks discovered by the search.
Definition zigbee-nwk.h:484
std::vector< NetworkDescriptor > m_netDescList
A list of descriptors, one for each of the networks discovered.
Definition zigbee-nwk.h:485
NwkStatus m_status
The status of the corresponding request.
Definition zigbee-nwk.h:482
NLME-NETWORK-DISCOVERY.request params.
Definition zigbee-nwk.h:442
NLME-NETWORK-FORMATION.confirm params.
Definition zigbee-nwk.h:374
NwkStatus m_status
The status as a result of this request.
Definition zigbee-nwk.h:375
NLME-NETWORK-FORMATION.request params.
Definition zigbee-nwk.h:329
Mac16Address m_distributedNetworkAddress
The address of the device in a distributed network.
Definition zigbee-nwk.h:340
uint8_t m_superFrameOrder
The superframe order.
Definition zigbee-nwk.h:336
bool m_batteryLifeExtension
True: The zigbee coordinator is started supporting battery extension mode.
Definition zigbee-nwk.h:337
bool m_distributedNetwork
Indicates that distributed security will be used.
Definition zigbee-nwk.h:339
ChannelList m_scanChannelList
A structure that contain a description on the pages and their channels to be scanned.
Definition zigbee-nwk.h:330
uint8_t m_scanDuration
The time spent of each channel in symbols: aBaseSuperframeDuriantion * (2n+1).
Definition zigbee-nwk.h:333
NLME-ROUTE-DISCOVERY.confirm params.
Definition zigbee-nwk.h:400
NwkStatus m_status
The status as a result of this request.
Definition zigbee-nwk.h:401
NetworkStatusCode m_networkStatusCode
In case where.
Definition zigbee-nwk.h:403
NLME-ROUTE-DISCOVERY.request params.
Definition zigbee-nwk.h:385
NLME-START-ROUTER.confirm params.
Definition zigbee-nwk.h:593
NwkStatus m_status
The status of the corresponding request.
Definition zigbee-nwk.h:594
NLME-START-ROUTER.request params.
Definition zigbee-nwk.h:580