|
A Discrete-Event Network Simulator
|
API
|
Go to the documentation of this file.
21 #ifndef CSMA_NET_DEVICE_H
22 #define CSMA_NET_DEVICE_H
26 #include "ns3/backoff.h"
27 #include "ns3/address.h"
28 #include "ns3/net-device.h"
29 #include "ns3/callback.h"
30 #include "ns3/packet.h"
31 #include "ns3/traced-callback.h"
32 #include "ns3/nstime.h"
33 #include "ns3/data-rate.h"
35 #include "ns3/mac48-address.h"
39 template <
typename Item>
class Queue;
112 uint32_t maxRetries, uint32_t ceiling);
217 virtual void SetIfIndex (
const uint32_t index);
220 virtual bool SetMtu (
const uint16_t mtu);
221 virtual uint16_t
GetMtu (
void)
const;
274 uint16_t protocolNumber);
285 uint16_t protocolNumber);
381 void Init (
bool sendEnable,
bool receiveEnable);
DataRate m_bps
The data rate that the Net Device uses to simulate packet transmission timing.
a unique identifier for an interface.
void TransmitStart()
Start Sending a Packet Down the Wire.
EncapsulationMode
Enumeration of the types of packets supported in the class.
Ptr< CsmaChannel > m_channel
The CsmaChannel to which this CsmaNetDevice has been attached.
Mac48Address m_address
The MAC address which has been assigned to this device.
virtual ~CsmaNetDevice()
Destroy a CsmaNetDevice.
Ptr< Queue< Packet > > m_queue
The Queue which this CsmaNetDevice uses as a packet source.
CsmaNetDevice(const CsmaNetDevice &o)
Copy constructor is declared but not implemented.
int64_t AssignStreams(int64_t stream)
Assign a fixed random variable stream number to the random variables used by this model.
TracedCallback< Ptr< const Packet > > m_snifferTrace
A trace source that emulates a non-promiscuous protocol sniffer connected to the device.
virtual bool SupportsSendFrom(void) const
TracedCallback< Ptr< const Packet > > m_phyTxDropTrace
The trace source fired when the phy layer drops a packet as it tries to transmit it.
Every class exported by the ns3 library is enclosed in the ns3 namespace.
bool m_sendEnable
Enable net device to send packets.
TracedCallback< Ptr< const Packet > > m_macTxTrace
The trace source fired when packets come into the "top" of the device at the L3/L2 transition,...
@ BACKOFF
The transmitter is waiting for the channel to be free.
TracedCallback< Ptr< const Packet > > m_phyRxDropTrace
The trace source fired when the phy layer drops a packet it has received.
EncapsulationMode m_encapMode
The type of packet that should be created by the AddHeader function and that should be processed by t...
uint32_t m_ifIndex
The interface index (really net evice index) that has been assigned to this network device.
virtual bool Send(Ptr< Packet > packet, const Address &dest, uint16_t protocolNumber)
Start sending a packet down the channel.
Backoff m_backoff
Holds the backoff parameters and is used to calculate the next backoff time to use when the channel i...
TxMachineState m_txMachineState
The state of the Net Device transmit state machine.
void SetReceiveEnable(bool enable)
Enable or disable the receive side of the network device.
Ipv4 addresses are stored in host order in this class.
virtual bool SetMtu(const uint16_t mtu)
Describes an IPv6 address.
virtual void SetNode(Ptr< Node > node)
Set the node to which this device is being attached.
virtual bool IsLinkUp(void) const
virtual uint32_t GetIfIndex(void) const
uint32_t m_deviceId
Device ID returned by the attached functions.
virtual Address GetMulticast(Ipv4Address multicastGroup) const
Make and return a MAC multicast address using the provided multicast group.
virtual Ptr< Channel > GetChannel(void) const
bool IsSendEnabled(void)
Is the send side of the network device enabled?
void NotifyLinkUp(void)
Notify any interested parties that the link has come up.
TxMachineState
Enumeration of the states of the transmit machine of the net device.
bool Attach(Ptr< CsmaChannel > ch)
Attach the device to a channel.
Ptr< ErrorModel > m_receiveErrorModel
Error model for receive packet events.
virtual bool IsPointToPoint(void) const
Is this a point to point link?
CsmaNetDevice & operator=(const CsmaNetDevice &o)
Operator = is declared but not implemented.
CsmaNetDevice::EncapsulationMode GetEncapsulationMode(void)
Get the encapsulation mode of this device.
@ BUSY
The transmitter is busy transmitting a packet.
TracedCallback< Ptr< const Packet > > m_macPromiscRxTrace
The trace source fired for packets successfully received by the device immediately before being forwa...
Smart pointer class similar to boost::intrusive_ptr.
Class for representing data rates.
void SetReceiveErrorModel(Ptr< ErrorModel > em)
Attach a receive ErrorModel to the CsmaNetDevice.
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 d...
virtual void SetIfIndex(const uint32_t index)
The backoff class is used for calculating backoff times when many net devices can write to the same c...
a polymophic address class
void SetSendEnable(bool enable)
Enable or disable the send side of the network device.
virtual bool IsBridge(void) const
Is this a bridge?
Callback< bool, Ptr< NetDevice >, Ptr< const Packet >, uint16_t, const Address &, const Address &, enum PacketType > PromiscReceiveCallback
NetDevice::PromiscReceiveCallback m_promiscRxCallback
The callback used to notify higher layers that a packet has been received in promiscuous mode.
void SetQueue(Ptr< Queue< Packet > > queue)
Attach a queue to the CsmaNetDevice.
void SetEncapsulationMode(CsmaNetDevice::EncapsulationMode mode)
Set the encapsulation mode of this device.
virtual Address GetBroadcast(void) const
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.
Ptr< Node > m_node
The Node to which this device is attached.
Simulation virtual time values and global simulation resolution.
@ READY
The transmitter is ready to begin transmission of a packet.
@ ILLEGAL
Encapsulation mode not set.
uint32_t m_mtu
The Maximum Transmission Unit.
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...
virtual void SetAddress(Address address)
Set the address of this interface.
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_phyTxBeginTrace
The trace source fired when a packet begins the transmission process on the medium.
virtual Ptr< Node > GetNode(void) const
Get the node to which this device is attached.
virtual bool NeedsArp(void) const
Does this device need to use the address resolution protocol?
virtual void DoDispose(void)
Perform any object release functionality required to break reference cycles in reference counted obje...
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.
TracedCallback< Ptr< const Packet > > m_phyTxEndTrace
The trace source fired when a packet ends the transmission process on the medium.
@ LLC
802.2 LLC/SNAP Packet
CsmaNetDevice()
Construct a CsmaNetDevice.
void Receive(Ptr< Packet > p, Ptr< CsmaNetDevice > sender)
Receive a packet from a connected CsmaChannel.
Ptr< Queue< Packet > > GetQueue(void) const
Get a copy of the attached Queue.
void TransmitCompleteEvent(void)
Stop Sending a Packet Down the Wire and Begin the Interframe Gap.
virtual void AddLinkChangeCallback(Callback< void > callback)
Ptr< Packet > m_currentPkt
Next packet that will be transmitted (if transmitter is not currently transmitting) or packet that is...
bool m_receiveEnable
Enable net device to receive packets.
virtual Address GetAddress(void) const
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_macRxDropTrace
The trace source fired for packets successfully received by the device but dropped before being forwa...
@ DIX
DIX II / Ethernet II packet.
virtual bool IsBroadcast(void) const
A Device for a Csma Network Link.
void SetInterframeGap(Time t)
Set the interframe gap used to separate packets.
Forward calls to a chain of Callback.
void TransmitReadyEvent(void)
Cause the Transmitter to Become Ready to Send Another Packet.
virtual void SetPromiscReceiveCallback(PromiscReceiveCallback cb)
NetDevice::ReceiveCallback m_rxCallback
The callback used to notify higher layers that a packet has been received.
TracedCallback< Ptr< const Packet > > m_macRxTrace
The trace source fired for packets successfully received by the device immediately before being forwa...
@ GAP
The transmitter is in the interframe gap time.
TracedCallback< Ptr< const Packet > > m_phyRxEndTrace
The trace source fired when a packet ends the reception process from the medium.
TracedCallback m_linkChangeCallbacks
List of callbacks to fire if the link changes state (up or down).
void TransmitAbort(void)
Aborts the transmission of the current packet.
virtual void SetReceiveCallback(NetDevice::ReceiveCallback cb)
Set the callback to be used to notify higher layers when a packet has been received.
virtual uint16_t GetMtu(void) const
static TypeId GetTypeId(void)
Get the type ID.
void Init(bool sendEnable, bool receiveEnable)
Initialization function used during object construction.
Time m_tInterframeGap
The interframe gap that the Net Device uses insert time between packet transmission.
static const uint16_t DEFAULT_MTU
Default Maximum Transmission Unit (MTU) for the CsmaNetDevice.
virtual bool IsMulticast(void) const
bool IsReceiveEnabled(void)
Is the receive side of the network device enabled?
TracedCallback< Ptr< const Packet > > m_promiscSnifferTrace
A trace source that emulates a promiscuous mode protocol sniffer connected to the device.
bool m_linkUp
Flag indicating whether or not the link is up.
Network layer to device interface.