A Discrete-Event Network Simulator
API
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
fd-net-device.cc
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 
77 NS_OBJECT_ENSURE_REGISTERED (FdNetDevice);
78 
79 TypeId
80 FdNetDevice::GetTypeId (void)
81 {
82  static TypeId tid = TypeId ("ns3::FdNetDevice")
83  .SetParent<NetDevice> ()
84  .AddConstructor<FdNetDevice> ()
85  .AddAttribute ("Address",
86  "The MAC address of this device.",
87  Mac48AddressValue (Mac48Address ("ff:ff:ff:ff:ff:ff")),
88  MakeMac48AddressAccessor (&FdNetDevice::m_address),
89  MakeMac48AddressChecker ())
90  .AddAttribute ("Start",
91  "The simulation time at which to spin up the device thread.",
92  TimeValue (Seconds (0.)),
93  MakeTimeAccessor (&FdNetDevice::m_tStart),
94  MakeTimeChecker ())
95  .AddAttribute ("Stop",
96  "The simulation time at which to tear down the device thread.",
97  TimeValue (Seconds (0.)),
98  MakeTimeAccessor (&FdNetDevice::m_tStop),
99  MakeTimeChecker ())
100  .AddAttribute ("EncapsulationMode",
101  "The link-layer encapsulation type to use.",
102  EnumValue (DIX),
103  MakeEnumAccessor (&FdNetDevice::m_encapMode),
104  MakeEnumChecker (DIX, "Dix",
105  LLC, "Llc",
106  DIXPI, "DixPi"))
107  .AddAttribute ("RxQueueSize", "Maximum size of the read queue. "
108  "This value limits number of packets that have been read "
109  "from the network into a memory buffer but have not yet "
110  "been processed by the simulator.",
111  UintegerValue (1000),
112  MakeUintegerAccessor (&FdNetDevice::m_maxPendingReads),
113  MakeUintegerChecker<uint32_t> ())
114  //
115  // Trace sources at the "top" of the net device, where packets transition
116  // to/from higher layers. These points do not really correspond to the
117  // MAC layer of the underlying operating system, but exist to provide
118  // a consitent tracing environment. These trace hooks should really be
119  // interpreted as the points at which a packet leaves the ns-3 environment
120  // destined for the underlying operating system or vice-versa.
121  //
122  .AddTraceSource ("MacTx",
123  "Trace source indicating a packet has arrived for transmission by this device",
125  .AddTraceSource ("MacTxDrop",
126  "Trace source indicating a packet has been dropped by the device before transmission",
128  .AddTraceSource ("MacPromiscRx",
129  "A packet has been received by this device, has been passed up from the physical layer "
130  "and is being forwarded up the local protocol stack. This is a promiscuous trace,",
132  .AddTraceSource ("MacRx",
133  "A packet has been received by this device, has been passed up from the physical layer "
134  "and is being forwarded up the local protocol stack. This is a non-promiscuous trace,",
136 
137  //
138  // Trace sources designed to simulate a packet sniffer facility (tcpdump).
139  //
140  .AddTraceSource ("Sniffer",
141  "Trace source simulating a non-promiscuous packet sniffer attached to the device",
143  .AddTraceSource ("PromiscSniffer",
144  "Trace source simulating a promiscuous packet sniffer attached to the device",
146  ;
147  return tid;
148 }
149 
151  : m_node (0),
152  m_ifIndex (0),
153  m_mtu (1500), // Defaults to Ethernet v2 MTU
154  m_fd (-1),
155  m_fdReader (0),
156  m_isBroadcast (true),
157  m_isMulticast (false),
158  m_pendingReadCount (0),
159  m_startEvent (),
160  m_stopEvent ()
161 {
162  NS_LOG_FUNCTION (this);
163  Start (m_tStart);
164 }
165 
167 {
168 }
169 
171 {
172  NS_LOG_FUNCTION (this);
173 }
174 
175 void
177 {
178  NS_LOG_FUNCTION (this);
179  StopDevice ();
181 }
182 
183 void
185 {
186  NS_LOG_FUNCTION (mode);
187  m_encapMode = mode;
188  NS_LOG_LOGIC ("m_encapMode = " << m_encapMode);
189 }
190 
193 {
194  NS_LOG_FUNCTION (this);
195  return m_encapMode;
196 }
197 
198 void
200 {
201  NS_LOG_FUNCTION (tStart);
202  Simulator::Cancel (m_startEvent);
203  m_startEvent = Simulator::Schedule (tStart, &FdNetDevice::StartDevice, this);
204 }
205 
206 void
208 {
209  NS_LOG_FUNCTION (tStop);
210  Simulator::Cancel (m_stopEvent);
211  m_startEvent = Simulator::Schedule (tStop, &FdNetDevice::StopDevice, this);
212 }
213 
214 void
216 {
217  NS_LOG_FUNCTION (this);
218 
219  if (m_fd == -1)
220  {
221  NS_LOG_DEBUG ("FdNetDevice::Start(): Failure, invalid file descriptor.");
222  return;
223  }
224  //
225  // A similar story exists for the node ID. We can't just naively do a
226  // GetNode ()->GetId () since GetNode is going to give us a Ptr<Node> which
227  // is reference counted. We need to stash away the node ID for use in the
228  // read thread.
229  //
230  m_nodeId = GetNode ()->GetId ();
231 
232  m_fdReader = Create<FdNetDeviceFdReader> ();
233  m_fdReader->SetBufferSize(m_mtu);
235 
236  NotifyLinkUp ();
237 }
238 
239 void
241 {
242  NS_LOG_FUNCTION (this);
243 
244  if (m_fdReader != 0)
245  {
246  m_fdReader->Stop ();
247  m_fdReader = 0;
248  }
249 
250  if (m_fd != -1)
251  {
252  close (m_fd);
253  m_fd = -1;
254  }
255 }
256 
257 void
258 FdNetDevice::ReceiveCallback (uint8_t *buf, ssize_t len)
259 {
260  NS_LOG_FUNCTION (this << buf << len);
261  bool skip = false;
262 
263  {
266  {
267  //XXX: Packet dropped!
268  skip = true;
269  }
270  else
271  {
273  }
274  }
275 
276  if (skip)
277  {
278  struct timespec time = { 0, 100000000L }; // 100 ms
279  nanosleep (&time, NULL);
280  }
281  else
282  {
283  Simulator::ScheduleWithContext (m_nodeId, Time (0), MakeEvent (&FdNetDevice::ForwardUp, this, buf, len));
284  }
285 }
286 
287 // XXX: Consider having a instance member m_packetBuffer and using memmove
288 // instead of memcpy to add the PI header.
289 // It might be faster in this case to use memmove and avoid the extra mallocs.
290 static void
291 AddPIHeader (uint8_t *&buf, ssize_t &len)
292 {
293  // Synthesize PI header for our friend the kernel
294  uint8_t *buf2 = (uint8_t*)malloc (len + 4);
295  memcpy (buf2 + 4, buf, len);
296  len += 4;
297 
298  // PI = 16 bits flags (0) + 16 bits proto
299  // NOTE: be careful to interpret buffer data explicitly as
300  // little-endian to be insensible to native byte ordering.
301  uint16_t flags = 0;
302  uint16_t proto = 0x0008; // default to IPv4
303  if (len > 14)
304  {
305  if (buf[12] == 0x81 && buf[13] == 0x00 && len > 18)
306  {
307  // tagged ethernet packet
308  proto = buf[16] | (buf[17] << 8);
309  }
310  else
311  {
312  // untagged ethernet packet
313  proto = buf[12] | (buf[13] << 8);
314  }
315  }
316  buf2[0] = (uint8_t)flags;
317  buf2[1] = (uint8_t)(flags >> 8);
318  buf2[2] = (uint8_t)proto;
319  buf2[3] = (uint8_t)(proto >> 8);
320 
321  // swap buffer
322  free (buf);
323  buf = buf2;
324 }
325 
326 static void
327 RemovePIHeader (uint8_t *&buf, ssize_t &len)
328 {
329  // strip PI header if present, shrink buffer
330  if (len >= 4)
331  {
332  len -= 4;
333  memmove (buf, buf + 4, len);
334  buf = (uint8_t*)realloc (buf, len);
335  }
336 }
337 
338 void
339 FdNetDevice::ForwardUp (uint8_t *buf, ssize_t len)
340 {
341  NS_LOG_FUNCTION (this << buf << len);
342 
343  if (m_pendingReadCount > 0)
344  {
345  {
348  }
349  }
350 
351  // We need to remove the PI header and ignore it
352  if (m_encapMode == DIXPI)
353  {
354  RemovePIHeader (buf, len);
355  }
356 
357  //
358  // Create a packet out of the buffer we received and free that buffer.
359  //
360  Ptr<Packet> packet = Create<Packet> (reinterpret_cast<const uint8_t *> (buf), len);
361  free (buf);
362  buf = 0;
363 
364  //
365  // Trace sinks will expect complete packets, not packets without some of the
366  // headers
367  //
368  Ptr<Packet> originalPacket = packet->Copy ();
369 
370  Mac48Address destination;
371  Mac48Address source;
372  uint16_t protocol;
373  bool isBroadcast = false;
374  bool isMulticast = false;
375 
376  EthernetHeader header (false);
377 
378  //
379  // This device could be running in an environment where completely unexpected
380  // kinds of packets are flying around, so we need to harden things a bit and
381  // filter out packets we think are completely bogus, so we always check to see
382  // that the packet is long enough to contain the header we want to remove.
383  //
384  if (packet->GetSize () < header.GetSerializedSize ())
385  {
386  m_phyRxDropTrace (originalPacket);
387  return;
388  }
389 
390  packet->RemoveHeader (header);
391  destination = header.GetDestination ();
392  source = header.GetSource ();
393  isBroadcast = header.GetDestination ().IsBroadcast ();
394  isMulticast = header.GetDestination ().IsGroup ();
395  protocol = header.GetLengthType ();
396 
397  //
398  // If the length/type is less than 1500, it corresponds to a length
399  // interpretation packet. In this case, it is an 802.3 packet and
400  // will also have an 802.2 LLC header. If greater than 1500, we
401  // find the protocol number (Ethernet type) directly.
402  //
403  if (m_encapMode == LLC and header.GetLengthType () <= 1500)
404  {
405  LlcSnapHeader llc;
406  //
407  // Check to see that the packet is long enough to possibly contain the
408  // header we want to remove before just naively calling.
409  //
410  if (packet->GetSize () < llc.GetSerializedSize ())
411  {
412  m_phyRxDropTrace (originalPacket);
413  return;
414  }
415 
416  packet->RemoveHeader (llc);
417  protocol = llc.GetType ();
418  }
419 
420  NS_LOG_LOGIC ("Pkt source is " << source);
421  NS_LOG_LOGIC ("Pkt destination is " << destination);
422 
423  PacketType packetType;
424 
425  if (isBroadcast)
426  {
427  packetType = NS3_PACKET_BROADCAST;
428  }
429  else if (isMulticast)
430  {
431  packetType = NS3_PACKET_MULTICAST;
432  }
433  else if (destination == m_address)
434  {
435  packetType = NS3_PACKET_HOST;
436  }
437  else
438  {
439  packetType = NS3_PACKET_OTHERHOST;
440  }
441 
442  //
443  // For all kinds of packetType we receive, we hit the promiscuous sniffer
444  // hook and pass a copy up to the promiscuous callback. Pass a copy to
445  // make sure that nobody messes with our packet.
446  //
447  m_promiscSnifferTrace (originalPacket);
448 
449  if (!m_promiscRxCallback.IsNull ())
450  {
451  m_macPromiscRxTrace (originalPacket);
452  m_promiscRxCallback (this, packet, protocol, source, destination,
453  packetType);
454  }
455 
456  //
457  // If this packet is not destined for some other host, it must be for us
458  // as either a broadcast, multicast or unicast. We need to hit the mac
459  // packet received trace hook and forward the packet up the stack.
460  //
461  if (packetType != NS3_PACKET_OTHERHOST)
462  {
463  m_snifferTrace (originalPacket);
464  m_macRxTrace (originalPacket);
465  m_rxCallback (this, packet, protocol, source);
466  }
467 }
468 
469 bool
470 FdNetDevice::Send (Ptr<Packet> packet, const Address& destination, uint16_t protocolNumber)
471 {
472  NS_LOG_FUNCTION (this << packet << destination << protocolNumber);
473  return SendFrom (packet, m_address, destination, protocolNumber);
474 }
475 
476 bool
477 FdNetDevice::SendFrom (Ptr<Packet> packet, const Address& src, const Address& dest, uint16_t protocolNumber)
478 {
479  NS_LOG_FUNCTION (this << packet << src << dest << protocolNumber);
480  NS_LOG_LOGIC ("packet " << packet);
481  NS_LOG_LOGIC ("UID is " << packet->GetUid ());
482 
483  if (IsLinkUp () == false)
484  {
485  m_macTxDropTrace (packet);
486  return false;
487  }
488 
489  Mac48Address destination = Mac48Address::ConvertFrom (dest);
491 
492  NS_LOG_LOGIC ("Transmit packet with UID " << packet->GetUid ());
493  NS_LOG_LOGIC ("Transmit packet from " << source);
494  NS_LOG_LOGIC ("Transmit packet to " << destination);
495 
496  EthernetHeader header (false);
497  header.SetSource (source);
498  header.SetDestination (destination);
499 
500  if (m_encapMode == LLC)
501  {
502  LlcSnapHeader llc;
503  llc.SetType (protocolNumber);
504  packet->AddHeader (llc);
505 
506  header.SetLengthType (packet->GetSize ());
507  }
508  else
509  {
510  header.SetLengthType (protocolNumber);
511  }
512 
513  packet->AddHeader (header);
514 
515  //
516  // there's not much meaning associated with the different layers in this
517  // device, so don't be surprised when they're all stacked together in
518  // essentially one place. We do this for trace consistency across devices.
519  //
520  m_macTxTrace (packet);
521 
522  m_promiscSnifferTrace (packet);
523  m_snifferTrace (packet);
524 
525  NS_LOG_LOGIC ("calling write");
526 
527  NS_ASSERT_MSG (packet->GetSize () <= m_mtu, "FdNetDevice::SendFrom(): Packet too big " << packet->GetSize ());
528 
529  ssize_t len = (ssize_t) packet->GetSize ();
530  uint8_t *buffer = (uint8_t*)malloc (len);
531  packet->CopyData (buffer, len);
532 
533  // We need to add the PI header
534  if (m_encapMode == DIXPI)
535  {
536  AddPIHeader (buffer, len);
537  }
538 
539  ssize_t written = write (m_fd, buffer, len);
540  free (buffer);
541 
542  if (written == -1 || written != len)
543  {
544  m_macTxDropTrace (packet);
545  return false;
546  }
547 
548  return true;
549 }
550 
551 void
553 {
554  if (m_fd == -1 and fd > 0)
555  {
556  m_fd = fd;
557  }
558 }
559 
560 void
562 {
564 }
565 
566 Address
568 {
569  return m_address;
570 }
571 
572 void
573 FdNetDevice::NotifyLinkUp (void)
574 {
575  m_linkUp = true;
577 }
578 
579 void
580 FdNetDevice::SetIfIndex (const uint32_t index)
581 {
582  m_ifIndex = index;
583 }
584 
585 uint32_t
587 {
588  return m_ifIndex;
589 }
590 
593 {
594  return NULL;
595 }
596 
597 bool
598 FdNetDevice::SetMtu (const uint16_t mtu)
599 {
600  // The MTU depends on the technology associated to
601  // the file descriptor. The user is responsible of
602  // setting the correct value of the MTU.
603  // If the file descriptor is created using a helper,
604  // then is the responsibility of the helper to set
605  // the correct MTU value.
606  m_mtu = mtu;
607  return true;
608 }
609 
610 uint16_t
612 {
613  return m_mtu;
614 }
615 
616 bool
618 {
619  return m_linkUp;
620 }
621 
622 void
624 {
626 }
627 
628 bool
630 {
631  return m_isBroadcast;
632 }
633 
634 void
635 FdNetDevice::SetIsBroadcast (bool broadcast)
636 {
637  m_isBroadcast = broadcast;
638 }
639 
640 Address
642 {
643  return Mac48Address ("ff:ff:ff:ff:ff:ff");
644 }
645 
646 bool
648 {
649  return m_isMulticast;
650 }
651 
652 void
653 FdNetDevice::SetIsMulticast (bool multicast)
654 {
655  m_isMulticast = multicast;
656 }
657 
658 Address
660 {
661  return Mac48Address::GetMulticast (multicastGroup);
662 }
663 
664 Address
666 {
667  return Mac48Address::GetMulticast (addr);
668 }
669 
670 bool
672 {
673  return false;
674 }
675 
676 bool
678 {
679  return false;
680 }
681 
682 Ptr<Node>
684 {
685  return m_node;
686 }
687 
688 void
690 {
691  m_node = node;
692 }
693 
694 bool
696 {
697  return true;
698 }
699 
700 void
702 {
703  m_rxCallback = cb;
704 }
705 
706 void
708 {
709  m_promiscRxCallback = cb;
710 }
711 
712 bool
714 {
715  return true;
716 }
717 
718 } // 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)
Definition: packet.cc:285
keep track of time unit.
Definition: nstime.h:149
void StopDevice(void)
A structure representing data read.
#define NS_LOG_FUNCTION(parameters)
Definition: log.h:311
void ForwardUp(uint8_t *buf, ssize_t len)
void SetFileDescriptor(int fd)
virtual void AddLinkChangeCallback(Callback< void > callback)
virtual bool SupportsSendFrom() const
EncapsulationMode m_encapMode
virtual bool NeedsArp(void) const
TracedCallback< Ptr< const Packet > > m_macRxTrace
uint64_t GetUid(void) const
Definition: packet.cc:412
virtual bool SendFrom(Ptr< Packet > packet, const Address &source, const Address &dest, uint16_t protocolNumber)
#define NS_LOG_COMPONENT_DEFINE(name)
Definition: log.h:122
uint16_t GetLengthType(void) const
uint32_t GetSize(void) const
Definition: packet.h:620
bool IsBroadcast(void) const
NetDevice::ReceiveCallback m_rxCallback
TracedCallback< Ptr< const Packet > > m_macTxDropTrace
virtual void DoDispose(void)
Definition: object.cc:335
static void Cancel(const EventId &id)
Definition: simulator.cc:267
virtual bool IsMulticast(void) const
Ptr< FdNetDeviceFdReader > m_fdReader
static EventId Schedule(Time const &time, MEM mem_ptr, OBJ obj)
Definition: simulator.h:820
void Stop(Time tStop)
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
virtual Ptr< Node > GetNode(void) const
TracedCallback< Ptr< const Packet > > m_macTxTrace
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:700
int m_fd
The file descriptor to read from.
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
void StartDevice(void)
void ReceiveCallback(uint8_t *buf, ssize_t len)
Ptr< Node > m_node
Callback< R > MakeCallback(R(T::*memPtr)(void), OBJ objPtr)
Definition: callback.h:502
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)
Definition: simulator.h:900
#define NS_LOG_LOGIC(msg)
Definition: log.h:334
virtual bool IsLinkUp(void) const
static Mac48Address ConvertFrom(const Address &address)
void SetEncapsulationMode(FdNetDevice::EncapsulationMode mode)
virtual void SetPromiscReceiveCallback(NetDevice::PromiscReceiveCallback cb)
Ptr< Packet > Copy(void) const
Definition: packet.cc:131
TracedCallback m_linkChangeCallbacks
TracedCallback< Ptr< const Packet > > m_promiscSnifferTrace
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
FdReader::Data DoRead(void)
The read implementation.
FdNetDevice::EncapsulationMode GetEncapsulationMode(void) const
#define NS_ASSERT_MSG(condition, message)
Definition: assert.h:86
Mac48Address GetSource(void) const
TracedCallback< Ptr< const Packet > > m_phyRxDropTrace
uint32_t m_pendingReadCount
virtual bool SetMtu(const uint16_t mtu)
Describes an IPv6 address.
Definition: ipv6-address.h:44
Mac48Address GetDestination(void) const
Ipv4 addresses are stored in host order in this class.
Definition: ipv4-address.h:38
Time Seconds(double seconds)
create ns3::Time instances in units of seconds.
Definition: nstime.h:586
void ConnectWithoutContext(const CallbackBase &callback)
uint32_t GetId(void) const
Definition: node.cc:105
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)
virtual uint32_t GetSerializedSize(void) const
void Start(Time tStart)
#define NS_LOG_DEBUG(msg)
Definition: log.h:255
virtual void SetReceiveCallback(NetDevice::ReceiveCallback cb)
virtual uint32_t GetSerializedSize(void) const
NetDevice::PromiscReceiveCallback m_promiscRxCallback
void SetLengthType(uint16_t size)
TracedCallback< Ptr< const Packet > > m_macPromiscRxTrace
void SetBufferSize(uint32_t bufferSize)
uint32_t CopyData(uint8_t *buffer, uint32_t size) const
Definition: packet.cc:398
a NetDevice to read/write network traffic from/into a file descriptor.
Definition: fd-net-device.h:82
Mac48Address m_address
#define NS_ABORT_MSG_IF(cond, msg)
Abnormal program termination if cond is true.
Definition: abort.h:98
virtual uint16_t GetMtu(void) const
void SetDestination(Mac48Address destination)
virtual void DoDispose(void)
a unique identifier for an interface.
Definition: type-id.h:44
virtual ~FdNetDevice()
TypeId SetParent(TypeId tid)
Definition: type-id.cc:471
virtual bool Send(Ptr< Packet > packet, const Address &dest, uint16_t protocolNumber)
void AddHeader(const Header &header)
Definition: packet.cc:270
Header for the LLC/SNAP encapsulation.
SystemMutex m_pendingReadMutex