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  .SetGroupName ("PointToPoint")
44  .AddConstructor<PointToPointNetDevice> ()
45  .AddAttribute ("Mtu", "The MAC-level Maximum Transmission Unit",
49  MakeUintegerChecker<uint16_t> ())
50  .AddAttribute ("Address",
51  "The MAC address of this device.",
52  Mac48AddressValue (Mac48Address ("ff:ff:ff:ff:ff:ff")),
55  .AddAttribute ("DataRate",
56  "The default data rate for point to point links",
57  DataRateValue (DataRate ("32768b/s")),
60  .AddAttribute ("ReceiveErrorModel",
61  "The receiver error model used to simulate packet loss",
62  PointerValue (),
64  MakePointerChecker<ErrorModel> ())
65  .AddAttribute ("InterframeGap",
66  "The time to wait between packet (frame) transmissions",
67  TimeValue (Seconds (0.0)),
69  MakeTimeChecker ())
70 
71  //
72  // Transmit queueing discipline for the device which includes its own set
73  // of trace hooks.
74  //
75  .AddAttribute ("TxQueue",
76  "A queue to use as the transmit queue in the device.",
77  PointerValue (),
79  MakePointerChecker<Queue> ())
80 
81  //
82  // Trace sources at the "top" of the net device, where packets transition
83  // to/from higher layers.
84  //
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, "
97  "has been 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")
109 #if 0
110  // Not currently implemented for this device
111  .AddTraceSource ("MacRxDrop",
112  "Trace source indicating a packet was dropped "
113  "before being forwarded up the stack",
115  "ns3::Packet::TracedCallback")
116 #endif
117  //
118  // Trace souces at the "bottom" of the net device, where packets transition
119  // to/from the channel.
120  //
121  .AddTraceSource ("PhyTxBegin",
122  "Trace source indicating a packet has begun "
123  "transmitting over the channel",
125  "ns3::Packet::TracedCallback")
126  .AddTraceSource ("PhyTxEnd",
127  "Trace source indicating a packet has been "
128  "completely transmitted over the channel",
130  "ns3::Packet::TracedCallback")
131  .AddTraceSource ("PhyTxDrop",
132  "Trace source indicating a packet has been "
133  "dropped by the device during transmission",
135  "ns3::Packet::TracedCallback")
136 #if 0
137  // Not currently implemented for this device
138  .AddTraceSource ("PhyRxBegin",
139  "Trace source indicating a packet has begun "
140  "being received by the device",
142  "ns3::Packet::TracedCallback")
143 #endif
144  .AddTraceSource ("PhyRxEnd",
145  "Trace source indicating a packet has been "
146  "completely received by the device",
148  "ns3::Packet::TracedCallback")
149  .AddTraceSource ("PhyRxDrop",
150  "Trace source indicating a packet has been "
151  "dropped by the device during reception",
153  "ns3::Packet::TracedCallback")
154 
155  //
156  // Trace sources designed to simulate a packet sniffer facility (tcpdump).
157  // Note that there is really no difference between promiscuous and
158  // non-promiscuous traces in a point-to-point link.
159  //
160  .AddTraceSource ("Sniffer",
161  "Trace source simulating a non-promiscuous packet sniffer "
162  "attached to the device",
164  "ns3::Packet::TracedCallback")
165  .AddTraceSource ("PromiscSniffer",
166  "Trace source simulating a promiscuous packet sniffer "
167  "attached to the device",
169  "ns3::Packet::TracedCallback")
170  ;
171  return tid;
172 }
173 
174 
176  :
177  m_txMachineState (READY),
178  m_channel (0),
179  m_linkUp (false),
180  m_currentPkt (0)
181 {
182  NS_LOG_FUNCTION (this);
183 }
184 
186 {
187  NS_LOG_FUNCTION (this);
188 }
189 
190 void
191 PointToPointNetDevice::AddHeader (Ptr<Packet> p, uint16_t protocolNumber)
192 {
193  NS_LOG_FUNCTION (this << p << protocolNumber);
194  PppHeader ppp;
195  ppp.SetProtocol (EtherToPpp (protocolNumber));
196  p->AddHeader (ppp);
197 }
198 
199 bool
201 {
202  NS_LOG_FUNCTION (this << p << param);
203  PppHeader ppp;
204  p->RemoveHeader (ppp);
205  param = PppToEther (ppp.GetProtocol ());
206  return true;
207 }
208 
209 void
211 {
212  NS_LOG_FUNCTION (this);
213  if (m_queueInterface == 0)
214  {
215  Ptr<NetDeviceQueueInterface> ndqi = this->GetObject<NetDeviceQueueInterface> ();
216  //verify that it's a valid netdevice queue interface and that
217  //the netdevice queue interface was not set before
218  if (ndqi != 0)
219  {
220  m_queueInterface = ndqi;
221  }
222  }
224 }
225 
226 void
228 {
229  NS_LOG_FUNCTION (this);
230  m_node = 0;
231  m_channel = 0;
233  m_currentPkt = 0;
234  m_queue = 0;
235  m_queueInterface = 0;
237 }
238 
239 void
241 {
242  NS_LOG_FUNCTION (this);
243  m_bps = bps;
244 }
245 
246 void
248 {
249  NS_LOG_FUNCTION (this << t.GetSeconds ());
250  m_tInterframeGap = t;
251 }
252 
253 bool
255 {
256  NS_LOG_FUNCTION (this << p);
257  NS_LOG_LOGIC ("UID is " << p->GetUid () << ")");
258 
259  //
260  // This function is called to start the process of transmitting a packet.
261  // We need to tell the channel that we've started wiggling the wire and
262  // schedule an event that will be executed when the transmission is complete.
263  //
264  NS_ASSERT_MSG (m_txMachineState == READY, "Must be READY to transmit");
266  m_currentPkt = p;
268 
269  Time txTime = m_bps.CalculateBytesTxTime (p->GetSize ());
270  Time txCompleteTime = txTime + m_tInterframeGap;
271 
272  NS_LOG_LOGIC ("Schedule TransmitCompleteEvent in " << txCompleteTime.GetSeconds () << "sec");
274 
275  bool result = m_channel->TransmitStart (p, this, txTime);
276  if (result == false)
277  {
278  m_phyTxDropTrace (p);
279  }
280  return result;
281 }
282 
283 void
285 {
286  NS_LOG_FUNCTION (this);
287 
288  //
289  // This function is called to when we're all done transmitting a packet.
290  // We try and pull another packet off of the transmit queue. If the queue
291  // is empty, we are done, otherwise we need to start transmitting the
292  // next packet.
293  //
294  NS_ASSERT_MSG (m_txMachineState == BUSY, "Must be BUSY if transmitting");
296 
297  NS_ASSERT_MSG (m_currentPkt != 0, "PointToPointNetDevice::TransmitComplete(): m_currentPkt zero");
298 
300  m_currentPkt = 0;
301 
303  if (m_queueInterface)
304  {
305  txq = m_queueInterface->GetTxQueue (0);
306  }
307 
308  Ptr<QueueItem> item = m_queue->Dequeue ();
309  if (item == 0)
310  {
311  NS_LOG_LOGIC ("No pending packets in device queue after tx complete");
312  if (txq)
313  {
314  NS_LOG_DEBUG ("The device queue is being woken up (" << m_queue->GetNPackets () <<
315  " packets and " << m_queue->GetNBytes () << " bytes inside)");
316  txq->Wake ();
317  }
318  return;
319  }
320 
321  //
322  // Got another packet off of the queue, so start the transmit process again.
323  // If the queue was stopped, start it again if there is room for another packet.
324  // Note that we cannot wake the upper layers because otherwise a packet is sent
325  // to the device while the machine state is busy, thus causing the assert in
326  // TransmitStart to fail.
327  //
328  if (txq && txq->IsStopped ())
329  {
330  if ((m_queue->GetMode () == Queue::QUEUE_MODE_PACKETS &&
331  m_queue->GetNPackets () < m_queue->GetMaxPackets ()) ||
332  (m_queue->GetMode () == Queue::QUEUE_MODE_BYTES &&
333  m_queue->GetNBytes () + m_mtu <= m_queue->GetMaxBytes ()))
334  {
335  NS_LOG_DEBUG ("The device queue is being started (" << m_queue->GetNPackets () <<
336  " packets and " << m_queue->GetNBytes () << " bytes inside)");
337  txq->Start ();
338  }
339  }
340  Ptr<Packet> p = item->GetPacket ();
341  m_snifferTrace (p);
343  TransmitStart (p);
344  if (txq)
345  {
346  // Inform BQL
347  txq->NotifyTransmittedBytes (m_currentPkt->GetSize ());
348  }
349 }
350 
351 bool
353 {
354  NS_LOG_FUNCTION (this << &ch);
355 
356  m_channel = ch;
357 
358  m_channel->Attach (this);
359 
360  //
361  // This device is up whenever it is attached to a channel. A better plan
362  // would be to have the link come up when both devices are attached, but this
363  // is not done for now.
364  //
365  NotifyLinkUp ();
366  return true;
367 }
368 
369 void
371 {
372  NS_LOG_FUNCTION (this << q);
373  m_queue = q;
374 }
375 
376 void
378 {
379  NS_LOG_FUNCTION (this << em);
380  m_receiveErrorModel = em;
381 }
382 
383 void
385 {
386  NS_LOG_FUNCTION (this << packet);
387  uint16_t protocol = 0;
388 
389  if (m_receiveErrorModel && m_receiveErrorModel->IsCorrupt (packet) )
390  {
391  //
392  // If we have an error model and it indicates that it is time to lose a
393  // corrupted packet, don't forward this packet up, let it go.
394  //
395  m_phyRxDropTrace (packet);
396  }
397  else
398  {
399  //
400  // Hit the trace hooks. All of these hooks are in the same place in this
401  // device because it is so simple, but this is not usually the case in
402  // more complicated devices.
403  //
404  m_snifferTrace (packet);
405  m_promiscSnifferTrace (packet);
406  m_phyRxEndTrace (packet);
407 
408  //
409  // Trace sinks will expect complete packets, not packets without some of the
410  // headers.
411  //
412  Ptr<Packet> originalPacket = packet->Copy ();
413 
414  //
415  // Strip off the point-to-point protocol header and forward this packet
416  // up the protocol stack. Since this is a simple point-to-point link,
417  // there is no difference in what the promisc callback sees and what the
418  // normal receive callback sees.
419  //
420  ProcessHeader (packet, protocol);
421 
422  if (!m_promiscCallback.IsNull ())
423  {
424  m_macPromiscRxTrace (originalPacket);
425  m_promiscCallback (this, packet, protocol, GetRemote (), GetAddress (), NetDevice::PACKET_HOST);
426  }
427 
428  m_macRxTrace (originalPacket);
429  m_rxCallback (this, packet, protocol, GetRemote ());
430  }
431 }
432 
435 {
436  NS_LOG_FUNCTION (this);
437  return m_queue;
438 }
439 
440 void
442 {
443  NS_LOG_FUNCTION (this);
444  m_linkUp = true;
446 }
447 
448 void
449 PointToPointNetDevice::SetIfIndex (const uint32_t index)
450 {
451  NS_LOG_FUNCTION (this);
452  m_ifIndex = index;
453 }
454 
455 uint32_t
457 {
458  return m_ifIndex;
459 }
460 
463 {
464  return m_channel;
465 }
466 
467 //
468 // This is a point-to-point device, so we really don't need any kind of address
469 // information. However, the base class NetDevice wants us to define the
470 // methods to get and set the address. Rather than be rude and assert, we let
471 // clients get and set the address, but simply ignore them.
472 
473 void
475 {
476  NS_LOG_FUNCTION (this << address);
478 }
479 
480 Address
482 {
483  return m_address;
484 }
485 
486 bool
488 {
489  NS_LOG_FUNCTION (this);
490  return m_linkUp;
491 }
492 
493 void
495 {
496  NS_LOG_FUNCTION (this);
498 }
499 
500 //
501 // This is a point-to-point device, so every transmission is a broadcast to
502 // all of the devices on the network.
503 //
504 bool
506 {
507  NS_LOG_FUNCTION (this);
508  return true;
509 }
510 
511 //
512 // We don't really need any addressing information since this is a
513 // point-to-point device. The base class NetDevice wants us to return a
514 // broadcast address, so we make up something reasonable.
515 //
516 Address
518 {
519  NS_LOG_FUNCTION (this);
520  return Mac48Address ("ff:ff:ff:ff:ff:ff");
521 }
522 
523 bool
525 {
526  NS_LOG_FUNCTION (this);
527  return true;
528 }
529 
530 Address
532 {
533  NS_LOG_FUNCTION (this);
534  return Mac48Address ("01:00:5e:00:00:00");
535 }
536 
537 Address
539 {
540  NS_LOG_FUNCTION (this << addr);
541  return Mac48Address ("33:33:00:00:00:00");
542 }
543 
544 bool
546 {
547  NS_LOG_FUNCTION (this);
548  return true;
549 }
550 
551 bool
553 {
554  NS_LOG_FUNCTION (this);
555  return false;
556 }
557 
558 bool
560  Ptr<Packet> packet,
561  const Address &dest,
562  uint16_t protocolNumber)
563 {
565  if (m_queueInterface)
566  {
567  txq = m_queueInterface->GetTxQueue (0);
568  }
569 
570  NS_ASSERT_MSG (!txq || !txq->IsStopped (), "Send should not be called when the device is stopped");
571 
572  NS_LOG_FUNCTION (this << packet << dest << protocolNumber);
573  NS_LOG_LOGIC ("p=" << packet << ", dest=" << &dest);
574  NS_LOG_LOGIC ("UID is " << packet->GetUid ());
575 
576  //
577  // If IsLinkUp() is false it means there is no channel to send any packet
578  // over so we just hit the drop trace on the packet and return an error.
579  //
580  if (IsLinkUp () == false)
581  {
582  m_macTxDropTrace (packet);
583  return false;
584  }
585 
586  //
587  // Stick a point to point protocol header on the packet in preparation for
588  // shoving it out the door.
589  //
590  AddHeader (packet, protocolNumber);
591 
592  m_macTxTrace (packet);
593 
594  //
595  // We should enqueue and dequeue the packet to hit the tracing hooks.
596  //
597  if (m_queue->Enqueue (Create<QueueItem> (packet)))
598  {
599  // Inform BQL
600  if (txq)
601  {
602  txq->NotifyQueuedBytes (packet->GetSize ());
603  }
604  //
605  // If the channel is ready for transition we send the packet right now
606  //
607  if (m_txMachineState == READY)
608  {
609  packet = m_queue->Dequeue ()->GetPacket ();
610  // We have enqueued a packet and dequeued a (possibly different) packet. We
611  // need to check if there is still room for another packet only if the queue
612  // is in byte mode (the enqueued packet might be larger than the dequeued
613  // packet, thus leaving no room for another packet)
614  if (txq)
615  {
616  if (m_queue->GetMode () == Queue::QUEUE_MODE_BYTES &&
617  m_queue->GetNBytes () + m_mtu > m_queue->GetMaxBytes ())
618  {
619  NS_LOG_DEBUG ("The device queue is being stopped (" << m_queue->GetNPackets () <<
620  " packets and " << m_queue->GetNBytes () << " bytes inside)");
621  txq->Stop ();
622  }
623  }
624  m_snifferTrace (packet);
625  m_promiscSnifferTrace (packet);
626  bool ret = TransmitStart (packet);
627  if (txq)
628  {
629  // Inform BQL
630  txq->NotifyTransmittedBytes (m_currentPkt->GetSize ());
631  }
632  return ret;
633  }
634  // We have enqueued a packet but we have not dequeued any packet. Thus, we
635  // need to check whether the queue is able to store another packet. If not,
636  // we stop the queue
637  if (txq)
638  {
639  if ((m_queue->GetMode () == Queue::QUEUE_MODE_PACKETS &&
640  m_queue->GetNPackets () >= m_queue->GetMaxPackets ()) ||
641  (m_queue->GetMode () == Queue::QUEUE_MODE_BYTES &&
642  m_queue->GetNBytes () + m_mtu > m_queue->GetMaxBytes ()))
643  {
644  NS_LOG_DEBUG ("The device queue is being stopped (" << m_queue->GetNPackets () <<
645  " packets and " << m_queue->GetNBytes () << " bytes inside)");
646  txq->Stop ();
647  }
648  }
649  return true;
650  }
651 
652  // Enqueue may fail (overflow). This should not happen if the traffic control
653  // module has been installed. Anyway, stop the tx queue, so that the upper layers
654  // do not send packets until there is room in the queue again.
655  m_macTxDropTrace (packet);
656  if (txq)
657  {
658  NS_LOG_ERROR ("BUG! Device queue full when the queue is not stopped! (" << m_queue->GetNPackets () <<
659  " packets and " << m_queue->GetNBytes () << " bytes inside)");
660  txq->Stop ();
661  }
662  return false;
663 }
664 
665 bool
667  const Address &source,
668  const Address &dest,
669  uint16_t protocolNumber)
670 {
671  NS_LOG_FUNCTION (this << packet << source << dest << protocolNumber);
672  return false;
673 }
674 
675 Ptr<Node>
677 {
678  return m_node;
679 }
680 
681 void
683 {
684  NS_LOG_FUNCTION (this);
685  m_node = node;
686 }
687 
688 bool
690 {
691  NS_LOG_FUNCTION (this);
692  return false;
693 }
694 
695 void
697 {
698  m_rxCallback = cb;
699 }
700 
701 void
703 {
704  m_promiscCallback = cb;
705 }
706 
707 bool
709 {
710  NS_LOG_FUNCTION (this);
711  return false;
712 }
713 
714 void
716 {
717  NS_LOG_FUNCTION (this << p);
718  Receive (p);
719 }
720 
721 Address
723 {
724  NS_LOG_FUNCTION (this);
725  NS_ASSERT (m_channel->GetNDevices () == 2);
726  for (uint32_t i = 0; i < m_channel->GetNDevices (); ++i)
727  {
728  Ptr<NetDevice> tmp = m_channel->GetDevice (i);
729  if (tmp != this)
730  {
731  return tmp->GetAddress ();
732  }
733  }
734  NS_ASSERT (false);
735  // quiet compiler.
736  return Address ();
737 }
738 
739 bool
741 {
742  NS_LOG_FUNCTION (this << mtu);
743  m_mtu = mtu;
744  return true;
745 }
746 
747 uint16_t
749 {
750  NS_LOG_FUNCTION (this);
751  return m_mtu;
752 }
753 
754 uint16_t
756 {
758  switch(proto)
759  {
760  case 0x0021: return 0x0800; //IPv4
761  case 0x0057: return 0x86DD; //IPv6
762  default: NS_ASSERT_MSG (false, "PPP Protocol number not defined!");
763  }
764  return 0;
765 }
766 
767 uint16_t
769 {
771  switch(proto)
772  {
773  case 0x0800: return 0x0021; //IPv4
774  case 0x86DD: return 0x0057; //IPv6
775  default: NS_ASSERT_MSG (false, "PPP Protocol number not defined!");
776  }
777  return 0;
778 }
779 
780 
781 } // 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: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.
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
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
virtual ~PointToPointNetDevice()
Destroy a PointToPointNetDevice.
Use number of bytes for maximum queue size.
Definition: queue.h:133
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:368
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:792
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.
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:608
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:1238
virtual void SetAddress(Address address)
Set the address of this interface.
AttributeValue implementation for Time.
Definition: nstime.h:957
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
#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:958
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: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:405
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.
#define NS_LOG_DEBUG(msg)
Use NS_LOG to output a message of level LOG_DEBUG.
Definition: log.h:236
virtual bool IsBroadcast(void) const
Time Seconds(double value)
Construct a Time in the indicated unit.
Definition: nstime.h:895
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)
virtual void NotifyNewAggregate(void)
Notify all Objects aggregated to this one of a new Object being aggregated.
#define NS_LOG_ERROR(msg)
Use NS_LOG to output a message of level LOG_ERROR.
Definition: log.h:220
Use number of packets for maximum queue size.
Definition: queue.h:132
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:904
virtual Address GetBroadcast(void) const
void AddHeader(const Header &header)
Add header to this packet.
Definition: packet.cc:257
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. ...