point-to-point cleanup
This commit is contained in:
@@ -71,13 +71,13 @@ main (int argc, char *argv[])
|
||||
// We create the channels first without any IP addressing information
|
||||
NS_LOG_INFO ("Create channels.");
|
||||
PointToPointHelper p2p;
|
||||
p2p.SetChannelParameter ("BitRate", StringValue ("5Mbps"));
|
||||
p2p.SetDeviceParameter ("DataRate", StringValue ("5Mbps"));
|
||||
p2p.SetChannelParameter ("Delay", StringValue ("2ms"));
|
||||
NetDeviceContainer d0d2 = p2p.Install (n0n2);
|
||||
|
||||
NetDeviceContainer d1d2 = p2p.Install (n1n2);
|
||||
|
||||
p2p.SetChannelParameter ("BitRate", StringValue ("1500kbps"));
|
||||
p2p.SetDeviceParameter ("DataRate", StringValue ("1500kbps"));
|
||||
p2p.SetChannelParameter ("Delay", StringValue ("10ms"));
|
||||
NetDeviceContainer d5d6 = p2p.Install (n5n6);
|
||||
|
||||
|
||||
@@ -97,13 +97,13 @@ main (int argc, char *argv[])
|
||||
// We create the channels first without any IP addressing information
|
||||
NS_LOG_INFO ("Create channels.");
|
||||
PointToPointHelper p2p;
|
||||
p2p.SetChannelParameter ("BitRate", StringValue ("5Mbps"));
|
||||
p2p.SetDeviceParameter ("DataRate", StringValue ("5Mbps"));
|
||||
p2p.SetChannelParameter ("Delay", StringValue ("2ms"));
|
||||
NetDeviceContainer d0d2 = p2p.Install (n0n2);
|
||||
|
||||
NetDeviceContainer d1d2 = p2p.Install (n1n2);
|
||||
|
||||
p2p.SetChannelParameter ("BitRate", StringValue ("1500kbps"));
|
||||
p2p.SetDeviceParameter ("DataRate", StringValue ("1500kbps"));
|
||||
p2p.SetChannelParameter ("Delay", StringValue ("10ms"));
|
||||
NetDeviceContainer d3d2 = p2p.Install (n3n2);
|
||||
|
||||
|
||||
@@ -92,13 +92,13 @@ main (int argc, char *argv[])
|
||||
// We create the channels first without any IP addressing information
|
||||
NS_LOG_INFO ("Create channels.");
|
||||
PointToPointHelper p2p;
|
||||
p2p.SetChannelParameter ("BitRate", DataRateValue (DataRate (5000000)));
|
||||
p2p.SetDeviceParameter ("DataRate", DataRateValue (DataRate (5000000)));
|
||||
p2p.SetChannelParameter ("Delay", TimeValue (MilliSeconds (2)));
|
||||
NetDeviceContainer d0d2 = p2p.Install (n0n2);
|
||||
|
||||
NetDeviceContainer d1d2 = p2p.Install (n1n2);
|
||||
|
||||
p2p.SetChannelParameter ("BitRate", DataRateValue (DataRate (1500000)));
|
||||
p2p.SetDeviceParameter ("DataRate", DataRateValue (DataRate (1500000)));
|
||||
p2p.SetChannelParameter ("Delay", TimeValue (MilliSeconds (10)));
|
||||
NetDeviceContainer d3d2 = p2p.Install (n3n2);
|
||||
|
||||
|
||||
@@ -92,13 +92,13 @@ main (int argc, char *argv[])
|
||||
// We create the channels first without any IP addressing information
|
||||
NS_LOG_INFO ("Create channels.");
|
||||
PointToPointHelper p2p;
|
||||
p2p.SetChannelParameter ("BitRate", StringValue ("5Mbps"));
|
||||
p2p.SetDeviceParameter ("DataRate", StringValue ("5Mbps"));
|
||||
p2p.SetChannelParameter ("Delay", StringValue ("2ms"));
|
||||
NetDeviceContainer d0d2 = p2p.Install (n0n2);
|
||||
|
||||
NetDeviceContainer d1d2 = p2p.Install (n1n2);
|
||||
|
||||
p2p.SetChannelParameter ("BitRate", StringValue ("1500kbps"));
|
||||
p2p.SetDeviceParameter ("DataRate", StringValue ("1500kbps"));
|
||||
p2p.SetChannelParameter ("Delay", StringValue ("10ms"));
|
||||
NetDeviceContainer d3d2 = p2p.Install (n3n2);
|
||||
|
||||
|
||||
@@ -93,11 +93,11 @@ main (int argc, char *argv[])
|
||||
// We create the channels first without any IP addressing information
|
||||
NS_LOG_INFO ("Create channels.");
|
||||
PointToPointHelper p2p;
|
||||
p2p.SetChannelParameter ("BitRate", StringValue ("5Mbps"));
|
||||
p2p.SetDeviceParameter ("DataRate", StringValue ("5Mbps"));
|
||||
p2p.SetChannelParameter ("Delay", StringValue ("2ms"));
|
||||
NetDeviceContainer nd02 = p2p.Install (n02);
|
||||
NetDeviceContainer nd12 = p2p.Install (n12);
|
||||
p2p.SetChannelParameter ("BitRate", StringValue ("1500kbps"));
|
||||
p2p.SetDeviceParameter ("DataRate", StringValue ("1500kbps"));
|
||||
p2p.SetChannelParameter ("Delay", StringValue ("10ms"));
|
||||
NetDeviceContainer nd32 = p2p.Install (n32);
|
||||
NetDeviceContainer nd34 = p2p.Install (n34);
|
||||
|
||||
@@ -137,7 +137,7 @@ int main (int argc, char *argv[])
|
||||
|
||||
// We create the channels first without any IP addressing information
|
||||
PointToPointHelper p2p;
|
||||
p2p.SetChannelParameter ("BitRate", DataRateValue (DataRate(10000000)));
|
||||
p2p.SetDeviceParameter ("DataRate", DataRateValue (DataRate(10000000)));
|
||||
p2p.SetChannelParameter ("Delay", TimeValue (MilliSeconds(10)));
|
||||
NetDeviceContainer dev0 = p2p.Install (c0);
|
||||
NetDeviceContainer dev1 = p2p.Install (c1);
|
||||
|
||||
@@ -34,10 +34,6 @@ PointToPointChannel::GetTypeId (void)
|
||||
static TypeId tid = TypeId ("ns3::PointToPointChannel")
|
||||
.SetParent<Channel> ()
|
||||
.AddConstructor<PointToPointChannel> ()
|
||||
.AddAttribute ("BitRate", "The maximum bitrate of the channel",
|
||||
DataRateValue (DataRate (0xffffffff)),
|
||||
MakeDataRateAccessor (&PointToPointChannel::m_bps),
|
||||
MakeDataRateChecker ())
|
||||
.AddAttribute ("Delay", "Transmission delay through the channel",
|
||||
TimeValue (Seconds (0)),
|
||||
MakeTimeAccessor (&PointToPointChannel::m_delay),
|
||||
@@ -52,7 +48,8 @@ PointToPointChannel::GetTypeId (void)
|
||||
PointToPointChannel::PointToPointChannel()
|
||||
:
|
||||
Channel ("PointToPoint Channel"),
|
||||
m_nDevices(0)
|
||||
m_delay (Seconds (0.)),
|
||||
m_nDevices (0)
|
||||
{
|
||||
NS_LOG_FUNCTION_NOARGS ();
|
||||
}
|
||||
@@ -79,9 +76,10 @@ PointToPointChannel::Attach(Ptr<PointToPointNetDevice> device)
|
||||
}
|
||||
|
||||
bool
|
||||
PointToPointChannel::TransmitStart(Ptr<Packet> p,
|
||||
Ptr<PointToPointNetDevice> src,
|
||||
const Time& txTime)
|
||||
PointToPointChannel::TransmitStart(
|
||||
Ptr<Packet> p,
|
||||
Ptr<PointToPointNetDevice> src,
|
||||
Time txTime)
|
||||
{
|
||||
NS_LOG_FUNCTION (this << p << src);
|
||||
NS_LOG_LOGIC ("UID is " << p->GetUid () << ")");
|
||||
@@ -91,12 +89,8 @@ PointToPointChannel::TransmitStart(Ptr<Packet> p,
|
||||
|
||||
uint32_t wire = src == m_link[0].m_src ? 0 : 1;
|
||||
|
||||
// Here we schedule the packet receive event at the receiver,
|
||||
// which simplifies this model quite a bit. The channel just
|
||||
// adds the propagation delay time
|
||||
Simulator::Schedule (txTime + m_delay,
|
||||
&PointToPointNetDevice::Receive,
|
||||
m_link[wire].m_dst, p);
|
||||
Simulator::Schedule (txTime + m_delay, &PointToPointNetDevice::Receive,
|
||||
m_link[wire].m_dst, p);
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -115,20 +109,6 @@ PointToPointChannel::GetPointToPointDevice (uint32_t i) const
|
||||
return m_link[i].m_src;
|
||||
}
|
||||
|
||||
const DataRate&
|
||||
PointToPointChannel::GetDataRate (void)
|
||||
{
|
||||
NS_LOG_FUNCTION_NOARGS ();
|
||||
return m_bps;
|
||||
}
|
||||
|
||||
const Time&
|
||||
PointToPointChannel::GetDelay (void)
|
||||
{
|
||||
NS_LOG_FUNCTION_NOARGS ();
|
||||
return m_delay;
|
||||
}
|
||||
|
||||
Ptr<NetDevice>
|
||||
PointToPointChannel::GetDevice (uint32_t i) const
|
||||
{
|
||||
@@ -136,5 +116,4 @@ PointToPointChannel::GetDevice (uint32_t i) const
|
||||
return GetPointToPointDevice (i);
|
||||
}
|
||||
|
||||
|
||||
} // namespace ns3
|
||||
|
||||
@@ -36,14 +36,7 @@ class Packet;
|
||||
* This class represents a very simple point to point channel. Think full
|
||||
* duplex RS-232 or RS-422 with null modem and no handshaking. There is no
|
||||
* multi-drop capability on this channel -- there can be a maximum of two
|
||||
* point-to-point net devices connected. Once we start talking about multi-
|
||||
* drop, or CSMA, or some other sharing mechanism, things begin getting
|
||||
* complicated quickly. Rather than invent some ad-hoc mechanism, we just
|
||||
* Keep It Simple everywhere.
|
||||
*
|
||||
* When the channel is instaniated, the constructor takes parameters for
|
||||
* a single speed, in bits per second, and a speed-of-light delay time as a
|
||||
* Time object. Both directions use the same speed and delay time.
|
||||
* point-to-point net devices connected.
|
||||
*
|
||||
* There are two "wires" in the channel. The first device connected gets the
|
||||
* [0] wire to transmit on. The second device gets the [1] wire. There is a
|
||||
@@ -58,7 +51,7 @@ public:
|
||||
* \brief Create a PointToPointChannel
|
||||
*
|
||||
* By default, you get a channel with the name "PointToPoint Channel" that
|
||||
* has an "infitely" fast transmission speed and zero delay.
|
||||
* has zero transmission delay.
|
||||
*/
|
||||
PointToPointChannel ();
|
||||
|
||||
@@ -75,38 +68,32 @@ public:
|
||||
* \param txTime Transmit time to apply
|
||||
*/
|
||||
bool TransmitStart (Ptr<Packet> p, Ptr<PointToPointNetDevice> src,
|
||||
const Time& txTime);
|
||||
Time txTime);
|
||||
|
||||
/**
|
||||
* \brief Get number of devices on this channel
|
||||
* \returns number of devices on this channel
|
||||
*/
|
||||
virtual uint32_t GetNDevices (void) const;
|
||||
|
||||
/*
|
||||
* \brief Get PointToPointNetDevice corresponding to index i on this channel
|
||||
* \param i Index number of the device requested
|
||||
* \returns Ptr to PointToPointNetDevice requested
|
||||
*/
|
||||
Ptr<PointToPointNetDevice> GetPointToPointDevice (uint32_t i) const;
|
||||
|
||||
/*
|
||||
* \brief Get NetDevice corresponding to index i on this channel
|
||||
* \param i Index number of the device requested
|
||||
* \returns Ptr to NetDevice requested
|
||||
*/
|
||||
virtual Ptr<NetDevice> GetDevice (uint32_t i) const;
|
||||
/*
|
||||
* \brief Get reference to DataRate for this channel
|
||||
* \returns const reference to underlying DataRate object
|
||||
*/
|
||||
const DataRate& GetDataRate (void);
|
||||
/*
|
||||
* \brief Get reference to Time object storing the delay on this channel
|
||||
* \returns const reference to underlying Time object
|
||||
*/
|
||||
const Time& GetDelay (void);
|
||||
|
||||
private:
|
||||
|
||||
// Each point to point link has exactly two net devices
|
||||
static const int N_DEVICES = 2;
|
||||
|
||||
|
||||
DataRate m_bps;
|
||||
Time m_delay;
|
||||
int32_t m_nDevices;
|
||||
|
||||
@@ -122,7 +109,7 @@ private:
|
||||
{
|
||||
public:
|
||||
Link() : m_state (INITIALIZING), m_src (0), m_dst (0) {}
|
||||
WireState m_state;
|
||||
WireState m_state;
|
||||
Ptr<PointToPointNetDevice> m_src;
|
||||
Ptr<PointToPointNetDevice> m_dst;
|
||||
};
|
||||
|
||||
@@ -45,7 +45,7 @@ PointToPointNetDevice::GetTypeId (void)
|
||||
MakeMac48AddressAccessor (&PointToPointNetDevice::m_address),
|
||||
MakeMac48AddressChecker ())
|
||||
.AddAttribute ("DataRate", "The default data rate for point to point links",
|
||||
DataRateValue (DataRate ("10Mb/s")),
|
||||
DataRateValue (DataRate ("32768b/s")),
|
||||
MakeDataRateAccessor (&PointToPointNetDevice::m_bps),
|
||||
MakeDataRateChecker ())
|
||||
.AddAttribute ("ReceiveErrorModel", "XXX",
|
||||
@@ -82,15 +82,10 @@ PointToPointNetDevice::PointToPointNetDevice ()
|
||||
}
|
||||
|
||||
PointToPointNetDevice::~PointToPointNetDevice ()
|
||||
{}
|
||||
|
||||
void
|
||||
PointToPointNetDevice::SetAddress (Mac48Address self)
|
||||
{
|
||||
m_address = self;
|
||||
}
|
||||
|
||||
void
|
||||
void
|
||||
PointToPointNetDevice::AddHeader(Ptr<Packet> p, uint16_t protocolNumber)
|
||||
{
|
||||
NS_LOG_FUNCTION_NOARGS ();
|
||||
@@ -100,7 +95,7 @@ PointToPointNetDevice::AddHeader(Ptr<Packet> p, uint16_t protocolNumber)
|
||||
p->AddHeader (ppp);
|
||||
}
|
||||
|
||||
bool
|
||||
bool
|
||||
PointToPointNetDevice::ProcessHeader(Ptr<Packet> p, uint16_t& param)
|
||||
{
|
||||
NS_LOG_FUNCTION_NOARGS ();
|
||||
@@ -110,7 +105,8 @@ PointToPointNetDevice::ProcessHeader(Ptr<Packet> p, uint16_t& param)
|
||||
return true;
|
||||
}
|
||||
|
||||
void PointToPointNetDevice::DoDispose()
|
||||
void
|
||||
PointToPointNetDevice::DoDispose()
|
||||
{
|
||||
NS_LOG_FUNCTION_NOARGS ();
|
||||
m_node = 0;
|
||||
@@ -119,22 +115,21 @@ void PointToPointNetDevice::DoDispose()
|
||||
NetDevice::DoDispose ();
|
||||
}
|
||||
|
||||
void PointToPointNetDevice::SetDataRate(const DataRate& bps)
|
||||
void
|
||||
PointToPointNetDevice::SetDataRate(DataRate bps)
|
||||
{
|
||||
NS_LOG_FUNCTION_NOARGS ();
|
||||
if (!m_channel || bps <= m_channel->GetDataRate ())
|
||||
{
|
||||
m_bps = bps;
|
||||
}
|
||||
m_bps = bps;
|
||||
}
|
||||
|
||||
void PointToPointNetDevice::SetInterframeGap(const Time& t)
|
||||
void
|
||||
PointToPointNetDevice::SetInterframeGap(Time t)
|
||||
{
|
||||
NS_LOG_FUNCTION_NOARGS ();
|
||||
m_tInterframeGap = t;
|
||||
}
|
||||
|
||||
bool
|
||||
bool
|
||||
PointToPointNetDevice::TransmitStart (Ptr<Packet> p)
|
||||
{
|
||||
NS_LOG_FUNCTION (this << p);
|
||||
@@ -151,33 +146,40 @@ PointToPointNetDevice::TransmitStart (Ptr<Packet> p)
|
||||
|
||||
NS_LOG_LOGIC ("Schedule TransmitCompleteEvent in " <<
|
||||
txCompleteTime.GetSeconds () << "sec");
|
||||
// Schedule the tx complete event
|
||||
|
||||
Simulator::Schedule (txCompleteTime,
|
||||
&PointToPointNetDevice::TransmitComplete,
|
||||
this);
|
||||
&PointToPointNetDevice::TransmitComplete, this);
|
||||
|
||||
return m_channel->TransmitStart(p, this, txTime);
|
||||
}
|
||||
|
||||
void PointToPointNetDevice::TransmitComplete (void)
|
||||
void
|
||||
PointToPointNetDevice::TransmitComplete (void)
|
||||
{
|
||||
NS_LOG_FUNCTION_NOARGS ();
|
||||
//
|
||||
// This function is called to finish the process of transmitting a packet.
|
||||
// We need to tell the channel that we've stopped wiggling the wire and
|
||||
// get the next packet from the queue. If the queue is empty, we are
|
||||
// done, otherwise transmit the next packet.
|
||||
// This function is called to when we're all done transmitting a packet.
|
||||
// We try and pull another packet off of the transmit queue. If the queue
|
||||
// is empty, we are done, otherwise we need to start transmitting the
|
||||
// next packet.
|
||||
//
|
||||
NS_ASSERT_MSG(m_txMachineState == BUSY, "Must be BUSY if transmitting");
|
||||
m_txMachineState = READY;
|
||||
Ptr<Packet> p = m_queue->Dequeue ();
|
||||
if (p == 0)
|
||||
{
|
||||
return; // Nothing to do at this point
|
||||
//
|
||||
// No packet was on the queue, so we just exit.
|
||||
//
|
||||
return;
|
||||
}
|
||||
//
|
||||
// Got another packet off of the queue, so start the transmit process agin.
|
||||
//
|
||||
TransmitStart(p);
|
||||
}
|
||||
|
||||
bool
|
||||
bool
|
||||
PointToPointNetDevice::Attach (Ptr<PointToPointChannel> ch)
|
||||
{
|
||||
NS_LOG_FUNCTION (this << &ch);
|
||||
@@ -185,64 +187,64 @@ PointToPointNetDevice::Attach (Ptr<PointToPointChannel> ch)
|
||||
m_channel = ch;
|
||||
|
||||
m_channel->Attach(this);
|
||||
m_bps = m_channel->GetDataRate ();
|
||||
// GFR Comment. Below is definitely wrong. Interframe gap
|
||||
// is unrelated to channel delay.
|
||||
// -- unlesss you want to introduce a default gap which is there to avoid
|
||||
// parts of multiple packets flowing on the "wire" at the same time.
|
||||
//m_tInterframeGap = m_channel->GetDelay ();
|
||||
|
||||
/*
|
||||
* For now, this device is up whenever a channel is attached to it.
|
||||
* In fact, it should become up only when the second device
|
||||
* is attached to the channel. So, there should be a way for
|
||||
* a PointToPointChannel to notify both of its attached devices
|
||||
* that the channel is 'complete', hence that the devices are
|
||||
* up, hence that they can call NotifyLinkUp.
|
||||
*/
|
||||
//
|
||||
// This device is up whenever it is attached to a channel. A better plan
|
||||
// would be to have the link come up when both devices are attached, but this
|
||||
// is not done for now.
|
||||
//
|
||||
NotifyLinkUp ();
|
||||
return true;
|
||||
}
|
||||
|
||||
void PointToPointNetDevice::SetQueue (Ptr<Queue> q)
|
||||
void
|
||||
PointToPointNetDevice::SetQueue (Ptr<Queue> q)
|
||||
{
|
||||
NS_LOG_FUNCTION (this << q);
|
||||
|
||||
m_queue = q;
|
||||
}
|
||||
|
||||
void PointToPointNetDevice::SetReceiveErrorModel (Ptr<ErrorModel> em)
|
||||
void
|
||||
PointToPointNetDevice::SetReceiveErrorModel (Ptr<ErrorModel> em)
|
||||
{
|
||||
NS_LOG_FUNCTION ("(" << em << ")");
|
||||
|
||||
m_receiveErrorModel = em;
|
||||
}
|
||||
|
||||
void PointToPointNetDevice::Receive (Ptr<Packet> packet)
|
||||
void
|
||||
PointToPointNetDevice::Receive (Ptr<Packet> packet)
|
||||
{
|
||||
NS_LOG_FUNCTION (this << packet);
|
||||
uint16_t protocol = 0;
|
||||
|
||||
if (m_receiveErrorModel && m_receiveErrorModel->IsCorrupt (packet) )
|
||||
{
|
||||
//
|
||||
// If we have an error model and it indicates that it is time to lose a
|
||||
// corrupted packet, don't forward this packet up, let it go.
|
||||
//
|
||||
m_dropTrace (packet);
|
||||
// Do not forward up; let this packet go
|
||||
}
|
||||
else
|
||||
{
|
||||
//
|
||||
// Hit the receive trace hook, strip off the point-to-point protocol header
|
||||
// and forward this packet up the protocol stack.
|
||||
//
|
||||
m_rxTrace (packet);
|
||||
ProcessHeader(packet, protocol);
|
||||
m_rxCallback (this, packet, protocol, GetBroadcast ());
|
||||
}
|
||||
}
|
||||
|
||||
Ptr<Queue> PointToPointNetDevice::GetQueue(void) const
|
||||
Ptr<Queue>
|
||||
PointToPointNetDevice::GetQueue(void) const
|
||||
{
|
||||
NS_LOG_FUNCTION_NOARGS ();
|
||||
return m_queue;
|
||||
}
|
||||
|
||||
void
|
||||
void
|
||||
PointToPointNetDevice::NotifyLinkUp (void)
|
||||
{
|
||||
m_linkUp = true;
|
||||
@@ -252,110 +254,167 @@ PointToPointNetDevice::NotifyLinkUp (void)
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
void
|
||||
PointToPointNetDevice::SetName(const std::string name)
|
||||
{
|
||||
m_name = name;
|
||||
}
|
||||
std::string
|
||||
|
||||
std::string
|
||||
PointToPointNetDevice::GetName(void) const
|
||||
{
|
||||
return m_name;
|
||||
}
|
||||
void
|
||||
|
||||
void
|
||||
PointToPointNetDevice::SetIfIndex(const uint32_t index)
|
||||
{
|
||||
m_ifIndex = index;
|
||||
}
|
||||
uint32_t
|
||||
|
||||
uint32_t
|
||||
PointToPointNetDevice::GetIfIndex(void) const
|
||||
{
|
||||
return m_ifIndex;
|
||||
}
|
||||
Ptr<Channel>
|
||||
|
||||
Ptr<Channel>
|
||||
PointToPointNetDevice::GetChannel (void) const
|
||||
{
|
||||
return m_channel;
|
||||
}
|
||||
Address
|
||||
|
||||
//
|
||||
// This is a point-to-point device, so we really don't need any kind of address
|
||||
// information. However, the base class NetDevice wants us to define the
|
||||
// methods to get and set the address. Rather than be rude and assert, we let
|
||||
// clients get and set the address, but simply ignore them.
|
||||
void
|
||||
PointToPointNetDevice::SetAddress (Mac48Address addr)
|
||||
{
|
||||
m_address = addr;
|
||||
}
|
||||
|
||||
Address
|
||||
PointToPointNetDevice::GetAddress (void) const
|
||||
{
|
||||
return m_address;
|
||||
}
|
||||
bool
|
||||
|
||||
bool
|
||||
PointToPointNetDevice::SetMtu (const uint16_t mtu)
|
||||
{
|
||||
m_mtu = mtu;
|
||||
return true;
|
||||
}
|
||||
uint16_t
|
||||
|
||||
uint16_t
|
||||
PointToPointNetDevice::GetMtu (void) const
|
||||
{
|
||||
return m_mtu;
|
||||
}
|
||||
bool
|
||||
|
||||
bool
|
||||
PointToPointNetDevice::IsLinkUp (void) const
|
||||
{
|
||||
return m_linkUp;
|
||||
}
|
||||
void
|
||||
|
||||
void
|
||||
PointToPointNetDevice::SetLinkChangeCallback (Callback<void> callback)
|
||||
{
|
||||
m_linkChangeCallback = callback;
|
||||
}
|
||||
bool
|
||||
|
||||
//
|
||||
// This is a point-to-point device, so every transmission is a broadcast to
|
||||
// all of the devices on the network.
|
||||
//
|
||||
bool
|
||||
PointToPointNetDevice::IsBroadcast (void) const
|
||||
{
|
||||
return true;
|
||||
}
|
||||
Address
|
||||
|
||||
//
|
||||
// We don't really need any addressing information since this is a
|
||||
// point-to-point device. The base class NetDevice wants us to return a
|
||||
// broadcast address, so we make up something reasonable.
|
||||
//
|
||||
Address
|
||||
PointToPointNetDevice::GetBroadcast (void) const
|
||||
{
|
||||
return Mac48Address ("ff:ff:ff:ff:ff:ff");
|
||||
}
|
||||
bool
|
||||
|
||||
//
|
||||
// We don't deal with multicast here. It doesn't make sense to include some
|
||||
// of the one destinations on the network but exclude some of the others.
|
||||
bool
|
||||
PointToPointNetDevice::IsMulticast (void) const
|
||||
{
|
||||
return false;
|
||||
}
|
||||
Address
|
||||
|
||||
//
|
||||
// Since we return false in the IsMulticast call, calls to other multicast
|
||||
// related methods returns are undefined according to the base class. So we
|
||||
// can freely make something up, which is the base of the MAC multicast
|
||||
// address space.
|
||||
//
|
||||
Address
|
||||
PointToPointNetDevice::GetMulticast (void) const
|
||||
{
|
||||
return Mac48Address ("01:00:5e:00:00:00");
|
||||
}
|
||||
Address
|
||||
|
||||
Address
|
||||
PointToPointNetDevice::MakeMulticastAddress (Ipv4Address multicastGroup) const
|
||||
{
|
||||
return Mac48Address ("01:00:5e:00:00:00");
|
||||
}
|
||||
bool
|
||||
|
||||
bool
|
||||
PointToPointNetDevice::IsPointToPoint (void) const
|
||||
{
|
||||
return true;
|
||||
}
|
||||
bool
|
||||
PointToPointNetDevice::Send(Ptr<Packet> packet, const Address& dest, uint16_t protocolNumber)
|
||||
|
||||
bool
|
||||
PointToPointNetDevice::Send(
|
||||
Ptr<Packet> packet,
|
||||
const Address &dest,
|
||||
uint16_t protocolNumber)
|
||||
{
|
||||
NS_LOG_FUNCTION_NOARGS ();
|
||||
NS_LOG_LOGIC ("p=" << packet << ", dest=" << &dest);
|
||||
NS_LOG_LOGIC ("UID is " << packet->GetUid ());
|
||||
|
||||
// GFR Comment. Why is this an assertion? Can't a link legitimately
|
||||
// "go down" during the simulation? Shouldn't we just wait for it
|
||||
// to come back up?
|
||||
NS_ASSERT (IsLinkUp ());
|
||||
//
|
||||
// If IsLinkUp() is false it means there is no channel to send any packet
|
||||
// over so we just return an error.
|
||||
//
|
||||
if (IsLinkUp () == false)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
//
|
||||
// Stick a point to point protocol header on the packet in preparation for
|
||||
// shoving it out the door.
|
||||
//
|
||||
AddHeader(packet, protocolNumber);
|
||||
|
||||
//
|
||||
// This class simulates a point to point device. In the case of a serial
|
||||
// link, this means that we're simulating something like a UART.
|
||||
//
|
||||
//
|
||||
// If there's a transmission in progress, we enque the packet for later
|
||||
// transmission; otherwise we send it now.
|
||||
//
|
||||
if (m_txMachineState == READY)
|
||||
{
|
||||
// We still enqueue and dequeue it to hit the tracing hooks
|
||||
//
|
||||
// Even if the transmitter is immediately available, we still enqueue and
|
||||
// dequeue the packet to hit the tracing hooks.
|
||||
//
|
||||
m_queue->Enqueue (packet);
|
||||
packet = m_queue->Dequeue ();
|
||||
return TransmitStart (packet);
|
||||
@@ -365,22 +424,26 @@ PointToPointNetDevice::Send(Ptr<Packet> packet, const Address& dest, uint16_t pr
|
||||
return m_queue->Enqueue(packet);
|
||||
}
|
||||
}
|
||||
Ptr<Node>
|
||||
|
||||
Ptr<Node>
|
||||
PointToPointNetDevice::GetNode (void) const
|
||||
{
|
||||
return m_node;
|
||||
}
|
||||
void
|
||||
|
||||
void
|
||||
PointToPointNetDevice::SetNode (Ptr<Node> node)
|
||||
{
|
||||
m_node = node;
|
||||
}
|
||||
bool
|
||||
|
||||
bool
|
||||
PointToPointNetDevice::NeedsArp (void) const
|
||||
{
|
||||
return false;
|
||||
}
|
||||
void
|
||||
|
||||
void
|
||||
PointToPointNetDevice::SetReceiveCallback (NetDevice::ReceiveCallback cb)
|
||||
{
|
||||
m_rxCallback = cb;
|
||||
|
||||
@@ -60,16 +60,16 @@ public:
|
||||
* This is the constructor for the PointToPointNetDevice. It takes as a
|
||||
* parameter a pointer to the Node to which this device is connected,
|
||||
* as well as an optional DataRate object.
|
||||
*
|
||||
* @see PointToPointTopology::AddPointToPointLink ()
|
||||
*/
|
||||
PointToPointNetDevice ();
|
||||
|
||||
/**
|
||||
* Destroy a PointToPointNetDevice
|
||||
*
|
||||
* This is the destructor for the PointToPointNetDevice.
|
||||
*/
|
||||
virtual ~PointToPointNetDevice ();
|
||||
|
||||
/**
|
||||
* Set the Data Rate used for transmission of packets. The data rate is
|
||||
* set in the Attach () method from the corresponding field in the channel
|
||||
@@ -78,48 +78,35 @@ public:
|
||||
* @see Attach ()
|
||||
* @param bps the data rate at which this object operates
|
||||
*/
|
||||
void SetDataRate (const DataRate& bps);
|
||||
void SetDataRate (DataRate bps);
|
||||
|
||||
/**
|
||||
* Set the inteframe gap used to separate packets. The interframe gap
|
||||
* defines the minimum space required between packets sent by this device.
|
||||
* It is usually set in the Attach () method based on the speed of light
|
||||
* delay of the channel to which the device is attached. It can be
|
||||
* overridden using this method if desired.
|
||||
*
|
||||
* @see Attach ()
|
||||
* @param t the interframe gap time
|
||||
*/
|
||||
void SetInterframeGap (const Time& t);
|
||||
void SetInterframeGap (Time t);
|
||||
|
||||
/**
|
||||
* Attach the device to a channel.
|
||||
*
|
||||
* The PointToPointTopology object creates a PointToPointChannel and two
|
||||
* PointtoPointNetDevices. In order to introduce these components to each
|
||||
* other, the topology object calls Attach () on each PointToPointNetDevice.
|
||||
* Inside this method, the Net Device calls out to the PointToPointChannel
|
||||
* to introduce itself.
|
||||
*
|
||||
* @see PointToPointTopology::AddPointToPointLink ()
|
||||
* @see SetDataRate ()
|
||||
* @see SetInterframeGap ()
|
||||
* @param ch a pointer to the channel to which this object is being attached.
|
||||
* @param ch Ptr to the channel to which this object is being attached.
|
||||
*/
|
||||
bool Attach (Ptr<PointToPointChannel> ch);
|
||||
|
||||
/**
|
||||
* Attach a queue to the PointToPointNetDevice.
|
||||
*
|
||||
* The PointToPointNetDevice "owns" a queue. This queue is created by the
|
||||
* PointToPointTopology object and implements a queueing method such as
|
||||
* DropTail or RED. The PointToPointNetDevice assumes ownership of this
|
||||
* queue and must delete it when the device is destroyed.
|
||||
* The PointToPointNetDevice "owns" a queue that implements a queueing
|
||||
* method such as DropTail or RED.
|
||||
*
|
||||
* @see PointToPointTopology::AddPointToPointLink ()
|
||||
* @see Queue
|
||||
* @see DropTailQueue
|
||||
* @param queue a pointer to the queue for which object is assuming
|
||||
* ownership.
|
||||
* @param queue Ptr to the new queue.
|
||||
*/
|
||||
void SetQueue (Ptr<Queue> queue);
|
||||
|
||||
/**
|
||||
* Attach a receive ErrorModel to the PointToPointNetDevice.
|
||||
*
|
||||
@@ -127,9 +114,10 @@ public:
|
||||
* the packet receive chain.
|
||||
*
|
||||
* @see ErrorModel
|
||||
* @param em a pointer to the ErrorModel
|
||||
* @param em Ptr to the ErrorModel.
|
||||
*/
|
||||
void SetReceiveErrorModel(Ptr<ErrorModel> em);
|
||||
|
||||
/**
|
||||
* Receive a packet from a connected PointToPointChannel.
|
||||
*
|
||||
@@ -139,46 +127,67 @@ public:
|
||||
* arrived at the device.
|
||||
*
|
||||
* @see PointToPointChannel
|
||||
* @param p a reference to the received packet
|
||||
* @param p Ptr to the received packet.
|
||||
*/
|
||||
void Receive (Ptr<Packet> p);
|
||||
|
||||
void SetAddress (Mac48Address self);
|
||||
/**
|
||||
* Assign a MAC address to this device.
|
||||
*
|
||||
* @see Mac48Address
|
||||
* @param addr The new address.
|
||||
*/
|
||||
void SetAddress (Mac48Address addr);
|
||||
|
||||
// inherited from NetDevice base class.
|
||||
//
|
||||
// Pure virtual methods inherited from NetDevice we must implement.
|
||||
//
|
||||
virtual void SetName(const std::string name);
|
||||
virtual std::string GetName(void) const;
|
||||
|
||||
virtual void SetIfIndex(const uint32_t index);
|
||||
virtual uint32_t GetIfIndex(void) const;
|
||||
|
||||
virtual Ptr<Channel> GetChannel (void) const;
|
||||
virtual Address GetAddress (void) const;
|
||||
|
||||
virtual bool SetMtu (const uint16_t mtu);
|
||||
virtual uint16_t GetMtu (void) const;
|
||||
|
||||
virtual bool IsLinkUp (void) const;
|
||||
|
||||
virtual void SetLinkChangeCallback (Callback<void> callback);
|
||||
|
||||
virtual bool IsBroadcast (void) const;
|
||||
virtual Address GetBroadcast (void) const;
|
||||
|
||||
virtual bool IsMulticast (void) const;
|
||||
virtual Address GetMulticast (void) const;
|
||||
virtual Address MakeMulticastAddress (Ipv4Address multicastGroup) const;
|
||||
|
||||
virtual bool IsPointToPoint (void) const;
|
||||
virtual bool Send(Ptr<Packet> packet, const Address& dest, uint16_t protocolNumber);
|
||||
|
||||
virtual bool Send(Ptr<Packet> packet, const Address &dest,
|
||||
uint16_t protocolNumber);
|
||||
|
||||
virtual Ptr<Node> GetNode (void) const;
|
||||
virtual void SetNode (Ptr<Node> node);
|
||||
|
||||
virtual bool NeedsArp (void) const;
|
||||
|
||||
virtual void SetReceiveCallback (NetDevice::ReceiveCallback cb);
|
||||
|
||||
private:
|
||||
|
||||
virtual void DoDispose (void);
|
||||
|
||||
/**
|
||||
* Get a copy of the attached Queue.
|
||||
*
|
||||
* This method is provided for any derived class that may need to get
|
||||
* direct access to the underlying queue.
|
||||
*
|
||||
* @see PointToPointTopology
|
||||
* @returns a pointer to the queue.
|
||||
* @returns Ptr to the queue.
|
||||
*/
|
||||
Ptr<Queue> GetQueue(void) const;
|
||||
|
||||
@@ -188,6 +197,7 @@ private:
|
||||
* respect the protocol implemented by the agent.
|
||||
*/
|
||||
void AddHeader(Ptr<Packet> p, uint16_t protocolNumber);
|
||||
|
||||
/**
|
||||
* Removes, from a packet of data, all headers and trailers that
|
||||
* relate to the protocol implemented by the agent
|
||||
@@ -195,6 +205,7 @@ private:
|
||||
* protocol stack.
|
||||
*/
|
||||
bool ProcessHeader(Ptr<Packet> p, uint16_t& param);
|
||||
|
||||
/**
|
||||
* Start Sending a Packet Down the Wire.
|
||||
*
|
||||
@@ -211,14 +222,15 @@ private:
|
||||
* @returns true if success, false on failure
|
||||
*/
|
||||
bool TransmitStart (Ptr<Packet> p);
|
||||
|
||||
/**
|
||||
* Stop Sending a Packet Down the Wire and Begin the Interframe Gap.
|
||||
*
|
||||
* The TransmitComplete method is used internally to finish the process
|
||||
* of sending a packet out on the channel.
|
||||
*
|
||||
*/
|
||||
void TransmitComplete(void);
|
||||
|
||||
void NotifyLinkUp (void);
|
||||
|
||||
/**
|
||||
@@ -234,24 +246,28 @@ private:
|
||||
* @see TxMachineState
|
||||
*/
|
||||
TxMachineState m_txMachineState;
|
||||
|
||||
/**
|
||||
* The data rate that the Net Device uses to simulate packet transmission
|
||||
* timing.
|
||||
* @see class DataRate
|
||||
*/
|
||||
DataRate m_bps;
|
||||
|
||||
/**
|
||||
* The interframe gap that the Net Device uses to throttle packet
|
||||
* transmission
|
||||
* @see class Time
|
||||
*/
|
||||
Time m_tInterframeGap;
|
||||
|
||||
/**
|
||||
* The PointToPointChannel to which this PointToPointNetDevice has been
|
||||
* attached.
|
||||
* @see class PointToPointChannel
|
||||
*/
|
||||
Ptr<PointToPointChannel> m_channel;
|
||||
|
||||
/**
|
||||
* The Queue which this PointToPointNetDevice uses as a packet source.
|
||||
* Management of this Queue has been delegated to the PointToPointNetDevice
|
||||
@@ -260,6 +276,7 @@ private:
|
||||
* @see class DropTailQueue
|
||||
*/
|
||||
Ptr<Queue> m_queue;
|
||||
|
||||
/**
|
||||
* The trace source for the packet reception events that the device can
|
||||
* fire.
|
||||
@@ -267,6 +284,7 @@ private:
|
||||
* @see class CallBackTraceSource
|
||||
*/
|
||||
TracedCallback<Ptr<const Packet> > m_rxTrace;
|
||||
|
||||
/**
|
||||
* The trace source for the packet drop events that the device can
|
||||
* fire.
|
||||
|
||||
@@ -40,6 +40,6 @@
|
||||
* beyond the eight bits per byte of the packet sent. That is, we do not
|
||||
* model Flag Sequences, Frame Check Sequences nor do we "escape" any data.
|
||||
*
|
||||
* The ns3::PointToPointChannel does model a speed-of-light delay which can
|
||||
* be accessed via the attribute "Delay."
|
||||
* The ns3::PointToPointChannel does model a speed-of-light or transmission
|
||||
* delay which can be set and get via the attribute "Delay."
|
||||
*/
|
||||
|
||||
Reference in New Issue
Block a user