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 */