A Discrete-Event Network Simulator
API
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
ns3::EmuNetDevice Class Reference

A Device for an Emu Network Link. More...

#include <emu-net-device.h>

+ Inheritance diagram for ns3::EmuNetDevice:
+ Collaboration diagram for ns3::EmuNetDevice:

Public Types

enum  EncapsulationMode { ILLEGAL, DIX, LLC }
 Enumeration of the types of packets supported in the class. More...
 
- Public Types inherited from ns3::NetDevice
enum  PacketType {
  PACKET_HOST = 1, NS3_PACKET_HOST = PACKET_HOST, PACKET_BROADCAST, NS3_PACKET_BROADCAST = PACKET_BROADCAST,
  PACKET_MULTICAST, NS3_PACKET_MULTICAST = PACKET_MULTICAST, PACKET_OTHERHOST, NS3_PACKET_OTHERHOST = PACKET_OTHERHOST
}
 Packet types are used as they are in Linux. More...
 
typedef Callback< bool, Ptr
< NetDevice >, Ptr< const
Packet >, uint16_t, const
Address &, const Address
&, enum PacketType
PromiscReceiveCallback
 
typedef Callback< bool, Ptr
< NetDevice >, Ptr< const
Packet >, uint16_t, const
Address & > 
ReceiveCallback
 

Public Member Functions

 EmuNetDevice ()
 Construct a EmuNetDevice. More...
 
virtual ~EmuNetDevice ()
 Destroy a EmuNetDevice. More...
 
virtual void AddLinkChangeCallback (Callback< void > callback)
 
virtual Address GetAddress (void) const
 
virtual Address GetBroadcast (void) const
 
virtual Ptr< ChannelGetChannel (void) const
 
EmuNetDevice::EncapsulationMode GetEncapsulationMode (void) const
 Get the encapsulation mode of this device. More...
 
virtual uint32_t GetIfIndex (void) const
 
virtual uint16_t GetMtu (void) const
 
virtual Address GetMulticast (Ipv4Address multicastGroup) const
 Make and return a MAC multicast address using the provided multicast group. More...
 
virtual Address GetMulticast (Ipv6Address addr) const
 Get the MAC multicast address corresponding to the IPv6 address provided. More...
 
virtual Ptr< NodeGetNode (void) const
 
Ptr< QueueGetQueue (void) const
 Get a copy of the attached Queue. More...
 
virtual bool IsBridge (void) const
 Is this a bridge? More...
 
virtual bool IsBroadcast (void) const
 
virtual bool IsLinkUp (void) const
 
virtual bool IsMulticast (void) const
 
virtual bool IsPointToPoint (void) const
 Is this a point to point link? More...
 
virtual bool NeedsArp (void) const
 
virtual bool Send (Ptr< Packet > packet, const Address &dest, uint16_t protocolNumber)
 
virtual bool SendFrom (Ptr< Packet > packet, const Address &source, const Address &dest, uint16_t protocolNumber)
 
virtual void SetAddress (Address address)
 Set the address of this interface. More...
 
void SetDataRate (DataRate bps)
 Set the Data Rate used for transmission of packets. More...
 
void SetEncapsulationMode (EmuNetDevice::EncapsulationMode mode)
 Set the encapsulation mode of this device. More...
 
virtual void SetIfIndex (const uint32_t index)
 
virtual bool SetMtu (const uint16_t mtu)
 
virtual void SetNode (Ptr< Node > node)
 
virtual void SetPromiscReceiveCallback (PromiscReceiveCallback cb)
 
void SetQueue (Ptr< Queue > queue)
 Attach a queue to the EmuNetDevice. More...
 
virtual void SetReceiveCallback (NetDevice::ReceiveCallback cb)
 
void Start (Time tStart)
 Set a start time for the device. More...
 
void Stop (Time tStop)
 Set a stop time for the device. More...
 
virtual bool SupportsSendFrom (void) const
 
- Public Member Functions inherited from ns3::NetDevice
virtual ~NetDevice ()
 
- Public Member Functions inherited from ns3::Object
 Object ()
 
virtual ~Object ()
 
void AggregateObject (Ptr< Object > other)
 
void Dispose (void)
 Run the DoDispose methods of this object and all the objects aggregated to it. More...
 
AggregateIterator GetAggregateIterator (void) const
 
virtual TypeId GetInstanceTypeId (void) const
 
template<typename T >
Ptr< T > GetObject (void) const
 
template<typename T >
Ptr< T > GetObject (TypeId tid) const
 
void Initialize (void)
 This method calls the virtual DoInitialize method on all the objects aggregated to this object. More...
 
- Public Member Functions inherited from ns3::SimpleRefCount< Object, ObjectBase, ObjectDeleter >
 SimpleRefCount ()
 Constructor. More...
 
 SimpleRefCount (const SimpleRefCount &o)
 Copy constructor. More...
 
uint32_t GetReferenceCount (void) const
 Get the reference count of the object. More...
 
SimpleRefCountoperator= (const SimpleRefCount &o)
 Assignment. More...
 
void Ref (void) const
 Increment the reference count. More...
 
void Unref (void) const
 Decrement the reference count. More...
 
- Public Member Functions inherited from ns3::ObjectBase
virtual ~ObjectBase ()
 Virtual destructor. More...
 
void GetAttribute (std::string name, AttributeValue &value) const
 
bool GetAttributeFailSafe (std::string name, AttributeValue &attribute) const
 
void SetAttribute (std::string name, const AttributeValue &value)
 
