19 #ifndef EMU_NET_DEVICE_H
20 #define EMU_NET_DEVICE_H
24 #include "ns3/address.h"
25 #include "ns3/net-device.h"
27 #include "ns3/callback.h"
28 #include "ns3/packet.h"
29 #include "ns3/traced-callback.h"
30 #include "ns3/event-id.h"
31 #include "ns3/nstime.h"
32 #include "ns3/data-rate.h"
34 #include "ns3/mac48-address.h"
35 #include "ns3/system-thread.h"
36 #include "ns3/system-mutex.h"
125 virtual void SetIfIndex (
const uint32_t index);
133 virtual bool SetMtu (
const uint16_t mtu);
134 virtual uint16_t
GetMtu (
void)
const;
256 void ForwardUp (uint8_t *buf, uint32_t len);
keep track of time values and allow control of global simulation resolution
void StopDevice(void)
Tear down the device.
virtual ~EmuNetDevice()
Destroy a EmuNetDevice.
smart pointer class similar to boost::intrusive_ptr
TracedCallback< Ptr< const Packet > > m_macPromiscRxTrace
The trace source fired for packets successfully received by the device immediately before being forwa...
SystemMutex m_pendingReadMutex
virtual bool NeedsArp(void) const
Ptr< Queue > m_queue
The Queue which this EmuNetDevice uses as a packet source.
TracedCallback< Ptr< const Packet > > m_promiscSnifferTrace
A trace source that emulates a promiscuous mode protocol sniffer connected to the device...
virtual void SetReceiveCallback(NetDevice::ReceiveCallback cb)
std::string FindCreator(std::string creatorName)
Figure out where the raw socket creation process lives on the system.
std::string m_deviceName
The unix/linux name of the underlying device (e.g., eth0)
EmuNetDevice & operator=(const EmuNetDevice &)
virtual bool Send(Ptr< Packet > packet, const Address &dest, uint16_t protocolNumber)
uint8_t * m_packetBuffer
A 64K buffer to hold packet data while it is being sent.
virtual bool IsBroadcast(void) const
forward calls to a chain of CallbackAn ns3::TracedCallback has almost exactly the same API as a norma...
EncapsulationMode
Enumeration of the types of packets supported in the class.
virtual bool SupportsSendFrom(void) const
bool m_isBroadcast
Flag indicating whether or not the underlying net device supports broadcast.
Ptr< Queue > GetQueue(void) const
Get a copy of the attached Queue.
void StartDevice(void)
Spin up the device.
TracedCallback< Ptr< const Packet > > m_snifferTrace
A trace source that emulates a non-promiscuous protocol sniffer connected to the device.
virtual void SetNode(Ptr< Node > node)
TracedCallback< Ptr< const Packet > > m_phyTxDropTrace
The trace source fired when the phy layer drops a packet as it tries to transmit it.
bool TransmitStart(Ptr< Packet > p)
Start Sending a Packet Down the Wire.
void ReadThread(void)
Loop to read and process packets.
TracedCallback< Ptr< const Packet > > m_macRxTrace
The trace source fired for packets successfully received by the device immediately before being forwa...
virtual void SetIfIndex(const uint32_t index)
NetDevice::PromiscReceiveCallback m_promiscRxCallback
The callback used to notify higher layers that a packet has been received in promiscuous mode...
TracedCallback< Ptr< const Packet > > m_phyTxBeginTrace
The trace source fired when a packet begins the transmission process on the medium.
TracedCallback< Ptr< const Packet > > m_macTxDropTrace
The trace source fired when packets coming into the "top" of the device at the L3/L2 transition are d...
Ptr< Node > m_node
The Node to which this device is attached.
void Start(Time tStart)
Set a start time for the device.
static TypeId GetTypeId(void)
a polymophic address class
virtual uint32_t GetIfIndex(void) const
virtual Address GetAddress(void) const
Class for representing data rates.
TracedCallback< Ptr< const Packet > > m_phyRxBeginTrace
The trace source fired when a packet begins the reception process from the medium.
bool m_linkUp
Flag indicating whether or not the link is up.
void SetQueue(Ptr< Queue > queue)
Attach a queue to the EmuNetDevice.
bool ProcessHeader(Ptr< Packet > p, uint16_t ¶m)
Removes, from a packet of data, all headers and trailers that relate to the protocol implemented by t...
virtual uint16_t GetMtu(void) const
virtual Ptr< Node > GetNode(void) const
TracedCallback< Ptr< const Packet > > m_macRxDropTrace
The trace source fired for packets successfully received by the device but which are dropped before b...
virtual Ptr< Channel > GetChannel(void) const
Ptr< SystemThread > m_readThread
EmuNetDevice::EncapsulationMode GetEncapsulationMode(void) const
Get the encapsulation mode of this device.
EmuNetDevice()
Construct a EmuNetDevice.
void SetEncapsulationMode(EmuNetDevice::EncapsulationMode mode)
Set the encapsulation mode of this device.
void Stop(Time tStop)
Set a stop time for the device.
NetDevice::ReceiveCallback m_rxCallback
The callback used to notify higher layers that a packet has been received.
TracedCallback< Ptr< const Packet > > m_phyRxTrace
The trace source fired when a packet ends the reception process from the medium.
virtual void SetPromiscReceiveCallback(PromiscReceiveCallback cb)
uint32_t m_ifIndex
The ns-3 interface index (in the sense of net device index) that has been assigned to this network de...
TracedCallback m_linkChangeCallbacks
Callbacks to fire if the link changes state (up or down).
TracedCallback< Ptr< const Packet > > m_phyTxEndTrace
The trace source fired when a packet ends the transmission process on the medium. ...
void ForwardUp(uint8_t *buf, uint32_t len)
Method to handle received packets.
virtual bool SendFrom(Ptr< Packet > packet, const Address &source, const Address &dest, uint16_t protocolNumber)
virtual bool IsPointToPoint(void) const
Is this a point to point link?
Callback< bool, Ptr< NetDevice >, Ptr< const Packet >, uint16_t, const Address &, const Address &, enum PacketType > PromiscReceiveCallback
bool m_isMulticast
Flag indicating whether or not the underlying net device supports multicast.
virtual void SetAddress(Address address)
Set the address of this interface.
A class which provides a relatively platform-independent Mutual Exclusion thread synchronization prim...
virtual bool IsLinkUp(void) const
void SetDataRate(DataRate bps)
Set the Data Rate used for transmission of packets.
TracedCallback< Ptr< const Packet > > m_phyRxEndTrace
The trace source fired when a packet begins the reception process from the medium.
uint32_t m_pendingReadCount
Describes an IPv6 address.
Ipv4 addresses are stored in host order in this class.
Time m_tStart
Time to start spinning up the device.
int32_t m_sll_ifindex
The Unix interface index that we got from the system and which corresponds to the interface (e...
TracedCallback< Ptr< const Packet > > m_macTxTrace
The trace source fired when packets come into the "top" of the device at the L3/L2 transition...
uint32_t m_maxPendingReads
an identifier for simulation events.
Time m_tStop
Time to start tearing down the device.
Network layer to device interface.
void AddHeader(Ptr< Packet > p, uint16_t protocolNumber)
Adds the necessary headers and trailers to a packet of data in order to respect the protocol implemen...
void CreateSocket(void)
Call out to a separate process running as suid root in order to get a raw socket. ...
virtual Address GetMulticast(Ipv4Address multicastGroup) const
Make and return a MAC multicast address using the provided multicast group.
virtual void DoDispose(void)
This method is called by Object::Dispose or by the object's destructor, whichever comes first...
Encapsulation mode not set.
DIX II / Ethernet II packet.
virtual void AddLinkChangeCallback(Callback< void > callback)
A Device for an Emu Network Link.
EncapsulationMode m_encapMode
The type of packet that should be created by the AddHeader function and that should be processed by t...
virtual bool SetMtu(const uint16_t mtu)
a unique identifier for an interface.
virtual Address GetBroadcast(void) const
virtual bool IsMulticast(void) const
virtual bool IsBridge(void) const
Is this a bridge?
Mac48Address m_address
The MAC address which has been assigned to this device.
TracedCallback< Ptr< const Packet > > m_phyRxDropTrace
The trace source fired when the phy layer drops a packet it has received.