21 #include "csma-channel.h"
22 #include "csma-net-device.h"
23 #include "ns3/packet.h"
24 #include "ns3/simulator.h"
31 NS_OBJECT_ENSURE_REGISTERED (CsmaChannel);
34 CsmaChannel::GetTypeId (
void)
36 static TypeId tid = TypeId (
"ns3::CsmaChannel")
37 .SetParent<Channel> ()
38 .AddConstructor<CsmaChannel> ()
39 .AddAttribute (
"DataRate",
40 "The transmission data rate to be provided to devices connected to the channel",
41 DataRateValue (DataRate (0xffffffff)),
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)
356 devicePtr = deviceRec.devicePtr;
357 active = deviceRec.active;
smart pointer class similar to boost::intrusive_ptr
#define NS_LOG_FUNCTION(parameters)
void Receive(Ptr< Packet > p, Ptr< CsmaNetDevice > sender)
uint64_t GetUid(void) const
#define NS_ASSERT(condition)
uint32_t GetNumActDevices(void)
#define NS_LOG_COMPONENT_DEFINE(name)
Abstract Channel Base Class.
#define NS_LOG_FUNCTION_NOARGS()
static EventId Schedule(Time const &time, MEM mem_ptr, OBJ obj)
std::vector< CsmaDeviceRec > m_deviceList
Ptr< Packet > m_currentPkt
Class for representing data rates.
virtual ~CsmaChannel()
Destroy a CsmaChannel.
double GetSeconds(void) const
bool Detach(Ptr< CsmaNetDevice > device)
Detach a given netdevice from this channel.
virtual uint32_t GetNDevices(void) const
virtual Ptr< NetDevice > GetDevice(uint32_t i) const
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)
#define NS_LOG_LOGIC(msg)
Ptr< Packet > Copy(void) const
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. The channel is released and b...
CsmaDeviceRec()
Is net device enabled to TX/RX.
int32_t GetDeviceNum(Ptr< CsmaNetDevice > device)
CsmaChannel()
Create a CsmaChannel.
Time Seconds(double seconds)
create ns3::Time instances in units of seconds.
bool TransmitEnd()
Indicates that the net device has finished transmitting the packet over the channel.
bool IsBusy()
Indicates if the channel is busy. The channel will only accept new packets for transmission if it is ...
bool active
Pointer to the net device.
DataRate GetDataRate(void)
Ptr< CsmaNetDevice > GetCsmaDevice(uint32_t i) const
#define NS_LOG_ERROR(msg)
bool Reattach(uint32_t deviceId)
Reattach a previously detached net device to the channel.
bool TransmitStart(Ptr< Packet > p, uint32_t srcId)
Start transmitting a packet over the channel.