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
109 // Delete copy constructor and assignment operator to avoid misuse
110 CsmaChannel (const CsmaChannel &) = delete;
112
120
132 bool Detach (Ptr<CsmaNetDevice> device);
133
146 bool Detach (uint32_t deviceId);
147
161 bool Reattach (uint32_t deviceId);
162
175 bool Reattach (Ptr<CsmaNetDevice> device);
176
192
207 bool TransmitEnd ();
208
217
226
232
240 bool IsBusy ();
241
251 bool IsActive (uint32_t deviceId);
252
258
263 virtual std::size_t GetNDevices (void) const;
264
272 virtual Ptr<NetDevice> GetDevice (std::size_t i) const;
273
282 Ptr<CsmaNetDevice> GetCsmaDevice (std::size_t i) const;
283
290 DataRate GetDataRate (void);
291
297 Time GetDelay (void);
298
299private:
304
309
321 std::vector<CsmaDeviceRec> m_deviceList;
322
329
336
341};
342
343} // namespace ns3
344
345#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(const CsmaChannel &)=delete
Ptr< CsmaNetDevice > GetCsmaDevice(std::size_t i) const
DataRate m_bps
The assigned data rate of the channel.
Definition: csma-channel.h:303
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:308
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:340
CsmaChannel & operator=(const CsmaChannel &)=delete
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:328
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:321
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:335
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:104
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