A Discrete-Event Network Simulator
API
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
csma-channel.h
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:
43  Ptr< CsmaNetDevice > devicePtr;
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 &);
279  CsmaChannel &operator = (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
Definition: csma-channel.h:316
keep track of time unit.
Definition: nstime.h:149
smart pointer class similar to boost::intrusive_ptr
Definition: ptr.h:59
WireState m_state
Definition: csma-channel.h:321
uint32_t GetNumActDevices(void)
Abstract Channel Base Class.
Definition: channel.h:43
std::vector< CsmaDeviceRec > m_deviceList
Definition: csma-channel.h:302
WireState GetState()
Ptr< Packet > m_currentPkt
Definition: csma-channel.h:309
Class for representing data rates.
Definition: data-rate.h:71
virtual ~CsmaChannel()
Destroy a CsmaChannel.
Definition: csma-channel.cc:61
bool Detach(Ptr< CsmaNetDevice > device)
Detach a given netdevice from this channel.
virtual uint32_t GetNDevices(void) const
virtual Ptr< NetDevice > GetDevice(uint32_t i) const
Time GetDelay(void)
int32_t Attach(Ptr< CsmaNetDevice > device)
Attach a given netdevice to this channel.
Definition: csma-channel.cc:68
WireState
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. The channel is released and b...
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:52
bool TransmitEnd()
Indicates that the net device has finished transmitting the packet over the channel.
bool IsBusy()
Indicates if the channel is busy. The channel will only accept new packets for transmission if it is ...
bool active
Pointer to the net device.
Definition: csma-channel.h:44
DataRate GetDataRate(void)
Ptr< CsmaNetDevice > GetCsmaDevice(uint32_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:44
bool TransmitStart(Ptr< Packet > p, uint32_t srcId)
Start transmitting a packet over the channel.