A Discrete-Event Network Simulator
API
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
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 
42 public:
44  bool active;
45 
46  CsmaDeviceRec();
48  CsmaDeviceRec (CsmaDeviceRec const &);
49 
54  bool IsActive ();
55 };
56 
61 {
62  IDLE,
65 };
66 
76 class CsmaChannel : public Channel
77 {
78 public:
79  static TypeId GetTypeId (void);
80 
84  CsmaChannel ();
88  virtual ~CsmaChannel ();
89 
96  int32_t Attach (Ptr<CsmaNetDevice> device);
97 
109  bool Detach (Ptr<CsmaNetDevice> device);
110 
123  bool Detach (uint32_t deviceId);
124 
138  bool Reattach (uint32_t deviceId);
139 
152  bool Reattach (Ptr<CsmaNetDevice> device);
153 
168  bool TransmitStart (Ptr<Packet> p, uint32_t srcId);
169 
184  bool TransmitEnd ();
185 
193  void PropagationCompleteEvent ();
194 
202  int32_t GetDeviceNum (Ptr<CsmaNetDevice> device);
203 
208  WireState GetState ();
209 
217  bool IsBusy ();
218 
228  bool IsActive (uint32_t deviceId);
229 
234  uint32_t GetNumActDevices (void);
235 
240  virtual uint32_t GetNDevices (void) const;
241 
249  virtual Ptr<NetDevice> GetDevice (uint32_t i) const;
250 
259  Ptr<CsmaNetDevice> GetCsmaDevice (uint32_t i) const;
260 
267  DataRate GetDataRate (void);
268 
274  Time GetDelay (void);
275 
276 private:
277  // Avoid implicit copy constructor and assignment (python bindings issues)
278  CsmaChannel (CsmaChannel const &);
280 
285 
290 
302  std::vector<CsmaDeviceRec> m_deviceList;
303 
310 
316  uint32_t m_currentSrc;
317 
322 };
323 
324 } // namespace ns3
325 
326 #endif /* CSMA_CHANNEL_H */
uint32_t m_currentSrc
Device Id of the source that is currently transmitting on the channel.
Definition: csma-channel.h:316
keep track of time values and allow control of global simulation resolution
Definition: nstime.h:81
smart pointer class similar to boost::intrusive_ptr
Definition: ptr.h:59
WireState m_state
Current state of the channel.
Definition: csma-channel.h:321
uint32_t GetNumActDevices(void)
Channel is IDLE, no packet is being transmitted.
Definition: csma-channel.h:62
Abstract Channel Base Class.
Definition: channel.h:43
std::vector< CsmaDeviceRec > m_deviceList
List of the net devices that have been or are currently connected to the channel. ...
Definition: csma-channel.h:302
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:309
Class for representing data rates.
Definition: data-rate.h:71
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:63
bool Detach(Ptr< CsmaNetDevice > device)
Detach a given netdevice from this channel.
virtual uint32_t GetNDevices(void) const
DataRate m_bps
The assigned data rate of the channel.
Definition: csma-channel.h:284
virtual Ptr< NetDevice > GetDevice(uint32_t i) const
Time m_delay
The assigned speed-of-light delay of the channel.
Definition: csma-channel.h:289
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:64
WireState
Current state of the channel.
Definition: csma-channel.h:60
bool IsActive(uint32_t deviceId)
Indicates if a net device is currently attached or detached from the channel.
Csma Channel.
Definition: csma-channel.h:76
void PropagationCompleteEvent()
Indicates that the channel has finished propagating the current packet.
CsmaNetDevice Record.
Definition: csma-channel.h:41
CsmaDeviceRec()
Is net device enabled to TX/RX.
int32_t GetDeviceNum(Ptr< CsmaNetDevice > device)
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
Pointer to the net device.
Definition: csma-channel.h:44
DataRate GetDataRate(void)
Get the assigned data rate of the channel.
Ptr< CsmaNetDevice > GetCsmaDevice(uint32_t i) const
Ptr< CsmaNetDevice > devicePtr
Definition: csma-channel.h:43
bool Reattach(uint32_t deviceId)
Reattach a previously detached net device to the channel.
a unique identifier for an interface.
Definition: type-id.h:49
bool TransmitStart(Ptr< Packet > p, uint32_t srcId)
Start transmitting a packet over the channel.
static TypeId GetTypeId(void)
Definition: csma-channel.cc:35
CsmaChannel & operator=(CsmaChannel const &)