A Discrete-Event Network Simulator
API
point-to-point-net-device.cc
Go to the documentation of this file.
1 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
2 /*
3  * Copyright (c) 2007, 2008 University of Washington
4  *
5  * This program is free software; you can redistribute it and/or modify
6  * it under the terms of the GNU General Public License version 2 as
7  * published by the Free Software Foundation;
8  *
9  * This program is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12  * GNU General Public License for more details.
13  *
14  * You should have received a copy of the GNU General Public License
15  * along with this program; if not, write to the Free Software
16  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17  */
18 
19 #include "ns3/log.h"
20 #include "ns3/queue.h"
21 #include "ns3/simulator.h"
22 #include "ns3/mac48-address.h"
23 #include "ns3/llc-snap-header.h"
24 #include "ns3/error-model.h"
25 #include "ns3/trace-source-accessor.h"
26 #include "ns3/uinteger.h"
27 #include "ns3/pointer.h"
29 #include "point-to-point-channel.h"
30 #include "ppp-header.h"
31 
32 namespace ns3 {
33 
34 NS_LOG_COMPONENT_DEFINE ("PointToPointNetDevice");
35 
36 NS_OBJECT_ENSURE_REGISTERED (PointToPointNetDevice);
37 
38 TypeId
40 {
41  static TypeId tid = TypeId ("ns3::PointToPointNetDevice")
42  .SetParent<NetDevice> ()
43  .AddConstructor<PointToPointNetDevice> ()
44  .AddAttribute ("Mtu", "The MAC-level Maximum Transmission Unit",
48  MakeUintegerChecker<uint16_t> ())
49  .AddAttribute ("Address",
50  "The MAC address of this device.",
51  Mac48AddressValue (Mac48Address ("ff:ff:ff:ff:ff:ff")),
54  .AddAttribute ("DataRate",
55  "The default data rate for point to point links",
56  DataRateValue (DataRate ("32768b/s")),
59  .AddAttribute ("ReceiveErrorModel",
60  "The receiver error model used to simulate packet loss",
61  PointerValue (),
63  MakePointerChecker<ErrorModel> ())
64  .AddAttribute ("InterframeGap",
65  "The time to wait between packet (frame) transmissions",
66  TimeValue (Seconds (0.0)),
68  MakeTimeChecker ())
69 
70  //
71  // Transmit queueing discipline for the device which includes its own set
72  // of trace hooks.
73  //
74  .AddAttribute ("TxQueue",
75  "A queue to use as the transmit queue in the device.",
76  PointerValue (),
78  MakePointerChecker<Queue> ())
79 
80  //
81  // Trace sources at the "top" of the net device, where packets transition
82  // to/from higher layers.
83  //
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, "
96  "has been 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")
108 #if 0
109  // Not currently implemented for this device
110  .AddTraceSource ("MacRxDrop",
111  "Trace source indicating a packet was dropped "
112  "before being forwarded up the stack",
114  "ns3::Packet::TracedCallback")
115 #endif
116  //
117  // Trace souces at the "bottom" of the net device, where packets transition
118  // to/from the channel.
119  //
120  .AddTraceSource ("PhyTxBegin",
121  "Trace source indicating a packet has begun "
122  "transmitting over the channel",
124  "ns3::Packet::TracedCallback")
125  .AddTraceSource ("PhyTxEnd",
126  "Trace source indicating a packet has been "
127  "completely transmitted over the channel",
129  "ns3::Packet::TracedCallback")
130  .AddTraceSource ("PhyTxDrop",
131  "Trace source indicating a packet has been "
132  "dropped by the device during transmission",
134  "ns3::Packet::TracedCallback")
135 #if 0
136  // Not currently implemented for this device
137  .AddTraceSource ("PhyRxBegin",
138  "Trace source indicating a packet has begun "
139  "being received by the device",
141  "ns3::Packet::TracedCallback")
142 #endif
143  .AddTraceSource ("PhyRxEnd",
144  "Trace source indicating a packet has been "
145  "completely received by the device",
147  "ns3::Packet::TracedCallback")
148  .AddTraceSource ("PhyRxDrop",
149  "Trace source indicating a packet has been "
150  "dropped by the device during reception",
152  "ns3::Packet::TracedCallback")
153 
154  //
155  // Trace sources designed to simulate a packet sniffer facility (tcpdump).
156  // Note that there is really no difference between promiscuous and
157  // non-promiscuous traces in a point-to-point link.
158  //
159  .AddTraceSource ("Sniffer",
160  "Trace source simulating a non-promiscuous packet sniffer "
161  "attached to the device",
163  "ns3::Packet::TracedCallback")
164  .AddTraceSource ("PromiscSniffer",
165  "Trace source simulating a promiscuous packet sniffer "
166  "attached to the device",
168  "ns3::Packet::TracedCallback")
169  ;
170  return tid;
171 }
172 
173 
175  :
176  m_txMachineState (READY),
177  m_channel (0),
178  m_linkUp (false),
179  m_currentPkt (0)
180 {
181  NS_LOG_FUNCTION (this);
182 }
183 
185 {
186  NS_LOG_FUNCTION (this);
187 }
188 
189 void
190 PointToPointNetDevice::AddHeader (Ptr<Packet> p, uint16_t protocolNumber)
191 {
192  NS_LOG_FUNCTION (this << p << protocolNumber);
193  PppHeader ppp;
194  ppp.SetProtocol (EtherToPpp (protocolNumber));
195  p->AddHeader (ppp);
196 }
197 
198 bool
200 {
201  NS_LOG_FUNCTION (this << p << param);
202  PppHeader ppp;
203  p->RemoveHeader (ppp);
204  param = PppToEther (ppp.GetProtocol ());
205  return true;
206 }
207 
208 void
210 {
211  NS_LOG_FUNCTION (this);
212  m_node = 0;
213  m_channel = 0;
215  m_currentPkt = 0;
217 }
218 
219 void
221 {
222  NS_LOG_FUNCTION (this);
223  m_bps = bps;
224 }
225 
226 void
228 {
229  NS_LOG_FUNCTION (this << t.GetSeconds ());
230  m_tInterframeGap = t;
231 }
232 
233 bool
235 {
236  NS_LOG_FUNCTION (this << p);
237  NS_LOG_LOGIC ("UID is " << p->GetUid () << ")");
238 
239  //
240  // This function is called to start the process of transmitting a packet.
241  // We need to tell the channel that we've started wiggling the wire and
242  // schedule an event that will be executed when the transmission is complete.
243  //
244  NS_ASSERT_MSG (m_txMachineState == READY, "Must be READY to transmit");
246  m_currentPkt = p;
248 
249  Time txTime = Seconds (m_bps.CalculateTxTime (p->GetSize ()));
250  Time txCompleteTime = txTime + m_tInterframeGap;
251 
252  NS_LOG_LOGIC ("Schedule TransmitCompleteEvent in " << txCompleteTime.GetSeconds () << "sec");
254 
255  bool result = m_channel->TransmitStart (p, this, txTime);
256  if (result == false)
257  {
258  m_phyTxDropTrace (p);
259  }
260  return result;
261 }
262 
263 void
265 {
266  NS_LOG_FUNCTION (this);
267 
268  //
269  // This function is called to when we're all done transmitting a packet.
270  // We try and pull another packet off of the transmit queue. If the queue
271  // is empty, we are done, otherwise we need to start transmitting the
272  // next packet.
273  //
274  NS_ASSERT_MSG (m_txMachineState == BUSY, "Must be BUSY if transmitting");
276 
277  NS_ASSERT_MSG (m_currentPkt != 0, "PointToPointNetDevice::TransmitComplete(): m_currentPkt zero");
278 
280  m_currentPkt = 0;
281 
282  Ptr<Packet> p = m_queue->Dequeue ();
283  if (p == 0)
284  {
285  //
286  // No packet was on the queue, so we just exit.
287  //
288  return;
289  }
290 
291  //
292  // Got another packet off of the queue, so start the transmit process agin.
293  //
294  m_snifferTrace (p);
296  TransmitStart (p);
297 }
298 
299 bool
301 {
302  NS_LOG_FUNCTION (this << &ch);
303 
304  m_channel = ch;
305 
306  m_channel->Attach (this);
307 
308  //
309  // This device is up whenever it is attached to a channel. A better plan
310  // would be to have the link come up when both devices are attached, but this
311  // is not done for now.
312  //
313  NotifyLinkUp ();
314  return true;
315 }
316 
317 void
319 {
320  NS_LOG_FUNCTION (this << q);
321  m_queue = q;
322 }
323 
324 void
326 {
327  NS_LOG_FUNCTION (this << em);
328  m_receiveErrorModel = em;
329 }
330 
331 void
333 {
334  NS_LOG_FUNCTION (this << packet);
335  uint16_t protocol = 0;
336 
337  if (m_receiveErrorModel && m_receiveErrorModel->IsCorrupt (packet) )
338  {
339  //
340  // If we have an error model and it indicates that it is time to lose a
341  // corrupted packet, don't forward this packet up, let it go.
342  //
343  m_phyRxDropTrace (packet);
344  }
345  else
346  {
347  //
348  // Hit the trace hooks. All of these hooks are in the same place in this
349  // device because it is so simple, but this is not usually the case in
350  // more complicated devices.
351  //
352  m_snifferTrace (packet);
353  m_promiscSnifferTrace (packet);
354  m_phyRxEndTrace (packet);
355 
356  //
357  // Trace sinks will expect complete packets, not packets without some of the
358  // headers.
359  //
360  Ptr<Packet> originalPacket = packet->Copy ();
361 
362  //
363  // Strip off the point-to-point protocol header and forward this packet
364  // up the protocol stack. Since this is a simple point-to-point link,
365  // there is no difference in what the promisc callback sees and what the
366  // normal receive callback sees.
367  //
368  ProcessHeader (packet, protocol);
369 
370  if (!m_promiscCallback.IsNull ())
371  {
372  m_macPromiscRxTrace (originalPacket);
373  m_promiscCallback (this, packet, protocol, GetRemote (), GetAddress (), NetDevice::PACKET_HOST);
374  }
375 
376  m_macRxTrace (originalPacket);
377  m_rxCallback (this, packet, protocol, GetRemote ());
378  }
379 }
380 
383 {
384  NS_LOG_FUNCTION (this);
385  return m_queue;
386 }
387 
388 void
390 {
391  NS_LOG_FUNCTION (this);
392  m_linkUp = true;
394 }
395 
396 void
397 PointToPointNetDevice::SetIfIndex (const uint32_t index)
398 {
399  NS_LOG_FUNCTION (this);
400  m_ifIndex = index;
401 }
402 
403 uint32_t
405 {
406  return m_ifIndex;
407 }
408 
411 {
412  return m_channel;
413 }
414 
415 //
416 // This is a point-to-point device, so we really don't need any kind of address
417 // information. However, the base class NetDevice wants us to define the
418 // methods to get and set the address. Rather than be rude and assert, we let
419 // clients get and set the address, but simply ignore them.
420 
421 void
423 {
424  NS_LOG_FUNCTION (this << address);
426 }
427 
428 Address
430 {
431  return m_address;
432 }
433 
434 bool
436 {
437  NS_LOG_FUNCTION (this);
438  return m_linkUp;
439 }
440 
441 void
443 {
444  NS_LOG_FUNCTION (this);
446 }
447 
448 //
449 // This is a point-to-point device, so every transmission is a broadcast to
450 // all of the devices on the network.
451 //
452 bool
454 {
455  NS_LOG_FUNCTION (this);
456  return true;
457 }
458 
459 //
460 // We don't really need any addressing information since this is a
461 // point-to-point device. The base class NetDevice wants us to return a
462 // broadcast address, so we make up something reasonable.
463 //
464 Address
466 {
467  NS_LOG_FUNCTION (this);
468  return Mac48Address ("ff:ff:ff:ff:ff:ff");
469 }
470 
471 bool
473 {
474  NS_LOG_FUNCTION (this);
475  return true;
476 }
477 
478 Address
480 {
481  NS_LOG_FUNCTION (this);
482  return Mac48Address ("01:00:5e:00:00:00");
483 }
484 
485 Address
487 {
488  NS_LOG_FUNCTION (this << addr);
489  return Mac48Address ("33:33:00:00:00:00");
490 }
491 
492 bool
494 {
495  NS_LOG_FUNCTION (this);
496  return true;
497 }
498 
499 bool
501 {
502  NS_LOG_FUNCTION (this);
503  return false;
504 }
505 
506 bool
508  Ptr<Packet> packet,
509  const Address &dest,
510  uint16_t protocolNumber)
511 {
512  NS_LOG_FUNCTION (this << packet << dest << protocolNumber);
513  NS_LOG_LOGIC ("p=" << packet << ", dest=" << &dest);
514  NS_LOG_LOGIC ("UID is " << packet->GetUid ());
515 
516  //
517  // If IsLinkUp() is false it means there is no channel to send any packet
518  // over so we just hit the drop trace on the packet and return an error.
519  //
520  if (IsLinkUp () == false)
521  {
522  m_macTxDropTrace (packet);
523  return false;
524  }
525 
526  //
527  // Stick a point to point protocol header on the packet in preparation for
528  // shoving it out the door.
529  //
530  AddHeader (packet, protocolNumber);
531 
532  m_macTxTrace (packet);
533 
534  //
535  // We should enqueue and dequeue the packet to hit the tracing hooks.
536  //
537  if (m_queue->Enqueue (packet))
538  {
539  //
540  // If the channel is ready for transition we send the packet right now
541  //
542  if (m_txMachineState == READY)
543  {
544  packet = m_queue->Dequeue ();
545  m_snifferTrace (packet);
546  m_promiscSnifferTrace (packet);
547  return TransmitStart (packet);
548  }
549  return true;
550  }
551 
552  // Enqueue may fail (overflow)
553  m_macTxDropTrace (packet);
554  return false;
555 }
556 
557 bool
559  const Address &source,
560  const Address &dest,
561  uint16_t protocolNumber)
562 {
563  NS_LOG_FUNCTION (this << packet << source << dest << protocolNumber);
564  return false;
565 }
566 
567 Ptr<Node>
569 {
570  return m_node;
571 }
572 
573 void
575 {
576  NS_LOG_FUNCTION (this);
577  m_node = node;
578 }
579 
580 bool
582 {
583  NS_LOG_FUNCTION (this);
584  return false;
585 }
586 
587 void
589 {
590  m_rxCallback = cb;
591 }
592 
593 void
595 {
596  m_promiscCallback = cb;
597 }
598 
599 bool
601 {
602  NS_LOG_FUNCTION (this);
603  return false;
604 }
605 
606 void
608 {
609  NS_LOG_FUNCTION (this << p);
610  Receive (p);
611 }
612 
613 Address
615 {
616  NS_LOG_FUNCTION (this);
617  NS_ASSERT (m_channel->GetNDevices () == 2);
618  for (uint32_t i = 0; i < m_channel->GetNDevices (); ++i)
619  {
620  Ptr<NetDevice> tmp = m_channel->GetDevice (i);
621  if (tmp != this)
622  {
623  return tmp->GetAddress ();
624  }
625  }
626  NS_ASSERT (false);
627  // quiet compiler.
628  return Address ();
629 }
630 
631 bool
633 {
634  NS_LOG_FUNCTION (this << mtu);
635  m_mtu = mtu;
636  return true;
637 }
638 
639 uint16_t
641 {
642  NS_LOG_FUNCTION (this);
643  return m_mtu;
644 }
645 
646 uint16_t
648 {
650  switch(proto)
651  {
652  case 0x0021: return 0x0800; //IPv4
653  case 0x0057: return 0x86DD; //IPv6
654  default: NS_ASSERT_MSG (false, "PPP Protocol number not defined!");
655  }
656  return 0;
657 }
658 
659 uint16_t
661 {
663  switch(proto)
664  {
665  case 0x0800: return 0x0021; //IPv4
666  case 0x86DD: return 0x0057; //IPv6
667  default: NS_ASSERT_MSG (false, "PPP Protocol number not defined!");
668  }
669  return 0;
670 }
671 
672 
673 } // namespace ns3
uint32_t RemoveHeader(Header &header)
Deserialize and remove the header from the internal buffer.
Definition: packet.cc:268
void SetReceiveErrorModel(Ptr< ErrorModel > em)
Attach a receive ErrorModel to the PointToPointNetDevice.
PointToPointNetDevice()
Construct a PointToPointNetDevice.
Simulation virtual time values and global simulation resolution.
Definition: nstime.h:95
NetDevice::ReceiveCallback m_rxCallback
Receive callback.
void NotifyLinkUp(void)
Make the link up and running.
virtual bool IsLinkUp(void) const
#define NS_LOG_FUNCTION(parameters)
If log level LOG_FUNCTION is enabled, this macro will output all input parameters separated by "...
static TypeId GetTypeId(void)
Get the TypeId.
Ptr< Queue > GetQueue(void) const
Get a copy of the attached Queue.
The transmitter is busy transmitting a packet.
TracedCallback< Ptr< const Packet > > m_phyTxDropTrace
The trace source fired when the phy layer drops a packet before it tries to transmit it...
#define NS_OBJECT_ENSURE_REGISTERED(type)
Register an Object subclass with the TypeId system.
Definition: object-base.h:44
uint32_t m_mtu
The Maximum Transmission Unit.
virtual bool SupportsSendFrom(void) const
virtual ~PointToPointNetDevice()
Destroy a PointToPointNetDevice.
static const uint16_t DEFAULT_MTU
Default MTU.
TracedCallback< Ptr< const Packet > > m_phyRxEndTrace
The trace source fired when a packet ends the reception process from the medium.
Ptr< Node > m_node
Node owning this NetDevice.
TracedCallback< Ptr< const Packet > > m_phyRxDropTrace
The trace source fired when the phy layer drops a packet it has received.
uint64_t GetUid(void) const
Returns the packet's Uid.
Definition: packet.cc:380
bool IsNull(void) const
Check for null implementation.
Definition: callback.h:1072
#define NS_ASSERT(condition)
At runtime, in debugging builds, if this condition is not true, the program prints the source file...
Definition: assert.h:61
TracedCallback< Ptr< const Packet > > m_phyTxBeginTrace
The trace source fired when a packet begins the transmission process on the medium.
#define NS_LOG_COMPONENT_DEFINE(name)
Define a Log component with a specific name.
Definition: log.h:201
Ptr< Packet > m_currentPkt
Current packet processed.
static uint16_t EtherToPpp(uint16_t protocol)
Ethernet to PPP protocol number mapping.
uint32_t GetSize(void) const
Returns the the size in bytes of the packet (including the zero-filled initial payload).
Definition: packet.h:766
virtual void DoDispose(void)
Destructor implementation.
Definition: object.cc:338
Ptr< const AttributeChecker > MakeMac48AddressChecker(void)
#define NS_LOG_FUNCTION_NOARGS()
Output the name of the function.
virtual Ptr< Node > GetNode(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.
Definition: simulator.h:819
TracedCallback< Ptr< const Packet > > m_macRxTrace
The trace source fired for packets successfully received by the device immediately before being forwa...
Packet addressed oo us.
Definition: net-device.h:274
Ptr< const AttributeAccessor > MakeMac48AddressAccessor(T1 a1)
Create an AttributeAccessor for a class data member, or a lone class get functor or set method...
The transmitter is ready to begin transmission of a packet.
bool ProcessHeader(Ptr< Packet > p, uint16_t &param)
Removes, from a packet of data, all headers and trailers that relate to the protocol implemented by t...
a polymophic address class
Definition: address.h:90
Packet header for PPP.
Definition: ppp-header.h:48
Ptr< const AttributeChecker > MakeDataRateChecker(void)
Definition: data-rate.cc:30
Ptr< const TraceSourceAccessor > MakeTraceSourceAccessor(T a)
Create a TraceSourceAccessor which will control access to the underlying trace source.
virtual Address GetMulticast(Ipv4Address multicastGroup) const
Make and return a MAC multicast address using the provided multicast group.
Ptr< const AttributeChecker > MakeTimeChecker(const Time min, const Time max)
Helper to make a Time checker with bounded range.
Definition: time.cc:439
static uint16_t PppToEther(uint16_t protocol)
PPP to Ethernet protocol number mapping.
Class for representing data rates.
Definition: data-rate.h:87
virtual bool IsPointToPoint(void) const
Return true if the net device is on a point-to-point link.
double GetSeconds(void) const
Get an approximation of the time stored in this instance in the indicated unit.
Definition: nstime.h:327
double CalculateTxTime(uint32_t bytes) const
Calculate transmission time.
Definition: data-rate.cc:229
virtual void SetPromiscReceiveCallback(PromiscReceiveCallback cb)
void SetProtocol(uint16_t protocol)
Set the protocol type carried by this PPP packet.
Definition: ppp-header.cc:95
Ptr< const AttributeAccessor > MakePointerAccessor(T1 a1)
Create an AttributeAccessor for a class data member, or a lone class get functor or set method...
Definition: pointer.h:210
virtual void SetAddress(Address address)
Set the address of this interface.
AttributeValue implementation for Time.
Definition: nstime.h:921
Hold an unsigned integer type.
Definition: uinteger.h:44
void TransmitComplete(void)
Stop Sending a Packet Down the Wire and Begin the Interframe Gap.
TracedCallback m_linkChangeCallbacks
Callback for the link change event.
TracedCallback< Ptr< const Packet > > m_snifferTrace
A trace source that emulates a non-promiscuous protocol sniffer connected to the device.
bool TransmitStart(Ptr< Packet > p)
Start Sending a Packet Down the Wire.
void SetInterframeGap(Time t)
Set the interframe gap used to separate packets.
NetDevice::PromiscReceiveCallback m_promiscCallback
Receive callback.
Mac48Address m_address
Mac48Address of this NetDevice.
uint16_t GetProtocol(void)
Get the protocol type carried by this PPP packet.
Definition: ppp-header.cc:101
Ptr< const AttributeAccessor > MakeDataRateAccessor(T1 a1)
Create an AttributeAccessor for a class data member, or a lone class get functor or set method...
Definition: data-rate.h:219
#define NS_LOG_LOGIC(msg)
Use NS_LOG to output a message of level LOG_LOGIC.
Definition: log.h:252
Time m_tInterframeGap
The interframe gap that the Net Device uses to throttle packet transmission.
virtual void AddLinkChangeCallback(Callback< void > callback)
static Mac48Address ConvertFrom(const Address &address)
virtual bool NeedsArp(void) const
Ptr< Packet > Copy(void) const
performs a COW copy of the packet.
Definition: packet.cc:122
virtual void SetReceiveCallback(NetDevice::ReceiveCallback cb)
Every class exported by the ns3 library is enclosed in the ns3 namespace.
virtual uint32_t GetIfIndex(void) const
Hold objects of type Ptr.
Definition: pointer.h:36
virtual Ptr< Channel > GetChannel(void) const
virtual Address GetAddress(void) const
an EUI-48 address
Definition: mac48-address.h:43
virtual bool IsBridge(void) const
Return true if the net device is acting as a bridge.
Ptr< const AttributeAccessor > MakeTimeAccessor(T1 a1)
Create an AttributeAccessor for a class data member, or a lone class get functor or set method...
Definition: nstime.h:922
void DoMpiReceive(Ptr< Packet > p)
Handler for MPI receive event.
DataRate m_bps
The data rate that the Net Device uses to simulate packet transmission timing.
Ptr< PointToPointChannel > m_channel
The PointToPointChannel to which this PointToPointNetDevice has been attached.
TracedCallback< Ptr< const Packet > > m_promiscSnifferTrace
A trace source that emulates a promiscuous mode protocol sniffer connected to the device...
Ptr< ErrorModel > m_receiveErrorModel
Error model for receive packet events.
#define NS_ASSERT_MSG(condition, message)
At runtime, in debugging builds, if this condition is not true, the program prints the message to out...
Definition: assert.h:84
virtual bool SendFrom(Ptr< Packet > packet, const Address &source, const Address &dest, uint16_t protocolNumber)
virtual bool Send(Ptr< Packet > packet, const Address &dest, uint16_t protocolNumber)
Describes an IPv6 address.
Definition: ipv6-address.h:47
Ipv4 addresses are stored in host order in this class.
Definition: ipv4-address.h:40
uint32_t m_ifIndex
Index of the interface.
TracedCallback< Ptr< const Packet > > m_macPromiscRxTrace
The trace source fired for packets successfully received by the device immediately before being forwa...
TracedCallback< Ptr< const Packet > > m_phyRxBeginTrace
The trace source fired when a packet begins the reception process from the medium – when the simulat...
void ConnectWithoutContext(const CallbackBase &callback)
Append a Callback to the chain (without a context).
TxMachineState m_txMachineState
The state of the Net Device transmit state machine.
TracedCallback< Ptr< const Packet > > m_macTxDropTrace
The trace source fired when packets coming into the "top" of the device at the L3/L2 transition are d...
Network layer to device interface.
Definition: net-device.h:75
virtual bool SetMtu(const uint16_t mtu)
virtual void SetIfIndex(const uint32_t index)
AttributeValue implementation for DataRate.
Definition: data-rate.h:219
AttributeValue implementation for Mac48Address.
void SetDataRate(DataRate bps)
Set the Data Rate used for transmission of packets.
TracedCallback< Ptr< const Packet > > m_macRxDropTrace
The trace source fired for packets successfully received by the device but are dropped before being f...
void Receive(Ptr< Packet > p)
Receive a packet from a connected PointToPointChannel.
virtual bool IsBroadcast(void) const
Time Seconds(double value)
Construct a Time in the indicated unit.
Definition: nstime.h:859
bool Attach(Ptr< PointToPointChannel > ch)
Attach the device to a channel.
Ptr< Queue > m_queue
The Queue which this PointToPointNetDevice uses as a packet source.
virtual void DoDispose(void)
Dispose of the object.
virtual void SetNode(Ptr< Node > node)
bool m_linkUp
Identify if the link is up or not.
tuple address
Definition: first.py:37
void AddHeader(Ptr< Packet > p, uint16_t protocolNumber)
Adds the necessary headers and trailers to a packet of data in order to respect the protocol implemen...
virtual uint16_t GetMtu(void) const
Ptr< const AttributeAccessor > MakeUintegerAccessor(T1 a1)
Create an AttributeAccessor for a class data member, or a lone class get functor or set method...
Definition: uinteger.h:45
virtual bool IsMulticast(void) const
a unique identifier for an interface.
Definition: type-id.h:51
TracedCallback< Ptr< const Packet > > m_macTxTrace
The trace source fired when packets come into the "top" of the device at the L3/L2 transition...
TypeId SetParent(TypeId tid)
Definition: type-id.cc:631
virtual Address GetBroadcast(void) const
void AddHeader(const Header &header)
Add header to this packet.
Definition: packet.cc:253
void SetQueue(Ptr< Queue > queue)
Attach a queue to the PointToPointNetDevice.
TracedCallback< Ptr< const Packet > > m_phyTxEndTrace
The trace source fired when a packet ends the transmission process on the medium. ...