#include <csma-channel.h>
Public Member Functions | |
CsmaChannel () | |
Create a CsmaChannel. | |
virtual | ~CsmaChannel () |
Destroy a CsmaChannel. | |
int32_t | Attach (Ptr< CsmaNetDevice > device) |
Attach a given netdevice to this channel. | |
bool | Detach (Ptr< CsmaNetDevice > device) |
Detach a given netdevice from this channel. | |
bool | Detach (uint32_t deviceId) |
Detach a given netdevice from this channel. | |
Ptr< CsmaNetDevice > | GetCsmaDevice (uint32_t i) const |
DataRate | GetDataRate (void) |
Time | GetDelay (void) |
virtual Ptr< NetDevice > | GetDevice (uint32_t i) const |
int32_t | GetDeviceNum (Ptr< CsmaNetDevice > device) |
virtual uint32_t | GetNDevices (void) const |
uint32_t | GetNumActDevices (void) |
WireState | GetState () |
bool | IsActive (uint32_t deviceId) |
Indicates if a net device is currently attached or detached from the channel. | |
bool | IsBusy () |
Indicates if the channel is busy. The channel will only accept new packets for transmission if it is not busy. | |
void | PropagationCompleteEvent () |
Indicates that the channel has finished propagating the current packet. The channel is released and becomes free. | |
bool | Reattach (uint32_t deviceId) |
Reattach a previously detached net device to the channel. | |
bool | Reattach (Ptr< CsmaNetDevice > device) |
Reattach a previously detached net device to the channel. | |
bool | TransmitEnd () |
Indicates that the net device has finished transmitting the packet over the channel. | |
bool | TransmitStart (Ptr< Packet > p, uint32_t srcId) |
Start transmitting a packet over the channel. | |
![]() | |
Channel () | |
virtual | ~Channel () |
uint32_t | GetId (void) const |
![]() | |
Object () | |
virtual | ~Object () |
void | AggregateObject (Ptr< Object > other) |
void | Dispose (void) |
AggregateIterator | GetAggregateIterator (void) const |
virtual TypeId | GetInstanceTypeId (void) const |
template<typename T > | |
Ptr< T > | GetObject (void) const |
template<typename T > | |
Ptr< T > | GetObject (TypeId tid) const |
void | Initialize (void) |
![]() | |
SimpleRefCount () | |
SimpleRefCount (const SimpleRefCount &o) | |
uint32_t | GetReferenceCount (void) const |
SimpleRefCount & | operator= (const SimpleRefCount &o) |
void | Ref (void) const |
void | Unref (void) const |
![]() | |
virtual | ~ObjectBase () |
void | GetAttribute (std::string name, AttributeValue &value) const |
bool | GetAttributeFailSafe (std::string name, AttributeValue &attribute) const |
void | SetAttribute (std::string name, const AttributeValue &value) |
bool | SetAttributeFailSafe (std::string name, const AttributeValue &value) |
bool | TraceConnect (std::string name, std::string context, const CallbackBase &cb) |
bool | TraceConnectWithoutContext (std::string name, const CallbackBase &cb) |
bool | TraceDisconnect (std::string name, std::string context, const CallbackBase &cb) |
bool | TraceDisconnectWithoutContext (std::string name, const CallbackBase &cb) |
Static Public Member Functions | |
static TypeId | GetTypeId (void) |
Private Member Functions | |
CsmaChannel (CsmaChannel const &) | |
CsmaChannel & | operator= (CsmaChannel const &) |
Private Attributes | |
DataRate | m_bps |
Ptr< Packet > | m_currentPkt |
uint32_t | m_currentSrc |
Time | m_delay |
std::vector< CsmaDeviceRec > | m_deviceList |
WireState | m_state |
Additional Inherited Members | |
![]() | |
Object (const Object &o) | |
virtual void | DoDispose (void) |
virtual void | DoInitialize (void) |
virtual void | NotifyNewAggregate (void) |
Csma Channel.
This class represents a simple Csma channel that can be used when many nodes are connected to one wire. It uses a single busy flag to indicate if the channel is currently in use. It does not take into account the distances between stations or the speed of light to determine collisions.
ns3::CsmaChannel is accessible through the following paths with Config::Set and Config::Connect:
No TraceSources are defined for this type.
Definition at line 76 of file csma-channel.h.
ns3::CsmaChannel::CsmaChannel | ( | ) |
Create a CsmaChannel.
Definition at line 52 of file csma-channel.cc.
References ns3::IDLE, m_deviceList, m_state, and NS_LOG_FUNCTION_NOARGS.
|
virtual |
Destroy a CsmaChannel.
Definition at line 61 of file csma-channel.cc.
References m_deviceList, and NS_LOG_FUNCTION.
|
private |
int32_t ns3::CsmaChannel::Attach | ( | Ptr< CsmaNetDevice > | device | ) |
Attach a given netdevice to this channel.
device | Device pointer to the netdevice to attach to the channel |
Definition at line 68 of file csma-channel.cc.
References m_deviceList, NS_ASSERT, and NS_LOG_FUNCTION.
Referenced by ns3::CsmaNetDevice::Attach().
bool ns3::CsmaChannel::Detach | ( | Ptr< CsmaNetDevice > | device | ) |
Detach a given netdevice from this channel.
The net device is marked as inactive and it is not allowed to receive or transmit packets
device | Device pointer to the netdevice to detach from the channel |
Definition at line 154 of file csma-channel.cc.
References m_deviceList, NS_ASSERT, and NS_LOG_FUNCTION.
bool ns3::CsmaChannel::Detach | ( | uint32_t | deviceId | ) |
Detach a given netdevice from this channel.
The net device is marked as inactive and it is not allowed to receive or transmit packets
deviceId | The deviceID assigned to the net device when it was connected to the channel |
Definition at line 126 of file csma-channel.cc.
References m_currentSrc, m_deviceList, m_state, NS_LOG_FUNCTION, NS_LOG_WARN, and ns3::TRANSMITTING.
Ptr< CsmaNetDevice > ns3::CsmaChannel::GetCsmaDevice | ( | uint32_t | i | ) | const |
i | The deviceId of the net device for which we want the pointer. |
Definition at line 277 of file csma-channel.cc.
References m_deviceList.
Referenced by GetDevice().
DataRate ns3::CsmaChannel::GetDataRate | ( | void | ) |
Get the assigned data rate of the channel
Definition at line 320 of file csma-channel.cc.
References m_bps.
Referenced by ns3::CsmaNetDevice::Attach().
Time ns3::CsmaChannel::GetDelay | ( | void | ) |
Get the assigned speed-of-light delay of the channel
Definition at line 326 of file csma-channel.cc.
References m_delay.
i | The index of the net device. |
Implements ns3::Channel.
Definition at line 338 of file csma-channel.cc.
References GetCsmaDevice().
int32_t ns3::CsmaChannel::GetDeviceNum | ( | Ptr< CsmaNetDevice > | device | ) |
device | Device pointer to the netdevice for which the device number is needed |
Definition at line 284 of file csma-channel.cc.
References m_deviceList.
|
virtual |
Implements ns3::Channel.
Definition at line 271 of file csma-channel.cc.
References m_deviceList.
uint32_t ns3::CsmaChannel::GetNumActDevices | ( | void | ) |
Definition at line 256 of file csma-channel.cc.
References m_deviceList.
WireState ns3::CsmaChannel::GetState | ( | void | ) |
Definition at line 332 of file csma-channel.cc.
References m_state.
Referenced by ns3::CsmaNetDevice::TransmitCompleteEvent(), and ns3::CsmaNetDevice::TransmitStart().
|
static |
Reimplemented from ns3::Channel.
Definition at line 34 of file csma-channel.cc.
References m_bps, m_delay, ns3::Seconds(), and ns3::TypeId::SetParent().
bool ns3::CsmaChannel::IsActive | ( | uint32_t | deviceId | ) |
Indicates if a net device is currently attached or detached from the channel.
deviceId | The ID that was assigned to the net device when it was attached to the channel. |
Definition at line 197 of file csma-channel.cc.
References m_deviceList.
Referenced by TransmitEnd(), and TransmitStart().
bool ns3::CsmaChannel::IsBusy | ( | void | ) |
Indicates if the channel is busy. The channel will only accept new packets for transmission if it is not busy.
Definition at line 307 of file csma-channel.cc.
|
private |
void ns3::CsmaChannel::PropagationCompleteEvent | ( | ) |
Indicates that the channel has finished propagating the current packet. The channel is released and becomes free.
Calls the receive function of every active net device that is attached to the channel.
Definition at line 246 of file csma-channel.cc.
References ns3::Packet::GetUid(), ns3::IDLE, m_currentPkt, m_state, NS_ASSERT, NS_LOG_FUNCTION, NS_LOG_INFO, and ns3::PROPAGATING.
Referenced by TransmitEnd().
bool ns3::CsmaChannel::Reattach | ( | uint32_t | deviceId | ) |
Reattach a previously detached net device to the channel.
The net device is marked as active. It is now allowed to receive or transmit packets. The net device must have been previously attached to the channel using the attach function.
deviceId | The device ID assigned to the net device when it was connected to the channel |
Definition at line 105 of file csma-channel.cc.
References m_deviceList, and NS_LOG_FUNCTION.
bool ns3::CsmaChannel::Reattach | ( | Ptr< CsmaNetDevice > | device | ) |
Reattach a previously detached net device to the channel.
The net device is marked as active. It is now allowed to receive or transmit packets. The net device must have been previously attached to the channel using the attach function.
device | Device pointer to the netdevice to detach from the channel |
Definition at line 80 of file csma-channel.cc.
References m_deviceList, NS_ASSERT, and NS_LOG_FUNCTION.
bool ns3::CsmaChannel::TransmitEnd | ( | ) |
Indicates that the net device has finished transmitting the packet over the channel.
The channel will stay busy until the packet has completely propagated to all net devices attached to the channel. The TransmitEnd function schedules the PropagationCompleteEvent which will free the channel for further transmissions. Stores the packet p as the m_currentPkt, the packet being currently transmitting.
Definition at line 203 of file csma-channel.cc.
References ns3::Packet::Copy(), ns3::Time::GetSeconds(), ns3::Packet::GetUid(), IsActive(), m_currentPkt, m_currentSrc, m_delay, m_deviceList, m_state, NS_ASSERT, NS_LOG_ERROR, NS_LOG_FUNCTION, NS_LOG_INFO, NS_LOG_LOGIC, ns3::PROPAGATING, PropagationCompleteEvent(), ns3::CsmaNetDevice::Receive(), ns3::Simulator::Schedule(), ns3::Simulator::ScheduleWithContext(), and ns3::TRANSMITTING.
Referenced by ns3::CsmaNetDevice::TransmitCompleteEvent().
Start transmitting a packet over the channel.
If the srcId belongs to a net device that is connected to the channel, packet transmission begins, and the channel becomes busy until the packet has completely reached all destinations.
p | A reference to the packet that will be transmitted over the channel |
srcId | The device Id of the net device that wants to transmit on the channel. |
Definition at line 172 of file csma-channel.cc.
References ns3::Packet::GetUid(), ns3::IDLE, IsActive(), m_currentPkt, m_currentSrc, m_state, NS_LOG_ERROR, NS_LOG_FUNCTION, NS_LOG_INFO, NS_LOG_LOGIC, NS_LOG_WARN, and ns3::TRANSMITTING.
Referenced by ns3::CsmaNetDevice::TransmitStart().
|
private |
The assigned data rate of the channel
Definition at line 284 of file csma-channel.h.
Referenced by GetDataRate(), and GetTypeId().
The Packet that is currently being transmitted on the channel (or last packet to have been transmitted on the channel if the channel is free.)
Definition at line 309 of file csma-channel.h.
Referenced by PropagationCompleteEvent(), TransmitEnd(), and TransmitStart().
|
private |
Device Id of the source that is currently transmitting on the channel. Or last source to have transmitted a packet on the channel, if the channel is currently not busy.
Definition at line 316 of file csma-channel.h.
Referenced by Detach(), TransmitEnd(), and TransmitStart().
|
private |
The assigned speed-of-light delay of the channel
Definition at line 289 of file csma-channel.h.
Referenced by GetDelay(), GetTypeId(), and TransmitEnd().
|
private |
List of the net devices that have been or are currently connected to the channel.
Devices are nor removed from this list, they are marked as inactive. Otherwise the assigned device IDs will not refer to the correct NetDevice. The DeviceIds are used so that it is possible to have a number to refer to an entry in the list so that the whole list does not have to be searched when making sure that a source is attached to a channel when it is transmitting data.
Definition at line 302 of file csma-channel.h.
Referenced by Attach(), CsmaChannel(), Detach(), GetCsmaDevice(), GetDeviceNum(), GetNDevices(), GetNumActDevices(), IsActive(), Reattach(), TransmitEnd(), and ~CsmaChannel().
|
private |
Current state of the channel
Definition at line 321 of file csma-channel.h.
Referenced by CsmaChannel(), Detach(), GetState(), IsBusy(), PropagationCompleteEvent(), TransmitEnd(), and TransmitStart().