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. | |
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. | |
~CsmaNetDevice () override | |
Destroy a CsmaNetDevice. | |
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. | |
bool | Attach (Ptr< CsmaChannel > ch) |
Attach the device to a channel. | |
Address | GetAddress () const override |
Address | GetBroadcast () const override |
Ptr< Channel > | GetChannel () const override |
CsmaNetDevice::EncapsulationMode | GetEncapsulationMode () |
Get the encapsulation mode of this device. | |
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< Node > | GetNode () const override |
Get the node to which this device is attached. | |
Ptr< Queue< Packet > > | GetQueue () const |
Get a copy of the attached Queue. | |
bool | IsBridge () const override |
Is this a bridge? | |
bool | IsBroadcast () const override |
bool | IsLinkUp () const override |
bool | IsMulticast () const override |
bool | IsPointToPoint () const override |
Is this a point to point link? | |
bool | IsReceiveEnabled () const |
Is the receive side of the network device enabled? | |
bool | IsSendEnabled () const |
Is the send side of the network device enabled? | |
bool | NeedsArp () const override |
Does this device need to use the address resolution protocol? | |
void | Receive (Ptr< const Packet > p, Ptr< CsmaNetDevice > sender) |
Receive a packet from a connected CsmaChannel. | |
bool | Send (Ptr< Packet > packet, const Address &dest, uint16_t protocolNumber) override |
Start sending a packet down the channel. | |
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. | |
void | SetAddress (Address address) override |
Set the address of this interface. | |
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. | |
void | SetEncapsulationMode (CsmaNetDevice::EncapsulationMode mode) |
Set the encapsulation mode of this device. | |
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 |
Set the node to which this device is being attached. | |
void | SetPromiscReceiveCallback (PromiscReceiveCallback cb) override |
void | SetQueue (Ptr< Queue< Packet > > queue) |
Attach a queue to the CsmaNetDevice. | |
void | SetReceiveCallback (NetDevice::ReceiveCallback cb) override |
Set the callback to be used to notify higher layers when a packet has been received. | |
void | SetReceiveEnable (bool enable) |
Enable or disable the receive side of the network device. | |
void | SetReceiveErrorModel (Ptr< ErrorModel > em) |
Attach a receive ErrorModel to the CsmaNetDevice. | |
void | SetSendEnable (bool enable) |
Enable or disable the send side of the network device. | |
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< Object > | GetObject () 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< Object > | GetObject (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. | |
SimpleRefCount & | operator= (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 type ID. | |
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 | 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. | |
void | DoDispose () override |
Perform any object release functionality required to break reference cycles in reference counted objects held by the device. | |
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 , 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. | |
void | Init (bool sendEnable, bool receiveEnable) |
Initialization function used during object construction. | |
void | NotifyLinkUp () |
Notify any interested parties that the link has come up. | |
CsmaNetDevice & | operator= (const CsmaNetDevice &o) |
Operator = is declared but not implemented. | |
void | TransmitAbort () |
Aborts the transmission of the current packet. | |
void | TransmitCompleteEvent () |
Stop Sending a Packet Down the Wire and Begin the Interframe Gap. | |
void | TransmitReadyEvent () |
Cause the Transmitter to Become Ready to Send Another Packet. | |
void | TransmitStart () |
Start Sending a Packet Down the Wire. | |
Private Attributes | |
Mac48Address | m_address |
The MAC address which has been assigned to this device. | |
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. | |
DataRate | m_bps |
The data rate that the Net Device uses to simulate packet transmission timing. | |
Ptr< CsmaChannel > | m_channel |
The CsmaChannel to which this CsmaNetDevice has been attached. | |
Ptr< Packet > | m_currentPkt |
Next packet that will be transmitted (if transmitter is not currently transmitting) or packet that is currently being transmitted. | |
uint32_t | m_deviceId |
Device ID returned by the attached functions. | |
EncapsulationMode | m_encapMode |
The type of packet that should be created by the AddHeader function and that should be processed by the ProcessHeader function. | |
uint32_t | m_ifIndex |
The interface index (really net evice index) that has been assigned to this network device. | |
TracedCallback | m_linkChangeCallbacks |
List of callbacks to fire if the link changes state (up or down). | |
bool | m_linkUp |
Flag indicating whether or not the link is up. | |
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 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_macTxBackoffTrace |
The trace source fired when the mac layer is forced to begin the backoff process for a packet. | |
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< Node > | m_node |
The Node to which this device is attached. | |
TracedCallback< Ptr< const Packet > > | m_phyRxBeginTrace |
The trace source fired when a packet begins the reception process from the medium. | |
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 as 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_promiscRxCallback |
The callback used to notify higher layers that a packet has been received in promiscuous mode. | |
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 CsmaNetDevice uses as a packet source. | |
bool | m_receiveEnable |
Enable net device to receive packets. | |
Ptr< ErrorModel > | m_receiveErrorModel |
Error model for receive packet events. | |
NetDevice::ReceiveCallback | m_rxCallback |
The callback used to notify higher layers that a packet has been received. | |
bool | m_sendEnable |
Enable net device to send packets. | |
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 insert time between 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 Maximum Transmission Unit (MTU) for the CsmaNetDevice. | |
Additional Inherited Members | |
Related Symbols inherited from ns3::ObjectBase | |
static TypeId | GetObjectIid () |
Ensure the TypeId for ObjectBase gets fully configured to anchor the inheritance tree properly. | |
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.
ns3::CsmaNetDevice is accessible through the following paths with Config::Set and Config::Connect:
Mac48Address
Dix|Llc
Group: Csma
Size of this type is 568 bytes (on a 64-bit architecture).
Definition at line 50 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 62 of file csma-net-device.h.
|
private |
Enumeration of the states of the transmit machine of the net device.
Definition at line 464 of file csma-net-device.h.
ns3::CsmaNetDevice::CsmaNetDevice | ( | ) |
Construct a CsmaNetDevice.
This is the default constructor for a CsmaNetDevice.
Definition at line 176 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 198 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 302 of file csma-net-device.cc.
References ns3::EthernetTrailer::CalcFcs(), ns3::Node::ChecksumEnabled(), ns3::Create(), DIX, ns3::EthernetTrailer::EnableFcs(), GetMtu(), 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 887 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 1063 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 647 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 205 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 873 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 901 of file csma-net-device.cc.
References ns3::Mac48Address::GetBroadcast(), and NS_LOG_FUNCTION_NOARGS.
Implements ns3::NetDevice.
Definition at line 859 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 226 of file csma-net-device.cc.
References m_encapMode, and NS_LOG_FUNCTION_NOARGS.
|
overridevirtual |
Implements ns3::NetDevice.
Definition at line 852 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 245 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 915 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 1040 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 1011 of file csma-net-device.cc.
References m_node, and NS_LOG_FUNCTION_NOARGS.
Get a copy of the attached Queue.
Definition at line 830 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 34 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::MakeEnumAccessor(), ns3::MakeEnumChecker(), ns3::MakeMac48AddressAccessor(), ns3::MakeMac48AddressChecker(), ns3::MakePointerAccessor(), ns3::MakePointerChecker(), ns3::MakeTraceSourceAccessor(), ns3::MakeUintegerAccessor(), ns3::MakeUintegerChecker(), 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 939 of file csma-net-device.cc.
References NS_LOG_FUNCTION_NOARGS.
|
overridevirtual |
Implements ns3::NetDevice.
Definition at line 894 of file csma-net-device.cc.
References NS_LOG_FUNCTION_NOARGS.
|
overridevirtual |
Implements ns3::NetDevice.
Definition at line 880 of file csma-net-device.cc.
References m_linkUp, and NS_LOG_FUNCTION_NOARGS.
Referenced by SendFrom().
|
overridevirtual |
Implements ns3::NetDevice.
Definition at line 908 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 932 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 273 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 266 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 1026 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 837 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 687 of file csma-net-device.cc.
References ns3::EthernetTrailer::CheckFcs(), ns3::Node::ChecksumEnabled(), ns3::EthernetTrailer::EnableFcs(), ns3::EthernetHeader::GetDestination(), ns3::EthernetHeader::GetLengthType(), ns3::EthernetHeader::GetSource(), ns3::LlcSnapHeader::GetType(), 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, and ns3::NetDevice::PACKET_OTHERHOST.
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 946 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 953 of file csma-net-device.cc.
References AddHeader(), ns3::Mac48Address::ConvertFrom(), 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 866 of file csma-net-device.cc.
References 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 287 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 215 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 845 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 280 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 233 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 1018 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 1049 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 673 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 1033 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 259 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 680 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 252 of file csma-net-device.cc.
References m_sendEnable, and NS_LOG_FUNCTION.
|
overridevirtual |
Implements ns3::NetDevice.
Definition at line 1056 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 528 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 575 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 608 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 435 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(), TransmitCompleteEvent(), and TransmitStart().
Referenced by SendFrom(), TransmitAbort(), TransmitReadyEvent(), and TransmitStart().
|
staticprivate |
Default Maximum Transmission Unit (MTU) for the CsmaNetDevice.
Definition at line 716 of file csma-net-device.h.
Referenced by GetTypeId().
|
private |
The MAC address which has been assigned to this device.
Definition at line 683 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 504 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 490 of file csma-net-device.h.
Referenced by Attach(), and TransmitStart().
|
private |
The CsmaChannel to which this CsmaNetDevice has been attached.
Definition at line 518 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 511 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 449 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 483 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 700 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 711 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 706 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 559 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 577 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 568 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 586 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 550 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 542 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 724 of file csma-net-device.h.
Referenced by AddHeader(), GetMtu(), SetEncapsulationMode(), and SetMtu().
The Node to which this device is attached.
Definition at line 678 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 618 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 633 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 626 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 594 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 610 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 602 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 694 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 673 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 527 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 459 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 534 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 688 of file csma-net-device.h.
Referenced by Receive(), and SetReceiveCallback().
|
private |
Enable net device to send packets.
True by default
Definition at line 454 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 653 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 497 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 476 of file csma-net-device.h.
Referenced by CsmaNetDevice(), SendFrom(), TransmitAbort(), TransmitCompleteEvent(), TransmitReadyEvent(), and TransmitStart().