A Device for a Csma Network Link. More...
#include "csma-net-device.h"
Public Types | |
enum | EncapsulationMode { ILLEGAL , DIX , LLC } |
Enumeration of the types of packets supported in the class. More... | |
Public Types inherited from ns3::NetDevice | |
typedef void(* | LinkChangeTracedCallback) () |
TracedCallback signature for link changed event. More... | |
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 &, PacketType > | PromiscReceiveCallback |
typedef Callback< bool, Ptr< NetDevice >, Ptr< const Packet >, uint16_t, const Address & > | ReceiveCallback |
Public Member Functions | |
CsmaNetDevice () | |
Construct a CsmaNetDevice. More... | |
~CsmaNetDevice () override | |
Destroy a CsmaNetDevice. More... | |
void | AddLinkChangeCallback (Callback< void > callback) override |
int64_t | AssignStreams (int64_t stream) |
Assign a fixed random variable stream number to the random variables used by this model. More... | |
bool | Attach (Ptr< CsmaChannel > ch) |
Attach the device to a channel. More... | |
Address | GetAddress () const override |
Address | GetBroadcast () const override |
Ptr< Channel > | GetChannel () const override |
CsmaNetDevice::EncapsulationMode | GetEncapsulationMode () |
Get the encapsulation mode of this device. More... | |
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. More... | |
Address | GetMulticast (Ipv6Address addr) const override |
Get the MAC multicast address corresponding to the IPv6 address provided. More... | |
Ptr< Node > | GetNode () const override |
Get the node to which this device is attached. More... | |
Ptr< Queue< Packet > > | GetQueue () const |
Get a copy of the attached Queue. More... | |
bool | IsBridge () const override |
Is this a bridge? More... | |
bool | IsBroadcast () const override |
bool | IsLinkUp () const override |
bool | IsMulticast () const override |
bool | IsPointToPoint () const override |
Is this a point to point link? More... | |
bool | IsReceiveEnabled () const |
Is the receive side of the network device enabled? More... | |
bool | IsSendEnabled () const |
Is the send side of the network device enabled? More... | |
bool | NeedsArp () const override |
Does this device need to use the address resolution protocol? More... | |
void | Receive (Ptr< const Packet > p, Ptr< CsmaNetDevice > sender) |
Receive a packet from a connected CsmaChannel. More... | |
bool | Send (Ptr< Packet > packet, const Address &dest, uint16_t protocolNumber) override |
Start sending a packet down the channel. More... | |
bool | SendFrom (Ptr< Packet > packet, const Address &source, const Address &dest, uint16_t protocolNumber) override |
Start sending a packet down the channel, with MAC spoofing. More... | |
void | SetAddress (Address address) override |
Set the address of this interface. More... | |
void | SetBackoffParams (Time slotTime, uint32_t minSlots, uint32_t maxSlots, uint32_t maxRetries, uint32_t ceiling) |
Set the backoff parameters used to determine the wait to retry transmitting a packet when the channel is busy. More... | |
void | SetEncapsulationMode (CsmaNetDevice::EncapsulationMode mode) |
Set the encapsulation mode of this device. More... | |
void | SetIfIndex (const uint32_t index) override |
void | SetInterframeGap (Time t) |
Set the interframe gap used to separate packets. More... | |
bool | SetMtu (const uint16_t mtu) override |
void | SetNode (Ptr< Node > node) override |
Set the node to which this device is being attached. More... | |
void | SetPromiscReceiveCallback (PromiscReceiveCallback cb) override |
void | SetQueue (Ptr< Queue< Packet >> queue) |
Attach a queue to the CsmaNetDevice. More... | |
void | SetReceiveCallback (NetDevice::ReceiveCallback cb) override |
Set the callback to be used to notify higher layers when a packet has been received. More... | |
void | SetReceiveEnable (bool enable) |
Enable or disable the receive side of the network device. More... | |
void | SetReceiveErrorModel (Ptr< ErrorModel > em) |
Attach a receive ErrorModel to the CsmaNetDevice. More... | |
void | SetSendEnable (bool enable) |
Enable or disable the send side of the network device. More... | |
bool | SupportsSendFrom () const override |
Public Member Functions inherited from ns3::NetDevice | |
~NetDevice () override | |
Public Member Functions inherited from ns3::Object | |
Object () | |
Constructor. More... | |
~Object () override | |
Destructor. More... | |
void | AggregateObject (Ptr< Object > other) |
Aggregate two Objects together. More... | |
void | Dispose () |
Dispose of this Object. More... | |
AggregateIterator | GetAggregateIterator () const |
Get an iterator to the Objects aggregated to this one. More... | |
TypeId | GetInstanceTypeId () const override |
Get the most derived TypeId for this Object. More... | |
template<typename T > | |
Ptr< T > | GetObject () const |
Get a pointer to the requested aggregated Object. More... | |
template<> | |
Ptr< Object > | GetObject () const |
Specialization of () for objects of type ns3::Object. More... | |
template<typename T > | |
Ptr< T > | GetObject (TypeId tid) const |
Get a pointer to the requested aggregated Object by TypeId. More... | |
template<> | |
Ptr< Object > | GetObject (TypeId tid) const |
Specialization of (TypeId tid) for objects of type ns3::Object. More... | |
void | Initialize () |
Invoke DoInitialize on all Objects aggregated to this one. More... | |
bool | IsInitialized () const |
Check if the object has been initialized. More... | |
Public Member Functions inherited from ns3::SimpleRefCount< Object, ObjectBase, ObjectDeleter > | |
SimpleRefCount () | |
Default constructor. More... | |
SimpleRefCount (const SimpleRefCount &o[[maybe_unused]]) | |
Copy constructor. More... | |
uint32_t | GetReferenceCount () const |
Get the reference count of the object. More... | |
SimpleRefCount & | operator= (const SimpleRefCount &o[[maybe_unused]]) |
Assignment operator. More... | |
void | Ref () const |
Increment the reference count. More... | |
void | Unref () 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 |
Get the value of an attribute, raising fatal errors if unsuccessful. More... | |
bool | GetAttributeFailSafe (std::string name, AttributeValue &value) const |
Get the value of an attribute without raising errors. More... | |
void | SetAttribute (std::string name, const AttributeValue &value) |
Set a single attribute, raising fatal errors if unsuccessful. More... | |
bool | SetAttributeFailSafe (std::string name, const AttributeValue &value) |
Set a single attribute without raising errors. More... | |
bool | TraceConnect (std::string name, std::string context, const CallbackBase &cb) |
Connect a TraceSource to a Callback with a context. More... | |
bool | TraceConnectWithoutContext (std::string name, const CallbackBase &cb) |
Connect a TraceSource to a Callback without a context. More... | |
bool | TraceDisconnect (std::string name, std::string context, const CallbackBase &cb) |
Disconnect from a TraceSource a Callback previously connected with a context. More... | |
bool | TraceDisconnectWithoutContext (std::string name, const CallbackBase &cb) |
Disconnect from a TraceSource a Callback previously connected without a context. More... | |
Static Public Member Functions | |
static TypeId | GetTypeId () |
Get the type ID. More... | |
Static Public Member Functions inherited from ns3::NetDevice | |
static TypeId | GetTypeId () |
Get the type ID. More... | |
Static Public Member Functions inherited from ns3::Object | |
static TypeId | GetTypeId () |
Register this type. More... | |
Static Public Member Functions inherited from ns3::ObjectBase | |
static TypeId | GetTypeId () |
Get the type ID. More... | |
Protected Member Functions | |
void | AddHeader (Ptr< Packet > p, Mac48Address source, Mac48Address dest, uint16_t protocolNumber) |
Adds the necessary headers and trailers to a packet of data in order to respect the packet type. More... | |
void | DoDispose () override |
Perform any object release functionality required to break reference cycles in reference counted objects held by the device. More... | |
Protected Member Functions inherited from ns3::Object | |
Object (const Object &o) | |
Copy an Object. More... | |
virtual void | DoInitialize () |
Initialize() implementation. More... | |
virtual void | NotifyNewAggregate () |
Notify all Objects aggregated to this one of a new Object being aggregated. More... | |
Protected Member Functions inherited from ns3::ObjectBase | |
void | ConstructSelf (const AttributeConstructionList &attributes) |
Complete construction of ObjectBase; invoked by derived classes. More... | |
virtual void | NotifyConstructionCompleted () |
Notifier called once the ObjectBase is fully constructed. More... | |
Private Types | |
enum | TxMachineState { READY , BUSY , GAP , BACKOFF } |
Enumeration of the states of the transmit machine of the net device. More... | |
Private Member Functions | |
CsmaNetDevice (const CsmaNetDevice &o) | |
Copy constructor is declared but not implemented. More... | |
void | Init (bool sendEnable, bool receiveEnable) |
Initialization function used during object construction. More... | |
void | NotifyLinkUp () |
Notify any interested parties that the link has come up. More... | |
CsmaNetDevice & | operator= (const CsmaNetDevice &o) |
Operator = is declared but not implemented. More... | |
void | TransmitAbort () |
Aborts the transmission of the current packet. More... | |
void | TransmitCompleteEvent () |
Stop Sending a Packet Down the Wire and Begin the Interframe Gap. More... | |
void | TransmitReadyEvent () |
Cause the Transmitter to Become Ready to Send Another Packet. More... | |
void | TransmitStart () |
Start Sending a Packet Down the Wire. More... | |
Private Attributes | |
Mac48Address | m_address |
The MAC address which has been assigned to this device. More... | |
Backoff | m_backoff |
Holds the backoff parameters and is used to calculate the next backoff time to use when the channel is busy and the net device is ready to transmit. More... | |
DataRate | m_bps |
The data rate that the Net Device uses to simulate packet transmission timing. More... | |
Ptr< CsmaChannel > | m_channel |
The CsmaChannel to which this CsmaNetDevice has been attached. More... | |
Ptr< Packet > | m_currentPkt |
Next packet that will be transmitted (if transmitter is not currently transmitting) or packet that is currently being transmitted. More... | |
uint32_t | m_deviceId |
Device ID returned by the attached functions. 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 interface index (really net evice index) that has been assigned to this network device. More... | |
TracedCallback | m_linkChangeCallbacks |
List of 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 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_macTxBackoffTrace |
The trace source fired when the mac layer is forced to begin the backoff process for a packet. 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_mtu |
The Maximum Transmission Unit. More... | |
Ptr< Node > | m_node |
The Node to which this device is attached. More... | |
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 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< Queue< Packet > > | m_queue |
The Queue which this CsmaNetDevice uses as a packet source. More... | |
bool | m_receiveEnable |
Enable net device to receive packets. More... | |
Ptr< ErrorModel > | m_receiveErrorModel |
Error model for receive packet events. More... | |
NetDevice::ReceiveCallback | m_rxCallback |
The callback used to notify higher layers that a packet has been received. More... | |
bool | m_sendEnable |
Enable net device to send packets. More... | |
TracedCallback< Ptr< const Packet > > | m_snifferTrace |
A trace source that emulates a non-promiscuous protocol sniffer connected to the device. More... | |
Time | m_tInterframeGap |
The interframe gap that the Net Device uses insert time between packet transmission. More... | |
TxMachineState | m_txMachineState |
The state of the Net Device transmit state machine. More... | |
Static Private Attributes | |
static const uint16_t | DEFAULT_MTU = 1500 |
Default Maximum Transmission Unit (MTU) for the CsmaNetDevice. More... | |
Additional Inherited Members | |
Related Functions inherited from ns3::ObjectBase | |
static TypeId | GetObjectIid () |
Ensure the TypeId for ObjectBase gets fully configured to anchor the inheritance tree properly. More... | |
A Device for a Csma Network Link.
The Csma net device class is analogous to layer 1 and 2 of the TCP stack. The NetDevice takes a raw packet of bytes and creates a protocol specific packet from them.
Definition at line 61 of file csma-net-device.h.
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 73 of file csma-net-device.h.
|
private |
Enumeration of the states of the transmit machine of the net device.
Definition at line 475 of file csma-net-device.h.
ns3::CsmaNetDevice::CsmaNetDevice | ( | ) |
Construct a CsmaNetDevice.
This is the default constructor for a CsmaNetDevice.
Definition at line 187 of file csma-net-device.cc.
References DIX, m_channel, m_encapMode, m_tInterframeGap, m_txMachineState, NS_LOG_FUNCTION, READY, and ns3::Seconds().
|
override |
Destroy a CsmaNetDevice.
This is the destructor for a CsmaNetDevice.
Definition at line 209 of file csma-net-device.cc.
References m_queue, and NS_LOG_FUNCTION_NOARGS.
|
private |
Copy constructor is declared but not implemented.
This disables the copy constructor for CsmaNetDevice objects.
o | object to copy |
|
protected |
Adds the necessary headers and trailers to a packet of data in order to respect the packet type.
p | Packet to which header should be added |
source | MAC source address from which packet should be sent |
dest | MAC destination address to which packet should be sent |
protocolNumber | In some protocols, identifies the type of payload contained in this packet. |
Definition at line 313 of file csma-net-device.cc.
References ns3::Packet::AddAtEnd(), ns3::Packet::AddHeader(), ns3::Packet::AddTrailer(), ns3::EthernetTrailer::CalcFcs(), ns3::Node::ChecksumEnabled(), DIX, ns3::EthernetTrailer::EnableFcs(), GetMtu(), ns3::Packet::GetSize(), ILLEGAL, LLC, m_encapMode, m_mtu, 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 SendFrom().
|
overridevirtual |
callback | the 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 898 of file csma-net-device.cc.
References ns3::TracedCallback< Ts >::ConnectWithoutContext(), m_linkChangeCallbacks, and NS_LOG_FUNCTION.
int64_t ns3::CsmaNetDevice::AssignStreams | ( | int64_t | stream | ) |
Assign a fixed random variable stream number to the random variables used by this model.
Return the number of streams (possibly zero) that have been assigned.
stream | first stream index to use |
Definition at line 1074 of file csma-net-device.cc.
References ns3::Backoff::AssignStreams(), and m_backoff.
bool ns3::CsmaNetDevice::Attach | ( | Ptr< CsmaChannel > | ch | ) |
Attach the device to a channel.
The function Attach is used to add a CsmaNetDevice to a CsmaChannel.
ch | a pointer to the channel to which this object is being attached. |
Definition at line 658 of file csma-net-device.cc.
References ns3::DataRate::CalculateBytesTxTime(), m_bps, m_channel, m_deviceId, m_tInterframeGap, NotifyLinkUp(), and NS_LOG_FUNCTION.
|
overrideprotectedvirtual |
Perform any object release functionality required to break reference cycles in reference counted objects held by the device.
Reimplemented from ns3::Object.
Definition at line 216 of file csma-net-device.cc.
References ns3::Object::DoDispose(), m_channel, m_node, m_queue, and NS_LOG_FUNCTION_NOARGS.
|
overridevirtual |
Implements ns3::NetDevice.
Definition at line 884 of file csma-net-device.cc.
References m_address, and NS_LOG_FUNCTION_NOARGS.
|
overridevirtual |
Calling this method is invalid if IsBroadcast returns not true.
Implements ns3::NetDevice.
Definition at line 912 of file csma-net-device.cc.
References NS_LOG_FUNCTION_NOARGS.
Implements ns3::NetDevice.
Definition at line 870 of file csma-net-device.cc.
References m_channel, and NS_LOG_FUNCTION_NOARGS.
CsmaNetDevice::EncapsulationMode ns3::CsmaNetDevice::GetEncapsulationMode | ( | ) |
Get the encapsulation mode of this device.
Definition at line 237 of file csma-net-device.cc.
References m_encapMode, and NS_LOG_FUNCTION_NOARGS.
|
overridevirtual |
Implements ns3::NetDevice.
Definition at line 863 of file csma-net-device.cc.
References m_ifIndex, and NS_LOG_FUNCTION_NOARGS.
|
overridevirtual |
This value is typically used by the IP layer to perform IP fragmentation when needed.
Implements ns3::NetDevice.
Definition at line 256 of file csma-net-device.cc.
References m_mtu, and NS_LOG_FUNCTION_NOARGS.
Referenced by AddHeader(), and GetTypeId().
|
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).
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.
multicastGroup | The IP address for the multicast group destination of the packet. |
Implements ns3::NetDevice.
Definition at line 926 of file csma-net-device.cc.
References ns3::Mac48Address::GetMulticast(), NS_LOG_FUNCTION, and NS_LOG_LOGIC.
|
overridevirtual |
Get the MAC multicast address corresponding to the IPv6 address provided.
addr | IPv6 address |
Implements ns3::NetDevice.
Definition at line 1051 of file csma-net-device.cc.
References ns3::Mac48Address::GetMulticast(), and NS_LOG_LOGIC.
Get the node to which this device is attached.
Implements ns3::NetDevice.
Definition at line 1022 of file csma-net-device.cc.
References m_node, and NS_LOG_FUNCTION_NOARGS.
Get a copy of the attached Queue.
Definition at line 841 of file csma-net-device.cc.
References m_queue, and NS_LOG_FUNCTION_NOARGS.
Referenced by ns3::CsmaHelper::EnableAsciiInternal().
|
static |
Get the type ID.
Definition at line 45 of file csma-net-device.cc.
References DEFAULT_MTU, DIX, GetMtu(), LLC, m_address, m_macPromiscRxTrace, m_macRxDropTrace, m_macRxTrace, m_macTxBackoffTrace, m_macTxDropTrace, m_macTxTrace, m_phyRxBeginTrace, m_phyRxDropTrace, m_phyRxEndTrace, m_phyTxBeginTrace, m_phyTxDropTrace, m_phyTxEndTrace, m_promiscSnifferTrace, m_queue, m_receiveEnable, m_receiveErrorModel, m_sendEnable, m_snifferTrace, ns3::MakeBooleanAccessor(), ns3::MakeBooleanChecker(), ns3::MakeEnumChecker(), ns3::MakePointerAccessor(), ns3::MakeTraceSourceAccessor(), ns3::MakeUintegerAccessor(), SetEncapsulationMode(), SetMtu(), and ns3::TypeId::SetParent().
|
private |
Initialization function used during object construction.
sendEnable | if device will be allowed to send |
receiveEnable | if device will be allowed to receive |
|
overridevirtual |
Is this a bridge?
Implements ns3::NetDevice.
Definition at line 950 of file csma-net-device.cc.
References NS_LOG_FUNCTION_NOARGS.
|
overridevirtual |
Implements ns3::NetDevice.
Definition at line 905 of file csma-net-device.cc.
References NS_LOG_FUNCTION_NOARGS.
|
overridevirtual |
Implements ns3::NetDevice.
Definition at line 891 of file csma-net-device.cc.
References m_linkUp, and NS_LOG_FUNCTION_NOARGS.
Referenced by SendFrom().
|
overridevirtual |
Implements ns3::NetDevice.
Definition at line 919 of file csma-net-device.cc.
References NS_LOG_FUNCTION_NOARGS.
|
overridevirtual |
Is this a point to point link?
Implements ns3::NetDevice.
Definition at line 943 of file csma-net-device.cc.
References NS_LOG_FUNCTION_NOARGS.
bool ns3::CsmaNetDevice::IsReceiveEnabled | ( | ) | const |
Is the receive side of the network device enabled?
Definition at line 284 of file csma-net-device.cc.
References m_receiveEnable, and NS_LOG_FUNCTION_NOARGS.
Referenced by Receive().
bool ns3::CsmaNetDevice::IsSendEnabled | ( | ) | const |
Is the send side of the network device enabled?
Definition at line 277 of file csma-net-device.cc.
References m_sendEnable, and NS_LOG_FUNCTION_NOARGS.
Referenced by SendFrom(), and TransmitStart().
|
overridevirtual |
Does this device need to use the address resolution protocol?
Implements ns3::NetDevice.
Definition at line 1037 of file csma-net-device.cc.
References NS_LOG_FUNCTION_NOARGS.
|
private |
Notify any interested parties that the link has come up.
Definition at line 848 of file csma-net-device.cc.
References m_linkChangeCallbacks, m_linkUp, and NS_LOG_FUNCTION_NOARGS.
Referenced by Attach().
|
private |
Operator = is declared but not implemented.
This disables the assignment operator for CsmaNetDevice objects.
o | object to copy |
void ns3::CsmaNetDevice::Receive | ( | Ptr< const Packet > | p, |
Ptr< CsmaNetDevice > | sender | ||
) |
Receive a packet from a connected CsmaChannel.
The CsmaNetDevice 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.
p | a reference to the received packet |
sender | the CsmaNetDevice that transmitted the packet in the first place |
Definition at line 698 of file csma-net-device.cc.
References ns3::EthernetTrailer::CheckFcs(), ns3::Node::ChecksumEnabled(), ns3::Packet::Copy(), ns3::EthernetTrailer::EnableFcs(), ns3::EthernetHeader::GetDestination(), ns3::EthernetHeader::GetLengthType(), ns3::Packet::GetSize(), ns3::EthernetHeader::GetSource(), ns3::LlcSnapHeader::GetType(), ns3::Packet::GetUid(), ns3::Mac48Address::IsBroadcast(), ns3::Mac48Address::IsGroup(), ns3::Callback< R, UArgs >::IsNull(), IsReceiveEnabled(), m_address, m_macPromiscRxTrace, m_macRxTrace, m_phyRxDropTrace, m_phyRxEndTrace, m_promiscRxCallback, m_promiscSnifferTrace, m_receiveErrorModel, m_rxCallback, m_snifferTrace, NS_ASSERT, NS_LOG_FUNCTION, NS_LOG_INFO, NS_LOG_LOGIC, ns3::NetDevice::PACKET_BROADCAST, ns3::NetDevice::PACKET_HOST, ns3::NetDevice::PACKET_MULTICAST, ns3::NetDevice::PACKET_OTHERHOST, ns3::Packet::RemoveAtEnd(), ns3::Packet::RemoveHeader(), and ns3::Packet::RemoveTrailer().
Referenced by ns3::CsmaChannel::TransmitEnd().
|
overridevirtual |
Start sending a packet down the channel.
packet | packet to send |
dest | layer 2 destination address |
protocolNumber | protocol number |
Implements ns3::NetDevice.
Definition at line 957 of file csma-net-device.cc.
References m_address, NS_LOG_FUNCTION, and SendFrom().
|
overridevirtual |
Start sending a packet down the channel, with MAC spoofing.
packet | packet to send |
source | layer 2 source address |
dest | layer 2 destination address |
protocolNumber | protocol number |
Implements ns3::NetDevice.
Definition at line 964 of file csma-net-device.cc.
References AddHeader(), ns3::Mac48Address::ConvertFrom(), ns3::Packet::GetUid(), IsLinkUp(), IsSendEnabled(), m_currentPkt, m_macTxDropTrace, m_macTxTrace, m_promiscSnifferTrace, m_queue, m_snifferTrace, m_txMachineState, NS_ASSERT, NS_ASSERT_MSG, NS_LOG_FUNCTION, NS_LOG_LOGIC, READY, and TransmitStart().
Referenced by Send().
|
overridevirtual |
Set the address of this interface.
address | address to set |
Implements ns3::NetDevice.
Definition at line 877 of file csma-net-device.cc.
References first::address, ns3::Mac48Address::ConvertFrom(), m_address, and NS_LOG_FUNCTION_NOARGS.
void ns3::CsmaNetDevice::SetBackoffParams | ( | Time | slotTime, |
uint32_t | minSlots, | ||
uint32_t | maxSlots, | ||
uint32_t | maxRetries, | ||
uint32_t | ceiling | ||
) |
Set the backoff parameters used to determine the wait to retry transmitting a packet when the channel is busy.
slotTime | Length of a packet slot (or average packet time) |
minSlots | Minimum number of slots to wait |
maxSlots | Maximum number of slots to wait |
maxRetries | Maximum number of retries before packet is discard |
ceiling | Cap on the exponential function when calculating max slots |
Definition at line 298 of file csma-net-device.cc.
References m_backoff, ns3::Backoff::m_ceiling, ns3::Backoff::m_maxRetries, ns3::Backoff::m_maxSlots, ns3::Backoff::m_minSlots, ns3::Backoff::m_slotTime, and NS_LOG_FUNCTION.
void ns3::CsmaNetDevice::SetEncapsulationMode | ( | CsmaNetDevice::EncapsulationMode | mode | ) |
Set the encapsulation mode of this device.
mode | The encapsulation mode of this device. |
Definition at line 226 of file csma-net-device.cc.
References m_encapMode, m_mtu, NS_LOG_FUNCTION, and NS_LOG_LOGIC.
Referenced by GetTypeId().
|
overridevirtual |
index | ifIndex of the device |
Implements ns3::NetDevice.
Definition at line 856 of file csma-net-device.cc.
References m_ifIndex, and NS_LOG_FUNCTION.
void ns3::CsmaNetDevice::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. As in Ethernet, it defaults to 96 bit times.
t | the interframe gap time |
Definition at line 291 of file csma-net-device.cc.
References m_tInterframeGap, and NS_LOG_FUNCTION.
|
overridevirtual |
mtu | MTU value, in bytes, to set for the device |
Override for default MTU defined on a per-type basis.
Implements ns3::NetDevice.
Definition at line 244 of file csma-net-device.cc.
References m_encapMode, m_mtu, NS_LOG_FUNCTION, and NS_LOG_LOGIC.
Referenced by GetTypeId().
Set the node to which this device is being attached.
Implements ns3::NetDevice.
Definition at line 1029 of file csma-net-device.cc.
References m_node, and NS_LOG_FUNCTION.
|
overridevirtual |
cb | callback 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 1060 of file csma-net-device.cc.
References m_promiscRxCallback, and NS_LOG_FUNCTION.
Attach a queue to the CsmaNetDevice.
The CsmaNetDevice "owns" a queue. This queue may be set by higher level topology objects to implement a particular queueing method such as DropTail.
queue | a Ptr to the queue for being assigned to the device. |
Definition at line 684 of file csma-net-device.cc.
References m_queue, and NS_LOG_FUNCTION.
|
overridevirtual |
Set the callback to be used to notify higher layers when a packet has been received.
cb | The callback. |
Implements ns3::NetDevice.
Definition at line 1044 of file csma-net-device.cc.
References m_rxCallback, and NS_LOG_FUNCTION.
void ns3::CsmaNetDevice::SetReceiveEnable | ( | bool | enable | ) |
Enable or disable the receive side of the network device.
enable | Enable the receive side if true, otherwise disable. |
Definition at line 270 of file csma-net-device.cc.
References m_receiveEnable, and NS_LOG_FUNCTION.
void ns3::CsmaNetDevice::SetReceiveErrorModel | ( | Ptr< ErrorModel > | em | ) |
Attach a receive ErrorModel to the CsmaNetDevice.
The CsmaNetDevice may optionally include an ErrorModel in the packet receive chain to simulate data errors in during transmission.
em | a pointer to the ErrorModel |
Definition at line 691 of file csma-net-device.cc.
References m_receiveErrorModel, and NS_LOG_FUNCTION.
void ns3::CsmaNetDevice::SetSendEnable | ( | bool | enable | ) |
Enable or disable the send side of the network device.
enable | Enable the send side if true, otherwise disable. |
Definition at line 263 of file csma-net-device.cc.
References m_sendEnable, and NS_LOG_FUNCTION.
|
overridevirtual |
Implements ns3::NetDevice.
Definition at line 1067 of file csma-net-device.cc.
References NS_LOG_FUNCTION_NOARGS.
|
private |
Aborts the transmission of the current packet.
If the net device has tried to transmit a packet for more times than the maximum allowed number of retries (channel always busy) then the packet is dropped.
Definition at line 539 of file csma-net-device.cc.
References BACKOFF, ns3::Packet::GetUid(), m_backoff, m_currentPkt, m_phyTxDropTrace, m_promiscSnifferTrace, m_queue, m_snifferTrace, m_txMachineState, NS_ASSERT_MSG, NS_LOG_FUNCTION_NOARGS, NS_LOG_LOGIC, READY, ns3::Backoff::ResetBackoffTime(), and TransmitStart().
Referenced by TransmitStart().
|
private |
Stop Sending a Packet Down the Wire and Begin the Interframe Gap.
The TransmitCompleteEvent method is used internally to finish the process of sending a packet out on the channel. During execution of this method the TransmitEnd method is called on the channel to let it know that the physical device this class represents has finished sending simulated signals. The channel uses this event to begin its speed of light delay timer after which it notifies the Net Device(s) at the other end of the link that new bits have arrived (it delivers the Packet). During this method, the net device also schedules the TransmitReadyEvent at which time the transmitter becomes ready to send the next packet.
Definition at line 586 of file csma-net-device.cc.
References ns3::Time::As(), BUSY, GAP, ns3::Packet::GetUid(), m_channel, m_currentPkt, m_phyTxEndTrace, m_tInterframeGap, m_txMachineState, NS_ASSERT, NS_ASSERT_MSG, NS_LOG_FUNCTION_NOARGS, NS_LOG_LOGIC, ns3::Time::S, ns3::Simulator::Schedule(), TransmitReadyEvent(), and ns3::TRANSMITTING.
Referenced by TransmitStart().
|
private |
Cause the Transmitter to Become Ready to Send Another Packet.
The TransmitReadyEvent method is used internally to re-enable the transmit machine of the net device. It is scheduled after a suitable interframe gap after the completion of the previous transmission. The queue is checked at this time, and if there is a packet waiting on the queue, the transmission process is begun.
If a packet is in the queue, it is extracted for the queue as the next packet to be transmitted by the net device.
Definition at line 619 of file csma-net-device.cc.
References GAP, m_currentPkt, m_promiscSnifferTrace, m_queue, m_snifferTrace, m_txMachineState, NS_ASSERT_MSG, NS_LOG_FUNCTION_NOARGS, READY, and TransmitStart().
Referenced by TransmitCompleteEvent().
|
private |
Start Sending a Packet Down the Wire.
The TransmitStart method is the method that is used internally in the CsmaNetDevice to begin the process of sending a packet out on the channel. A corresponding method is called on the channel to let it know that the physical device this class represents has actually started sending signals, this causes the channel to enter the BUSY state. An event is scheduled for the time at which the bits have been completely transmitted.
If the channel is found to be BUSY, this method reschedules itself for execution at a later time (within the backoff period).
Definition at line 446 of file csma-net-device.cc.
References ns3::Time::As(), BACKOFF, BUSY, ns3::DataRate::CalculateBytesTxTime(), ns3::Backoff::GetBackoffTime(), ns3::Packet::GetSize(), ns3::Packet::GetUid(), ns3::IDLE, ns3::Backoff::IncrNumRetries(), IsSendEnabled(), m_backoff, m_bps, m_channel, m_currentPkt, m_deviceId, m_macTxBackoffTrace, m_phyTxBeginTrace, m_phyTxDropTrace, m_txMachineState, ns3::Backoff::MaxRetriesReached(), NS_ASSERT_MSG, NS_LOG_FUNCTION_NOARGS, NS_LOG_LOGIC, NS_LOG_WARN, READY, ns3::Backoff::ResetBackoffTime(), ns3::Time::S, ns3::Simulator::Schedule(), TransmitAbort(), and TransmitCompleteEvent().
Referenced by SendFrom(), TransmitAbort(), and TransmitReadyEvent().
|
staticprivate |
Default Maximum Transmission Unit (MTU) for the CsmaNetDevice.
Definition at line 727 of file csma-net-device.h.
Referenced by GetTypeId().
|
private |
The MAC address which has been assigned to this device.
Definition at line 694 of file csma-net-device.h.
Referenced by GetAddress(), GetTypeId(), Receive(), Send(), and SetAddress().
|
private |
Holds the backoff parameters and is used to calculate the next backoff time to use when the channel is busy and the net device is ready to transmit.
Definition at line 515 of file csma-net-device.h.
Referenced by AssignStreams(), SetBackoffParams(), TransmitAbort(), and TransmitStart().
|
private |
The data rate that the Net Device uses to simulate packet transmission timing.
Definition at line 501 of file csma-net-device.h.
Referenced by Attach(), and TransmitStart().
|
private |
The CsmaChannel to which this CsmaNetDevice has been attached.
Definition at line 529 of file csma-net-device.h.
Referenced by CsmaNetDevice(), Attach(), DoDispose(), GetChannel(), TransmitCompleteEvent(), and TransmitStart().
Next packet that will be transmitted (if transmitter is not currently transmitting) or packet that is currently being transmitted.
Definition at line 522 of file csma-net-device.h.
Referenced by SendFrom(), TransmitAbort(), TransmitCompleteEvent(), TransmitReadyEvent(), and TransmitStart().
|
private |
Device ID returned by the attached functions.
It is used by the mp-channel to identify each net device to make sure that only active net devices are writing to the channel
Definition at line 460 of file csma-net-device.h.
Referenced by Attach(), and TransmitStart().
|
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 494 of file csma-net-device.h.
Referenced by CsmaNetDevice(), AddHeader(), GetEncapsulationMode(), SetEncapsulationMode(), and SetMtu().
|
private |
The interface index (really net evice index) that has been assigned to this network device.
Definition at line 711 of file csma-net-device.h.
Referenced by GetIfIndex(), and SetIfIndex().
|
private |
List of callbacks to fire if the link changes state (up or down).
Definition at line 722 of file csma-net-device.h.
Referenced by AddLinkChangeCallback(), and NotifyLinkUp().
|
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 717 of file csma-net-device.h.
Referenced by IsLinkUp(), and NotifyLinkUp().
|
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.
Definition at line 570 of file csma-net-device.h.
Referenced by GetTypeId(), and Receive().
|
private |
The trace source fired for packets successfully received by the device but dropped before being forwarded up to higher layers (at the L2/L3 transition).
Definition at line 588 of file csma-net-device.h.
Referenced by GetTypeId().
|
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.
Definition at line 579 of file csma-net-device.h.
Referenced by GetTypeId(), and Receive().
|
private |
The trace source fired when the mac layer is forced to begin the backoff process for a packet.
This can happen a number of times as the backoff sequence is repeated with increasing delays.
Definition at line 597 of file csma-net-device.h.
Referenced by GetTypeId(), and TransmitStart().
|
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 561 of file csma-net-device.h.
Referenced by GetTypeId(), and SendFrom().
|
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 553 of file csma-net-device.h.
Referenced by GetTypeId(), and SendFrom().
|
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 735 of file csma-net-device.h.
Referenced by AddHeader(), GetMtu(), SetEncapsulationMode(), and SetMtu().
The Node to which this device is attached.
Definition at line 689 of file csma-net-device.h.
Referenced by DoDispose(), GetNode(), and SetNode().
|
private |
The trace source fired when a packet begins the reception process from the medium.
Definition at line 629 of file csma-net-device.h.
Referenced by GetTypeId().
|
private |
The trace source fired when the phy layer drops a packet it has received.
Definition at line 644 of file csma-net-device.h.
Referenced by GetTypeId(), and Receive().
|
private |
The trace source fired when a packet ends the reception process from the medium.
Definition at line 637 of file csma-net-device.h.
Referenced by GetTypeId(), and Receive().
|
private |
The trace source fired when a packet begins the transmission process on the medium.
Definition at line 605 of file csma-net-device.h.
Referenced by GetTypeId(), and TransmitStart().
|
private |
The trace source fired when the phy layer drops a packet as it tries to transmit it.
Definition at line 621 of file csma-net-device.h.
Referenced by GetTypeId(), TransmitAbort(), and TransmitStart().
|
private |
The trace source fired when a packet ends the transmission process on the medium.
Definition at line 613 of file csma-net-device.h.
Referenced by GetTypeId(), and TransmitCompleteEvent().
|
private |
The callback used to notify higher layers that a packet has been received in promiscuous mode.
Definition at line 705 of file csma-net-device.h.
Referenced by Receive(), and SetPromiscReceiveCallback().
|
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 684 of file csma-net-device.h.
Referenced by GetTypeId(), Receive(), SendFrom(), TransmitAbort(), and TransmitReadyEvent().
The Queue which this CsmaNetDevice uses as a packet source.
Management of this Queue has been delegated to the CsmaNetDevice and it has the responsibility for deletion.
Definition at line 538 of file csma-net-device.h.
Referenced by ~CsmaNetDevice(), DoDispose(), GetQueue(), GetTypeId(), SendFrom(), SetQueue(), TransmitAbort(), and TransmitReadyEvent().
|
private |
Enable net device to receive packets.
True by default
Definition at line 470 of file csma-net-device.h.
Referenced by GetTypeId(), IsReceiveEnabled(), and SetReceiveEnable().
|
private |
Error model for receive packet events.
When active this model will be used to model transmission errors by marking some of the packets received as corrupt.
Definition at line 545 of file csma-net-device.h.
Referenced by GetTypeId(), Receive(), and SetReceiveErrorModel().
|
private |
The callback used to notify higher layers that a packet has been received.
Definition at line 699 of file csma-net-device.h.
Referenced by Receive(), and SetReceiveCallback().
|
private |
Enable net device to send packets.
True by default
Definition at line 465 of file csma-net-device.h.
Referenced by GetTypeId(), IsSendEnabled(), and SetSendEnable().
|
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 664 of file csma-net-device.h.
Referenced by GetTypeId(), Receive(), SendFrom(), TransmitAbort(), and TransmitReadyEvent().
|
private |
The interframe gap that the Net Device uses insert time between packet transmission.
Definition at line 508 of file csma-net-device.h.
Referenced by CsmaNetDevice(), Attach(), SetInterframeGap(), and TransmitCompleteEvent().
|
private |
The state of the Net Device transmit state machine.
Definition at line 487 of file csma-net-device.h.
Referenced by CsmaNetDevice(), SendFrom(), TransmitAbort(), TransmitCompleteEvent(), TransmitReadyEvent(), and TransmitStart().