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 // Delete copy constructor and assignment operator to avoid misuse
84 CsmaNetDevice(const CsmaNetDevice&) = delete;
86
87 /**
88 * Set the interframe gap used to separate packets. The interframe gap
89 * defines the minimum space required between packets sent by this device.
90 * As in Ethernet, it defaults to 96 bit times.
91 *
92 * @param t the interframe gap time
93 */
94 void SetInterframeGap(Time t);
95
96 /**
97 * Set the backoff parameters used to determine the wait to retry
98 * transmitting a packet when the channel is busy.
99 *
100 * @see Attach ()
101 * @param slotTime Length of a packet slot (or average packet time)
102 * @param minSlots Minimum number of slots to wait
103 * @param maxSlots Maximum number of slots to wait
104 * @param maxRetries Maximum number of retries before packet is discard
105 * @param ceiling Cap on the exponential function when calculating max slots
106 */
107 void SetBackoffParams(Time slotTime,
108 uint32_t minSlots,
109 uint32_t maxSlots,
110 uint32_t maxRetries,
111 uint32_t ceiling);
112
113 /**
114 * Attach the device to a channel.
115 *
116 * The function Attach is used to add a CsmaNetDevice to a CsmaChannel.
117 *
118 * @see SetDataRate ()
119 * @see SetInterframeGap ()
120 * @param ch a pointer to the channel to which this object is being attached.
121 * @returns true if no error
122 */
123 bool Attach(Ptr<CsmaChannel> ch);
124
125 /**
126 * Attach a queue to the CsmaNetDevice.
127 *
128 * The CsmaNetDevice "owns" a queue. This queue may be set by higher
129 * level topology objects to implement a particular queueing method such as
130 * DropTail.
131 *
132 * @see Queue
133 * @see DropTailQueue
134 * @param queue a Ptr to the queue for being assigned to the device.
135 */
136 void SetQueue(Ptr<Queue<Packet>> queue);
137
138 /**
139 * Get a copy of the attached Queue.
140 *
141 * @return a pointer to the queue.
142 */
144
145 /**
146 * Attach a receive ErrorModel to the CsmaNetDevice.
147 *
148 * The CsmaNetDevice may optionally include an ErrorModel in
149 * the packet receive chain to simulate data errors in during transmission.
150 *
151 * @see ErrorModel
152 * @param em a pointer to the ErrorModel
153 */
155
156 /**
157 * Receive a packet from a connected CsmaChannel.
158 *
159 * The CsmaNetDevice receives packets from its connected channel
160 * and forwards them up the protocol stack. This is the public method
161 * used by the channel to indicate that the last bit of a packet has
162 * arrived at the device.
163 *
164 * @see CsmaChannel
165 * @param p a reference to the received packet
166 * @param sender the CsmaNetDevice that transmitted the packet in the first place
167 */
169
170 /**
171 * Is the send side of the network device enabled?
172 *
173 * @returns True if the send side is enabled, otherwise false.
174 */
175 bool IsSendEnabled() const;
176
177 /**
178 * Enable or disable the send side of the network device.
179 *
180 * @param enable Enable the send side if true, otherwise disable.
181 */
182 void SetSendEnable(bool enable);
183
184 /**
185 * Is the receive side of the network device enabled?
186 *
187 * @returns True if the receiver side is enabled, otherwise false.
188 */
189 bool IsReceiveEnabled() const;
190
191 /**
192 * Enable or disable the receive side of the network device.
193 *
194 * @param enable Enable the receive side if true, otherwise disable.
195 */
196 void SetReceiveEnable(bool enable);
197
198 /**
199 * Set the encapsulation mode of this device.
200 *
201 * @param mode The encapsulation mode of this device.
202 *
203 */
205
206 /**
207 * Get the encapsulation mode of this device.
208 *
209 * @returns The encapsulation mode of this device.
210 */
212
213 //
214 // The following methods are inherited from NetDevice base class.
215 //
216 void SetIfIndex(const uint32_t index) override;
217 uint32_t GetIfIndex() const override;
218 Ptr<Channel> GetChannel() const override;
219 bool SetMtu(const uint16_t mtu) override;
220 uint16_t GetMtu() const override;
221 void SetAddress(Address address) override;
222 Address GetAddress() const override;
223 bool IsLinkUp() const override;
224 void AddLinkChangeCallback(Callback<void> callback) override;
225 bool IsBroadcast() const override;
226 Address GetBroadcast() const override;
227 bool IsMulticast() const override;
228
229 /**
230 * @brief Make and return a MAC multicast address using the provided
231 * multicast group
232 *
233 * \RFC{1112} says that an Ipv4 host group address is mapped to an Ethernet
234 * multicast address by placing the low-order 23-bits of the IP address into
235 * the low-order 23 bits of the Ethernet multicast address
236 * 01-00-5E-00-00-00 (hex).
237 *
238 * This method performs the multicast address creation function appropriate
239 * to an EUI-48-based CSMA device. This MAC address is encapsulated in an
240 * abstract Address to avoid dependencies on the exact address format.
241 *
242 * @param multicastGroup The IP address for the multicast group destination
243 * of the packet.
244 * @return The MAC multicast Address used to send packets to the provided
245 * multicast group.
246 *
247 * @see Ipv4Address
248 * @see Mac48Address
249 * @see Address
250 */
251 Address GetMulticast(Ipv4Address multicastGroup) const override;
252
253 /**
254 * Is this a point to point link?
255 * @returns false.
256 */
257 bool IsPointToPoint() const override;
258
259 /**
260 * Is this a bridge?
261 * @returns false.
262 */
263 bool IsBridge() const override;
264
265 /**
266 * Start sending a packet down the channel.
267 * @param packet packet to send
268 * @param dest layer 2 destination address
269 * @param protocolNumber protocol number
270 * @return true if successful, false otherwise (drop, ...)
271 */
272 bool Send(Ptr<Packet> packet, const Address& dest, uint16_t protocolNumber) override;
273
274 /**
275 * Start sending a packet down the channel, with MAC spoofing
276 * @param packet packet to send
277 * @param source layer 2 source address
278 * @param dest layer 2 destination address
279 * @param protocolNumber protocol number
280 * @return true if successful, false otherwise (drop, ...)
281 */
282 bool SendFrom(Ptr<Packet> packet,
283 const Address& source,
284 const Address& dest,
285 uint16_t protocolNumber) override;
286
287 /**
288 * Get the node to which this device is attached.
289 *
290 * @returns Ptr to the Node to which the device is attached.
291 */
292 Ptr<Node> GetNode() const override;
293
294 /**
295 * Set the node to which this device is being attached.
296 *
297 * @param node Ptr to the Node to which the device is being attached.
298 */
299 void SetNode(Ptr<Node> node) override;
300
301 /**
302 * Does this device need to use the address resolution protocol?
303 *
304 * @returns True if the encapsulation mode is set to a value that requires
305 * ARP (IP_ARP or LLC).
306 */
307 bool NeedsArp() const override;
308
309 /**
310 * Set the callback to be used to notify higher layers when a packet has been
311 * received.
312 *
313 * @param cb The callback.
314 */
316
317 /**
318 * @brief Get the MAC multicast address corresponding
319 * to the IPv6 address provided.
320 * @param addr IPv6 address
321 * @return the MAC multicast address
322 * @warning Calling this method is invalid if IsMulticast returns not true.
323 */
324 Address GetMulticast(Ipv6Address addr) const override;
325
327 bool SupportsSendFrom() const override;
328
329 /**
330 * Assign a fixed random variable stream number to the random variables
331 * used by this model. Return the number of streams (possibly zero) that
332 * have been assigned.
333 *
334 * @param stream first stream index to use
335 * @return the number of stream indices assigned by this model
336 */
337 int64_t AssignStreams(int64_t stream);
338
339 protected:
340 /**
341 * Perform any object release functionality required to break reference
342 * cycles in reference counted objects held by the device.
343 */
344 void DoDispose() override;
345
346 /**
347 * Adds the necessary headers and trailers to a packet of data in order to
348 * respect the packet type
349 *
350 * @param p Packet to which header should be added
351 * @param source MAC source address from which packet should be sent
352 * @param dest MAC destination address to which packet should be sent
353 * @param protocolNumber In some protocols, identifies the type of
354 * payload contained in this packet.
355 */
356 void AddHeader(Ptr<Packet> p, Mac48Address source, Mac48Address dest, uint16_t protocolNumber);
357
358 private:
359 /**
360 * Initialization function used during object construction.
361 * @param sendEnable if device will be allowed to send
362 * @param receiveEnable if device will be allowed to receive
363 */
364 void Init(bool sendEnable, bool receiveEnable);
365
366 /**
367 * Start Sending a Packet Down the Wire.
368 *
369 * The TransmitStart method is the method that is used internally in
370 * the CsmaNetDevice to begin the process of sending a packet
371 * out on the channel. A corresponding method is called on the
372 * channel to let it know that the physical device this class
373 * represents has actually started sending signals, this causes the
374 * channel to enter the BUSY state. An event is scheduled for the time at
375 * which the bits have been completely transmitted.
376 *
377 * If the channel is found to be BUSY, this method reschedules itself for
378 * execution at a later time (within the backoff period).
379 *
380 * @see CsmaChannel::TransmitStart ()
381 * @see TransmitCompleteEvent ()
382 */
383 void TransmitStart();
384
385 /**
386 * Stop Sending a Packet Down the Wire and Begin the Interframe Gap.
387 *
388 * The TransmitCompleteEvent method is used internally to finish the process
389 * of sending a packet out on the channel. During execution of this method
390 * the TransmitEnd method is called on the channel to let it know that the
391 * physical device this class represents has finished sending simulated
392 * signals. The channel uses this event to begin its speed of light delay
393 * timer after which it notifies the Net Device(s) at the other end of the
394 * link that new bits have arrived (it delivers the Packet). During this
395 * method, the net device also schedules the TransmitReadyEvent at which
396 * time the transmitter becomes ready to send the next packet.
397 *
398 * @see CsmaChannel::TransmitEnd ()
399 * @see TransmitReadyEvent ()
400 */
402
403 /**
404 * Cause the Transmitter to Become Ready to Send Another Packet.
405 *
406 * The TransmitReadyEvent method is used internally to re-enable the
407 * transmit machine of the net device. It is scheduled after a suitable
408 * interframe gap after the completion of the previous transmission.
409 * The queue is checked at this time, and if there is a packet waiting on
410 * the queue, the transmission process is begun.
411 *
412 * If a packet is in the queue, it is extracted for the queue as the
413 * next packet to be transmitted by the net device.
414 *
415 * @see TransmitStart ()
416 */
417 void TransmitReadyEvent();
418
419 /**
420 * Aborts the transmission of the current packet
421 *
422 * If the net device has tried to transmit a packet for more times
423 * than the maximum allowed number of retries (channel always busy)
424 * then the packet is dropped.
425 */
426 void TransmitAbort();
427
428 /**
429 * Notify any interested parties that the link has come up.
430 */
431 void NotifyLinkUp();
432
433 /**
434 * Device ID returned by the attached functions. It is used by the
435 * mp-channel to identify each net device to make sure that only
436 * active net devices are writing to the channel
437 */
439
440 /**
441 * Enable net device to send packets. True by default
442 */
444
445 /**
446 * Enable net device to receive packets. True by default
447 */
449
450 /**
451 * Enumeration of the states of the transmit machine of the net device.
452 */
454 {
455 READY, /**< The transmitter is ready to begin transmission of a packet */
456 BUSY, /**< The transmitter is busy transmitting a packet */
457 GAP, /**< The transmitter is in the interframe gap time */
458 BACKOFF /**< The transmitter is waiting for the channel to be free */
459 };
460
461 /**
462 * The state of the Net Device transmit state machine.
463 * @see TxMachineState
464 */
466
467 /**
468 * The type of packet that should be created by the AddHeader
469 * function and that should be processed by the ProcessHeader
470 * function.
471 */
473
474 /**
475 * The data rate that the Net Device uses to simulate packet transmission
476 * timing.
477 * @see class DataRate
478 */
480
481 /**
482 * The interframe gap that the Net Device uses insert time between packet
483 * transmission
484 * @see class Time
485 */
487
488 /**
489 * Holds the backoff parameters and is used to calculate the next
490 * backoff time to use when the channel is busy and the net device
491 * is ready to transmit
492 */
494
495 /**
496 * Next packet that will be transmitted (if transmitter is not
497 * currently transmitting) or packet that is currently being
498 * transmitted.
499 */
501
502 /**
503 * The CsmaChannel to which this CsmaNetDevice has been
504 * attached.
505 * @see class CsmaChannel
506 */
508
509 /**
510 * The Queue which this CsmaNetDevice uses as a packet source.
511 * Management of this Queue has been delegated to the CsmaNetDevice
512 * and it has the responsibility for deletion.
513 * @see class Queue
514 * @see class DropTailQueue
515 */
517
518 /**
519 * Error model for receive packet events. When active this model will be
520 * used to model transmission errors by marking some of the packets
521 * received as corrupt.
522 */
524
525 /**
526 * The trace source fired when packets come into the "top" of the device
527 * at the L3/L2 transition, before being queued for transmission.
528 *
529 * @see class CallBackTraceSource
530 */
532
533 /**
534 * The trace source fired when packets coming into the "top" of the device
535 * at the L3/L2 transition are dropped before being queued for transmission.
536 *
537 * @see class CallBackTraceSource
538 */
540
541 /**
542 * The trace source fired for packets successfully received by the device
543 * immediately before being forwarded up to higher layers (at the L2/L3
544 * transition). This is a promiscuous trace.
545 *
546 * @see class CallBackTraceSource
547 */
549
550 /**
551 * The trace source fired for packets successfully received by the device
552 * immediately before being forwarded up to higher layers (at the L2/L3
553 * transition). This is a non-promiscuous trace.
554 *
555 * @see class CallBackTraceSource
556 */
558
559 /**
560 * The trace source fired for packets successfully received by the device
561 * but dropped before being forwarded up to higher layers (at the L2/L3
562 * transition).
563 *
564 * @see class CallBackTraceSource
565 */
567
568 /**
569 * The trace source fired when the mac layer is forced to begin the backoff
570 * process for a packet. This can happen a number of times as the backoff
571 * sequence is repeated with increasing delays.
572 *
573 * @see class CallBackTraceSource
574 */
576
577 /**
578 * The trace source fired when a packet begins the transmission process on
579 * the medium.
580 *
581 * @see class CallBackTraceSource
582 */
584
585 /**
586 * The trace source fired when a packet ends the transmission process on
587 * the medium.
588 *
589 * @see class CallBackTraceSource
590 */
592
593 /**
594 * The trace source fired when the phy layer drops a packet as it tries
595 * to transmit it.
596 *
597 * @see class CallBackTraceSource
598 */
600
601 /**
602 * The trace source fired when a packet begins the reception process from
603 * the medium.
604 *
605 * @see class CallBackTraceSource
606 */
608
609 /**
610 * The trace source fired when a packet ends the reception process from
611 * the medium.
612 *
613 * @see class CallBackTraceSource
614 */
616
617 /**
618 * The trace source fired when the phy layer drops a packet it has received.
619 *
620 * @see class CallBackTraceSource
621 */
623
624 /**
625 * A trace source that emulates a non-promiscuous protocol sniffer connected
626 * to the device. Unlike your average everyday sniffer, this trace source
627 * will not fire on PACKET_OTHERHOST events.
628 *
629 * On the transmit size, this trace hook will fire after a packet is dequeued
630 * from the device queue for transmission. In Linux, for example, this would
631 * correspond to the point just before a device hard_start_xmit where
632 * dev_queue_xmit_nit is called to dispatch the packet to the PF_PACKET
633 * ETH_P_ALL handlers.
634 *
635 * On the receive side, this trace hook will fire when a packet is received,
636 * just before the receive callback is executed. In Linux, for example,
637 * this would correspond to the point at which the packet is dispatched to
638 * packet sniffers in netif_receive_skb.
639 *
640 * @see class CallBackTraceSource
641 */
643
644 /**
645 * A trace source that emulates a promiscuous mode protocol sniffer connected
646 * to the device. This trace source fire on packets destined for any host
647 * just like your average everyday packet sniffer.
648 *
649 * On the transmit size, this trace hook will fire after a packet is dequeued
650 * from the device queue for transmission. In Linux, for example, this would
651 * correspond to the point just before a device hard_start_xmit where
652 * dev_queue_xmit_nit is called to dispatch the packet to the PF_PACKET
653 * ETH_P_ALL handlers.
654 *
655 * On the receive side, this trace hook will fire when a packet is received,
656 * just before the receive callback is executed. In Linux, for example,
657 * this would correspond to the point at which the packet is dispatched to
658 * packet sniffers in netif_receive_skb.
659 *
660 * @see class CallBackTraceSource
661 */
663
664 /**
665 * The Node to which this device is attached.
666 */
668
669 /**
670 * The MAC address which has been assigned to this device.
671 */
673
674 /**
675 * The callback used to notify higher layers that a packet has been received.
676 */
678
679 /**
680 * The callback used to notify higher layers that a packet has been received in promiscuous
681 * mode.
682 */
684
685 /**
686 * The interface index (really net evice index) that has been assigned to
687 * this network device.
688 */
690
691 /**
692 * Flag indicating whether or not the link is up. In this case,
693 * whether or not the device is connected to a channel.
694 */
696
697 /**
698 * List of callbacks to fire if the link changes state (up or down).
699 */
701
702 /**
703 * Default Maximum Transmission Unit (MTU) for the CsmaNetDevice
704 */
705 static const uint16_t DEFAULT_MTU = 1500;
706
707 /**
708 * The Maximum Transmission Unit. This corresponds to the maximum
709 * number of bytes that can be transmitted as seen from higher layers.
710 * This corresponds to the 1500 byte MTU size often seen on IP over
711 * Ethernet.
712 */
714};
715
716} // namespace ns3
717
718#endif /* CSMA_NET_DEVICE_H */
a polymophic address class
Definition address.h:114
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:428
Csma Channel.
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 &)=delete
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.
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.
CsmaNetDevice(const CsmaNetDevice &)=delete
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
General error model that can be used to corrupt packets.
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
Callback< bool, Ptr< NetDevice >, Ptr< const Packet >, uint16_t, const Address &, const Address &, PacketType > PromiscReceiveCallback
Definition net-device.h:341
Callback< bool, Ptr< NetDevice >, Ptr< const Packet >, uint16_t, const Address & > ReceiveCallback
Definition net-device.h:311
Smart pointer class similar to boost::intrusive_ptr.
Definition ptr.h:70
Template class for packet Queues.
Definition queue.h:257
Simulation virtual time values and global simulation resolution.
Definition nstime.h:96
Forward calls to a chain of Callback.
a unique identifier for an interface.
Definition type-id.h:49
Every class exported by the ns3 library is enclosed in the ns3 namespace.