bool SetAttributeFailSafe (std::string name, const AttributeValue &value)
 
bool TraceConnect (std::string name, std::string context, const CallbackBase &cb)
 
bool TraceConnectWithoutContext (std::string name, const CallbackBase &cb)
 
bool TraceDisconnect (std::string name, std::string context, const CallbackBase &cb)
 
bool TraceDisconnectWithoutContext (std::string name, const CallbackBase &cb)
 

Static Public Member Functions

static TypeId GetTypeId (void)
 
- Static Public Member Functions inherited from ns3::NetDevice
static TypeId GetTypeId (void)
 Get the type ID. More...
 
- Static Public Member Functions inherited from ns3::Object
static TypeId GetTypeId (void)
 Register this type. More...
 
- Static Public Member Functions inherited from ns3::SimpleRefCount< Object, ObjectBase, ObjectDeleter >
static void Cleanup (void)
 Noop. More...
 
- Static Public Member Functions inherited from ns3::ObjectBase
static TypeId GetTypeId (void)
 Get the type ID. More...
 

Private Member Functions

 EmuNetDevice (const EmuNetDevice &)
 
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 implemented by the agent. More...
 
void CreateSocket (void)
 Call out to a separate process running as suid root in order to get a raw socket. More...
 
virtual void DoDispose (void)
 This method is called by Object::Dispose or by the object's destructor, whichever comes first. More...
 
std::string FindCreator (std::string creatorName)
 Figure out where the raw socket creation process lives on the system. More...
 
void ForwardUp (uint8_t *buf, uint32_t len)
 Method to handle received packets. More...
 
void NotifyLinkUp (void)
 
EmuNetDeviceoperator= (const EmuNetDevice &)
 
bool ProcessHeader (Ptr< Packet > p, uint16_t &param)
 Removes, from a packet of data, all headers and trailers that relate to the protocol implemented by the agent. More...
 
void ReadThread (void)
 Loop to read and process packets. More...
 
void StartDevice (void)
 Spin up the device. More...
 
void StopDevice (void)
 Tear down the device. More...
 
bool TransmitStart (Ptr< Packet > p)
 Start Sending a Packet Down the Wire. More...
 

Private Attributes

Mac48Address m_address
 The MAC address which has been assigned to this device. More...
 
std::string m_deviceName
 The unix/linux name of the underlying device (e.g., eth0) More...
 
EncapsulationMode m_encapMode
 The type of packet that should be created by the AddHeader function and that should be processed by the ProcessHeader function. More...
 
uint32_t m_ifIndex
 The ns-3 interface index (in the sense of net device index) that has been assigned to this network device. More...
 
bool m_isBroadcast
 Flag indicating whether or not the underlying net device supports broadcast. More...
 
bool m_isMulticast
 Flag indicating whether or not the underlying net device supports multicast. More...
 
TracedCallback m_linkChangeCallbacks
 Callbacks to fire if the link changes state (up or down). More...
 
bool m_linkUp
 Flag indicating whether or not the link is up. More...
 
TracedCallback< Ptr< const
Packet > > 
m_macPromiscRxTrace
 The trace source fired for packets successfully received by the device immediately before being forwarded up to higher layers (at the L2/L3 transition). More...
 
TracedCallback< Ptr< const
Packet > > 
m_macRxDropTrace
 The trace source fired for packets successfully received by the device but which are dropped before being forwarded up to higher layers (at the L2/L3 transition). More...
 
TracedCallback< Ptr< const
Packet > > 
m_macRxTrace
 The trace source fired for packets successfully received by the device immediately before being forwarded up to higher layers (at the L2/L3 transition). More...
 
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 dropped before being queued for transmission. More...
 
TracedCallback< Ptr< const
Packet > > 
m_macTxTrace
 The trace source fired when packets come into the "top" of the device at the L3/L2 transition, before being queued for transmission. More...
 
uint32_t m_maxPendingReads
 
Ptr< Nodem_node
 The Node to which this device is attached. More...
 
uint32_t m_nodeId
 
uint8_t * m_packetBuffer
 A 64K buffer to hold packet data while it is being sent. More...
 
uint32_t m_pendingReadCount
 
SystemMutex m_pendingReadMutex
 
TracedCallback< Ptr< const
Packet > > 
m_phyRxBeginTrace
 The trace source fired when a packet begins the reception process from the medium. More...
 
TracedCallback< Ptr< const
Packet > > 
m_phyRxDropTrace
 The trace source fired when the phy layer drops a packet it has received. More...
 
TracedCallback< Ptr< const
Packet > > 
m_phyRxEndTrace
 The trace source fired when a packet begins the reception process from the medium. More...
 
TracedCallback< Ptr< const
Packet > > 
m_phyRxTrace
 The trace source fired when a packet ends the reception process from the medium. More...
 
TracedCallback< Ptr< const
Packet > > 
m_phyTxBeginTrace
 The trace source fired when a packet begins the transmission process on the medium. More...
 
TracedCallback< Ptr< const
Packet > > 
m_phyTxDropTrace
 The trace source fired when the phy layer drops a packet as it tries to transmit it. More...
 
TracedCallback< Ptr< const
Packet > > 
m_phyTxEndTrace
 The trace source fired when a packet ends the transmission process on the medium. More...
 
NetDevice::PromiscReceiveCallback m_promiscRxCallback
 The callback used to notify higher layers that a packet has been received in promiscuous mode. More...
 
