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
29namespace ns3 {
30
31class Packet;
32
33class CsmaNetDevice;
34
43public:
45 bool active;
46
48
56
62
67 bool IsActive ();
68};
69
74{
78};
79
90class CsmaChannel : public Channel
91{
92public:
93
98 static TypeId GetTypeId (void);
99
103 CsmaChannel ();
107 virtual ~CsmaChannel ();
108
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
188
203 bool TransmitEnd ();
204
213
222
228
236 bool IsBusy ();
237
247 bool IsActive (uint32_t deviceId);
248
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
295private:
302
310
315
320
332 std::vector<CsmaDeviceRec> m_deviceList;
333
340
347
352};
353
354} // namespace ns3
355
356#endif /* CSMA_CHANNEL_H */
Abstract Channel Base Class.
Definition: channel.h:44
Csma Channel.
Definition: csma-channel.h:91
virtual Ptr< NetDevice > GetDevice(std::size_t i) const
uint32_t GetNumActDevices(void)
CsmaChannel(CsmaChannel const &o)
Copy constructor is declared but not implemented.
Ptr< CsmaNetDevice > GetCsmaDevice(std::size_t i) const
CsmaChannel & operator=(CsmaChannel const &o)
Operator = is declared but not implemented.
DataRate m_bps
The assigned data rate of the channel.
Definition: csma-channel.h:314
DataRate GetDataRate(void)
Get the assigned data rate of the channel.
bool Reattach(uint32_t deviceId)
Reattach a previously detached net device to the channel.
bool IsActive(uint32_t deviceId)
Indicates if a net device is currently attached or detached from the channel.
static TypeId GetTypeId(void)
Get the type ID.
Definition: csma-channel.cc:34
Time GetDelay(void)
Get the assigned speed-of-light delay of the channel.
int32_t GetDeviceNum(Ptr< CsmaNetDevice > device)
bool TransmitEnd()
Indicates that the net device has finished transmitting the packet over the channel.
Time m_delay
The assigned speed-of-light delay of the channel.
Definition: csma-channel.h:319
virtual ~CsmaChannel()
Destroy a CsmaChannel.
Definition: csma-channel.cc:62
bool TransmitStart(Ptr< const Packet > p, uint32_t srcId)
Start transmitting a packet over the channel.
WireState m_state
Current state of the channel.
Definition: csma-channel.h:351
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
CsmaChannel()
Create a CsmaChannel.
Definition: csma-channel.cc:53
bool Detach(Ptr< CsmaNetDevice > device)
Detach a given netdevice from this channel.
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
void PropagationCompleteEvent()
Indicates that the channel has finished propagating the current packet.
virtual std::size_t GetNDevices(void) const
int32_t Attach(Ptr< CsmaNetDevice > device)
Attach a given netdevice to this channel.
Definition: csma-channel.cc:69
bool IsBusy()
Indicates if the channel is busy.
WireState GetState()
uint32_t m_currentSrc
Device Id of the source that is currently transmitting on the channel.
Definition: csma-channel.h:346
CsmaNetDevice Record.
Definition: csma-channel.h:42
Ptr< CsmaNetDevice > devicePtr
Pointer to the net device.
Definition: csma-channel.h:44
bool active
Is net device enabled to TX/RX.
Definition: csma-channel.h:45
Class for representing data rates.
Definition: data-rate.h:89
Smart pointer class similar to boost::intrusive_ptr.
Definition: ptr.h:74
Simulation virtual time values and global simulation resolution.
Definition: nstime.h:103
a unique identifier for an interface.
Definition: type-id.h:59
Every class exported by the ns3 library is enclosed in the ns3 namespace.
WireState
Current state of the channel.
Definition: csma-channel.h:74
@ TRANSMITTING
Channel is BUSY, a packet is being written by a net device.
Definition: csma-channel.h:76
@ PROPAGATING
Channel is BUSY, packet is propagating to all attached net devices.
Definition: csma-channel.h:77
@ IDLE
Channel is IDLE, no packet is being transmitted.
Definition: csma-channel.h:75