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"
28 #include "ns3/net-device-queue-interface.h"
30 #include "point-to-point-channel.h"
31 #include "ppp-header.h"
32 
33 namespace ns3 {
34 
35 NS_LOG_COMPONENT_DEFINE ("PointToPointNetDevice");
36 
37 NS_OBJECT_ENSURE_REGISTERED (PointToPointNetDevice);
38 
39 TypeId
41 {
42  static TypeId tid = TypeId ("ns3::PointToPointNetDevice")
43  .SetParent<NetDevice> ()
44  .SetGroupName ("PointToPoint")
45  .AddConstructor<PointToPointNetDevice> ()
46  .AddAttribute ("Mtu", "The MAC-level Maximum Transmission Unit",
50  MakeUintegerChecker<uint16_t> ())
51  .AddAttribute ("Address",
52  "The MAC address of this device.",
53  Mac48AddressValue (Mac48Address ("ff:ff:ff:ff:ff:ff")),
56  .AddAttribute ("DataRate",
57  "The default data rate for point to point links",
58  DataRateValue (DataRate ("32768b/s")),
61  .AddAttribute ("ReceiveErrorModel",
62  "The receiver error model used to simulate packet loss",
63  PointerValue (),
65  MakePointerChecker<ErrorModel> ())
66  .AddAttribute ("InterframeGap",
67  "The time to wait between packet (frame) transmissions",
68  TimeValue (Seconds (0.0)),
70  MakeTimeChecker ())
71 
72  //
73  // Transmit queueing discipline for the device which includes its own set
74  // of trace hooks.
75  //
76  .AddAttribute ("TxQueue",
77  "A queue to use as the transmit queue in the device.",
78  PointerValue (),
81 
82  //
83  // Trace sources at the "top" of the net device, where packets transition
84  // to/from higher layers.
85  //
86  .AddTraceSource ("MacTx",
87  "Trace source indicating a packet has arrived "
88  "for transmission by this device",
90  "ns3::Packet::TracedCallback")
91  .AddTraceSource ("MacTxDrop",
92  "Trace source indicating a packet has been dropped "
93  "by the device before transmission",
95  "ns3::Packet::TracedCallback")
96  .AddTraceSource ("MacPromiscRx",
97  "A packet has been received by this device, "
98  "has been passed up from the physical layer "
99  "and is being forwarded up the local protocol stack. "
100  "This is a promiscuous trace,",
102  "ns3::Packet::TracedCallback")
103  .AddTraceSource ("MacRx",
104  "A packet has been received by this device, "
105  "has been passed up from the physical layer "
106  "and is being forwarded up the local protocol stack. "
107  "This is a non-promiscuous trace,",
109  "ns3::Packet::TracedCallback")
110 #if 0
111  // Not currently implemented for this device
112  .AddTraceSource ("MacRxDrop",
113  "Trace source indicating a packet was dropped "
114  "before being forwarded up the stack",
116  "ns3::Packet::TracedCallback")
117 #endif
118  //
119  // Trace souces at the "bottom" of the net device, where packets transition
120  // to/from the channel.
121  //
122  .AddTraceSource ("PhyTxBegin",
123  "Trace source indicating a packet has begun "
124  "transmitting over the channel",
126  "ns3::Packet::TracedCallback")
127  .AddTraceSource ("PhyTxEnd",
128  "Trace source indicating a packet has been "
129  "completely transmitted over the channel",
131  "ns3::Packet::TracedCallback")
132  .AddTraceSource ("PhyTxDrop",
133  "Trace source indicating a packet has been "
134  "dropped by the device during transmission",
136  "ns3::Packet::TracedCallback")
137 #if 0
138  // Not currently implemented for this device
139  .AddTraceSource ("PhyRxBegin",
140  "Trace source indicating a packet has begun "
141  "being received by the device",
143  "ns3::Packet::TracedCallback")
144 #endif
145  .AddTraceSource ("PhyRxEnd",
146  "Trace source indicating a packet has been "
147  "completely received by the device",
149  "ns3::Packet::TracedCallback")
150  .AddTraceSource ("PhyRxDrop",
151  "Trace source indicating a packet has been "
152  "dropped by the device during reception",
154  "ns3::Packet::TracedCallback")
155 
156  //
157  // Trace sources designed to simulate a packet sniffer facility (tcpdump).
158  // Note that there is really no difference between promiscuous and
159  // non-promiscuous traces in a point-to-point link.
160  //
161  .AddTraceSource ("Sniffer",
162  "Trace source simulating a non-promiscuous packet sniffer "
163  "attached to the device",
165  "ns3::Packet::TracedCallback")
166  .AddTraceSource ("PromiscSniffer",
167  "Trace source simulating a promiscuous packet sniffer "
168  "attached to the device",
170  "ns3::Packet::TracedCallback")
171  ;
172  return tid;
173 }
174 
175 
177  :
178  m_txMachineState (READY),
179  m_channel (0),
180  m_linkUp (false),
181  m_currentPkt (0)
182 {
183  NS_LOG_FUNCTION (this);
184 }
185 
187 {
188  NS_LOG_FUNCTION (this);
189 }
190 
191 void
192 PointToPointNetDevice::AddHeader (Ptr<Packet> p, uint16_t protocolNumber)
193 {
194  NS_LOG_FUNCTION (this << p << protocolNumber);
195  PppHeader ppp;
196  ppp.SetProtocol (EtherToPpp (protocolNumber));
197  p->AddHeader (ppp);
198 }
199 
200 bool
202 {
203  NS_LOG_FUNCTION (this << p << param);
204  PppHeader ppp;
205  p->RemoveHeader (ppp);
206  param = PppToEther (ppp.GetProtocol ());
207  return true;
208 }
209 
210 void
212 {
213  if (m_queueInterface)
214  {
215  NS_ASSERT_MSG (m_queue != 0, "A Queue object has not been attached to the device");
216 
217  // connect the traced callbacks of m_queue to the static methods provided by
218  // the NetDeviceQueue class to support flow control and dynamic queue limits.
219  // This could not be done in NotifyNewAggregate because at that time we are
220  // not guaranteed that a queue has been attached to the netdevice
221  m_queueInterface->ConnectQueueTraces (m_queue, 0);
222  }
223 
225 }
226 
227 void
229 {
230  NS_LOG_FUNCTION (this);
231  if (m_queueInterface == 0)
232  {
233  Ptr<NetDeviceQueueInterface> ndqi = this->GetObject<NetDeviceQueueInterface> ();
234  //verify that it's a valid netdevice queue interface and that
235  //the netdevice queue interface was not set before
236  if (ndqi != 0)
237  {
238  m_queueInterface = ndqi;
239  }
240  }
242 }
243 
244 void
246 {
247  NS_LOG_FUNCTION (this);
248  m_node = 0;
249  m_channel = 0;
251  m_currentPkt = 0;
252  m_queue = 0;
253  m_queueInterface = 0;
255 }
256 
257 void
259 {
260  NS_LOG_FUNCTION (this);
261  m_bps = bps;
262 }
263 
264 void
266 {
267  NS_LOG_FUNCTION (this << t.GetSeconds ());
268  m_tInterframeGap = t;
269 }
270 
271 bool
273 {
274  NS_LOG_FUNCTION (this << p);
275  NS_LOG_LOGIC ("UID is " << p->GetUid () << ")");
276 
277  //
278  // This function is called to start the process of transmitting a packet.
279  // We need to tell the channel that we've started wiggling the wire and
280  // schedule an event that will be executed when the transmission is complete.
281  //
282  NS_ASSERT_MSG (m_txMachineState == READY, "Must be READY to transmit");
284  m_currentPkt = p;
286 
287  Time txTime = m_bps.CalculateBytesTxTime (p->GetSize ());
288  Time txCompleteTime = txTime + m_tInterframeGap;
289 
290  NS_LOG_LOGIC ("Schedule TransmitCompleteEvent in " << txCompleteTime.GetSeconds () << "sec");
292 
293  bool result = m_channel->TransmitStart (p, this, txTime);
294  if (result == false)
295  {
296  m_phyTxDropTrace (p);
297  }
298  return result;
299 }
300 
301 void
303 {
304  NS_LOG_FUNCTION (this);
305 
306  //
307  // This function is called to when we're all done transmitting a packet.
308  // We try and pull another packet off of the transmit queue. If the queue
309  // is empty, we are done, otherwise we need to start transmitting the
310  // next packet.
311  //
312  NS_ASSERT_MSG (m_txMachineState == BUSY, "Must be BUSY if transmitting");
314 
315  NS_ASSERT_MSG (m_currentPkt != 0, "PointToPointNetDevice::TransmitComplete(): m_currentPkt zero");
316 
318  m_currentPkt = 0;
319 
320  Ptr<Packet> p = m_queue->Dequeue ();
321  if (p == 0)
322  {
323  NS_LOG_LOGIC ("No pending packets in device queue after tx complete");
324  return;
325  }
326 
327  //
328  // Got another packet off of the queue, so start the transmit process again.
329  //
330  m_snifferTrace (p);
332  TransmitStart (p);
333 }
334 
335 bool
337 {
338  NS_LOG_FUNCTION (this << &ch);
339 
340  m_channel = ch;
341 
342  m_channel->Attach (this);
343 
344  //
345  // This device is up whenever it is attached to a channel. A better plan
346  // would be to have the link come up when both devices are attached, but this
347  // is not done for now.
348  //
349  NotifyLinkUp ();
350  return true;
351 }
352 
353 void
355 {
356  NS_LOG_FUNCTION (this << q);
357  m_queue = q;
358 }
359 
360 void
362 {
363  NS_LOG_FUNCTION (this << em);
364  m_receiveErrorModel = em;
365 }
366 
367 void
369 {
370  NS_LOG_FUNCTION (this << packet);
371  uint16_t protocol = 0;
372 
373  if (m_receiveErrorModel && m_receiveErrorModel->IsCorrupt (packet) )
374  {
375  //
376  // If we have an error model and it indicates that it is time to lose a
377  // corrupted packet, don't forward this packet up, let it go.
378  //
379  m_phyRxDropTrace (packet);
380  }
381  else
382  {
383  //
384  // Hit the trace hooks. All of these hooks are in the same place in this
385  // device because it is so simple, but this is not usually the case in
386  // more complicated devices.
387  //
388  m_snifferTrace (packet);
389  m_promiscSnifferTrace (packet);
390  m_phyRxEndTrace (packet);
391 
392  //
393  // Trace sinks will expect complete packets, not packets without some of the
394  // headers.
395  //
396  Ptr<Packet> originalPacket = packet->Copy ();
397 
398  //
399  // Strip off the point-to-point protocol header and forward this packet
400  // up the protocol stack. Since this is a simple point-to-point link,
401  // there is no difference in what the promisc callback sees and what the
402  // normal receive callback sees.
403  //
404  ProcessHeader (packet, protocol);
405 
406  if (!m_promiscCallback.IsNull ())
407  {
408  m_macPromiscRxTrace (originalPacket);
409  m_promiscCallback (this, packet, protocol, GetRemote (), GetAddress (), NetDevice::PACKET_HOST);
410  }
411 
412  m_macRxTrace (originalPacket);
413  m_rxCallback (this, packet, protocol, GetRemote ());
414  }
415 }
416 
419 {
420  NS_LOG_FUNCTION (this);
421  return m_queue;
422 }
423 
424 void
426 {
427  NS_LOG_FUNCTION (this);
428  m_linkUp = true;
430 }
431 
432 void
433 PointToPointNetDevice::SetIfIndex (const uint32_t index)
434 {
435  NS_LOG_FUNCTION (this);
436  m_ifIndex = index;
437 }
438 
439 uint32_t
441 {
442  return m_ifIndex;
443 }
444 
447 {
448  return m_channel;
449 }
450 
451 //
452 // This is a point-to-point device, so we really don't need any kind of address
453 // information. However, the base class NetDevice wants us to define the
454 // methods to get and set the address. Rather than be rude and assert, we let
455 // clients get and set the address, but simply ignore them.
456 
457 void
459 {
460  NS_LOG_FUNCTION (this << address);
462 }
463 
464 Address
466 {
467  return m_address;
468 }
469 
470 bool
472 {
473  NS_LOG_FUNCTION (this);
474  return m_linkUp;
475 }
476 
477 void
479 {
480  NS_LOG_FUNCTION (this);
482 }
483 
484 //
485 // This is a point-to-point device, so every transmission is a broadcast to
486 // all of the devices on the network.
487 //
488 bool
490 {
491  NS_LOG_FUNCTION (this);
492  return true;
493 }
494 
495 //
496 // We don't really need any addressing information since this is a
497 // point-to-point device. The base class NetDevice wants us to return a
498 // broadcast address, so we make up something reasonable.
499 //
500 Address
502 {
503  NS_LOG_FUNCTION (this);
504  return Mac48Address ("ff:ff:ff:ff:ff:ff");
505 }
506 
507 bool
509 {
510  NS_LOG_FUNCTION (this);
511  return true;
512 }
513 
514 Address
516 {
517  NS_LOG_FUNCTION (this);
518  return Mac48Address ("01:00:5e:00:00:00");
519 }
520 
521 Address
523 {
524  NS_LOG_FUNCTION (this << addr);
525  return Mac48Address ("33:33:00:00:00:00");
526 }
527 
528 bool
530 {
531  NS_LOG_FUNCTION (this);
532  return true;
533 }
534 
535 bool
537 {
538  NS_LOG_FUNCTION (this);
539  return false;
540 }
541 
542 bool
544  Ptr<Packet> packet,
545  const Address &dest,
546  uint16_t protocolNumber)
547 {
548  NS_LOG_FUNCTION (this << packet << dest << protocolNumber);
549  NS_LOG_LOGIC ("p=" << packet << ", dest=" << &dest);
550  NS_LOG_LOGIC ("UID is " << packet->GetUid ());
551 
552  //
553  // If IsLinkUp() is false it means there is no channel to send any packet
554  // over so we just hit the drop trace on the packet and return an error.
555  //
556  if (IsLinkUp () == false)
557  {
558  m_macTxDropTrace (packet);
559  return false;
560  }
561 
562  //
563  // Stick a point to point protocol header on the packet in preparation for
564  // shoving it out the door.
565  //
566  AddHeader (packet, protocolNumber);
567 
568  m_macTxTrace (packet);
569 
570  //
571  // We should enqueue and dequeue the packet to hit the tracing hooks.
572  //
573  if (m_queue->Enqueue (packet))
574  {
575  //
576  // If the channel is ready for transition we send the packet right now
577  //
578  if (m_txMachineState == READY)
579  {
580  packet = m_queue->Dequeue ();
581  m_snifferTrace (packet);
582  m_promiscSnifferTrace (packet);
583  bool ret = TransmitStart (packet);
584  return ret;
585  }
586  return true;
587  }
588 
589  // Enqueue may fail (overflow)
590 
591  m_macTxDropTrace (packet);
592  return false;
593 }
594 
595 bool
597  const Address &source,
598  const Address &dest,
599  uint16_t protocolNumber)
600 {
601  NS_LOG_FUNCTION (this << packet << source << dest << protocolNumber);
602  return false;
603 }
604 
605 Ptr<Node>
607 {
608  return m_node;
609 }
610 
611 void
613 {
614  NS_LOG_FUNCTION (this);
615  m_node = node;
616 }
617 
618 bool
620 {
621  NS_LOG_FUNCTION (this);
622  return false;
623 }
624 
625 void
627 {
628  m_rxCallback = cb;
629 }
630 
631 void
633 {
634  m_promiscCallback = cb;
635 }
636 
637 bool
639 {
640  NS_LOG_FUNCTION (this);
641  return false;
642 }
643 
644 void
646 {
647  NS_LOG_FUNCTION (this << p);
648  Receive (p);
649 }
650 
651 Address
653 {
654  NS_LOG_FUNCTION (this);
655  NS_ASSERT (m_channel->GetNDevices () == 2);
656  for (uint32_t i = 0; i < m_channel->GetNDevices (); ++i)
657  {
658  Ptr<NetDevice> tmp = m_channel->GetDevice (i);
659  if (tmp != this)
660  {
661  return tmp->GetAddress ();
662  }
663  }
664  NS_ASSERT (false);
665  // quiet compiler.
666  return Address ();
667 }
668 
669 bool
671 {
672  NS_LOG_FUNCTION (this << mtu);
673  m_mtu = mtu;
674  return true;
675 }
676 
677 uint16_t
679 {
680  NS_LOG_FUNCTION (this);
681  return m_mtu;
682 }
683 
684 uint16_t
686 {
688  switch(proto)
689  {
690  case 0x0021: return 0x0800; //IPv4
691  case 0x0057: return 0x86DD; //IPv6
692  default: NS_ASSERT_MSG (false, "PPP Protocol number not defined!");
693  }
694  return 0;
695 }
696 
697 uint16_t
699 {
701  switch(proto)
702  {
703  case 0x0800: return 0x0021; //IPv4
704  case 0x86DD: return 0x0057; //IPv6
705  default: NS_ASSERT_MSG (false, "PPP Protocol number not defined!");
706  }
707  return 0;
708 }
709 
710 
711 } // namespace ns3
uint32_t RemoveHeader(Header &header)
Deserialize and remove the header from the internal buffer.
Definition: packet.cc:267
void SetReceiveErrorModel(Ptr< ErrorModel > em)
Attach a receive ErrorModel to the PointToPointNetDevice.
virtual void DoInitialize(void)
Initialize() implementation.
Definition: object.cc:353
PointToPointNetDevice()
Construct a PointToPointNetDevice.
Simulation virtual time values and global simulation resolution.
Definition: nstime.h:102
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.
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:45
Time CalculateBytesTxTime(uint32_t bytes) const
Calculate transmission time.
Definition: data-rate.cc:235
uint32_t m_mtu
The Maximum Transmission Unit.
virtual bool SupportsSendFrom(void) const
Ptr< Queue< Packet > > GetQueue(void) const
Get a copy of the attached Queue.
Ptr< AttributeChecker > MakePointerChecker(void)
Create a PointerChecker for a type.
Definition: pointer.h:224
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:367
bool IsNull(void) const
Check for null implementation.
Definition: callback.h:1270
#define NS_ASSERT(condition)
At runtime, in debugging builds, if this condition is not true, the program prints the source file...
Definition: assert.h:67
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:796
Ptr< const AttributeChecker > MakeMac48AddressChecker(void)
virtual void DoDispose(void)
Destructor implementation.
Definition: object.cc:346
#define NS_LOG_FUNCTION_NOARGS()
Output the name of the function.
Ptr< Queue< Packet > > m_queue
The Queue which this PointToPointNetDevice uses as a packet source.
virtual Ptr< Node > GetNode(void) const
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:298
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:446
static uint16_t PppToEther(uint16_t protocol)
PPP to Ethernet protocol number mapping.
Class for representing data rates.
Definition: data-rate.h:88
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:341
virtual void SetPromiscReceiveCallback(PromiscReceiveCallback cb)
void SetProtocol(uint16_t protocol)
Set the protocol type carried by this PPP packet.
Definition: ppp-header.cc:96
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:220
static EventId Schedule(Time const &delay, MEM mem_ptr, OBJ obj)
Schedule an event to expire after delay.
Definition: simulator.h:1375
virtual void SetAddress(Address address)
Set the address of this interface.
AttributeValue implementation for Time.
Definition: nstime.h:1055
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.
Ptr< NetDeviceQueueInterface > m_queueInterface
NetDevice queue interface.
bool TransmitStart(Ptr< Packet > p)
Start Sending a Packet Down the Wire.
void SetInterframeGap(Time t)
Set the interframe gap used to separate packets.
A Device for a Point to Point Network Link.
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:102
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:242
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:121
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 void DoInitialize(void)
Initialize() implementation.
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:1056
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.
NS_LOG_LOGIC("Net device "<< nd<< " is not bridged")
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:90
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:48
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:95
virtual bool SetMtu(const uint16_t mtu)
virtual void SetIfIndex(const uint32_t index)
AttributeValue implementation for DataRate.
Definition: data-rate.h:242
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:993
bool Attach(Ptr< PointToPointChannel > ch)
Attach the device to a channel.
virtual void DoDispose(void)
Dispose of the object.
virtual void SetNode(Ptr< Node > node)
virtual void NotifyNewAggregate(void)
Notify all Objects aggregated to this one of a new Object being aggregated.
bool m_linkUp
Identify if the link is up or not.
tuple address
Definition: first.py:37
virtual void NotifyNewAggregate(void)
Notify all Objects aggregated to this one of a new Object being aggregated.
Definition: object.cc:325
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:58
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)
Set the parent TypeId.
Definition: type-id.cc:914
virtual Address GetBroadcast(void) const
void AddHeader(const Header &header)
Add header to this packet.
Definition: packet.cc:256
void SetQueue(Ptr< Queue< Packet > > 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. ...