23 #include "ns3/channel.h" 24 #include "ns3/packet.h" 26 #include "ns3/boolean.h" 27 #include "ns3/abort.h" 28 #include "ns3/simulator.h" 29 #include "ns3/uinteger.h" 30 #include "ns3/icmpv6-header.h" 31 #include "ns3/ipv6-header.h" 32 #include "ns3/mac16-address.h" 33 #include "ns3/mac48-address.h" 34 #include "ns3/mac64-address.h" 35 #include "ns3/unused.h" 36 #include "ns3/ipv6-l3-protocol.h" 37 #include "ns3/ipv6-extension-header.h" 38 #include "ns3/udp-header.h" 39 #include "ns3/udp-l4-protocol.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 .AddTraceSource (
"Tx",
89 "Send - packet (including 6LoWPAN header), " 90 "SixLoWPanNetDevice Ptr, interface index.",
92 "ns3::SixLowPanNetDevice::RxTxTracedCallback")
93 .AddTraceSource (
"Rx",
94 "Receive - packet (including 6LoWPAN header), " 95 "SixLoWPanNetDevice Ptr, interface index.",
97 "ns3::SixLowPanNetDevice::RxTxTracedCallback")
98 .AddTraceSource (
"Drop",
99 "Drop - DropReason, packet (including 6LoWPAN header), " 100 "SixLoWPanNetDevice Ptr, interface index.",
102 "ns3::SixLowPanNetDevice::DropTracedCallback")
114 m_rng = CreateObject<UniformRandomVariable> ();
128 NS_LOG_DEBUG (
"RegisterProtocolHandler for " << device->GetInstanceTypeId ().GetName ());
130 uint16_t protocolType = 0;
137 protocolType, device,
false);
156 iter->second.Cancel ();
176 NS_LOG_FUNCTION (
this << incomingPort << packet << protocol << src << dst);
179 uint8_t dispatchRawVal = 0;
185 copyPkt->
CopyData (&dispatchRawVal,
sizeof(dispatchRawVal));
187 bool isPktDecompressed =
false;
188 bool fragmented =
false;
192 NS_LOG_DEBUG (
"Dispatches: " <<
int(dispatchRawVal) <<
" - " <<
int(dispatchVal) );
206 if ( !isPktDecompressed )
212 copyPkt->
CopyData (&dispatchRawVal,
sizeof(dispatchRawVal));
217 switch ( dispatchVal )
220 NS_LOG_DEBUG (
"Unsupported 6LoWPAN encoding: MESH, dropping.");
224 NS_LOG_DEBUG (
"Unsupported 6LoWPAN encoding: BC0, dropping.");
232 isPktDecompressed =
true;
237 isPktDecompressed =
true;
241 isPktDecompressed =
true;
244 NS_LOG_DEBUG (
"Unsupported 6LoWPAN encoding: dropping.");
249 if ( !isPktDecompressed )
255 NS_LOG_DEBUG (
"Packet decompressed received: " << *copyPkt );
338 return m_netDevice->AddLinkChangeCallback (callback);
399 uint16_t protocolNumber)
405 ret =
DoSend (packet, src, dest, protocolNumber,
false);
412 uint16_t protocolNumber)
417 ret =
DoSend (packet, src, dest, protocolNumber,
true);
424 uint16_t protocolNumber,
427 NS_LOG_FUNCTION (
this << *packet << src << dest << protocolNumber << doSendFrom);
431 uint32_t origHdrSize = 0;
432 uint32_t origPacketSize = packet->
GetSize ();
453 NS_LOG_LOGIC (
"Compressed packet too short, using uncompressed one");
463 std::list<Ptr<Packet> > fragmentList;
465 std::list<Ptr<Packet> >::iterator it;
467 for ( it = fragmentList.begin (); it != fragmentList.end (); it++ )
469 NS_LOG_DEBUG (
"SixLowPanNetDevice::Send (Fragment) " << **it );
473 success &=
m_netDevice->SendFrom (*it, src, dest, protocolNumber);
477 success &=
m_netDevice->Send (*it, dest, protocolNumber);
488 ret =
m_netDevice->SendFrom (packet, src, dest, protocolNumber);
493 ret =
m_netDevice->Send (packet, dest, protocolNumber);
560 NS_LOG_LOGIC (
"Checking source compression: " << mySrcAddr <<
" - " << srcAddr );
563 bool isSrcSrc = (memcmp (bufOne + 8, bufTwo + 8, 8) == 0);
590 NS_LOG_LOGIC (
"Checking destination compression: " << myDstAddr <<
" - " << dstAddr );
593 bool isDstDst = (memcmp (bufOne + 8, bufTwo + 8, 8) == 0);
653 NS_LOG_DEBUG (
"removed " << ret <<
" bytes - pkt is " << *packet);
660 const uint8_t* interface;
661 const uint8_t* prefix;
666 interface = encoding.GetSrcInterface ();
667 for (
int j = 0; j < 8; j++)
676 for (
int j = 0; j < 8; j++)
684 interface = encoding.GetSrcInterface ();
687 for (
int j = 0; j < 8; j++)
700 const uint8_t* interface;
701 const uint8_t* prefix;
706 interface = encoding.GetDstInterface ();
707 for (
int j = 0; j < 8; j++)
716 for (
int j = 0; j < 8; j++)
724 interface = encoding.GetDstInterface ();
727 for (
int j = 0; j < 8; j++)
754 "6LoWPAN: error in decompressing HC1 encoding, unsupported L4 compressed header present.");
808 iphcHeader.
SetNh (
true);
813 iphcHeader.
SetNh (
true);
822 iphcHeader.
SetNh (
true);
827 iphcHeader.
SetNh (
false);
834 iphcHeader.
SetNh (
false);
861 iphcHeader.
SetCid (
false);
865 iphcHeader.
SetSac (
false);
867 uint8_t addressBuf[16];
868 uint8_t unicastAddrCheckerBuf[16];
873 checker.
GetBytes (unicastAddrCheckerBuf);
880 NS_LOG_LOGIC (
"Checking source compression: " << mySrcAddr <<
" - " << srcAddr );
882 if ( mySrcAddr == srcAddr )
886 else if (memcmp (addressBuf, unicastAddrCheckerBuf, 14) == 0)
902 iphcHeader.
SetM (
true);
906 iphcHeader.
SetM (
false);
911 iphcHeader.
SetDac (
false);
921 NS_LOG_LOGIC (
"Checking destination compression: " << myDstAddr <<
" - " << dstAddr );
923 if ( !iphcHeader.
GetM () )
926 if ( myDstAddr == dstAddr )
930 else if (memcmp (addressBuf, unicastAddrCheckerBuf, 14) == 0)
946 uint8_t multicastAddrCheckerBuf[16];
948 multicastCheckAddress.
GetBytes (multicastAddrCheckerBuf);
951 if ( memcmp (addressBuf, multicastAddrCheckerBuf, 15) == 0 )
957 else if ( (addressBuf[0] == multicastAddrCheckerBuf[0])
958 && (memcmp (addressBuf + 2, multicastAddrCheckerBuf + 2, 11) == 0) )
964 else if ( (addressBuf[0] == multicastAddrCheckerBuf[0])
965 && (memcmp (addressBuf + 2, multicastAddrCheckerBuf + 2, 9) == 0) )
980 NS_LOG_DEBUG (
"Packet after IPHC compression: " << *packet);
1018 NS_LOG_DEBUG (
"removed " << ret <<
" bytes - pkt is " << *packet);
1025 if ( encoding.
GetSac () )
1048 if ( encoding.
GetDac () )
1075 uint8_t traf = 0x00;
1076 switch (encoding.
GetTf ())
1079 traf |= encoding.
GetEcn ();
1080 traf = ( traf << 6 ) | encoding.
GetDscp ();
1085 traf |= encoding.
GetEcn ();
1091 traf |= encoding.
GetEcn ();
1092 traf = ( traf << 6 ) | encoding.
GetDscp ();
1102 if ( encoding.
GetNh () )
1105 uint8_t dispatchRawVal = 0;
1108 packet->
CopyData (&dispatchRawVal,
sizeof(dispatchRawVal));
1149 NS_LOG_DEBUG (
"LOWPAN_NHC MUST NOT be used to encode IPv6 Extension Headers " 1150 "that have more than 255 octets following the Length field after compression. " 1151 "Packet uncompressed.");
1164 nhcHeader.
SetNh (
true);
1169 nhcHeader.
SetNh (
true);
1178 nhcHeader.
SetNh (
true);
1183 nhcHeader.
SetNh (
false);
1190 nhcHeader.
SetNh (
false);
1207 NS_LOG_DEBUG (
"LOWPAN_NHC MUST NOT be used to encode IPv6 Extension Headers " 1208 "that have more than 255 octets following the Length field after compression. " 1209 "Packet uncompressed.");
1222 nhcHeader.
SetNh (
true);
1227 nhcHeader.
SetNh (
true);
1236 nhcHeader.
SetNh (
true);
1241 nhcHeader.
SetNh (
false);
1248 nhcHeader.
SetNh (
false);
1265 NS_LOG_DEBUG (
"LOWPAN_NHC MUST NOT be used to encode IPv6 Extension Headers " 1266 "that have more than 255 octets following the Length field after compression. " 1267 "Packet uncompressed.");
1279 nhcHeader.
SetNh (
true);
1284 nhcHeader.
SetNh (
true);
1293 nhcHeader.
SetNh (
true);
1298 nhcHeader.
SetNh (
false);
1305 nhcHeader.
SetNh (
false);
1322 NS_LOG_DEBUG (
"LOWPAN_NHC MUST NOT be used to encode IPv6 Extension Headers " 1323 "that have more than 255 octets following the Length field after compression. " 1324 "Packet uncompressed.");
1336 nhcHeader.
SetNh (
true);
1341 nhcHeader.
SetNh (
true);
1350 nhcHeader.
SetNh (
true);
1355 nhcHeader.
SetNh (
false);
1362 nhcHeader.
SetNh (
false);
1376 NS_ABORT_MSG (
"IPv6 Mobility Header is not supported in ns-3 yet");
1389 NS_LOG_DEBUG (
"Packet after NHC compression: " << *packet);
1401 NS_LOG_DEBUG (
"removed " << ret <<
" bytes - pkt is " << *packet);
1410 uint8_t blobData[260];
1411 blobSize = encoding.
CopyBlob (blobData + 2, 260-2);
1412 uint8_t paddingSize = 0;
1414 uint8_t actualEncodedHeaderType = encoding.
GetEid ();
1415 uint8_t actualHeaderType;
1418 switch (actualEncodedHeaderType)
1422 if ( encoding.
GetNh () )
1425 uint8_t dispatchRawVal = 0;
1428 packet->
CopyData (&dispatchRawVal,
sizeof(dispatchRawVal));
1447 if ((blobSize + 2) % 8 > 0)
1449 paddingSize = 8 - (blobSize + 2) % 8;
1451 if (paddingSize == 1)
1453 blobData[blobSize + 2] = 0;
1455 else if (paddingSize > 1)
1457 blobData[blobSize + 2] = 1;
1458 blobData[blobSize + 2 + 1] = paddingSize - 2;
1459 for (uint8_t i = 0; i < paddingSize - 2; i++)
1461 blobData[blobSize + 2 + 2 + i] = 0;
1464 blobData [1] = ((blobSize + 2 + paddingSize) >> 3) - 1;
1465 blob.
AddAtStart (blobSize + 2 + paddingSize);
1466 blob.
Begin ().
Write (blobData, blobSize + 2 + paddingSize);
1474 if ( encoding.
GetNh () )
1477 uint8_t dispatchRawVal = 0;
1480 packet->
CopyData (&dispatchRawVal,
sizeof(dispatchRawVal));
1497 blobData [1] = ((blobSize + 2) >> 3) - 1;
1499 blob.
Begin ().
Write (blobData, blobSize + 2);
1506 if ( encoding.
GetNh () )
1509 uint8_t dispatchRawVal = 0;
1512 packet->
CopyData (&dispatchRawVal,
sizeof(dispatchRawVal));
1532 blob.
Begin ().
Write (blobData, blobSize + 2);
1540 if ( encoding.
GetNh () )
1543 uint8_t dispatchRawVal = 0;
1546 packet->
CopyData (&dispatchRawVal,
sizeof(dispatchRawVal));
1565 if ((blobSize + 2) % 8 > 0)
1567 paddingSize = 8 - (blobSize + 2) % 8;
1569 if (paddingSize == 1)
1571 blobData[blobSize + 2] = 0;
1573 else if (paddingSize > 1)
1575 blobData[blobSize + 2] = 1;
1576 blobData[blobSize + 2 + 1] = paddingSize - 2;
1577 for (uint8_t i = 0; i < paddingSize - 2; i++)
1579 blobData[blobSize + 2 + 2 + i] = 0;
1582 blobData [1] = ((blobSize + 2 + paddingSize) >> 3) - 1;
1583 blob.
AddAtStart (blobSize + 2 + paddingSize);
1584 blob.
Begin ().
Write (blobData, blobSize + 2 + paddingSize);
1591 NS_ABORT_MSG (
"IPv6 Mobility Header is not supported in ns-3 yet");
1598 NS_ABORT_MSG (
"Trying to decode unknown Extension Header");
1603 return actualHeaderType;
1620 udpNhcHeader.
SetC (
false);
1626 udpNhcHeader.
SetC (
true);
1656 NS_LOG_DEBUG (
"Packet after UDP_NHC compression: " << *packet);
1670 NS_LOG_DEBUG (
"removed " << ret <<
" bytes - pkt is " << *packet);
1684 temp |= (temp << 8) | encoding.
GetDstPort ();
1689 temp |= (temp << 8) | encoding.
GetSrcPort ();
1695 temp |= (temp << 4) | encoding.
GetSrcPort ();
1698 temp |= (temp << 4) | encoding.
GetDstPort ();
1706 if ( encoding.
GetC () )
1732 uint32_t origPacketSize,
1733 uint32_t origHdrSize,
1740 uint16_t offsetData = 0;
1741 uint16_t offset = 0;
1744 uint32_t compressedHeaderSize =
packetSize - (origPacketSize - origHdrSize);
1755 "6LoWPAN: can not fragment, 6LoWPAN headers are bigger than MTU");
1759 size += compressedHeaderSize;
1764 offset += size + origHdrSize - compressedHeaderSize;
1768 listFragments.push_back (fragment1);
1770 bool moreFrag =
true;
1787 NS_LOG_LOGIC (
"Fragment creation - " << offset <<
", " << offset );
1795 listFragments.push_back (fragment);
1810 key.first = std::pair<Address, Address> (src, dst);
1813 uint16_t offset = 0;
1827 uint8_t dispatchRawValFrag1 = 0;
1832 p->CopyData (&dispatchRawValFrag1,
sizeof(dispatchRawValFrag1));
1834 NS_LOG_DEBUG (
"Dispatches: " <<
int(dispatchRawValFrag1) <<
" - " <<
int(dispatchValFrag1) );
1837 switch ( dispatchValFrag1 )
1842 p->RemoveHeader(uncompressedHdr);
1860 p->RemoveHeader (fragNHeader);
1868 MapFragments_t::iterator it =
m_fragments.find (key);
1874 MapFragmentsTimers_t::iterator iter;
1878 if ( iter->second.GetTs () < iterFound->second.GetTs () )
1885 std::list< Ptr<Packet> > storedFragments =
m_fragments[oldestKey]->GetFraments ();
1887 fragIter != storedFragments.end (); fragIter++)
1898 fragments = Create<Fragments> ();
1900 m_fragments.insert (std::make_pair (key, fragments));
1908 fragments = it->second;
1958 std::list<std::pair<Ptr<Packet>, uint16_t> >::iterator it;
1959 bool duplicate =
false;
1963 if (it->second > fragmentOffset)
1967 if (it->second == fragmentOffset)
1970 NS_ASSERT_MSG (fragment->
GetSize () == it->first->GetSize (),
"Duplicate fragment size differs. Aborting.");
1976 m_fragments.insert (it, std::make_pair (fragment, fragmentOffset));
1984 m_firstFragment = fragment;
1992 uint16_t lastEndOffset = 0;
1999 NS_LOG_LOGIC (
"Checking overlaps " << lastEndOffset <<
" - " << it->second );
2001 if (lastEndOffset < it->
second)
2007 uint16_t fragmentEnd = it->first->GetSize () + it->second;
2008 lastEndOffset =
std::max ( lastEndOffset, fragmentEnd );
2012 if ( ret && (lastEndOffset == m_packetSize))
2023 std::list<std::pair<Ptr<Packet>, uint16_t> >::const_iterator it =
m_fragments.begin ();
2026 uint16_t lastEndOffset = 0;
2030 lastEndOffset = it->first->GetSize ();
2034 if ( lastEndOffset > it->second )
2036 NS_ABORT_MSG (
"Overlapping fragments found, forbidden condition");
2043 lastEndOffset += it->first->GetSize ();
2057 std::list< Ptr<Packet> > fragments;
2058 std::list<std::pair<Ptr<Packet>, uint16_t> >::const_iterator iter;
2061 fragments.push_back (iter->first);
2070 MapFragments_t::iterator it =
m_fragments.find (key);
2071 std::list< Ptr<Packet> > storedFragments = it->second->GetFraments ();
2073 fragIter != storedFragments.end (); fragIter++)
2107 if (ipv6Addr.
IsAny ())
2133 if (ipv6Addr.
IsAny ())
uint8_t GetEcn(void) const
Get the ECN.
uint32_t RemoveHeader(Header &header)
Deserialize and remove the header from the internal buffer.
void SetCid(bool cidField)
Set the CID (Context Identifier Extension) compression.
void DecompressLowPanUdpNhc(Ptr< Packet > packet, Ipv6Address saddr, Ipv6Address daddr)
Decompress the headers according to NHC compression.
static bool IsMatchingType(const Address &address)
uint8_t GetNextHeader(void) const
Get the Next Header field value.
void AddAtStart(uint32_t start)
NhcDispatch_e
Dispatch values for Next Header compression.
uint64_t GetUid(void) const
Returns the packet's Uid.
void SetTcflCompression(bool tcflCompression)
Set the Traffic Class and Flow Labels as compressed.
Smart pointer class similar to boost::intrusive_ptr.
#define NS_LOG_FUNCTION(parameters)
If log level LOG_FUNCTION is enabled, this macro will output all input parameters separated by "...
void SetStream(int64_t stream)
Specifies the stream number for the RngStream.
int64_t AssignStreams(int64_t stream)
Assign a fixed random variable stream number to the random variables used by this model...
AttributeValue implementation for Boolean.
void SetHopLimit(uint8_t hopLimit)
Set the Hop Limit field.
#define NS_ABORT_MSG(msg)
Unconditional abnormal program termination with a message.
uint32_t GetId(void) const
void SetDstCompression(LowPanHc1Addr_e dstCompression)
Set Destination Compression type.
NetDevice::PromiscReceiveCallback m_promiscRxCallback
The callback used to notify higher layers that a packet has been received in promiscuous mode...
#define NS_OBJECT_ENSURE_REGISTERED(type)
Register an Object subclass with the TypeId system.
uint32_t GetSize(void) const
Returns the the size in bytes of the packet (including the zero-filled initial payload).
6LoWPAN IPv6 uncompressed header - see RFC 4944.
void RemoveAtStart(uint32_t start)
uint8_t GetDscp(void) const
Get the DSCP.
NS_ASSERT_MSG(false, "Ipv4AddressGenerator::MaskToIndex(): Impossible")
uint16_t GetDstPort() const
Get the Destination Port.
void SetNextHeader(uint8_t nextHeader)
Set the Next Header field values.
virtual void SetIfIndex(const uint32_t index)
static Mac16Address ConvertFrom(const Address &address)
void SetPacketSize(uint32_t packetSize)
Set the packet-to-be-defragmented size.
void AddFirstFragment(Ptr< Packet > fragment)
Add the first packet fragment.
TracedCallback< Ptr< const Packet >, Ptr< SixLowPanNetDevice >, uint32_t > m_txTrace
Callback to trace TX (transmission) packets.
static bool IsMatchingType(const Address &address)
Ptr< const AttributeAccessor > MakeBooleanAccessor(T1 a1)
Create an AttributeAccessor for a class data member, or a lone class get functor or set method...
static Dispatch_e GetDispatchType(uint8_t dispatch)
Get the Dispatch type.
static bool ChecksumEnabled(void)
LOWPAN_IPHC base Encoding - see RFC 6282.
automatically resized byte buffer
Ptr< Packet > CreateFragment(uint32_t start, uint32_t length) const
Create a new packet which contains a fragment of the original packet.
void GetBytes(uint8_t buf[16]) const
Get the bytes corresponding to the address.
void SetPorts(Ports_e port)
Set the compressed Src and Dst Ports.
void SetSrcCompression(LowPanHc1Addr_e srcCompression)
Set Source Compression type.
static Ipv6Address GetAny()
Get the "any" (::) Ipv6Address.
static TypeId GetTypeId(void)
Get the type ID.
virtual uint32_t GetSerializedSize(void) const
Get the serialized size of the packet.
static Ipv6Address MakeAutoconfiguredAddress(Mac16Address addr, Ipv6Address prefix)
Make the autoconfigured IPv6 address with Mac16Address.
#define NS_LOG_COMPONENT_DEFINE(name)
Define a Log component with a specific name.
virtual bool IsBroadcast(void) const
HeaderCompression_e GetSam(void) const
Get the SAM (Source Address Mode) compression.
Unsupported compression kind.
#define NS_UNUSED(x)
Mark a local variable as unused.
bool GetNh(void) const
Get the Next Header field value.
LOWPAN_NHC Extension Header Encoding - see RFC 6282.
std::pair< std::pair< Address, Address >, std::pair< uint16_t, uint16_t > > FragmentKey
Fragment identifier type: src/dst address src/dst port.
uint16_t m_fragmentReassemblyListSize
How many packets can be rebuilt at the same time.
#define NS_FATAL_ERROR(msg)
Report a fatal error with a message and terminate.
virtual void DoDispose(void)
Destructor implementation.
void SetDatagramOffset(uint8_t datagramOffset)
Set the datagram offset.
void SetSam(HeaderCompression_e samField)
Set the SAM (Source Address Mode) compression.
static bool IsMatchingType(const Address &address)
Check that a generic Address is compatible with Mac8Address.
uint8_t const * PeekData(void) const
6LoWPAN FRAGN header - see RFC 4944.
virtual Address GetAddress(void) const
uint32_t GetFlowLabel(void) const
Get the Flow Label.
void SetDatagramSize(uint16_t datagramSize)
Set the datagram size.
virtual uint32_t GetSerializedSize(void) const
Get the serialized size of the packet.
Fragment buffer size exceeded.
virtual bool SetMtu(const uint16_t mtu)
bool IsEntire() const
If all fragments have been added.
void SetNetDevice(Ptr< NetDevice > device)
Setup SixLowPan to be a proxy for the specified NetDevice.
void SetTrafficClass(uint8_t trafficClass)
Set the Traffic Class value.
a polymophic address class
std::map< FragmentKey, EventId >::iterator MapFragmentsTimersI_t
Container Iterator for fragment key -> expiration event.
Ptr< const TraceSourceAccessor > MakeTraceSourceAccessor(T a)
Create a TraceSourceAccessor which will control access to the underlying trace source.
virtual uint32_t GetSerializedSize(void) const
Get the serialized size of the packet.
Ptr< const AttributeChecker > MakeTimeChecker(const Time min, const Time max)
Helper to make a Time checker with bounded range.
void SetHlim(Hlim_e hlimField)
Set the HLIM (Hop Limit) compression.
virtual bool IsMulticast(void) const
uint32_t CompressLowPanNhc(Ptr< Packet > packet, uint8_t headerType, Address const &src, Address const &dst)
Compress the headers according to NHC compression.
bool m_useIphc
Use IPHC or HC1.
void AddAtEnd(Ptr< const Packet > packet)
Concatenate the input packet at the end of the current packet.
Ptr< Node > m_node
Smart pointer to the Node.
uint8_t GetHopLimit(void) const
Get the "Hop limit" field (TTL).
void SetBlob(const uint8_t *blob, uint32_t size)
Set the option header data blob.
uint32_t CompressLowPanUdpNhc(Ptr< Packet > packet, bool omitChecksum)
Compress the headers according to NHC compression.
uint32_t CompressLowPanIphc(Ptr< Packet > packet, Address const &src, Address const &dst)
Compress the headers according to IPHC compression.
HeaderCompression_e GetDam(void) const
Get the DAM (Destination Address Mode) compression.
static EventId Schedule(Time const &delay, MEM mem_ptr, OBJ obj)
Schedule an event to expire after delay.
void SetHc2HeaderPresent(bool hc2HeaderPresent)
Set the next header a HC2 compressed header.
AttributeValue implementation for Time.
void SetDscp(uint8_t dscp)
Set the DSCP (6bits).
Ptr< Packet > GetPacket() const
Get the entire packet.
Hold an unsigned integer type.
void SetDstInterface(const uint8_t *dstInterface)
Set the destination interface.
uint32_t m_packetSize
The size of the reconstructed packet (bytes).
bool GetNh(void) const
Get the NH (Next Header) compression.
void SetSac(bool sacField)
Set the SAC (Source Address Compression) compression.
std::list< Ptr< Packet > > GetFraments() const
Get a list of the current stored fragments.
void SetNh(bool nhField)
Set the NH (Next Header) compression.
bool IsLinkLocal() const
If the IPv6 address is a link-local address (fe80::/64).
void SetChecksum(uint16_t checksum)
Set the Checksum field values.
uint32_t PeekHeader(Header &header) const
Deserialize but does not remove the header from the internal buffer.
Callback< R > MakeCallback(R(T::*memPtr)(void), OBJ objPtr)
Ipv6Address GetSrcAddress() const
Get the Source Address.
uint8_t GetNextHeader(void) const
Get the Next Header field.
void SetDstPort(uint16_t port)
Set the Destination Port.
uint8_t GetTrafficClass() const
Get the Traffic Class value.
void SetDatagramSize(uint16_t datagramSize)
Set the datagram size.
bool IsHc2HeaderPresent() const
Check if there is a HC2 compressed header.
TracedCallback< DropReason, Ptr< const Packet >, Ptr< SixLowPanNetDevice >, uint32_t > m_dropTrace
Callback to trace drop packets.
virtual void SetPromiscReceiveCallback(NetDevice::PromiscReceiveCallback cb)
void SetSrcPort(uint16_t port)
Set the Source Port.
static Mac48Address ConvertFrom(const Address &address)
virtual Ptr< Channel > GetChannel(void) const
Time m_fragmentExpirationTimeout
Time limit for fragment rebuilding.
Ptr< T > GetObject(void) const
Get a pointer to the requested aggregated Object.
bool m_forceEtherType
Force the EtherType number.
virtual bool NeedsArp(void) const
virtual uint32_t GetIfIndex(void) const
std::map< FragmentKey, Ptr< Fragments > >::iterator MapFragmentsI_t
Container Iterator for fragment key -> fragments.
const uint8_t * GetDstPrefix() const
Get the destination prefix.
virtual bool IsBridge(void) const
Return true if the net device is acting as a bridge.
bool IsMulticast() const
If the IPv6 address is multicast (ff00::/8).
virtual void SetNode(Ptr< Node > node)
Every class exported by the ns3 library is enclosed in the ns3 namespace.
void SetNextHeader(uint8_t nextHeader)
Set the Next Header field.
TrafficClassFlowLabel_e GetTf(void) const
Get the TF (Traffic Class, Flow Label) compression.
virtual Address GetMulticast(Ipv4Address multicastGroup) const
Make and return a MAC multicast address using the provided multicast group.
uint32_t m_compressionThreshold
Minimum L2 payload size.
Shim performing 6LoWPAN compression, decompression and fragmentation.
Ipv6Address MakeLinkLocalAddressFromMac(Address const &addr)
Make a link-local address from a MAC address.
Ptr< const AttributeChecker > MakeBooleanChecker(void)
virtual uint32_t GetSerializedSize(void) const
Get the serialized size of the packet.
bool IsTcflCompression() const
Check if the Traffic Class and Flow Labels are compressed.
Ptr< Packet > Copy(void) const
performs a COW copy of the packet.
MapFragmentsTimers_t m_fragmentsTimers
Timers related to fragment rebuilding.
uint16_t GetSrcPort() const
Get the Source Port.
virtual void AddLinkChangeCallback(Callback< void > callback)
LowPanHc1Addr_e GetDstCompression() const
Get Destination Compression type.
NetDevice::ReceiveCallback m_rxCallback
The callback used to notify higher layers that a packet has been received.
void SetSrcAddress(Ipv6Address srcAddress)
Set the Source Address.
uint8_t GetDatagramOffset(void) const
Get the datagram offset.
void DoFragmentation(Ptr< Packet > packet, uint32_t origPacketSize, uint32_t origHdrSize, std::list< Ptr< Packet > > &listFragments)
Performs a packet fragmentation.
Ptr< const AttributeAccessor > MakeTimeAccessor(T1 a1)
Create an AttributeAccessor for a class data member, or a lone class get functor or set method...
bool GetSac(void) const
Get the SAC (Source Address Compression) compression.
static Time Now(void)
Return the current simulation virtual time.
uint16_t GetChecksum(void) const
Get the Checksum field value.
uint16_t GetDatagramSize(void) const
Get the datagram size.
6LoWPAN HC1 header - see RFC 4944.
NS_LOG_LOGIC("Net device "<< nd<< " is not bridged")
void SetHopLimit(uint8_t limit)
Set the "Hop limit" field (TTL).
virtual bool SupportsSendFrom() const
void SetDac(bool dacField)
Set the DAC (Destination Address Compression) compression.
void RegisterProtocolHandler(ProtocolHandler handler, uint16_t protocolType, Ptr< NetDevice > device, bool promiscuous=false)
virtual bool Send(Ptr< Packet > packet, const Address &dest, uint16_t protocolNumber)
void SetSrcInterface(const uint8_t *srcInterface)
Set the source interface.
uint16_t m_etherType
EtherType number (used only if m_forceEtherType is true).
void SetDstPrefix(const uint8_t *dstPrefix)
Set the destination prefix.
uint16_t GetDatagramTag(void) const
Get the datagram tag.
static Ipv6Address MakeAutoconfiguredLinkLocalAddress(Mac16Address mac)
Make the autoconfigured link-local IPv6 address with Mac16Address.
Describes an IPv6 address.
void DecompressLowPanIphc(Ptr< Packet > packet, Address const &src, Address const &dst)
Decompress the headers according to IPHC compression.
Ipv4 addresses are stored in host order in this class.
SixLowPanNetDevice()
Constructor for the SixLowPanNetDevice.
virtual Ptr< Node > GetNode(void) const
uint32_t GetFlowLabel() const
Get the Flow Label value.
Ipv6Address MakeGlobalAddressFromMac(Address const &addr, Ipv6Address prefix)
Make a global address from a MAC address.
virtual uint32_t GetSerializedSize(void) const
Get the serialized size of the packet.
void SetFlowLabel(uint32_t flowLabel)
Set the Flow Label (20bits).
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.
static Mac64Address ConvertFrom(const Address &address)
Network layer to device interface.
uint8_t GetHopLimit(void) const
Get the Hop Limit field.
uint32_t CopyData(uint8_t *buffer, uint32_t size) const
Copy the packet contents to a byte buffer.
#define NS_LOG_DEBUG(msg)
Use NS_LOG to output a message of level LOG_DEBUG.
Time Seconds(double value)
Construct a Time in the indicated unit.
LowPanHc1Addr_e GetSrcCompression() const
Get Source Compression type.
static NhcDispatch_e GetNhcDispatchType(uint8_t dispatch)
Get the NhcDispatch type.
uint32_t GetSize(void) const
void SetEid(Eid_e extensionHeaderType)
Set the Extension Header Type.
Eid_e GetEid(void) const
Get the Extension Header Type.
bool CanCompressLowPanNhc(uint8_t headerType)
Checks if the next header can be compressed using NHC.
void Write(uint8_t const *buffer, uint32_t size)
bool m_omitUdpChecksum
Omit UDP checksum in NC1 encoding.
Ports_e GetPorts(void) const
Get the compressed Src and Dst Ports.
Fragment timeout exceeded.
bool DoSend(Ptr< Packet > packet, const Address &source, const Address &dest, uint16_t protocolNumber, bool doSendFrom)
TracedCallback< Ptr< const Packet >, Ptr< SixLowPanNetDevice >, uint32_t > m_rxTrace
Callback to trace RX (reception) packets.
void SetNh(bool nhField)
Set the NH field values.
void SetTf(TrafficClassFlowLabel_e tfField)
Set the TF (Traffic Class, Flow Label) compression.
uint16_t GetDatagramSize(void) const
Get the datagram size.
virtual bool SendFrom(Ptr< Packet > packet, const Address &source, const Address &dest, uint16_t protocolNumber)
Dispatch_e
Dispatch values, as defined in RFC 4944 and RFC 6282
virtual uint32_t GetSerializedSize(void) const
Get the serialized size of the packet.
static const uint32_t packetSize
void SetDstAddress(Ipv6Address dstAddress)
Set the Destination Address.
Ptr< NetDevice > m_netDevice
Smart pointer to the underlying NetDevice.
void HandleFragmentsTimeout(FragmentKey key, uint32_t iif)
Process the timeout for packet fragments.
void AddFragment(Ptr< Packet > fragment, uint16_t fragmentOffset)
Add a fragment to the pool.
bool ProcessFragment(Ptr< Packet > &packet, Address const &src, Address const &dst, bool isFirst)
Process a packet fragment.
void SetM(bool mField)
Set the M (Multicast) compression.
PacketType
Packet types are used as they are in Linux.
void SetSrcPrefix(const uint8_t *srcPrefix)
Set the source prefix.
bool GetM(void) const
Get the M (Multicast) compression.
Ptr< NetDevice > GetNetDevice() const
Returns a smart pointer to the underlying NetDevice.
virtual bool IsLinkUp(void) const
virtual uint16_t GetMtu(void) const
Returns the link-layer MTU for this interface.
static bool IsMatchingType(const Address &address)
bool IsNull(void) const
Check for null implementation.
uint32_t CopyBlob(uint8_t *blob, uint32_t size) const
Get the option header data blob.
void SetDatagramTag(uint16_t datagramTag)
Set the datagram tag.
void SetEcn(uint8_t ecn)
Set the ECN (2bits).
bool GetC(void) const
Get the C (Checksum).
virtual bool IsPointToPoint(void) const
Return true if the net device is on a point-to-point link.
uint16_t GetDatagramTag(void) const
Get the datagram tag.
6LoWPAN FRAG1 header - see RFC 4944.
uint32_t CompressLowPanHc1(Ptr< Packet > packet, Address const &src, Address const &dst)
Compress the headers according to HC1 compression.
virtual Address GetBroadcast(void) const
Ptr< const AttributeAccessor > MakeUintegerAccessor(T1 a1)
Create an AttributeAccessor for a class data member, or a lone class get functor or set method...
virtual void SetReceiveCallback(NetDevice::ReceiveCallback cb)
a unique identifier for an interface.
bool GetDac(void) const
Get the DAC (Destination Address Compression) compression.
static const uint8_t PROT_NUMBER
protocol number (0x11)
TypeId SetParent(TypeId tid)
Set the parent TypeId.
uint32_t m_ifIndex
Interface index.
Buffer::Iterator Begin(void) const
UDP LOWPAN_NHC Extension Header Encoding - see RFC 6282.
static Mac8Address ConvertFrom(const Address &address)
Convert a generic address to a Mac8Address.
void SetC(bool cField)
Set the C (Checksum).
uint8_t DecompressLowPanNhc(Ptr< Packet > packet, Address const &src, Address const &dst, Ipv6Address srcAddress, Ipv6Address dstAddress)
Decompress the headers according to NHC compression.
static const uint16_t PROT_NUMBER
The protocol number for IPv6 (0x86DD).
virtual void SetAddress(Address address)
Set the address of this interface.
const uint8_t * GetSrcPrefix() const
Get the source prefix.
void DecompressLowPanHc1(Ptr< Packet > packet, Address const &src, Address const &dst)
Decompress the headers according to HC1 compression.
void SetNextHeader(uint8_t nextHeader)
Set the Next Header value.
void AddHeader(const Header &header)
Add header to this packet.
void SetDam(HeaderCompression_e damField)
Set the DAM (Destination Address Mode) compression.
MapFragments_t m_fragments
Fragments hold to be rebuilt.
bool IsAny() const
If the IPv6 address is the "Any" address.
Ptr< UniformRandomVariable > m_rng
Rng for the fragments tag.
void SetFlowLabel(uint32_t flowLabel)
Set the Flow Label value.
Ipv6Address GetDstAddress() const
Get the Destination Address.
virtual void DoDispose(void)
Destructor implementation.
void SetDatagramTag(uint16_t datagramTag)
Set the datagram tag.
uint8_t GetNextHeader() const
Get the Next Header value.