A Discrete-Event Network Simulator
API
Loading...
Searching...
No Matches
ns3::PointToPointNetDevice Class Reference

A Device for a Point to Point Network Link. More...

#include "point-to-point-net-device.h"

+ Inheritance diagram for ns3::PointToPointNetDevice:
+ Collaboration diagram for ns3::PointToPointNetDevice:

Public Member Functions

 PointToPointNetDevice ()
 Construct a PointToPointNetDevice.
 
 PointToPointNetDevice (const PointToPointNetDevice &)=delete
 
 ~PointToPointNetDevice () override
 Destroy a PointToPointNetDevice.
 
void AddLinkChangeCallback (Callback< void > callback) override
 
bool Attach (Ptr< PointToPointChannel > ch)
 Attach the device to a channel.
 
Address GetAddress () const override
 
Address GetBroadcast () const override
 
Ptr< ChannelGetChannel () const override
 
uint32_t GetIfIndex () const override
 
uint16_t GetMtu () const override
 
Address GetMulticast (Ipv4Address multicastGroup) const override
 Make and return a MAC multicast address using the provided multicast group.
 
Address GetMulticast (Ipv6Address addr) const override
 Get the MAC multicast address corresponding to the IPv6 address provided.
 
Ptr< NodeGetNode () const override
 
Ptr< Queue< Packet > > GetQueue () const
 Get a copy of the attached Queue.
 
bool IsBridge () const override
 Return true if the net device is acting as a bridge.
 
bool IsBroadcast () const override
 
bool IsLinkUp () const override
 
bool IsMulticast () const override
 
bool IsPointToPoint () const override
 Return true if the net device is on a point-to-point link.
 
bool NeedsArp () const override
 
PointToPointNetDeviceoperator= (const PointToPointNetDevice &)=delete
 
void Receive (Ptr< Packet > p)
 Receive a packet from a connected PointToPointChannel.
 
bool Send (Ptr< Packet > packet, const Address &dest, uint16_t protocolNumber) override
 
bool SendFrom (Ptr< Packet > packet, const Address &source, const Address &dest, uint16_t protocolNumber) override
 
void SetAddress (Address address) override
 Set the address of this interface.
 
void SetDataRate (DataRate bps)
 Set the Data Rate used for transmission of packets.
 
void SetIfIndex (const uint32_t index) override
 
void SetInterframeGap (Time t)
 Set the interframe gap used to separate packets.
 
bool SetMtu (const uint16_t mtu) override
 
void SetNode (Ptr< Node > node) override
 
void SetPromiscReceiveCallback (PromiscReceiveCallback cb) override
 
void SetQueue (Ptr< Queue< Packet > > queue)
 Attach a queue to the PointToPointNetDevice.
 
void SetReceiveCallback (NetDevice::ReceiveCallback cb) override
 
void SetReceiveErrorModel (Ptr< ErrorModel > em)
 Attach a receive ErrorModel to the PointToPointNetDevice.
 
bool SupportsSendFrom () const override
 
- Public Member Functions inherited from ns3::NetDevice
 ~NetDevice () override
 
- Public Member Functions inherited from ns3::Object
 Object ()
 Constructor.
 
 ~Object () override
 Destructor.
 
void AggregateObject (Ptr< Object > other)
 Aggregate two Objects together.
 
void Dispose ()
 Dispose of this Object.
 
AggregateIterator GetAggregateIterator () const
 Get an iterator to the Objects aggregated to this one.
 
TypeId GetInstanceTypeId () const override
 Get the most derived TypeId for this Object.
 
template<typename T >
Ptr< T > GetObject () const
 Get a pointer to the requested aggregated Object.
 
template<>
Ptr< ObjectGetObject () const
 Specialization of () for objects of type ns3::Object.
 
template<typename T >
Ptr< T > GetObject (TypeId tid) const
 Get a pointer to the requested aggregated Object by TypeId.
 
template<>
Ptr< ObjectGetObject (TypeId tid) const
 Specialization of (TypeId tid) for objects of type ns3::Object.
 
void Initialize ()
 Invoke DoInitialize on all Objects aggregated to this one.
 
bool IsInitialized () const
 Check if the object has been initialized.
 
void UnidirectionalAggregateObject (Ptr< Object > other)
 Aggregate an Object to another Object.
 
- Public Member Functions inherited from ns3::SimpleRefCount< Object, ObjectBase, ObjectDeleter >
 SimpleRefCount ()
 Default constructor.
 
 SimpleRefCount (const SimpleRefCount &o)
 Copy constructor.
 
uint32_t GetReferenceCount () const
 Get the reference count of the object.
 
SimpleRefCountoperator= (const SimpleRefCount &o)
 Assignment operator.
 
void Ref () const
 Increment the reference count.
 
