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:
301  CsmaChannel (CsmaChannel const &o);
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 */
uint32_t m_currentSrc
Device Id of the source that is currently transmitting on the channel.
Definition: csma-channel.h:346
Simulation virtual time values and global simulation resolution.
Definition: nstime.h:102
Smart pointer class similar to boost::intrusive_ptr.
Definition: ptr.h:73
WireState m_state
Current state of the channel.
Definition: csma-channel.h:351
uint32_t GetNumActDevices(void)
Channel is IDLE, no packet is being transmitted.
Definition: csma-channel.h:75
Abstract Channel Base Class.
Definition: channel.h:43
virtual std::size_t GetNDevices(void) const
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
WireState GetState()
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
Class for representing data rates.
Definition: data-rate.h:88
virtual ~CsmaChannel()
Destroy a CsmaChannel.
Definition: csma-channel.cc:62
Channel is BUSY, a packet is being written by a net device.
Definition: csma-channel.h:76
bool Detach(Ptr< CsmaNetDevice > device)
Detach a given netdevice from this channel.
DataRate m_bps
The assigned data rate of the channel.
Definition: csma-channel.h:314
Time m_delay
The assigned speed-of-light delay of the channel.
Definition: csma-channel.h:319
Time GetDelay(void)
Get the assigned speed-of-light delay of the channel.
int32_t Attach(Ptr< CsmaNetDevice > device)
Attach a given netdevice to this channel.
Definition: csma-channel.cc:69
Channel is BUSY, packet is propagating to all attached net devices.
Definition: csma-channel.h:77
Ptr< CsmaNetDevice > GetCsmaDevice(std::size_t i) const
WireState
Current state of the channel.
Definition: csma-channel.h:73
bool IsActive(uint32_t deviceId)
Indicates if a net device is currently attached or detached from the channel.
Csma Channel.
Definition: csma-channel.h:90
Every class exported by the ns3 library is enclosed in the ns3 namespace.
void PropagationCompleteEvent()
Indicates that the channel has finished propagating the current packet.
CsmaNetDevice Record.
Definition: csma-channel.h:42
int32_t GetDeviceNum(Ptr< CsmaNetDevice > device)
CsmaChannel & operator=(CsmaChannel const &o)
Operator = is declared but not implemented.
CsmaChannel()
Create a CsmaChannel.
Definition: csma-channel.cc:53
bool TransmitEnd()
Indicates that the net device has finished transmitting the packet over the channel.
bool IsBusy()
Indicates if the channel is busy.
bool active
Is net device enabled to TX/RX.
Definition: csma-channel.h:45
DataRate GetDataRate(void)
Get the assigned data rate of the channel.
bool TransmitStart(Ptr< const Packet > p, uint32_t srcId)
Start transmitting a packet over the channel.
Ptr< CsmaNetDevice > devicePtr
Pointer to the net device.
Definition: csma-channel.h:44
virtual Ptr< NetDevice > GetDevice(std::size_t i) const
bool Reattach(uint32_t deviceId)
Reattach a previously detached net device to the channel.
a unique identifier for an interface.
Definition: type-id.h:58
static TypeId GetTypeId(void)
Get the type ID.
Definition: csma-channel.cc:34