19 #include "point-to-point-channel.h"
20 #include "point-to-point-net-device.h"
21 #include "ns3/trace-source-accessor.h"
22 #include "ns3/packet.h"
23 #include "ns3/simulator.h"
30 NS_OBJECT_ENSURE_REGISTERED (PointToPointChannel);
33 PointToPointChannel::GetTypeId (
void)
35 static TypeId tid = TypeId (
"ns3::PointToPointChannel")
36 .SetParent<Channel> ()
37 .AddConstructor<PointToPointChannel> ()
38 .AddAttribute (
"Delay",
"Transmission delay through the channel",
40 MakeTimeAccessor (&PointToPointChannel::m_delay),
42 .AddTraceSource (
"TxRxPointToPoint",
43 "Trace source indicating transmission of packet from the PointToPointChannel, used by the Animation interface.",
65 NS_ASSERT_MSG (m_nDevices < N_DEVICES,
"Only two devices permitted");
68 m_link[m_nDevices++].m_src = device;
73 if (m_nDevices == N_DEVICES)
75 m_link[0].m_dst = m_link[1].m_src;
76 m_link[1].m_dst = m_link[0].m_src;
77 m_link[0].m_state = IDLE;
78 m_link[1].m_state = IDLE;
91 NS_ASSERT (m_link[0].m_state != INITIALIZING);
92 NS_ASSERT (m_link[1].m_state != INITIALIZING);
94 uint32_t wire = src == m_link[0].m_src ? 0 : 1;
98 m_link[wire].m_dst, p);
113 PointToPointChannel::GetPointToPointDevice (uint32_t i)
const
117 return m_link[i].m_src;
124 return GetPointToPointDevice (i);
128 PointToPointChannel::GetDelay (
void)
const
133 Ptr<PointToPointNetDevice>
134 PointToPointChannel::GetSource (uint32_t i)
const
136 return m_link[i].m_src;
139 Ptr<PointToPointNetDevice>
140 PointToPointChannel::GetDestination (uint32_t i)
const
142 return m_link[i].m_dst;
146 PointToPointChannel::IsInitialized (
void)
const
148 NS_ASSERT (m_link[0].m_state != INITIALIZING);
149 NS_ASSERT (m_link[1].m_state != INITIALIZING);
smart pointer class similar to boost::intrusive_ptr
#define NS_LOG_FUNCTION(parameters)
uint64_t GetUid(void) const
TracedCallback< Ptr< const Packet >, Ptr< NetDevice >, Ptr< NetDevice >, Time, Time > m_txrxPointToPoint
#define NS_ASSERT(condition)
#define NS_LOG_COMPONENT_DEFINE(name)
Abstract Channel Base Class.
#define NS_LOG_FUNCTION_NOARGS()
virtual uint32_t GetNDevices(void) const
Get number of devices on this channel.
void Attach(Ptr< PointToPointNetDevice > device)
Attach a given netdevice to this channel.
PointToPointChannel()
Create a PointToPointChannel.
static void ScheduleWithContext(uint32_t context, Time const &time, MEM mem_ptr, OBJ obj)
#define NS_LOG_LOGIC(msg)
Ptr< const TraceSourceAccessor > MakeTraceSourceAccessor(T a)
virtual Ptr< NetDevice > GetDevice(uint32_t i) const
#define NS_ASSERT_MSG(condition, message)
Time Seconds(double seconds)
create ns3::Time instances in units of seconds.
void Receive(Ptr< Packet > p)
virtual bool TransmitStart(Ptr< Packet > p, Ptr< PointToPointNetDevice > src, Time txTime)
Transmit a packet over this channel.