25#include "ns3/boolean.h"
26#include "ns3/channel.h"
27#include "ns3/ipv6-extension-header.h"
28#include "ns3/ipv6-l3-protocol.h"
30#include "ns3/mac16-address.h"
31#include "ns3/mac48-address.h"
32#include "ns3/mac64-address.h"
34#include "ns3/packet.h"
35#include "ns3/pointer.h"
36#include "ns3/simulator.h"
37#include "ns3/string.h"
38#include "ns3/udp-header.h"
39#include "ns3/udp-l4-protocol.h"
40#include "ns3/uinteger.h"
55 TypeId(
"ns3::SixLowPanNetDevice")
57 .SetGroupName(
"SixLowPan")
59 .AddAttribute(
"Rfc6282",
60 "Use RFC6282 (IPHC) if true, RFC4944 (HC1) otherwise.",
64 .AddAttribute(
"OmitUdpChecksum",
65 "Omit the UDP checksum in IPHC compression.",
70 "FragmentReassemblyListSize",
71 "The maximum size of the reassembly buffer (in packets). Zero meaning infinite.",
74 MakeUintegerChecker<uint16_t>())
76 "FragmentExpirationTimeout",
77 "When this timeout expires, the fragments will be cleared from the buffer.",
81 .AddAttribute(
"CompressionThreshold",
82 "The minimum MAC layer payload size.",
85 MakeUintegerChecker<uint32_t>())
86 .AddAttribute(
"ForceEtherType",
87 "Force a specific EtherType in L2 frames.",
91 .AddAttribute(
"EtherType",
92 "The specific EtherType to be used in L2 frames.",
95 MakeUintegerChecker<uint16_t>())
96 .AddAttribute(
"UseMeshUnder",
97 "Use a mesh-under routing protocol.",
101 .AddAttribute(
"MeshUnderRadius",
102 "Hops Left to use in mesh-under.",
105 MakeUintegerChecker<uint8_t>())
106 .AddAttribute(
"MeshCacheLength",
107 "Length of the cache for each source.",
110 MakeUintegerChecker<uint16_t>())
111 .AddAttribute(
"MeshUnderJitter",
112 "The jitter in ms a node uses to forward mesh-under packets - used to "
113 "prevent collisions",
114 StringValue(
"ns3::UniformRandomVariable[Min=0.0|Max=10.0]"),
116 MakePointerChecker<RandomVariableStream>())
117 .AddTraceSource(
"Tx",
118 "Send - packet (including 6LoWPAN header), "
119 "SixLoWPanNetDevice Ptr, interface index.",
121 "ns3::SixLowPanNetDevice::RxTxTracedCallback")
122 .AddTraceSource(
"Rx",
123 "Receive - packet (including 6LoWPAN header), "
124 "SixLoWPanNetDevice Ptr, interface index.",
126 "ns3::SixLowPanNetDevice::RxTxTracedCallback")
127 .AddTraceSource(
"Drop",
128 "Drop - DropReason, packet (including 6LoWPAN header), "
129 "SixLoWPanNetDevice Ptr, interface index.",
131 "ns3::SixLowPanNetDevice::DropTracedCallback");
137 m_netDevice(nullptr),
142 m_rng = CreateObject<UniformRandomVariable>();
159 NS_LOG_DEBUG(
"RegisterProtocolHandler for " << device->GetInstanceTypeId().GetName());
161 uint16_t protocolType = 0;
197 iter->second =
nullptr;
212 NS_LOG_FUNCTION(
this << incomingPort << packet << protocol << src << dst);
214 uint8_t dispatchRawVal = 0;
220 copyPkt->CopyData(&dispatchRawVal,
sizeof(dispatchRawVal));
222 bool isPktDecompressed =
false;
223 bool fragmented =
false;
227 NS_LOG_DEBUG(
"Dispatches: " <<
int(dispatchRawVal) <<
" - " <<
int(dispatchVal));
231 bool hasMesh =
false;
237 copyPkt->RemoveHeader(meshHdr);
238 copyPkt->CopyData(&dispatchRawVal,
sizeof(dispatchRawVal));
244 copyPkt->RemoveHeader(bc0Hdr);
245 copyPkt->CopyData(&dispatchRawVal,
sizeof(dispatchRawVal));
253 NS_LOG_LOGIC(
"Dropped packet - we only support mesh if it is paired with a BC0");
262 NS_LOG_LOGIC(
"We have already seen this, no further processing.");
273 "SixLowPan mesh-under flooding can not currently handle extended address "
274 "final destinations: "
277 "SixLowPan mesh-under flooding can not currently handle devices using "
278 "extended addresses: "
291 NS_LOG_LOGIC(
"Not forwarding packet -- hop limit reached");
295 NS_LOG_LOGIC(
"Not forwarding packet -- I am the originator");
301 sendPkt->AddHeader(bc0Hdr);
302 sendPkt->AddHeader(meshHdr);
338 if (!isPktDecompressed)
344 copyPkt->CopyData(&dispatchRawVal,
sizeof(dispatchRawVal));
352 NS_LOG_DEBUG(
"Packet without compression. Length: " << copyPkt->GetSize());
355 copyPkt->RemoveHeader(uncompressedHdr);
356 isPktDecompressed =
true;
366 isPktDecompressed =
true;
380 isPktDecompressed =
true;
384 NS_LOG_DEBUG(
"Unsupported 6LoWPAN encoding: dropping.");
389 if (!isPktDecompressed)
394 NS_LOG_DEBUG(
"Packet decompressed length: " << copyPkt->GetSize());
395 NS_LOG_DEBUG(
"Packet decompressed received: " << *copyPkt);
490 return m_netDevice->AddLinkChangeCallback(callback);
563 ret =
DoSend(packet, src, dest, protocolNumber,
false);
571 uint16_t protocolNumber)
576 ret =
DoSend(packet, src, dest, protocolNumber,
true);
584 uint16_t protocolNumber,
587 NS_LOG_FUNCTION(
this << *packet << src << dest << protocolNumber << doSendFrom);
592 uint32_t origPacketSize = packet->GetSize();
615 uint16_t
pktSize = packet->GetSize();
651 NS_LOG_LOGIC(
"Compressed packet too short, using uncompressed one");
654 packet->AddHeader(ipv6UncompressedHdr);
664 NS_LOG_LOGIC(
"Fragmentation: Packet size " << packet->GetSize() <<
" - Mtu "
667 std::list<Ptr<Packet>> fragmentList;
668 DoFragmentation(packet, origPacketSize, origHdrSize, extraHdrSize, fragmentList);
670 for (
auto it = fragmentList.begin(); it != fragmentList.end(); it++)
672 NS_LOG_DEBUG(
"SixLowPanNetDevice::Send (Fragment) " << **it);
678 (*it)->AddHeader(bc0Hdr);
679 (*it)->AddHeader(meshHdr);
683 success &=
m_netDevice->SendFrom(*it, src, destination, protocolNumber);
687 success &=
m_netDevice->Send(*it, destination, protocolNumber);
699 packet->AddHeader(bc0Hdr);
700 packet->AddHeader(meshHdr);
706 ret =
m_netDevice->SendFrom(packet, src, destination, protocolNumber);
711 ret =
m_netDevice->Send(packet, destination, protocolNumber);
771 NS_LOG_DEBUG(
"Original packet: " << *packet <<
" Size " << packet->GetSize());
773 if (packet->PeekHeader(ipHeader) != 0)
775 packet->RemoveHeader(ipHeader);
786 NS_LOG_LOGIC(
"Checking source compression: " << mySrcAddr <<
" - " << srcAddr);
789 bool isSrcSrc = (memcmp(bufOne + 8, bufTwo + 8, 8) == 0);
816 NS_LOG_LOGIC(
"Checking destination compression: " << myDstAddr <<
" - " << dstAddr);
819 bool isDstDst = (memcmp(bufOne + 8, bufTwo + 8, 8) == 0);
860 NS_LOG_DEBUG(
"HC1 Compression - packet size = " << packet->GetSize());
862 packet->AddHeader(hc1Header);
878 uint32_t ret [[maybe_unused]] = packet->RemoveHeader(encoding);
879 NS_LOG_DEBUG(
"removed " << ret <<
" bytes - pkt is " << *packet);
883 switch (encoding.GetSrcCompression())
885 const uint8_t* interface;
886 const uint8_t* prefix;
890 prefix = encoding.GetSrcPrefix();
891 interface = encoding.GetSrcInterface();
892 for (
int j = 0; j < 8; j++)
894 address[j + 8] = interface[j];
895 address[j] = prefix[j];
900 prefix = encoding.GetSrcPrefix();
901 for (
int j = 0; j < 8; j++)
904 address[j] = prefix[j];
909 interface = encoding.GetSrcInterface();
912 for (
int j = 0; j < 8; j++)
914 address[j + 8] = interface[j];
923 switch (encoding.GetDstCompression())
925 const uint8_t* interface;
926 const uint8_t* prefix;
930 prefix = encoding.GetDstPrefix();
931 interface = encoding.GetDstInterface();
932 for (
int j = 0; j < 8; j++)
934 address[j + 8] = interface[j];
935 address[j] = prefix[j];
940 prefix = encoding.GetDstPrefix();
941 for (
int j = 0; j < 8; j++)
944 address[j] = prefix[j];
949 interface = encoding.GetDstInterface();
952 for (
int j = 0; j < 8; j++)
954 address[j + 8] = interface[j];
963 if (!encoding.IsTcflCompression())
979 encoding.IsHc2HeaderPresent() ==
false,
980 "6LoWPAN: error in decompressing HC1 encoding, unsupported L4 compressed header present.");
982 packet->AddHeader(ipHeader);
984 NS_LOG_DEBUG(
"Rebuilt packet: " << *packet <<
" Size " << packet->GetSize());
996 NS_LOG_DEBUG(
"Original packet: " << *packet <<
" Size " << packet->GetSize() <<
" src: " << src
999 if (packet->PeekHeader(ipHeader) != 0)
1001 packet->RemoveHeader(ipHeader);
1036 iphcHeader.
SetNh(
true);
1041 iphcHeader.
SetNh(
true);
1050 iphcHeader.
SetNh(
true);
1055 iphcHeader.
SetNh(
false);
1062 iphcHeader.
SetNh(
false);
1087 iphcHeader.
SetCid(
false);
1088 iphcHeader.
SetSac(
false);
1089 iphcHeader.
SetDac(
false);
1092 uint8_t unicastAddrCheckerBuf[16];
1093 checker.
GetBytes(unicastAddrCheckerBuf);
1094 uint8_t addressBuf[16];
1099 uint8_t srcContextId;
1112 NS_LOG_LOGIC(
"Checking stateful source compression: " << srcAddr);
1115 if (srcContextId != 0)
1135 uint8_t serializedCleanedAddress[16];
1136 cleanedAddr.
Serialize(serializedCleanedAddress);
1138 if (serializedCleanedAddress[8] == 0x00 &&
1139 serializedCleanedAddress[9] == 0x00 &&
1140 serializedCleanedAddress[10] == 0x00 &&
1141 serializedCleanedAddress[11] == 0xff &&
1142 serializedCleanedAddress[12] == 0xfe &&
1143 serializedCleanedAddress[13] == 0x00)
1158 NS_LOG_LOGIC(
"Checking stateless source compression: " << srcAddr);
1162 uint8_t serializedSrcAddress[16];
1163 srcAddr.
Serialize(serializedSrcAddress);
1169 else if (memcmp(addressBuf, unicastAddrCheckerBuf, 14) == 0)
1190 iphcHeader.
SetM(
true);
1194 iphcHeader.
SetM(
false);
1202 NS_LOG_LOGIC(
"Checking destination compression: " << dstAddr);
1204 uint8_t serializedDstAddress[16];
1205 dstAddr.
Serialize(serializedDstAddress);
1207 if (!iphcHeader.
GetM())
1211 uint8_t dstContextId;
1215 NS_LOG_LOGIC(
"Checking stateful destination compression: " << dstAddr);
1218 if (dstContextId != 0)
1238 uint8_t serializedCleanedAddress[16];
1239 cleanedAddr.
Serialize(serializedCleanedAddress);
1241 if (serializedCleanedAddress[8] == 0x00 &&
1242 serializedCleanedAddress[9] == 0x00 &&
1243 serializedCleanedAddress[10] == 0x00 &&
1244 serializedCleanedAddress[11] == 0xff &&
1245 serializedCleanedAddress[12] == 0xfe &&
1246 serializedCleanedAddress[13] == 0x00)
1260 NS_LOG_LOGIC(
"Checking stateless destination compression: " << dstAddr);
1266 else if (memcmp(addressBuf, unicastAddrCheckerBuf, 14) == 0)
1287 uint8_t dstContextId;
1293 uint8_t dstInlinePart[6] = {};
1294 dstInlinePart[0] = serializedDstAddress[1];
1295 dstInlinePart[1] = serializedDstAddress[2];
1296 dstInlinePart[2] = serializedDstAddress[12];
1297 dstInlinePart[3] = serializedDstAddress[13];
1298 dstInlinePart[4] = serializedDstAddress[14];
1299 dstInlinePart[5] = serializedDstAddress[15];
1302 if (dstContextId != 0)
1315 uint8_t multicastAddrCheckerBuf[16];
1317 multicastCheckAddress.
GetBytes(multicastAddrCheckerBuf);
1320 if (memcmp(addressBuf, multicastAddrCheckerBuf, 15) == 0)
1327 else if ((addressBuf[0] == multicastAddrCheckerBuf[0]) &&
1328 (memcmp(addressBuf + 2, multicastAddrCheckerBuf + 2, 11) == 0))
1330 uint8_t dstInlinePart[4] = {};
1331 memcpy(dstInlinePart, serializedDstAddress + 1, 1);
1332 memcpy(dstInlinePart + 1, serializedDstAddress + 13, 3);
1338 else if ((addressBuf[0] == multicastAddrCheckerBuf[0]) &&
1339 (memcmp(addressBuf + 2, multicastAddrCheckerBuf + 2, 9) == 0))
1341 uint8_t dstInlinePart[6] = {};
1342 memcpy(dstInlinePart, serializedDstAddress + 1, 1);
1343 memcpy(dstInlinePart + 1, serializedDstAddress + 11, 5);
1357 NS_LOG_DEBUG(
"IPHC Compression - packet size = " << packet->GetSize());
1359 packet->AddHeader(iphcHeader);
1361 NS_LOG_DEBUG(
"Packet after IPHC compression: " << *packet);
1397 uint32_t ret [[maybe_unused]] = packet->RemoveHeader(encoding);
1398 NS_LOG_DEBUG(
"removed " << ret <<
" bytes - pkt is " << *packet);
1404 if (encoding.GetSac())
1413 uint8_t contextId = encoding.GetSrcContextId();
1416 NS_LOG_LOGIC(
"Unknown Source compression context (" << +contextId
1417 <<
"), dropping packet");
1422 NS_LOG_LOGIC(
"Expired Source compression context (" << +contextId
1423 <<
"), dropping packet");
1427 uint8_t contextPrefix[16];
1429 uint8_t contextLength =
m_contextTable[contextId].contextPrefix.GetPrefixLength();
1431 uint8_t srcAddress[16] = {};
1434 memcpy(srcAddress + 8, encoding.GetSrcInlinePart(), 8);
1438 srcAddress[11] = 0xff;
1439 srcAddress[12] = 0xfe;
1440 memcpy(srcAddress + 14, encoding.GetSrcInlinePart(), 2);
1447 uint8_t bytesToCopy = contextLength / 8;
1448 uint8_t bitsToCopy = contextLength % 8;
1451 for (uint8_t i = 0; i < bytesToCopy; i++)
1453 srcAddress[i] = contextPrefix[i];
1457 uint8_t addressBitMask = (1 << (8 - bitsToCopy)) - 1;
1458 uint8_t prefixBitMask = ~addressBitMask;
1459 srcAddress[bytesToCopy] = (contextPrefix[bytesToCopy] & prefixBitMask) |
1460 (srcAddress[bytesToCopy] & addressBitMask);
1471 uint8_t srcAddress[16] = {};
1472 memcpy(srcAddress, encoding.GetSrcInlinePart(), 16);
1477 uint8_t srcAddress[16] = {};
1478 memcpy(srcAddress + 8, encoding.GetSrcInlinePart(), 8);
1479 srcAddress[0] = 0xfe;
1480 srcAddress[1] = 0x80;
1485 uint8_t srcAddress[16] = {};
1486 memcpy(srcAddress + 14, encoding.GetSrcInlinePart(), 2);
1487 srcAddress[0] = 0xfe;
1488 srcAddress[1] = 0x80;
1489 srcAddress[11] = 0xff;
1490 srcAddress[12] = 0xfe;
1499 if (encoding.GetDac())
1510 uint8_t contextId = encoding.GetDstContextId();
1513 NS_LOG_LOGIC(
"Unknown Destination compression context (" << +contextId
1514 <<
"), dropping packet");
1519 NS_LOG_LOGIC(
"Expired Destination compression context (" << +contextId
1520 <<
"), dropping packet");
1524 uint8_t contextPrefix[16];
1526 uint8_t contextLength =
m_contextTable[contextId].contextPrefix.GetPrefixLength();
1528 if (!encoding.GetM())
1531 uint8_t dstAddress[16] = {};
1534 memcpy(dstAddress + 8, encoding.GetDstInlinePart(), 8);
1538 dstAddress[11] = 0xff;
1539 dstAddress[12] = 0xfe;
1540 memcpy(dstAddress + 14, encoding.GetDstInlinePart(), 2);
1547 uint8_t bytesToCopy =
m_contextTable[contextId].contextPrefix.GetPrefixLength() / 8;
1548 uint8_t bitsToCopy = contextLength % 8;
1551 for (uint8_t i = 0; i < bytesToCopy; i++)
1553 dstAddress[i] = contextPrefix[i];
1557 uint8_t addressBitMask = (1 << (8 - bitsToCopy)) - 1;
1558 uint8_t prefixBitMask = ~addressBitMask;
1559 dstAddress[bytesToCopy] = (contextPrefix[bytesToCopy] & prefixBitMask) |
1560 (dstAddress[bytesToCopy] & addressBitMask);
1568 uint8_t dstAddress[16] = {};
1569 dstAddress[0] = 0xff;
1570 memcpy(dstAddress + 1, encoding.GetDstInlinePart(), 2);
1571 dstAddress[3] = contextLength;
1572 memcpy(dstAddress + 4, contextPrefix, 8);
1573 memcpy(dstAddress + 12, encoding.GetDstInlinePart() + 2, 4);
1580 if (!encoding.GetM())
1585 uint8_t dstAddress[16] = {};
1586 memcpy(dstAddress, encoding.GetDstInlinePart(), 16);
1591 uint8_t dstAddress[16] = {};
1592 memcpy(dstAddress + 8, encoding.GetDstInlinePart(), 8);
1593 dstAddress[0] = 0xfe;
1594 dstAddress[1] = 0x80;
1599 uint8_t dstAddress[16] = {};
1600 memcpy(dstAddress + 14, encoding.GetDstInlinePart(), 2);
1601 dstAddress[0] = 0xfe;
1602 dstAddress[1] = 0x80;
1603 dstAddress[11] = 0xff;
1604 dstAddress[12] = 0xfe;
1617 uint8_t dstAddress[16] = {};
1618 memcpy(dstAddress, encoding.GetDstInlinePart(), 16);
1623 uint8_t dstAddress[16] = {};
1624 dstAddress[0] = 0xff;
1625 memcpy(dstAddress + 1, encoding.GetDstInlinePart(), 1);
1626 memcpy(dstAddress + 11, encoding.GetDstInlinePart() + 1, 5);
1631 uint8_t dstAddress[16] = {};
1632 dstAddress[0] = 0xff;
1633 memcpy(dstAddress + 1, encoding.GetDstInlinePart(), 1);
1634 memcpy(dstAddress + 13, encoding.GetDstInlinePart() + 1, 3);
1639 uint8_t dstAddress[16] = {};
1640 dstAddress[0] = 0xff;
1641 dstAddress[1] = 0x02;
1642 memcpy(dstAddress + 15, encoding.GetDstInlinePart(), 1);
1649 uint8_t traf = 0x00;
1650 switch (encoding.GetTf())
1653 traf |= encoding.GetEcn();
1654 traf = (traf << 6) | encoding.GetDscp();
1656 ipHeader.
SetFlowLabel(encoding.GetFlowLabel() & 0xfff);
1659 traf |= encoding.GetEcn();
1665 traf |= encoding.GetEcn();
1666 traf = (traf << 6) | encoding.GetDscp();
1676 if (encoding.GetNh())
1679 uint8_t dispatchRawVal = 0;
1682 packet->CopyData(&dispatchRawVal,
sizeof(dispatchRawVal));
1714 packet->AddHeader(ipHeader);
1716 NS_LOG_DEBUG(
"Rebuilt packet: " << *packet <<
" Size " << packet->GetSize());
1736 packet->PeekHeader(hopHeader);
1740 "LOWPAN_NHC MUST NOT be used to encode IPv6 Extension Headers "
1741 "that have more than 255 octets following the Length field after compression. "
1742 "Packet uncompressed.");
1746 size += packet->RemoveHeader(hopHeader);
1755 nhcHeader.
SetNh(
true);
1760 nhcHeader.
SetNh(
true);
1769 nhcHeader.
SetNh(
true);
1774 nhcHeader.
SetNh(
false);
1781 nhcHeader.
SetNh(
false);
1795 packet->PeekHeader(routingHeader);
1799 "LOWPAN_NHC MUST NOT be used to encode IPv6 Extension Headers "
1800 "that have more than 255 octets following the Length field after compression. "
1801 "Packet uncompressed.");
1805 size += packet->RemoveHeader(routingHeader);
1814 nhcHeader.
SetNh(
true);
1819 nhcHeader.
SetNh(
true);
1828 nhcHeader.
SetNh(
true);
1833 nhcHeader.
SetNh(
false);
1840 nhcHeader.
SetNh(
false);
1854 packet->PeekHeader(fragHeader);
1858 "LOWPAN_NHC MUST NOT be used to encode IPv6 Extension Headers "
1859 "that have more than 255 octets following the Length field after compression. "
1860 "Packet uncompressed.");
1863 size += packet->RemoveHeader(fragHeader);
1872 nhcHeader.
SetNh(
true);
1877 nhcHeader.
SetNh(
true);
1886 nhcHeader.
SetNh(
true);
1891 nhcHeader.
SetNh(
false);
1898 nhcHeader.
SetNh(
false);
1912 packet->PeekHeader(destHeader);
1916 "LOWPAN_NHC MUST NOT be used to encode IPv6 Extension Headers "
1917 "that have more than 255 octets following the Length field after compression. "
1918 "Packet uncompressed.");
1921 size += packet->RemoveHeader(destHeader);
1930 nhcHeader.
SetNh(
true);
1935 nhcHeader.
SetNh(
true);
1944 nhcHeader.
SetNh(
true);
1949 nhcHeader.
SetNh(
false);
1956 nhcHeader.
SetNh(
false);
1970 NS_ABORT_MSG(
"IPv6 Mobility Header is not supported in ns-3 yet");
1979 NS_LOG_DEBUG(
"NHC Compression - packet size = " << packet->GetSize());
1981 packet->AddHeader(nhcHeader);
1983 NS_LOG_DEBUG(
"Packet after NHC compression: " << *packet);
1987std::pair<uint8_t, bool>
1998 uint32_t ret [[maybe_unused]] = packet->RemoveHeader(encoding);
1999 NS_LOG_DEBUG(
"removed " << ret <<
" bytes - pkt is " << *packet);
2007 uint8_t blobData[260];
2008 blobSize = encoding.CopyBlob(blobData + 2, 260 - 2);
2009 uint8_t paddingSize = 0;
2011 uint8_t actualEncodedHeaderType = encoding.GetEid();
2012 uint8_t actualHeaderType;
2015 switch (actualEncodedHeaderType)
2019 if (encoding.GetNh())
2022 uint8_t dispatchRawVal = 0;
2025 packet->CopyData(&dispatchRawVal,
sizeof(dispatchRawVal));
2040 blobData[0] = encoding.GetNextHeader();
2044 if ((blobSize + 2) % 8 > 0)
2046 paddingSize = 8 - (blobSize + 2) % 8;
2048 if (paddingSize == 1)
2050 blobData[blobSize + 2] = 0;
2052 else if (paddingSize > 1)
2054 blobData[blobSize + 2] = 1;
2055 blobData[blobSize + 2 + 1] = paddingSize - 2;
2056 for (uint8_t i = 0; i < paddingSize - 2; i++)
2058 blobData[blobSize + 2 + 2 + i] = 0;
2061 blobData[1] = ((blobSize + 2 + paddingSize) >> 3) - 1;
2063 blob.
Begin().
Write(blobData, blobSize + 2 + paddingSize);
2066 packet->AddHeader(hopHeader);
2071 if (encoding.GetNh())
2074 uint8_t dispatchRawVal = 0;
2077 packet->CopyData(&dispatchRawVal,
sizeof(dispatchRawVal));
2092 blobData[0] = encoding.GetNextHeader();
2094 blobData[1] = ((blobSize + 2) >> 3) - 1;
2098 packet->AddHeader(routingHeader);
2103 if (encoding.GetNh())
2106 uint8_t dispatchRawVal = 0;
2109 packet->CopyData(&dispatchRawVal,
sizeof(dispatchRawVal));
2124 blobData[0] = encoding.GetNextHeader();
2132 packet->AddHeader(fragHeader);
2137 if (encoding.GetNh())
2140 uint8_t dispatchRawVal = 0;
2143 packet->CopyData(&dispatchRawVal,
sizeof(dispatchRawVal));
2158 blobData[0] = encoding.GetNextHeader();
2162 if ((blobSize + 2) % 8 > 0)
2164 paddingSize = 8 - (blobSize + 2) % 8;
2166 if (paddingSize == 1)
2168 blobData[blobSize + 2] = 0;
2170 else if (paddingSize > 1)
2172 blobData[blobSize + 2] = 1;
2173 blobData[blobSize + 2 + 1] = paddingSize - 2;
2174 for (uint8_t i = 0; i < paddingSize - 2; i++)
2176 blobData[blobSize + 2 + 2 + i] = 0;
2179 blobData[1] = ((blobSize + 2 + paddingSize) >> 3) - 1;
2181 blob.
Begin().
Write(blobData, blobSize + 2 + paddingSize);
2184 packet->AddHeader(destHeader);
2188 NS_ABORT_MSG(
"IPv6 Mobility Header is not supported in ns-3 yet");
2195 return std::pair<uint8_t, bool>(0,
true);
2199 NS_ABORT_MSG(
"Trying to decode unknown Extension Header");
2203 NS_LOG_DEBUG(
"Rebuilt packet: " << *packet <<
" Size " << packet->GetSize());
2204 return std::pair<uint8_t, bool>(actualHeaderType,
false);
2216 NS_ASSERT_MSG(packet->PeekHeader(udpHeader) != 0,
"UDP header not found, abort");
2218 size += packet->RemoveHeader(udpHeader);
2221 udpNhcHeader.
SetC(
false);
2227 udpNhcHeader.
SetC(
true);
2255 "UDP_NHC Compression - UDP_NHC header size = " << udpNhcHeader.
GetSerializedSize());
2256 NS_LOG_DEBUG(
"UDP_NHC Compression - packet size = " << packet->GetSize());
2258 packet->AddHeader(udpNhcHeader);
2260 NS_LOG_DEBUG(
"Packet after UDP_NHC compression: " << *packet);
2273 uint32_t ret [[maybe_unused]] = packet->RemoveHeader(encoding);
2274 NS_LOG_DEBUG(
"removed " << ret <<
" bytes - pkt is " << *packet);
2277 switch (encoding.GetPorts())
2286 temp = (0xf0 << 8) | encoding.GetDstPort();
2290 temp = (0xf0 << 8) | encoding.GetSrcPort();
2295 temp = (0xf0b << 4) | encoding.GetSrcPort();
2297 temp = (0xf0b << 4) | encoding.GetDstPort();
2305 if (encoding.GetC())
2310 packet->AddHeader(udpHeader);
2314 NS_LOG_LOGIC(
"Forcing UDP Checksum to " << encoding.GetChecksum());
2316 packet->AddHeader(udpHeader);
2322 packet->AddHeader(udpHeader);
2325 NS_LOG_DEBUG(
"Rebuilt packet: " << *packet <<
" Size " << packet->GetSize());
2339 uint16_t offsetData = 0;
2340 uint16_t offset = 0;
2345 auto tag =
static_cast<uint16_t
>(
m_rng->
GetValue(0, 65535));
2354 "6LoWPAN: can not fragment, 6LoWPAN headers are bigger than MTU");
2357 size = l2Mtu - frag1Hdr.
GetSerializedSize() - compressedHeaderSize - extraHdrSize;
2359 size += compressedHeaderSize;
2363 Ptr<Packet> fragment1 = p->CreateFragment(offsetData, size);
2364 offset += size + origHdrSize - compressedHeaderSize;
2367 fragment1->AddHeader(frag1Hdr);
2368 listFragments.push_back(fragment1);
2370 bool moreFrag =
true;
2389 NS_LOG_LOGIC(
"Fragment creation - " << offset <<
", " << offset);
2390 Ptr<Packet> fragment = p->CreateFragment(offsetData, size);
2391 NS_LOG_LOGIC(
"Fragment created - " << offset <<
", " << fragment->GetSize());
2396 fragment->AddHeader(fragNHdr);
2397 listFragments.push_back(fragment);
2413 key.first = std::pair<Address, Address>(src, dst);
2416 uint16_t offset = 0;
2430 uint8_t dispatchRawValFrag1 = 0;
2433 p->RemoveHeader(frag1Header);
2435 p->CopyData(&dispatchRawValFrag1,
sizeof(dispatchRawValFrag1));
2437 NS_LOG_DEBUG(
"Dispatches: " <<
int(dispatchRawValFrag1) <<
" - " <<
int(dispatchValFrag1));
2440 switch (dispatchValFrag1)
2444 p->RemoveHeader(uncompressedHdr);
2462 key.second = std::pair<uint16_t, uint16_t>(frag1Header.
GetDatagramSize(),
2467 p->RemoveHeader(fragNHeader);
2470 key.second = std::pair<uint16_t, uint16_t>(fragNHeader.
GetDatagramSize(),
2485 std::list<Ptr<Packet>> storedFragments =
m_fragments[oldestKey]->GetFragments();
2486 for (
auto fragIter = storedFragments.begin(); fragIter != storedFragments.end();
2496 fragments = Create<Fragments>();
2498 m_fragments.insert(std::make_pair(key, fragments));
2502 fragments->SetTimeoutIter(iter);
2506 fragments = it->second;
2509 fragments->AddFragment(p, offset);
2515 fragments->AddFirstFragment(packet);
2518 if (fragments->IsEntire())
2520 packet = fragments->GetPacket();
2524 packet->RemoveHeader(frag1Header);
2526 NS_LOG_LOGIC(
"Rebuilt packet. Size " << packet->GetSize() <<
" - " << *packet);
2528 fragments =
nullptr;
2552 std::list<std::pair<Ptr<Packet>, uint16_t>>::iterator it;
2553 bool duplicate =
false;
2557 if (it->second > fragmentOffset)
2561 if (it->second == fragmentOffset)
2565 "Duplicate fragment size differs. Aborting.");
2571 m_fragments.insert(it, std::make_pair(fragment, fragmentOffset));
2580 m_firstFragment = fragment;
2589 uint16_t lastEndOffset = 0;
2596 NS_LOG_LOGIC(
"Checking overlaps " << lastEndOffset <<
" - " << it->second);
2598 if (lastEndOffset < it->
second)
2604 uint16_t fragmentEnd = it->first->GetSize() + it->second;
2605 lastEndOffset = std::max(lastEndOffset, fragmentEnd);
2609 return ret && lastEndOffset == m_packetSize;
2620 uint16_t lastEndOffset = 0;
2622 p->AddAtEnd(m_firstFragment);
2624 lastEndOffset = it->first->GetSize();
2628 if (lastEndOffset > it->second)
2630 NS_ABORT_MSG(
"Overlapping fragments found, forbidden condition");
2635 p->AddAtEnd(it->first);
2637 lastEndOffset += it->first->GetSize();
2650std::list<Ptr<Packet>>
2653 std::list<Ptr<Packet>> fragments;
2656 fragments.push_back(iter->first);
2664 m_timeoutIter = iter;
2670 return m_timeoutIter;
2679 std::list<Ptr<Packet>> storedFragments = it->second->GetFragments();
2680 for (
auto fragIter = storedFragments.begin(); fragIter != storedFragments.end(); fragIter++)
2685 it->second =
nullptr;
2744 bool compressionAllowed,
2748 << contextPrefix << compressionAllowed << validLifetime.
As(
Time::S));
2752 NS_LOG_LOGIC(
"Invalid context ID (" << +contextId <<
"), ignoring");
2756 if (validLifetime ==
Time(0))
2758 NS_LOG_LOGIC(
"Context (" << +contextId <<
"), removed (validity time is zero)");
2764 m_contextTable[contextId].compressionAllowed = compressionAllowed;
2771 bool& compressionAllowed,
2772 Time& validLifetime)
2778 NS_LOG_LOGIC(
"Invalid context ID (" << +contextId <<
"), ignoring");
2784 NS_LOG_LOGIC(
"Context not found (" << +contextId <<
"), ignoring");
2789 compressionAllowed =
m_contextTable[contextId].compressionAllowed;
2802 NS_LOG_LOGIC(
"Invalid context ID (" << +contextId <<
"), ignoring");
2808 NS_LOG_LOGIC(
"Context not found (" << +contextId <<
"), ignoring");
2822 NS_LOG_LOGIC(
"Invalid context ID (" << +contextId <<
"), ignoring");
2828 NS_LOG_LOGIC(
"Context not found (" << +contextId <<
"), ignoring");
2841 NS_LOG_LOGIC(
"Invalid context ID (" << +contextId <<
"), ignoring");
2847 NS_LOG_LOGIC(
"Context not found (" << +contextId <<
"), ignoring");
2868 << +contextId <<
" "
2872 contextId = iter.first;
2896 if (contextLength <= 64)
2898 uint8_t contextBytes[16];
2899 uint8_t addressBytes[16];
2902 address.GetBytes(addressBytes);
2904 if (addressBytes[3] == contextLength && addressBytes[4] == contextBytes[0] &&
2905 addressBytes[5] == contextBytes[1] && addressBytes[6] == contextBytes[2] &&
2906 addressBytes[7] == contextBytes[3] && addressBytes[8] == contextBytes[4] &&
2907 addressBytes[9] == contextBytes[5] && addressBytes[10] == contextBytes[6] &&
2908 addressBytes[11] == contextBytes[7])
2911 << +contextId <<
" "
2915 contextId = iter.first;
2927 uint8_t addressBytes[16];
2928 address.GetBytes(addressBytes);
2931 uint8_t bytesToClean = prefixLength / 8;
2932 uint8_t bitsToClean = prefixLength % 8;
2933 for (uint8_t i = 0; i < bytesToClean; i++)
2935 addressBytes[i] = 0;
2939 uint8_t cleanupMask = (1 << bitsToClean) - 1;
2940 addressBytes[bytesToClean] &= cleanupMask;
2945 return cleanedAddress;
a polymophic address class
uint32_t CopyTo(uint8_t buffer[MAX_SIZE]) const
Copy the address bytes into a buffer.
AttributeValue implementation for Boolean.
void Write(const uint8_t *buffer, uint32_t size)
automatically resized byte buffer
void AddAtStart(uint32_t start)
Buffer::Iterator Begin() const
void RemoveAtStart(uint32_t start)
const uint8_t * PeekData() const
bool IsNull() const
Check for null implementation.
void Cancel()
This method is syntactic sugar for the ns3::Simulator::Cancel method.
bool IsRunning() const
This method is syntactic sugar for !IsExpired().
Ipv4 addresses are stored in host order in this class.
Describes an IPv6 address.
bool IsLinkLocal() const
If the IPv6 address is a link-local address (fe80::/64).
static Ipv6Address GetAny()
Get the "any" (::) Ipv6Address.
static Ipv6Address Deserialize(const uint8_t buf[16])
Deserialize this address.
static Ipv6Address MakeAutoconfiguredAddress(Address addr, Ipv6Address prefix)
Make the autoconfigured IPv6 address from a Mac address.
bool IsMulticast() const
If the IPv6 address is multicast (ff00::/8).
void GetBytes(uint8_t buf[16]) const
Get the bytes corresponding to the address.
void Serialize(uint8_t buf[16]) const
Serialize this address to a 16-byte buffer.
static Ipv6Address GetOnes()
Get the "all-1" IPv6 address (ffff:ffff:ffff:ffff:ffff:ffff:ffff:ffff).
static Ipv6Address MakeAutoconfiguredLinkLocalAddress(Address mac)
Make the autoconfigured link-local IPv6 address from a Mac address.
static const uint16_t PROT_NUMBER
The protocol number for IPv6 (0x86DD).
Describes an IPv6 prefix.
uint8_t GetPrefixLength() const
Get prefix length.
void GetBytes(uint8_t buf[16]) const
Get the bytes corresponding to the prefix.
This class can contain 16 bit addresses.
static bool IsMatchingType(const Address &address)
static Mac16Address ConvertFrom(const Address &address)
void CopyFrom(const uint8_t buffer[2])
bool IsMulticast() const
Checks if the address is a multicast address according to RFC 4944 Section 9 (i.e....
bool IsBroadcast() const
Checks if the address is a broadcast address according to 802.15.4 scheme (i.e., 0xFFFF).
static bool IsMatchingType(const Address &address)
Network layer to device interface.
virtual bool Send(Ptr< Packet > packet, const Address &dest, uint16_t protocolNumber)=0
PacketType
Packet types are used as they are in Linux.
static bool ChecksumEnabled()
void RegisterProtocolHandler(ProtocolHandler handler, uint16_t protocolType, Ptr< NetDevice > device, bool promiscuous=false)
virtual void DoDispose()
Destructor implementation.
Smart pointer class similar to boost::intrusive_ptr.
virtual double GetValue()=0
Get the next random value drawn from the distribution.
void SetStream(int64_t stream)
Specifies the stream number for the RngStream.
static EventId Schedule(const Time &delay, FUNC f, Ts &&... args)
Schedule an event to expire after delay.
static Time Now()
Return the current simulation virtual time.
6LoWPAN BC0 header - see RFC 4944.
uint32_t GetSerializedSize() const override
Get the serialized size of the packet.
void SetSequenceNumber(uint8_t seqNumber)
Set the "Sequence Number" field.
uint8_t GetSequenceNumber() const
Get the "Sequence Number" field.
static Dispatch_e GetDispatchType(uint8_t dispatch)
Get the Dispatch type.
static NhcDispatch_e GetNhcDispatchType(uint8_t dispatch)
Get the NhcDispatch type.
NhcDispatch_e
Dispatch values for Next Header compression.
6LoWPAN FRAG1 header - see RFC 4944.
void SetDatagramSize(uint16_t datagramSize)
Set the datagram size.
void SetDatagramTag(uint16_t datagramTag)
Set the datagram tag.
uint16_t GetDatagramSize() const
Get the datagram size.
uint16_t GetDatagramTag() const
Get the datagram tag.
uint32_t GetSerializedSize() const override
Get the serialized size of the packet.
6LoWPAN FRAGN header - see RFC 4944.
void SetDatagramSize(uint16_t datagramSize)
Set the datagram size.
uint32_t GetSerializedSize() const override
Get the serialized size of the packet.
uint16_t GetDatagramTag() const
Get the datagram tag.
void SetDatagramTag(uint16_t datagramTag)
Set the datagram tag.
void SetDatagramOffset(uint8_t datagramOffset)
Set the datagram offset.
uint8_t GetDatagramOffset() const
Get the datagram offset.
uint16_t GetDatagramSize() const
Get the datagram size.
6LoWPAN HC1 header - see RFC 4944.
void SetTcflCompression(bool tcflCompression)
Set the Traffic Class and Flow Labels as compressed.
void SetFlowLabel(uint32_t flowLabel)
Set the Flow Label value.
void SetDstCompression(LowPanHc1Addr_e dstCompression)
Set Destination Compression type.
void SetTrafficClass(uint8_t trafficClass)
Set the Traffic Class value.
void SetHopLimit(uint8_t limit)
Set the "Hop limit" field (TTL).
void SetHc2HeaderPresent(bool hc2HeaderPresent)
Set the next header a HC2 compressed header.
uint32_t GetSerializedSize() const override
Get the serialized size of the packet.
void SetNextHeader(uint8_t nextHeader)
Set the Next Header value.
void SetSrcCompression(LowPanHc1Addr_e srcCompression)
Set Source Compression type.
void SetDstInterface(const uint8_t *dstInterface)
Set the destination interface.
void SetDstPrefix(const uint8_t *dstPrefix)
Set the destination prefix.
void SetSrcPrefix(const uint8_t *srcPrefix)
Set the source prefix.
void SetSrcInterface(const uint8_t *srcInterface)
Set the source interface.
LOWPAN_IPHC base Encoding - see RFC 6282.
void SetNextHeader(uint8_t nextHeader)
Set the Next Header field.
void SetHlim(Hlim_e hlimField)
Set the HLIM (Hop Limit) compression.
void SetDstContextId(uint8_t dstContextId)
Set the DstContextId.
void SetSam(HeaderCompression_e samField)
Set the SAM (Source Address Mode) compression.
void SetNh(bool nhField)
Set the NH (Next Header) compression.
void SetEcn(uint8_t ecn)
Set the ECN (2bits).
void SetFlowLabel(uint32_t flowLabel)
Set the Flow Label (20bits).
void SetDscp(uint8_t dscp)
Set the DSCP (6bits).
void SetTf(TrafficClassFlowLabel_e tfField)
Set the TF (Traffic Class, Flow Label) compression.
void SetDam(HeaderCompression_e damField)
Set the DAM (Destination Address Mode) compression.
void SetCid(bool cidField)
Set the CID (Context Identifier Extension) compression.
uint32_t GetSerializedSize() const override
Get the serialized size of the packet.
void SetSac(bool sacField)
Set the SAC (Source Address Compression) compression.
bool GetM() const
Get the M (Multicast) compression.
void SetDstInlinePart(uint8_t dstInlinePart[16], uint8_t size)
brief Set the destination address inline part
void SetSrcContextId(uint8_t srcContextId)
Set the SrcContextId.
void SetSrcInlinePart(uint8_t srcInlinePart[16], uint8_t size)
brief Set the source address inline part
void SetM(bool mField)
Set the M (Multicast) compression.
void SetHopLimit(uint8_t hopLimit)
Set the Hop Limit field.
void SetDac(bool dacField)
Set the DAC (Destination Address Compression) compression.
6LoWPAN IPv6 uncompressed header - see RFC 4944.
6LoWPAN Mesh header - see RFC 4944.
Address GetOriginator() const
Get the "Originator" address.
void SetHopsLeft(uint8_t hopsLeft)
Set the "Hops Left" field.
void SetFinalDst(Address finalDst)
Set the "Final Destination" address.
uint32_t GetSerializedSize() const override
Get the serialized size of the packet.
uint8_t GetHopsLeft() const
Get the "Hops Left" field.
Address GetFinalDst() const
Get the "Final Destination" address.
void SetOriginator(Address originator)
Set the "Originator" address.
void SetTimeoutIter(FragmentsTimeoutsListI_t iter)
Set the Timeout iterator.
bool IsEntire() const
If all fragments have been added.
std::list< Ptr< Packet > > GetFragments() const
Get a list of the current stored fragments.
void SetPacketSize(uint32_t packetSize)
Set the packet-to-be-defragmented size.
void AddFragment(Ptr< Packet > fragment, uint16_t fragmentOffset)
Add a fragment to the pool.
uint32_t m_packetSize
The size of the reconstructed packet (bytes).
FragmentsTimeoutsListI_t GetTimeoutIter()
Get the Timeout iterator.
Ptr< Packet > GetPacket() const
Get the entire packet.
void AddFirstFragment(Ptr< Packet > fragment)
Add the first packet fragment.
Shim performing 6LoWPAN compression, decompression and fragmentation.
bool IsLinkUp() const override
bool SetMtu(const uint16_t mtu) override
void DecompressLowPanUdpNhc(Ptr< Packet > packet, Ipv6Address saddr, Ipv6Address daddr)
Decompress the headers according to NHC compression.
bool DoSend(Ptr< Packet > packet, const Address &source, const Address &dest, uint16_t protocolNumber, bool doSendFrom)
Ipv6Address CleanPrefix(Ipv6Address address, Ipv6Prefix prefix)
Clean an address from its prefix.
uint8_t m_bc0Serial
Serial number used in BC0 header.
bool SendFrom(Ptr< Packet > packet, const Address &source, const Address &dest, uint16_t protocolNumber) override
void SetNode(Ptr< Node > node) override
bool NeedsArp() const override
EventId m_timeoutEvent
Event for the next scheduled timeout.
FragmentsTimeoutsListI_t SetTimeout(FragmentKey_t key, uint32_t iif)
Set a new timeout "event" for a fragmented packet.
Ptr< UniformRandomVariable > m_rng
Rng for the fragments tag.
uint16_t m_meshCacheLength
length of the cache for each source.
bool IsPointToPoint() const override
Return true if the net device is on a point-to-point link.
bool m_useIphc
Use IPHC or HC1.
void RenewContext(uint8_t contextId, Time validLifetime)
Renew a context used in IPHC stateful compression.
bool DecompressLowPanIphc(Ptr< Packet > packet, const Address &src, const Address &dst)
Decompress the headers according to IPHC compression.
uint32_t CompressLowPanHc1(Ptr< Packet > packet, const Address &src, const Address &dst)
Compress the headers according to HC1 compression.
bool IsBridge() const override
Return true if the net device is acting as a bridge.
void DoFragmentation(Ptr< Packet > packet, uint32_t origPacketSize, uint32_t origHdrSize, uint32_t extraHdrSize, std::list< Ptr< Packet > > &listFragments)
Performs a packet fragmentation.
Ptr< Node > m_node
Smart pointer to the Node.
bool CanCompressLowPanNhc(uint8_t headerType)
Checks if the next header can be compressed using NHC.
Ptr< Channel > GetChannel() const override
uint16_t GetMtu() const override
Returns the link-layer MTU for this interface.
std::list< std::tuple< Time, FragmentKey_t, uint32_t > >::iterator FragmentsTimeoutsListI_t
Container Iterator for fragment timeouts.
int64_t AssignStreams(int64_t stream)
Assign a fixed random variable stream number to the random variables used by this model.
bool m_forceEtherType
Force the EtherType number.
Address GetAddress() const override
void SetReceiveCallback(NetDevice::ReceiveCallback cb) override
uint32_t m_compressionThreshold
Minimum L2 payload size.
Ptr< NetDevice > GetNetDevice() const
Returns a smart pointer to the underlying NetDevice.
void HandleTimeout()
Handles a fragmented packet timeout.
void ReceiveFromDevice(Ptr< NetDevice > device, Ptr< const Packet > packet, uint16_t protocol, const Address &source, const Address &destination, PacketType packetType)
Receives all the packets from a NetDevice for further processing.
uint32_t CompressLowPanNhc(Ptr< Packet > packet, uint8_t headerType, const Address &src, const Address &dst)
Compress the headers according to NHC compression.
TracedCallback< Ptr< const Packet >, Ptr< SixLowPanNetDevice >, uint32_t > m_txTrace
Callback to trace TX (transmission) packets.
std::pair< std::pair< Address, Address >, std::pair< uint16_t, uint16_t > > FragmentKey_t
Fragment identifier type: src/dst address src/dst port.
@ DROP_DISALLOWED_COMPRESSION
HC1 while in IPHC mode or vice-versa.
@ DROP_UNKNOWN_EXTENSION
Unsupported compression kind.
@ DROP_FRAGMENT_BUFFER_FULL
Fragment buffer size exceeded.
@ DROP_SATETFUL_DECOMPRESSION_PROBLEM
Decompression failed due to missing or expired context.
@ DROP_FRAGMENT_TIMEOUT
Fragment timeout exceeded.
void AddContext(uint8_t contextId, Ipv6Prefix contextPrefix, bool compressionAllowed, Time validLifetime)
Add, remove, or update a context used in IPHC stateful compression.
Ptr< NetDevice > m_netDevice
Smart pointer to the underlying NetDevice.
void SetNetDevice(Ptr< NetDevice > device)
Setup SixLowPan to be a proxy for the specified NetDevice.
std::map< uint8_t, ContextEntry > m_contextTable
Table of the contexts used in compression/decompression.
TracedCallback< Ptr< const Packet >, Ptr< SixLowPanNetDevice >, uint32_t > m_rxTrace
Callback to trace RX (reception) packets.
bool GetContext(uint8_t contextId, Ipv6Prefix &contextPrefix, bool &compressionAllowed, Time &validLifetime)
Get a context used in IPHC stateful compression.
uint32_t GetIfIndex() const override
bool Send(Ptr< Packet > packet, const Address &dest, uint16_t protocolNumber) override
bool IsBroadcast() const override
Address Get16MacFrom48Mac(Address addr)
Get a Mac16 from its Mac48 pseudo-MAC.
TracedCallback< DropReason, Ptr< const Packet >, Ptr< SixLowPanNetDevice >, uint32_t > m_dropTrace
Callback to trace drop packets.
void SetPromiscReceiveCallback(NetDevice::PromiscReceiveCallback cb) override
bool FindUnicastCompressionContext(Ipv6Address address, uint8_t &contextId)
Finds if the given unicast address matches a context for compression.
Ptr< RandomVariableStream > m_meshUnderJitter
Random variable for the mesh-under packet retransmission.
uint32_t CompressLowPanUdpNhc(Ptr< Packet > packet, bool omitChecksum)
Compress the headers according to NHC compression.
void RemoveContext(uint8_t contextId)
Remove a context used in IPHC stateful compression.
bool m_omitUdpChecksum
Omit UDP checksum in NC1 encoding.
Ptr< Node > GetNode() const override
void AddLinkChangeCallback(Callback< void > callback) override
uint32_t m_ifIndex
Interface index.
Address GetBroadcast() const override
void SetIfIndex(const uint32_t index) override
uint32_t CompressLowPanIphc(Ptr< Packet > packet, const Address &src, const Address &dst)
Compress the headers according to IPHC compression.
void DoDispose() override
Destructor implementation.
bool IsMulticast() const override
Address GetMulticast(Ipv4Address multicastGroup) const override
Make and return a MAC multicast address using the provided multicast group.
Time m_fragmentExpirationTimeout
Time limit for fragment rebuilding.
uint16_t m_fragmentReassemblyListSize
How many packets can be rebuilt at the same time.
uint8_t m_meshUnderHopsLeft
Start value for mesh-under hops left.
void SetAddress(Address address) override
Set the address of this interface.
void DecompressLowPanHc1(Ptr< Packet > packet, const Address &src, const Address &dst)
Decompress the headers according to HC1 compression.
FragmentsTimeoutsList_t m_timeoutEventList
Timeout "events" container.
std::pair< uint8_t, bool > DecompressLowPanNhc(Ptr< Packet > packet, const Address &src, const Address &dst, Ipv6Address srcAddress, Ipv6Address dstAddress)
Decompress the headers according to NHC compression.
NetDevice::PromiscReceiveCallback m_promiscRxCallback
The callback used to notify higher layers that a packet has been received in promiscuous mode.
void HandleFragmentsTimeout(FragmentKey_t key, uint32_t iif)
Process the timeout for packet fragments.
void InvalidateContext(uint8_t contextId)
Invalidate a context used in IPHC stateful compression.
static TypeId GetTypeId()
Get the type ID.
bool SupportsSendFrom() const override
NetDevice::ReceiveCallback m_rxCallback
The callback used to notify higher layers that a packet has been received.
bool ProcessFragment(Ptr< Packet > &packet, const Address &src, const Address &dst, bool isFirst)
Process a packet fragment.
MapFragments_t m_fragments
Fragments hold to be rebuilt.
bool FindMulticastCompressionContext(Ipv6Address address, uint8_t &contextId)
Finds if the given multicast address matches a context for compression.
bool m_meshUnder
Use a mesh-under routing.
std::map< Address, std::list< uint8_t > > m_seenPkts
Seen packets, memorized by OriginatorAddress, SequenceNumber.
SixLowPanNetDevice()
Constructor for the SixLowPanNetDevice.
uint16_t m_etherType
EtherType number (used only if m_forceEtherType is true).
LOWPAN_NHC Extension Header Encoding - see RFC 6282.
void SetNh(bool nhField)
Set the NH field values.
void SetEid(Eid_e extensionHeaderType)
Set the Extension Header Type.
void SetBlob(const uint8_t *blob, uint32_t size)
Set the option header data blob.
@ EID_DESTINATION_OPTIONS_H
void SetNextHeader(uint8_t nextHeader)
Set the Next Header field values.
uint32_t GetSerializedSize() const override
Get the serialized size of the packet.
UDP LOWPAN_NHC Extension Header Encoding - see RFC 6282.
@ PORTS_LAST_SRC_LAST_DST
void SetPorts(Ports_e port)
Set the compressed Src and Dst Ports.
void SetChecksum(uint16_t checksum)
Set the Checksum field values.
void SetDstPort(uint16_t port)
Set the Destination Port.
uint32_t GetSerializedSize() const override
Get the serialized size of the packet.
void SetSrcPort(uint16_t port)
Set the Source Port.
void SetC(bool cField)
Set the C (Checksum).
Hold variables of type string.
Simulation virtual time values and global simulation resolution.
TimeWithUnit As(const Unit unit=Time::AUTO) const
Attach a unit to a Time, to facilitate output in a specific unit.
AttributeValue implementation for Time.
a unique identifier for an interface.
TypeId SetParent(TypeId tid)
Set the parent TypeId.
static const uint8_t PROT_NUMBER
protocol number (0x11)
Hold an unsigned integer 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...
Ptr< const AttributeAccessor > MakeBooleanAccessor(T1 a1)
Ptr< const AttributeChecker > MakeBooleanChecker()
Ptr< const AttributeAccessor > MakePointerAccessor(T1 a1)
Ptr< const AttributeChecker > MakeTimeChecker()
Helper to make an unbounded Time checker.
Ptr< const AttributeAccessor > MakeTimeAccessor(T1 a1)
Ptr< const AttributeAccessor > MakeUintegerAccessor(T1 a1)
#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.
#define NS_ABORT_MSG_IF(cond, msg)
Abnormal program termination if a condition is true, with a message.
#define NS_LOG_COMPONENT_DEFINE(name)
Define a Log component with a specific name.
#define NS_LOG_DEBUG(msg)
Use NS_LOG to output a message of level LOG_DEBUG.
#define NS_LOG_LOGIC(msg)
Use NS_LOG to output a message of level LOG_LOGIC.
#define NS_LOG_FUNCTION(parameters)
If log level LOG_FUNCTION is enabled, this macro will output all input parameters separated by ",...
#define NS_OBJECT_ENSURE_REGISTERED(type)
Register an Object subclass with the TypeId system.
Time Seconds(double value)
Construct a Time in the indicated unit.
Time MilliSeconds(uint64_t value)
Construct a Time in the indicated unit.
Ptr< const TraceSourceAccessor > MakeTraceSourceAccessor(T a)
Create a TraceSourceAccessor which will control access to the underlying trace source.
Every class exported by the ns3 library is enclosed in the ns3 namespace.
Callback< R, Args... > MakeCallback(R(T::*memPtr)(Args...), OBJ objPtr)
Build Callbacks for class method members which take varying numbers of arguments and potentially retu...
Structure holding the information for a context (used in compression and decompression)
Ipv6Prefix contextPrefix
context prefix to be used in compression/decompression
bool compressionAllowed
compression and decompression allowed (true), decompression only (false)
Time validLifetime
validity period
uint32_t pktSize
packet size used for the simulation (in bytes)
static const uint32_t packetSize
Packet size generated at the AP.