25 #include "ns3/channel.h"
26 #include "ns3/packet.h"
28 #include "ns3/boolean.h"
29 #include "ns3/uinteger.h"
30 #include "ns3/simulator.h"
31 #include "ns3/mac16-address.h"
32 #include "ns3/mac48-address.h"
33 #include "ns3/mac64-address.h"
34 #include "ns3/ipv6-l3-protocol.h"
35 #include "ns3/ipv6-extension-header.h"
36 #include "ns3/udp-header.h"
37 #include "ns3/udp-l4-protocol.h"
38 #include "ns3/string.h"
39 #include "ns3/pointer.h"
53 .SetGroupName (
"SixLowPan")
55 .AddAttribute (
"Rfc6282",
"Use RFC6282 (IPHC) if true, RFC4944 (HC1) otherwise.",
59 .AddAttribute (
"OmitUdpChecksum",
60 "Omit the UDP checksum in IPHC compression.",
64 .AddAttribute (
"FragmentReassemblyListSize",
"The maximum size of the reassembly buffer (in packets). Zero meaning infinite.",
67 MakeUintegerChecker<uint16_t> ())
68 .AddAttribute (
"FragmentExpirationTimeout",
69 "When this timeout expires, the fragments will be cleared from the buffer.",
73 .AddAttribute (
"CompressionThreshold",
74 "The minimum MAC layer payload size.",
77 MakeUintegerChecker<uint32_t> ())
78 .AddAttribute (
"ForceEtherType",
79 "Force a specific EtherType in L2 frames.",
83 .AddAttribute (
"EtherType",
84 "The specific EtherType to be used in L2 frames.",
87 MakeUintegerChecker<uint16_t> ())
88 .AddAttribute (
"UseMeshUnder",
89 "Use a mesh-under routing protocol.",
93 .AddAttribute (
"MeshUnderRadius",
94 "Hops Left to use in mesh-under.",
97 MakeUintegerChecker<uint8_t> ())
98 .AddAttribute (
"MeshCacheLength",
99 "Length of the cache for each source.",
102 MakeUintegerChecker<uint16_t> ())
103 .AddAttribute (
"MeshUnderJitter",
104 "The jitter in ms a node uses to forward mesh-under packets - used to prevent collisions",
105 StringValue (
"ns3::UniformRandomVariable[Min=0.0|Max=10.0]"),
107 MakePointerChecker<RandomVariableStream> ())
108 .AddTraceSource (
"Tx",
109 "Send - packet (including 6LoWPAN header), "
110 "SixLoWPanNetDevice Ptr, interface index.",
112 "ns3::SixLowPanNetDevice::RxTxTracedCallback")
113 .AddTraceSource (
"Rx",
114 "Receive - packet (including 6LoWPAN header), "
115 "SixLoWPanNetDevice Ptr, interface index.",
117 "ns3::SixLowPanNetDevice::RxTxTracedCallback")
118 .AddTraceSource (
"Drop",
119 "Drop - DropReason, packet (including 6LoWPAN header), "
120 "SixLoWPanNetDevice Ptr, interface index.",
122 "ns3::SixLowPanNetDevice::DropTracedCallback")
134 m_rng = CreateObject<UniformRandomVariable> ();
149 NS_LOG_DEBUG (
"RegisterProtocolHandler for " << device->GetInstanceTypeId ().GetName ());
151 uint16_t protocolType = 0;
158 protocolType, device,
false);
198 NS_LOG_FUNCTION (
this << incomingPort << packet << protocol << src << dst);
200 uint8_t dispatchRawVal = 0;
206 copyPkt->
CopyData (&dispatchRawVal,
sizeof(dispatchRawVal));
208 bool isPktDecompressed =
false;
209 bool fragmented =
false;
213 NS_LOG_DEBUG (
"Dispatches: " <<
int(dispatchRawVal) <<
" - " <<
int(dispatchVal) );
217 bool hasMesh =
false;
224 copyPkt->
CopyData (&dispatchRawVal,
sizeof(dispatchRawVal));
231 copyPkt->
CopyData (&dispatchRawVal,
sizeof(dispatchRawVal));
239 NS_LOG_LOGIC (
"Dropped packet - we only support mesh if it is paired with a BC0");
248 NS_LOG_LOGIC (
"We have already seen this, no further processing.");
273 NS_LOG_LOGIC (
"Not forwarding packet -- hop limit reached");
277 NS_LOG_LOGIC (
"Not forwarding packet -- I am the originator");
310 isPktDecompressed =
ProcessFragment (copyPkt, realSrc, realDst,
false);
315 if ( !isPktDecompressed )
321 copyPkt->
CopyData (&dispatchRawVal,
sizeof(dispatchRawVal));
326 switch ( dispatchVal )
333 isPktDecompressed =
true;
343 isPktDecompressed =
true;
357 isPktDecompressed =
true;
361 NS_LOG_DEBUG (
"Unsupported 6LoWPAN encoding: dropping.");
366 if ( !isPktDecompressed )
372 NS_LOG_DEBUG (
"Packet decompressed received: " << *copyPkt );
455 return m_netDevice->AddLinkChangeCallback (callback);
516 uint16_t protocolNumber)
522 ret =
DoSend (packet, src, dest, protocolNumber,
false);
529 uint16_t protocolNumber)
534 ret =
DoSend (packet, src, dest, protocolNumber,
true);
541 uint16_t protocolNumber,
544 NS_LOG_FUNCTION (
this << *packet << src << dest << protocolNumber << doSendFrom);
548 uint32_t origHdrSize = 0;
549 uint32_t origPacketSize = packet->
GetSize ();
576 uint32_t extraHdrSize = 0;
608 NS_LOG_LOGIC (
"Compressed packet too short, using uncompressed one");
624 std::list<Ptr<Packet> > fragmentList;
625 DoFragmentation (packet, origPacketSize, origHdrSize, extraHdrSize, fragmentList);
626 std::list<Ptr<Packet> >::iterator it;
628 for ( it = fragmentList.begin (); it != fragmentList.end (); it++ )
630 NS_LOG_DEBUG (
"SixLowPanNetDevice::Send (Fragment) " << **it );
636 (*it)->AddHeader (bc0Hdr);
637 (*it)->AddHeader (meshHdr);
641 success &=
m_netDevice->SendFrom (*it, src, destination, protocolNumber);
645 success &=
m_netDevice->Send (*it, destination, protocolNumber);
664 ret =
m_netDevice->SendFrom (packet, src, destination, protocolNumber);
669 ret =
m_netDevice->Send (packet, destination, protocolNumber);
738 NS_LOG_LOGIC (
"Checking source compression: " << mySrcAddr <<
" - " << srcAddr );
741 bool isSrcSrc = (memcmp (bufOne + 8, bufTwo + 8, 8) == 0);
768 NS_LOG_LOGIC (
"Checking destination compression: " << myDstAddr <<
" - " << dstAddr );
771 bool isDstDst = (memcmp (bufOne + 8, bufTwo + 8, 8) == 0);
831 NS_LOG_DEBUG (
"removed " << ret <<
" bytes - pkt is " << *packet);
838 const uint8_t* interface;
839 const uint8_t* prefix;
844 interface = encoding.GetSrcInterface ();
845 for (
int j = 0; j < 8; j++)
854 for (
int j = 0; j < 8; j++)
862 interface = encoding.GetSrcInterface ();
865 for (
int j = 0; j < 8; j++)
878 const uint8_t* interface;
879 const uint8_t* prefix;
884 interface = encoding.GetDstInterface ();
885 for (
int j = 0; j < 8; j++)
894 for (
int j = 0; j < 8; j++)
902 interface = encoding.GetDstInterface ();
905 for (
int j = 0; j < 8; j++)
932 "6LoWPAN: error in decompressing HC1 encoding, unsupported L4 compressed header present.");
948 NS_LOG_DEBUG (
"Original packet: " << *packet <<
" Size " << packet->
GetSize () <<
" src: " << src <<
" dst: " << dst);
987 iphcHeader.
SetNh (
true);
992 iphcHeader.
SetNh (
true);
1001 iphcHeader.
SetNh (
true);
1006 iphcHeader.
SetNh (
false);
1013 iphcHeader.
SetNh (
false);
1038 iphcHeader.
SetCid (
false);
1039 iphcHeader.
SetSac (
false);
1040 iphcHeader.
SetDac (
false);
1044 uint8_t unicastAddrCheckerBuf[16];
1045 checker.
GetBytes (unicastAddrCheckerBuf);
1046 uint8_t addressBuf[16];
1052 uint8_t srcContextId;
1059 iphcHeader.
SetSac (
true);
1065 NS_LOG_LOGIC (
"Checking stateful source compression: " << srcAddr );
1067 iphcHeader.
SetSac (
true);
1068 if (srcContextId != 0)
1072 iphcHeader.
SetCid (
true);
1084 uint8_t serializedCleanedAddress[16];
1085 cleanedAddr.
Serialize (serializedCleanedAddress);
1087 if ( serializedCleanedAddress[8] == 0x00 && serializedCleanedAddress[9] == 0x00 &&
1088 serializedCleanedAddress[10] == 0x00 && serializedCleanedAddress[11] == 0xff &&
1089 serializedCleanedAddress[12] == 0xfe && serializedCleanedAddress[13] == 0x00 )
1105 NS_LOG_LOGIC (
"Checking stateless source compression: " << srcAddr );
1109 uint8_t serializedSrcAddress[16];
1110 srcAddr.
Serialize (serializedSrcAddress);
1116 else if (memcmp (addressBuf, unicastAddrCheckerBuf, 14) == 0)
1137 iphcHeader.
SetM (
true);
1141 iphcHeader.
SetM (
false);
1150 NS_LOG_LOGIC (
"Checking destination compression: " << dstAddr );
1152 uint8_t serializedDstAddress[16];
1153 dstAddr.
Serialize (serializedDstAddress);
1155 if ( !iphcHeader.
GetM () )
1159 uint8_t dstContextId;
1163 NS_LOG_LOGIC (
"Checking stateful destination compression: " << dstAddr );
1165 iphcHeader.
SetDac (
true);
1166 if (dstContextId != 0)
1170 iphcHeader.
SetCid (
true);
1182 uint8_t serializedCleanedAddress[16];
1183 cleanedAddr.
Serialize (serializedCleanedAddress);
1185 if ( serializedCleanedAddress[8] == 0x00 && serializedCleanedAddress[9] == 0x00 &&
1186 serializedCleanedAddress[10] == 0x00 && serializedCleanedAddress[11] == 0xff &&
1187 serializedCleanedAddress[12] == 0xfe && serializedCleanedAddress[13] == 0x00 )
1201 NS_LOG_LOGIC (
"Checking stateless destination compression: " << dstAddr );
1207 else if (memcmp (addressBuf, unicastAddrCheckerBuf, 14) == 0)
1228 uint8_t dstContextId;
1234 uint8_t dstInlinePart[6] = {};
1235 dstInlinePart[0] = serializedDstAddress[1];
1236 dstInlinePart[1] = serializedDstAddress[2];
1237 dstInlinePart[2] = serializedDstAddress[12];
1238 dstInlinePart[3] = serializedDstAddress[13];
1239 dstInlinePart[4] = serializedDstAddress[14];
1240 dstInlinePart[5] = serializedDstAddress[15];
1242 iphcHeader.
SetDac (
true);
1243 if (dstContextId != 0)
1247 iphcHeader.
SetCid (
true);
1256 uint8_t multicastAddrCheckerBuf[16];
1258 multicastCheckAddress.
GetBytes (multicastAddrCheckerBuf);
1261 if ( memcmp (addressBuf, multicastAddrCheckerBuf, 15) == 0 )
1268 else if ( (addressBuf[0] == multicastAddrCheckerBuf[0])
1269 && (memcmp (addressBuf + 2, multicastAddrCheckerBuf + 2, 11) == 0) )
1271 uint8_t dstInlinePart[4] = {};
1272 memcpy (dstInlinePart, serializedDstAddress+1, 1);
1273 memcpy (dstInlinePart+1, serializedDstAddress+13, 3);
1279 else if ( (addressBuf[0] == multicastAddrCheckerBuf[0])
1280 && (memcmp (addressBuf + 2, multicastAddrCheckerBuf + 2, 9) == 0) )
1282 uint8_t dstInlinePart[6] = {};
1283 memcpy (dstInlinePart, serializedDstAddress+1, 1);
1284 memcpy (dstInlinePart+1, serializedDstAddress+11, 5);
1302 NS_LOG_DEBUG (
"Packet after IPHC compression: " << *packet);
1339 NS_LOG_DEBUG (
"removed " << ret <<
" bytes - pkt is " << *packet);
1346 if ( encoding.
GetSac () )
1358 NS_LOG_LOGIC (
"Unknown Source compression context (" << +contextId <<
"), dropping packet");
1363 NS_LOG_LOGIC (
"Expired Source compression context (" << +contextId <<
"), dropping packet");
1367 uint8_t contexPrefix[16];
1369 uint8_t contextLength =
m_contextTable[contextId].contextPrefix.GetPrefixLength ();
1371 uint8_t srcAddress[16] = { };
1378 srcAddress[11] = 0xff;
1379 srcAddress[12] = 0xfe;
1387 uint8_t bytesToCopy = contextLength / 8;
1388 uint8_t bitsToCopy = contextLength % 8;
1391 for (uint8_t i=0; i<bytesToCopy; i++)
1393 srcAddress[i] = contexPrefix[i];
1397 uint8_t addressBitMask = (1<<(8-bitsToCopy))-1;
1398 uint8_t prefixBitMask = ~addressBitMask;
1399 srcAddress[bytesToCopy] = (contexPrefix[bytesToCopy] & prefixBitMask) | (srcAddress[bytesToCopy] & addressBitMask);
1410 uint8_t srcAddress[16] = { };
1416 uint8_t srcAddress[16] = { };
1418 srcAddress[0] = 0xfe;
1419 srcAddress[1] = 0x80;
1424 uint8_t srcAddress[16] = { };
1426 srcAddress[0] = 0xfe;
1427 srcAddress[1] = 0x80;
1428 srcAddress[11] = 0xff;
1429 srcAddress[12] = 0xfe;
1438 if ( encoding.
GetDac () )
1452 NS_LOG_LOGIC (
"Unknown Destination compression context (" << +contextId <<
"), dropping packet");
1457 NS_LOG_LOGIC (
"Expired Destination compression context (" << +contextId <<
"), dropping packet");
1461 uint8_t contexPrefix[16];
1463 uint8_t contextLength =
m_contextTable[contextId].contextPrefix.GetPrefixLength ();
1465 if (encoding.
GetM () ==
false)
1468 uint8_t dstAddress[16] = { };
1475 dstAddress[11] = 0xff;
1476 dstAddress[12] = 0xfe;
1484 uint8_t bytesToCopy =
m_contextTable[contextId].contextPrefix.GetPrefixLength () / 8;
1485 uint8_t bitsToCopy = contextLength % 8;
1488 for (uint8_t i=0; i<bytesToCopy; i++)
1490 dstAddress[i] = contexPrefix[i];
1494 uint8_t addressBitMask = (1<<(8-bitsToCopy))-1;
1495 uint8_t prefixBitMask = ~addressBitMask;
1496 dstAddress[bytesToCopy] = (contexPrefix[bytesToCopy] & prefixBitMask) | (dstAddress[bytesToCopy] & addressBitMask);
1504 uint8_t dstAddress[16] = { };
1505 dstAddress[0] = 0xff;
1507 dstAddress[3] = contextLength;
1508 memcpy (dstAddress +4, contexPrefix, 8);
1516 if (encoding.
GetM () ==
false)
1521 uint8_t dstAddress[16] = { };
1527 uint8_t dstAddress[16] = { };
1529 dstAddress[0] = 0xfe;
1530 dstAddress[1] = 0x80;
1535 uint8_t dstAddress[16] = { };
1537 dstAddress[0] = 0xfe;
1538 dstAddress[1] = 0x80;
1539 dstAddress[11] = 0xff;
1540 dstAddress[12] = 0xfe;
1553 uint8_t dstAddress[16] = { };
1559 uint8_t dstAddress[16] = { };
1560 dstAddress[0] = 0xff;
1567 uint8_t dstAddress[16] = { };
1568 dstAddress[0] = 0xff;
1575 uint8_t dstAddress[16] = { };
1576 dstAddress[0] = 0xff;
1577 dstAddress[1] = 0x02;
1585 uint8_t traf = 0x00;
1586 switch (encoding.
GetTf ())
1589 traf |= encoding.
GetEcn ();
1590 traf = ( traf << 6 ) | encoding.
GetDscp ();
1595 traf |= encoding.
GetEcn ();
1601 traf |= encoding.
GetEcn ();
1602 traf = ( traf << 6 ) | encoding.
GetDscp ();
1612 if ( encoding.
GetNh () )
1615 uint8_t dispatchRawVal = 0;
1618 packet->
CopyData (&dispatchRawVal,
sizeof(dispatchRawVal));
1629 if ( retval.second ==
true )
1668 NS_LOG_DEBUG (
"LOWPAN_NHC MUST NOT be used to encode IPv6 Extension Headers "
1669 "that have more than 255 octets following the Length field after compression. "
1670 "Packet uncompressed.");
1683 nhcHeader.
SetNh (
true);
1688 nhcHeader.
SetNh (
true);
1697 nhcHeader.
SetNh (
true);
1702 nhcHeader.
SetNh (
false);
1709 nhcHeader.
SetNh (
false);
1726 NS_LOG_DEBUG (
"LOWPAN_NHC MUST NOT be used to encode IPv6 Extension Headers "
1727 "that have more than 255 octets following the Length field after compression. "
1728 "Packet uncompressed.");
1741 nhcHeader.
SetNh (
true);
1746 nhcHeader.
SetNh (
true);
1755 nhcHeader.
SetNh (
true);
1760 nhcHeader.
SetNh (
false);
1767 nhcHeader.
SetNh (
false);
1784 NS_LOG_DEBUG (
"LOWPAN_NHC MUST NOT be used to encode IPv6 Extension Headers "
1785 "that have more than 255 octets following the Length field after compression. "
1786 "Packet uncompressed.");
1798 nhcHeader.
SetNh (
true);
1803 nhcHeader.
SetNh (
true);
1812 nhcHeader.
SetNh (
true);
1817 nhcHeader.
SetNh (
false);
1824 nhcHeader.
SetNh (
false);
1841 NS_LOG_DEBUG (
"LOWPAN_NHC MUST NOT be used to encode IPv6 Extension Headers "
1842 "that have more than 255 octets following the Length field after compression. "
1843 "Packet uncompressed.");
1855 nhcHeader.
SetNh (
true);
1860 nhcHeader.
SetNh (
true);
1869 nhcHeader.
SetNh (
true);
1874 nhcHeader.
SetNh (
false);
1881 nhcHeader.
SetNh (
false);
1895 NS_ABORT_MSG (
"IPv6 Mobility Header is not supported in ns-3 yet");
1908 NS_LOG_DEBUG (
"Packet after NHC compression: " << *packet);
1912 std::pair <uint8_t, bool>
1920 NS_LOG_DEBUG (
"removed " << ret <<
" bytes - pkt is " << *packet);
1929 uint8_t blobData[260];
1930 blobSize = encoding.
CopyBlob (blobData + 2, 260 - 2);
1931 uint8_t paddingSize = 0;
1933 uint8_t actualEncodedHeaderType = encoding.
GetEid ();
1934 uint8_t actualHeaderType;
1937 switch (actualEncodedHeaderType)
1941 if ( encoding.
GetNh () )
1944 uint8_t dispatchRawVal = 0;
1947 packet->
CopyData (&dispatchRawVal,
sizeof(dispatchRawVal));
1966 if ((blobSize + 2) % 8 > 0)
1968 paddingSize = 8 - (blobSize + 2) % 8;
1970 if (paddingSize == 1)
1972 blobData[blobSize + 2] = 0;
1974 else if (paddingSize > 1)
1976 blobData[blobSize + 2] = 1;
1977 blobData[blobSize + 2 + 1] = paddingSize - 2;
1978 for (uint8_t i = 0; i < paddingSize - 2; i++)
1980 blobData[blobSize + 2 + 2 + i] = 0;
1983 blobData [1] = ((blobSize + 2 + paddingSize) >> 3) - 1;
1984 blob.
AddAtStart (blobSize + 2 + paddingSize);
1985 blob.
Begin ().
Write (blobData, blobSize + 2 + paddingSize);
1993 if ( encoding.
GetNh () )
1996 uint8_t dispatchRawVal = 0;
1999 packet->
CopyData (&dispatchRawVal,
sizeof(dispatchRawVal));
2016 blobData [1] = ((blobSize + 2) >> 3) - 1;
2018 blob.
Begin ().
Write (blobData, blobSize + 2);
2025 if ( encoding.
GetNh () )
2028 uint8_t dispatchRawVal = 0;
2031 packet->
CopyData (&dispatchRawVal,
sizeof(dispatchRawVal));
2051 blob.
Begin ().
Write (blobData, blobSize + 2);
2059 if ( encoding.
GetNh () )
2062 uint8_t dispatchRawVal = 0;
2065 packet->
CopyData (&dispatchRawVal,
sizeof(dispatchRawVal));
2084 if ((blobSize + 2) % 8 > 0)
2086 paddingSize = 8 - (blobSize + 2) % 8;
2088 if (paddingSize == 1)
2090 blobData[blobSize + 2] = 0;
2092 else if (paddingSize > 1)
2094 blobData[blobSize + 2] = 1;
2095 blobData[blobSize + 2 + 1] = paddingSize - 2;
2096 for (uint8_t i = 0; i < paddingSize - 2; i++)
2098 blobData[blobSize + 2 + 2 + i] = 0;
2101 blobData [1] = ((blobSize + 2 + paddingSize) >> 3) - 1;
2102 blob.
AddAtStart (blobSize + 2 + paddingSize);
2103 blob.
Begin ().
Write (blobData, blobSize + 2 + paddingSize);
2110 NS_ABORT_MSG (
"IPv6 Mobility Header is not supported in ns-3 yet");
2117 return std::pair<uint8_t, bool> (0,
true);
2121 NS_ABORT_MSG (
"Trying to decode unknown Extension Header");
2126 return std::pair<uint8_t, bool> (actualHeaderType,
false);
2143 udpNhcHeader.
SetC (
false);
2149 udpNhcHeader.
SetC (
true);
2179 NS_LOG_DEBUG (
"Packet after UDP_NHC compression: " << *packet);
2193 NS_LOG_DEBUG (
"removed " << ret <<
" bytes - pkt is " << *packet);
2207 temp |= (temp << 8) | encoding.
GetDstPort ();
2212 temp |= (temp << 8) | encoding.
GetSrcPort ();
2218 temp |= (temp << 4) | encoding.
GetSrcPort ();
2221 temp |= (temp << 4) | encoding.
GetDstPort ();
2229 if ( encoding.
GetC () )
2255 uint32_t origPacketSize,
2256 uint32_t origHdrSize,
2257 uint32_t extraHdrSize,
2264 uint16_t offsetData = 0;
2265 uint16_t offset = 0;
2268 uint32_t compressedHeaderSize =
packetSize - (origPacketSize - origHdrSize);
2279 "6LoWPAN: can not fragment, 6LoWPAN headers are bigger than MTU");
2282 size = l2Mtu - frag1Hdr.
GetSerializedSize () - compressedHeaderSize - extraHdrSize;
2284 size += compressedHeaderSize;
2289 offset += size + origHdrSize - compressedHeaderSize;
2293 listFragments.push_back (fragment1);
2295 bool moreFrag =
true;
2314 NS_LOG_LOGIC (
"Fragment creation - " << offset <<
", " << offset );
2322 listFragments.push_back (fragment);
2337 key.first = std::pair<Address, Address> (src, dst);
2340 uint16_t offset = 0;
2354 uint8_t dispatchRawValFrag1 = 0;
2359 p->
CopyData (&dispatchRawValFrag1,
sizeof(dispatchRawValFrag1));
2361 NS_LOG_DEBUG (
"Dispatches: " <<
int(dispatchRawValFrag1) <<
" - " <<
int(dispatchValFrag1) );
2364 switch ( dispatchValFrag1 )
2399 MapFragments_t::iterator it =
m_fragments.find (key);
2408 std::list< Ptr<Packet> > storedFragments =
m_fragments[oldestKey]->GetFraments ();
2410 fragIter != storedFragments.end (); fragIter++)
2420 fragments = Create<Fragments> ();
2422 m_fragments.insert (std::make_pair (key, fragments));
2430 fragments = it->second;
2475 std::list<std::pair<Ptr<Packet>, uint16_t> >::iterator it;
2476 bool duplicate =
false;
2480 if (it->second > fragmentOffset)
2484 if (it->second == fragmentOffset)
2487 NS_ASSERT_MSG (fragment->
GetSize () == it->first->GetSize (),
"Duplicate fragment size differs. Aborting.");
2493 m_fragments.insert (it, std::make_pair (fragment, fragmentOffset));
2501 m_firstFragment = fragment;
2509 uint16_t lastEndOffset = 0;
2516 NS_LOG_LOGIC (
"Checking overlaps " << lastEndOffset <<
" - " << it->second );
2518 if (lastEndOffset < it->
second)
2524 uint16_t fragmentEnd = it->first->GetSize () + it->second;
2525 lastEndOffset =
std::max ( lastEndOffset, fragmentEnd );
2529 if ( ret && (lastEndOffset == m_packetSize))
2540 std::list<std::pair<Ptr<Packet>, uint16_t> >::const_iterator it =
m_fragments.begin ();
2543 uint16_t lastEndOffset = 0;
2547 lastEndOffset = it->first->GetSize ();
2551 if ( lastEndOffset > it->second )
2553 NS_ABORT_MSG (
"Overlapping fragments found, forbidden condition");
2560 lastEndOffset += it->first->GetSize ();
2574 std::list< Ptr<Packet> > fragments;
2575 std::list<std::pair<Ptr<Packet>, uint16_t> >::const_iterator iter;
2578 fragments.push_back (iter->first);
2586 m_timeoutIter = iter;
2593 return m_timeoutIter;
2600 MapFragments_t::iterator it =
m_fragments.find (key);
2601 std::list< Ptr<Packet> > storedFragments = it->second->GetFraments ();
2603 fragIter != storedFragments.end (); fragIter++)
2667 NS_LOG_LOGIC (
"Invalid context ID (" << +contextId <<
"), ignoring");
2671 if (validLifetime ==
Time(0))
2673 NS_LOG_LOGIC (
"Context (" << +contextId <<
"), removed (validity time is zero)");
2679 m_contextTable[contextId].compressionAllowed = compressionAllowed;
2691 NS_LOG_LOGIC (
"Invalid context ID (" << +contextId <<
"), ignoring");
2697 NS_LOG_LOGIC (
"Context not found (" << +contextId <<
"), ignoring");
2702 compressionAllowed =
m_contextTable[contextId].compressionAllowed;
2714 NS_LOG_LOGIC (
"Invalid context ID (" << +contextId <<
"), ignoring");
2720 NS_LOG_LOGIC (
"Context not found (" << +contextId <<
"), ignoring");
2735 NS_LOG_LOGIC (
"Invalid context ID (" << +contextId <<
"), ignoring");
2741 NS_LOG_LOGIC (
"Context not found (" << +contextId <<
"), ignoring");
2754 NS_LOG_LOGIC (
"Invalid context ID (" << +contextId <<
"), ignoring");
2760 NS_LOG_LOGIC (
"Context not found (" << +contextId <<
"), ignoring");
2784 contextId = iter.first;
2807 if (contextLength <= 64)
2809 uint8_t contextBytes[16];
2810 uint8_t addressBytes[16];
2813 address.GetBytes (addressBytes);
2815 if (addressBytes[3] == contextLength &&
2816 addressBytes[4] == contextBytes[0] &&
2817 addressBytes[5] == contextBytes[1] &&
2818 addressBytes[6] == contextBytes[2] &&
2819 addressBytes[7] == contextBytes[3] &&
2820 addressBytes[8] == contextBytes[4] &&
2821 addressBytes[9] == contextBytes[5] &&
2822 addressBytes[10] == contextBytes[6] &&
2823 addressBytes[11] == contextBytes[7])
2828 contextId = iter.first;
2839 uint8_t addressBytes[16];
2840 address.GetBytes (addressBytes);
2843 uint8_t bytesToClean = prefixLength / 8;
2844 uint8_t bitsToClean = prefixLength % 8;
2845 for (uint8_t i=0; i<bytesToClean; i++)
2847 addressBytes[i] = 0;
2851 uint8_t cleanupMask = (1<<bitsToClean)-1;
2852 addressBytes[bytesToClean] &= cleanupMask;
2857 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(uint8_t const *buffer, uint32_t size)
automatically resized byte buffer
uint32_t GetSize(void) const
void AddAtStart(uint32_t start)
uint8_t const * PeekData(void) const
Buffer::Iterator Begin(void) const
void RemoveAtStart(uint32_t start)
bool IsNull(void) const
Check for null implementation.
bool IsRunning(void) const
This method is syntactic sugar for !IsExpired().
void Cancel(void)
This method is syntactic sugar for the ns3::Simulator::Cancel method.
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.
bool IsBroadcast(void) const
Checks if the address is a broadcast address according to 802.15.4 scheme (i.e., 0xFFFF).
static bool IsMatchingType(const Address &address)
static Mac16Address ConvertFrom(const Address &address)
bool IsMulticast(void) const
Checks if the address is a multicast address according to RFC 4944 Section 9 (i.e....
void CopyFrom(const uint8_t buffer[2])
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)
uint32_t GetId(void) const
void RegisterProtocolHandler(ProtocolHandler handler, uint16_t protocolType, Ptr< NetDevice > device, bool promiscuous=false)
virtual void DoDispose(void)
Destructor implementation.
Ptr< T > GetObject(void) const
Get a pointer to the requested aggregated Object.
uint32_t RemoveHeader(Header &header)
Deserialize and remove the header from the internal buffer.
void AddAtEnd(Ptr< const Packet > packet)
Concatenate the input packet at the end of the current packet.
void AddHeader(const Header &header)
Add header to this packet.
uint32_t CopyData(uint8_t *buffer, uint32_t size) const
Copy the packet contents to a byte buffer.
uint32_t PeekHeader(Header &header) const
Deserialize but does not remove the header from the internal buffer.
Ptr< Packet > CreateFragment(uint32_t start, uint32_t length) const
Create a new packet which contains a fragment of the original packet.
Ptr< Packet > Copy(void) const
performs a COW copy of the packet.
uint32_t GetSize(void) const
Returns the the size in bytes of the packet (including the zero-filled initial payload).
Smart pointer class similar to boost::intrusive_ptr.
virtual double GetValue(void)=0
Get the next random value as a double drawn from the distribution.
void SetStream(int64_t stream)
Specifies the stream number for the RngStream.
static EventId Schedule(Time const &delay, FUNC f, Ts &&... args)
Schedule an event to expire after delay.
static Time Now(void)
Return the current simulation virtual time.
6LoWPAN BC0 header - see RFC 4944.
virtual uint32_t GetSerializedSize(void) const
Get the serialized size of the packet.
uint8_t GetSequenceNumber(void) const
Get the "Sequence Number" field.
void SetSequenceNumber(uint8_t seqNumber)
Set 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.
virtual uint32_t GetSerializedSize(void) const
Get the serialized size of the packet.
uint16_t GetDatagramSize(void) const
Get the datagram size.
uint16_t GetDatagramTag(void) const
Get the datagram tag.
6LoWPAN FRAGN header - see RFC 4944.
uint16_t GetDatagramTag(void) const
Get the datagram tag.
uint8_t GetDatagramOffset(void) const
Get the datagram offset.
void SetDatagramSize(uint16_t datagramSize)
Set the datagram size.
uint16_t GetDatagramSize(void) const
Get the datagram size.
void SetDatagramTag(uint16_t datagramTag)
Set the datagram tag.
void SetDatagramOffset(uint8_t datagramOffset)
Set the datagram offset.
virtual uint32_t GetSerializedSize(void) const
Get the serialized size of the packet.
6LoWPAN HC1 header - see RFC 4944.
void SetTcflCompression(bool tcflCompression)
Set the Traffic Class and Flow Labels as compressed.
const uint8_t * GetSrcPrefix() const
Get the source prefix.
void SetFlowLabel(uint32_t flowLabel)
Set the Flow Label value.
uint8_t GetTrafficClass() const
Get the Traffic Class value.
void SetDstCompression(LowPanHc1Addr_e dstCompression)
Set Destination Compression type.
void SetTrafficClass(uint8_t trafficClass)
Set the Traffic Class value.
virtual uint32_t GetSerializedSize(void) const
Get the serialized size of the packet.
void SetHopLimit(uint8_t limit)
Set the "Hop limit" field (TTL).
uint32_t GetFlowLabel() const
Get the Flow Label value.
uint8_t GetHopLimit(void) const
Get the "Hop limit" field (TTL).
const uint8_t * GetDstPrefix() const
Get the destination prefix.
void SetHc2HeaderPresent(bool hc2HeaderPresent)
Set the next header a HC2 compressed header.
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.
uint8_t GetNextHeader() const
Get the Next Header value.
void SetSrcInterface(const uint8_t *srcInterface)
Set the source interface.
LowPanHc1Addr_e GetDstCompression() const
Get Destination Compression type.
bool IsHc2HeaderPresent() const
Check if there is a HC2 compressed header.
LowPanHc1Addr_e GetSrcCompression() const
Get Source Compression type.
bool IsTcflCompression() const
Check if the Traffic Class and Flow Labels are compressed.
LOWPAN_IPHC base Encoding - see RFC 6282.
void SetNextHeader(uint8_t nextHeader)
Set the Next Header field.
bool GetM(void) const
Get the M (Multicast) compression.
void SetHlim(Hlim_e hlimField)
Set the HLIM (Hop Limit) compression.
bool GetSac(void) const
Get the SAC (Source Address Compression) 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.
virtual uint32_t GetSerializedSize(void) const
Get the serialized size of the packet.
void SetEcn(uint8_t ecn)
Set the ECN (2bits).
void SetFlowLabel(uint32_t flowLabel)
Set the Flow Label (20bits).
TrafficClassFlowLabel_e GetTf(void) const
Get the TF (Traffic Class, Flow Label) compression.
bool GetDac(void) const
Get the DAC (Destination Address Compression) compression.
void SetDscp(uint8_t dscp)
Set the DSCP (6bits).
uint8_t GetDstContextId(void) const
Get the DstContextId.
void SetTf(TrafficClassFlowLabel_e tfField)
Set the TF (Traffic Class, Flow Label) compression.
const uint8_t * GetDstInlinePart(void) const
brief Get the destination address inline part
void SetDam(HeaderCompression_e damField)
Set the DAM (Destination Address Mode) compression.
void SetCid(bool cidField)
Set the CID (Context Identifier Extension) compression.
uint8_t GetEcn(void) const
Get the ECN.
HeaderCompression_e GetSam(void) const
Get the SAM (Source Address Mode) compression.
uint8_t GetHopLimit(void) const
Get the Hop Limit field.
bool GetNh(void) const
Get the NH (Next Header) compression.
void SetSac(bool sacField)
Set the SAC (Source Address Compression) compression.
HeaderCompression_e GetDam(void) const
Get the DAM (Destination Address Mode) compression.
const uint8_t * GetSrcInlinePart(void) const
brief Get the source address inline part
void SetDstInlinePart(uint8_t dstInlinePart[16], uint8_t size)
brief Set the destination address inline part
uint8_t GetSrcContextId(void) const
Get the SrcContextId.
void SetSrcContextId(uint8_t srcContextId)
Set the SrcContextId.
void SetSrcInlinePart(uint8_t srcInlinePart[16], uint8_t size)
brief Set the source address inline part
uint8_t GetDscp(void) const
Get the DSCP.
void SetM(bool mField)
Set the M (Multicast) compression.
uint32_t GetFlowLabel(void) const
Get the Flow Label.
uint8_t GetNextHeader(void) const
Get the Next Header field.
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.
void SetHopsLeft(uint8_t hopsLeft)
Set the "Hops Left" field.
Address GetFinalDst(void) const
Get the "Final Destination" address.
void SetFinalDst(Address finalDst)
Set the "Final Destination" address.
Address GetOriginator(void) const
Get the "Originator" address.
uint8_t GetHopsLeft(void) const
Get the "Hops Left" field.
virtual uint32_t GetSerializedSize(void) const
Get the serialized size of the packet.
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.
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.
std::list< Ptr< Packet > > GetFraments() const
Get a list of the current stored fragments.
void AddFirstFragment(Ptr< Packet > fragment)
Add the first packet fragment.
Shim performing 6LoWPAN compression, decompression and fragmentation.
bool DecompressLowPanIphc(Ptr< Packet > packet, Address const &src, Address const &dst)
Decompress the headers according to IPHC compression.
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.
uint32_t CompressLowPanHc1(Ptr< Packet > packet, Address const &src, Address const &dst)
Compress the headers according to HC1 compression.
uint8_t m_bc0Serial
Serial number used in BC0 header.
EventId m_timeoutEvent
Event for the next scheduled timeout.
virtual Ptr< Channel > GetChannel(void) const
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.
std::map< FragmentKey_t, Ptr< Fragments > >::iterator MapFragmentsI_t
Container Iterator for fragment key -> fragments.
uint16_t m_meshCacheLength
length of the cache for each source.
bool m_useIphc
Use IPHC or HC1.
void RenewContext(uint8_t contextId, Time validLifetime)
Renew a context used in IPHC stateful compression.
virtual Address GetAddress(void) const
virtual Address GetBroadcast(void) const
void ReceiveFromDevice(Ptr< NetDevice > device, Ptr< const Packet > packet, uint16_t protocol, Address const &source, Address const &destination, PacketType packetType)
Receives all the packets from a NetDevice for further processing.
void DoFragmentation(Ptr< Packet > packet, uint32_t origPacketSize, uint32_t origHdrSize, uint32_t extraHdrSize, std::list< Ptr< Packet > > &listFragments)
Performs a packet fragmentation.
virtual bool SupportsSendFrom() const
Ptr< Node > m_node
Smart pointer to the Node.
uint32_t CompressLowPanNhc(Ptr< Packet > packet, uint8_t headerType, Address const &src, Address const &dst)
Compress the headers according to NHC compression.
virtual void SetPromiscReceiveCallback(NetDevice::PromiscReceiveCallback cb)
bool CanCompressLowPanNhc(uint8_t headerType)
Checks if the next header can be compressed using NHC.
virtual void SetReceiveCallback(NetDevice::ReceiveCallback cb)
virtual Ptr< Node > GetNode(void) const
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.
virtual uint32_t GetIfIndex(void) const
virtual bool NeedsArp(void) const
uint32_t m_compressionThreshold
Minimum L2 payload size.
virtual void AddLinkChangeCallback(Callback< void > callback)
void DecompressLowPanHc1(Ptr< Packet > packet, Address const &src, Address const &dst)
Decompress the headers according to HC1 compression.
Ptr< NetDevice > GetNetDevice() const
Returns a smart pointer to the underlying NetDevice.
virtual bool Send(Ptr< Packet > packet, const Address &dest, uint16_t protocolNumber)
uint32_t CompressLowPanIphc(Ptr< Packet > packet, Address const &src, Address const &dst)
Compress the headers according to IPHC compression.
TracedCallback< Ptr< const Packet >, Ptr< SixLowPanNetDevice >, uint32_t > m_txTrace
Callback to trace TX (transmission) packets.
@ DROP_DISALLOWED_COMPRESSION
HC1 while in IPHC mode or viceversa.
@ 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.
static TypeId GetTypeId(void)
Get the type ID.
Ptr< NetDevice > m_netDevice
Smart pointer to the underlying NetDevice.
std::pair< uint8_t, bool > DecompressLowPanNhc(Ptr< Packet > packet, Address const &src, Address const &dst, Ipv6Address srcAddress, Ipv6Address dstAddress)
Decompress the headers according to NHC compression.
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 ProcessFragment(Ptr< Packet > &packet, Address const &src, Address const &dst, bool isFirst)
Process a packet fragment.
bool GetContext(uint8_t contextId, Ipv6Prefix &contextPrefix, bool &compressionAllowed, Time &validLifetime)
Get a context used in IPHC stateful compression.
virtual bool IsBridge(void) const
Return true if the net device is acting as a bridge.
virtual bool IsMulticast(void) const
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.
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.
virtual Address GetMulticast(Ipv4Address multicastGroup) const
Make and return a MAC multicast address using the provided multicast group.
virtual bool IsPointToPoint(void) const
Return true if the net device is on a point-to-point link.
virtual void DoDispose(void)
Destructor implementation.
uint32_t CompressLowPanUdpNhc(Ptr< Packet > packet, bool omitChecksum)
Compress the headers according to NHC compression.
virtual bool IsLinkUp(void) const
void RemoveContext(uint8_t contextId)
Remove a context used in IPHC stateful compression.
bool m_omitUdpChecksum
Omit UDP checksum in NC1 encoding.
std::pair< std::pair< Address, Address >, std::pair< uint16_t, uint16_t > > FragmentKey_t
Fragment identifier type: src/dst address src/dst port.
virtual bool SetMtu(const uint16_t mtu)
uint32_t m_ifIndex
Interface index.
virtual bool IsBroadcast(void) const
virtual void SetAddress(Address address)
Set the address of this interface.
virtual uint16_t GetMtu(void) const
Returns the link-layer MTU for this interface.
void HandleTimeout(void)
Handles a fragmented packet timeout.
virtual void SetIfIndex(const uint32_t index)
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.
FragmentsTimeoutsList_t m_timeoutEventList
Timeout "events" container.
virtual void SetNode(Ptr< Node > node)
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.
NetDevice::ReceiveCallback m_rxCallback
The callback used to notify higher layers that a packet has been received.
virtual bool SendFrom(Ptr< Packet > packet, const Address &source, const Address &dest, uint16_t protocolNumber)
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 OriginatorAdddress, SequenceNumber.
std::list< std::tuple< Time, FragmentKey_t, uint32_t > >::iterator FragmentsTimeoutsListI_t
Container Iterator for fragment timeouts.
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.
uint8_t GetNextHeader(void) const
Get the Next Header field value.
void SetNh(bool nhField)
Set the NH field values.
Eid_e GetEid(void) const
Get the Extension Header Type.
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
virtual uint32_t GetSerializedSize(void) const
Get the serialized size of the packet.
uint32_t CopyBlob(uint8_t *blob, uint32_t size) const
Get the option header data blob.
bool GetNh(void) const
Get the Next Header field value.
void SetNextHeader(uint8_t nextHeader)
Set the Next Header field values.
UDP LOWPAN_NHC Extension Header Encoding - see RFC 6282.
uint16_t GetDstPort() const
Get the Destination Port.
@ PORTS_LAST_SRC_LAST_DST
void SetPorts(Ports_e port)
Set the compressed Src and Dst Ports.
uint16_t GetChecksum(void) const
Get the Checksum field value.
virtual uint32_t GetSerializedSize(void) const
Get the serialized size of the packet.
bool GetC(void) const
Get the C (Checksum).
void SetChecksum(uint16_t checksum)
Set the Checksum field values.
void SetDstPort(uint16_t port)
Set the Destination Port.
void SetSrcPort(uint16_t port)
Set the Source Port.
void SetC(bool cField)
Set the C (Checksum).
Ports_e GetPorts(void) const
Get the compressed Src and Dst Ports.
uint16_t GetSrcPort() const
Get the Source Port.
Hold variables of type string.
Simulation virtual time values and global simulation resolution.
TimeWithUnit As(const enum 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 AttributeChecker > MakeBooleanChecker(void)
Ptr< const AttributeAccessor > MakeBooleanAccessor(T1 a1)
Create an AttributeAccessor for a class data member, or a lone class get functor or set method.
Ptr< const AttributeAccessor > MakePointerAccessor(T1 a1)
Create an AttributeAccessor for a class data member, or a lone class get functor or set method.
Ptr< const AttributeAccessor > MakeTimeAccessor(T1 a1)
Create an AttributeAccessor for a class data member, or a lone class get functor or set method.
Ptr< const AttributeAccessor > MakeUintegerAccessor(T1 a1)
Create an AttributeAccessor for a class data member, or a lone class get functor or set method.
#define NS_UNUSED(x)
Mark a local variable as unused.
#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.
void(* Time)(Time oldValue, Time newValue)
TracedValue callback signature for Time.
Every class exported by the ns3 library is enclosed in the ns3 namespace.
Ptr< const AttributeChecker > MakeTimeChecker(const Time min, const Time max)
Helper to make a Time checker with bounded range.
Callback< R, Ts... > MakeCallback(R(T::*memPtr)(Ts...), OBJ objPtr)
Build Callbacks for class method members which take varying numbers of arguments and potentially retu...
Structure holding the informations 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