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 | |
enum | PacketType { PACKET_HOST = 1, NS3_PACKET_HOST = PACKET_HOST, PACKET_BROADCAST, NS3_PACKET_BROADCAST = PACKET_BROADCAST, PACKET_MULTICAST, NS3_PACKET_MULTICAST = PACKET_MULTICAST, PACKET_OTHERHOST, NS3_PACKET_OTHERHOST = PACKET_OTHERHOST } |
Packet types are used as they are in Linux. More... | |
typedef Callback< bool, Ptr < NetDevice >, Ptr< const Packet >, uint16_t, const Address &, const Address &, enum PacketType > | PromiscReceiveCallback |
typedef Callback< bool, Ptr < NetDevice >, Ptr< const Packet >, uint16_t, const Address & > | ReceiveCallback |
Public Member Functions | |
CsmaNetDevice () | |
Construct a CsmaNetDevice. More... | |
virtual | ~CsmaNetDevice () |
Destroy a CsmaNetDevice. More... | |
virtual void | AddLinkChangeCallback (Callback< void > callback) |
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... | |
virtual Address | GetAddress (void) const |
virtual Address | GetBroadcast (void) const |
virtual Ptr< Channel > | GetChannel (void) const |
CsmaNetDevice::EncapsulationMode | GetEncapsulationMode (void) |
Get the encapsulation mode of this device. More... | |
virtual uint32_t | GetIfIndex (void) const |
virtual uint16_t | GetMtu (void) const |
virtual Address | GetMulticast (Ipv4Address multicastGroup) const |
Make and return a MAC multicast address using the provided multicast group. More... | |
virtual Address | GetMulticast (Ipv6Address addr) const |
Get the MAC multicast address corresponding to the IPv6 address provided. More... | |
virtual Ptr< Node > | GetNode (void) const |
Get the node to which this device is attached. More... | |
Ptr< Queue > | GetQueue (void) const |
Get a copy of the attached Queue. More... | |
virtual bool | IsBridge (void) const |
Is this a bridge? More... | |
virtual bool | IsBroadcast (void) const |
virtual bool | IsLinkUp (void) const |
virtual bool | IsMulticast (void) const |
virtual bool | IsPointToPoint (void) const |
Is this a point to point link? More... | |
bool | IsReceiveEnabled (void) |
Is the receive side of the network device enabled? More... | |
bool | IsSendEnabled (void) |
Is the send side of the network device enabled? More... | |
virtual bool | NeedsArp (void) const |
Does this device need to use the address resolution protocol? More... | |
void | Receive (Ptr< Packet > p, Ptr< CsmaNetDevice > sender) |
Receive a packet from a connected CsmaChannel. More... | |
virtual bool | Send (Ptr< Packet > packet, const Address &dest, uint16_t protocolNumber) |
Start sending a packet down the channel. More... | |
virtual bool | SendFrom (Ptr< Packet > packet, const Address &source, const Address &dest, uint16_t protocolNumber) |
Start sending a packet down the channel, with MAC spoofing. More... | |
virtual void | SetAddress (Address address) |
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... | |
virtual void | SetIfIndex (const uint32_t index) |
void | SetInterframeGap (Time t) |
Set the interframe gap used to separate packets. More... | |
virtual bool | SetMtu (const uint16_t mtu) |
virtual void | SetNode (Ptr< Node > node) |
Set the node to which this device is being attached. More... | |
virtual void | SetPromiscReceiveCallback (PromiscReceiveCallback cb) |
void | SetQueue (Ptr< Queue > queue) |
Attach a queue to the CsmaNetDevice. More... | |
virtual void | SetReceiveCallback (NetDevice::ReceiveCallback cb) |
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... | |
virtual bool | SupportsSendFrom (void) const |
Public Member Functions inherited from ns3::NetDevice | |
virtual | ~NetDevice () |
Public Member Functions inherited from ns3::Object | |
Object () | |
virtual | ~Object () |
void | AggregateObject (Ptr< Object > other) |
void | Dispose (void) |
Run the DoDispose methods of this object and all the objects aggregated to it. More... | |
AggregateIterator | GetAggregateIterator (void) const |
virtual TypeId | GetInstanceTypeId (void) const |
template<typename T > | |
Ptr< T > | GetObject (void) const |
template<typename T > | |
Ptr< T > | GetObject (TypeId tid) const |
void | Initialize (void) |
This method calls the virtual DoInitialize method on all the objects aggregated to this object. More... | |
Public Member Functions inherited from ns3::SimpleRefCount< Object, ObjectBase, ObjectDeleter > | |
SimpleRefCount () | |
Constructor. More... | |
SimpleRefCount (const SimpleRefCount &o) | |
Copy constructor. More... | |
uint32_t | GetReferenceCount (void) const |
Get the reference count of the object. More... | |
SimpleRefCount & | operator= (const SimpleRefCount &o) |
Assignment. More... | |
void | Ref (void) const |
Increment the reference count. More... | |
void | Unref (void) const |
Decrement the reference count. More... | |
Public Member Functions inherited from ns3::ObjectBase | |
virtual | ~ObjectBase () |
Virtual destructor. More... | |
void | GetAttribute (std::string name, AttributeValue &value) const |
bool | GetAttributeFailSafe (std::string name, AttributeValue &attribute) const |
void | SetAttribute (std::string name, const AttributeValue &value) |
bool | SetAttributeFailSafe (std::string name, const AttributeValue &value) |
bool | TraceConnect (std::string name, std::string context, const CallbackBase &cb) |
bool | TraceConnectWithoutContext (std::string name, const CallbackBase &cb) |
bool | TraceDisconnect (std::string name, std::string context, const CallbackBase &cb) |
bool | TraceDisconnectWithoutContext (std::string name, const CallbackBase &cb) |
Static Public Member Functions | |
static TypeId | GetTypeId (void) |
Static Public Member Functions inherited from ns3::NetDevice | |
static TypeId | GetTypeId (void) |
Static Public Member Functions inherited from ns3::Object | |
static TypeId | GetTypeId (void) |
Register this type. More... | |
Static Public Member Functions inherited from ns3::SimpleRefCount< Object, ObjectBase, ObjectDeleter > | |
static void | Cleanup (void) |
Noop. More... | |
Static Public Member Functions inherited from ns3::ObjectBase | |
static TypeId | GetTypeId (void) |
Get the type ID. More... | |
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... | |
virtual void | DoDispose (void) |
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) | |
virtual void | DoInitialize (void) |
This method is called only once by Object::Initialize. More... | |
virtual void | NotifyNewAggregate (void) |
This method is invoked whenever two sets of objects are aggregated together. More... | |
Protected Member Functions inherited from ns3::ObjectBase | |
void | ConstructSelf (const AttributeConstructionList &attributes) |
virtual void | NotifyConstructionCompleted (void) |
This method is invoked once all member attributes have been initialized. More... | |
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 (void) |
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 (void) |
Aborts the transmission of the current packet. More... | |
void | TransmitCompleteEvent (void) |
Stop Sending a Packet Down the Wire and Begin the Interframe Gap. More... | |
void | TransmitReadyEvent (void) |
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 > | 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 |
A Device for a Csma Network Link.
ns3::CsmaNetDevice is accessible through the following paths with Config::Set and Config::Connect:
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 58 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 66 of file csma-net-device.h.
|
private |
Enumeration of the states of the transmit machine of the net device.
Definition at line 463 of file csma-net-device.h.
ns3::CsmaNetDevice::CsmaNetDevice | ( | ) |
Construct a CsmaNetDevice.
This is the default constructor for a CsmaNetDevice.
Definition at line 156 of file csma-net-device.cc.
References DIX, m_channel, m_encapMode, m_tInterframeGap, m_txMachineState, NS_LOG_FUNCTION, and READY.
|
virtual |
Destroy a CsmaNetDevice.
This is the destructor for a CsmaNetDevice.
Definition at line 178 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 278 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().
|
virtual |
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 848 of file csma-net-device.cc.
References ns3::TracedCallback< T1, T2, T3, T4, T5, T6, T7, T8 >::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 1018 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 614 of file csma-net-device.cc.
References ns3::DataRate::CalculateTxTime(), m_bps, m_channel, m_deviceId, m_tInterframeGap, NotifyLinkUp(), and NS_LOG_FUNCTION.
|
protectedvirtual |
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 185 of file csma-net-device.cc.
References ns3::Object::DoDispose(), m_channel, m_node, and NS_LOG_FUNCTION_NOARGS.
|
virtual |
Implements ns3::NetDevice.
Definition at line 834 of file csma-net-device.cc.
References m_address, and NS_LOG_FUNCTION_NOARGS.
|
virtual |
Calling this method is invalid if IsBroadcast returns not true.
Implements ns3::NetDevice.
Definition at line 862 of file csma-net-device.cc.
References NS_LOG_FUNCTION_NOARGS.
Implements ns3::NetDevice.
Definition at line 820 of file csma-net-device.cc.
References m_channel, and NS_LOG_FUNCTION_NOARGS.
CsmaNetDevice::EncapsulationMode ns3::CsmaNetDevice::GetEncapsulationMode | ( | void | ) |
Get the encapsulation mode of this device.
Definition at line 205 of file csma-net-device.cc.
References m_encapMode, and NS_LOG_FUNCTION_NOARGS.
|
virtual |
Implements ns3::NetDevice.
Definition at line 813 of file csma-net-device.cc.
References m_ifIndex, and NS_LOG_FUNCTION_NOARGS.
|
virtual |
This value is typically used by the IP layer to perform IP fragmentation when needed.
Implements ns3::NetDevice.
Definition at line 224 of file csma-net-device.cc.
References m_mtu, and NS_LOG_FUNCTION_NOARGS.
Referenced by AddHeader(), and GetTypeId().
|
virtual |
Make and return a MAC multicast address using the provided multicast group.
RFC 1112 says that an Ipv4 host group address is mapped to an Ethernet multicast address by placing the low-order 23-bits of the IP address into the low-order 23 bits of the Ethernet multicast address 01-00-5E-00-00-00 (hex).
This method performs the multicast address creation function appropriate to an EUI-48-based CSMA device. This MAC address is encapsulated in an abstract Address to avoid dependencies on the exact address format.
multicastGroup | The IP address for the multicast group destination of the packet. |
Implements ns3::NetDevice.
Definition at line 876 of file csma-net-device.cc.
References ns3::Mac48Address::GetMulticast(), NS_LOG_FUNCTION, and NS_LOG_LOGIC.
|
virtual |
Get the MAC multicast address corresponding to the IPv6 address provided.
addr | IPv6 address |
Implements ns3::NetDevice.
Definition at line 995 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 967 of file csma-net-device.cc.
References m_node, and NS_LOG_FUNCTION_NOARGS.
Get a copy of the attached Queue.
Definition at line 791 of file csma-net-device.cc.
References m_queue, and NS_LOG_FUNCTION_NOARGS.
Referenced by ns3::CsmaHelper::EnableAsciiInternal().
|
static |
Definition at line 44 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::MakeEnumAccessor(), ns3::MakeEnumChecker(), ns3::MakeTraceSourceAccessor(), 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 |
|
virtual |
Is this a bridge?
Implements ns3::NetDevice.
Definition at line 900 of file csma-net-device.cc.
References NS_LOG_FUNCTION_NOARGS.
|
virtual |
Implements ns3::NetDevice.
Definition at line 855 of file csma-net-device.cc.
References NS_LOG_FUNCTION_NOARGS.
|
virtual |
Implements ns3::NetDevice.
Definition at line 841 of file csma-net-device.cc.
References m_linkUp, and NS_LOG_FUNCTION_NOARGS.
Referenced by SendFrom().
|
virtual |
Implements ns3::NetDevice.
Definition at line 869 of file csma-net-device.cc.
References NS_LOG_FUNCTION_NOARGS.
|
virtual |
Is this a point to point link?
Implements ns3::NetDevice.
Definition at line 893 of file csma-net-device.cc.
References NS_LOG_FUNCTION_NOARGS.
bool ns3::CsmaNetDevice::IsReceiveEnabled | ( | void | ) |
Is the receive side of the network device enabled?
Definition at line 253 of file csma-net-device.cc.
References m_receiveEnable, and NS_LOG_FUNCTION_NOARGS.
Referenced by Receive().
bool ns3::CsmaNetDevice::IsSendEnabled | ( | void | ) |
Is the send side of the network device enabled?
Definition at line 246 of file csma-net-device.cc.
References m_sendEnable, and NS_LOG_FUNCTION_NOARGS.
Referenced by SendFrom(), and TransmitStart().
|
virtual |
Does this device need to use the address resolution protocol?
Implements ns3::NetDevice.
Definition at line 982 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 798 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< 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 654 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, T1, T2, T3, T4, T5, T6, T7, T8, T9 >::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().
|
virtual |
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 907 of file csma-net-device.cc.
References m_address, NS_LOG_FUNCTION, and SendFrom().
|
virtual |
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 914 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().
|
virtual |
Set the address of this interface.
address | address to set |
Implements ns3::NetDevice.
Definition at line 827 of file csma-net-device.cc.
References ns3::Mac48Address::ConvertFrom(), m_address, and NS_LOG_FUNCTION_NOARGS.
Referenced by StaticRoutingSlash32TestCase::DoRun(), GlobalRoutingSlash32TestCase::DoRun(), and main().
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 267 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 194 of file csma-net-device.cc.
References m_encapMode, m_mtu, NS_LOG_FUNCTION, and NS_LOG_LOGIC.
Referenced by GetTypeId().
|
virtual |
index | ifIndex of the device |
Implements ns3::NetDevice.
Definition at line 806 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 260 of file csma-net-device.cc.
References m_tInterframeGap, and NS_LOG_FUNCTION.
|
virtual |
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 212 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 974 of file csma-net-device.cc.
References m_node, and NS_LOG_FUNCTION.
|
virtual |
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 1004 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 or RED.
queue | a Ptr to the queue for being assigned to the device. |
Definition at line 640 of file csma-net-device.cc.
References m_queue, and NS_LOG_FUNCTION.
|
virtual |
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 989 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 239 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 647 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 232 of file csma-net-device.cc.
References m_sendEnable, and NS_LOG_FUNCTION.
|
virtual |
Implements ns3::NetDevice.
Definition at line 1011 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 502 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 546 of file csma-net-device.cc.
References BUSY, GAP, ns3::Time::GetSeconds(), 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::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 578 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 409 of file csma-net-device.cc.
References BACKOFF, BUSY, ns3::DataRate::CalculateTxTime(), ns3::Backoff::GetBackoffTime(), ns3::Time::GetSeconds(), 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::Simulator::Schedule(), TransmitAbort(), and TransmitCompleteEvent().
Referenced by SendFrom(), TransmitAbort(), and TransmitReadyEvent().
|
staticprivate |
Definition at line 711 of file csma-net-device.h.
Referenced by GetTypeId().
|
private |
The MAC address which has been assigned to this device.
Definition at line 682 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 503 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 489 of file csma-net-device.h.
Referenced by Attach(), and TransmitStart().
|
private |
The CsmaChannel to which this CsmaNetDevice has been attached.
Definition at line 517 of file csma-net-device.h.
Referenced by Attach(), CsmaNetDevice(), 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 510 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 448 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 482 of file csma-net-device.h.
Referenced by AddHeader(), CsmaNetDevice(), GetEncapsulationMode(), SetEncapsulationMode(), and SetMtu().
|
private |
The interface index (really net evice index) that has been assigned to this network device.
Definition at line 698 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 709 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 704 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 558 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 576 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 567 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 585 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 549 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 541 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 719 of file csma-net-device.h.
Referenced by AddHeader(), GetMtu(), SetEncapsulationMode(), and SetMtu().
The Node to which this device is attached.
Definition at line 677 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 617 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 632 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 625 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 593 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 609 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 601 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 692 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 672 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 526 of file csma-net-device.h.
Referenced by GetQueue(), GetTypeId(), SendFrom(), SetQueue(), TransmitAbort(), TransmitReadyEvent(), and ~CsmaNetDevice().
|
private |
Enable net device to receive packets.
True by default
Definition at line 458 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 533 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 687 of file csma-net-device.h.
Referenced by Receive(), and SetReceiveCallback().
|
private |
Enable net device to send packets.
True by default
Definition at line 453 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 652 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 496 of file csma-net-device.h.
Referenced by Attach(), CsmaNetDevice(), SetInterframeGap(), and TransmitCompleteEvent().
|
private |
The state of the Net Device transmit state machine.
Definition at line 475 of file csma-net-device.h.
Referenced by CsmaNetDevice(), SendFrom(), TransmitAbort(), TransmitCompleteEvent(), TransmitReadyEvent(), and TransmitStart().