void Unref () const
 Decrement the reference count.
 
- Public Member Functions inherited from ns3::ObjectBase
virtual ~ObjectBase ()
 Virtual destructor.
 
void GetAttribute (std::string name, AttributeValue &value, bool permissive=false) const
 Get the value of an attribute, raising fatal errors if unsuccessful.
 
bool GetAttributeFailSafe (std::string name, AttributeValue &value) const
 Get the value of an attribute without raising errors.
 
void SetAttribute (std::string name, const AttributeValue &value)
 Set a single attribute, raising fatal errors if unsuccessful.
 
bool SetAttributeFailSafe (std::string name, const AttributeValue &value)
 Set a single attribute without raising errors.
 
bool TraceConnect (std::string name, std::string context, const CallbackBase &cb)
 Connect a TraceSource to a Callback with a context.
 
bool TraceConnectWithoutContext (std::string name, const CallbackBase &cb)
 Connect a TraceSource to a Callback without a context.
 
bool TraceDisconnect (std::string name, std::string context, const CallbackBase &cb)
 Disconnect from a TraceSource a Callback previously connected with a context.
 
bool TraceDisconnectWithoutContext (std::string name, const CallbackBase &cb)
 Disconnect from a TraceSource a Callback previously connected without a context.
 

Static Public Member Functions

static TypeId GetTypeId ()
 Get the TypeId.
 
- Static Public Member Functions inherited from ns3::NetDevice
static TypeId GetTypeId ()
 Get the type ID.
 
- Static Public Member Functions inherited from ns3::Object
static TypeId GetTypeId ()
 Register this type.
 
- Static Public Member Functions inherited from ns3::ObjectBase
static TypeId GetTypeId ()
 Get the type ID.
 

Protected Member Functions

void DoMpiReceive (Ptr< Packet > p)
 Handler for MPI receive event.
 
- Protected Member Functions inherited from ns3::Object
 Object (const Object &o)
 Copy an Object.
 
virtual void DoInitialize ()
 Initialize() implementation.
 
virtual void NotifyNewAggregate ()
 Notify all Objects aggregated to this one of a new Object being aggregated.
 
- Protected Member Functions inherited from ns3::ObjectBase
void ConstructSelf (const AttributeConstructionList &attributes)
 Complete construction of ObjectBase; invoked by derived classes.
 
virtual void NotifyConstructionCompleted ()
 Notifier called once the ObjectBase is fully constructed.
 

Private Types

enum  TxMachineState { READY , BUSY }
 Enumeration of the states of the transmit machine of the net device. More...
 

Private Member Functions

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.
 
void DoDispose () override
 Dispose of the object.
 
Address GetRemote () const
 
void NotifyLinkUp ()
 Make the link up and running.
 
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.
 
void TransmitComplete ()
 Stop Sending a Packet Down the Wire and Begin the Interframe Gap.
 
bool TransmitStart (Ptr< Packet > p)
 Start Sending a Packet Down the Wire.
 

Static Private Member Functions

static uint16_t EtherToPpp (uint16_t protocol)
 Ethernet to PPP protocol number mapping.
 
static uint16_t PppToEther (uint16_t protocol)
 PPP to Ethernet protocol number mapping.
 

Private Attributes

Mac48Address m_address
 Mac48Address of this NetDevice.
 
DataRate m_bps
 The data rate that the Net Device uses to simulate packet transmission timing.
 
Ptr< PointToPointChannelm_channel
 The PointToPointChannel to which this PointToPointNetDevice has been attached.
 
Ptr< Packetm_currentPkt
 Current packet processed.
 
uint32_t m_ifIndex
 Index of the interface.
 
TracedCallback m_linkChangeCallbacks
 Callback for the link change event.
 
bool m_linkUp
 Identify if the link is up or not.
 
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).
 
TracedCallback< Ptr< const Packet > > m_macRxDropTrace
 The trace source fired for packets successfully received by the device but are dropped before being forwarded up to higher layers (at the L2/L3 transition).
 
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).
 
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.
 
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.
 
uint32_t m_mtu
 The Maximum Transmission Unit.
 
Ptr< Nodem_node
 Node owning this NetDevice.
 
TracedCallback< Ptr< const Packet > > m_phyRxBeginTrace
 The trace source fired when a packet begins the reception process from the medium – when the simulated first bit(s) arrive.
 
TracedCallback< Ptr< const Packet > > m_phyRxDropTrace
 The trace source fired when the phy layer drops a packet it has received.
 
TracedCallback< Ptr< const Packet > > m_phyRxEndTrace
 The trace source fired when a packet ends the reception process from the medium.
 
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_phyTxDropTrace
 The trace source fired when the phy layer drops a packet before it tries to transmit it.
 
