A Discrete-Event Network Simulator
API
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
fd-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) 2012 INRIA, 2012 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  * Author: Alina Quereilhac <alina.quereilhac@inria.fr>
19  * Claudio Freire <klaussfreire@sourceforge.net>
20  */
21 
22 #include "fd-net-device.h"
23 
24 #include "ns3/abort.h"
25 #include "ns3/boolean.h"
26 #include "ns3/channel.h"
27 #include "ns3/enum.h"
28 #include "ns3/ethernet-header.h"
29 #include "ns3/ethernet-trailer.h"
30 #include "ns3/log.h"
31 #include "ns3/llc-snap-header.h"
32 #include "ns3/mac48-address.h"
33 #include "ns3/pointer.h"
34 #include "ns3/simulator.h"
35 #include "ns3/string.h"
36 #include "ns3/trace-source-accessor.h"
37 #include "ns3/uinteger.h"
38 
39 #include <unistd.h>
40 #include <arpa/inet.h>
41 #include <net/ethernet.h>
42 
43 NS_LOG_COMPONENT_DEFINE ("FdNetDevice");
44 
45 namespace ns3 {
46 
48  : m_bufferSize (65536) // Defaults to maximum TCP window size
49 {
50 }
51 
52 void
54 {
55  m_bufferSize = bufferSize;
56 }
57 
59 {
60  NS_LOG_FUNCTION (this);
61 
62  uint8_t *buf = (uint8_t *)malloc (m_bufferSize);
63  NS_ABORT_MSG_IF (buf == 0, "malloc() failed");
64 
65  NS_LOG_LOGIC ("Calling read on fd " << m_fd);
66  ssize_t len = read (m_fd, buf, m_bufferSize);
67  if (len <= 0)
68  {
69  free (buf);
70  buf = 0;
71  len = 0;
72  }
73 
74  return FdReader::Data (buf, len);
75 }
76 
78  ;
79 
80 TypeId
82 {
83  static TypeId tid = TypeId ("ns3::FdNetDevice")
84  .SetParent<NetDevice> ()
85  .AddConstructor<FdNetDevice> ()
86  .AddAttribute ("Address",
87  "The MAC address of this device.",
88  Mac48AddressValue (Mac48Address ("ff:ff:ff:ff:ff:ff")),
89  MakeMac48AddressAccessor (&FdNetDevice::m_address),
90  MakeMac48AddressChecker ())
91  .AddAttribute ("Start",
92  "The simulation time at which to spin up the device thread.",
93  TimeValue (Seconds (0.)),
94  MakeTimeAccessor (&FdNetDevice::m_tStart),
95  MakeTimeChecker ())
96  .AddAttribute ("Stop",
97  "The simulation time at which to tear down the device thread.",
98  TimeValue (Seconds (0.)),
99  MakeTimeAccessor (&FdNetDevice::m_tStop),
100  MakeTimeChecker ())
101  .AddAttribute ("EncapsulationMode",
102  "The link-layer encapsulation type to use.",
103  EnumValue (DIX),
105  MakeEnumChecker (DIX, "Dix",
106  LLC, "Llc",
107  DIXPI, "DixPi"))
108  .AddAttribute ("RxQueueSize", "Maximum size of the read queue. "
109  "This value limits number of packets that have been read "
110  "from the network into a memory buffer but have not yet "
111  "been processed by the simulator.",
112  UintegerValue (1000),
113  MakeUintegerAccessor (&FdNetDevice::m_maxPendingReads),
114  MakeUintegerChecker<uint32_t> ())
115  //
116  // Trace sources at the "top" of the net device, where packets transition
117  // to/from higher layers. These points do not really correspond to the
118  // MAC layer of the underlying operating system, but exist to provide
119  // a consitent tracing environment. These trace hooks should really be
120  // interpreted as the points at which a packet leaves the ns-3 environment
121  // destined for the underlying operating system or vice-versa.
122  //
123  .AddTraceSource ("MacTx",
124  "Trace source indicating a packet has arrived for transmission by this device",
126  .AddTraceSource ("MacTxDrop",
127  "Trace source indicating a packet has been dropped by the device before transmission",
129  .AddTraceSource ("MacPromiscRx",
130  "A packet has been received by this device, has been passed up from the physical layer "
131  "and is being forwarded up the local protocol stack. This is a promiscuous trace,",
133  .AddTraceSource ("MacRx",
134  "A packet has been received by this device, has been passed up from the physical layer "
135  "and is being forwarded up the local protocol stack. This is a non-promiscuous trace,",
137 
138  //
139  // Trace sources designed to simulate a packet sniffer facility (tcpdump).
140  //
141  .AddTraceSource ("Sniffer",
142  "Trace source simulating a non-promiscuous packet sniffer attached to the device",
144  .AddTraceSource ("PromiscSniffer",
145  "Trace source simulating a promiscuous packet sniffer attached to the device",
147  ;
148  return tid;
149 }
150 
152  : m_node (0),
153  m_ifIndex (0),
154  m_mtu (1500), // Defaults to Ethernet v2 MTU
155  m_fd (-1),
156  m_fdReader (0),
157  m_isBroadcast (true),
158  m_isMulticast (false),
159  m_pendingReadCount (0),
160  m_startEvent (),
161  m_stopEvent ()
162 {
163  NS_LOG_FUNCTION (this);
164  Start (m_tStart);
165 }
166 
168 {
169 }
170 
172 {
173  NS_LOG_FUNCTION (this);
174 }
175 
176 void
178 {
179  NS_LOG_FUNCTION (this);
180  StopDevice ();
182 }
183 
184 void
186 {
187  NS_LOG_FUNCTION (mode);
188  m_encapMode = mode;
189  NS_LOG_LOGIC ("m_encapMode = " << m_encapMode);
190 }
191 
194 {
195  NS_LOG_FUNCTION (this);
196  return m_encapMode;
197 }
198 
199 void
201 {
202  NS_LOG_FUNCTION (tStart);
205 }
206 
207 void
209 {
210  NS_LOG_FUNCTION (tStop);
213 }
214 
215 void
217 {
218  NS_LOG_FUNCTION (this);
219 
220  if (m_fd == -1)
221  {
222  NS_LOG_DEBUG ("FdNetDevice::Start(): Failure, invalid file descriptor.");
223  return;
224  }
225  //
226  // A similar story exists for the node ID. We can't just naively do a
227  // GetNode ()->GetId () since GetNode is going to give us a Ptr<Node> which
228  // is reference counted. We need to stash away the node ID for use in the
229  // read thread.
230  //
231  m_nodeId = GetNode ()->GetId ();
232 
233  m_fdReader = Create<FdNetDeviceFdReader> ();
234  m_fdReader->SetBufferSize(m_mtu);
236 
237  NotifyLinkUp ();
238 }
239 
240 void
242 {
243  NS_LOG_FUNCTION (this);
244 
245  if (m_fdReader != 0)
246  {
247  m_fdReader->Stop ();
248  m_fdReader = 0;
249  }
250 
251  if (m_fd != -1)
252  {
253  close (m_fd);
254  m_fd = -1;
255  }
256 }
257 
258 void
259 FdNetDevice::ReceiveCallback (uint8_t *buf, ssize_t len)
260 {
261  NS_LOG_FUNCTION (this << buf << len);
262  bool skip = false;
263 
264  {
267  {
268  //XXX: Packet dropped!
269  skip = true;
270  }
271  else
272  {
274  }
275  }
276 
277  if (skip)
278  {
279  struct timespec time = { 0, 100000000L }; // 100 ms
280  nanosleep (&time, NULL);
281  }
282  else
283  {
285  }
286 }
287 
291 static void
292 AddPIHeader (uint8_t *&buf, ssize_t &len)
293 {
294  // Synthesize PI header for our friend the kernel
295  uint8_t *buf2 = (uint8_t*)malloc (len + 4);
296  memcpy (buf2 + 4, buf, len);
297  len += 4;
298 
299  // PI = 16 bits flags (0) + 16 bits proto
300  // NOTE: be careful to interpret buffer data explicitly as
301  // little-endian to be insensible to native byte ordering.
302  uint16_t flags = 0;
303  uint16_t proto = 0x0008; // default to IPv4
304  if (len > 14)
305  {
306  if (buf[12] == 0x81 && buf[13] == 0x00 && len > 18)
307  {
308  // tagged ethernet packet
309  proto = buf[16] | (buf[17] << 8);
310  }
311  else
312  {
313  // untagged ethernet packet
314  proto = buf[12] | (buf[13] << 8);
315  }
316  }
317  buf2[0] = (uint8_t)flags;
318  buf2[1] = (uint8_t)(flags >> 8);
319  buf2[2] = (uint8_t)proto;
320  buf2[3] = (uint8_t)(proto >> 8);
321 
322  // swap buffer
323  free (buf);
324  buf = buf2;
325 }
326 
327 static void
328 RemovePIHeader (uint8_t *&buf, ssize_t &len)
329 {
330  // strip PI header if present, shrink buffer
331  if (len >= 4)
332  {
333  len -= 4;
334  memmove (buf, buf + 4, len);
335  buf = (uint8_t*)realloc (buf, len);
336  }
337 }
338 
339 void
340 FdNetDevice::ForwardUp (uint8_t *buf, ssize_t len)
341 {
342  NS_LOG_FUNCTION (this << buf << len);
343 
344  if (m_pendingReadCount > 0)
345  {
346  {
349  }
350  }
351 
352  // We need to remove the PI header and ignore it
353  if (m_encapMode == DIXPI)
354  {
355  RemovePIHeader (buf, len);
356  }
357 
358  //
359  // Create a packet out of the buffer we received and free that buffer.
360  //
361  Ptr<Packet> packet = Create<Packet> (reinterpret_cast<const uint8_t *> (buf), len);
362  free (buf);
363  buf = 0;
364 
365  //
366  // Trace sinks will expect complete packets, not packets without some of the
367  // headers
368  //
369  Ptr<Packet> originalPacket = packet->Copy ();
370 
371  Mac48Address destination;
372  Mac48Address source;
373  uint16_t protocol;
374  bool isBroadcast = false;
375  bool isMulticast = false;
376 
377  EthernetHeader header (false);
378 
379  //
380  // This device could be running in an environment where completely unexpected
381  // kinds of packets are flying around, so we need to harden things a bit and
382  // filter out packets we think are completely bogus, so we always check to see
383  // that the packet is long enough to contain the header we want to remove.
384  //
385  if (packet->GetSize () < header.GetSerializedSize ())
386  {
387  m_phyRxDropTrace (originalPacket);
388  return;
389  }
390 
391  packet->RemoveHeader (header);
392  destination = header.GetDestination ();
393  source = header.GetSource ();
394  isBroadcast = header.GetDestination ().IsBroadcast ();
395  isMulticast = header.GetDestination ().IsGroup ();
396  protocol = header.GetLengthType ();
397 
398  //
399  // If the length/type is less than 1500, it corresponds to a length
400  // interpretation packet. In this case, it is an 802.3 packet and
401  // will also have an 802.2 LLC header. If greater than 1500, we
402  // find the protocol number (Ethernet type) directly.
403  //
404  if (m_encapMode == LLC and header.GetLengthType () <= 1500)
405  {
406  LlcSnapHeader llc;
407  //
408  // Check to see that the packet is long enough to possibly contain the
409  // header we want to remove before just naively calling.
410  //
411  if (packet->GetSize () < llc.GetSerializedSize ())
412  {
413  m_phyRxDropTrace (originalPacket);
414  return;
415  }
416 
417  packet->RemoveHeader (llc);
418  protocol = llc.GetType ();
419  }
420 
421  NS_LOG_LOGIC ("Pkt source is " << source);
422  NS_LOG_LOGIC ("Pkt destination is " << destination);
423 
424  PacketType packetType;
425 
426  if (isBroadcast)
427  {
428  packetType = NS3_PACKET_BROADCAST;
429  }
430  else if (isMulticast)
431  {
432  packetType = NS3_PACKET_MULTICAST;
433  }
434  else if (destination == m_address)
435  {
436  packetType = NS3_PACKET_HOST;
437  }
438  else
439  {
440  packetType = NS3_PACKET_OTHERHOST;
441  }
442 
443  //
444  // For all kinds of packetType we receive, we hit the promiscuous sniffer
445  // hook and pass a copy up to the promiscuous callback. Pass a copy to
446  // make sure that nobody messes with our packet.
447  //
448  m_promiscSnifferTrace (originalPacket);
449 
450  if (!m_promiscRxCallback.IsNull ())
451  {
452  m_macPromiscRxTrace (originalPacket);
453  m_promiscRxCallback (this, packet, protocol, source, destination,
454  packetType);
455  }
456 
457  //
458  // If this packet is not destined for some other host, it must be for us
459  // as either a broadcast, multicast or unicast. We need to hit the mac
460  // packet received trace hook and forward the packet up the stack.
461  //
462  if (packetType != NS3_PACKET_OTHERHOST)
463  {
464  m_snifferTrace (originalPacket);
465  m_macRxTrace (originalPacket);
466  m_rxCallback (this, packet, protocol, source);
467  }
468 }
469 
470 bool
471 FdNetDevice::Send (Ptr<Packet> packet, const Address& destination, uint16_t protocolNumber)
472 {
473  NS_LOG_FUNCTION (this << packet << destination << protocolNumber);
474  return SendFrom (packet, m_address, destination, protocolNumber);
475 }
476 
477 bool
478 FdNetDevice::SendFrom (Ptr<Packet> packet, const Address& src, const Address& dest, uint16_t protocolNumber)
479 {
480  NS_LOG_FUNCTION (this << packet << src << dest << protocolNumber);
481  NS_LOG_LOGIC ("packet " << packet);
482  NS_LOG_LOGIC ("UID is " << packet->GetUid ());
483 
484  if (IsLinkUp () == false)
485  {
486  m_macTxDropTrace (packet);
487  return false;
488  }
489 
490  Mac48Address destination = Mac48Address::ConvertFrom (dest);
492 
493  NS_LOG_LOGIC ("Transmit packet with UID " << packet->GetUid ());
494  NS_LOG_LOGIC ("Transmit packet from " << source);
495  NS_LOG_LOGIC ("Transmit packet to " << destination);
496 
497  EthernetHeader header (false);
498  header.SetSource (source);
499  header.SetDestination (destination);
500 
501  if (m_encapMode == LLC)
502  {
503  LlcSnapHeader llc;
504  llc.SetType (protocolNumber);
505  packet->AddHeader (llc);
506 
507  header.SetLengthType (packet->GetSize ());
508  }
509  else
510  {
511  header.SetLengthType (protocolNumber);
512  }
513 
514  packet->AddHeader (header);
515 
516  //
517  // there's not much meaning associated with the different layers in this
518  // device, so don't be surprised when they're all stacked together in
519  // essentially one place. We do this for trace consistency across devices.
520  //
521  m_macTxTrace (packet);
522 
523  m_promiscSnifferTrace (packet);
524  m_snifferTrace (packet);
525 
526  NS_LOG_LOGIC ("calling write");
527 
528  NS_ASSERT_MSG (packet->GetSize () <= m_mtu, "FdNetDevice::SendFrom(): Packet too big " << packet->GetSize ());
529 
530  ssize_t len = (ssize_t) packet->GetSize ();
531  uint8_t *buffer = (uint8_t*)malloc (len);
532  packet->CopyData (buffer, len);
533 
534  // We need to add the PI header
535  if (m_encapMode == DIXPI)
536  {
537  AddPIHeader (buffer, len);
538  }
539 
540  ssize_t written = write (m_fd, buffer, len);
541  free (buffer);
542 
543  if (written == -1 || written != len)
544  {
545  m_macTxDropTrace (packet);
546  return false;
547  }
548 
549  return true;
550 }
551 
552 void
554 {
555  if (m_fd == -1 and fd > 0)
556  {
557  m_fd = fd;
558  }
559 }
560 
561 void
563 {
565 }
566 
567 Address
569 {
570  return m_address;
571 }
572 
573 void
575 {
576  m_linkUp = true;
578 }
579 
580 void
581 FdNetDevice::SetIfIndex (const uint32_t index)
582 {
583  m_ifIndex = index;
584 }
585 
586 uint32_t
588 {
589  return m_ifIndex;
590 }
591 
594 {
595  return NULL;
596 }
597 
598 bool
599 FdNetDevice::SetMtu (const uint16_t mtu)
600 {
601  // The MTU depends on the technology associated to
602  // the file descriptor. The user is responsible of
603  // setting the correct value of the MTU.
604  // If the file descriptor is created using a helper,
605  // then is the responsibility of the helper to set
606  // the correct MTU value.
607  m_mtu = mtu;
608  return true;
609 }
610 
611 uint16_t
613 {
614  return m_mtu;
615 }
616 
617 bool
619 {
620  return m_linkUp;
621 }
622 
623 void
625 {
627 }
628 
629 bool
631 {
632  return m_isBroadcast;
633 }
634 
635 void
637 {
638  m_isBroadcast = broadcast;
639 }
640 
641 Address
643 {
644  return Mac48Address ("ff:ff:ff:ff:ff:ff");
645 }
646 
647 bool
649 {
650  return m_isMulticast;
651 }
652 
653 void
655 {
656  m_isMulticast = multicast;
657 }
658 
659 Address
661 {
662  return Mac48Address::GetMulticast (multicastGroup);
663 }
664 
665 Address
667 {
668  return Mac48Address::GetMulticast (addr);
669 }
670 
671 bool
673 {
674  return false;
675 }
676 
677 bool
679 {
680  return false;
681 }
682 
683 Ptr<Node>
685 {
686  return m_node;
687 }
688 
689 void
691 {
692  m_node = node;
693 }
694 
695 bool
697 {
698  return true;
699 }
700 
701 void
703 {
704  m_rxCallback = cb;
705 }
706 
707 void
709 {
710  m_promiscRxCallback = cb;
711 }
712 
713 bool
715 {
716  return true;
717 }
718 
719 } // namespace ns3
virtual bool IsPointToPoint(void) const
Return true if the net device is on a point-to-point link.
uint32_t RemoveHeader(Header &header)
Deserialize and remove the header from the internal buffer.
Definition: packet.cc:268
keep track of time values and allow control of global simulation resolution
Definition: nstime.h:81
void StopDevice(void)
A structure representing data read.
#define NS_LOG_FUNCTION(parameters)
Definition: log.h:345
Ptr< const AttributeChecker > MakeEnumChecker(int v1, std::string n1, int v2, std::string n2, int v3, std::string n3, int v4, std::string n4, int v5, std::string n5, int v6, std::string n6, int v7, std::string n7, int v8, std::string n8, int v9, std::string n9, int v10, std::string n10, int v11, std::string n11, int v12, std::string n12, int v13, std::string n13, int v14, std::string n14, int v15, std::string n15, int v16, std::string n16, int v17, std::string n17, int v18, std::string n18, int v19, std::string n19, int v20, std::string n20, int v21, std::string n21, int v22, std::string n22)
Definition: enum.cc:178
DIX II / Ethernet II packet.
Definition: fd-net-device.h:92
void ForwardUp(uint8_t *buf, ssize_t len)
void SetFileDescriptor(int fd)
Set the associated file descriptor.
virtual void AddLinkChangeCallback(Callback< void > callback)
virtual bool SupportsSendFrom() const
EncapsulationMode m_encapMode
When using TAP devices, if flag IFF_NO_PI is not set on the device, IP packets will have an extra hea...
Definition: fd-net-device.h:94
virtual bool NeedsArp(void) const
TracedCallback< Ptr< const Packet > > m_macRxTrace
The trace source fired for packets successfully received by the device immediately before being forwa...
uint64_t GetUid(void) const
A packet is allocated a new uid when it is created empty or with zero-filled payload.
Definition: packet.cc:393
bool IsNull(void) const
Check for null implementation.
Definition: callback.h:1014
virtual bool SendFrom(Ptr< Packet > packet, const Address &source, const Address &dest, uint16_t protocolNumber)
NS_OBJECT_ENSURE_REGISTERED(NullMessageSimulatorImpl)
uint16_t GetLengthType(void) const
uint32_t GetSize(void) const
Definition: packet.h:650
bool IsBroadcast(void) const
NetDevice::ReceiveCallback m_rxCallback
The callback used to notify higher layers that a packet has been received.
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...
static void RemovePIHeader(uint8_t *&buf, ssize_t &len)
virtual void DoDispose(void)
This method is called by Object::Dispose or by the object's destructor, whichever comes first...
Definition: object.cc:336
static void Cancel(const EventId &id)
Set the cancel bit on this event: the event's associated function will not be invoked when it expires...
Definition: simulator.cc:268
virtual bool IsMulticast(void) const
void SetType(uint16_t type)
Ptr< FdNetDeviceFdReader > m_fdReader
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:824
void Stop(Time tStop)
Set a stop time for the device.
virtual void SetIsBroadcast(bool broadcast)
virtual uint32_t GetIfIndex(void) const
void SetSource(Mac48Address source)
virtual void SetIfIndex(const uint32_t index)
a polymophic address class
Definition: address.h:86
void NotifyLinkUp(void)
virtual Ptr< Node > GetNode(void) const
TracedCallback< Ptr< const Packet > > m_macTxTrace
The trace source fired when packets come into the "top" of the device at the L3/L2 transition...
hold variables of type 'enum'
Definition: enum.h:37
virtual Ptr< Channel > GetChannel(void) const
static Mac48Address GetMulticast(Ipv4Address address)
hold objects of type ns3::Time
Definition: nstime.h:961
uint16_t GetType(void)
int m_fd
The file descriptor to read from.
virtual void SetIsMulticast(bool multicast)
A class which provides a simple way to implement a Critical Section.
Definition: system-mutex.h:109
Hold an unsigned integer type.
Definition: uinteger.h:46
virtual bool IsBridge(void) const
Return true if the net device is acting as a bridge.
uint32_t m_maxPendingReads
virtual Address GetBroadcast(void) const
FdNetDeviceFdReader()
Constructor for the FdNetDevice.
Callback< R > MakeCallback(R(T::*memPtr)(void), OBJ objPtr)
Definition: callback.h:1238
void StartDevice(void)
void ReceiveCallback(uint8_t *buf, ssize_t len)
Ptr< Node > m_node
virtual Address GetMulticast(Ipv4Address multicastGroup) const
Make and return a MAC multicast address using the provided multicast group.
static void ScheduleWithContext(uint32_t context, Time const &time, MEM mem_ptr, OBJ obj)
Schedule an event with the given context.
Definition: simulator.h:904
#define NS_LOG_LOGIC(msg)
Definition: log.h:368
virtual bool IsLinkUp(void) const
NS_LOG_COMPONENT_DEFINE("FdNetDevice")
static Mac48Address ConvertFrom(const Address &address)
void SetEncapsulationMode(FdNetDevice::EncapsulationMode mode)
Set the link layer encapsulation mode of this device.
virtual void SetPromiscReceiveCallback(NetDevice::PromiscReceiveCallback cb)
Ptr< Packet > Copy(void) const
Definition: packet.cc:122
TracedCallback m_linkChangeCallbacks
TracedCallback< Ptr< const Packet > > m_promiscSnifferTrace
A trace source that emulates a promiscuous mode protocol sniffer connected to the device...
bool IsGroup(void) const
virtual bool IsBroadcast(void) const
Ptr< const TraceSourceAccessor > MakeTraceSourceAccessor(T a)
virtual void SetNode(Ptr< Node > node)
an EUI-48 address
Definition: mac48-address.h:41
Packet header for Ethernet.
TracedCallback< Ptr< const Packet > > m_snifferTrace
A trace source that emulates a non-promiscuous protocol sniffer connected to the device.
FdReader::Data DoRead(void)
The read implementation.
Ptr< const AttributeAccessor > MakeEnumAccessor(T1 a1)
Definition: enum.h:118
FdNetDevice::EncapsulationMode GetEncapsulationMode(void) const
Get the link layer encapsulation mode of this device.
#define NS_ASSERT_MSG(condition, message)
Definition: assert.h:86
Mac48Address GetSource(void) const
TracedCallback< Ptr< const Packet > > m_phyRxDropTrace
The trace source fired when the phy layer drops a packet it has received.
uint32_t m_pendingReadCount
virtual bool SetMtu(const uint16_t mtu)
Describes an IPv6 address.
Definition: ipv6-address.h:46
Mac48Address GetDestination(void) const
Ipv4 addresses are stored in host order in this class.
Definition: ipv4-address.h:38
802.2 LLC/SNAP Packet
Definition: fd-net-device.h:93
static TypeId GetTypeId(void)
void ConnectWithoutContext(const CallbackBase &callback)
uint32_t GetId(void) const
Definition: node.cc:104
virtual Address GetAddress(void) const
Network layer to device interface.
Definition: net-device.h:75
hold objects of type ns3::Mac48Address
virtual void SetAddress(Address address)
Set the address of this interface.
virtual uint32_t GetSerializedSize(void) const
void Start(Time tStart)
Set a start time for the device.
#define NS_LOG_DEBUG(msg)
Definition: log.h:289
virtual void SetReceiveCallback(NetDevice::ReceiveCallback cb)
virtual uint32_t GetSerializedSize(void) const
NetDevice::PromiscReceiveCallback m_promiscRxCallback
The callback used to notify higher layers that a packet has been received in promiscuous mode...
void SetLengthType(uint16_t size)
TracedCallback< Ptr< const Packet > > m_macPromiscRxTrace
The trace source fired for packets successfully received by the device immediately before being forwa...
EncapsulationMode
Enumeration of the types of frames supported in the class.
Definition: fd-net-device.h:90
void SetBufferSize(uint32_t bufferSize)
Set size of the read buffer.
EventImpl * MakeEvent(void(*f)(void))
Definition: make-event.cc:8
Ptr< const AttributeChecker > MakeTimeChecker(const Time min, const Time max)
Helper to make a Time checker with bounded range.
Definition: time.cc:452
uint32_t CopyData(uint8_t *buffer, uint32_t size) const
Copy the packet contents to a byte buffer.
Definition: packet.cc:381
a NetDevice to read/write network traffic from/into a file descriptor.
Definition: fd-net-device.h:82
tuple address
Definition: first.py:37
Mac48Address m_address
PacketType
Packet types are used as they are in Linux.
Definition: net-device.h:270
#define NS_ABORT_MSG_IF(cond, msg)
Abnormal program termination if cond is true.
Definition: abort.h:98
static void AddPIHeader(uint8_t *&buf, ssize_t &len)
virtual uint16_t GetMtu(void) const
void SetDestination(Mac48Address destination)
virtual void DoDispose(void)
This method is called by Object::Dispose or by the object's destructor, whichever comes first...
a unique identifier for an interface.
Definition: type-id.h:49
FdNetDevice()
Constructor for the FdNetDevice.
virtual ~FdNetDevice()
Destructor for the FdNetDevice.
TypeId SetParent(TypeId tid)
Definition: type-id.cc:611
virtual bool Send(Ptr< Packet > packet, const Address &dest, uint16_t protocolNumber)
void AddHeader(const Header &header)
Add header to this packet.
Definition: packet.cc:253
Header for the LLC/SNAP encapsulation.
SystemMutex m_pendingReadMutex