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