TracedCallback< Ptr< const Packet > > m_phyTxEndTrace
 The trace source fired when a packet ends the transmission process on the medium.
 
NetDevice::PromiscReceiveCallback m_promiscCallback
 Receive callback.
 
TracedCallback< Ptr< const Packet > > m_promiscSnifferTrace
 A trace source that emulates a promiscuous mode protocol sniffer connected to the device.
 
Ptr< Queue< Packet > > m_queue
 The Queue which this PointToPointNetDevice uses as a packet source.
 
Ptr< ErrorModelm_receiveErrorModel
 Error model for receive packet events.
 
NetDevice::ReceiveCallback m_rxCallback
 Receive callback.
 
TracedCallback< Ptr< const Packet > > m_snifferTrace
 A trace source that emulates a non-promiscuous protocol sniffer connected to the device.
 
Time m_tInterframeGap
 The interframe gap that the Net Device uses to throttle packet transmission.
 
TxMachineState m_txMachineState
 The state of the Net Device transmit state machine.
 

Static Private Attributes

static const uint16_t DEFAULT_MTU = 1500
 Default MTU.
 

Additional Inherited Members

- Public Types inherited from ns3::NetDevice
typedef void(* LinkChangeTracedCallback) ()
 TracedCallback signature for link changed event.
 
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 &, PacketTypePromiscReceiveCallback
 
typedef Callback< bool, Ptr< NetDevice >, Ptr< const Packet >, uint16_t, const Address & > ReceiveCallback
 

Detailed Description

A Device for a Point to Point Network Link.

This PointToPointNetDevice class specializes the NetDevice abstract base class. Together with a PointToPointChannel (and a peer PointToPointNetDevice), the class models, with some level of abstraction, a generic point-to-point or serial link. Key parameters or objects that can be specified for this device include a queue, data rate, and interframe transmission gap (the propagation delay is set in the PointToPointChannel).

Config Paths

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

  • "/NodeList/[i]/DeviceList/[i]/$ns3::PointToPointNetDevice"

Attributes

  • Address: The MAC address of this device.
  • DataRate: The default data rate for point to point links
    • Set with class: ns3::DataRateValue
    • Underlying type: DataRate
    • Initial value: 32768bps
    • Flags: constructwriteread
    • Support level: SUPPORTED
  • InterframeGap: The time to wait between packet (frame) transmissions
    • Set with class: ns3::TimeValue
    • Underlying type: Time -9.22337e+18ns:+9.22337e+18ns
    • Initial value: +0ns
    • Flags: constructwriteread
    • Support level: SUPPORTED
  • Mtu: The MAC-level Maximum Transmission Unit
    • Set with class: ns3::UintegerValue
    • Underlying type: uint16_t 0:65535
    • Initial value: 1500
    • Flags: constructwriteread
    • Support level: SUPPORTED
  • ReceiveErrorModel: The receiver error model used to simulate packet loss
  • TxQueue: A queue to use as the transmit queue in the device.

TraceSources

  • 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,
  • 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
  • PhyRxDrop: Trace source indicating a packet has been dropped by the device during reception
  • PhyRxEnd: Trace source indicating a packet has been completely received by the device
  • PhyTxBegin: Trace source indicating a packet has begun transmitting over the channel
  • PhyTxDrop: Trace source indicating a packet has been dropped by the device during transmission
  • PhyTxEnd: Trace source indicating a packet has been completely transmitted over the channel
  • PromiscSniffer: Trace source simulating a promiscuous packet sniffer attached to the device
  • Sniffer: Trace source simulating a non-promiscuous packet sniffer attached to the device

Group: PointToPoint

Size of this type is 488 bytes (on a 64-bit architecture).

Definition at line 52 of file point-to-point-net-device.h.

Member Enumeration Documentation

◆ TxMachineState

Enumeration of the states of the transmit machine of the net device.

Enumerator
READY 

The transmitter is ready to begin transmission of a packet.

BUSY 

The transmitter is busy transmitting a packet.

Definition at line 263 of file point-to-point-net-device.h.

Constructor & Destructor Documentation

◆ PointToPointNetDevice() [1/2]

ns3::PointToPointNetDevice::PointToPointNetDevice ( )

Construct a PointToPointNetDevice.

This is the constructor for the PointToPointNetDevice. It takes as a parameter a pointer to the Node to which this device is connected, as well as an optional DataRate object.

Definition at line 166 of file point-to-point-net-device.cc.

References NS_LOG_FUNCTION.

◆ ~PointToPointNetDevice()

ns3::PointToPointNetDevice::~PointToPointNetDevice ( )
override

Destroy a PointToPointNetDevice.

This is the destructor for the PointToPointNetDevice.

Definition at line 175 of file point-to-point-net-device.cc.