TracedCallback< Ptr< const
Packet > > 
m_promiscSnifferTrace
 A trace source that emulates a promiscuous mode protocol sniffer connected to the device. More...
 
Ptr< Queuem_queue
 The Queue which this EmuNetDevice uses as a packet source. More...
 
Ptr< SystemThreadm_readThread
 
NetDevice::ReceiveCallback m_rxCallback
 The callback used to notify higher layers that a packet has been received. More...
 
int32_t m_sll_ifindex
 The Unix interface index that we got from the system and which corresponds to the interface (e.g., "eth1") we are using to talk to the network. More...
 
TracedCallback< Ptr< const
Packet > > 
m_snifferTrace
 A trace source that emulates a non-promiscuous protocol sniffer connected to the device. More...
 
int32_t m_sock
 
EventId m_startEvent
 
EventId m_stopEvent
 
Time m_tStart
 Time to start spinning up the device. More...
 
Time m_tStop
 Time to start tearing down the device. More...
 

Additional Inherited Members

- Protected Member Functions inherited from ns3::Object
 Object (const Object &o)
 
virtual void DoInitialize (void)
 This method is called only once by Object::Initialize. More...
 
virtual void NotifyNewAggregate (void)
 This method is invoked whenever two sets of objects are aggregated together. More...
 
- Protected Member Functions inherited from ns3::ObjectBase
void ConstructSelf (const AttributeConstructionList &attributes)
 
virtual void NotifyConstructionCompleted (void)
 This method is invoked once all member attributes have been initialized. More...
 

Detailed Description

A Device for an Emu Network Link.

Config Paths

ns3::EmuNetDevice is accessible through the following paths with Config::Set and Config::Connect:

  • /NodeList/[i]/DeviceList/[i]/$ns3::EmuNetDevice

Attributes

  • Mtu: The MAC-level Maximum Transmission Unit
  • Address: The ns-3 MAC address of this (virtual) device.
  • DeviceName: The name of the underlying real device (e.g. eth1).
    • Set with class: StringValue
    • Underlying type:
    • Initial value: eth1
    • Flags: construct write read
  • Start: The simulation time at which to spin up the device thread.
    • Set with class: ns3::TimeValue
    • Underlying type: Time –9223372036854775808.0ns:+9223372036854775807.0ns
    • Initial value: +0.0ns
    • Flags: construct write read
  • Stop: The simulation time at which to tear down the device thread.
    • Set with class: ns3::TimeValue
    • Underlying type: Time –9223372036854775808.0ns:+9223372036854775807.0ns
    • Initial value: +0.0ns
    • Flags: construct write read
  • EncapsulationMode: The link-layer encapsulation type to use.
    • Set with class: ns3::EnumValue
    • Underlying type:
    • Initial value: Dix
    • Flags: construct write
  • TxQueue: A queue to use as the transmit queue in the device.
  • RxQueueSize: Maximum size of the read queue. This value limits number of packets that have been read from the network into a memory buffer but have not yet been processed by the simulator.

TraceSources

  • MacTx: Trace source indicating a packet has arrived for transmission by this device
  • MacTxDrop: Trace source indicating a packet has been dropped by the device before transmission
  • MacPromiscRx: A packet has been received by this device, has been passed up from the physical layer and is being forwarded up the local protocol stack. This is a promiscuous trace,
  • MacRx: A packet has been received by this device, has been passed up from the physical layer and is being forwarded up the local protocol stack. This is a non-promiscuous trace,
  • Sniffer: Trace source simulating a non-promiscuous packet sniffer attached to the device
  • PromiscSniffer: Trace source simulating a promiscuous packet sniffer attached to the device

Definition at line 52 of file emu-net-device.h.

Member Enumeration Documentation

Enumeration of the types of packets supported in the class.

Enumerator
ILLEGAL 

Encapsulation mode not set.

DIX 

DIX II / Ethernet II packet.

LLC 

802.2 LLC/SNAP Packet

Definition at line 60 of file emu-net-device.h.

Constructor & Destructor Documentation

ns3::EmuNetDevice::EmuNetDevice ( )

Construct a EmuNetDevice.

This is the constructor for the EmuNetDevice. It takes as a

Definition at line 188 of file emu-net-device.cc.

References m_packetBuffer, m_tStart, NS_LOG_FUNCTION, and Start().

+ Here is the call graph for this function:

ns3::EmuNetDevice::~EmuNetDevice ( )
virtual

Destroy a EmuNetDevice.

This is the destructor for the EmuNetDevice.

Definition at line 205 of file emu-net-device.cc.

References m_packetBuffer.

ns3::EmuNetDevice::EmuNetDevice ( const EmuNetDevice )
private

Member Function Documentation

void ns3::EmuNetDevice::AddHeader ( Ptr< Packet p,
uint16_t  protocolNumber 
)
private

Adds the necessary headers and trailers to a packet of data in order to respect the protocol implemented by the agent.

Parameters
ppacket
protocolNumberprotocol number
void ns3::EmuNetDevice::AddLinkChangeCallback ( Callback< void >  callback)
virtual
Parameters
callbackthe callback to invoke

Add a callback invoked whenever the link status changes to UP. This callback is typically used by the IP/ARP layer to flush the ARP cache and by IPv6 stack to flush NDISC cache whenever the link goes up.

Implements ns3::NetDevice.

Definition at line 1015 of file emu-net-device.cc.

References ns3::TracedCallback< T1, T2, T3, T4, T5, T6, T7, T8 >::ConnectWithoutContext(), and m_linkChangeCallbacks.

