00001 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ 00002 /* 00003 * Copyright (c) 2007 Emmanuelle Laprise 00004 * 00005 * This program is free software; you can redistribute it and/or modify 00006 * it under the terms of the GNU General Public License version 2 as 00007 * published by the Free Software Foundation; 00008 * 00009 * This program is distributed in the hope that it will be useful, 00010 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00011 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00012 * GNU General Public License for more details. 00013 * 00014 * You should have received a copy of the GNU General Public License 00015 * along with this program; if not, write to the Free Software 00016 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 00017 * 00018 * Author: Emmanuelle Laprise <emmanuelle.laprise@bluekazoo.ca 00019 */ 00020 00021 #ifndef CSMA_NET_DEVICE_H 00022 #define CSMA_NET_DEVICE_H 00023 00024 #include <string.h> 00025 #include "ns3/node.h" 00026 #include "ns3/backoff.h" 00027 #include "ns3/address.h" 00028 #include "ns3/net-device.h" 00029 #include "ns3/callback.h" 00030 #include "ns3/packet.h" 00031 #include "ns3/traced-callback.h" 00032 #include "ns3/nstime.h" 00033 #include "ns3/data-rate.h" 00034 #include "ns3/ptr.h" 00035 #include "ns3/random-variable.h" 00036 #include "ns3/mac48-address.h" 00037 00038 namespace ns3 { 00039 00040 class Queue; 00041 class CsmaChannel; 00042 class ErrorModel; 00043 00044 /** 00045 * \class CsmaNetDevice 00046 * \brief A Device for a Csma Network Link. 00047 * 00048 * The Csma net device class is analogous to layer 1 and 2 of the 00049 * TCP stack. The NetDevice takes a raw packet of bytes and creates a 00050 * protocol specific packet from them. 00051 * 00052 * Each Csma net device will receive all packets written to the Csma link. 00053 * The ProcessHeader function can be used to filter out the packets such that 00054 * higher level layers only receive packets that are addressed to their 00055 * associated net devices 00056 */ 00057 class CsmaNetDevice : public NetDevice 00058 { 00059 public: 00060 static TypeId GetTypeId (void); 00061 00062 /** 00063 * Enumeration of the types of packets supported in the class. 00064 * 00065 */ 00066 enum EncapsulationMode { 00067 ILLEGAL, /**< Encapsulation mode not set */ 00068 DIX, /**< DIX II / Ethernet II packet */ 00069 LLC, /**< 802.2 LLC/SNAP Packet*/ 00070 }; 00071 00072 /** 00073 * Construct a CsmaNetDevice 00074 * 00075 * This is the default constructor for a CsmaNetDevice. 00076 */ 00077 CsmaNetDevice (); 00078 00079 /** 00080 * Destroy a CsmaNetDevice 00081 * 00082 * This is the destructor for a CsmaNetDevice. 00083 */ 00084 virtual ~CsmaNetDevice (); 00085 00086 /** 00087 * Set the inteframe gap used to separate packets. The interframe gap 00088 * defines the minimum space required between packets sent by this device. 00089 * As in Ethernet, it defaults to 96 bit times. 00090 * 00091 * \param t the interframe gap time 00092 */ 00093 void SetInterframeGap (Time t); 00094 00095 /** 00096 * Set the backoff parameters used to determine the wait to retry 00097 * transmitting a packet when the channel is busy. 00098 * 00099 * \see Attach () 00100 * \param slotTime Length of a packet slot (or average packet time) 00101 * \param minSlots Minimum number of slots to wait 00102 * \param maxSlots Maximum number of slots to wait 00103 * \param maxRetries Maximum number of retries before packet is discard 00104 * \param ceiling Cap on the exponential function when calculating max slots 00105 */ 00106 void SetBackoffParams (Time slotTime, uint32_t minSlots, uint32_t maxSlots, 00107 uint32_t maxRetries, uint32_t ceiling); 00108 00109 /** 00110 * Attach the device to a channel. 00111 * 00112 * The function Attach is used to add a CsmaNetDevice to a CsmaChannel. 00113 * 00114 * \see SetDataRate () 00115 * \see SetInterframeGap () 00116 * \param ch a pointer to the channel to which this object is being attached. 00117 */ 00118 bool Attach (Ptr<CsmaChannel> ch); 00119 00120 /** 00121 * Attach a queue to the CsmaNetDevice. 00122 * 00123 * The CsmaNetDevice "owns" a queue. This queue may be set by higher 00124 * level topology objects to implement a particular queueing method such as 00125 * DropTail or RED. 00126 * 00127 * \see Queue 00128 * \see DropTailQueue 00129 * \param queue a Ptr to the queue for being assigned to the device. 00130 */ 00131 void SetQueue (Ptr<Queue> queue); 00132 00133 /** 00134 * Attach a receive ErrorModel to the CsmaNetDevice. 00135 * 00136 * The CsmaNetDevice may optionally include an ErrorModel in 00137 * the packet receive chain to simulate data errors in during transmission. 00138 * 00139 * \see ErrorModel 00140 * \param em a pointer to the ErrorModel 00141 */ 00142 void SetReceiveErrorModel (Ptr<ErrorModel> em); 00143 00144 /** 00145 * Receive a packet from a connected CsmaChannel. 00146 * 00147 * The CsmaNetDevice receives packets from its connected channel 00148 * and forwards them up the protocol stack. This is the public method 00149 * used by the channel to indicate that the last bit of a packet has 00150 * arrived at the device. 00151 * 00152 * \see CsmaChannel 00153 * \param p a reference to the received packet 00154 * \param sender the CsmaNetDevice that transmitted the packet in the first place 00155 */ 00156 void Receive (Ptr<Packet> p, Ptr<CsmaNetDevice> sender); 00157 00158 /** 00159 * Is the send side of the network device enabled? 00160 * 00161 * \returns True if the send side is enabled, otherwise false. 00162 */ 00163 bool IsSendEnabled (void); 00164 00165 /** 00166 * Enable or disable the send side of the network device. 00167 * 00168 * \param enable Enable the send side if true, otherwise disable. 00169 */ 00170 void SetSendEnable (bool enable); 00171 00172 /** 00173 * Is the receive side of the network device enabled? 00174 * 00175 * \returns True if the receiver side is enabled, otherwise false. 00176 */ 00177 bool IsReceiveEnabled (void); 00178 00179 /** 00180 * Enable or disable the receive side of the network device. 00181 * 00182 * \param enable Enable the receive side if true, otherwise disable. 00183 */ 00184 void SetReceiveEnable (bool enable); 00185 00186 /** 00187 * Set the MAC address of the the network device. 00188 * 00189 * \param addr The Mac48Address to use as the address of the device. 00190 */ 00191 void SetAddress (Mac48Address addr); 00192 00193 /** 00194 * Set The max frame size of packets sent over this device. 00195 * 00196 * Okay, that was easy to say, but the details are a bit thorny. We have a MAC-level MTU that is the payload that higher 00197 * level protocols see. We have a PHY-level MTU which is the maximum number of bytes we can send over the link 00198 * (cf. 1500 bytes for Ethernet). We also have a frame size which is some total number of bytes in a packet which could 00199 * or could not include any framing and overhead. There can be a lot of inconsistency in definitions of these terms. For 00200 * example, RFC 1042 asserts that the terms maximum transmission unit and maximum packet size are equivalent. RFC 791, 00201 * however, defines MTU as the maximum sized IP datagram that can be sent. Packet size and frame size are sometimes 00202 * used interchangeably. 00203 * 00204 * So, some careful definitions are in order to avoid confusion: 00205 * 00206 * In real Ethernet, a packet on the wire starts with a preamble of seven bytes of alternating ones and zeroes followed by 00207 * a Start-of-Frame-Delimeter (10101011). This is followed by what is usually called the packet: a MAC destination and 00208 * source, a type field, payload, a possible padding field and a CRC. To be strictly and pedantically correct the frame 00209 * size is necessarily larger than the packet size on a real Ethernet. But, this isn't a real Ethernet, it's a simulation 00210 * of a device similar to Ethernet, and we have no good reason to add framing bits. So, in the case of the CSMA device, 00211 * the frame size is equal to the packet size. Since these two values are equal, there is no danger in assuming they are 00212 * identical. We do not implement any padding out to a minimum frame size, so padding is a non-issue. We define packet 00213 * size to be equal to frame size and this excludes the preamble and SFD bytes of a real Ethernet frame. We define a 00214 * single (MAC-level) MTU that coresponds to the payload size of the packet, which is the IP-centric view of the term as 00215 * seen in RFC 791. 00216 * 00217 * To make this concrete, consider DIX II (Digital Equipment, Intel, Xerox type II) framing, which is used in most TCP/IP 00218 * stacks. NetWare and Wireshark call this framing Ethernet II, by the way. In this framing scheme, a real packet on the 00219 * wire starts with the preamble and Start-of-Frame-Delimeter (10101011). We ignore these bits on this device since it they 00220 * are not needed. In DIX II, the SFD is followed by the MAC (48) destination address (6 bytes), source address (6 bytes), 00221 * the EtherType field (2 bytes), payload (0-1500 bytes) and a CRC (4 bytes) -- this corresponds to our entire frame. The 00222 * payload of the packet/frame in DIX can be from 0 to 1500 bytes. It is the maxmimum value of this payload that we call 00223 * the MTU. Typically, one sees the MTU set to 1500 bytes and the maximum frame size set to 1518 bytes in Ethernet-based 00224 * networks. 00225 * 00226 * Different framing schemes can make for different MTU and frame size relationships. For example, we support LLC/SNAP 00227 * encapsulation which adds eight bytes of header overhead to the usual DIX framing. In this case, if the maximum frame 00228 * size is left at 1518 bytes, we need to export an MTU that reflects the loss of eight bytes for a total of 1492. 00229 * 00230 * Another complication is that IEEE 802.1Q adds four bytes to the maximum frame size for VLAN tagging. In order to 00231 * provide an MTU of 1500 bytes, the frame size would need to increased to 1522 bytes to absorb the additional overhead. 00232 * 00233 * So, there are really three variables that are not entirely free at work here. There is the maximum frame size, the 00234 * MTU and the framing scheme which we call the encapsulation mode. 00235 * 00236 * So, what do we do since there are be three values which must always be consistent in the driver? Which values to we 00237 * allow to be changed and how do we ensure the other two are consistent? We want to actually allow a user to change 00238 * these three variables in flexible ways, but we want the results (even at intermediate stages of her ultimate change) to 00239 * be consistent. We certainly don't want to require that users must understand the various requirements of an enapsulation 00240 * mode in order to set these variables. 00241 * 00242 * Consider the following situation: A user wants to set the maximum frame size to 1418 bytes instead of 1518. This 00243 * user shouldn't have to concern herself that the current encapuslation mode is LLC/SNAP and this will consume eight bytes. 00244 * She should not have to also figure out that the MTU needs to be set to 1392 bytes, and she should certainly not have to 00245 * do this in some special order to keep intermediate steps consistent. 00246 * 00247 * Similarly, a user who is interested in setting the MTU to 1400 bytes should not be forced to understand that 00248 * (based on encapsulation mode) the frame size may need to be set to eighteen + eight bytes more than what he wants 00249 * in certain cases (802,3 + LLC/SNAP), twenty-two + zero bytes in others (802.1Q) and other inscrutable combinations 00250 * 00251 * Now, consider a user who is only interested in changing the encapsulation mode from LLC/SNAP to DIX. This 00252 * is going to change the relationship between the MTU and the frame size. We've may have to come up with a new value 00253 * for at least one of the these? Which one? There are too many free variables. 00254 * 00255 * We could play games trying to figure out what the user wants to do, but that is typically a bad plan and programmers 00256 * have a long and distinguished history of guessing wrong. We'll avoid all of that and just define a flexible behavior 00257 * that can be worked to get what you want. Here it is: 00258 * 00259 * - If the user is changing the encapsulation mode, the PHY MTU will remain fixed and the MAC MTU will change, if required, 00260 * to make the three values consistent; 00261 * 00262 * - If the user is changing the MTU, she is interested in getting that part of the system set, so the frame size 00263 * will be changed to make the three values consistent; 00264 * 00265 * - If the user is changing the frame size, he is interested in getting that part of the system set, so the MTU 00266 * will be changed to make the three values consistent; 00267 * 00268 * - You cannot define the MTU and frame size separately -- they are always tied together by the emulation mode. This 00269 * is not a restriction. Consider what this means. Perhaps you want to set the frame size to some large number and the 00270 * MTU to some small number. The largest packet you can send is going to be limited by the MTU, so it is not possible to 00271 * send a frame larger than the MTU plus overhead. The larger frame size is not useful. 00272 * 00273 * So, if a user calls SetFrameSize, we assume that the maximum frame size is the interesting thing for that user and 00274 * we just adjust the MTU to a new "correct value" based on the current encapsulation mode. If a user calls SetMtu, we 00275 * assume that the MTU is the interesting property for that user, and we adjust the frame size to a new "correct value" 00276 * for the current encapsulation mode. If a user calls SetEncapsulationMode, then we take the MTU as the free variable 00277 * and set its value to match the current frame size. 00278 * 00279 * \param frameSize The max frame size of packets sent over this device. 00280 */ 00281 void SetFrameSize (uint16_t frameSize); 00282 00283 /** 00284 * Get The max frame size of packets sent over this device. 00285 * 00286 * \returns The max frame size of packets sent over this device. 00287 */ 00288 uint16_t GetFrameSize (void) const; 00289 00290 /** 00291 * Set the encapsulation mode of this device. 00292 * 00293 * \param mode The encapsulation mode of this device. 00294 * 00295 * \see SetFrameSize 00296 */ 00297 void SetEncapsulationMode (CsmaNetDevice::EncapsulationMode mode); 00298 00299 /** 00300 * Get the encapsulation mode of this device. 00301 * 00302 * \returns The encapsulation mode of this device. 00303 */ 00304 CsmaNetDevice::EncapsulationMode GetEncapsulationMode (void); 00305 00306 // 00307 // The following methods are inherited from NetDevice base class. 00308 // 00309 virtual void SetName (const std::string name); 00310 virtual std::string GetName (void) const; 00311 virtual void SetIfIndex (const uint32_t index); 00312 virtual uint32_t GetIfIndex (void) const; 00313 virtual Ptr<Channel> GetChannel (void) const; 00314 virtual bool SetMtu (const uint16_t mtu); 00315 virtual uint16_t GetMtu (void) const; 00316 virtual Address GetAddress (void) const; 00317 virtual bool IsLinkUp (void) const; 00318 virtual void SetLinkChangeCallback (Callback<void> callback); 00319 virtual bool IsBroadcast (void) const; 00320 virtual Address GetBroadcast (void) const; 00321 virtual bool IsMulticast (void) const; 00322 00323 /** 00324 * \brief Make and return a MAC multicast address using the provided 00325 * multicast group 00326 * 00327 * RFC 1112 says that an Ipv4 host group address is mapped to an Ethernet 00328 * multicast address by placing the low-order 23-bits of the IP address into 00329 * the low-order 23 bits of the Ethernet multicast address 00330 * 01-00-5E-00-00-00 (hex). 00331 * 00332 * This method performs the multicast address creation function appropriate 00333 * to an EUI-48-based CSMA device. This MAC address is encapsulated in an 00334 * abstract Address to avoid dependencies on the exact address format. 00335 * 00336 * \param multicastGroup The IP address for the multicast group destination 00337 * of the packet. 00338 * \return The MAC multicast Address used to send packets to the provided 00339 * multicast group. 00340 * 00341 * \see Ipv4Address 00342 * \see Mac48Address 00343 * \see Address 00344 */ 00345 virtual Address GetMulticast (Ipv4Address multicastGroup) const; 00346 00347 /** 00348 * Is this a point to point link? 00349 * \returns false. 00350 */ 00351 virtual bool IsPointToPoint (void) const; 00352 00353 /** 00354 * Is this a bridge? 00355 * \returns false. 00356 */ 00357 virtual bool IsBridge (void) const; 00358 00359 /** 00360 * Start sending a packet down the channel. 00361 */ 00362 virtual bool Send (Ptr<Packet> packet, const Address& dest, 00363 uint16_t protocolNumber); 00364 00365 /** 00366 * Start sending a packet down the channel, with MAC spoofing 00367 */ 00368 virtual bool SendFrom (Ptr<Packet> packet, const Address& source, const Address& dest, 00369 uint16_t protocolNumber); 00370 00371 /** 00372 * Get the node to which this device is attached. 00373 * 00374 * \returns Ptr to the Node to which the device is attached. 00375 */ 00376 virtual Ptr<Node> GetNode (void) const; 00377 00378 /** 00379 * Set the node to which this device is being attached. 00380 * 00381 * \param node Ptr to the Node to which the device is being attached. 00382 */ 00383 virtual void SetNode (Ptr<Node> node); 00384 00385 /** 00386 * Does this device need to use the address resolution protocol? 00387 * 00388 * \returns True if the encapsulation mode is set to a value that requires 00389 * ARP (IP_ARP or LLC). 00390 */ 00391 virtual bool NeedsArp (void) const; 00392 00393 /** 00394 * Set the callback to be used to notify higher layers when a packet has been 00395 * received. 00396 * 00397 * \param cb The callback. 00398 */ 00399 virtual void SetReceiveCallback (NetDevice::ReceiveCallback cb); 00400 00401 /** 00402 * \brief Get the MAC multicast address corresponding 00403 * to the IPv6 address provided. 00404 * \param addr IPv6 address 00405 * \return the MAC multicast address 00406 * \warning Calling this method is invalid if IsMulticast returns not true. 00407 */ 00408 virtual Address GetMulticast (Ipv6Address addr) const; 00409 00410 00411 virtual void SetPromiscReceiveCallback (PromiscReceiveCallback cb); 00412 virtual bool SupportsSendFrom (void) const; 00413 00414 protected: 00415 /** 00416 * Perform any object release functionality required to break reference 00417 * cycles in reference counted objects held by the device. 00418 */ 00419 virtual void DoDispose (void); 00420 00421 /** 00422 * Get a copy of the attached Queue. 00423 * 00424 * This method is provided for any derived class that may need to get 00425 * direct access to the underlying queue. 00426 * 00427 * \return a pointer to the queue. 00428 */ 00429 Ptr<Queue> GetQueue (void) const; 00430 00431 /** 00432 * Adds the necessary headers and trailers to a packet of data in order to 00433 * respect the packet type 00434 * 00435 * \param p Packet to which header should be added 00436 * \param source MAC source address from which packet should be sent 00437 * \param dest MAC destination address to which packet should be sent 00438 * \param protocolNumber In some protocols, identifies the type of 00439 * payload contained in this packet. 00440 */ 00441 void AddHeader (Ptr<Packet> p, Mac48Address source, Mac48Address dest, uint16_t protocolNumber); 00442 00443 /** 00444 * Removes, from a packet of data, all headers and trailers that 00445 * relate to the packet type 00446 * 00447 * \param p Packet whose headers need to be processed 00448 * \param param An integer parameter that can be set by the function 00449 * to return information gathered in the header 00450 * \return Returns true if the packet should be forwarded up the 00451 * protocol stack. 00452 */ 00453 bool ProcessHeader (Ptr<Packet> p, uint16_t & param); 00454 00455 private: 00456 00457 /** 00458 * Operator = is declared but not implemented. This disables the assigment 00459 * operator for CsmaNetDevice objects. 00460 00461 */ 00462 CsmaNetDevice &operator = (const CsmaNetDevice &o); 00463 00464 /** 00465 * Copy constructor is declared but not implemented. This disables the 00466 * copy constructor for CsmaNetDevice objects. 00467 */ 00468 CsmaNetDevice (const CsmaNetDevice &o); 00469 00470 /** 00471 * Initialization function used during object construction. 00472 */ 00473 void Init (bool sendEnable, bool receiveEnable); 00474 00475 /** 00476 * Calculate the value for the MTU that would result from 00477 * setting the frame size to the given value. 00478 */ 00479 uint32_t MtuFromFrameSize (uint32_t frameSize); 00480 00481 /** 00482 * Calculate the value for the frame size that would be required 00483 * to be able to set the MTU to the given value. 00484 */ 00485 uint32_t FrameSizeFromMtu (uint32_t mtu); 00486 00487 /** 00488 * Start Sending a Packet Down the Wire. 00489 * 00490 * The TransmitStart method is the method that is used internally in 00491 * the CsmaNetDevice to begin the process of sending a packet 00492 * out on the channel. A corresponding method is called on the 00493 * channel to let it know that the physical device this class 00494 * represents has actually started sending signals, this causes the 00495 * channel to enter the BUSY state. An event is scheduled for the time at 00496 * which the bits have been completely transmitted. 00497 * 00498 * If the channel is found to be BUSY, this method reschedules itself for 00499 * execution at a later time (within the backoff period). 00500 * 00501 * \see CsmaChannel::TransmitStart () 00502 * \see TransmitCompleteEvent () 00503 */ 00504 void TransmitStart (); 00505 00506 /** 00507 * Stop Sending a Packet Down the Wire and Begin the Interframe Gap. 00508 * 00509 * The TransmitCompleteEvent method is used internally to finish the process 00510 * of sending a packet out on the channel. During execution of this method 00511 * the TransmitEnd method is called on the channel to let it know that the 00512 * physical device this class represents has finished sending simulated 00513 * signals. The channel uses this event to begin its speed of light delay 00514 * timer after which it notifies the Net Device(s) at the other end of the 00515 * link that new bits have arrived (it delivers the Packet). During this 00516 * method, the net device also schedules the TransmitReadyEvent at which 00517 * time the transmitter becomes ready to send the next packet. 00518 * 00519 * \see CsmaChannel::TransmitEnd () 00520 * \see TransmitReadyEvent () 00521 */ 00522 void TransmitCompleteEvent (void); 00523 00524 /** 00525 * Cause the Transmitter to Become Ready to Send Another Packet. 00526 * 00527 * The TransmitReadyEvent method is used internally to re-enable the 00528 * transmit machine of the net device. It is scheduled after a suitable 00529 * interframe gap after the completion of the previous transmission. 00530 * The queue is checked at this time, and if there is a packet waiting on 00531 * the queue, the transmission process is begun. 00532 * 00533 * If a packet is in the queue, it is extracted for the queue as the 00534 * next packet to be transmitted by the net device. 00535 * 00536 * \see TransmitStart () 00537 */ 00538 void TransmitReadyEvent (void); 00539 00540 /** 00541 * Aborts the transmission of the current packet 00542 * 00543 * If the net device has tried to transmit a packet for more times 00544 * than the maximum allowed number of retries (channel always busy) 00545 * then the packet is dropped. 00546 */ 00547 void TransmitAbort (void); 00548 00549 /** 00550 * Notify any interested parties that the link has come up. 00551 */ 00552 void NotifyLinkUp (void); 00553 00554 /** 00555 * Device ID returned by the attached functions. It is used by the 00556 * mp-channel to identify each net device to make sure that only 00557 * active net devices are writing to the channel 00558 */ 00559 uint32_t m_deviceId; 00560 00561 /** 00562 * Enable net device to send packets. True by default 00563 */ 00564 bool m_sendEnable; 00565 00566 /** 00567 * Enable net device to receive packets. True by default 00568 */ 00569 bool m_receiveEnable; 00570 00571 /** 00572 * Enumeration of the states of the transmit machine of the net device. 00573 */ 00574 enum TxMachineState 00575 { 00576 READY, /**< The transmitter is ready to begin transmission of a packet */ 00577 BUSY, /**< The transmitter is busy transmitting a packet */ 00578 GAP, /**< The transmitter is in the interframe gap time */ 00579 BACKOFF /**< The transmitter is waiting for the channel to be free */ 00580 }; 00581 00582 /** 00583 * The state of the Net Device transmit state machine. 00584 * \see TxMachineState 00585 */ 00586 TxMachineState m_txMachineState; 00587 00588 /** 00589 * The type of packet that should be created by the AddHeader 00590 * function and that should be processed by the ProcessHeader 00591 * function. 00592 */ 00593 EncapsulationMode m_encapMode; 00594 00595 /** 00596 * The data rate that the Net Device uses to simulate packet transmission 00597 * timing. 00598 * \see class DataRate 00599 */ 00600 DataRate m_bps; 00601 00602 /** 00603 * The interframe gap that the Net Device uses insert time between packet 00604 * transmission 00605 * \see class Time 00606 */ 00607 Time m_tInterframeGap; 00608 00609 /** 00610 * Holds the backoff parameters and is used to calculate the next 00611 * backoff time to use when the channel is busy and the net device 00612 * is ready to transmit 00613 */ 00614 Backoff m_backoff; 00615 00616 /** 00617 * Next packet that will be transmitted (if transmitter is not 00618 * currently transmitting) or packet that is currently being 00619 * transmitted. 00620 */ 00621 Ptr<Packet> m_currentPkt; 00622 00623 /** 00624 * The CsmaChannel to which this CsmaNetDevice has been 00625 * attached. 00626 * \see class CsmaChannel 00627 */ 00628 Ptr<CsmaChannel> m_channel; 00629 00630 /** 00631 * The Queue which this CsmaNetDevice uses as a packet source. 00632 * Management of this Queue has been delegated to the CsmaNetDevice 00633 * and it has the responsibility for deletion. 00634 * \see class Queue 00635 * \see class DropTailQueue 00636 */ 00637 Ptr<Queue> m_queue; 00638 00639 /** 00640 * Error model for receive packet events 00641 */ 00642 Ptr<ErrorModel> m_receiveErrorModel; 00643 00644 /** 00645 * The trace source for the packet reception events that the device can 00646 * fire. 00647 * 00648 * \see class CallBackTraceSource 00649 */ 00650 TracedCallback<Ptr<const Packet> > m_rxTrace; 00651 00652 /** 00653 * The trace source for the packet drop events that the device can 00654 * fire. 00655 * 00656 * \see class CallBackTraceSource 00657 */ 00658 TracedCallback<Ptr<const Packet> > m_dropTrace; 00659 00660 /** 00661 * The Node to which this device is attached. 00662 */ 00663 Ptr<Node> m_node; 00664 00665 /** 00666 * The MAC address which has been assigned to this device. 00667 */ 00668 Mac48Address m_address; 00669 00670 /** 00671 * The callback used to notify higher layers that a packet has been received. 00672 */ 00673 NetDevice::ReceiveCallback m_rxCallback; 00674 /** 00675 * The callback used to notify higher layers that a packet has been received in promiscuous mode. 00676 */ 00677 NetDevice::PromiscReceiveCallback m_promiscRxCallback; 00678 00679 /** 00680 * The interface index (really net evice index) that has been assigned to 00681 * this network device. 00682 */ 00683 uint32_t m_ifIndex; 00684 00685 /** 00686 * The human readable name of this device. 00687 */ 00688 std::string m_name; 00689 00690 /** 00691 * Flag indicating whether or not the link is up. In this case, 00692 * whether or not the device is connected to a channel. 00693 */ 00694 bool m_linkUp; 00695 00696 /** 00697 * Callback to fire if the link changes state (up or down). 00698 */ 00699 Callback<void> m_linkChangeCallback; 00700 00701 static const uint16_t DEFAULT_FRAME_SIZE = 1518; 00702 static const uint16_t ETHERNET_OVERHEAD = 18; 00703 00704 /** 00705 * The frame size/packet size. This corresponds to the maximum 00706 * number of bytes that can be transmitted as a packet without framing. 00707 * This corresponds to the 1518 byte packet size often seen on Ethernet. 00708 */ 00709 uint32_t m_frameSize; 00710 00711 /** 00712 * The Maxmimum Transmission Unit. This corresponds to the maximum 00713 * number of bytes that can be transmitted as seen from higher layers. 00714 * This corresponds to the 1500 byte MTU size often seen on IP over 00715 * Ethernet. 00716 */ 00717 uint32_t m_mtu; 00718 }; 00719 00720 }; // namespace ns3 00721 00722 #endif // CSMA_NET_DEVICE_H