References NS_LOG_FUNCTION.

◆ PointToPointNetDevice() [2/2]

ns3::PointToPointNetDevice::PointToPointNetDevice ( const PointToPointNetDevice & )
delete

Member Function Documentation

◆ AddHeader()

void ns3::PointToPointNetDevice::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

Definition at line 181 of file point-to-point-net-device.cc.

References EtherToPpp(), NS_LOG_FUNCTION, and ns3::PppHeader::SetProtocol().

Referenced by Send().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ AddLinkChangeCallback()

void ns3::PointToPointNetDevice::AddLinkChangeCallback ( Callback< void > callback)
overridevirtual
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 437 of file point-to-point-net-device.cc.

References ns3::TracedCallback< Ts >::ConnectWithoutContext(), m_linkChangeCallbacks, and NS_LOG_FUNCTION.

+ Here is the call graph for this function:

◆ Attach()

bool ns3::PointToPointNetDevice::Attach ( Ptr< PointToPointChannel > ch)

Attach the device to a channel.

Parameters
chPtr to the channel to which this object is being attached.
Returns
true if the operation was successful (always true actually)

Definition at line 290 of file point-to-point-net-device.cc.

References m_channel, NotifyLinkUp(), and NS_LOG_FUNCTION.

+ Here is the call graph for this function:

◆ DoDispose()

void ns3::PointToPointNetDevice::DoDispose ( )
overrideprivatevirtual

Dispose of the object.

Reimplemented from ns3::Object.

Definition at line 200 of file point-to-point-net-device.cc.

References ns3::Object::DoDispose(), m_channel, m_currentPkt, m_node, m_queue, m_receiveErrorModel, and NS_LOG_FUNCTION.

+ Here is the call graph for this function:

◆ DoMpiReceive()

void ns3::PointToPointNetDevice::DoMpiReceive ( Ptr< Packet > p)
protected

Handler for MPI receive event.

Parameters
pPacket received

Definition at line 601 of file point-to-point-net-device.cc.

References NS_LOG_FUNCTION, and Receive().

+ Here is the call graph for this function:

◆ EtherToPpp()

uint16_t ns3::PointToPointNetDevice::EtherToPpp ( uint16_t protocol)
staticprivate

Ethernet to PPP protocol number mapping.

Parameters
protocolAn Ethernet protocol number
Returns
The corresponding PPP protocol number

Definition at line 657 of file point-to-point-net-device.cc.

References NS_ASSERT_MSG, and NS_LOG_FUNCTION_NOARGS.

Referenced by AddHeader().

+ Here is the caller graph for this function:

◆ GetAddress()

Address ns3::PointToPointNetDevice::GetAddress ( ) const
overridevirtual
Returns
the current Address of this interface.

Implements ns3::NetDevice.

Definition at line 424 of file point-to-point-net-device.cc.

References m_address.

Referenced by Receive().

+ Here is the caller graph for this function:

◆ GetBroadcast()

Address ns3::PointToPointNetDevice::GetBroadcast ( ) const
overridevirtual
Returns
the broadcast address supported by this netdevice.

Calling this method is invalid if IsBroadcast returns not true.

Implements ns3::NetDevice.

Definition at line 460 of file point-to-point-net-device.cc.

References ns3::Mac48Address::GetBroadcast(), and NS_LOG_FUNCTION.

+ Here is the call graph for this function:

◆ GetChannel()

Ptr< Channel > ns3::PointToPointNetDevice::GetChannel ( ) const
overridevirtual
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 405 of file point-to-point-net-device.cc.

References m_channel.

◆ GetIfIndex()

uint32_t ns3::PointToPointNetDevice::GetIfIndex ( ) const
overridevirtual
Returns
index ifIndex of the device

Implements ns3::NetDevice.

Definition at line 399 of file point-to-point-net-device.cc.

References m_ifIndex.

◆ GetMtu()

uint16_t ns3::PointToPointNetDevice::GetMtu ( ) const
overridevirtual
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 634 of file point-to-point-net-device.cc.

References m_mtu, and NS_LOG_FUNCTION.

Referenced by GetTypeId().

+ Here is the caller graph for this function:

◆ GetMulticast() [1/2]

Address ns3::PointToPointNetDevice::GetMulticast ( Ipv4Address multicastGroup) const
overridevirtual

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). Similar RFCs exist for Ipv6 and Eui64 mappings. This method performs the multicast address creation function appropriate to the underlying MAC address of the device. This MAC address is encapsulated in an abstract Address to avoid dependencies on the exact MAC address format.

In the case of net devices that do not support multicast, clients are expected to test NetDevice::IsMulticast and avoid attempting to map multicast packets. Subclasses of NetDevice that do support multicasting are expected to override this method and provide an implementation appropriate to the particular device.

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.
Warning
Calling this method is invalid if IsMulticast returns not true.
See also
IsMulticast()

