23 #include "ns3/packet.h"
24 #include "ns3/simulator.h"
38 .AddConstructor<CsmaChannel> ()
39 .AddAttribute (
"DataRate",
40 "The transmission data rate to be provided to devices connected to the channel",
43 MakeDataRateChecker ())
44 .AddAttribute (
"Delay",
"Transmission delay through the channel",
85 std::vector<CsmaDeviceRec>::iterator it;
88 if (it->devicePtr == device)
134 NS_LOG_WARN (
"CsmaChannel::Detach(): Device is already detached (" << deviceId <<
")");
142 NS_LOG_WARN (
"CsmaChannel::Detach(): Device is currently" <<
"transmitting (" << deviceId <<
")");
159 std::vector<CsmaDeviceRec>::iterator it;
162 if ((it->devicePtr == device) && (it->active))
179 NS_LOG_WARN (
"CsmaChannel::TransmitStart(): State is not IDLE");
185 NS_LOG_ERROR (
"CsmaChannel::TransmitStart(): Seclected source is not currently attached to network");
215 NS_LOG_ERROR (
"CsmaChannel::TransmitEnd(): Seclected source was detached before the end of the transmission");
224 std::vector<CsmaDeviceRec>::iterator it;
258 int numActDevices = 0;
259 std::vector<CsmaDeviceRec>::iterator it;
267 return numActDevices;
286 std::vector<CsmaDeviceRec>::iterator it;
290 if (it->devicePtr == device)
uint32_t m_currentSrc
Device Id of the source that is currently transmitting on the channel.
Simulation virtual time values and global simulation resolution.
smart pointer class similar to boost::intrusive_ptr
#define NS_LOG_FUNCTION(parameters)
If log level LOG_FUNCTION is enabled, this macro will output all input parameters separated by "...
WireState m_state
Current state of the channel.
#define NS_OBJECT_ENSURE_REGISTERED(type)
Register the class in the ns-3 factory.
void Receive(Ptr< Packet > p, Ptr< CsmaNetDevice > sender)
Receive a packet from a connected CsmaChannel.
uint64_t GetUid(void) const
Returns the packet's Uid.
#define NS_ASSERT(condition)
At runtime, in debugging builds, if this condition is not true, the program prints the source file...
uint32_t GetNumActDevices(void)
Channel is IDLE, no packet is being transmitted.
#define NS_LOG_COMPONENT_DEFINE(name)
Define a Log component with a specific name.
Abstract Channel Base Class.
#define NS_LOG_INFO(msg)
Use NS_LOG to output a message of level LOG_INFO.
#define NS_LOG_FUNCTION_NOARGS()
Output the name of the function.
static EventId Schedule(Time const &time, MEM mem_ptr, OBJ obj)
Schedule an event to expire at the relative time "time" is reached.
std::vector< CsmaDeviceRec > m_deviceList
List of the net devices that have been or are currently connected to the channel. ...
Ptr< const AttributeChecker > MakeTimeChecker(const Time min, const Time max)
Helper to make a Time checker with bounded range.
Ptr< Packet > m_currentPkt
The Packet that is currently being transmitted on the channel (or last packet to have been transmitte...
Class for representing data rates.
virtual ~CsmaChannel()
Destroy a CsmaChannel.
Channel is BUSY, a packet is being written by a net device.
double GetSeconds(void) const
Get an approximation of the time stored in this instance in the indicated unit.
bool Detach(Ptr< CsmaNetDevice > device)
Detach a given netdevice from this channel.
virtual uint32_t GetNDevices(void) const
Attribute for objects of type ns3::Time.
DataRate m_bps
The assigned data rate of the channel.
virtual Ptr< NetDevice > GetDevice(uint32_t i) const
Time m_delay
The assigned speed-of-light delay of the channel.
Time GetDelay(void)
Get the assigned speed-of-light delay of the channel.
int32_t Attach(Ptr< CsmaNetDevice > device)
Attach a given netdevice to this channel.
static void ScheduleWithContext(uint32_t context, Time const &time, MEM mem_ptr, OBJ obj)
Schedule an event with the given context.
#define NS_LOG_LOGIC(msg)
Use NS_LOG to output a message of level LOG_LOGIC.
Channel is BUSY, packet is propagating to all attached net devices.
Ptr< Packet > Copy(void) const
performs a COW copy of the packet.
WireState
Current state of the channel.
bool IsActive(uint32_t deviceId)
Indicates if a net device is currently attached or detached from the channel.
void PropagationCompleteEvent()
Indicates that the channel has finished propagating the current packet.
CsmaDeviceRec()
Is net device enabled to TX/RX.
int32_t GetDeviceNum(Ptr< CsmaNetDevice > device)
CsmaChannel()
Create a CsmaChannel.
bool TransmitEnd()
Indicates that the net device has finished transmitting the packet over the channel.
bool IsBusy()
Indicates if the channel is busy.
#define NS_LOG_WARN(msg)
Use NS_LOG to output a message of level LOG_WARN.
hold objects of type ns3::DataRate
bool active
Pointer to the net device.
Time Seconds(double value)
Construct a Time in the indicated unit.
DataRate GetDataRate(void)
Get the assigned data rate of the channel.
Ptr< CsmaNetDevice > GetCsmaDevice(uint32_t i) const
#define NS_LOG_ERROR(msg)
Use NS_LOG to output a message of level LOG_ERROR.
Ptr< CsmaNetDevice > devicePtr
bool Reattach(uint32_t deviceId)
Reattach a previously detached net device to the channel.
a unique identifier for an interface.
TypeId SetParent(TypeId tid)
bool TransmitStart(Ptr< Packet > p, uint32_t srcId)
Start transmitting a packet over the channel.
static TypeId GetTypeId(void)