14#include "ns3/boolean.h"
15#include "ns3/channel.h"
16#include "ns3/ipv6-extension-header.h"
17#include "ns3/ipv6-l3-protocol.h"
19#include "ns3/mac16-address.h"
20#include "ns3/mac48-address.h"
21#include "ns3/mac64-address.h"
23#include "ns3/packet.h"
24#include "ns3/pointer.h"
25#include "ns3/simulator.h"
26#include "ns3/string.h"
27#include "ns3/udp-header.h"
28#include "ns3/udp-l4-protocol.h"
29#include "ns3/uinteger.h"
44 TypeId(
"ns3::SixLowPanNetDevice")
46 .SetGroupName(
"SixLowPan")
48 .AddAttribute(
"Rfc6282",
49 "Use RFC6282 (IPHC) if true, RFC4944 (HC1) otherwise.",
53 .AddAttribute(
"OmitUdpChecksum",
54 "Omit the UDP checksum in IPHC compression.",
59 "FragmentReassemblyListSize",
60 "The maximum size of the reassembly buffer (in packets). Zero meaning infinite.",
65 "FragmentExpirationTimeout",
66 "When this timeout expires, the fragments will be cleared from the buffer.",
70 .AddAttribute(
"CompressionThreshold",
71 "The minimum MAC layer payload size.",
75 .AddAttribute(
"UseMeshUnder",
76 "Use a mesh-under routing protocol.",
80 .AddAttribute(
"MeshUnderRadius",
81 "Hops Left to use in mesh-under.",
85 .AddAttribute(
"MeshCacheLength",
86 "Length of the cache for each source.",
90 .AddAttribute(
"MeshUnderJitter",
91 "The jitter in ms a node uses to forward mesh-under packets - used to "
93 StringValue(
"ns3::UniformRandomVariable[Min=0.0|Max=10.0]"),
97 "Send - packet (including 6LoWPAN header), "
98 "SixLoWPanNetDevice Ptr, interface index.",
100 "ns3::SixLowPanNetDevice::RxTxTracedCallback")
101 .AddTraceSource(
"Rx",
102 "Receive - packet (including 6LoWPAN header), "
103 "SixLoWPanNetDevice Ptr, interface index.",
105 "ns3::SixLowPanNetDevice::RxTxTracedCallback")
106 .AddTraceSource(
"Drop",
107 "Drop - DropReason, packet (including 6LoWPAN header), "
108 "SixLoWPanNetDevice Ptr, interface index.",
110 "ns3::SixLowPanNetDevice::DropTracedCallback");
116 m_netDevice(nullptr),
138 NS_LOG_DEBUG(
"RegisterProtocolHandler for " << device->GetInstanceTypeId().GetName());
141 if (device->GetInstanceTypeId().GetName().find(
"LrWpanNetDevice") != std::string::npos)
158 m_rng->SetStream(stream);
179 iter->second =
nullptr;
235 NS_LOG_LOGIC(
"Dropped packet - we only support mesh if it is paired with a BC0");
244 NS_LOG_LOGIC(
"We have already seen this, no further processing.");
255 "SixLowPan mesh-under flooding can not currently handle extended address "
256 "final destinations: "
259 "SixLowPan mesh-under flooding can not currently handle devices using "
260 "extended addresses: "
273 NS_LOG_LOGIC(
"Not forwarding packet -- hop limit reached");
277 NS_LOG_LOGIC(
"Not forwarding packet -- I am the originator");
366 NS_LOG_DEBUG(
"Unsupported 6LoWPAN encoding: dropping.");
472 return m_netDevice->AddLinkChangeCallback(callback);
553 uint16_t protocolNumber)
566 uint16_t protocolNumber,
594 uint16_t
pktSize = packet->GetSize();
620 meshHdr.SetFinalDst(destination);
630 NS_LOG_LOGIC(
"Compressed packet too short, using uncompressed one");
643 NS_LOG_LOGIC(
"Fragmentation: Packet size " << packet->GetSize() <<
" - Mtu "
662 success &=
m_netDevice->SendFrom(*
it, src, destination, protocolNumber);
666 success &=
m_netDevice->Send(*
it, destination, protocolNumber);
678 packet->AddHeader(
bc0Hdr);
685 ret =
m_netDevice->SendFrom(packet, src, destination, protocolNumber);
750 NS_LOG_DEBUG(
"Original packet: " << *packet <<
" Size " << packet->GetSize());
752 if (packet->PeekHeader(
ipHeader) != 0)
755 size +=
ipHeader.GetSerializedSize();
774 else if (
srcAddr.IsLinkLocal())
839 NS_LOG_DEBUG(
"HC1 Compression - packet size = " << packet->GetSize());
860 ipHeader.SetHopLimit(encoding.GetHopLimit());
862 switch (encoding.GetSrcCompression())
864 const uint8_t* interface;
865 const uint8_t* prefix;
869 prefix = encoding.GetSrcPrefix();
871 for (
int j = 0;
j < 8;
j++)
873 address[
j + 8] = interface[
j];
874 address[
j] = prefix[
j];
879 prefix = encoding.GetSrcPrefix();
880 for (
int j = 0;
j < 8;
j++)
883 address[
j] = prefix[
j];
891 for (
int j = 0;
j < 8;
j++)
893 address[
j + 8] = interface[
j];
902 switch (encoding.GetDstCompression())
904 const uint8_t* interface;
905 const uint8_t* prefix;
909 prefix = encoding.GetDstPrefix();
911 for (
int j = 0;
j < 8;
j++)
913 address[
j + 8] = interface[
j];
914 address[
j] = prefix[
j];
919 prefix = encoding.GetDstPrefix();
920 for (
int j = 0;
j < 8;
j++)
923 address[
j] = prefix[
j];
931 for (
int j = 0;
j < 8;
j++)
933 address[
j + 8] = interface[
j];
942 if (!encoding.IsTcflCompression())
944 ipHeader.SetFlowLabel(encoding.GetFlowLabel());
945 ipHeader.SetTrafficClass(encoding.GetTrafficClass());
953 ipHeader.SetNextHeader(encoding.GetNextHeader());
955 ipHeader.SetPayloadLength(packet->GetSize());
958 encoding.IsHc2HeaderPresent() ==
false,
959 "6LoWPAN: error in decompressing HC1 encoding, unsupported L4 compressed header present.");
963 NS_LOG_DEBUG(
"Rebuilt packet: " << *packet <<
" Size " << packet->GetSize());
975 NS_LOG_DEBUG(
"Original packet: " << *packet <<
" Size " << packet->GetSize() <<
" src: " << src
978 if (packet->PeekHeader(
ipHeader) != 0)
981 size +=
ipHeader.GetSerializedSize();
988 else if ((
ipHeader.GetFlowLabel() != 0) && (
ipHeader.GetTrafficClass() != 0))
995 else if ((
ipHeader.GetFlowLabel() == 0) && (
ipHeader.GetTrafficClass() != 0))
1050 else if (
ipHeader.GetHopLimit() == 0x40)
1054 else if (
ipHeader.GetHopLimit() == 0xFF)
1153 else if (
srcAddr.IsLinkLocal())
1167 if (
ipHeader.GetDestination().IsMulticast())
1181 NS_LOG_LOGIC(
"Checking destination compression: " << dstAddr);
1194 NS_LOG_LOGIC(
"Checking stateful destination compression: " << dstAddr);
1239 NS_LOG_LOGIC(
"Checking stateless destination compression: " << dstAddr);
1336 NS_LOG_DEBUG(
"IPHC Compression - packet size = " << packet->GetSize());
1340 NS_LOG_DEBUG(
"Packet after IPHC compression: " << *packet);
1380 ipHeader.SetHopLimit(encoding.GetHopLimit());
1383 if (encoding.GetSac())
1392 uint8_t
contextId = encoding.GetSrcContextId();
1396 <<
"), dropping packet");
1402 <<
"), dropping packet");
1406 uint8_t contextPrefix[16];
1478 if (encoding.GetDac())
1489 uint8_t
contextId = encoding.GetDstContextId();
1493 <<
"), dropping packet");
1499 <<
"), dropping packet");
1503 uint8_t contextPrefix[16];
1507 if (!encoding.GetM())
1559 if (!encoding.GetM())
1628 uint8_t
traf = 0x00;
1629 switch (encoding.GetTf())
1632 traf |= encoding.GetEcn();
1633 traf = (
traf << 6) | encoding.GetDscp();
1635 ipHeader.SetFlowLabel(encoding.GetFlowLabel() & 0xfff);
1638 traf |= encoding.GetEcn();
1641 ipHeader.SetFlowLabel(encoding.GetFlowLabel());
1644 traf |= encoding.GetEcn();
1645 traf = (
traf << 6) | encoding.GetDscp();
1655 if (encoding.GetNh())
1688 ipHeader.SetNextHeader(encoding.GetNextHeader());
1691 ipHeader.SetPayloadLength(packet->GetSize());
1695 NS_LOG_DEBUG(
"Rebuilt packet: " << *packet <<
" Size " << packet->GetSize());
1719 "LOWPAN_NHC MUST NOT be used to encode IPv6 Extension Headers "
1720 "that have more than 255 octets following the Length field after compression. "
1721 "Packet uncompressed.");
1725 size += packet->RemoveHeader(
hopHeader);
1767 blob.RemoveAtStart(2);
1778 "LOWPAN_NHC MUST NOT be used to encode IPv6 Extension Headers "
1779 "that have more than 255 octets following the Length field after compression. "
1780 "Packet uncompressed.");
1826 blob.RemoveAtStart(2);
1837 "LOWPAN_NHC MUST NOT be used to encode IPv6 Extension Headers "
1838 "that have more than 255 octets following the Length field after compression. "
1839 "Packet uncompressed.");
1884 blob.RemoveAtStart(2);
1895 "LOWPAN_NHC MUST NOT be used to encode IPv6 Extension Headers "
1896 "that have more than 255 octets following the Length field after compression. "
1897 "Packet uncompressed.");
1942 blob.RemoveAtStart(2);
1949 NS_ABORT_MSG(
"IPv6 Mobility Header is not supported in ns-3 yet");
1958 NS_LOG_DEBUG(
"NHC Compression - packet size = " << packet->GetSize());
1962 NS_LOG_DEBUG(
"Packet after NHC compression: " << *packet);
1966std::pair<uint8_t, bool>
1998 if (encoding.GetNh())
2019 blobData[0] = encoding.GetNextHeader();
2050 if (encoding.GetNh())
2071 blobData[0] = encoding.GetNextHeader();
2082 if (encoding.GetNh())
2103 blobData[0] = encoding.GetNextHeader();
2116 if (encoding.GetNh())
2137 blobData[0] = encoding.GetNextHeader();
2167 NS_ABORT_MSG(
"IPv6 Mobility Header is not supported in ns-3 yet");
2174 return std::pair<uint8_t, bool>(0,
true);
2178 NS_ABORT_MSG(
"Trying to decode unknown Extension Header");
2182 NS_LOG_DEBUG(
"Rebuilt packet: " << *packet <<
" Size " << packet->GetSize());
2197 size += packet->RemoveHeader(
udpHeader);
2214 if ((
udpHeader.GetSourcePort() >> 4) == 0xf0b && (
udpHeader.GetDestinationPort() >> 4) == 0xf0b)
2218 else if ((
udpHeader.GetSourcePort() >> 8) == 0xf0 &&
2219 (
udpHeader.GetDestinationPort() >> 8) != 0xf0)
2223 else if ((
udpHeader.GetSourcePort() >> 8) != 0xf0 &&
2224 (
udpHeader.GetDestinationPort() >> 8) == 0xf0)
2234 "UDP_NHC Compression - UDP_NHC header size = " <<
udpNhcHeader.GetSerializedSize());
2235 NS_LOG_DEBUG(
"UDP_NHC Compression - packet size = " << packet->GetSize());
2239 NS_LOG_DEBUG(
"Packet after UDP_NHC compression: " << *packet);
2256 switch (encoding.GetPorts())
2260 udpHeader.SetSourcePort(encoding.GetSrcPort());
2261 udpHeader.SetDestinationPort(encoding.GetDstPort());
2264 udpHeader.SetSourcePort(encoding.GetSrcPort());
2265 temp = (0xf0 << 8) | encoding.GetDstPort();
2269 temp = (0xf0 << 8) | encoding.GetSrcPort();
2271 udpHeader.SetDestinationPort(encoding.GetDstPort());
2274 temp = (0xf0b << 4) | encoding.GetSrcPort();
2276 temp = (0xf0b << 4) | encoding.GetDstPort();
2284 if (encoding.GetC())
2293 NS_LOG_LOGIC(
"Forcing UDP Checksum to " << encoding.GetChecksum());
2294 udpHeader.ForceChecksum(encoding.GetChecksum());
2304 NS_LOG_DEBUG(
"Rebuilt packet: " << *packet <<
" Size " << packet->GetSize());
2319 uint16_t offset = 0;
2324 auto tag =
static_cast<uint16_t
>(
m_rng->GetValue(0, 65535));
2333 "6LoWPAN: can not fragment, 6LoWPAN headers are bigger than MTU");
2355 fragNHdr.SetDatagramOffset((offset) >> 3);
2368 NS_LOG_LOGIC(
"Fragment creation - " << offset <<
", " << offset);
2392 key.first = std::pair<Address, Address>(src, dst);
2395 uint16_t offset = 0;
2441 key.second = std::pair<uint16_t, uint16_t>(
frag1Header.GetDatagramSize(),
2449 key.second = std::pair<uint16_t, uint16_t>(
fragNHeader.GetDatagramSize(),
2505 NS_LOG_LOGIC(
"Rebuilt packet. Size " << packet->GetSize() <<
" - " << *packet);
2531 std::list<std::pair<Ptr<Packet>, uint16_t>>::iterator
it;
2544 "Duplicate fragment size differs. Aborting.");
2583 uint16_t fragmentEnd =
it->first->GetSize() +
it->second;
2601 p->AddAtEnd(m_firstFragment);
2609 NS_ABORT_MSG(
"Overlapping fragments found, forbidden condition");
2614 p->AddAtEnd(
it->first);
2629std::list<Ptr<Packet>>
2643 m_timeoutIter =
iter;
2649 return m_timeoutIter;
2664 it->second =
nullptr;
2723 bool compressionAllowed,
2727 << contextPrefix << compressionAllowed << validLifetime.
As(
Time::S));
2735 if (validLifetime.
IsZero())
2750 bool& compressionAllowed,
2751 Time& validLifetime)
a polymophic address class
uint32_t GetSerializedSize() const
Get the number of bytes needed to serialize the underlying Address Typically, this is GetLength () + ...
uint32_t CopyTo(uint8_t buffer[MAX_SIZE]) const
Copy the address bytes into a buffer.
AttributeValue implementation for Boolean.
automatically resized byte buffer
bool IsNull() const
Check for null implementation.
void Cancel()
This method is syntactic sugar for the ns3::Simulator::Cancel method.
bool IsPending() 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.
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 constexpr 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])
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.
static Dispatch_e GetDispatchType(uint8_t dispatch)
Get the Dispatch type.
Dispatch_e
Dispatch values, as defined in RFC 4944 and RFC 6282
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 SetDatagramTag(uint16_t datagramTag)
Set the datagram tag.
6LoWPAN FRAGN header - see RFC 4944.
void SetDatagramTag(uint16_t datagramTag)
Set the datagram tag.
6LoWPAN HC1 header - see RFC 4944.
LOWPAN_IPHC base Encoding - see RFC 6282.
6LoWPAN IPv6 uncompressed header - see RFC 4944.
6LoWPAN Mesh header - see RFC 4944.
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
static constexpr uint16_t PROT_NUMBER
The protocol number for 6LoWPAN (0xA0ED) - see RFC 7973.
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.
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.
LOWPAN_NHC Extension Header Encoding - see RFC 6282.
@ EID_DESTINATION_OPTIONS_H
UDP LOWPAN_NHC Extension Header Encoding - see RFC 6282.
@ PORTS_LAST_SRC_LAST_DST
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.
bool IsZero() const
Exactly equivalent to t == 0.
AttributeValue implementation for Time.
a unique identifier for an interface.
TypeId SetParent(TypeId tid)
Set the parent TypeId.
static constexpr uint8_t PROT_NUMBER
Protocol number (see http://www.iana.org/assignments/protocol-numbers)
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 > MakeTimeChecker()
Helper to make an unbounded Time checker.
#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.
Ptr< T > Create(Ts &&... args)
Create class instances by constructors with varying numbers of arguments and return them by Ptr.
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.
Ptr< const AttributeChecker > MakeBooleanChecker()
Ptr< const AttributeAccessor > MakeTimeAccessor(T1 a1)
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...
Ptr< const AttributeAccessor > MakeUintegerAccessor(T1 a1)
Ptr< const AttributeAccessor > MakePointerAccessor(T1 a1)
Ptr< const AttributeAccessor > MakeBooleanAccessor(T1 a1)
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.