|
A Discrete-Event Network Simulator
|
API
|
Go to the documentation of this file.
23 #include "ns3/packet.h"
24 #include "ns3/simulator.h"
38 .SetGroupName (
"Csma")
40 .AddAttribute (
"DataRate",
41 "The transmission data rate to be provided to devices connected to the channel",
45 .AddAttribute (
"Delay",
"Transmission delay through the channel",
86 std::vector<CsmaDeviceRec>::iterator it;
89 if (it->devicePtr == device)
135 NS_LOG_WARN (
"CsmaChannel::Detach(): Device is already detached (" << deviceId <<
")");
143 NS_LOG_WARN (
"CsmaChannel::Detach(): Device is currently" <<
"transmitting (" << deviceId <<
")");
160 std::vector<CsmaDeviceRec>::iterator it;
163 if ((it->devicePtr == device) && (it->active))
180 NS_LOG_WARN (
"CsmaChannel::TransmitStart(): State is not IDLE");
186 NS_LOG_ERROR (
"CsmaChannel::TransmitStart(): Seclected source is not currently attached to network");
216 NS_LOG_ERROR (
"CsmaChannel::TransmitEnd(): Seclected source was detached before the end of the transmission");
225 std::vector<CsmaDeviceRec>::iterator it;
259 int numActDevices = 0;
260 std::vector<CsmaDeviceRec>::iterator it;
268 return numActDevices;
286 std::vector<CsmaDeviceRec>::iterator it;
290 if (it->devicePtr == device)
a unique identifier for an interface.
#define NS_LOG_COMPONENT_DEFINE(name)
Define a Log component with a specific name.
DataRate m_bps
The assigned data rate of the channel.
AttributeValue implementation for DataRate.
Time m_delay
The assigned speed-of-light delay of the channel.
#define NS_OBJECT_ENSURE_REGISTERED(type)
Register an Object subclass with the TypeId system.
#define NS_ASSERT(condition)
At runtime, in debugging builds, if this condition is not true, the program prints the source file,...
Ptr< const AttributeChecker > MakeTimeChecker(const Time min, const Time max)
Helper to make a Time checker with bounded range.
static void ScheduleWithContext(uint32_t context, Time const &delay, FUNC f, Ts &&... args)
Schedule an event with the given context.
Every class exported by the ns3 library is enclosed in the ns3 namespace.
Ptr< CsmaNetDevice > devicePtr
Pointer to the net device.
Ptr< const AttributeAccessor > MakeDataRateAccessor(T1 a1)
Create an AttributeAccessor for a class data member, or a lone class get functor or set method.
virtual Ptr< NetDevice > GetDevice(std::size_t i) const
#define NS_LOG_WARN(msg)
Use NS_LOG to output a message of level LOG_WARN.
WireState
Current state of the channel.
Ptr< CsmaNetDevice > GetCsmaDevice(std::size_t i) const
Ptr< Packet > m_currentPkt
The Packet that is currently being transmitted on the channel (or last packet to have been transmitte...
static TypeId GetTypeId(void)
Get the type ID.
TimeWithUnit As(const enum Unit unit=Time::AUTO) const
Attach a unit to a Time, to facilitate output in a specific unit.
static EventId Schedule(Time const &delay, FUNC f, Ts &&... args)
Schedule an event to expire after delay.
int32_t Attach(Ptr< CsmaNetDevice > device)
Attach a given netdevice to this channel.
std::vector< CsmaDeviceRec > m_deviceList
List of the net devices that have been or are currently connected to the channel.
TypeId SetParent(TypeId tid)
Set the parent TypeId.
CsmaChannel()
Create a CsmaChannel.
Smart pointer class similar to boost::intrusive_ptr.
Class for representing data rates.
bool IsBusy()
Indicates if the channel is busy.
@ IDLE
Channel is IDLE, no packet is being transmitted.
#define NS_LOG_INFO(msg)
Use NS_LOG to output a message of level LOG_INFO.
virtual std::size_t GetNDevices(void) const
bool active
Is net device enabled to TX/RX.
bool IsActive(uint32_t deviceId)
Indicates if a net device is currently attached or detached from the channel.
Simulation virtual time values and global simulation resolution.
void PropagationCompleteEvent()
Indicates that the channel has finished propagating the current packet.
int32_t GetDeviceNum(Ptr< CsmaNetDevice > device)
Time GetDelay(void)
Get the assigned speed-of-light delay of the channel.
#define NS_LOG_LOGIC(msg)
Use NS_LOG to output a message of level LOG_LOGIC.
#define NS_LOG_ERROR(msg)
Use NS_LOG to output a message of level LOG_ERROR.
#define NS_LOG_FUNCTION_NOARGS()
Output the name of the function.
@ TRANSMITTING
Channel is BUSY, a packet is being written by a net device.
void Receive(Ptr< Packet > p, Ptr< CsmaNetDevice > sender)
Receive a packet from a connected CsmaChannel.
Time Seconds(double value)
Construct a Time in the indicated unit.
Ptr< Packet > Copy(void) const
performs a COW copy of the packet.
Abstract Channel Base Class.
bool TransmitStart(Ptr< const Packet > p, uint32_t srcId)
Start transmitting a packet over the channel.
WireState m_state
Current state of the channel.
AttributeValue implementation for Time.
#define NS_LOG_FUNCTION(parameters)
If log level LOG_FUNCTION is enabled, this macro will output all input parameters separated by ",...
virtual ~CsmaChannel()
Destroy a CsmaChannel.
uint32_t m_currentSrc
Device Id of the source that is currently transmitting on the channel.
DataRate GetDataRate(void)
Get the assigned data rate of the channel.
@ PROPAGATING
Channel is BUSY, packet is propagating to all attached net devices.
bool Detach(Ptr< CsmaNetDevice > device)
Detach a given netdevice from this channel.
bool TransmitEnd()
Indicates that the net device has finished transmitting the packet over the channel.
Ptr< const AttributeChecker > MakeDataRateChecker(void)
Ptr< const AttributeAccessor > MakeTimeAccessor(T1 a1)
Create an AttributeAccessor for a class data member, or a lone class get functor or set method.
uint32_t GetNumActDevices(void)
uint64_t GetUid(void) const
Returns the packet's Uid.
bool Reattach(uint32_t deviceId)
Reattach a previously detached net device to the channel.