|
A Discrete-Event Network Simulator
|
API
|
Go to the documentation of this file.
22 #include "ns3/queue.h"
23 #include "ns3/simulator.h"
25 #include "ns3/boolean.h"
26 #include "ns3/uinteger.h"
27 #include "ns3/pointer.h"
28 #include "ns3/channel.h"
29 #include "ns3/trace-source-accessor.h"
32 #include "ns3/llc-snap-header.h"
69 .SetGroupName (
"Spectrum")
71 .AddAttribute (
"Address",
72 "The MAC address of this device.",
76 .AddAttribute (
"Queue",
77 "packets being transmitted get queued here",
80 MakePointerChecker<Queue<Packet> > ())
81 .AddAttribute (
"Mtu",
"The Maximum Transmission Unit",
85 MakeUintegerChecker<uint16_t> (1,65535))
86 .AddAttribute (
"Phy",
"The PHY layer attached to this device.",
90 MakePointerChecker<Object> ())
91 .AddTraceSource (
"MacTx",
92 "Trace source indicating a packet has arrived "
93 "for transmission by this device",
95 "ns3::Packet::TracedCallback")
96 .AddTraceSource (
"MacTxDrop",
97 "Trace source indicating a packet has been dropped "
98 "by the device before transmission",
100 "ns3::Packet::TracedCallback")
101 .AddTraceSource (
"MacPromiscRx",
102 "A packet has been received by this device, has been "
103 "passed up from the physical layer "
104 "and is being forwarded up the local protocol stack. "
105 "This is a promiscuous trace,",
107 "ns3::Packet::TracedCallback")
108 .AddTraceSource (
"MacRx",
109 "A packet has been received by this device, "
110 "has been passed up from the physical layer "
111 "and is being forwarded up the local protocol stack. "
112 "This is a non-promiscuous trace,",
114 "ns3::Packet::TracedCallback")
374 NS_LOG_LOGIC (
"new packet is head of queue, starting TX immediately");
381 if (
m_queue->Enqueue (packet) ==
false)
392 if (
m_queue->Enqueue (packet) ==
false)
435 if (
m_queue->IsEmpty () ==
false)
virtual uint32_t GetIfIndex(void) const
a unique identifier for an interface.
@ PACKET_BROADCAST
Packet addressed to all.
#define NS_LOG_COMPONENT_DEFINE(name)
Define a Log component with a specific name.
void NotifyReceptionEndOk(Ptr< Packet > p)
Notify the MAC that the PHY finished a reception successfully.
virtual void SetReceiveCallback(NetDevice::ReceiveCallback cb)
#define NS_OBJECT_ENSURE_REGISTERED(type)
Register an Object subclass with the TypeId system.
#define NS_ASSERT(condition)
At runtime, in debugging builds, if this condition is not true, the program prints the source file,...
virtual Address GetMulticast(Ipv4Address addr) const
Make and return a MAC multicast address using the provided multicast group.
static Mac48Address GetMulticast(Ipv4Address address)
Ptr< const AttributeAccessor > MakeMac48AddressAccessor(T1 a1)
Create an AttributeAccessor for a class data member, or a lone class get functor or set method.
virtual bool IsPointToPoint(void) const
Return true if the net device is on a point-to-point link.
virtual bool SendFrom(Ptr< Packet > packet, const Address &source, const Address &dest, uint16_t protocolNumber)
void AddHeader(const Header &header)
Add header to this packet.
Every class exported by the ns3 library is enclosed in the ns3 namespace.
virtual uint16_t GetMtu(void) const
uint32_t m_ifIndex
Interface index.
virtual bool Send(Ptr< Packet > packet, const Address &dest, uint16_t protocolNumber)
bool IsNull(void) const
Check for null implementation.
void ConnectWithoutContext(const CallbackBase &callback)
Append a Callback to the chain (without a context).
void NotifyReceptionEndError()
Notify the MAC that the PHY finished a reception with an error.
virtual bool IsMulticast(void) const
State m_state
State of the NetDevice.
#define NS_LOG_WARN(msg)
Use NS_LOG to output a message of level LOG_WARN.
virtual bool SetMtu(const uint16_t mtu)
virtual void SetAddress(Address address)
Set the address of this interface.
void NotifyTransmissionEnd(Ptr< const Packet >)
Notify the MAC that the PHY has finished a previously started transmission.
Ipv4 addresses are stored in host order in this class.
Describes an IPv6 address.
@ PACKET_HOST
Packet addressed oo us.
Hold objects of type Ptr<T>.
AttributeValue implementation for Mac48Address.
TracedCallback< Ptr< const Packet > > m_macRxTrace
Rx trace.
TypeId SetParent(TypeId tid)
Set the parent TypeId.
virtual void SetPromiscReceiveCallback(PromiscReceiveCallback cb)
Ptr< const TraceSourceAccessor > MakeTraceSourceAccessor(T a)
Create a TraceSourceAccessor which will control access to the underlying trace source.
Mac48Address m_address
MAC address.
State
State of the NetDevice.
virtual Address GetAddress(void) const
Ptr< const AttributeChecker > MakeMac48AddressChecker(void)
Smart pointer class similar to boost::intrusive_ptr.
Ptr< Node > m_node
Node owning this NetDevice.
void SetChannel(Ptr< Channel > c)
This class doesn't talk directly with the underlying channel (a dedicated PHY class is expected to do...
@ PACKET_OTHERHOST
Packet addressed to someone else.
virtual bool NeedsArp(void) const
@ IDLE
Channel is IDLE, no packet is being transmitted.
virtual void SetNode(Ptr< Node > node)
a polymophic address class
static Mac48Address ConvertFrom(const Address &address)
virtual Ptr< Channel > GetChannel(void) const
bool IsBroadcast(void) const
TracedCallback< Ptr< const Packet > > m_macTxDropTrace
Tx Drop trace.
uint32_t RemoveHeader(Header &header)
Deserialize and remove the header from the internal buffer.
Ptr< Channel > m_channel
Channel.
virtual bool IsLinkUp(void) const
Ptr< Object > GetPhy() const
virtual bool IsBroadcast(void) const
void StartTransmission()
start the transmission of a packet by contacting the PHY layer
void SetPhy(Ptr< Object > phy)
Set the Phy object which is attached to this device.
#define NS_ASSERT_MSG(condition, message)
At runtime, in debugging builds, if this condition is not true, the program prints the message to out...
uint32_t m_mtu
NetDevice MTU.
#define NS_LOG_LOGIC(msg)
Use NS_LOG to output a message of level LOG_LOGIC.
virtual Ptr< Node > GetNode(void) const
Ptr< const AttributeAccessor > MakePointerAccessor(T1 a1)
Create an AttributeAccessor for a class data member, or a lone class get functor or set method.
bool m_linkUp
true if the link is up
NetDevice::ReceiveCallback m_rxCallback
Rx callback.
virtual bool SupportsSendFrom(void) const
static TypeId GetTypeId(void)
Get the type ID.
Ptr< Packet > m_currentPkt
Current packet.
virtual void SetIfIndex(const uint32_t index)
TracedCallback m_linkChangeCallbacks
List of callbacks to fire if the link changes state (up or down).
Ptr< Packet > Copy(void) const
performs a COW copy of the packet.
TracedCallback< Ptr< const Packet > > m_macTxTrace
Tx trace.
void SetGenericPhyTxStartCallback(GenericPhyTxStartCallback c)
set the callback used to instruct the lower layer to start a TX
#define NS_LOG_FUNCTION(parameters)
If log level LOG_FUNCTION is enabled, this macro will output all input parameters separated by ",...
Ptr< Object > m_phy
PHY object.
virtual ~AlohaNoackNetDevice()
PacketType
Packet types are used as they are in Linux.
virtual void AddLinkChangeCallback(Callback< void > callback)
Hold an unsigned integer type.
virtual void SetQueue(Ptr< Queue< Packet > > queue)
set the queue which is going to be used by this device
GenericPhyTxStartCallback m_phyMacTxStartCallback
Tx Start callback.
Ptr< const AttributeAccessor > MakeUintegerAccessor(T1 a1)
Create an AttributeAccessor for a class data member, or a lone class get functor or set method.
Ptr< Queue< Packet > > m_queue
packet queue
This devices implements the following features:
std::ostream & operator<<(std::ostream &os, const Angles &a)
NetDevice::PromiscReceiveCallback m_promiscRxCallback
Promiscuous Rx callback.
virtual Address GetBroadcast(void) const
void NotifyReceptionStart()
Notify the MAC that the PHY has started a reception.
virtual void DoDispose(void)
Destructor implementation.
static EventId ScheduleNow(FUNC f, Ts &&... args)
Schedule an event to expire Now.
TracedCallback< Ptr< const Packet > > m_macPromiscRxTrace
Promiscuous Rx trace.
virtual bool IsBridge(void) const
Return true if the net device is acting as a bridge.
Network layer to device interface.
virtual void DoDispose(void)
Destructor implementation.
@ PACKET_MULTICAST
Packet addressed to multicast group.