A Discrete-Event Network Simulator
API
Loading...
Searching...
No Matches
fd-net-device.cc
Go to the documentation of this file.
1/*
2 * Copyright (c) 2012 INRIA, 2012 University of Washington
3 *
4 * SPDX-License-Identifier: GPL-2.0-only
5 *
6 * Author: Alina Quereilhac <alina.quereilhac@inria.fr>
7 * Claudio Freire <klaussfreire@sourceforge.net>
8 */
9
10#include "fd-net-device.h"
11
12#include "ns3/abort.h"
13#include "ns3/boolean.h"
14#include "ns3/channel.h"
15#include "ns3/enum.h"
16#include "ns3/ethernet-header.h"
17#include "ns3/ethernet-trailer.h"
18#include "ns3/llc-snap-header.h"
19#include "ns3/log.h"
20#include "ns3/mac48-address.h"
21#include "ns3/pointer.h"
22#include "ns3/simulator.h"
23#include "ns3/string.h"
24#include "ns3/trace-source-accessor.h"
25#include "ns3/uinteger.h"
26
27#include <arpa/inet.h>
28#include <net/ethernet.h>
29#include <unistd.h>
30
31namespace ns3
32{
33
34NS_LOG_COMPONENT_DEFINE("FdNetDevice");
35
37 : m_bufferSize(65536) // Defaults to maximum TCP window size
38{
39}
40
41void
43{
44 NS_LOG_FUNCTION(this << bufferSize);
45 m_bufferSize = bufferSize;
46}
47
50{
51 NS_LOG_FUNCTION(this);
52
53 auto buf = (uint8_t*)malloc(m_bufferSize);
54 NS_ABORT_MSG_IF(buf == nullptr, "malloc() failed");
55
56 NS_LOG_LOGIC("Calling read on fd " << m_fd);
57 ssize_t len = read(m_fd, buf, m_bufferSize);
58 if (len <= 0)
59 {
60 free(buf);
61 buf = nullptr;
62 len = 0;
63 }
64 NS_LOG_LOGIC("Read " << len << " bytes on fd " << m_fd);
65 return FdReader::Data(buf, len);
66}
67
69
72{
73 static TypeId tid =
74 TypeId("ns3::FdNetDevice")
76 .SetGroupName("FdNetDevice")
77 .AddConstructor<FdNetDevice>()
78 .AddAttribute("Address",
79 "The MAC address of this device.",
80 Mac48AddressValue(Mac48Address("ff:ff:ff:ff:ff:ff")),
83 .AddAttribute("Start",
84 "The simulation time at which to spin up "
85 "the device thread.",
86 TimeValue(Seconds(0.)),
89 .AddAttribute("Stop",
90 "The simulation time at which to tear down "
91 "the device thread.",
92 TimeValue(Seconds(0.)),
95 .AddAttribute("EncapsulationMode",
96 "The link-layer encapsulation type to use.",
99 MakeEnumChecker(DIX, "Dix", LLC, "Llc", DIXPI, "DixPi"))
100 .AddAttribute("RxQueueSize",
101 "Maximum size of the read queue. "
102 "This value limits number of packets that have been read "
103 "from the network into a memory buffer but have not yet "
104 "been processed by the simulator.",
105 UintegerValue(1000),
108 //
109 // Trace sources at the "top" of the net device, where packets transition
110 // to/from higher layers. These points do not really correspond to the
111 // MAC layer of the underlying operating system, but exist to provide
112 // a consistent tracing environment. These trace hooks should really be
113 // interpreted as the points at which a packet leaves the ns-3 environment
114 // destined for the underlying operating system or vice-versa.
115 //
116 .AddTraceSource("MacTx",
117 "Trace source indicating a packet has "
118 "arrived for transmission by this device",
120 "ns3::Packet::TracedCallback")
121 .AddTraceSource("MacTxDrop",
122 "Trace source indicating a packet has "
123 "been dropped by the device before transmission",
125 "ns3::Packet::TracedCallback")
126 .AddTraceSource("MacPromiscRx",
127 "A packet has been received by this device, "
128 "has been passed up from the physical layer "
129 "and is being forwarded up the local protocol stack. "
130 "This is a promiscuous trace,",
132 "ns3::Packet::TracedCallback")
133 .AddTraceSource("MacRx",
134 "A packet has been received by this device, "
135 "has been passed up from the physical layer "
136 "and is being forwarded up the local protocol stack. "
137 "This is a non-promiscuous trace,",
139 "ns3::Packet::TracedCallback")
140
141 //
142 // Trace sources designed to simulate a packet sniffer facility (tcpdump).
143 //
144 .AddTraceSource("Sniffer",
145 "Trace source simulating a non-promiscuous "
146 "packet sniffer attached to the device",
148 "ns3::Packet::TracedCallback")
149 .AddTraceSource("PromiscSniffer",
150 "Trace source simulating a promiscuous "
151 "packet sniffer attached to the device",
153 "ns3::Packet::TracedCallback");
154 return tid;
155}
156
158 : m_node(nullptr),
159 m_ifIndex(0),
160 // Defaults to Ethernet v2 MTU
161 m_mtu(1500),
162 m_fd(-1),
163 m_fdReader(nullptr),
164 m_isBroadcast(true),
165 m_isMulticast(false),
166 m_startEvent(),
167 m_stopEvent()
168{
169 NS_LOG_FUNCTION(this);
170}
171
176
177void
179{
180 NS_LOG_FUNCTION(this);
182 if (m_tStop != Seconds(0))
183 {
184 Stop(m_tStop);
185 }
186
188}
189
190void
197
198void
200{
201 NS_LOG_FUNCTION(this << mode);
202 m_encapMode = mode;
203 NS_LOG_LOGIC("m_encapMode = " << m_encapMode);
204}
205
208{
209 NS_LOG_FUNCTION(this);
210 return m_encapMode;
211}
212
213void
220
221void
228
229void
231{
232 NS_LOG_FUNCTION(this);
233
234 if (m_fd == -1)
235 {
236 NS_LOG_DEBUG("FdNetDevice::Start(): Failure, invalid file descriptor.");
237 return;
238 }
239
242
244
245 NotifyLinkUp();
246}
247
250{
251 NS_LOG_FUNCTION(this);
252
254 // 22 bytes covers 14 bytes Ethernet header with possible 8 bytes LLC/SNAP
255 fdReader->SetBufferSize(m_mtu + 22);
256 return fdReader;
257}
258
259void
264
265void
270
271void
273{
274 NS_LOG_FUNCTION(this);
275
276 if (m_fdReader)
277 {
278 m_fdReader->Stop();
279 m_fdReader = nullptr;
280 }
281
282 if (m_fd != -1)
283 {
284 close(m_fd);
285 m_fd = -1;
286 }
287
288 while (!m_pendingQueue.empty())
289 {
290 std::pair<uint8_t*, ssize_t> next = m_pendingQueue.front();
291 m_pendingQueue.pop();
292 FreeBuffer(next.first);
293 }
294
296}
297
298void
299FdNetDevice::ReceiveCallback(uint8_t* buf, ssize_t len)
300{
301 NS_LOG_FUNCTION(this << static_cast<void*>(buf) << len);
302 bool skip = false;
303
304 {
305 std::unique_lock lock{m_pendingReadMutex};
306 if (m_pendingQueue.size() >= m_maxPendingReads)
307 {
308 NS_LOG_WARN("Packet dropped");
309 skip = true;
310 }
311 else
312 {
313 m_pendingQueue.emplace(buf, len);
314 }
315 }
316
317 if (skip)
318 {
319 struct timespec time = {0, 100000000L}; // 100 ms
320 nanosleep(&time, nullptr);
321 }
322 else
323 {
325 }
326}
327
328/**
329 * \ingroup fd-net-device
330 * \brief Synthesize PI header for the kernel
331 * \param buf the buffer to add the header to
332 * \param len the buffer length
333 *
334 * \todo Consider having a instance member m_packetBuffer and using memmove
335 * instead of memcpy to add the PI header. It might be faster in this case
336 * to use memmove and avoid the extra mallocs.
337 */
338static void
339AddPIHeader(uint8_t*& buf, size_t& len)
340{
341 // Synthesize PI header for our friend the kernel
342 auto buf2 = (uint8_t*)malloc(len + 4);
343 memcpy(buf2 + 4, buf, len);
344 len += 4;
345
346 // PI = 16 bits flags (0) + 16 bits proto
347 // NOTE: be careful to interpret buffer data explicitly as
348 // little-endian to be insensible to native byte ordering.
349 uint16_t flags = 0;
350 uint16_t proto = 0x0008; // default to IPv4
351 if (len > 14)
352 {
353 if (buf[12] == 0x81 && buf[13] == 0x00 && len > 18)
354 {
355 // tagged ethernet packet
356 proto = buf[16] | (buf[17] << 8);
357 }
358 else
359 {
360 // untagged ethernet packet
361 proto = buf[12] | (buf[13] << 8);
362 }
363 }
364 buf2[0] = (uint8_t)flags;
365 buf2[1] = (uint8_t)(flags >> 8);
366 buf2[2] = (uint8_t)proto;
367 buf2[3] = (uint8_t)(proto >> 8);
368
369 // swap buffer
370 free(buf);
371 buf = buf2;
372}
373
374/**
375 * \ingroup fd-net-device
376 * \brief Removes PI header
377 * \param buf the buffer to add the header to
378 * \param len the buffer length
379 */
380static void
381RemovePIHeader(uint8_t*& buf, ssize_t& len)
382{
383 // strip PI header if present, shrink buffer
384 if (len >= 4)
385 {
386 len -= 4;
387 memmove(buf, buf + 4, len);
388 buf = (uint8_t*)realloc(buf, len);
389 }
390}
391
392uint8_t*
394{
395 return (uint8_t*)malloc(len);
396}
397
398void
400{
401 free(buf);
402}
403
404void
406{
407 NS_LOG_FUNCTION(this);
408
409 uint8_t* buf = nullptr;
410 ssize_t len = 0;
411
412 if (m_pendingQueue.empty())
413 {
414 NS_LOG_LOGIC("buffer is empty, probably the device is stopped.");
415 return;
416 }
417
418 {
419 std::unique_lock lock{m_pendingReadMutex};
420 std::pair<uint8_t*, ssize_t> next = m_pendingQueue.front();
421 m_pendingQueue.pop();
422
423 buf = next.first;
424 len = next.second;
425 }
426
427 NS_LOG_LOGIC("buffer: " << static_cast<void*>(buf) << " length: " << len);
428
429 // We need to remove the PI header and ignore it
430 if (m_encapMode == DIXPI)
431 {
432 RemovePIHeader(buf, len);
433 }
434
435 //
436 // Create a packet out of the buffer we received and free that buffer.
437 //
438 Ptr<Packet> packet = Create<Packet>(reinterpret_cast<const uint8_t*>(buf), len);
439 FreeBuffer(buf);
440 buf = nullptr;
441
442 //
443 // Trace sinks will expect complete packets, not packets without some of the
444 // headers
445 //
446 Ptr<Packet> originalPacket = packet->Copy();
447
448 Mac48Address destination;
449 Mac48Address source;
450 uint16_t protocol;
451 bool isBroadcast = false;
452 bool isMulticast = false;
453
454 EthernetHeader header(false);
455
456 //
457 // This device could be running in an environment where completely unexpected
458 // kinds of packets are flying around, so we need to harden things a bit and
459 // filter out packets we think are completely bogus, so we always check to see
460 // that the packet is long enough to contain the header we want to remove.
461 //
462 if (packet->GetSize() < header.GetSerializedSize())
463 {
464 m_phyRxDropTrace(originalPacket);
465 return;
466 }
467
468 packet->RemoveHeader(header);
469 destination = header.GetDestination();
470 source = header.GetSource();
471 isBroadcast = header.GetDestination().IsBroadcast();
472 isMulticast = header.GetDestination().IsGroup();
473 protocol = header.GetLengthType();
474
475 //
476 // If the length/type is less than 1500, it corresponds to a length
477 // interpretation packet. In this case, it is an 802.3 packet and
478 // will also have an 802.2 LLC header. If greater than 1500, we
479 // find the protocol number (Ethernet type) directly.
480 //
481 if (m_encapMode == LLC and header.GetLengthType() <= 1500)
482 {
483 LlcSnapHeader llc;
484 //
485 // Check to see that the packet is long enough to possibly contain the
486 // header we want to remove before just naively calling.
487 //
488 if (packet->GetSize() < llc.GetSerializedSize())
489 {
490 m_phyRxDropTrace(originalPacket);
491 return;
492 }
493
494 packet->RemoveHeader(llc);
495 protocol = llc.GetType();
496 }
497
498 NS_LOG_LOGIC("Pkt source is " << source);
499 NS_LOG_LOGIC("Pkt destination is " << destination);
500
501 PacketType packetType;
502
503 if (isBroadcast)
504 {
505 packetType = NS3_PACKET_BROADCAST;
506 }
507 else if (isMulticast)
508 {
509 packetType = NS3_PACKET_MULTICAST;
510 }
511 else if (destination == m_address)
512 {
513 packetType = NS3_PACKET_HOST;
514 }
515 else
516 {
517 packetType = NS3_PACKET_OTHERHOST;
518 }
519
520 //
521 // For all kinds of packetType we receive, we hit the promiscuous sniffer
522 // hook and pass a copy up to the promiscuous callback. Pass a copy to
523 // make sure that nobody messes with our packet.
524 //
525 m_promiscSnifferTrace(originalPacket);
526
528 {
529 m_macPromiscRxTrace(originalPacket);
530 m_promiscRxCallback(this, packet, protocol, source, destination, packetType);
531 }
532
533 //
534 // If this packet is not destined for some other host, it must be for us
535 // as either a broadcast, multicast or unicast. We need to hit the mac
536 // packet received trace hook and forward the packet up the stack.
537 //
538 if (packetType != NS3_PACKET_OTHERHOST)
539 {
540 m_snifferTrace(originalPacket);
541 m_macRxTrace(originalPacket);
542 m_rxCallback(this, packet, protocol, source);
543 }
544}
545
546bool
547FdNetDevice::Send(Ptr<Packet> packet, const Address& destination, uint16_t protocolNumber)
548{
549 NS_LOG_FUNCTION(this << packet << destination << protocolNumber);
550 return SendFrom(packet, m_address, destination, protocolNumber);
551}
552
553bool
555 const Address& src,
556 const Address& dest,
557 uint16_t protocolNumber)
558{
559 NS_LOG_FUNCTION(this << packet << src << dest << protocolNumber);
560 NS_LOG_LOGIC("packet: " << packet << " UID: " << packet->GetUid());
561
562 if (!IsLinkUp())
563 {
564 m_macTxDropTrace(packet);
565 return false;
566 }
567
568 Mac48Address destination = Mac48Address::ConvertFrom(dest);
570
571 NS_LOG_LOGIC("Transmit packet with UID " << packet->GetUid());
572 NS_LOG_LOGIC("Transmit packet from " << source);
573 NS_LOG_LOGIC("Transmit packet to " << destination);
574
575 EthernetHeader header(false);
576 header.SetSource(source);
577 header.SetDestination(destination);
578
579 NS_ASSERT_MSG(packet->GetSize() <= m_mtu,
580 "FdNetDevice::SendFrom(): Packet too big " << packet->GetSize());
581
582 if (m_encapMode == LLC)
583 {
584 LlcSnapHeader llc;
585 llc.SetType(protocolNumber);
586 packet->AddHeader(llc);
587
588 header.SetLengthType(packet->GetSize());
589 }
590 else
591 {
592 header.SetLengthType(protocolNumber);
593 }
594
595 packet->AddHeader(header);
596
597 //
598 // there's not much meaning associated with the different layers in this
599 // device, so don't be surprised when they're all stacked together in
600 // essentially one place. We do this for trace consistency across devices.
601 //
602 m_macTxTrace(packet);
603
604 m_promiscSnifferTrace(packet);
605 m_snifferTrace(packet);
606
607 NS_LOG_LOGIC("calling write");
608
609 auto len = (size_t)packet->GetSize();
610 uint8_t* buffer = AllocateBuffer(len);
611 if (!buffer)
612 {
613 m_macTxDropTrace(packet);
614 return false;
615 }
616
617 packet->CopyData(buffer, len);
618
619 // We need to add the PI header
620 if (m_encapMode == DIXPI)
621 {
622 AddPIHeader(buffer, len);
623 }
624
625 ssize_t written = Write(buffer, len);
626 FreeBuffer(buffer);
627
628 if (written == -1 || (size_t)written != len)
629 {
630 m_macTxDropTrace(packet);
631 return false;
632 }
633
634 return true;
635}
636
637ssize_t
638FdNetDevice::Write(uint8_t* buffer, size_t length)
639{
640 NS_LOG_FUNCTION(this << static_cast<void*>(buffer) << length);
641
642 uint32_t ret = write(m_fd, buffer, length);
643 return ret;
644}
645
646void
648{
649 if (m_fd == -1 and fd > 0)
650 {
651 m_fd = fd;
652 }
653}
654
655int
657{
658 return m_fd;
659}
660
661void
666
669{
670 return m_address;
671}
672
673void
679
680void
682{
683 m_ifIndex = index;
684}
685
688{
689 return m_ifIndex;
690}
691
694{
695 return nullptr;
696}
697
698bool
699FdNetDevice::SetMtu(const uint16_t mtu)
700{
701 // The MTU depends on the technology associated to
702 // the file descriptor. The user is responsible of
703 // setting the correct value of the MTU.
704 // If the file descriptor is created using a helper,
705 // then is the responsibility of the helper to set
706 // the correct MTU value.
707 m_mtu = mtu;
708 return true;
709}
710
711uint16_t
713{
714 return m_mtu;
715}
716
717bool
719{
720 return m_linkUp;
721}
722
723void
728
729bool
731{
732 return m_isBroadcast;
733}
734
735void
737{
738 m_isBroadcast = broadcast;
739}
740
746
747bool
749{
750 return m_isMulticast;
751}
752
753void
755{
756 m_isMulticast = multicast;
757}
758
761{
762 return Mac48Address::GetMulticast(multicastGroup);
763}
764
770
771bool
773{
774 return false;
775}
776
777bool
779{
780 return false;
781}
782
785{
786 return m_node;
787}
788
789void
791{
792 m_node = node;
793
794 // Save the node ID for use in the read thread, to avoid having
795 // to make a call to GetNode ()->GetId () that increments
796 // Ptr<Node>'s reference count.
797 m_nodeId = node->GetId();
798}
799
800bool
802{
803 return true;
804}
805
806void
811
812void
817
818bool
820{
821 return true;
822}
823
824} // namespace ns3
a polymophic address class
Definition address.h:90
bool IsNull() const
Check for null implementation.
Definition callback.h:555
Hold variables of type enum.
Definition enum.h:52
Packet header for Ethernet.
uint16_t GetLengthType() const
uint32_t GetSerializedSize() const override
void SetDestination(Mac48Address destination)
Mac48Address GetDestination() const
void SetLengthType(uint16_t size)
void SetSource(Mac48Address source)
Mac48Address GetSource() const
uint32_t m_bufferSize
size of the read buffer
void SetBufferSize(uint32_t bufferSize)
Set size of the read buffer.
FdReader::Data DoRead() override
The read implementation.
a NetDevice to read/write network traffic from/into a file descriptor.
EventId m_stopEvent
NetDevice stop event.
void StopDevice()
Tear down the device.
virtual void FreeBuffer(uint8_t *buf)
Free the given packet buffer.
bool m_isBroadcast
Flag indicating whether or not the underlying net device supports broadcast.
Ptr< FdReader > m_fdReader
Reader for the file descriptor.
bool IsMulticast() const override
uint32_t m_ifIndex
The ns-3 interface index (in the sense of net device index) that has been assigned to this network de...
int m_fd
The file descriptor used for receive/send network traffic.
virtual uint8_t * AllocateBuffer(size_t len)
Allocate packet buffer.
uint16_t m_mtu
The MTU associated to the file descriptor technology.
void SetReceiveCallback(NetDevice::ReceiveCallback cb) override
virtual void SetIsBroadcast(bool broadcast)
Set if the NetDevice is able to send Broadcast messages.
Ptr< Node > GetNode() const override
void Start(Time tStart)
Set a start time for the device.
Ptr< Node > m_node
The ns-3 node associated to the net device.
bool SetMtu(const uint16_t mtu) override
int GetFileDescriptor() const
Get the associated file descriptor.
TracedCallback m_linkChangeCallbacks
Callbacks to fire if the link changes state (up or down).
virtual Ptr< FdReader > DoCreateFdReader()
Create the FdReader object.
void SetAddress(Address address) override
Set the address of this interface.
uint32_t m_maxPendingReads
Maximum number of packets that can be received and scheduled for read but not yet read.
std::mutex m_pendingReadMutex
Mutex to increase pending read counter.
Address GetBroadcast() const override
NetDevice::ReceiveCallback m_rxCallback
The callback used to notify higher layers that a packet has been received.
TracedCallback< Ptr< const Packet > > m_macRxTrace
The trace source fired for packets successfully received by the device immediately before being forwa...
Time m_tStart
Time to start spinning up the device.
void SetNode(Ptr< Node > node) override
std::queue< std::pair< uint8_t *, ssize_t > > m_pendingQueue
Number of packets that were received and scheduled for read but not yet read.
void Stop(Time tStop)
Set a stop time for the device.
void SetIfIndex(const uint32_t index) override
EventId m_startEvent
NetDevice start event.
void StartDevice()
Spin up the device.
bool m_isMulticast
Flag indicating whether or not the underlying net device supports multicast.
void DoDispose() override
Destructor implementation.
TracedCallback< Ptr< const Packet > > m_macTxTrace
The trace source fired when packets come into the "top" of the device at the L3/L2 transition,...
bool IsBroadcast() const override
TracedCallback< Ptr< const Packet > > m_promiscSnifferTrace
A trace source that emulates a promiscuous mode protocol sniffer connected to the device.
Address GetAddress() const override
FdNetDevice()
Constructor for the FdNetDevice.
TracedCallback< Ptr< const Packet > > m_snifferTrace
A trace source that emulates a non-promiscuous protocol sniffer connected to the device.
bool NeedsArp() const override
~FdNetDevice() override
Destructor for the FdNetDevice.
uint16_t GetMtu() const override
void SetEncapsulationMode(FdNetDevice::EncapsulationMode mode)
Set the link layer encapsulation mode of this device.
static TypeId GetTypeId()
Get the type ID.
bool IsBridge() const override
Return true if the net device is acting as a bridge.
void SetPromiscReceiveCallback(NetDevice::PromiscReceiveCallback cb) override
EncapsulationMode m_encapMode
The type of encapsulation of the received/transmitted frames.
bool SendFrom(Ptr< Packet > packet, const Address &source, const Address &dest, uint16_t protocolNumber) override
Ptr< Channel > GetChannel() const override
NetDevice::PromiscReceiveCallback m_promiscRxCallback
The callback used to notify higher layers that a packet has been received in promiscuous mode.
void NotifyLinkUp()
Notify that the link is up and ready.
TracedCallback< Ptr< const Packet > > m_phyRxDropTrace
The trace source fired when the phy layer drops a packet it has received.
Address GetMulticast(Ipv4Address multicastGroup) const override
Make and return a MAC multicast address using the provided multicast group.
uint32_t GetIfIndex() const override
void AddLinkChangeCallback(Callback< void > callback) override
EncapsulationMode
Enumeration of the types of frames supported in the class.
@ DIX
DIX II / Ethernet II packet.
@ DIXPI
When using TAP devices, if flag IFF_NO_PI is not set on the device, IP packets will have an extra hea...
@ LLC
802.2 LLC/SNAP Packet
bool m_linkUp
Flag indicating whether or not the link is up.
TracedCallback< Ptr< const Packet > > m_macPromiscRxTrace
The trace source fired for packets successfully received by the device immediately before being forwa...
virtual void DoFinishStoppingDevice()
Complete additional actions, if any, to tear down the device.
bool Send(Ptr< Packet > packet, const Address &dest, uint16_t protocolNumber) override
void SetFileDescriptor(int fd)
Set the associated file descriptor.
Time m_tStop
Time to start tearing down the device.
virtual ssize_t Write(uint8_t *buffer, size_t length)
Write packet data to device.
bool IsLinkUp() const override
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...
Mac48Address m_address
The net device mac address.
virtual void SetIsMulticast(bool multicast)
Set if the NetDevice is able to send Multicast messages.
void ForwardUp()
Forward the frame to the appropriate callback for processing.
void DoInitialize() override
Method Initialization for start and stop attributes.
FdNetDevice::EncapsulationMode GetEncapsulationMode() const
Get the link layer encapsulation mode of this device.
bool SupportsSendFrom() const override
uint32_t m_nodeId
a copy of the node id so the read thread doesn't have to GetNode() in in order to find the node ID.
virtual void DoFinishStartingDevice()
Complete additional actions, if any, to spin up down the device.
bool IsPointToPoint() const override
Return true if the net device is on a point-to-point link.
int m_fd
The file descriptor to read from.
Definition fd-reader.h:124
Ipv4 addresses are stored in host order in this class.
Describes an IPv6 address.
Header for the LLC/SNAP encapsulation.
uint16_t GetType()
Return the Ethertype.
uint32_t GetSerializedSize() const override
void SetType(uint16_t type)
Set the Ethertype.
an EUI-48 address
static Mac48Address GetMulticast(Ipv4Address address)
bool IsGroup() const
static Mac48Address ConvertFrom(const Address &address)
static Mac48Address GetBroadcast()
bool IsBroadcast() const
Network layer to device interface.
Definition net-device.h:87
PacketType
Packet types are used as they are in Linux.
Definition net-device.h:289
Callback< bool, Ptr< NetDevice >, Ptr< const Packet >, uint16_t, const Address & > ReceiveCallback
Definition net-device.h:311
virtual void DoInitialize()
Initialize() implementation.
Definition object.cc:440
virtual void DoDispose()
Destructor implementation.
Definition object.cc:433
Smart pointer class similar to boost::intrusive_ptr.
static EventId Schedule(const Time &delay, FUNC f, Ts &&... args)
Schedule an event to expire after delay.
Definition simulator.h:560
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:274
static void ScheduleWithContext(uint32_t context, const Time &delay, FUNC f, Ts &&... args)
Schedule an event with the given context.
Definition simulator.h:577
Simulation virtual time values and global simulation resolution.
Definition nstime.h:94
void ConnectWithoutContext(const CallbackBase &callback)
Append a Callback to the chain (without a context).
a unique identifier for an interface.
Definition type-id.h:48
TypeId SetParent(TypeId tid)
Set the parent TypeId.
Definition type-id.cc:1001
Hold an unsigned integer type.
Definition uinteger.h:34
#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:75
std::enable_if_t< std::is_member_pointer_v< MEM >, EventImpl * > MakeEvent(MEM mem_ptr, OBJ obj, Ts... args)
Make an EventImpl from class method members which take varying numbers of arguments.
Definition make-event.h:133
#define NS_ABORT_MSG_IF(cond, msg)
Abnormal program termination if a condition is true, with a message.
Definition abort.h:97
static void RemovePIHeader(uint8_t *&buf, ssize_t &len)
Removes PI header.
static void AddPIHeader(uint8_t *&buf, size_t &len)
Synthesize PI header for the kernel.
#define NS_LOG_COMPONENT_DEFINE(name)
Define a Log component with a specific name.
Definition log.h:191
#define NS_LOG_DEBUG(msg)
Use NS_LOG to output a message of level LOG_DEBUG.
Definition log.h:257
#define NS_LOG_LOGIC(msg)
Use NS_LOG to output a message of level LOG_LOGIC.
Definition log.h:271
#define NS_LOG_FUNCTION(parameters)
If log level LOG_FUNCTION is enabled, this macro will output all input parameters separated by ",...
#define NS_LOG_WARN(msg)
Use NS_LOG to output a message of level LOG_WARN.
Definition log.h:250
#define NS_OBJECT_ENSURE_REGISTERED(type)
Register an Object subclass with the TypeId system.
Definition object-base.h:35
Ptr< T > Create(Ts &&... args)
Create class instances by constructors with varying numbers of arguments and return them by Ptr.
Definition ptr.h:436
Time Seconds(double value)
Construct a Time in the indicated unit.
Definition nstime.h:1308
Ptr< const TraceSourceAccessor > MakeTraceSourceAccessor(T a)
Create a TraceSourceAccessor which will control access to the underlying trace source.
Every class exported by the ns3 library is enclosed in the ns3 namespace.
Ptr< const AttributeChecker > MakeUintegerChecker()
Definition uinteger.h:85
Ptr< const AttributeAccessor > MakeTimeAccessor(T1 a1)
Definition nstime.h:1396
Callback< R, Args... > MakeCallback(R(T::*memPtr)(Args...), OBJ objPtr)
Build Callbacks for class method members which take varying numbers of arguments and potentially retu...
Definition callback.h:684
Ptr< const AttributeAccessor > MakeUintegerAccessor(T1 a1)
Definition uinteger.h:35
Ptr< const AttributeAccessor > MakeMac48AddressAccessor(T1 a1)
Ptr< const AttributeChecker > MakeMac48AddressChecker()
Ptr< const AttributeChecker > MakeEnumChecker(T v, std::string n, Ts... args)
Make an EnumChecker pre-configured with a set of allowed values by name.
Definition enum.h:179
Ptr< const AttributeAccessor > MakeEnumAccessor(T1 a1)
Definition enum.h:221
Ptr< const AttributeChecker > MakeTimeChecker()
Helper to make an unbounded Time checker.
Definition nstime.h:1416
A structure representing data read.
Definition fd-reader.h:80