Implements ns3::NetDevice.

Definition at line 474 of file point-to-point-net-device.cc.

References NS_LOG_FUNCTION.

◆ GetMulticast() [2/2]

Address ns3::PointToPointNetDevice::GetMulticast ( Ipv6Address addr) const
overridevirtual

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 481 of file point-to-point-net-device.cc.

References NS_LOG_FUNCTION.

◆ GetNode()

Ptr< Node > ns3::PointToPointNetDevice::GetNode ( ) const
overridevirtual
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 562 of file point-to-point-net-device.cc.

References m_node.

◆ GetQueue()

Ptr< Queue< Packet > > ns3::PointToPointNetDevice::GetQueue ( ) const

Get a copy of the attached Queue.

Returns
Ptr to the queue.

Definition at line 377 of file point-to-point-net-device.cc.

References m_queue, and NS_LOG_FUNCTION.

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

+ Here is the caller graph for this function:

◆ GetRemote()

Address ns3::PointToPointNetDevice::GetRemote ( ) const
private
Returns
the address of the remote device connected to this device through the point to point channel.

Definition at line 608 of file point-to-point-net-device.cc.

References m_channel, NS_ASSERT, and NS_LOG_FUNCTION.

Referenced by Receive().

+ Here is the caller graph for this function:

◆ GetTypeId()

◆ IsBridge()

bool ns3::PointToPointNetDevice::IsBridge ( ) const
overridevirtual

Return true if the net device is acting as a bridge.

Returns
value of m_isBridge flag

Implements ns3::NetDevice.

Definition at line 495 of file point-to-point-net-device.cc.

References NS_LOG_FUNCTION.

◆ IsBroadcast()

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

Implements ns3::NetDevice.

Definition at line 448 of file point-to-point-net-device.cc.

References NS_LOG_FUNCTION.

◆ IsLinkUp()

bool ns3::PointToPointNetDevice::IsLinkUp ( ) const
overridevirtual
Returns
true if link is up; false otherwise

Implements ns3::NetDevice.

Definition at line 430 of file point-to-point-net-device.cc.

References m_linkUp, and NS_LOG_FUNCTION.

Referenced by Send().

+ Here is the caller graph for this function:

◆ IsMulticast()

bool ns3::PointToPointNetDevice::IsMulticast ( ) const
overridevirtual
Returns
value of m_isMulticast flag

Implements ns3::NetDevice.

Definition at line 467 of file point-to-point-net-device.cc.

References NS_LOG_FUNCTION.

◆ IsPointToPoint()

bool ns3::PointToPointNetDevice::IsPointToPoint ( ) const
overridevirtual

Return true if the net device is on a point-to-point link.

Returns
value of m_isPointToPoint flag

Implements ns3::NetDevice.

Definition at line 488 of file point-to-point-net-device.cc.

References NS_LOG_FUNCTION.

◆ NeedsArp()

bool ns3::PointToPointNetDevice::NeedsArp ( ) const
overridevirtual
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 575 of file point-to-point-net-device.cc.

References NS_LOG_FUNCTION.

◆ NotifyLinkUp()

void ns3::PointToPointNetDevice::NotifyLinkUp ( )
private

Make the link up and running.

It calls also the linkChange callback.

Definition at line 384 of file point-to-point-net-device.cc.

References m_linkChangeCallbacks, m_linkUp, and NS_LOG_FUNCTION.

Referenced by Attach().

+ Here is the caller graph for this function:

◆ operator=()

PointToPointNetDevice & ns3::PointToPointNetDevice::operator= ( const PointToPointNetDevice & )
delete

◆ PppToEther()

uint16_t ns3::PointToPointNetDevice::PppToEther ( uint16_t protocol)
staticprivate

PPP to Ethernet protocol number mapping.

Parameters
protocolA PPP protocol number
Returns
The corresponding Ethernet protocol number

Definition at line 641 of file point-to-point-net-device.cc.

References NS_ASSERT_MSG, and NS_LOG_FUNCTION_NOARGS.

Referenced by ProcessHeader().

+ Here is the caller graph for this function:

◆ ProcessHeader()

bool ns3::PointToPointNetDevice::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.

Definition at line 190 of file point-to-point-net-device.cc.

References ns3::PppHeader::GetProtocol(), NS_LOG_FUNCTION, and PppToEther().

Referenced by Receive().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ Receive()

void ns3::PointToPointNetDevice::Receive ( Ptr< Packet > p)

Receive a packet from a connected PointToPointChannel.

The PointToPointNetDevice receives packets from its connected channel and forwards them up the protocol stack. This is the public method used by the channel to indicate that the last bit of a packet has arrived at the device.

