23 #include "ns3/packet.h"
25 #include "ns3/pointer.h"
26 #include "ns3/error-model.h"
27 #include "ns3/trace-source-accessor.h"
28 #include "ns3/boolean.h"
30 #include "ns3/simulator.h"
31 #include "ns3/drop-tail-queue.h"
58 void Print (std::ostream &os)
const;
74 .AddConstructor<SimpleTag> ()
161 .AddConstructor<SimpleNetDevice> ()
162 .AddAttribute (
"ReceiveErrorModel",
163 "The receiver error model used to simulate packet loss",
166 MakePointerChecker<ErrorModel> ())
167 .AddAttribute (
"PointToPointMode",
168 "The device is configured in Point to Point mode",
171 MakeBooleanChecker ())
172 .AddAttribute (
"TxQueue",
173 "A queue to use as the transmit queue in the device.",
176 MakePointerChecker<Queue> ())
177 .AddAttribute (
"DataRate",
178 "The default data rate for point to point links. Zero means infinite",
181 MakeDataRateChecker ())
182 .AddTraceSource (
"PhyRxDrop",
183 "Trace source indicating a packet has been dropped by the device during reception",
416 if (
m_queue->GetNPackets () == 1)
425 m_channel->Send (p, protocolNumber, to, from,
this);
432 m_channel->Send (packet, protocolNumber, to, from,
this);
442 if (
m_queue->GetNPackets () == 0)
456 m_channel->Send (packet, proto, dst, src,
this);
virtual Address GetAddress(void) const
virtual bool Send(Ptr< Packet > packet, const Address &dest, uint16_t protocolNumber)
void Write(const uint8_t *buffer, uint32_t size)
Simulation virtual time values and global simulation resolution.
EventId TransmitCompleteEvent
the Tx Complete event
#define NS_LOG_FUNCTION(parameters)
If log level LOG_FUNCTION is enabled, this macro will output all input parameters separated by "...
Packet addressed to someone else.
#define NS_OBJECT_ENSURE_REGISTERED(type)
Register the class in the ns-3 factory.
Ptr< Node > m_node
Node this netDevice is associated to.
virtual TypeId GetInstanceTypeId(void) const
virtual Ptr< Channel > GetChannel(void) const
uint16_t m_protocolNumber
TracedCallback m_linkChangeCallbacks
List of callbacks to fire if the link changes state (up or down).
void AddPacketTag(const Tag &tag) const
Add a packet tag.
void Receive(Ptr< Packet > packet, uint16_t protocol, Mac48Address to, Mac48Address from)
Receive a packet from a connected SimpleChannel.
bool IsNull(void) const
Check for null implementation.
#define NS_LOG_COMPONENT_DEFINE(name)
Define a Log component with a specific name.
uint32_t GetSize(void) const
Returns the the size in bytes of the packet (including the zero-filled initial payload).
bool IsBroadcast(void) const
virtual void SetIfIndex(const uint32_t index)
virtual void DoDispose(void)
This method is called by Object::Dispose or by the object's destructor, whichever comes first...
bool IsRunning(void) const
This method is syntactic sugar for the ns3::Simulator::isExpired method.
virtual bool IsBroadcast(void) const
virtual bool NeedsArp(void) const
static EventId Schedule(Time const &time, MEM mem_ptr, OBJ obj)
Schedule an event to expire at the relative time "time" is reached.
bool m_pointToPointMode
Flag indicating whether or not the NetDevice is a Point to Point model.
void SetProto(uint16_t proto)
virtual bool IsMulticast(void) const
a polymophic address class
bool m_linkUp
Flag indicating whether or not the link is up.
Class for representing data rates.
virtual void SetNode(Ptr< Node > node)
void CopyTo(uint8_t buffer[6]) const
double CalculateTxTime(uint32_t bytes) const
Calculate transmission time.
void SetDst(Mac48Address dst)
static Mac48Address GetMulticast(Ipv4Address address)
virtual void SetPromiscReceiveCallback(PromiscReceiveCallback cb)
virtual bool SetMtu(const uint16_t mtu)
This device assumes 48-bit mac addressing; there is also the possibility to add an ErrorModel if you ...
virtual bool IsPointToPoint(void) const
Return true if the net device is on a point-to-point link.
Mac48Address m_address
MAC address.
Ptr< Queue > m_queue
The Queue for outgoing packets.
Mac48Address GetSrc(void) const
TAG_BUFFER_INLINE void WriteU16(uint16_t v)
Internal tag to store source, destination and protocol of each packet.
virtual void Serialize(TagBuffer i) const
static Mac48Address ConvertFrom(const Address &address)
Ptr< Packet > Copy(void) const
performs a COW copy of the packet.
tag a set of bytes in a packet
virtual Address GetMulticast(Ipv4Address multicastGroup) const
Make and return a MAC multicast address using the provided multicast group.
Ptr< const TraceSourceAccessor > MakeTraceSourceAccessor(T a)
virtual void SetReceiveCallback(NetDevice::ReceiveCallback cb)
virtual uint16_t GetMtu(void) const
void SetReceiveErrorModel(Ptr< ErrorModel > em)
Attach a receive ErrorModel to the SimpleNetDevice.
void CopyFrom(const uint8_t buffer[6])
virtual Ptr< Node > GetNode(void) const
NetDevice::PromiscReceiveCallback m_promiscCallback
Promiscuous receive callback.
uint16_t GetProto(void) const
Mac48Address GetDst(void) const
Describes an IPv6 address.
Ipv4 addresses are stored in host order in this class.
TracedCallback< Ptr< const Packet > > m_phyRxDropTrace
The trace source fired when the phy layer drops a packet it has received due to the error model being...
void SetSrc(Mac48Address src)
void ConnectWithoutContext(const CallbackBase &callback)
Network layer to device interface.
virtual void AddLinkChangeCallback(Callback< void > callback)
hold objects of type ns3::DataRate
bool RemovePacketTag(Tag &tag)
Remove a packet tag.
virtual void SetAddress(Address address)
Set the address of this interface.
Time Seconds(double value)
Construct a Time in the indicated unit.
Ptr< ErrorModel > m_receiveErrorModel
Receive error model.
void Cancel(void)
This method is syntactic sugar for the ns3::Simulator::cancel method.
void Read(uint8_t *buffer, uint32_t size)
virtual void DoDispose(void)
This method is called by Object::Dispose or by the object's destructor, whichever comes first...
virtual bool SendFrom(Ptr< Packet > packet, const Address &source, const Address &dest, uint16_t protocolNumber)
NetDevice::ReceiveCallback m_rxCallback
Receive callback.
TAG_BUFFER_INLINE uint16_t ReadU16(void)
Ptr< SimpleChannel > m_channel
the channel the device is connected to
virtual void Deserialize(TagBuffer i)
void TransmitComplete(void)
The TransmitComplete method is used internally to finish the process of sending a packet out on the c...
PacketType
Packet types are used as they are in Linux.
void SetQueue(Ptr< Queue > queue)
Attach a queue to the SimpleNetDevice.
virtual bool IsBridge(void) const
Return true if the net device is acting as a bridge.
void SetChannel(Ptr< SimpleChannel > channel)
Attach a channel to this net device.
Packet addressed to multicast group.
Ptr< Queue > GetQueue(void) const
Get a copy of the attached Queue.
DataRate m_bps
The device nominal Data rate.
a unique identifier for an interface.
virtual Address GetBroadcast(void) const
TypeId SetParent(TypeId tid)
void Print(std::ostream &os) const
virtual uint32_t GetIfIndex(void) const
static TypeId GetTypeId(void)
static TypeId GetTypeId(void)
Get the type ID.
virtual bool SupportsSendFrom(void) const
virtual bool IsLinkUp(void) const
virtual uint32_t GetSerializedSize(void) const
uint32_t m_ifIndex
Interface index.