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