OLD | NEW |
1 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ | 1 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ |
2 /* | 2 /* |
3 * Copyright (c) 2007 Emmanuelle Laprise | 3 * Copyright (c) 2007 Emmanuelle Laprise |
4 * | 4 * |
5 * This program is free software; you can redistribute it and/or modify | 5 * This program is free software; you can redistribute it and/or modify |
6 * it under the terms of the GNU General Public License version 2 as | 6 * it under the terms of the GNU General Public License version 2 as |
7 * published by the Free Software Foundation; | 7 * published by the Free Software Foundation; |
8 * | 8 * |
9 * This program is distributed in the hope that it will be useful, | 9 * This program is distributed in the hope that it will be useful, |
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of | 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of |
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | 11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
12 * GNU General Public License for more details. | 12 * GNU General Public License for more details. |
13 * | 13 * |
14 * You should have received a copy of the GNU General Public License | 14 * You should have received a copy of the GNU General Public License |
15 * along with this program; if not, write to the Free Software | 15 * along with this program; if not, write to the Free Software |
16 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | 16 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
17 * | 17 * |
18 * Author: Emmanuelle Laprise <emmanuelle.laprise@bluekazoo.ca | 18 * Author: Emmanuelle Laprise <emmanuelle.laprise@bluekazoo.ca |
| 19 * Vedran Miletić <rivanvx@gmail.com> |
19 */ | 20 */ |
20 | 21 |
21 #ifndef CSMA_NET_DEVICE_H | 22 #ifndef CSMA_NET_DEVICE_H |
22 #define CSMA_NET_DEVICE_H | 23 #define CSMA_NET_DEVICE_H |
23 | 24 |
24 #include <cstring> | |
25 #include "ns3/node.h" | 25 #include "ns3/node.h" |
26 #include "ns3/backoff.h" | 26 #include "ns3/backoff.h" |
27 #include "ns3/address.h" | 27 #include "ns3/address.h" |
28 #include "ns3/net-device.h" | 28 #include "ns3/net-device.h" |
29 #include "ns3/callback.h" | 29 #include "ns3/callback.h" |
30 #include "ns3/packet.h" | 30 #include "ns3/packet.h" |
31 #include "ns3/traced-callback.h" | 31 #include "ns3/traced-callback.h" |
32 #include "ns3/nstime.h" | 32 #include "ns3/nstime.h" |
33 #include "ns3/data-rate.h" | 33 #include "ns3/data-rate.h" |
34 #include "ns3/ptr.h" | 34 #include "ns3/ptr.h" |
(...skipping 28 matching lines...) Expand all Loading... |
63 /** | 63 /** |
64 * Enumeration of the types of packets supported in the class. | 64 * Enumeration of the types of packets supported in the class. |
65 */ | 65 */ |
66 enum EncapsulationMode { | 66 enum EncapsulationMode { |
67 ILLEGAL, /**< Encapsulation mode not set */ | 67 ILLEGAL, /**< Encapsulation mode not set */ |
68 DIX, /**< DIX II / Ethernet II packet */ | 68 DIX, /**< DIX II / Ethernet II packet */ |
69 LLC, /**< 802.2 LLC/SNAP Packet*/ | 69 LLC, /**< 802.2 LLC/SNAP Packet*/ |
70 }; | 70 }; |
71 | 71 |
72 /** | 72 /** |
| 73 * Enumeration of the states of the wire sensed by transceiver. |
| 74 */ |
| 75 enum CarrierSense |
| 76 { |
| 77 CARRIER_SENSE_IDLE, /**< The transceiver senses no signal propagating throug
h the wire */ |
| 78 CARRIER_SENSE_BUSY, /**< The transceiver senses signal (own or otherwise) pr
opagating through the wire */ |
| 79 }; |
| 80 |
| 81 /** |
73 * Construct a CsmaNetDevice | 82 * Construct a CsmaNetDevice |
74 * | 83 * |
75 * This is the default constructor for a CsmaNetDevice. | 84 * This is the default constructor for a CsmaNetDevice. |
76 */ | 85 */ |
77 CsmaNetDevice (); | 86 CsmaNetDevice (); |
78 | 87 |
79 /** | 88 /** |
80 * Destroy a CsmaNetDevice | 89 * Destroy a CsmaNetDevice |
81 * | 90 * |
82 * This is the destructor for a CsmaNetDevice. | 91 * This is the destructor for a CsmaNetDevice. |
(...skipping 24 matching lines...) Expand all Loading... |
107 uint32_t maxRetries, uint32_t ceiling); | 116 uint32_t maxRetries, uint32_t ceiling); |
108 | 117 |
109 /** | 118 /** |
110 * Attach the device to a channel. | 119 * Attach the device to a channel. |
111 * | 120 * |
112 * The function Attach is used to add a CsmaNetDevice to a CsmaChannel. | 121 * The function Attach is used to add a CsmaNetDevice to a CsmaChannel. |
113 * | 122 * |
114 * \see SetDataRate () | 123 * \see SetDataRate () |
115 * \see SetInterframeGap () | 124 * \see SetInterframeGap () |
116 * \param ch a pointer to the channel to which this object is being attached. | 125 * \param ch a pointer to the channel to which this object is being attached. |
| 126 * \param distance Distance in metres from one end of the wire. |
117 */ | 127 */ |
118 bool Attach (Ptr<CsmaChannel> ch); | 128 bool Attach (Ptr<CsmaChannel> ch, double distance); |
119 | 129 |
120 /** | 130 /** |
121 * Attach a queue to the CsmaNetDevice. | 131 * Attach a queue to the CsmaNetDevice. |
122 * | 132 * |
123 * The CsmaNetDevice "owns" a queue. This queue may be set by higher | 133 * The CsmaNetDevice "owns" a queue. This queue may be set by higher |
124 * level topology objects to implement a particular queueing method such as | 134 * level topology objects to implement a particular queueing method such as |
125 * DropTail or RED. | 135 * DropTail or RED. |
126 * | 136 * |
127 * \see Queue | 137 * \see Queue |
128 * \see DropTailQueue | 138 * \see DropTailQueue |
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
198 */ | 208 */ |
199 void SetEncapsulationMode (CsmaNetDevice::EncapsulationMode mode); | 209 void SetEncapsulationMode (CsmaNetDevice::EncapsulationMode mode); |
200 | 210 |
201 /** | 211 /** |
202 * Get the encapsulation mode of this device. | 212 * Get the encapsulation mode of this device. |
203 * | 213 * |
204 * \returns The encapsulation mode of this device. | 214 * \returns The encapsulation mode of this device. |
205 */ | 215 */ |
206 CsmaNetDevice::EncapsulationMode GetEncapsulationMode (void); | 216 CsmaNetDevice::EncapsulationMode GetEncapsulationMode (void); |
207 | 217 |
| 218 /** |
| 219 * Set the carrier sense of this device. |
| 220 * |
| 221 * \param sense Signal carrier sense, can be either CARRIER_SENSE_IDLE or CARR
IER_SENSE_BUSY. |
| 222 */ |
| 223 void SetCarrierSense (CsmaNetDevice::CarrierSense sense); |
| 224 |
| 225 /** |
| 226 * Get the carrier sense of this device. |
| 227 * |
| 228 * \returns The signal carrier sense of this device. |
| 229 */ |
| 230 CsmaNetDevice::CarrierSense GetCarrierSense (void); |
| 231 |
208 // | 232 // |
209 // The following methods are inherited from NetDevice base class. | 233 // The following methods are inherited from NetDevice base class. |
210 // | 234 // |
211 virtual void SetIfIndex (const uint32_t index); | 235 virtual void SetIfIndex (const uint32_t index); |
212 virtual uint32_t GetIfIndex (void) const; | 236 virtual uint32_t GetIfIndex (void) const; |
213 virtual Ptr<Channel> GetChannel (void) const; | 237 virtual Ptr<Channel> GetChannel (void) const; |
214 virtual bool SetMtu (const uint16_t mtu); | 238 virtual bool SetMtu (const uint16_t mtu); |
215 virtual uint16_t GetMtu (void) const; | 239 virtual uint16_t GetMtu (void) const; |
216 virtual void SetAddress (Address address); | 240 virtual void SetAddress (Address address); |
217 virtual Address GetAddress (void) const; | 241 virtual Address GetAddress (void) const; |
(...skipping 257 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
475 TxMachineState m_txMachineState; | 499 TxMachineState m_txMachineState; |
476 | 500 |
477 /** | 501 /** |
478 * The type of packet that should be created by the AddHeader | 502 * The type of packet that should be created by the AddHeader |
479 * function and that should be processed by the ProcessHeader | 503 * function and that should be processed by the ProcessHeader |
480 * function. | 504 * function. |
481 */ | 505 */ |
482 EncapsulationMode m_encapMode; | 506 EncapsulationMode m_encapMode; |
483 | 507 |
484 /** | 508 /** |
| 509 * The state of the wire as sensed by transceiver. |
| 510 * \see CarrierSense |
| 511 */ |
| 512 CarrierSense m_carrierSense; |
| 513 |
| 514 /** |
485 * The data rate that the Net Device uses to simulate packet transmission | 515 * The data rate that the Net Device uses to simulate packet transmission |
486 * timing. | 516 * timing. |
487 * \see class DataRate | 517 * \see class DataRate |
488 */ | 518 */ |
489 DataRate m_bps; | 519 DataRate m_bps; |
490 | 520 |
491 /** | 521 /** |
492 * The interframe gap that the Net Device uses insert time between packet | 522 * The interframe gap that the Net Device uses insert time between packet |
493 * transmission | 523 * transmission |
494 * \see class Time | 524 * \see class Time |
(...skipping 220 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
715 * number of bytes that can be transmitted as seen from higher layers. | 745 * number of bytes that can be transmitted as seen from higher layers. |
716 * This corresponds to the 1500 byte MTU size often seen on IP over· | 746 * This corresponds to the 1500 byte MTU size often seen on IP over· |
717 * Ethernet. | 747 * Ethernet. |
718 */ | 748 */ |
719 uint32_t m_mtu; | 749 uint32_t m_mtu; |
720 }; | 750 }; |
721 | 751 |
722 } // namespace ns3 | 752 } // namespace ns3 |
723 | 753 |
724 #endif /* CSMA_NET_DEVICE_H */ | 754 #endif /* CSMA_NET_DEVICE_H */ |
OLD | NEW |