+ Here is the call graph for this function:

void ns3::EmuNetDevice::CreateSocket ( void  )
private

Call out to a separate process running as suid root in order to get a raw socket.

We do this to avoid having the entire simulation running as root. If this method returns, we'll have a raw socket waiting for us in m_sock.

Definition at line 380 of file emu-net-device.cc.

References EMU_MAGIC, ns3::EmuBufferToString(), m_sock, NS_ASSERT_MSG, NS_FATAL_ERROR, NS_LOG_DEBUG, NS_LOG_FUNCTION_NOARGS, and NS_LOG_INFO.

Referenced by StartDevice().

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void ns3::EmuNetDevice::DoDispose ( void  )
privatevirtual

This method is called by Object::Dispose or by the object's destructor, whichever comes first.

Subclasses are expected to implement their real destruction code in an overriden version of this method and chain up to their parent's implementation once they are done. i.e., for simplicity, the destructor of every subclass should be empty and its content should be moved to the associated DoDispose method.

It is safe to call GetObject from within this method.

Reimplemented from ns3::Object.

Definition at line 212 of file emu-net-device.cc.

References ns3::Object::DoDispose(), m_node, m_readThread, NS_LOG_FUNCTION_NOARGS, and StopDevice().

+ Here is the call graph for this function:

std::string ns3::EmuNetDevice::FindCreator ( std::string  creatorName)
private

Figure out where the raw socket creation process lives on the system.

Address ns3::EmuNetDevice::GetAddress ( void  ) const
virtual
Returns
the current Address of this interface.

Implements ns3::NetDevice.

Definition at line 974 of file emu-net-device.cc.

References m_address, and NS_LOG_FUNCTION_NOARGS.

Address ns3::EmuNetDevice::GetBroadcast ( void  ) const
virtual
Returns
the broadcast address supported by this netdevice.

Calling this method is invalid if IsBroadcast returns not true.

Implements ns3::NetDevice.

Definition at line 1027 of file emu-net-device.cc.

Ptr< Channel > ns3::EmuNetDevice::GetChannel ( void  ) const
virtual
Returns
the channel this NetDevice is connected to. The value returned can be zero if the NetDevice is not yet connected to any channel or if the underlying NetDevice has no concept of a channel. i.e., callers must check for zero and be ready to handle it.

Implements ns3::NetDevice.

Definition at line 960 of file emu-net-device.cc.

References NS_FATAL_ERROR.

EmuNetDevice::EncapsulationMode ns3::EmuNetDevice::GetEncapsulationMode ( void  ) const

Get the encapsulation mode of this device.

Returns
The encapsulation mode of this device.

Definition at line 232 of file emu-net-device.cc.

References m_encapMode, and NS_LOG_FUNCTION_NOARGS.

uint32_t ns3::EmuNetDevice::GetIfIndex ( void  ) const
virtual
Returns
index ifIndex of the device

Implements ns3::NetDevice.

Definition at line 954 of file emu-net-device.cc.

References m_ifIndex.

uint16_t ns3::EmuNetDevice::GetMtu ( void  ) const
virtual
Returns
the link-level MTU in bytes for this interface.

This value is typically used by the IP layer to perform IP fragmentation when needed.

Implements ns3::NetDevice.

Definition at line 988 of file emu-net-device.cc.

References m_deviceName, and NS_FATAL_ERROR.

Referenced by GetTypeId().

+ Here is the caller graph for this function:

Address ns3::EmuNetDevice::GetMulticast ( Ipv4Address  multicastGroup) const
virtual

Make and return a MAC multicast address using the provided multicast group.

RFC 1112 says that an Ipv4 host group address is mapped to an Ethernet multicast address by placing the low-order 23-bits of the IP address into the low-order 23 bits of the Ethernet multicast address 01-00-5E-00-00-00 (hex).

This method performs the multicast address creation function appropriate to an EUI-48-based CSMA device. This MAC address is encapsulated in an abstract Address to avoid dependencies on the exact address format.

Parameters
multicastGroupThe IP address for the multicast group destination of the packet.
Returns
The MAC multicast Address used to send packets to the provided multicast group.
See also
Ipv4Address
Mac48Address
Address

Implements ns3::NetDevice.

Definition at line 1039 of file emu-net-device.cc.

References ns3::Mac48Address::GetMulticast(), NS_LOG_FUNCTION, and NS_LOG_LOGIC.

+ Here is the call graph for this function:

Address ns3::EmuNetDevice::GetMulticast ( Ipv6Address  addr) const
virtual

Get the MAC multicast address corresponding to the IPv6 address provided.

Parameters
addrIPv6 address
Returns
the MAC multicast address
Warning
Calling this method is invalid if IsMulticast returns not true.

Implements ns3::NetDevice.

Definition at line 1056 of file emu-net-device.cc.

References ns3::Mac48Address::GetMulticast(), NS_LOG_FUNCTION, and NS_LOG_LOGIC.

+ Here is the call graph for this function:

Ptr< Node > ns3::EmuNetDevice::GetNode ( void  ) const
virtual
Returns
the node base class which contains this network interface.

When a subclass needs to get access to the underlying node base class to print the nodeid for example, it can invoke this method.

Implements ns3::NetDevice.

Definition at line 1093 of file emu-net-device.cc.

References m_node.

Referenced by StartDevice().

+ Here is the caller graph for this function:

Ptr< Queue > ns3::EmuNetDevice::GetQueue ( void  ) const

Get a copy of the attached Queue.

