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"
63 .AddConstructor<AlohaNoackNetDevice> ()
64 .AddAttribute (
"Address",
65 "The MAC address of this device.",
69 .AddAttribute (
"Queue",
70 "packets being transmitted get queued here",
73 MakePointerChecker<Queue> ())
74 .AddAttribute (
"Mtu",
"The Maximum Transmission Unit",
78 MakeUintegerChecker<uint16_t> (1,65535))
79 .AddAttribute (
"Phy",
"The PHY layer attached to this device.",
83 MakePointerChecker<Object> ())
84 .AddTraceSource (
"MacTx",
85 "Trace source indicating a packet has arrived "
86 "for transmission by this device",
88 "ns3::Packet::TracedCallback")
89 .AddTraceSource (
"MacTxDrop",
90 "Trace source indicating a packet has been dropped "
91 "by the device before transmission",
93 "ns3::Packet::TracedCallback")
94 .AddTraceSource (
"MacPromiscRx",
95 "A packet has been received by this device, has been "
96 "passed up from the physical layer "
97 "and is being forwarded up the local protocol stack. "
98 "This is a promiscuous trace,",
100 "ns3::Packet::TracedCallback")
101 .AddTraceSource (
"MacRx",
102 "A packet has been received by this device, "
103 "has been passed up from the physical layer "
104 "and is being forwarded up the local protocol stack. "
105 "This is a non-promiscuous trace,",
107 "ns3::Packet::TracedCallback")
367 NS_LOG_LOGIC (
"new packet is head of queue, starting TX immediately");
374 if (
m_queue->Enqueue (packet) ==
false)
385 if (
m_queue->Enqueue (packet) ==
false)
428 if (
m_queue->IsEmpty () ==
false)
uint32_t RemoveHeader(Header &header)
Deserialize and remove the header from the internal buffer.
virtual void SetIfIndex(const uint32_t index)
Smart pointer class similar to boost::intrusive_ptr.
#define NS_LOG_FUNCTION(parameters)
If log level LOG_FUNCTION is enabled, this macro will output all input parameters separated by "...
void NotifyReceptionStart()
Notify the MAC that the PHY has started a reception.
#define NS_OBJECT_ENSURE_REGISTERED(type)
Register an Object subclass with the TypeId system.
virtual bool IsBridge(void) const
Return true if the net device is acting as a bridge.
virtual bool SendFrom(Ptr< Packet > packet, const Address &source, const Address &dest, uint16_t protocolNumber)
virtual Address GetMulticast(Ipv4Address addr) const
Make and return a MAC multicast address using the provided multicast group.
void SetGenericPhyTxStartCallback(GenericPhyTxStartCallback c)
set the callback used to instruct the lower layer to start a TX
virtual Address GetBroadcast(void) const
bool IsNull(void) const
Check for null implementation.
#define NS_ASSERT(condition)
At runtime, in debugging builds, if this condition is not true, the program prints the source file...
PacketType
Packet types are used as they are in Linux.
TracedCallback< Ptr< const Packet > > m_macTxDropTrace
Channel is IDLE, no packet is being transmitted.
#define NS_LOG_COMPONENT_DEFINE(name)
Define a Log component with a specific name.
virtual bool IsPointToPoint(void) const
Return true if the net device is on a point-to-point link.
TracedCallback< Ptr< const Packet > > m_macPromiscRxTrace
bool IsBroadcast(void) const
virtual void AddLinkChangeCallback(Callback< void > callback)
virtual void DoDispose(void)
Destructor implementation.
Ptr< const AttributeChecker > MakeMac48AddressChecker(void)
Packet addressed to multicast group.
Ptr< const AttributeAccessor > MakeMac48AddressAccessor(T1 a1)
Create an AttributeAccessor for a class data member, or a lone class get functor or set method...
TracedCallback m_linkChangeCallbacks
List of callbacks to fire if the link changes state (up or down).
a polymophic address class
Ptr< const TraceSourceAccessor > MakeTraceSourceAccessor(T a)
Create a TraceSourceAccessor which will control access to the underlying trace source.
virtual Ptr< Node > GetNode(void) const
void NotifyReceptionEndOk(Ptr< Packet > p)
Notify the MAC that the PHY finished a reception successfully.
GenericPhyTxStartCallback m_phyMacTxStartCallback
Ptr< const AttributeAccessor > MakePointerAccessor(T1 a1)
Create an AttributeAccessor for a class data member, or a lone class get functor or set method...
static Mac48Address GetMulticast(Ipv4Address address)
virtual void SetReceiveCallback(NetDevice::ReceiveCallback cb)
Hold an unsigned integer type.
virtual uint16_t GetMtu(void) const
virtual bool IsBroadcast(void) const
void NotifyTransmissionEnd(Ptr< const Packet >)
Notify the MAC that the PHY has finished a previously started transmission.
virtual bool SetMtu(const uint16_t mtu)
#define NS_LOG_LOGIC(msg)
Use NS_LOG to output a message of level LOG_LOGIC.
static Mac48Address ConvertFrom(const Address &address)
virtual void DoDispose(void)
Destructor implementation.
TracedCallback< Ptr< const Packet > > m_macRxTrace
std::ostream & operator<<(std::ostream &os, const Angles &a)
print a struct Angles to output
Ptr< Packet > Copy(void) const
performs a COW copy of the packet.
virtual bool IsLinkUp(void) const
Every class exported by the ns3 library is enclosed in the ns3 namespace.
Hold objects of type Ptr.
virtual bool SupportsSendFrom(void) const
TracedCallback< Ptr< const Packet > > m_macTxTrace
void SetChannel(Ptr< Channel > c)
This class doesn't talk directly with the underlying channel (a dedicated PHY class is expected to do...
static TypeId GetTypeId(void)
void StartTransmission()
start the transmission of a packet by contacting the PHY layer
Packet addressed to someone else.
virtual bool NeedsArp(void) const
Ptr< Object > GetPhy() const
static EventId ScheduleNow(MEM mem_ptr, OBJ obj)
Schedule an event to expire Now.
virtual void SetQueue(Ptr< Queue > queue)
set the queue which is going to be used by this device
virtual bool IsMulticast(void) const
NetDevice::PromiscReceiveCallback m_promiscRxCallback
#define NS_ASSERT_MSG(condition, message)
At runtime, in debugging builds, if this condition is not true, the program prints the message to out...
void NotifyReceptionEndError()
Notify the MAC that the PHY finished a reception with an error.
Describes an IPv6 address.
Ipv4 addresses are stored in host order in this class.
Ptr< Packet > m_currentPkt
void ConnectWithoutContext(const CallbackBase &callback)
Append a Callback to the chain (without a context).
Network layer to device interface.
#define NS_LOG_WARN(msg)
Use NS_LOG to output a message of level LOG_WARN.
AttributeValue implementation for Mac48Address.
void SetPhy(Ptr< Object > phy)
Set the Phy object which is attached to this device.
virtual ~AlohaNoackNetDevice()
virtual bool Send(Ptr< Packet > packet, const Address &dest, uint16_t protocolNumber)
Ptr< const AttributeAccessor > MakeUintegerAccessor(T1 a1)
Create an AttributeAccessor for a class data member, or a lone class get functor or set method...
a unique identifier for an interface.
virtual void SetPromiscReceiveCallback(PromiscReceiveCallback cb)
virtual uint32_t GetIfIndex(void) const
TypeId SetParent(TypeId tid)
virtual void SetNode(Ptr< Node > node)
NetDevice::ReceiveCallback m_rxCallback
void AddHeader(const Header &header)
Add header to this packet.
virtual Ptr< Channel > GetChannel(void) const
virtual Address GetAddress(void) const
virtual void SetAddress(Address address)
Set the address of this interface.