Parameters
pPtr to the received packet.

Definition at line 322 of file point-to-point-net-device.cc.

References GetAddress(), GetRemote(), ns3::Callback< R, UArgs >::IsNull(), m_macPromiscRxTrace, m_macRxTrace, m_phyRxDropTrace, m_phyRxEndTrace, m_promiscCallback, m_promiscSnifferTrace, m_receiveErrorModel, m_rxCallback, m_snifferTrace, NS_LOG_FUNCTION, ns3::NetDevice::PACKET_HOST, and ProcessHeader().

Referenced by DoMpiReceive(), ns3::PointToPointHelper::Install(), and ns3::PointToPointChannel::TransmitStart().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ Send()

bool ns3::PointToPointNetDevice::Send ( Ptr< Packet > packet,
const Address & dest,
uint16_t protocolNumber )
overridevirtual
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 502 of file point-to-point-net-device.cc.

References AddHeader(), IsLinkUp(), m_macTxDropTrace, m_macTxTrace, m_promiscSnifferTrace, m_queue, m_snifferTrace, m_txMachineState, NS_LOG_FUNCTION, NS_LOG_LOGIC, READY, and TransmitStart().

+ Here is the call graph for this function:

◆ SendFrom()

bool ns3::PointToPointNetDevice::SendFrom ( Ptr< Packet > packet,
const Address & source,
const Address & dest,
uint16_t protocolNumber )
overridevirtual
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 552 of file point-to-point-net-device.cc.

References NS_LOG_FUNCTION.

◆ SetAddress()

void ns3::PointToPointNetDevice::SetAddress ( Address address)
overridevirtual

Set the address of this interface.

Parameters
addressaddress to set

Implements ns3::NetDevice.

Definition at line 417 of file point-to-point-net-device.cc.

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

+ Here is the call graph for this function:

◆ SetDataRate()

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

Set the Data Rate used for transmission of packets.

The data rate is set in the Attach () method from the corresponding field in the channel to which the device is attached. It can be overridden using this method.

Parameters
bpsthe data rate at which this object operates

Definition at line 212 of file point-to-point-net-device.cc.

References m_bps, and NS_LOG_FUNCTION.

◆ SetIfIndex()

void ns3::PointToPointNetDevice::SetIfIndex ( const uint32_t index)
overridevirtual
Parameters
indexifIndex of the device

Implements ns3::NetDevice.

Definition at line 392 of file point-to-point-net-device.cc.

References m_ifIndex, and NS_LOG_FUNCTION.

◆ SetInterframeGap()

void ns3::PointToPointNetDevice::SetInterframeGap ( Time t)

Set the interframe gap used to separate packets.

The interframe gap defines the minimum space required between packets sent by this device.

Parameters
tthe interframe gap time

Definition at line 219 of file point-to-point-net-device.cc.

References ns3::Time::As(), m_tInterframeGap, NS_LOG_FUNCTION, and ns3::Time::S.

+ Here is the call graph for this function:

◆ SetMtu()

bool ns3::PointToPointNetDevice::SetMtu ( const uint16_t mtu)
overridevirtual
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 626 of file point-to-point-net-device.cc.

References m_mtu, and NS_LOG_FUNCTION.

Referenced by GetTypeId().

+ Here is the caller graph for this function:

◆ SetNode()

void ns3::PointToPointNetDevice::SetNode ( Ptr< Node > node)
overridevirtual
Parameters
nodethe node associated to this netdevice.

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

Implements ns3::NetDevice.

Definition at line 568 of file point-to-point-net-device.cc.

References m_node, and NS_LOG_FUNCTION.

◆ SetPromiscReceiveCallback()

void ns3::PointToPointNetDevice::SetPromiscReceiveCallback ( PromiscReceiveCallback cb)
overridevirtual
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 588 of file point-to-point-net-device.cc.

References m_promiscCallback.

◆ SetQueue()

void ns3::PointToPointNetDevice::SetQueue ( Ptr< Queue< Packet > > queue)

Attach a queue to the PointToPointNetDevice.

The PointToPointNetDevice "owns" a queue that implements a queueing method such as DropTailQueue or RedQueue

Parameters
queuePtr to the new queue.

Definition at line 308 of file point-to-point-net-device.cc.

References m_queue, and NS_LOG_FUNCTION.

◆ SetReceiveCallback()

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

Set the callback to be used to notify higher layers when a packet has been received.

Implements ns3::NetDevice.

Definition at line 582 of file point-to-point-net-device.cc.

References m_rxCallback.

◆ SetReceiveErrorModel()

void ns3::PointToPointNetDevice::SetReceiveErrorModel ( Ptr< ErrorModel > em)