Returns
Ptr to the queue.

Definition at line 934 of file emu-net-device.cc.

References m_queue, and NS_LOG_FUNCTION_NOARGS.

Referenced by ns3::EmuHelper::EnableAsciiInternal().

+ Here is the caller graph for this function:

bool ns3::EmuNetDevice::IsBridge ( void  ) const
virtual

Is this a bridge?

Returns
false.

Implements ns3::NetDevice.

Definition at line 1073 of file emu-net-device.cc.

bool ns3::EmuNetDevice::IsBroadcast ( void  ) const
virtual
Returns
true if this interface supports a broadcast address, false otherwise.

Implements ns3::NetDevice.

Definition at line 1021 of file emu-net-device.cc.

References m_isBroadcast.

bool ns3::EmuNetDevice::IsLinkUp ( void  ) const
virtual
Returns
true if link is up; false otherwise

Implements ns3::NetDevice.

Definition at line 1009 of file emu-net-device.cc.

References m_linkUp.

Referenced by SendFrom().

+ Here is the caller graph for this function:

bool ns3::EmuNetDevice::IsMulticast ( void  ) const
virtual
Returns
value of m_isMulticast flag

Implements ns3::NetDevice.

Definition at line 1033 of file emu-net-device.cc.

References m_isMulticast.

bool ns3::EmuNetDevice::IsPointToPoint ( void  ) const
virtual

Is this a point to point link?

Returns
false.

Implements ns3::NetDevice.

Definition at line 1067 of file emu-net-device.cc.

bool ns3::EmuNetDevice::NeedsArp ( void  ) const
virtual
Returns
true if ARP is needed, false otherwise.

Called by higher-layers to check if this NetDevice requires ARP to be used.

Implements ns3::NetDevice.

Definition at line 1105 of file emu-net-device.cc.

void ns3::EmuNetDevice::NotifyLinkUp ( void  )
private

Definition at line 941 of file emu-net-device.cc.

References m_linkChangeCallbacks, and m_linkUp.

Referenced by StartDevice().

+ Here is the caller graph for this function:

EmuNetDevice& ns3::EmuNetDevice::operator= ( const EmuNetDevice )
private
bool ns3::EmuNetDevice::ProcessHeader ( Ptr< Packet p,
uint16_t &  param 
)
private

Removes, from a packet of data, all headers and trailers that relate to the protocol implemented by the agent.

Parameters
pPacket whose headers need to be processed
paramAn integer parameter that can be set by the function
Returns
Returns true if the packet should be forwarded up the protocol stack.
void ns3::EmuNetDevice::ReadThread ( void  )
private

Loop to read and process packets.

Definition at line 743 of file emu-net-device.cc.

References ForwardUp(), m_maxPendingReads, m_nodeId, m_pendingReadCount, m_pendingReadMutex, m_sock, ns3::MakeEvent(), NS_FATAL_ERROR, NS_LOG_FUNCTION_NOARGS, NS_LOG_INFO, NS_LOG_LOGIC, and ns3::Simulator::ScheduleWithContext().

Referenced by StartDevice().

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

bool ns3::EmuNetDevice::Send ( Ptr< Packet packet,
const Address dest,
uint16_t  protocolNumber 
)
virtual
Parameters
packetpacket sent from above down to Network Device
destmac address of the destination (already resolved)
protocolNumberidentifies the type of payload contained in this packet. Used to call the right L3Protocol when the packet is received.

Called from higher layer to send packet into Network Device to the specified destination Address

Returns
whether the Send operation succeeded

Implements ns3::NetDevice.

Definition at line 813 of file emu-net-device.cc.

References m_address, NS_LOG_FUNCTION, and SendFrom().

+ Here is the call graph for this function:

bool ns3::EmuNetDevice::SendFrom ( Ptr< Packet packet,
const Address source,
const Address dest,
uint16_t  protocolNumber 
)
virtual
Parameters
packetpacket sent from above down to Network Device
sourcesource mac address (so called "MAC spoofing")
destmac address of the destination (already resolved)
protocolNumberidentifies the type of payload contained in this packet. Used to call the right L3Protocol when the packet is received.

Called from higher layer to send packet into Network Device with the specified source and destination Addresses.

Returns
whether the Send operation succeeded

Implements ns3::NetDevice.

Definition at line 839 of file emu-net-device.cc.

References ns3::Packet::AddHeader(), ns3::Mac48Address::ConvertFrom(), ns3::Packet::CopyData(), DIX, ns3::Packet::GetSize(), ns3::Packet::GetUid(), IsLinkUp(), LLC, m_encapMode, m_macTxDropTrace, m_macTxTrace, m_packetBuffer, m_promiscSnifferTrace, m_queue, m_sll_ifindex, m_snifferTrace, m_sock, NS_ASSERT_MSG, NS_FATAL_ERROR, NS_LOG_FUNCTION, NS_LOG_LOGIC, ns3::EthernetHeader::SetDestination(), ns3::EthernetHeader::SetLengthType(), ns3::EthernetHeader::SetSource(), and ns3::LlcSnapHeader::SetType().

Referenced by Send().

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void ns3::EmuNetDevice::SetAddress ( Address  address)
virtual

Set the address of this interface.

Parameters
addressaddress to set

Implements ns3::NetDevice.

Definition at line 967 of file emu-net-device.cc.

References ns3::Mac48Address::ConvertFrom(), m_address, and NS_LOG_FUNCTION.

+ Here is the call graph for this function:

