A Discrete-Event Network Simulator
API
csma-channel.h
Go to the documentation of this file.
1 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
2 /*
3  * Copyright (c) 2007 Emmanuelle Laprise
4  *
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
7  * published by the Free Software Foundation;
8  *
9  * This program is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12  * GNU General Public License for more details.
13  *
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
16  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17  *
18  * Author: Emmanuelle Laprise<emmanuelle.laprise@bluekazoo.ca>
19  */
20 
21 #ifndef CSMA_CHANNEL_H
22 #define CSMA_CHANNEL_H
23 
24 #include "ns3/channel.h"
25 #include "ns3/ptr.h"
26 #include "ns3/nstime.h"
27 #include "ns3/data-rate.h"
28 
29 namespace ns3 {
30 
31 class Packet;
32 
33 class CsmaNetDevice;
34 
43 public:
45  bool active;
46 
47  CsmaDeviceRec();
48 
56 
61  CsmaDeviceRec (CsmaDeviceRec const &o);
62 
67  bool IsActive ();
68 };
69 
74 {
75  IDLE,
78 };
79 
90 class CsmaChannel : public Channel
91 {
92 public:
93 
98  static TypeId GetTypeId (void);
99 
103  CsmaChannel ();
107  virtual ~CsmaChannel ();
108 
115  int32_t Attach (Ptr<CsmaNetDevice> device);
116 
128  bool Detach (Ptr<CsmaNetDevice> device);
129 
142  bool Detach (uint32_t deviceId);
143 
157  bool Reattach (uint32_t deviceId);
158 
171  bool Reattach (Ptr<CsmaNetDevice> device);
172 
187  bool TransmitStart (Ptr<const Packet> p, uint32_t srcId);
188 
203  bool TransmitEnd ();
204 
212  void PropagationCompleteEvent ();
213 
221  int32_t GetDeviceNum (Ptr<CsmaNetDevice> device);
222 
227  WireState GetState ();
228 
236  bool IsBusy ();
237 
247  bool IsActive (uint32_t deviceId);
248 
253  uint32_t GetNumActDevices (void);
254 
259  virtual std::size_t GetNDevices (void) const;
260 
268  virtual Ptr<NetDevice> GetDevice (std::size_t i) const;
269 
278  Ptr<CsmaNetDevice> GetCsmaDevice (std::size_t i) const;
279 
286  DataRate GetDataRate (void);
287 
293  Time GetDelay (void);
294 
295 private:
302 
310 
315 
320 
332  std::vector<CsmaDeviceRec> m_deviceList;
333 
340 
346  uint32_t m_currentSrc;
347 
352 };
353 
354 } // namespace ns3
355 
356 #endif /* CSMA_CHANNEL_H */
ns3::TypeId
a unique identifier for an interface.
Definition: type-id.h:59
ns3::CsmaChannel::m_bps
DataRate m_bps
The assigned data rate of the channel.
Definition: csma-channel.h:314
ns3::CsmaChannel::m_delay
Time m_delay
The assigned speed-of-light delay of the channel.
Definition: csma-channel.h:319
ns3::CsmaDeviceRec::CsmaDeviceRec
CsmaDeviceRec()
Definition: csma-channel.cc:343
ns3
Every class exported by the ns3 library is enclosed in the ns3 namespace.
ns3::CsmaDeviceRec::devicePtr
Ptr< CsmaNetDevice > devicePtr
Pointer to the net device.
Definition: csma-channel.h:44
ns3::CsmaChannel::GetDevice
virtual Ptr< NetDevice > GetDevice(std::size_t i) const
Definition: csma-channel.cc:338
ns3::CsmaDeviceRec::IsActive
bool IsActive()
Definition: csma-channel.cc:361
ns3::CsmaChannel
Csma Channel.
Definition: csma-channel.h:91
ns3::WireState
WireState
Current state of the channel.
Definition: csma-channel.h:74
ns3::CsmaChannel::GetState
WireState GetState()
Definition: csma-channel.cc:332
ns3::CsmaChannel::GetCsmaDevice
Ptr< CsmaNetDevice > GetCsmaDevice(std::size_t i) const
Definition: csma-channel.cc:278
ns3::CsmaChannel::m_currentPkt
Ptr< Packet > m_currentPkt
The Packet that is currently being transmitted on the channel (or last packet to have been transmitte...
Definition: csma-channel.h:339
ns3::CsmaChannel::GetTypeId
static TypeId GetTypeId(void)
Get the type ID.
Definition: csma-channel.cc:34
ns3::CsmaDeviceRec
CsmaNetDevice Record.
Definition: csma-channel.h:42
ns3::CsmaChannel::Attach
int32_t Attach(Ptr< CsmaNetDevice > device)
Attach a given netdevice to this channel.
Definition: csma-channel.cc:69
ns3::CsmaChannel::m_deviceList
std::vector< CsmaDeviceRec > m_deviceList
List of the net devices that have been or are currently connected to the channel.
Definition: csma-channel.h:332
ns3::CsmaChannel::CsmaChannel
CsmaChannel()
Create a CsmaChannel.
Definition: csma-channel.cc:53
ns3::Ptr
Smart pointer class similar to boost::intrusive_ptr.
Definition: ptr.h:74
ns3::DataRate
Class for representing data rates.
Definition: data-rate.h:89
ns3::CsmaChannel::IsBusy
bool IsBusy()
Indicates if the channel is busy.
Definition: csma-channel.cc:307
ns3::IDLE
@ IDLE
Channel is IDLE, no packet is being transmitted.
Definition: csma-channel.h:75
ns3::CsmaChannel::GetNDevices
virtual std::size_t GetNDevices(void) const
Definition: csma-channel.cc:272
ns3::CsmaDeviceRec::active
bool active
Is net device enabled to TX/RX.
Definition: csma-channel.h:45
ns3::CsmaChannel::IsActive
bool IsActive(uint32_t deviceId)
Indicates if a net device is currently attached or detached from the channel.
Definition: csma-channel.cc:198
ns3::Time
Simulation virtual time values and global simulation resolution.
Definition: nstime.h:104
ns3::CsmaChannel::PropagationCompleteEvent
void PropagationCompleteEvent()
Indicates that the channel has finished propagating the current packet.
Definition: csma-channel.cc:247
ns3::CsmaChannel::GetDeviceNum
int32_t GetDeviceNum(Ptr< CsmaNetDevice > device)
Definition: csma-channel.cc:284
ns3::CsmaChannel::GetDelay
Time GetDelay(void)
Get the assigned speed-of-light delay of the channel.
Definition: csma-channel.cc:326
ns3::TRANSMITTING
@ TRANSMITTING
Channel is BUSY, a packet is being written by a net device.
Definition: csma-channel.h:76
ns3::Channel
Abstract Channel Base Class.
Definition: channel.h:44
ns3::CsmaChannel::TransmitStart
bool TransmitStart(Ptr< const Packet > p, uint32_t srcId)
Start transmitting a packet over the channel.
Definition: csma-channel.cc:173
ns3::CsmaChannel::m_state
WireState m_state
Current state of the channel.
Definition: csma-channel.h:351
ns3::CsmaChannel::~CsmaChannel
virtual ~CsmaChannel()
Destroy a CsmaChannel.
Definition: csma-channel.cc:62
ns3::CsmaChannel::m_currentSrc
uint32_t m_currentSrc
Device Id of the source that is currently transmitting on the channel.
Definition: csma-channel.h:346
ns3::CsmaChannel::GetDataRate
DataRate GetDataRate(void)
Get the assigned data rate of the channel.
Definition: csma-channel.cc:320
ns3::PROPAGATING
@ PROPAGATING
Channel is BUSY, packet is propagating to all attached net devices.
Definition: csma-channel.h:77
ns3::CsmaChannel::Detach
bool Detach(Ptr< CsmaNetDevice > device)
Detach a given netdevice from this channel.
Definition: csma-channel.cc:155
ns3::CsmaChannel::TransmitEnd
bool TransmitEnd()
Indicates that the net device has finished transmitting the packet over the channel.
Definition: csma-channel.cc:204
ns3::CsmaChannel::operator=
CsmaChannel & operator=(CsmaChannel const &o)
Operator = is declared but not implemented.
ns3::CsmaChannel::CsmaChannel
CsmaChannel(CsmaChannel const &o)
Copy constructor is declared but not implemented.
ns3::CsmaChannel::GetNumActDevices
uint32_t GetNumActDevices(void)
Definition: csma-channel.cc:257
ns3::CsmaChannel::Reattach
bool Reattach(uint32_t deviceId)
Reattach a previously detached net device to the channel.
Definition: csma-channel.cc:106