A Discrete-Event Network Simulator
API
Loading...
Searching...
No Matches
csma-net-device.h
Go to the documentation of this file.
1/*
2 * Copyright (c) 2007 Emmanuelle Laprise
3 *
4 * SPDX-License-Identifier: GPL-2.0-only
5 *
6 * Author: Emmanuelle Laprise <emmanuelle.laprise@bluekazoo.ca
7 */
8
9#ifndef CSMA_NET_DEVICE_H
10#define CSMA_NET_DEVICE_H
11
12#include "backoff.h"
13
14#include "ns3/address.h"
15#include "ns3/callback.h"
16#include "ns3/data-rate.h"
17#include "ns3/mac48-address.h"
18#include "ns3/net-device.h"
19#include "ns3/node.h"
20#include "ns3/nstime.h"
21#include "ns3/packet.h"
22#include "ns3/ptr.h"
23#include "ns3/queue-fwd.h"
24#include "ns3/traced-callback.h"
25
26#include <cstring>
27
28namespace ns3
29{
30
31class CsmaChannel;
32class ErrorModel;
33
34/**
35 * @defgroup csma CSMA Network Device
36 *
37 * This section documents the API of the ns-3 csma module. For a generic functional description,
38 * please refer to the ns-3 manual.
39 */
40
41/**
42 * @ingroup csma
43 * @class CsmaNetDevice
44 * @brief A Device for a Csma Network Link.
45 *
46 * The Csma net device class is analogous to layer 1 and 2 of the
47 * TCP stack. The NetDevice takes a raw packet of bytes and creates a
48 * protocol specific packet from them.
49 */
51{
52 public:
53 /**
54 * @brief Get the type ID.
55 * @return the object TypeId
56 */
57 static TypeId GetTypeId();
58
59 /**
60 * Enumeration of the types of packets supported in the class.
61 */
63 {
64 ILLEGAL, /**< Encapsulation mode not set */
65 DIX, /**< DIX II / Ethernet II packet */
66 LLC, /**< 802.2 LLC/SNAP Packet*/
67 };
68
69 /**
70 * Construct a CsmaNetDevice
71 *
72 * This is the default constructor for a CsmaNetDevice.
73 */
75
76 /**
77 * Destroy a CsmaNetDevice
78 *
79 * This is the destructor for a CsmaNetDevice.
80 */
81 ~CsmaNetDevice() override;
82
83 /**
84 * Set the interframe gap used to separate packets. The interframe gap
85 * defines the minimum space required between packets sent by this device.
86 * As in Ethernet, it defaults to 96 bit times.
87 *
88 * @param t the interframe gap time
89 */
90 void SetInterframeGap(Time t);
91
92 /**
93 * Set the backoff parameters used to determine the wait to retry
94 * transmitting a packet when the channel is busy.
95 *
96 * @see Attach ()
97 * @param slotTime Length of a packet slot (or average packet time)
98 * @param minSlots Minimum number of slots to wait
99 * @param maxSlots Maximum number of slots to wait
100 * @param maxRetries Maximum number of retries before packet is discard
101 * @param ceiling Cap on the exponential function when calculating max slots
102 */
103 void SetBackoffParams(Time slotTime,
104 uint32_t minSlots,
105 uint32_t maxSlots,
106 uint32_t maxRetries,
107 uint32_t ceiling);
108
109 /**
110 * Attach the device to a channel.
111 *
112 * The function Attach is used to add a CsmaNetDevice to a CsmaChannel.
113 *
114 * @see SetDataRate ()
115 * @see SetInterframeGap ()
116 * @param ch a pointer to the channel to which this object is being attached.
117 * @returns true if no error
118 */
119 bool Attach(Ptr<CsmaChannel> ch);
120
121 /**
122 * Attach a queue to the CsmaNetDevice.
123 *
124 * The CsmaNetDevice "owns" a queue. This queue may be set by higher
125 * level topology objects to implement a particular queueing method such as
126 * DropTail.
127 *
128 * @see Queue
129 * @see DropTailQueue
130 * @param queue a Ptr to the queue for being assigned to the device.
131 */
132 void SetQueue(Ptr<Queue<Packet>> queue);
133
134 /**
135 * Get a copy of the attached Queue.
136 *
137 * @return a pointer to the queue.
138 */
140
141 /**
142 * Attach a receive ErrorModel to the CsmaNetDevice.
143 *
144 * The CsmaNetDevice may optionally include an ErrorModel in
145 * the packet receive chain to simulate data errors in during transmission.
146 *
147 * @see ErrorModel
148 * @param em a pointer to the ErrorModel
149 */
151
152 /**
153 * Receive a packet from a connected CsmaChannel.
154 *
155 * The CsmaNetDevice receives packets from its connected channel
156 * and forwards them up the protocol stack. This is the public method
157 * used by the channel to indicate that the last bit of a packet has
158 * arrived at the device.
159 *
160 * @see CsmaChannel
161 * @param p a reference to the received packet
162 * @param sender the CsmaNetDevice that transmitted the packet in the first place
163 */
165
166 /**
167 * Is the send side of the network device enabled?
168 *
169 * @returns True if the send side is enabled, otherwise false.
170 */
171 bool IsSendEnabled() const;
172
173 /**
174 * Enable or disable the send side of the network device.
175 *
176 * @param enable Enable the send side if true, otherwise disable.
177 */
178 void SetSendEnable(bool enable);
179
180 /**
181 * Is the receive side of the network device enabled?
182 *
183 * @returns True if the receiver side is enabled, otherwise false.
184 */
185 bool IsReceiveEnabled() const;
186
187 /**
188 * Enable or disable the receive side of the network device.
189 *
190 * @param enable Enable the receive side if true, otherwise disable.
191 */
192 void SetReceiveEnable(bool enable);
193
194 /**
195 * Set the encapsulation mode of this device.
196 *
197 * @param mode The encapsulation mode of this device.
198 *
199 */
201
202 /**
203 * Get the encapsulation mode of this device.
204 *
205 * @returns The encapsulation mode of this device.
206 */
208
209 //
210 // The following methods are inherited from NetDevice base class.
211 //
212 void SetIfIndex(const uint32_t index) override;
213 uint32_t GetIfIndex() const override;
214 Ptr<Channel> GetChannel() const override;
215 bool SetMtu(const uint16_t mtu) override;
216 uint16_t GetMtu() const override;
217 void SetAddress(Address address) override;
218 Address GetAddress() const override;
219 bool IsLinkUp() const override;
220 void AddLinkChangeCallback(Callback<void> callback) override;
221 bool IsBroadcast() const override;
222 Address GetBroadcast() const override;
223 bool IsMulticast() const override;
224
225 /**
226 * @brief Make and return a MAC multicast address using the provided
227 * multicast group
228 *
229 * \RFC{1112} says that an Ipv4 host group address is mapped to an Ethernet
230 * multicast address by placing the low-order 23-bits of the IP address into
231 * the low-order 23 bits of the Ethernet multicast address
232 * 01-00-5E-00-00-00 (hex).
233 *
234 * This method performs the multicast address creation function appropriate
235 * to an EUI-48-based CSMA device. This MAC address is encapsulated in an
236 * abstract Address to avoid dependencies on the exact address format.
237 *
238 * @param multicastGroup The IP address for the multicast group destination
239 * of the packet.
240 * @return The MAC multicast Address used to send packets to the provided
241 * multicast group.
242 *
243 * @see Ipv4Address
244 * @see Mac48Address
245 * @see Address
246 */
247 Address GetMulticast(Ipv4Address multicastGroup) const override;
248
249 /**
250 * Is this a point to point link?
251 * @returns false.
252 */
253 bool IsPointToPoint() const override;
254
255 /**
256 * Is this a bridge?
257 * @returns false.
258 */
259 bool IsBridge() const override;
260
261 /**
262 * Start sending a packet down the channel.
263 * @param packet packet to send
264 * @param dest layer 2 destination address
265 * @param protocolNumber protocol number
266 * @return true if successful, false otherwise (drop, ...)
267 */
268 bool Send(Ptr<Packet> packet, const Address& dest, uint16_t protocolNumber) override;
269
270 /**
271 * Start sending a packet down the channel, with MAC spoofing
272 * @param packet packet to send
273 * @param source layer 2 source address
274 * @param dest layer 2 destination address
275 * @param protocolNumber protocol number
276 * @return true if successful, false otherwise (drop, ...)
277 */
278 bool SendFrom(Ptr<Packet> packet,
279 const Address& source,
280 const Address& dest,
281 uint16_t protocolNumber) override;
282
283 /**
284 * Get the node to which this device is attached.
285 *
286 * @returns Ptr to the Node to which the device is attached.
287 */
288 Ptr<Node> GetNode() const override;
289
290 /**
291 * Set the node to which this device is being attached.
292 *
293 * @param node Ptr to the Node to which the device is being attached.
294 */
295 void SetNode(Ptr<Node> node) override;
296
297 /**
298 * Does this device need to use the address resolution protocol?
299 *
300 * @returns True if the encapsulation mode is set to a value that requires
301 * ARP (IP_ARP or LLC).
302 */
303 bool NeedsArp() const override;
304
305 /**
306 * Set the callback to be used to notify higher layers when a packet has been
307 * received.
308 *
309 * @param cb The callback.
310 */
312
313 /**
314 * @brief Get the MAC multicast address corresponding
315 * to the IPv6 address provided.
316 * @param addr IPv6 address
317 * @return the MAC multicast address
318 * @warning Calling this method is invalid if IsMulticast returns not true.
319 */
320 Address GetMulticast(Ipv6Address addr) const override;
321
322 void SetPromiscReceiveCallback(PromiscReceiveCallback cb) override;
323 bool SupportsSendFrom() const override;
324
325 /**
326 * Assign a fixed random variable stream number to the random variables
327 * used by this model. Return the number of streams (possibly zero) that
328 * have been assigned.
329 *
330 * @param stream first stream index to use
331 * @return the number of stream indices assigned by this model
332 */
333 int64_t AssignStreams(int64_t stream);
334
335 protected:
336 /**
337 * Perform any object release functionality required to break reference
338 * cycles in reference counted objects held by the device.
339 */
340 void DoDispose() override;
341
342 /**
343 * Adds the necessary headers and trailers to a packet of data in order to
344 * respect the packet type
345 *
346 * @param p Packet to which header should be added
347 * @param source MAC source address from which packet should be sent
348 * @param dest MAC destination address to which packet should be sent
349 * @param protocolNumber In some protocols, identifies the type of
350 * payload contained in this packet.
351 */
352 void AddHeader(Ptr<Packet> p, Mac48Address source, Mac48Address dest, uint16_t protocolNumber);
353
354 private:
355 /**
356 * Operator = is declared but not implemented. This disables the assignment
357 * operator for CsmaNetDevice objects.
358 * @param o object to copy
359 * @returns the copied object
360 */
362
363 /**
364 * Copy constructor is declared but not implemented. This disables the
365 * copy constructor for CsmaNetDevice objects.
366 * @param o object to copy
367 */
369
370 /**
371 * Initialization function used during object construction.
372 * @param sendEnable if device will be allowed to send
373 * @param receiveEnable if device will be allowed to receive
374 */
375 void Init(bool sendEnable, bool receiveEnable);
376
377 /**
378 * Start Sending a Packet Down the Wire.
379 *
380 * The TransmitStart method is the method that is used internally in
381 * the CsmaNetDevice to begin the process of sending a packet
382 * out on the channel. A corresponding method is called on the
383 * channel to let it know that the physical device this class
384 * represents has actually started sending signals, this causes the
385 * channel to enter the BUSY state. An event is scheduled for the time at
386 * which the bits have been completely transmitted.
387 *
388 * If the channel is found to be BUSY, this method reschedules itself for
389 * execution at a later time (within the backoff period).
390 *
391 * @see CsmaChannel::TransmitStart ()
392 * @see TransmitCompleteEvent ()
393 */
394 void TransmitStart();
395
396 /**
397 * Stop Sending a Packet Down the Wire and Begin the Interframe Gap.
398 *
399 * The TransmitCompleteEvent method is used internally to finish the process
400 * of sending a packet out on the channel. During execution of this method
401 * the TransmitEnd method is called on the channel to let it know that the
402 * physical device this class represents has finished sending simulated
403 * signals. The channel uses this event to begin its speed of light delay
404 * timer after which it notifies the Net Device(s) at the other end of the
405 * link that new bits have arrived (it delivers the Packet). During this
406 * method, the net device also schedules the TransmitReadyEvent at which
407 * time the transmitter becomes ready to send the next packet.
408 *
409 * @see CsmaChannel::TransmitEnd ()
410 * @see TransmitReadyEvent ()
411 */
413
414 /**
415 * Cause the Transmitter to Become Ready to Send Another Packet.
416 *
417 * The TransmitReadyEvent method is used internally to re-enable the
418 * transmit machine of the net device. It is scheduled after a suitable
419 * interframe gap after the completion of the previous transmission.
420 * The queue is checked at this time, and if there is a packet waiting on
421 * the queue, the transmission process is begun.
422 *
423 * If a packet is in the queue, it is extracted for the queue as the
424 * next packet to be transmitted by the net device.
425 *
426 * @see TransmitStart ()
427 */
428 void TransmitReadyEvent();
429
430 /**
431 * Aborts the transmission of the current packet
432 *
433 * If the net device has tried to transmit a packet for more times
434 * than the maximum allowed number of retries (channel always busy)
435 * then the packet is dropped.
436 */
437 void TransmitAbort();
438
439 /**
440 * Notify any interested parties that the link has come up.
441 */
442 void NotifyLinkUp();
443
444 /**
445 * Device ID returned by the attached functions. It is used by the
446 * mp-channel to identify each net device to make sure that only
447 * active net devices are writing to the channel
448 */
450
451 /**
452 * Enable net device to send packets. True by default
453 */
455
456 /**
457 * Enable net device to receive packets. True by default
458 */
460
461 /**
462 * Enumeration of the states of the transmit machine of the net device.
463 */
465 {
466 READY, /**< The transmitter is ready to begin transmission of a packet */
467 BUSY, /**< The transmitter is busy transmitting a packet */
468 GAP, /**< The transmitter is in the interframe gap time */
469 BACKOFF /**< The transmitter is waiting for the channel to be free */
470 };
471
472 /**
473 * The state of the Net Device transmit state machine.
474 * @see TxMachineState
475 */
477
478 /**
479 * The type of packet that should be created by the AddHeader
480 * function and that should be processed by the ProcessHeader
481 * function.
482 */
484
485 /**
486 * The data rate that the Net Device uses to simulate packet transmission
487 * timing.
488 * @see class DataRate
489 */
491
492 /**
493 * The interframe gap that the Net Device uses insert time between packet
494 * transmission
495 * @see class Time
496 */
498
499 /**
500 * Holds the backoff parameters and is used to calculate the next
501 * backoff time to use when the channel is busy and the net device
502 * is ready to transmit
503 */
505
506 /**
507 * Next packet that will be transmitted (if transmitter is not
508 * currently transmitting) or packet that is currently being
509 * transmitted.
510 */
512
513 /**
514 * The CsmaChannel to which this CsmaNetDevice has been
515 * attached.
516 * @see class CsmaChannel
517 */
519
520 /**
521 * The Queue which this CsmaNetDevice uses as a packet source.
522 * Management of this Queue has been delegated to the CsmaNetDevice
523 * and it has the responsibility for deletion.
524 * @see class Queue
525 * @see class DropTailQueue
526 */
528
529 /**
530 * Error model for receive packet events. When active this model will be
531 * used to model transmission errors by marking some of the packets
532 * received as corrupt.
533 */
535
536 /**
537 * The trace source fired when packets come into the "top" of the device
538 * at the L3/L2 transition, before being queued for transmission.
539 *
540 * @see class CallBackTraceSource
541 */
543
544 /**
545 * The trace source fired when packets coming into the "top" of the device
546 * at the L3/L2 transition are dropped before being queued for transmission.
547 *
548 * @see class CallBackTraceSource
549 */
551
552 /**
553 * The trace source fired for packets successfully received by the device
554 * immediately before being forwarded up to higher layers (at the L2/L3
555 * transition). This is a promiscuous trace.
556 *
557 * @see class CallBackTraceSource
558 */
560
561 /**
562 * The trace source fired for packets successfully received by the device
563 * immediately before being forwarded up to higher layers (at the L2/L3
564 * transition). This is a non-promiscuous trace.
565 *
566 * @see class CallBackTraceSource
567 */
569
570 /**
571 * The trace source fired for packets successfully received by the device
572 * but dropped before being forwarded up to higher layers (at the L2/L3
573 * transition).
574 *
575 * @see class CallBackTraceSource
576 */
578
579 /**
580 * The trace source fired when the mac layer is forced to begin the backoff
581 * process for a packet. This can happen a number of times as the backoff
582 * sequence is repeated with increasing delays.
583 *
584 * @see class CallBackTraceSource
585 */
587
588 /**
589 * The trace source fired when a packet begins the transmission process on
590 * the medium.
591 *
592 * @see class CallBackTraceSource
593 */
595
596 /**
597 * The trace source fired when a packet ends the transmission process on
598 * the medium.
599 *
600 * @see class CallBackTraceSource
601 */
603
604 /**
605 * The trace source fired when the phy layer drops a packet as it tries
606 * to transmit it.
607 *
608 * @see class CallBackTraceSource
609 */
611
612 /**
613 * The trace source fired when a packet begins the reception process from
614 * the medium.
615 *
616 * @see class CallBackTraceSource
617 */
619
620 /**
621 * The trace source fired when a packet ends the reception process from
622 * the medium.
623 *
624 * @see class CallBackTraceSource
625 */
627
628 /**
629 * The trace source fired when the phy layer drops a packet it has received.
630 *
631 * @see class CallBackTraceSource
632 */
634
635 /**
636 * A trace source that emulates a non-promiscuous protocol sniffer connected
637 * to the device. Unlike your average everyday sniffer, this trace source
638 * will not fire on PACKET_OTHERHOST events.
639 *
640 * On the transmit size, this trace hook will fire after a packet is dequeued
641 * from the device queue for transmission. In Linux, for example, this would
642 * correspond to the point just before a device hard_start_xmit where
643 * dev_queue_xmit_nit is called to dispatch the packet to the PF_PACKET
644 * ETH_P_ALL handlers.
645 *
646 * On the receive side, this trace hook will fire when a packet is received,
647 * just before the receive callback is executed. In Linux, for example,
648 * this would correspond to the point at which the packet is dispatched to
649 * packet sniffers in netif_receive_skb.
650 *
651 * @see class CallBackTraceSource
652 */
654
655 /**
656 * A trace source that emulates a promiscuous mode protocol sniffer connected
657 * to the device. This trace source fire on packets destined for any host
658 * just like your average everyday packet sniffer.
659 *
660 * On the transmit size, this trace hook will fire after a packet is dequeued
661 * from the device queue for transmission. In Linux, for example, this would
662 * correspond to the point just before a device hard_start_xmit where
663 * dev_queue_xmit_nit is called to dispatch the packet to the PF_PACKET
664 * ETH_P_ALL handlers.
665 *
666 * On the receive side, this trace hook will fire when a packet is received,
667 * just before the receive callback is executed. In Linux, for example,
668 * this would correspond to the point at which the packet is dispatched to
669 * packet sniffers in netif_receive_skb.
670 *
671 * @see class CallBackTraceSource
672 */
674
675 /**
676 * The Node to which this device is attached.
677 */
679
680 /**
681 * The MAC address which has been assigned to this device.
682 */
684
685 /**
686 * The callback used to notify higher layers that a packet has been received.
687 */
689
690 /**
691 * The callback used to notify higher layers that a packet has been received in promiscuous
692 * mode.
693 */
695
696 /**
697 * The interface index (really net evice index) that has been assigned to
698 * this network device.
699 */
701
702 /**
703 * Flag indicating whether or not the link is up. In this case,
704 * whether or not the device is connected to a channel.
705 */
707
708 /**
709 * List of callbacks to fire if the link changes state (up or down).
710 */
712
713 /**
714 * Default Maximum Transmission Unit (MTU) for the CsmaNetDevice
715 */
716 static const uint16_t DEFAULT_MTU = 1500;
717
718 /**
719 * The Maximum Transmission Unit. This corresponds to the maximum
720 * number of bytes that can be transmitted as seen from higher layers.
721 * This corresponds to the 1500 byte MTU size often seen on IP over
722 * Ethernet.
723 */
725};
726
727} // namespace ns3
728
729#endif /* CSMA_NET_DEVICE_H */
a polymophic address class
Definition address.h:90
The backoff class is used for calculating backoff times when many net devices can write to the same c...
Definition backoff.h:28
Callback template class.
Definition callback.h:422
A Device for a Csma Network Link.
void SetInterframeGap(Time t)
Set the interframe gap used to separate packets.
Ptr< Queue< Packet > > GetQueue() const
Get a copy of the attached Queue.
TracedCallback< Ptr< const Packet > > m_macRxDropTrace
The trace source fired for packets successfully received by the device but dropped before being forwa...
Ptr< Node > GetNode() const override
Get the node to which this device is attached.
EncapsulationMode
Enumeration of the types of packets supported in the class.
@ ILLEGAL
Encapsulation mode not set.
@ DIX
DIX II / Ethernet II packet.
@ LLC
802.2 LLC/SNAP Packet
NetDevice::ReceiveCallback m_rxCallback
The callback used to notify higher layers that a packet has been received.
TracedCallback< Ptr< const Packet > > m_macTxBackoffTrace
The trace source fired when the mac layer is forced to begin the backoff process for a packet.
CsmaNetDevice & operator=(const CsmaNetDevice &o)
Operator = is declared but not implemented.
void SetReceiveEnable(bool enable)
Enable or disable the receive side of the network device.
Backoff m_backoff
Holds the backoff parameters and is used to calculate the next backoff time to use when the channel i...
DataRate m_bps
The data rate that the Net Device uses to simulate packet transmission timing.
void DoDispose() override
Perform any object release functionality required to break reference cycles in reference counted obje...
~CsmaNetDevice() override
Destroy a CsmaNetDevice.
bool SetMtu(const uint16_t mtu) override
void TransmitAbort()
Aborts the transmission of the current packet.
EncapsulationMode m_encapMode
The type of packet that should be created by the AddHeader function and that should be processed by t...
bool NeedsArp() const override
Does this device need to use the address resolution protocol?
TracedCallback< Ptr< const Packet > > m_macRxTrace
The trace source fired for packets successfully received by the device immediately before being forwa...
void TransmitStart()
Start Sending a Packet Down the Wire.
void SetIfIndex(const uint32_t index) override
TxMachineState
Enumeration of the states of the transmit machine of the net device.
@ BACKOFF
The transmitter is waiting for the channel to be free.
@ READY
The transmitter is ready to begin transmission of a packet.
@ BUSY
The transmitter is busy transmitting a packet.
@ GAP
The transmitter is in the interframe gap time.
Ptr< Queue< Packet > > m_queue
The Queue which this CsmaNetDevice uses as a packet source.
TracedCallback< Ptr< const Packet > > m_macPromiscRxTrace
The trace source fired for packets successfully received by the device immediately before being forwa...
uint32_t m_mtu
The Maximum Transmission Unit.
bool SupportsSendFrom() const override
NetDevice::PromiscReceiveCallback m_promiscRxCallback
The callback used to notify higher layers that a packet has been received in promiscuous mode.
CsmaNetDevice()
Construct a CsmaNetDevice.
void SetPromiscReceiveCallback(PromiscReceiveCallback cb) override
Address GetBroadcast() const override
static TypeId GetTypeId()
Get the type ID.
void Init(bool sendEnable, bool receiveEnable)
Initialization function used during object construction.
bool IsPointToPoint() const override
Is this a point to point link?
Ptr< CsmaChannel > m_channel
The CsmaChannel to which this CsmaNetDevice has been attached.
bool Attach(Ptr< CsmaChannel > ch)
Attach the device to a channel.
bool IsBridge() const override
Is this a bridge?
void TransmitCompleteEvent()
Stop Sending a Packet Down the Wire and Begin the Interframe Gap.
bool SendFrom(Ptr< Packet > packet, const Address &source, const Address &dest, uint16_t protocolNumber) override
Start sending a packet down the channel, with MAC spoofing.
void Receive(Ptr< const Packet > p, Ptr< CsmaNetDevice > sender)
Receive a packet from a connected CsmaChannel.
bool IsMulticast() const override
TracedCallback m_linkChangeCallbacks
List of callbacks to fire if the link changes state (up or down).
TracedCallback< Ptr< const Packet > > m_phyTxBeginTrace
The trace source fired when a packet begins the transmission process on the medium.
CsmaNetDevice::EncapsulationMode GetEncapsulationMode()
Get the encapsulation mode of this device.
void AddHeader(Ptr< Packet > p, Mac48Address source, Mac48Address dest, uint16_t protocolNumber)
Adds the necessary headers and trailers to a packet of data in order to respect the packet type.
uint16_t GetMtu() const override
int64_t AssignStreams(int64_t stream)
Assign a fixed random variable stream number to the random variables used by this model.
CsmaNetDevice(const CsmaNetDevice &o)
Copy constructor is declared but not implemented.
Ptr< Channel > GetChannel() const override
void NotifyLinkUp()
Notify any interested parties that the link has come up.
void SetBackoffParams(Time slotTime, uint32_t minSlots, uint32_t maxSlots, uint32_t maxRetries, uint32_t ceiling)
Set the backoff parameters used to determine the wait to retry transmitting a packet when the channel...
Ptr< Packet > m_currentPkt
Next packet that will be transmitted (if transmitter is not currently transmitting) or packet that is...
TracedCallback< Ptr< const Packet > > m_snifferTrace
A trace source that emulates a non-promiscuous protocol sniffer connected to the device.
TracedCallback< Ptr< const Packet > > m_phyTxEndTrace
The trace source fired when a packet ends the transmission process on the medium.
uint32_t m_deviceId
Device ID returned by the attached functions.
bool m_receiveEnable
Enable net device to receive packets.
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.
Ptr< Node > m_node
The Node to which this device is attached.
void SetReceiveErrorModel(Ptr< ErrorModel > em)
Attach a receive ErrorModel to the CsmaNetDevice.
void SetSendEnable(bool enable)
Enable or disable the send side of the network device.
bool IsLinkUp() const override
void TransmitReadyEvent()
Cause the Transmitter to Become Ready to Send Another Packet.
TracedCallback< Ptr< const Packet > > m_promiscSnifferTrace
A trace source that emulates a promiscuous mode protocol sniffer connected to the device.
uint32_t GetIfIndex() const override
bool IsBroadcast() const override
static const uint16_t DEFAULT_MTU
Default Maximum Transmission Unit (MTU) for the CsmaNetDevice.
void SetEncapsulationMode(CsmaNetDevice::EncapsulationMode mode)
Set the encapsulation mode of this device.
TracedCallback< Ptr< const Packet > > m_phyRxBeginTrace
The trace source fired when a packet begins the reception process from the medium.
bool m_sendEnable
Enable net device to send packets.
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...
bool Send(Ptr< Packet > packet, const Address &dest, uint16_t protocolNumber) override
Start sending a packet down the channel.
bool IsSendEnabled() const
Is the send side of the network device enabled?
TracedCallback< Ptr< const Packet > > m_macTxTrace
The trace source fired when packets come into the "top" of the device at the L3/L2 transition,...
void SetReceiveCallback(NetDevice::ReceiveCallback cb) override
Set the callback to be used to notify higher layers when a packet has been received.
TracedCallback< Ptr< const Packet > > m_phyTxDropTrace
The trace source fired when the phy layer drops a packet as it tries to transmit it.
Address GetAddress() const override
void AddLinkChangeCallback(Callback< void > callback) override
void SetNode(Ptr< Node > node) override
Set the node to which this device is being attached.
void SetAddress(Address address) override
Set the address of this interface.
Mac48Address m_address
The MAC address which has been assigned to this device.
Time m_tInterframeGap
The interframe gap that the Net Device uses insert time between packet transmission.
void SetQueue(Ptr< Queue< Packet > > queue)
Attach a queue to the CsmaNetDevice.
Ptr< ErrorModel > m_receiveErrorModel
Error model for receive packet events.
TxMachineState m_txMachineState
The state of the Net Device transmit state machine.
uint32_t m_ifIndex
The interface index (really net evice index) that has been assigned to this network device.
bool IsReceiveEnabled() const
Is the receive side of the network device enabled?
bool m_linkUp
Flag indicating whether or not the link is up.
TracedCallback< Ptr< const Packet > > m_phyRxEndTrace
The trace source fired when a packet ends the reception process from the medium.
Class for representing data rates.
Definition data-rate.h:78
Ipv4 addresses are stored in host order in this class.
Describes an IPv6 address.
an EUI-48 address
Network layer to device interface.
Definition net-device.h:87
Smart pointer class similar to boost::intrusive_ptr.
Template class for packet Queues.
Definition queue.h:257
Simulation virtual time values and global simulation resolution.
Definition nstime.h:94
Forward calls to a chain of Callback.
a unique identifier for an interface.
Definition type-id.h:48
Every class exported by the ns3 library is enclosed in the ns3 namespace.