31 #include "ns3/packet.h"
32 #include "ns3/simulator.h"
51 "The transmission data rate to be provided to devices connected to the channel",
54 MakeDataRateChecker())
55 .AddAttribute(
"Delay",
56 "Transmission delay through the channel",
60 .AddAttribute(
"FullDuplex",
61 "Whether the channel is full-duplex mode.",
112 std::vector<CsmaDeviceRec>::iterator it;
115 if (it->devicePtr == device)
161 NS_LOG_WARN(
"CsmaChannel::Detach(): Device is already detached (" << deviceId <<
")");
169 NS_LOG_WARN(
"CsmaChannel::Detach(): Device is currently"
170 <<
"transmitting (" << deviceId <<
")");
187 std::vector<CsmaDeviceRec>::iterator it;
190 if ((it->devicePtr == device) && (it->active))
207 NS_LOG_WARN(
"CsmaChannel::TransmitStart(): State is not IDLE");
214 "CsmaChannel::TransmitStart(): Selected source is not currently attached to network");
250 NS_LOG_ERROR(
"CsmaChannel::TransmitEnd(): Seclected source was detached before the end of "
259 std::vector<CsmaDeviceRec>::iterator it;
308 int numActDevices = 0;
309 std::vector<CsmaDeviceRec>::iterator it;
317 return numActDevices;
335 std::vector<CsmaDeviceRec>::iterator it;
339 if (it->devicePtr == device)
AttributeValue implementation for Boolean.
Abstract Channel Base Class.
void PropagationCompleteEvent(uint32_t deviceId)
Indicates that the channel has finished propagating the current packet.
void SetState(uint32_t deviceId, WireState state)
Sets the state of the channel.
~CsmaChannel() override
Destroy a CsmaChannel.
Ptr< CsmaNetDevice > GetCsmaDevice(std::size_t i) const
uint32_t GetNumActDevices()
DataRate m_bps
The assigned data rate of the channel.
bool m_fullDuplex
Whether the channel is in full-duplex mode.
DataRate GetDataRate()
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.
Time GetDelay()
Get the assigned speed-of-light delay of the channel.
bool IsBusy(uint32_t deviceId)
Indicates if the channel is busy.
int32_t GetDeviceNum(Ptr< CsmaNetDevice > device)
Time m_delay
The assigned speed-of-light delay of the channel.
bool TransmitStart(Ptr< const Packet > p, uint32_t srcId)
Start transmitting a packet over the channel.
static TypeId GetTypeId()
Get the type ID.
WireState GetState(uint32_t deviceId)
Checks the state of the channel.
CsmaChannel()
Create a CsmaChannel.
bool Detach(Ptr< CsmaNetDevice > device)
Detach a given netdevice from this channel.
bool TransmitEnd(uint32_t deviceId)
Indicates that the net device has finished transmitting the packet over the channel.
void SetCurrentPkt(uint32_t deviceId, Ptr< Packet > pkt)
Sets the current packet.
void SetCurrentSrc(uint32_t deviceId, uint32_t transmitterId)
Sets the current transmitter.
WireState m_state[2]
Current state of each subchannel.
std::vector< CsmaDeviceRec > m_deviceList
List of the net devices that have been or are currently connected to the channel.
Ptr< Packet > GetCurrentPkt(uint32_t deviceId)
Gets current packet.
int32_t Attach(Ptr< CsmaNetDevice > device)
Attach a given netdevice to this channel.
bool IsFullDuplex() const
Indicates if channel is operating in full-duplex mode.
Ptr< NetDevice > GetDevice(std::size_t i) const override
uint32_t m_currentSrc[2]
Device Id of the source that is currently transmitting on the subchannel, or the last source to have ...
uint32_t GetCurrentSrc(uint32_t deviceId)
Gets current transmitter.
WireState
Current state of the channel.
@ PROPAGATING
Channel is BUSY, packet is propagating to all attached net devices.
@ IDLE
Channel is IDLE, no packet is being transmitted.
@ TRANSMITTING
Channel is BUSY, a packet is being written by a net device.
Ptr< Packet > m_currentPkt[2]
The Packet that is currently being transmitted on the subchannel (or the last packet to have been tra...
std::size_t GetNDevices() const override
Ptr< CsmaNetDevice > devicePtr
Pointer to the net device.
bool active
Is net device enabled to TX/RX.
void Receive(Ptr< Packet > p, Ptr< CsmaNetDevice > sender)
Receive a packet from a connected CsmaChannel.
Class for representing data rates.
AttributeValue implementation for DataRate.
Ptr< Packet > Copy() const
performs a COW copy of the packet.
uint64_t GetUid() const
Returns the packet's Uid.
Smart pointer class similar to boost::intrusive_ptr.
static EventId Schedule(const Time &delay, FUNC f, Ts &&... args)
Schedule an event to expire after delay.
static void ScheduleWithContext(uint32_t context, const Time &delay, FUNC f, Ts &&... args)
Schedule an event with the given context.
Simulation virtual time values and global simulation resolution.
TimeWithUnit As(const Unit unit=Time::AUTO) const
Attach a unit to a Time, to facilitate output in a specific unit.
AttributeValue implementation for Time.
a unique identifier for an interface.
@ ATTR_CONSTRUCT
The attribute can be written at construction-time.
TypeId SetParent(TypeId tid)
Set the parent TypeId.
#define NS_ASSERT(condition)
At runtime, in debugging builds, if this condition is not true, the program prints the source file,...
Ptr< const AttributeAccessor > MakeBooleanAccessor(T1 a1)
Create an AttributeAccessor for a class data member, or a lone class get functor or set method.
Ptr< const AttributeChecker > MakeBooleanChecker()
Ptr< const AttributeAccessor > MakeTimeAccessor(T1 a1)
Create an AttributeAccessor for a class data member, or a lone class get functor or set method.
#define NS_LOG_ERROR(msg)
Use NS_LOG to output a message of level LOG_ERROR.
#define NS_LOG_COMPONENT_DEFINE(name)
Define a Log component with a specific name.
#define NS_LOG_DEBUG(msg)
Use NS_LOG to output a message of level LOG_DEBUG.
#define NS_LOG_LOGIC(msg)
Use NS_LOG to output a message of level LOG_LOGIC.
#define NS_LOG_FUNCTION_NOARGS()
Output the name of the function.
#define NS_LOG_FUNCTION(parameters)
If log level LOG_FUNCTION is enabled, this macro will output all input parameters separated by ",...
#define NS_LOG_WARN(msg)
Use NS_LOG to output a message of level LOG_WARN.
#define NS_LOG_INFO(msg)
Use NS_LOG to output a message of level LOG_INFO.
void(* DataRate)(DataRate oldValue, DataRate newValue)
TracedValue callback signature for DataRate.
#define NS_OBJECT_ENSURE_REGISTERED(type)
Register an Object subclass with the TypeId system.
Time Seconds(double value)
Construct a Time in the indicated unit.
Every class exported by the ns3 library is enclosed in the ns3 namespace.
Ptr< const AttributeChecker > MakeTimeChecker(const Time min, const Time max)
Helper to make a Time checker with bounded range.
Ptr< T > Copy(Ptr< T > object)
Return a deep copy of a Ptr.