|
A Discrete-Event Network Simulator
|
API
|
Go to the documentation of this file.
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"
29 #include "ns3/string.h"
31 #include "ns3/simulator.h"
32 #include "ns3/queue.h"
87 void Print (std::ostream &os)
const;
103 .SetGroupName(
"Network")
191 .SetGroupName(
"Network")
193 .AddAttribute (
"ReceiveErrorModel",
194 "The receiver error model used to simulate packet loss",
197 MakePointerChecker<ErrorModel> ())
198 .AddAttribute (
"PointToPointMode",
199 "The device is configured in Point to Point mode",
203 .AddAttribute (
"TxQueue",
204 "A queue to use as the transmit queue in the device.",
207 MakePointerChecker<Queue<Packet> > ())
208 .AddAttribute (
"DataRate",
209 "The default data rate for point to point links. Zero means infinite",
213 .AddTraceSource (
"PhyRxDrop",
214 "Trace source indicating a packet has been dropped "
215 "by the device during reception",
217 "ns3::Packet::TracedCallback")
461 if (
m_queue->GetNPackets () == 0)
466 "Tried to transmit a packet while another transmission was in progress");
499 m_channel->Send (packet, proto, dst, src,
this);
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.
virtual bool IsPointToPoint(void) const
Return true if the net device is on a point-to-point link.
AttributeValue implementation for DataRate.
Mac48Address GetSrc(void) const
Get the source address.
virtual void Serialize(TagBuffer i) const
#define NS_OBJECT_ENSURE_REGISTERED(type)
Register an Object subclass with the TypeId system.
AttributeValue implementation for Boolean.
static Mac48Address GetMulticast(Ipv4Address address)
Time CalculateBytesTxTime(uint32_t bytes) const
Calculate transmission time.
virtual void SetPromiscReceiveCallback(PromiscReceiveCallback cb)
virtual bool IsLinkUp(void) const
virtual uint16_t GetMtu(void) const
uint32_t GetSize(void) const
Returns the the size in bytes of the packet (including the zero-filled initial payload).
Every class exported by the ns3 library is enclosed in the ns3 namespace.
bool IsNull(void) const
Check for null implementation.
void ConnectWithoutContext(const CallbackBase &callback)
Append a Callback to the chain (without a context).
Ptr< const AttributeAccessor > MakeDataRateAccessor(T1 a1)
Create an AttributeAccessor for a class data member, or a lone class get functor or set method.
void FinishTransmission(Ptr< Packet > packet)
The FinishTransmission method is used internally to finish the process of sending a packet out on the...
virtual bool SendFrom(Ptr< Packet > packet, const Address &source, const Address &dest, uint16_t protocolNumber)
virtual TypeId GetInstanceTypeId(void) const
Get the most derived TypeId for this Object.
virtual bool IsBroadcast(void) const
SimpleNetDevice tag to store source, destination and protocol of each packet.
void SetProto(uint16_t proto)
Set the protocol number.
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>.
void SetChannel(Ptr< SimpleChannel > channel)
Attach a channel to this net device.
virtual bool Send(Ptr< Packet > packet, const Address &dest, uint16_t protocolNumber)
virtual bool SetMtu(const uint16_t mtu)
TracedCallback m_linkChangeCallbacks
List of callbacks to fire if the link changes state (up or down).
virtual void Deserialize(TagBuffer i)
static EventId Schedule(Time const &delay, FUNC f, Ts &&... args)
Schedule an event to expire after delay.
Ptr< const AttributeAccessor > MakeBooleanAccessor(T1 a1)
Create an AttributeAccessor for a class data member, or a lone class get functor or set method.
void StartTransmission(void)
The StartTransmission method is used internally to start the process of sending a packet out on the c...
TypeId SetParent(TypeId tid)
Set the parent TypeId.
virtual void SetAddress(Address address)
Set the address of this interface.
Ptr< const TraceSourceAccessor > MakeTraceSourceAccessor(T a)
Create a TraceSourceAccessor which will control access to the underlying trace source.
virtual void SetIfIndex(const uint32_t index)
Mac48Address GetDst(void) const
Get the destination address.
virtual Address GetBroadcast(void) const
Class for representing data rates.
EventId FinishTransmissionEvent
the Tx Complete event
bool IsRunning(void) const
This method is syntactic sugar for !IsExpired().
virtual Address GetAddress(void) const
virtual void AddLinkChangeCallback(Callback< void > callback)
@ PACKET_OTHERHOST
Packet addressed to someone else.
void Write(const uint8_t *buffer, uint32_t size)
TAG_BUFFER_INLINE uint16_t ReadU16(void)
uint16_t m_protocolNumber
protocol number
tag a set of bytes in a packet
a polymophic address class
static Mac48Address ConvertFrom(const Address &address)
bool IsBroadcast(void) const
Ptr< Queue< Packet > > m_queue
The Queue for outgoing packets.
virtual uint32_t GetSerializedSize(void) const
virtual bool SupportsSendFrom(void) const
void Cancel(void)
This method is syntactic sugar for the ns3::Simulator::Cancel method.
virtual bool IsMulticast(void) const
Ptr< const AttributeChecker > MakeBooleanChecker(void)
Ptr< SimpleChannel > m_channel
the channel the device is connected to
virtual bool NeedsArp(void) const
Simulation virtual time values and global simulation resolution.
virtual Ptr< Channel > GetChannel(void) const
#define NS_ASSERT_MSG(condition, message)
At runtime, in debugging builds, if this condition is not true, the program prints the message to out...
virtual void DoDispose(void)
Destructor implementation.
Ptr< Queue< Packet > > GetQueue(void) const
Get a copy of the attached Queue.
This device assumes 48-bit mac addressing; there is also the possibility to add an ErrorModel if you ...
void SetDst(Mac48Address dst)
Set the destination address.
void SetSrc(Mac48Address src)
Set the source address.
virtual bool IsBridge(void) const
Return true if the net device is acting as a bridge.
static TypeId GetTypeId(void)
Get the type ID.
void SetQueue(Ptr< Queue< Packet > > queue)
Attach a queue to the SimpleNetDevice.
Ptr< const AttributeAccessor > MakePointerAccessor(T1 a1)
Create an AttributeAccessor for a class data member, or a lone class get functor or set method.
Hold variables of type string.
void AddPacketTag(const Tag &tag) const
Add a packet tag.
virtual void SetNode(Ptr< Node > node)
static TypeId GetTypeId(void)
Get the type ID.
Mac48Address m_src
source address
bool m_pointToPointMode
Flag indicating whether or not the NetDevice is a Point to Point model.
void Read(uint8_t *buffer, uint32_t size)
virtual Address GetMulticast(Ipv4Address multicastGroup) const
Make and return a MAC multicast address using the provided multicast group.
bool RemovePacketTag(Tag &tag)
Remove a packet tag.
bool m_linkUp
Flag indicating whether or not the link is up.
#define NS_LOG_FUNCTION(parameters)
If log level LOG_FUNCTION is enabled, this macro will output all input parameters separated by ",...
DataRate m_bps
The device nominal Data rate.
Mac48Address m_address
MAC address.
NetDevice::ReceiveCallback m_rxCallback
Receive callback.
void Receive(Ptr< Packet > packet, uint16_t protocol, Mac48Address to, Mac48Address from)
Receive a packet from a connected SimpleChannel.
Mac48Address m_dst
destination address
virtual Ptr< Node > GetNode(void) const
PacketType
Packet types are used as they are in Linux.
void(* Time)(Time oldValue, Time newValue)
TracedValue callback signature for Time.
void CopyTo(uint8_t buffer[6]) const
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...
Ptr< ErrorModel > m_receiveErrorModel
Receive error model.
TAG_BUFFER_INLINE void WriteU16(uint16_t v)
void CopyFrom(const uint8_t buffer[6])
virtual void SetReceiveCallback(NetDevice::ReceiveCallback cb)
uint16_t GetProto(void) const
Get the protocol number.
NetDevice::PromiscReceiveCallback m_promiscCallback
Promiscuous receive callback.
virtual uint32_t GetIfIndex(void) const
void Print(std::ostream &os) const
uint32_t m_ifIndex
Interface index.
virtual void DoDispose(void)
Destructor implementation.
Ptr< const AttributeChecker > MakeDataRateChecker(void)
void SetReceiveErrorModel(Ptr< ErrorModel > em)
Attach a receive ErrorModel to the SimpleNetDevice.
Ptr< Node > m_node
Node this netDevice is associated to.
Network layer to device interface.
@ PACKET_MULTICAST
Packet addressed to multicast group.