void ns3::EmuNetDevice::SetDataRate ( DataRate  bps)

Set the Data Rate used for transmission of packets.

See also
Attach ()
Parameters
bpsthe data rate at which this object operates

Definition at line 920 of file emu-net-device.cc.

References NS_FATAL_ERROR, and NS_LOG_FUNCTION.

void ns3::EmuNetDevice::SetEncapsulationMode ( EmuNetDevice::EncapsulationMode  mode)

Set the encapsulation mode of this device.

Parameters
modeThe encapsulation mode of this device.
See also
SetFrameSize

Definition at line 224 of file emu-net-device.cc.

References m_encapMode, NS_LOG_FUNCTION, and NS_LOG_LOGIC.

Referenced by GetTypeId().

+ Here is the caller graph for this function:

void ns3::EmuNetDevice::SetIfIndex ( const uint32_t  index)
virtual
Parameters
indexifIndex of the device

Implements ns3::NetDevice.

Definition at line 948 of file emu-net-device.cc.

References m_ifIndex.

bool ns3::EmuNetDevice::SetMtu ( const uint16_t  mtu)
virtual
Parameters
mtuMTU value, in bytes, to set for the device
Returns
whether the MTU value was within legal bounds

Override for default MTU defined on a per-type basis.

Implements ns3::NetDevice.

Definition at line 981 of file emu-net-device.cc.

References NS_FATAL_ERROR.

void ns3::EmuNetDevice::SetNode ( Ptr< Node node)
virtual
Parameters
nodethe node associated to this netdevice.

This method is called from ns3::Node::AddDevice.

Implements ns3::NetDevice.

Definition at line 1099 of file emu-net-device.cc.

References m_node.

void ns3::EmuNetDevice::SetPromiscReceiveCallback ( PromiscReceiveCallback  cb)
virtual
Parameters
cbcallback to invoke whenever a packet has been received in promiscuous mode and must be forwarded to the higher layers.

Enables netdevice promiscuous mode and sets the callback that will handle promiscuous mode packets. Note, promiscuous mode packets means all packets, including those packets that can be sensed by the netdevice but which are intended to be received by other hosts.

Implements ns3::NetDevice.

Definition at line 1079 of file emu-net-device.cc.

References m_promiscRxCallback.

void ns3::EmuNetDevice::SetQueue ( Ptr< Queue queue)

Attach a queue to the EmuNetDevice.

The EmuNetDevice "owns" a queue that implements a queueing method such as DropTail or RED.

See also
Queue
DropTailQueue
Parameters
queuePtr to the new queue.

Definition at line 927 of file emu-net-device.cc.

References m_queue, and NS_LOG_FUNCTION.

Referenced by main().

+ Here is the caller graph for this function:

void ns3::EmuNetDevice::SetReceiveCallback ( NetDevice::ReceiveCallback  cb)
virtual
Parameters
cbcallback to invoke whenever a packet has been received and must be forwarded to the higher layers.

Implements ns3::NetDevice.

Definition at line 1111 of file emu-net-device.cc.

References m_rxCallback.

void ns3::EmuNetDevice::Start ( Time  tStart)

Set a start time for the device.

Parameters
tStartthe start time

Definition at line 239 of file emu-net-device.cc.

References ns3::Simulator::Cancel(), m_startEvent, NS_LOG_FUNCTION, ns3::Simulator::Schedule(), and StartDevice().

Referenced by EmuNetDevice().

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void ns3::EmuNetDevice::StartDevice ( void  )
private

Spin up the device.

Definition at line 262 of file emu-net-device.cc.

References CreateSocket(), ns3::Node::GetId(), GetNode(), m_deviceName, m_isBroadcast, m_isMulticast, m_nodeId, m_readThread, m_sll_ifindex, m_sock, ns3::MakeCallback(), NotifyLinkUp(), NS_FATAL_ERROR, NS_LOG_FUNCTION_NOARGS, NS_LOG_LOGIC, and ReadThread().

Referenced by Start().

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void ns3::EmuNetDevice::Stop ( Time  tStop)

Set a stop time for the device.

Parameters
tStopthe stop time

Definition at line 251 of file emu-net-device.cc.

References ns3::Simulator::Cancel(), m_startEvent, m_stopEvent, NS_LOG_FUNCTION, ns3::Simulator::Schedule(), and StopDevice().

+ Here is the call graph for this function:

void ns3::EmuNetDevice::StopDevice ( void  )
private

Tear down the device.

Definition at line 598 of file emu-net-device.cc.

References m_readThread, m_sock, NS_ASSERT_MSG, NS_LOG_FUNCTION_NOARGS, and NS_LOG_LOGIC.

Referenced by DoDispose(), and Stop().

+ Here is the caller graph for this function:

bool ns3::EmuNetDevice::SupportsSendFrom ( void  ) const
virtual
Returns
true if this interface supports a bridging mode, false otherwise.

Implements ns3::NetDevice.

Definition at line 1085 of file emu-net-device.cc.

References NS_LOG_FUNCTION_NOARGS.

bool ns3::EmuNetDevice::TransmitStart ( Ptr< Packet p)
private

Start Sending a Packet Down the Wire.

Parameters
ppacket to send
Returns
true if success, false on failure

Member Data Documentation

Mac48Address ns3::EmuNetDevice::m_address
private

The MAC address which has been assigned to this device.

Definition at line 457 of file emu-net-device.h.

Referenced by ForwardUp(), GetAddress(), GetTypeId(), Send(), and SetAddress().