Attach a receive ErrorModel to the PointToPointNetDevice.

The PointToPointNetDevice may optionally include an ErrorModel in the packet receive chain.

Parameters
emPtr to the ErrorModel.

Definition at line 315 of file point-to-point-net-device.cc.

References m_receiveErrorModel, and NS_LOG_FUNCTION.

◆ SupportsSendFrom()

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

Implements ns3::NetDevice.

Definition at line 594 of file point-to-point-net-device.cc.

References NS_LOG_FUNCTION.

◆ TransmitComplete()

void ns3::PointToPointNetDevice::TransmitComplete ( )
private

Stop Sending a Packet Down the Wire and Begin the Interframe Gap.

The TransmitComplete method is used internally to finish the process of sending a packet out on the channel.

Definition at line 256 of file point-to-point-net-device.cc.

References BUSY, m_currentPkt, m_phyTxEndTrace, m_promiscSnifferTrace, m_queue, m_snifferTrace, m_txMachineState, NS_ASSERT_MSG, NS_LOG_FUNCTION, NS_LOG_LOGIC, READY, and TransmitStart().

Referenced by TransmitStart().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ TransmitStart()

bool ns3::PointToPointNetDevice::TransmitStart ( Ptr< Packet > p)
private

Start Sending a Packet Down the Wire.

The TransmitStart method is the method that is used internally in the PointToPointNetDevice to begin the process of sending a packet out on the channel. The corresponding method is called on the channel to let it know that the physical device this class represents has virtually started sending signals. An event is scheduled for the time at which the bits have been completely transmitted.

See also
PointToPointChannel::TransmitStart ()
TransmitComplete()
Parameters
pa reference to the packet to send
Returns
true if success, false on failure

Definition at line 226 of file point-to-point-net-device.cc.

References ns3::Time::As(), BUSY, ns3::DataRate::CalculateBytesTxTime(), m_bps, m_channel, m_currentPkt, m_phyTxBeginTrace, m_phyTxDropTrace, m_tInterframeGap, m_txMachineState, NS_ASSERT_MSG, NS_LOG_FUNCTION, NS_LOG_LOGIC, READY, ns3::Time::S, ns3::Simulator::Schedule(), and TransmitComplete().

Referenced by Send(), and TransmitComplete().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

Member Data Documentation

◆ DEFAULT_MTU

const uint16_t ns3::PointToPointNetDevice::DEFAULT_MTU = 1500
staticprivate

Default MTU.

Definition at line 422 of file point-to-point-net-device.h.

Referenced by GetTypeId().

◆ m_address

Mac48Address ns3::PointToPointNetDevice::m_address
private

Mac48Address of this NetDevice.

Definition at line 414 of file point-to-point-net-device.h.

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

◆ m_bps

DataRate ns3::PointToPointNetDevice::m_bps
private

The data rate that the Net Device uses to simulate packet transmission timing.

Definition at line 278 of file point-to-point-net-device.h.

Referenced by GetTypeId(), SetDataRate(), and TransmitStart().

◆ m_channel

Ptr<PointToPointChannel> ns3::PointToPointNetDevice::m_channel
private

The PointToPointChannel to which this PointToPointNetDevice has been attached.

Definition at line 290 of file point-to-point-net-device.h.

Referenced by Attach(), DoDispose(), GetChannel(), GetRemote(), and TransmitStart().

◆ m_currentPkt

Ptr<Packet> ns3::PointToPointNetDevice::m_currentPkt
private

Current packet processed.

Definition at line 434 of file point-to-point-net-device.h.

Referenced by DoDispose(), TransmitComplete(), and TransmitStart().

◆ m_ifIndex

uint32_t ns3::PointToPointNetDevice::m_ifIndex
private

Index of the interface.

Definition at line 418 of file point-to-point-net-device.h.

Referenced by GetIfIndex(), and SetIfIndex().

◆ m_linkChangeCallbacks

TracedCallback ns3::PointToPointNetDevice::m_linkChangeCallbacks
private

Callback for the link change event.

Definition at line 420 of file point-to-point-net-device.h.

Referenced by AddLinkChangeCallback(), and NotifyLinkUp().

◆ m_linkUp

bool ns3::PointToPointNetDevice::m_linkUp
private

Identify if the link is up or not.

Definition at line 419 of file point-to-point-net-device.h.

Referenced by IsLinkUp(), and NotifyLinkUp().

◆ m_macPromiscRxTrace

