|
A Discrete-Event Network Simulator
|
API
|
Go to the documentation of this file.
22 #ifndef SIXLOWPAN_NET_DEVICE_H
23 #define SIXLOWPAN_NET_DEVICE_H
29 #include "ns3/traced-callback.h"
30 #include "ns3/nstime.h"
31 #include "ns3/net-device.h"
32 #include "ns3/random-variable-stream.h"
33 #include "ns3/simulator.h"
38 class UniformRandomVariable;
92 virtual void SetIfIndex (
const uint32_t index);
97 virtual bool SetMtu (
const uint16_t mtu);
106 virtual uint16_t
GetMtu (
void)
const;
411 typedef std::pair< std::pair<Address, Address>, std::pair<uint16_t, uint16_t> >
FragmentKey_t;
a unique identifier for an interface.
FragmentsTimeoutsListI_t m_timeoutIter
Timeout iterator to "event" handler.
@ DROP_UNKNOWN_EXTENSION
Unsupported compression kind.
FragmentsTimeoutsListI_t GetTimeoutIter()
Get the Timeout iterator.
TracedCallback< Ptr< const Packet >, Ptr< SixLowPanNetDevice >, uint32_t > m_txTrace
Callback to trace TX (transmission) packets.
void InvalidateContext(uint8_t contextId)
Invalidate a context used in IPHC stateful compression.
Ptr< Node > m_node
Smart pointer to the Node.
An identifier for simulation events.
virtual uint16_t GetMtu(void) const
Returns the link-layer MTU for this interface.
Every class exported by the ns3 library is enclosed in the ns3 namespace.
FragmentsTimeoutsList_t m_timeoutEventList
Timeout "events" container.
virtual bool IsPointToPoint(void) const
Return true if the net device is on a point-to-point link.
virtual void SetAddress(Address address)
Set the address of this interface.
uint16_t m_fragmentReassemblyListSize
How many packets can be rebuilt at the same time.
FragmentsTimeoutsListI_t SetTimeout(FragmentKey_t key, uint32_t iif)
Set a new timeout "event" for a fragmented packet.
int64_t AssignStreams(int64_t stream)
Assign a fixed random variable stream number to the random variables used by this model.
bool m_meshUnder
Use a mesh-under routing.
void AddFirstFragment(Ptr< Packet > fragment)
Add the first packet fragment.
Ipv6Address CleanPrefix(Ipv6Address address, Ipv6Prefix prefix)
Clean an address from its prefix.
void AddContext(uint8_t contextId, Ipv6Prefix contextPrefix, bool compressionAllowed, Time validLifetime)
Add, remove, or update a context used in IPHC stateful compression.
std::map< FragmentKey_t, Ptr< Fragments > >::iterator MapFragmentsI_t
Container Iterator for fragment key -> fragments.
bool compressionAllowed
compression and decompression allowed (true), decompression only (false)
A template-based reference counting class.
bool ProcessFragment(Ptr< Packet > &packet, Address const &src, Address const &dst, bool isFirst)
Process a packet fragment.
Ipv4 addresses are stored in host order in this class.
Describes an IPv6 address.
uint32_t m_packetSize
The size of the reconstructed packet (bytes).
virtual bool IsMulticast(void) const
Ptr< RandomVariableStream > m_meshUnderJitter
Random variable for the mesh-under packet retransmission.
virtual void SetIfIndex(const uint32_t index)
virtual Address GetMulticast(Ipv4Address multicastGroup) const
Make and return a MAC multicast address using the provided multicast group.
virtual Address GetAddress(void) const
@ DROP_DISALLOWED_COMPRESSION
HC1 while in IPHC mode or viceversa.
MapFragments_t m_fragments
Fragments hold to be rebuilt.
std::map< Address, std::list< uint8_t > > m_seenPkts
Seen packets, memorized by OriginatorAdddress, SequenceNumber.
std::list< std::tuple< Time, FragmentKey_t, uint32_t > > FragmentsTimeoutsList_t
Container for fragment timeouts.
bool m_useIphc
Use IPHC or HC1.
bool IsEntire() const
If all fragments have been added.
bool CanCompressLowPanNhc(uint8_t headerType)
Checks if the next header can be compressed using NHC.
bool DecompressLowPanIphc(Ptr< Packet > packet, Address const &src, Address const &dst)
Decompress the headers according to IPHC compression.
virtual bool IsLinkUp(void) const
virtual bool IsBridge(void) const
Return true if the net device is acting as a bridge.
uint32_t m_ifIndex
Interface index.
void SetTimeoutIter(FragmentsTimeoutsListI_t iter)
Set the Timeout iterator.
void RenewContext(uint8_t contextId, Time validLifetime)
Renew a context used in IPHC stateful compression.
bool m_forceEtherType
Force the EtherType number.
void SetPacketSize(uint32_t packetSize)
Set the packet-to-be-defragmented size.
bool DoSend(Ptr< Packet > packet, const Address &source, const Address &dest, uint16_t protocolNumber, bool doSendFrom)
virtual bool IsBroadcast(void) const
bool FindMulticastCompressionContext(Ipv6Address address, uint8_t &contextId)
Finds if the given multicast address matches a context for compression.
void DecompressLowPanUdpNhc(Ptr< Packet > packet, Ipv6Address saddr, Ipv6Address daddr)
Decompress the headers according to NHC compression.
SixLowPanNetDevice()
Constructor for the SixLowPanNetDevice.
void DoFragmentation(Ptr< Packet > packet, uint32_t origPacketSize, uint32_t origHdrSize, uint32_t extraHdrSize, std::list< Ptr< Packet > > &listFragments)
Performs a packet fragmentation.
uint8_t m_bc0Serial
Serial number used in BC0 header.
virtual void SetPromiscReceiveCallback(NetDevice::PromiscReceiveCallback cb)
Ptr< Packet > m_firstFragment
The very first fragment.
virtual void SetReceiveCallback(NetDevice::ReceiveCallback cb)
a polymophic address class
uint16_t m_meshCacheLength
length of the cache for each source.
Shim performing 6LoWPAN compression, decompression and fragmentation.
uint32_t CompressLowPanNhc(Ptr< Packet > packet, uint8_t headerType, Address const &src, Address const &dst)
Compress the headers according to NHC compression.
virtual Ptr< Node > GetNode(void) const
virtual bool Send(Ptr< Packet > packet, const Address &dest, uint16_t protocolNumber)
@ DROP_FRAGMENT_TIMEOUT
Fragment timeout exceeded.
uint32_t CompressLowPanIphc(Ptr< Packet > packet, Address const &src, Address const &dst)
Compress the headers according to IPHC compression.
SixLowPanNetDevice & operator=(SixLowPanNetDevice const &)
Copy constructor.
NetDevice::ReceiveCallback m_rxCallback
The callback used to notify higher layers that a packet has been received.
Ptr< Packet > GetPacket() const
Get the entire packet.
static TypeId GetTypeId(void)
Get the type ID.
Simulation virtual time values and global simulation resolution.
TracedCallback< DropReason, Ptr< const Packet >, Ptr< SixLowPanNetDevice >, uint32_t > m_dropTrace
Callback to trace drop packets.
virtual bool SupportsSendFrom() const
virtual Address GetBroadcast(void) const
bool GetContext(uint8_t contextId, Ipv6Prefix &contextPrefix, bool &compressionAllowed, Time &validLifetime)
Get a context used in IPHC stateful compression.
virtual void DoDispose(void)
Destructor implementation.
std::list< Ptr< Packet > > GetFraments() const
Get a list of the current stored fragments.
void(* RxTxTracedCallback)(Ptr< const Packet > packet, Ptr< SixLowPanNetDevice > sixNetDevice, uint32_t ifindex)
TracedCallback signature for packet send/receive events.
std::list< std::pair< Ptr< Packet >, uint16_t > > m_fragments
The current fragments.
void DropOldestFragmentSet()
Drops the oldest fragment set.
NetDevice::PromiscReceiveCallback m_promiscRxCallback
The callback used to notify higher layers that a packet has been received in promiscuous mode.
uint32_t CompressLowPanUdpNhc(Ptr< Packet > packet, bool omitChecksum)
Compress the headers according to NHC compression.
Structure holding the informations for a context (used in compression and decompression)
uint16_t m_etherType
EtherType number (used only if m_forceEtherType is true).
uint32_t m_compressionThreshold
Minimum L2 payload size.
void HandleTimeout(void)
Handles a fragmented packet timeout.
void DecompressLowPanHc1(Ptr< Packet > packet, Address const &src, Address const &dst)
Decompress the headers according to HC1 compression.
void AddFragment(Ptr< Packet > fragment, uint16_t fragmentOffset)
Add a fragment to the pool.
virtual bool NeedsArp(void) const
static const uint32_t packetSize
std::list< std::tuple< Time, FragmentKey_t, uint32_t > >::iterator FragmentsTimeoutsListI_t
Container Iterator for fragment timeouts.
TracedCallback< Ptr< const Packet >, Ptr< SixLowPanNetDevice >, uint32_t > m_rxTrace
Callback to trace RX (reception) packets.
void HandleFragmentsTimeout(FragmentKey_t key, uint32_t iif)
Process the timeout for packet fragments.
@ DROP_FRAGMENT_BUFFER_FULL
Fragment buffer size exceeded.
std::pair< std::pair< Address, Address >, std::pair< uint16_t, uint16_t > > FragmentKey_t
Fragment identifier type: src/dst address src/dst port.
virtual void AddLinkChangeCallback(Callback< void > callback)
Ptr< UniformRandomVariable > m_rng
Rng for the fragments tag.
Ptr< NetDevice > m_netDevice
Smart pointer to the underlying NetDevice.
uint32_t CompressLowPanHc1(Ptr< Packet > packet, Address const &src, Address const &dst)
Compress the headers according to HC1 compression.
std::map< FragmentKey_t, Ptr< Fragments > > MapFragments_t
Container for fragment key -> fragments.
Address Get16MacFrom48Mac(Address addr)
Get a Mac16 from its Mac48 pseudo-MAC.
Time validLifetime
validity period
EventId m_timeoutEvent
Event for the next scheduled timeout.
PacketType
Packet types are used as they are in Linux.
bool FindUnicastCompressionContext(Ipv6Address address, uint8_t &contextId)
Finds if the given unicast address matches a context for compression.
Forward calls to a chain of Callback.
virtual Ptr< Channel > GetChannel(void) const
DropReason
Enumeration of the dropping reasons in SixLoWPAN.
uint8_t m_meshUnderHopsLeft
Start value for mesh-under hops left.
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.
Time m_fragmentExpirationTimeout
Time limit for fragment rebuilding.
std::map< uint8_t, ContextEntry > m_contextTable
Table of the contexts used in compression/decompression.
Ptr< NetDevice > GetNetDevice() const
Returns a smart pointer to the underlying NetDevice.
Ipv6Prefix contextPrefix
context prefix to be used in compression/decompression
virtual bool SetMtu(const uint16_t mtu)
Describes an IPv6 prefix.
virtual uint32_t GetIfIndex(void) const
void RemoveContext(uint8_t contextId)
Remove a context used in IPHC stateful compression.
void SetNetDevice(Ptr< NetDevice > device)
Setup SixLowPan to be a proxy for the specified NetDevice.
virtual bool SendFrom(Ptr< Packet > packet, const Address &source, const Address &dest, uint16_t protocolNumber)
@ DROP_SATETFUL_DECOMPRESSION_PROBLEM
Decompression failed due to missing or expired context.
SixLowPanNetDevice(SixLowPanNetDevice const &)
Copy constructor.
Network layer to device interface.
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.
virtual void SetNode(Ptr< Node > node)
bool m_omitUdpChecksum
Omit UDP checksum in NC1 encoding.
void(* DropTracedCallback)(DropReason reason, Ptr< const Packet > packet, Ptr< SixLowPanNetDevice > sixNetDevice, uint32_t ifindex)
TracedCallback signature fo packet drop events.