std::string ns3::EmuNetDevice::m_deviceName
private

The unix/linux name of the underlying device (e.g., eth0)

Definition at line 513 of file emu-net-device.h.

Referenced by GetMtu(), GetTypeId(), and StartDevice().

EncapsulationMode ns3::EmuNetDevice::m_encapMode
private

The type of packet that should be created by the AddHeader function and that should be processed by the ProcessHeader function.

Definition at line 485 of file emu-net-device.h.

Referenced by ForwardUp(), GetEncapsulationMode(), SendFrom(), and SetEncapsulationMode().

uint32_t ns3::EmuNetDevice::m_ifIndex
private

The ns-3 interface index (in the sense of net device index) that has been assigned to this network device.

Definition at line 472 of file emu-net-device.h.

Referenced by GetIfIndex(), and SetIfIndex().

bool ns3::EmuNetDevice::m_isBroadcast
private

Flag indicating whether or not the underlying net device supports broadcast.

Definition at line 497 of file emu-net-device.h.

Referenced by IsBroadcast(), and StartDevice().

bool ns3::EmuNetDevice::m_isMulticast
private

Flag indicating whether or not the underlying net device supports multicast.

Definition at line 503 of file emu-net-device.h.

Referenced by IsMulticast(), and StartDevice().

TracedCallback ns3::EmuNetDevice::m_linkChangeCallbacks
private

Callbacks to fire if the link changes state (up or down).

Definition at line 508 of file emu-net-device.h.

Referenced by AddLinkChangeCallback(), and NotifyLinkUp().

bool ns3::EmuNetDevice::m_linkUp
private

Flag indicating whether or not the link is up.

In this case, whether or not the device is connected to a channel.

Definition at line 491 of file emu-net-device.h.

Referenced by IsLinkUp(), and NotifyLinkUp().

TracedCallback<Ptr<const Packet> > ns3::EmuNetDevice::m_macPromiscRxTrace
private

The trace source fired for packets successfully received by the device immediately before being forwarded up to higher layers (at the L2/L3 transition).

This is a promiscuous trace.

See also
class CallBackTraceSource

Definition at line 317 of file emu-net-device.h.

Referenced by ForwardUp(), and GetTypeId().

TracedCallback<Ptr<const Packet> > ns3::EmuNetDevice::m_macRxDropTrace
private

The trace source fired for packets successfully received by the device but which are dropped before being forwarded up to higher layers (at the L2/L3 transition).

See also
class CallBackTraceSource

Definition at line 335 of file emu-net-device.h.

Referenced by GetTypeId().

TracedCallback<Ptr<const Packet> > ns3::EmuNetDevice::m_macRxTrace
private

The trace source fired for packets successfully received by the device immediately before being forwarded up to higher layers (at the L2/L3 transition).

This is a non-promiscuous trace.

See also
class CallBackTraceSource

Definition at line 326 of file emu-net-device.h.

Referenced by ForwardUp(), and GetTypeId().

TracedCallback<Ptr<const Packet> > ns3::EmuNetDevice::m_macTxDropTrace
private

The trace source fired when packets coming into the "top" of the device at the L3/L2 transition are dropped before being queued for transmission.

See also
class CallBackTraceSource

Definition at line 308 of file emu-net-device.h.

Referenced by GetTypeId(), and SendFrom().

TracedCallback<Ptr<const Packet> > ns3::EmuNetDevice::m_macTxTrace
private

The trace source fired when packets come into the "top" of the device at the L3/L2 transition, before being queued for transmission.

See also
class CallBackTraceSource

Definition at line 300 of file emu-net-device.h.

Referenced by GetTypeId(), and SendFrom().

uint32_t ns3::EmuNetDevice::m_maxPendingReads
private

Definition at line 527 of file emu-net-device.h.

Referenced by GetTypeId(), and ReadThread().

Ptr<Node> ns3::EmuNetDevice::m_node
private

The Node to which this device is attached.

Definition at line 452 of file emu-net-device.h.

Referenced by DoDispose(), GetNode(), and SetNode().

uint32_t ns3::EmuNetDevice::m_nodeId
private

Definition at line 525 of file emu-net-device.h.

Referenced by ReadThread(), and StartDevice().

uint8_t* ns3::EmuNetDevice::m_packetBuffer
private

A 64K buffer to hold packet data while it is being sent.

Definition at line 518 of file emu-net-device.h.

Referenced by EmuNetDevice(), SendFrom(), and ~EmuNetDevice().

uint32_t ns3::EmuNetDevice::m_pendingReadCount
private

Definition at line 528 of file emu-net-device.h.

Referenced by ForwardUp(), and ReadThread().

SystemMutex ns3::EmuNetDevice::m_pendingReadMutex
private

Definition at line 529 of file emu-net-device.h.

Referenced by ForwardUp(), and ReadThread().

TracedCallback<Ptr<const Packet> > ns3::EmuNetDevice::m_phyRxBeginTrace
private

The trace source fired when a packet begins the reception process from the medium.

See also
class CallBackTraceSource

Definition at line 375 of file emu-net-device.h.

Referenced by GetTypeId().

TracedCallback<Ptr<const Packet> > ns3::EmuNetDevice::m_phyRxDropTrace
private

The trace source fired when the phy layer drops a packet it has received.

See also
class CallBackTraceSource

Definition at line 390 of file emu-net-device.h.

Referenced by ForwardUp(), and GetTypeId().

TracedCallback<Ptr<const Packet> > ns3::EmuNetDevice::m_phyRxEndTrace
private