TracedCallback<Ptr<const Packet> > ns3::PointToPointNetDevice::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 (which doesn't mean a lot here in the point-to-point device).

Definition at line 323 of file point-to-point-net-device.h.

Referenced by GetTypeId(), and Receive().

◆ m_macRxDropTrace

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

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

Definition at line 338 of file point-to-point-net-device.h.

Referenced by GetTypeId().

◆ m_macRxTrace

TracedCallback<Ptr<const Packet> > ns3::PointToPointNetDevice::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 (which doesn't mean a lot here in the point-to-point device).

Definition at line 331 of file point-to-point-net-device.h.

Referenced by GetTypeId(), and Receive().

◆ m_macTxDropTrace

TracedCallback<Ptr<const Packet> > ns3::PointToPointNetDevice::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.

Definition at line 315 of file point-to-point-net-device.h.

Referenced by GetTypeId(), and Send().

◆ m_macTxTrace

TracedCallback<Ptr<const Packet> > ns3::PointToPointNetDevice::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.

Definition at line 309 of file point-to-point-net-device.h.

Referenced by GetTypeId(), and Send().

◆ m_mtu

uint32_t ns3::PointToPointNetDevice::m_mtu
private

The Maximum Transmission Unit.

This corresponds to the maximum number of bytes that can be transmitted as seen from higher layers. This corresponds to the 1500 byte MTU size often seen on IP over Ethernet.

Definition at line 432 of file point-to-point-net-device.h.

Referenced by GetMtu(), and SetMtu().

◆ m_node

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

Node owning this NetDevice.

Definition at line 413 of file point-to-point-net-device.h.

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

◆ m_phyRxBeginTrace

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

The trace source fired when a packet begins the reception process from the medium – when the simulated first bit(s) arrive.

Definition at line 362 of file point-to-point-net-device.h.

Referenced by GetTypeId().

◆ m_phyRxDropTrace

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

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

This happens if the receiver is not enabled or the error model is active and indicates that the packet is corrupt.

Definition at line 375 of file point-to-point-net-device.h.

Referenced by GetTypeId(), and Receive().

◆ m_phyRxEndTrace

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

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

Definition at line 368 of file point-to-point-net-device.h.

Referenced by GetTypeId(), and Receive().

◆ m_phyTxBeginTrace

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

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

Definition at line 344 of file point-to-point-net-device.h.

Referenced by GetTypeId(), and TransmitStart().

◆ m_phyTxDropTrace

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

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

Definition at line 356 of file point-to-point-net-device.h.

Referenced by GetTypeId(), and TransmitStart().

◆ m_phyTxEndTrace

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

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

Definition at line 350 of file point-to-point-net-device.h.

Referenced by GetTypeId(), and TransmitComplete().

◆ m_promiscCallback

NetDevice::PromiscReceiveCallback ns3::PointToPointNetDevice::m_promiscCallback
private

Receive callback.

Definition at line 416 of file point-to-point-net-device.h.

Referenced by Receive(), and SetPromiscReceiveCallback().

◆ m_promiscSnifferTrace

TracedCallback<Ptr<const Packet> > ns3::PointToPointNetDevice::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.

Definition at line 411 of file point-to-point-net-device.h.

Referenced by GetTypeId(), Receive(), Send(), and TransmitComplete().

◆ m_queue

Ptr<Queue<Packet> > ns3::PointToPointNetDevice::m_queue
private

The Queue which this PointToPointNetDevice uses as a packet source.

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

See also
class DropTailQueue

Definition at line 298 of file point-to-point-net-device.h.

Referenced by DoDispose(), GetQueue(), GetTypeId(), Send(), SetQueue(), and TransmitComplete().

◆ m_receiveErrorModel

Ptr<ErrorModel> ns3::PointToPointNetDevice::m_receiveErrorModel
private

Error model for receive packet events.

Definition at line 303 of file point-to-point-net-device.h.

Referenced by DoDispose(), GetTypeId(), Receive(), and SetReceiveErrorModel().

◆ m_rxCallback

NetDevice::ReceiveCallback ns3::PointToPointNetDevice::m_rxCallback
private

Receive callback.

Definition at line 415 of file point-to-point-net-device.h.

Referenced by Receive(), and SetReceiveCallback().

◆ m_snifferTrace

TracedCallback<Ptr<const Packet> > ns3::PointToPointNetDevice::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.

Definition at line 393 of file point-to-point-net-device.h.

Referenced by GetTypeId(), Receive(), Send(), and TransmitComplete().

◆ m_tInterframeGap

Time ns3::PointToPointNetDevice::m_tInterframeGap
private

The interframe gap that the Net Device uses to throttle packet transmission.

Definition at line 284 of file point-to-point-net-device.h.

Referenced by GetTypeId(), SetInterframeGap(), and TransmitStart().

◆ m_txMachineState

TxMachineState ns3::PointToPointNetDevice::m_txMachineState
private

The state of the Net Device transmit state machine.

Definition at line 272 of file point-to-point-net-device.h.

Referenced by Send(), TransmitComplete(), and TransmitStart().


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