The trace source fired when a packet begins the reception process from the medium.

See also
class CallBackTraceSource

Definition at line 383 of file emu-net-device.h.

Referenced by GetTypeId().

TracedCallback<Ptr<const Packet> > ns3::EmuNetDevice::m_phyRxTrace
private

The trace source fired when a packet ends the reception process from the medium.

See also
class CallBackTraceSource

Definition at line 367 of file emu-net-device.h.

TracedCallback<Ptr<const Packet> > ns3::EmuNetDevice::m_phyTxBeginTrace
private

The trace source fired when a packet begins the transmission process on the medium.

See also
class CallBackTraceSource

Definition at line 343 of file emu-net-device.h.

Referenced by GetTypeId().

TracedCallback<Ptr<const Packet> > ns3::EmuNetDevice::m_phyTxDropTrace
private

The trace source fired when the phy layer drops a packet as it tries to transmit it.

See also
class CallBackTraceSource

Definition at line 359 of file emu-net-device.h.

Referenced by GetTypeId().

TracedCallback<Ptr<const Packet> > ns3::EmuNetDevice::m_phyTxEndTrace
private

The trace source fired when a packet ends the transmission process on the medium.

See also
class CallBackTraceSource

Definition at line 351 of file emu-net-device.h.

Referenced by GetTypeId().

NetDevice::PromiscReceiveCallback ns3::EmuNetDevice::m_promiscRxCallback
private

The callback used to notify higher layers that a packet has been received in promiscuous mode.

Definition at line 467 of file emu-net-device.h.

Referenced by ForwardUp(), and SetPromiscReceiveCallback().

TracedCallback<Ptr<const Packet> > ns3::EmuNetDevice::m_promiscSnifferTrace
private

A trace source that emulates a promiscuous mode protocol sniffer connected to the device.

This trace source fire on packets destined for any host just like your average everyday packet sniffer.

On the transmit size, this trace hook will fire after a packet is dequeued from the device queue for transmission. In Linux, for example, this would correspond to the point just before a device hard_start_xmit where dev_queue_xmit_nit is called to dispatch the packet to the PF_PACKET ETH_P_ALL handlers.

On the receive side, this trace hook will fire when a packet is received, just before the receive callback is executed. In Linux, for example, this would correspond to the point at which the packet is dispatched to packet sniffers in netif_receive_skb.

See also
class CallBackTraceSource

Definition at line 430 of file emu-net-device.h.

Referenced by ForwardUp(), GetTypeId(), and SendFrom().

Ptr<Queue> ns3::EmuNetDevice::m_queue
private

The Queue which this EmuNetDevice uses as a packet source.

Management of this Queue has been delegated to the EmuNetDevice and it has the responsibility for deletion.

See also
class Queue
class DropTailQueue

Definition at line 292 of file emu-net-device.h.

Referenced by GetQueue(), GetTypeId(), SendFrom(), and SetQueue().

Ptr<SystemThread> ns3::EmuNetDevice::m_readThread
private

Definition at line 447 of file emu-net-device.h.

Referenced by DoDispose(), StartDevice(), and StopDevice().

NetDevice::ReceiveCallback ns3::EmuNetDevice::m_rxCallback
private

The callback used to notify higher layers that a packet has been received.

Definition at line 462 of file emu-net-device.h.

Referenced by ForwardUp(), and SetReceiveCallback().

int32_t ns3::EmuNetDevice::m_sll_ifindex
private

The Unix interface index that we got from the system and which corresponds to the interface (e.g., "eth1") we are using to talk to the network.

Valid when m_sock is valid.

Definition at line 478 of file emu-net-device.h.

Referenced by SendFrom(), and StartDevice().

TracedCallback<Ptr<const Packet> > ns3::EmuNetDevice::m_snifferTrace
private

A trace source that emulates a non-promiscuous protocol sniffer connected to the device.

Unlike your average everyday sniffer, this trace source will not fire on PACKET_OTHERHOST events.

On the transmit size, this trace hook will fire after a packet is dequeued from the device queue for transmission. In Linux, for example, this would correspond to the point just before a device hard_start_xmit where dev_queue_xmit_nit is called to dispatch the packet to the PF_PACKET ETH_P_ALL handlers.

On the receive side, this trace hook will fire when a packet is received, just before the receive callback is executed. In Linux, for example, this would correspond to the point at which the packet is dispatched to packet sniffers in netif_receive_skb.

See also
class CallBackTraceSource

Definition at line 410 of file emu-net-device.h.

Referenced by ForwardUp(), GetTypeId(), and SendFrom().

int32_t ns3::EmuNetDevice::m_sock
private

Definition at line 445 of file emu-net-device.h.

Referenced by CreateSocket(), ReadThread(), SendFrom(), StartDevice(), and StopDevice().

EventId ns3::EmuNetDevice::m_startEvent
private

Definition at line 442 of file emu-net-device.h.

Referenced by Start(), and Stop().

EventId ns3::EmuNetDevice::m_stopEvent
private

Definition at line 443 of file emu-net-device.h.

Referenced by Stop().

Time ns3::EmuNetDevice::m_tStart
private

Time to start spinning up the device.

Definition at line 435 of file emu-net-device.h.

Referenced by EmuNetDevice(), and GetTypeId().

Time ns3::EmuNetDevice::m_tStop
private

Time to start tearing down the device.

Definition at line 440 of file emu-net-device.h.

Referenced by GetTypeId().


The documentation for this class was generated from the following files: