rename isl to mock

This commit is contained in:
Tim Schubert 2020-06-21 16:11:04 +02:00
parent 07cff2c920
commit d898890fa6
6 changed files with 179 additions and 179 deletions

View file

@ -30,8 +30,8 @@
#include "ns3/names.h"
#include "ns3/trace-helper.h"
#include "../model/isl-net-device.h"
#include "../model/isl-channel.h"
#include "../model/mock-net-device.h"
#include "../model/mock-channel.h"
#include "isl-helper.h"
namespace ns3 {
@ -41,8 +41,8 @@ NS_LOG_COMPONENT_DEFINE ("IslHelper");
IslHelper::IslHelper ()
{
m_queueFactory.SetTypeId ("ns3::DropTailQueue<Packet>");
m_deviceFactory.SetTypeId ("ns3::IslNetDevice");
m_channelFactory.SetTypeId ("ns3::IslChannel");
m_deviceFactory.SetTypeId ("ns3::MockNetDevice");
m_channelFactory.SetTypeId ("ns3::MockChannel");
}
void
@ -79,12 +79,12 @@ IslHelper::EnablePcapInternal (std::string prefix, Ptr<NetDevice> nd, bool promi
//
// All of the Pcap enable functions vector through here including the ones
// that are wandering through all of devices on perhaps all of the nodes in
// the system. We can only deal with devices of type IslNetDevice.
// the system. We can only deal with devices of type MockNetDevice.
//
Ptr<IslNetDevice> device = nd->GetObject<IslNetDevice> ();
Ptr<MockNetDevice> device = nd->GetObject<MockNetDevice> ();
if (device == 0)
{
NS_LOG_INFO ("IslHelper::EnablePcapInternal(): Device " << device << " not of type ns3::IslNetDevice");
NS_LOG_INFO ("IslHelper::EnablePcapInternal(): Device " << device << " not of type ns3::MockNetDevice");
return;
}
@ -102,7 +102,7 @@ IslHelper::EnablePcapInternal (std::string prefix, Ptr<NetDevice> nd, bool promi
Ptr<PcapFileWrapper> file = pcapHelper.CreateFile (filename, std::ios::out,
PcapHelper::DLT_PPP);
pcapHelper.HookDefaultSink<IslNetDevice> (device, "PromiscSniffer", file);
pcapHelper.HookDefaultSink<MockNetDevice> (device, "PromiscSniffer", file);
}
void
@ -115,13 +115,13 @@ IslHelper::EnableAsciiInternal (
//
// All of the ascii enable functions vector through here including the ones
// that are wandering through all of devices on perhaps all of the nodes in
// the system. We can only deal with devices of type IslNetDevice.
// the system. We can only deal with devices of type MockNetDevice.
//
Ptr<IslNetDevice> device = nd->GetObject<IslNetDevice> ();
Ptr<MockNetDevice> device = nd->GetObject<MockNetDevice> ();
if (device == 0)
{
NS_LOG_INFO ("IslHelper::EnableAsciiInternal(): Device " << device <<
" not of type ns3::IslNetDevice");
" not of type ns3::MockNetDevice");
return;
}
@ -161,7 +161,7 @@ IslHelper::EnableAsciiInternal (
//
// The MacRx trace source provides our "r" event.
//
asciiTraceHelper.HookDefaultReceiveSinkWithoutContext<IslNetDevice> (device, "MacRx", theStream);
asciiTraceHelper.HookDefaultReceiveSinkWithoutContext<MockNetDevice> (device, "MacRx", theStream);
//
// The "+", '-', and 'd' events are driven by trace sources actually in the
@ -173,7 +173,7 @@ IslHelper::EnableAsciiInternal (
asciiTraceHelper.HookDefaultDequeueSinkWithoutContext<Queue<Packet> > (queue, "Dequeue", theStream);
// PhyRxDrop trace source for "d" event
asciiTraceHelper.HookDefaultDropSinkWithoutContext<IslNetDevice> (device, "PhyRxDrop", theStream);
asciiTraceHelper.HookDefaultDropSinkWithoutContext<MockNetDevice> (device, "PhyRxDrop", theStream);
return;
}
@ -194,23 +194,23 @@ IslHelper::EnableAsciiInternal (
uint32_t deviceid = nd->GetIfIndex ();
std::ostringstream oss;
oss << "/NodeList/" << nd->GetNode ()->GetId () << "/DeviceList/" << deviceid << "/$ns3::IslNetDevice/MacRx";
oss << "/NodeList/" << nd->GetNode ()->GetId () << "/DeviceList/" << deviceid << "/$ns3::MockNetDevice/MacRx";
Config::Connect (oss.str (), MakeBoundCallback (&AsciiTraceHelper::DefaultReceiveSinkWithContext, stream));
oss.str ("");
oss << "/NodeList/" << nodeid << "/DeviceList/" << deviceid << "/$ns3::IslNetDevice/TxQueue/Enqueue";
oss << "/NodeList/" << nodeid << "/DeviceList/" << deviceid << "/$ns3::MockNetDevice/TxQueue/Enqueue";
Config::Connect (oss.str (), MakeBoundCallback (&AsciiTraceHelper::DefaultEnqueueSinkWithContext, stream));
oss.str ("");
oss << "/NodeList/" << nodeid << "/DeviceList/" << deviceid << "/$ns3::IslNetDevice/TxQueue/Dequeue";
oss << "/NodeList/" << nodeid << "/DeviceList/" << deviceid << "/$ns3::MockNetDevice/TxQueue/Dequeue";
Config::Connect (oss.str (), MakeBoundCallback (&AsciiTraceHelper::DefaultDequeueSinkWithContext, stream));
oss.str ("");
oss << "/NodeList/" << nodeid << "/DeviceList/" << deviceid << "/$ns3::IslNetDevice/TxQueue/Drop";
oss << "/NodeList/" << nodeid << "/DeviceList/" << deviceid << "/$ns3::MockNetDevice/TxQueue/Drop";
Config::Connect (oss.str (), MakeBoundCallback (&AsciiTraceHelper::DefaultDropSinkWithContext, stream));
oss.str ("");
oss << "/NodeList/" << nodeid << "/DeviceList/" << deviceid << "/$ns3::IslNetDevice/PhyRxDrop";
oss << "/NodeList/" << nodeid << "/DeviceList/" << deviceid << "/$ns3::MockNetDevice/PhyRxDrop";
Config::Connect (oss.str (), MakeBoundCallback (&AsciiTraceHelper::DefaultDropSinkWithContext, stream));
}
@ -224,13 +224,13 @@ IslHelper::Install (NodeContainer c)
NetDeviceContainer
IslHelper::Install (std::vector<Ptr<Node> > &nodes)
{
Ptr<IslChannel> channel = m_channelFactory.Create<IslChannel> ();
Ptr<MockChannel> channel = m_channelFactory.Create<MockChannel> ();
NetDeviceContainer container;
for (Ptr<Node> node: nodes)
{
Ptr<IslNetDevice> dev = m_deviceFactory.Create<IslNetDevice> ();
Ptr<MockNetDevice> dev = m_deviceFactory.Create<MockNetDevice> ();
dev->SetAddress (Mac48Address::Allocate ());
node->AddDevice (dev);
Ptr<Queue<Packet> > queue = m_queueFactory.Create<Queue<Packet> > ();

View file

@ -21,37 +21,37 @@
#include <ns3/simulator.h>
#include <ns3/log.h>
#include <ns3/pointer.h>
#include "isl-channel.h"
#include "mock-channel.h"
namespace ns3 {
NS_LOG_COMPONENT_DEFINE ("IslChannel");
NS_LOG_COMPONENT_DEFINE ("MockChannel");
NS_OBJECT_ENSURE_REGISTERED (IslChannel);
NS_OBJECT_ENSURE_REGISTERED (MockChannel);
TypeId
IslChannel::GetTypeId (void)
MockChannel::GetTypeId (void)
{
static TypeId tid = TypeId ("ns3::IslChannel")
static TypeId tid = TypeId ("ns3::MockChannel")
.SetParent<Channel> ()
.SetGroupName ("Leo")
.AddConstructor<IslChannel> ()
.AddConstructor<MockChannel> ()
.AddAttribute ("PropagationDelay",
"A propagation delay model for the channel.",
PointerValue (),
MakePointerAccessor (&IslChannel::m_propagationDelay),
MakePointerAccessor (&MockChannel::m_propagationDelay),
MakePointerChecker<PropagationDelayModel> ())
.AddAttribute ("PropagationLoss",
"A propagation loss model for the channel.",
PointerValue (),
MakePointerAccessor (&IslChannel::m_propagationLoss),
MakePointerAccessor (&MockChannel::m_propagationLoss),
MakePointerChecker<PropagationLossModel> ())
.AddTraceSource ("TxRxIslChannel",
.AddTraceSource ("TxRxMockChannel",
"Trace source indicating transmission of packet "
"from the IslChannel, used by the Animation "
"from the MockChannel, used by the Animation "
"interface.",
MakeTraceSourceAccessor (&IslChannel::m_txrxIsl),
"ns3::IslChannel::TxRxAnimationCallback")
MakeTraceSourceAccessor (&MockChannel::m_txrxMock),
"ns3::MockChannel::TxRxAnimationCallback")
;
return tid;
}
@ -59,24 +59,24 @@ IslChannel::GetTypeId (void)
//
// By default, you get a channel that
// has an "infitely" fast transmission speed and zero processing delay.
IslChannel::IslChannel() : Channel (), m_link (0)
MockChannel::MockChannel() : Channel (), m_link (0)
{
NS_LOG_FUNCTION_NOARGS ();
}
IslChannel::~IslChannel()
MockChannel::~MockChannel()
{
}
bool
IslChannel::Detach (uint32_t deviceId)
MockChannel::Detach (uint32_t deviceId)
{
NS_LOG_FUNCTION (this << deviceId);
if (deviceId < m_link.size ())
{
if (!m_link[deviceId]->IsLinkUp ())
{
NS_LOG_WARN ("IslChannel::Detach(): Device is already detached (" << deviceId << ")");
NS_LOG_WARN ("MockChannel::Detach(): Device is already detached (" << deviceId << ")");
return false;
}
@ -90,7 +90,7 @@ IslChannel::Detach (uint32_t deviceId)
}
int32_t
IslChannel::Attach (Ptr<IslNetDevice> device)
MockChannel::Attach (Ptr<MockNetDevice> device)
{
NS_LOG_FUNCTION (this << device);
NS_ASSERT (device != 0);
@ -99,23 +99,23 @@ IslChannel::Attach (Ptr<IslNetDevice> device)
}
std::size_t
IslChannel::GetNDevices (void) const
MockChannel::GetNDevices (void) const
{
NS_LOG_FUNCTION_NOARGS ();
return m_link.size ();
}
Ptr<NetDevice>
IslChannel::GetDevice (std::size_t i) const
MockChannel::GetDevice (std::size_t i) const
{
NS_LOG_FUNCTION_NOARGS ();
return m_link[i];
}
bool IslChannel::Deliver (
bool MockChannel::Deliver (
Ptr<const Packet> p,
Ptr<IslNetDevice> src,
Ptr<IslNetDevice> dst,
Ptr<MockNetDevice> src,
Ptr<MockNetDevice> dst,
Time txTime)
{
Time delay = GetDelay (src, dst, txTime);
@ -125,13 +125,13 @@ bool IslChannel::Deliver (
{
Simulator::ScheduleWithContext (dst->GetNode ()->GetId (),
delay,
&IslNetDevice::Receive,
&MockNetDevice::Receive,
dst,
p->Copy (),
src);
// Call the tx anim callback on the net device
m_txrxIsl (p, src, dst, txTime, delay);
m_txrxMock (p, src, dst, txTime, delay);
return true;
}
else
@ -143,7 +143,7 @@ bool IslChannel::Deliver (
}
bool
IslChannel::TransmitStart (
MockChannel::TransmitStart (
Ptr<const Packet> p,
uint32_t srcId,
Address destAddr,
@ -152,8 +152,8 @@ IslChannel::TransmitStart (
NS_LOG_FUNCTION (destAddr << this << p << srcId);
NS_LOG_LOGIC ("UID is " << p->GetUid () << ")");
Ptr<IslNetDevice> src = m_link[srcId];
Ptr<IslNetDevice> dst = GetDevice (destAddr);
Ptr<MockNetDevice> src = m_link[srcId];
Ptr<MockNetDevice> dst = GetDevice (destAddr);
if (dst == nullptr)
{
@ -171,7 +171,7 @@ IslChannel::TransmitStart (
}
Time
IslChannel::GetDelay (Ptr<const IslNetDevice> src, Ptr<const IslNetDevice> dst, Time txTime) const
MockChannel::GetDelay (Ptr<const MockNetDevice> src, Ptr<const MockNetDevice> dst, Time txTime) const
{
NS_LOG_DEBUG ("Get delay from " << src << " to " << dst);
@ -184,10 +184,10 @@ IslChannel::GetDelay (Ptr<const IslNetDevice> src, Ptr<const IslNetDevice> dst,
}
// TODO optimize
Ptr<IslNetDevice>
IslChannel::GetDevice (Address &addr) const
Ptr<MockNetDevice>
MockChannel::GetDevice (Address &addr) const
{
for (Ptr<IslNetDevice> dev : m_link)
for (Ptr<MockNetDevice> dev : m_link)
{
if (dev->GetAddress () == addr)
{

View file

@ -30,11 +30,11 @@
#include "ns3/mobility-module.h"
#include "ns3/propagation-delay-model.h"
#include "ns3/propagation-loss-model.h"
#include "isl-net-device.h"
#include "mock-net-device.h"
namespace ns3 {
class IslNetDevice;
class MockNetDevice;
/**
* \ingroup network
@ -47,20 +47,20 @@ class IslNetDevice;
* A perfect channel with varariable delay (time-of-flight).
*
*/
class IslChannel : public Channel
class MockChannel : public Channel
{
public:
static TypeId GetTypeId (void);
IslChannel ();
virtual ~IslChannel ();
MockChannel ();
virtual ~MockChannel ();
/**
* \brief Attach a device to the channel.
* \param device Device to attach to the channel
* \return Index of the device inside the devices list
*/
int32_t Attach (Ptr<IslNetDevice> device);
int32_t Attach (Ptr<MockNetDevice> device);
/**
* \brief Detach a given netdevice from this channel
@ -77,18 +77,18 @@ protected:
* \brief Get the delay associated with this channel
* \returns Time delay
*/
Time GetDelay (Ptr<const IslNetDevice> first, Ptr<const IslNetDevice> second, Time txTime) const;
Time GetDelay (Ptr<const MockNetDevice> first, Ptr<const MockNetDevice> second, Time txTime) const;
private:
Ptr<IslNetDevice> GetDevice (Address &addr) const;
Ptr<MockNetDevice> GetDevice (Address &addr) const;
TracedCallback<Ptr<const Packet>, // Packet being transmitted
Ptr<NetDevice>, // Transmitting NetDevice
Ptr<NetDevice>, // Receiving NetDevice
Time, // Amount of time to transmit the pkt
Time // Last bit receive time (relative to now)
> m_txrxIsl;
> m_txrxMock;
/**
* \brief Propagation delay model to be used with this channel
*/
@ -97,10 +97,10 @@ private:
* \brief Propagation loss model to be used with this channel
*/
Ptr<PropagationLossModel> m_propagationLoss;
std::vector<Ptr<IslNetDevice> > m_link;
std::vector<Ptr<MockNetDevice> > m_link;
bool Deliver (Ptr<const Packet> p, Ptr<IslNetDevice> src, Ptr<IslNetDevice> dst, Time txTime);
}; // class IslChannel
bool Deliver (Ptr<const Packet> p, Ptr<MockNetDevice> src, Ptr<MockNetDevice> dst, Time txTime);
}; // class MockChannel
} // namespace ns3

View file

@ -27,46 +27,46 @@
#include "ns3/pointer.h"
#include "ns3/net-device-queue-interface.h"
#include "ns3/ppp-header.h"
#include "isl-channel.h"
#include "isl-net-device.h"
#include "mock-channel.h"
#include "mock-net-device.h"
namespace ns3 {
NS_LOG_COMPONENT_DEFINE ("IslNetDevice");
NS_LOG_COMPONENT_DEFINE ("MockNetDevice");
NS_OBJECT_ENSURE_REGISTERED (IslNetDevice);
NS_OBJECT_ENSURE_REGISTERED (MockNetDevice);
TypeId
IslNetDevice::GetTypeId (void)
MockNetDevice::GetTypeId (void)
{
static TypeId tid = TypeId ("ns3::IslNetDevice")
static TypeId tid = TypeId ("ns3::MockNetDevice")
.SetParent<NetDevice> ()
.SetGroupName ("Leo")
.AddConstructor<IslNetDevice> ()
.AddConstructor<MockNetDevice> ()
.AddAttribute ("Mtu", "The MAC-level Maximum Transmission Unit",
UintegerValue (DEFAULT_MTU),
MakeUintegerAccessor (&IslNetDevice::SetMtu,
&IslNetDevice::GetMtu),
MakeUintegerAccessor (&MockNetDevice::SetMtu,
&MockNetDevice::GetMtu),
MakeUintegerChecker<uint16_t> ())
.AddAttribute ("Address",
"The MAC address of this device.",
Mac48AddressValue (Mac48Address ("ff:ff:ff:ff:ff:ff")),
MakeMac48AddressAccessor (&IslNetDevice::m_address),
MakeMac48AddressAccessor (&MockNetDevice::m_address),
MakeMac48AddressChecker ())
.AddAttribute ("DataRate",
"The default data rate for point to point links",
DataRateValue (DataRate ("32768b/s")),
MakeDataRateAccessor (&IslNetDevice::m_bps),
MakeDataRateAccessor (&MockNetDevice::m_bps),
MakeDataRateChecker ())
.AddAttribute ("ReceiveErrorModel",
"The receiver error model used to simulate packet loss",
PointerValue (),
MakePointerAccessor (&IslNetDevice::m_receiveErrorModel),
MakePointerAccessor (&MockNetDevice::m_receiveErrorModel),
MakePointerChecker<ErrorModel> ())
.AddAttribute ("InterframeGap",
"The time to wait between packet (frame) transmissions",
TimeValue (Seconds (0.0)),
MakeTimeAccessor (&IslNetDevice::m_tInterframeGap),
MakeTimeAccessor (&MockNetDevice::m_tInterframeGap),
MakeTimeChecker ())
//
@ -76,12 +76,12 @@ IslNetDevice::GetTypeId (void)
.AddAttribute ("TxQueue",
"A queue to use as the transmit queue in the device.",
PointerValue (),
MakePointerAccessor (&IslNetDevice::m_queue),
MakePointerAccessor (&MockNetDevice::m_queue),
MakePointerChecker<Queue<Packet> > ())
.AddAttribute ("MobilityModel", "The mobility model of the device",
PointerValue (),
MakePointerAccessor (&IslNetDevice::SetMobilityModel,
&IslNetDevice::GetMobilityModel),
MakePointerAccessor (&MockNetDevice::SetMobilityModel,
&MockNetDevice::GetMobilityModel),
MakePointerChecker<MobilityModel> ())
//
// Trace sources at the "top" of the net device, where packets transition
@ -90,33 +90,33 @@ IslNetDevice::GetTypeId (void)
.AddTraceSource ("MacTx",
"Trace source indicating a packet has arrived "
"for transmission by this device",
MakeTraceSourceAccessor (&IslNetDevice::m_macTxTrace),
MakeTraceSourceAccessor (&MockNetDevice::m_macTxTrace),
"ns3::Packet::TracedCallback")
.AddTraceSource ("MacTxDrop",
"Trace source indicating a packet has been dropped "
"by the device before transmission",
MakeTraceSourceAccessor (&IslNetDevice::m_macTxDropTrace),
MakeTraceSourceAccessor (&MockNetDevice::m_macTxDropTrace),
"ns3::Packet::TracedCallback")
.AddTraceSource ("MacPromiscRx",
"A packet has been received by this device, "
"has been passed up from the physical layer "
"and is being forwarded up the local protocol stack. "
"This is a promiscuous trace,",
MakeTraceSourceAccessor (&IslNetDevice::m_macPromiscRxTrace),
MakeTraceSourceAccessor (&MockNetDevice::m_macPromiscRxTrace),
"ns3::Packet::TracedCallback")
.AddTraceSource ("MacRx",
"A packet has been received by this device, "
"has been passed up from the physical layer "
"and is being forwarded up the local protocol stack. "
"This is a non-promiscuous trace,",
MakeTraceSourceAccessor (&IslNetDevice::m_macRxTrace),
MakeTraceSourceAccessor (&MockNetDevice::m_macRxTrace),
"ns3::Packet::TracedCallback")
#if 0
// Not currently implemented for this device
.AddTraceSource ("MacRxDrop",
"Trace source indicating a packet was dropped "
"before being forwarded up the stack",
MakeTraceSourceAccessor (&IslNetDevice::m_macRxDropTrace),
MakeTraceSourceAccessor (&MockNetDevice::m_macRxDropTrace),
"ns3::Packet::TracedCallback")
#endif
//
@ -126,35 +126,35 @@ IslNetDevice::GetTypeId (void)
.AddTraceSource ("PhyTxBegin",
"Trace source indicating a packet has begun "
"transmitting over the channel",
MakeTraceSourceAccessor (&IslNetDevice::m_phyTxBeginTrace),
MakeTraceSourceAccessor (&MockNetDevice::m_phyTxBeginTrace),
"ns3::Packet::TracedCallback")
.AddTraceSource ("PhyTxEnd",
"Trace source indicating a packet has been "
"completely transmitted over the channel",
MakeTraceSourceAccessor (&IslNetDevice::m_phyTxEndTrace),
MakeTraceSourceAccessor (&MockNetDevice::m_phyTxEndTrace),
"ns3::Packet::TracedCallback")
.AddTraceSource ("PhyTxDrop",
"Trace source indicating a packet has been "
"dropped by the device during transmission",
MakeTraceSourceAccessor (&IslNetDevice::m_phyTxDropTrace),
MakeTraceSourceAccessor (&MockNetDevice::m_phyTxDropTrace),
"ns3::Packet::TracedCallback")
#if 0
// Not currently implemented for this device
.AddTraceSource ("PhyRxBegin",
"Trace source indicating a packet has begun "
"being received by the device",
MakeTraceSourceAccessor (&IslNetDevice::m_phyRxBeginTrace),
MakeTraceSourceAccessor (&MockNetDevice::m_phyRxBeginTrace),
"ns3::Packet::TracedCallback")
#endif
.AddTraceSource ("PhyRxEnd",
"Trace source indicating a packet has been "
"completely received by the device",
MakeTraceSourceAccessor (&IslNetDevice::m_phyRxEndTrace),
MakeTraceSourceAccessor (&MockNetDevice::m_phyRxEndTrace),
"ns3::Packet::TracedCallback")
.AddTraceSource ("PhyRxDrop",
"Trace source indicating a packet has been "
"dropped by the device during reception",
MakeTraceSourceAccessor (&IslNetDevice::m_phyRxDropTrace),
MakeTraceSourceAccessor (&MockNetDevice::m_phyRxDropTrace),
"ns3::Packet::TracedCallback")
//
@ -165,18 +165,18 @@ IslNetDevice::GetTypeId (void)
.AddTraceSource ("Sniffer",
"Trace source simulating a non-promiscuous packet sniffer "
"attached to the device",
MakeTraceSourceAccessor (&IslNetDevice::m_snifferTrace),
MakeTraceSourceAccessor (&MockNetDevice::m_snifferTrace),
"ns3::Packet::TracedCallback")
.AddTraceSource ("PromiscSniffer",
"Trace source simulating a promiscuous packet sniffer "
"attached to the device",
MakeTraceSourceAccessor (&IslNetDevice::m_promiscSnifferTrace),
MakeTraceSourceAccessor (&MockNetDevice::m_promiscSnifferTrace),
"ns3::Packet::TracedCallback")
;
return tid;
}
IslNetDevice::IslNetDevice ()
MockNetDevice::MockNetDevice ()
:
m_txMachineState (READY),
m_channel (0),
@ -186,13 +186,13 @@ IslNetDevice::IslNetDevice ()
NS_LOG_FUNCTION (this);
}
IslNetDevice::~IslNetDevice ()
MockNetDevice::~MockNetDevice ()
{
NS_LOG_FUNCTION (this);
}
void
IslNetDevice::AddHeader (Ptr<Packet> p, uint16_t protocolNumber)
MockNetDevice::AddHeader (Ptr<Packet> p, uint16_t protocolNumber)
{
NS_LOG_FUNCTION (this << p << protocolNumber);
PppHeader ppp;
@ -201,7 +201,7 @@ IslNetDevice::AddHeader (Ptr<Packet> p, uint16_t protocolNumber)
}
bool
IslNetDevice::ProcessHeader (Ptr<Packet> p, uint16_t& param)
MockNetDevice::ProcessHeader (Ptr<Packet> p, uint16_t& param)
{
NS_LOG_FUNCTION (this << p << param);
PppHeader ppp;
@ -211,7 +211,7 @@ IslNetDevice::ProcessHeader (Ptr<Packet> p, uint16_t& param)
}
void
IslNetDevice::DoInitialize (void)
MockNetDevice::DoInitialize (void)
{
if (m_queueInterface)
{
@ -228,7 +228,7 @@ IslNetDevice::DoInitialize (void)
}
void
IslNetDevice::NotifyNewAggregate (void)
MockNetDevice::NotifyNewAggregate (void)
{
NS_LOG_FUNCTION (this);
if (m_queueInterface == 0)
@ -245,7 +245,7 @@ IslNetDevice::NotifyNewAggregate (void)
}
void
IslNetDevice::DoDispose ()
MockNetDevice::DoDispose ()
{
NS_LOG_FUNCTION (this);
m_node = 0;
@ -258,21 +258,21 @@ IslNetDevice::DoDispose ()
}
void
IslNetDevice::SetDataRate (DataRate bps)
MockNetDevice::SetDataRate (DataRate bps)
{
NS_LOG_FUNCTION (this);
m_bps = bps;
}
void
IslNetDevice::SetInterframeGap (Time t)
MockNetDevice::SetInterframeGap (Time t)
{
NS_LOG_FUNCTION (this << t.GetSeconds ());
m_tInterframeGap = t;
}
bool
IslNetDevice::TransmitStart (Ptr<Packet> p, const Address &dest)
MockNetDevice::TransmitStart (Ptr<Packet> p, const Address &dest)
{
NS_LOG_FUNCTION (this << p);
NS_LOG_LOGIC ("UID is " << p->GetUid () << ")");
@ -291,7 +291,7 @@ IslNetDevice::TransmitStart (Ptr<Packet> p, const Address &dest)
Time txCompleteTime = txTime + m_tInterframeGap;
NS_LOG_LOGIC ("Schedule TransmitCompleteEvent in " << txCompleteTime.GetSeconds () << "sec");
Simulator::Schedule (txCompleteTime, &IslNetDevice::TransmitComplete, this, dest);
Simulator::Schedule (txCompleteTime, &MockNetDevice::TransmitComplete, this, dest);
bool result = m_channel->TransmitStart (p, m_channelDevId, dest, txTime);
if (result == false)
@ -302,7 +302,7 @@ IslNetDevice::TransmitStart (Ptr<Packet> p, const Address &dest)
}
void
IslNetDevice::TransmitComplete (const Address &dest)
MockNetDevice::TransmitComplete (const Address &dest)
{
NS_LOG_FUNCTION (this);
@ -315,7 +315,7 @@ IslNetDevice::TransmitComplete (const Address &dest)
NS_ASSERT_MSG (m_txMachineState == BUSY, "Must be BUSY if transmitting");
m_txMachineState = READY;
NS_ASSERT_MSG (m_currentPkt != 0, "IslNetDevice::TransmitComplete(): m_currentPkt zero");
NS_ASSERT_MSG (m_currentPkt != 0, "MockNetDevice::TransmitComplete(): m_currentPkt zero");
m_phyTxEndTrace (m_currentPkt);
m_currentPkt = 0;
@ -336,7 +336,7 @@ IslNetDevice::TransmitComplete (const Address &dest)
}
bool
IslNetDevice::Attach (Ptr<IslChannel> ch)
MockNetDevice::Attach (Ptr<MockChannel> ch)
{
NS_LOG_FUNCTION (this << &ch);
@ -354,21 +354,21 @@ IslNetDevice::Attach (Ptr<IslChannel> ch)
}
void
IslNetDevice::SetQueue (Ptr<Queue<Packet> > q)
MockNetDevice::SetQueue (Ptr<Queue<Packet> > q)
{
NS_LOG_FUNCTION (this << q);
m_queue = q;
}
void
IslNetDevice::SetReceiveErrorModel (Ptr<ErrorModel> em)
MockNetDevice::SetReceiveErrorModel (Ptr<ErrorModel> em)
{
NS_LOG_FUNCTION (this << em);
m_receiveErrorModel = em;
}
void
IslNetDevice::Receive (Ptr<Packet> packet, Ptr<IslNetDevice> senderDevice)
MockNetDevice::Receive (Ptr<Packet> packet, Ptr<MockNetDevice> senderDevice)
{
NS_LOG_FUNCTION (this << packet);
uint16_t protocol = 0;
@ -419,14 +419,14 @@ IslNetDevice::Receive (Ptr<Packet> packet, Ptr<IslNetDevice> senderDevice)
}
Ptr<Queue<Packet> >
IslNetDevice::GetQueue (void) const
MockNetDevice::GetQueue (void) const
{
NS_LOG_FUNCTION (this);
return m_queue;
}
void
IslNetDevice::NotifyLinkUp (void)
MockNetDevice::NotifyLinkUp (void)
{
NS_LOG_FUNCTION (this);
m_linkUp = true;
@ -434,7 +434,7 @@ IslNetDevice::NotifyLinkUp (void)
}
void
IslNetDevice::NotifyLinkDown (void)
MockNetDevice::NotifyLinkDown (void)
{
NS_LOG_FUNCTION (this);
m_linkUp = false;
@ -442,20 +442,20 @@ IslNetDevice::NotifyLinkDown (void)
}
void
IslNetDevice::SetIfIndex (const uint32_t index)
MockNetDevice::SetIfIndex (const uint32_t index)
{
NS_LOG_FUNCTION (this);
m_ifIndex = index;
}
uint32_t
IslNetDevice::GetIfIndex (void) const
MockNetDevice::GetIfIndex (void) const
{
return m_ifIndex;
}
Ptr<Channel>
IslNetDevice::GetChannel (void) const
MockNetDevice::GetChannel (void) const
{
return m_channel;
}
@ -467,27 +467,27 @@ IslNetDevice::GetChannel (void) const
// clients get and set the address, but simply ignore them.
void
IslNetDevice::SetAddress (Address address)
MockNetDevice::SetAddress (Address address)
{
NS_LOG_FUNCTION (this << address);
m_address = Mac48Address::ConvertFrom (address);
}
Address
IslNetDevice::GetAddress (void) const
MockNetDevice::GetAddress (void) const
{
return m_address;
}
bool
IslNetDevice::IsLinkUp (void) const
MockNetDevice::IsLinkUp (void) const
{
NS_LOG_FUNCTION (this);
return m_linkUp;
}
void
IslNetDevice::AddLinkChangeCallback (Callback<void> callback)
MockNetDevice::AddLinkChangeCallback (Callback<void> callback)
{
NS_LOG_FUNCTION (this);
m_linkChangeCallbacks.ConnectWithoutContext (callback);
@ -498,7 +498,7 @@ IslNetDevice::AddLinkChangeCallback (Callback<void> callback)
// all of the devices on the network.
//
bool
IslNetDevice::IsBroadcast (void) const
MockNetDevice::IsBroadcast (void) const
{
NS_LOG_FUNCTION (this);
return true;
@ -510,49 +510,49 @@ IslNetDevice::IsBroadcast (void) const
// broadcast address, so we make up something reasonable.
//
Address
IslNetDevice::GetBroadcast (void) const
MockNetDevice::GetBroadcast (void) const
{
NS_LOG_FUNCTION (this);
return Mac48Address ("ff:ff:ff:ff:ff:ff");
}
bool
IslNetDevice::IsMulticast (void) const
MockNetDevice::IsMulticast (void) const
{
NS_LOG_FUNCTION (this);
return true;
}
Address
IslNetDevice::GetMulticast (Ipv4Address multicastGroup) const
MockNetDevice::GetMulticast (Ipv4Address multicastGroup) const
{
NS_LOG_FUNCTION (this);
return Mac48Address ("01:00:5e:00:00:00");
}
Address
IslNetDevice::GetMulticast (Ipv6Address addr) const
MockNetDevice::GetMulticast (Ipv6Address addr) const
{
NS_LOG_FUNCTION (this << addr);
return Mac48Address ("33:33:00:00:00:00");
}
bool
IslNetDevice::IsIsl (void) const
MockNetDevice::IsMock (void) const
{
NS_LOG_FUNCTION (this);
return true;
}
bool
IslNetDevice::IsBridge (void) const
MockNetDevice::IsBridge (void) const
{
NS_LOG_FUNCTION (this);
return false;
}
bool
IslNetDevice::Send (
MockNetDevice::Send (
Ptr<Packet> packet,
const Address &dest,
uint16_t protocolNumber)
@ -605,7 +605,7 @@ IslNetDevice::Send (
}
bool
IslNetDevice::SendFrom (Ptr<Packet> packet,
MockNetDevice::SendFrom (Ptr<Packet> packet,
const Address &source,
const Address &dest,
uint16_t protocolNumber)
@ -615,60 +615,60 @@ IslNetDevice::SendFrom (Ptr<Packet> packet,
}
Ptr<Node>
IslNetDevice::GetNode (void) const
MockNetDevice::GetNode (void) const
{
return m_node;
}
void
IslNetDevice::SetNode (Ptr<Node> node)
MockNetDevice::SetNode (Ptr<Node> node)
{
NS_LOG_FUNCTION (this);
m_node = node;
}
bool
IslNetDevice::NeedsArp (void) const
MockNetDevice::NeedsArp (void) const
{
NS_LOG_FUNCTION (this);
return true;
}
void
IslNetDevice::SetReceiveCallback (NetDevice::ReceiveCallback cb)
MockNetDevice::SetReceiveCallback (NetDevice::ReceiveCallback cb)
{
m_rxCallback = cb;
}
void
IslNetDevice::SetPromiscReceiveCallback (NetDevice::PromiscReceiveCallback cb)
MockNetDevice::SetPromiscReceiveCallback (NetDevice::PromiscReceiveCallback cb)
{
m_promiscCallback = cb;
}
bool
IslNetDevice::SupportsSendFrom (void) const
MockNetDevice::SupportsSendFrom (void) const
{
NS_LOG_FUNCTION (this);
return false;
}
void
IslNetDevice::DoMpiReceive (Ptr<Packet> p, Ptr<IslNetDevice> senderDevice)
MockNetDevice::DoMpiReceive (Ptr<Packet> p, Ptr<MockNetDevice> senderDevice)
{
NS_LOG_FUNCTION (this << p);
Receive (p, senderDevice);
}
Address
IslNetDevice::GetRemote (Ptr<IslNetDevice> senderDevice) const
MockNetDevice::GetRemote (Ptr<MockNetDevice> senderDevice) const
{
NS_LOG_FUNCTION (this);
return senderDevice->GetAddress ();
}
bool
IslNetDevice::SetMtu (uint16_t mtu)
MockNetDevice::SetMtu (uint16_t mtu)
{
NS_LOG_FUNCTION (this << mtu);
m_mtu = mtu;
@ -676,14 +676,14 @@ IslNetDevice::SetMtu (uint16_t mtu)
}
uint16_t
IslNetDevice::GetMtu (void) const
MockNetDevice::GetMtu (void) const
{
NS_LOG_FUNCTION (this);
return m_mtu;
}
uint16_t
IslNetDevice::PppToEther (uint16_t proto)
MockNetDevice::PppToEther (uint16_t proto)
{
NS_LOG_FUNCTION_NOARGS();
switch(proto)
@ -697,7 +697,7 @@ IslNetDevice::PppToEther (uint16_t proto)
}
uint16_t
IslNetDevice::EtherToPpp (uint16_t proto)
MockNetDevice::EtherToPpp (uint16_t proto)
{
NS_LOG_FUNCTION_NOARGS();
switch(proto)
@ -711,20 +711,20 @@ IslNetDevice::EtherToPpp (uint16_t proto)
}
Ptr<MobilityModel>
IslNetDevice::GetMobilityModel (void) const
MockNetDevice::GetMobilityModel (void) const
{
return m_mobilityModel;
}
void
IslNetDevice::SetMobilityModel (Ptr<MobilityModel> model)
MockNetDevice::SetMobilityModel (Ptr<MobilityModel> model)
{
NS_LOG_FUNCTION (this);
m_mobilityModel = model;
}
bool
IslNetDevice::IsPointToPoint() const
MockNetDevice::IsPointToPoint() const
{
return true;
}

View file

@ -37,7 +37,7 @@ namespace ns3 {
template <typename Item> class Queue;
class NetDeviceQueueInterface;
class IslChannel;
class MockChannel;
class ErrorModel;
/**
@ -51,18 +51,18 @@ class ErrorModel;
/**
* \ingroup point-to-point
* \class IslNetDevice
* \class MockNetDevice
* \brief A Device for a Point to Point Network Link.
*
* This IslNetDevice class specializes the NetDevice abstract
* base class. Together with a IslChannel (and a peer
* IslNetDevice), the class models, with some level of
* This MockNetDevice class specializes the NetDevice abstract
* base class. Together with a MockChannel (and a peer
* MockNetDevice), the class models, with some level of
* abstraction, a generic point-to-point or serial link.
* Key parameters or objects that can be specified for this device
* include a queue, data rate, and interframe transmission gap (the
* propagation delay is set in the IslChannel).
* propagation delay is set in the MockChannel).
*/
class IslNetDevice : public NetDevice
class MockNetDevice : public NetDevice
{
public:
/**
@ -73,20 +73,20 @@ public:
static TypeId GetTypeId (void);
/**
* Construct a IslNetDevice
* Construct a MockNetDevice
*
* This is the constructor for the IslNetDevice. It takes as a
* This is the constructor for the MockNetDevice. It takes as a
* parameter a pointer to the Node to which this device is connected,
* as well as an optional DataRate object.
*/
IslNetDevice ();
MockNetDevice ();
/**
* Destroy a IslNetDevice
* Destroy a MockNetDevice
*
* This is the destructor for the IslNetDevice.
* This is the destructor for the MockNetDevice.
*/
virtual ~IslNetDevice ();
virtual ~MockNetDevice ();
/**
* Set the Data Rate used for transmission of packets. The data rate is
@ -111,12 +111,12 @@ public:
* \param ch Ptr to the channel to which this object is being attached.
* \return true if the operation was successful (always true actually)
*/
bool Attach (Ptr<IslChannel> ch);
bool Attach (Ptr<MockChannel> ch);
/**
* Attach a queue to the IslNetDevice.
* Attach a queue to the MockNetDevice.
*
* The IslNetDevice "owns" a queue that implements a queueing
* The MockNetDevice "owns" a queue that implements a queueing
* method such as DropTailQueue or RedQueue
*
* \param queue Ptr to the new queue.
@ -131,9 +131,9 @@ public:
Ptr<Queue<Packet> > GetQueue (void) const;
/**
* Attach a receive ErrorModel to the IslNetDevice.
* Attach a receive ErrorModel to the MockNetDevice.
*
* The IslNetDevice may optionally include an ErrorModel in
* The MockNetDevice may optionally include an ErrorModel in
* the packet receive chain.
*
* \param em Ptr to the ErrorModel.
@ -141,16 +141,16 @@ public:
void SetReceiveErrorModel (Ptr<ErrorModel> em);
/**
* Receive a packet from a connected IslChannel.
* Receive a packet from a connected MockChannel.
*
* The IslNetDevice receives packets from its connected channel
* The MockNetDevice receives packets from its connected channel
* and forwards them up the protocol stack. This is the public method
* used by the channel to indicate that the last bit of a packet has
* arrived at the device.
*
* \param p Ptr to the received packet.
*/
void Receive (Ptr<Packet> p, Ptr<IslNetDevice> senderDevice);
void Receive (Ptr<Packet> p, Ptr<MockNetDevice> senderDevice);
// The remaining methods are documented in ns3::NetDevice*
@ -175,7 +175,7 @@ public:
virtual bool IsMulticast (void) const;
virtual Address GetMulticast (Ipv4Address multicastGroup) const;
virtual bool IsIsl (void) const;
virtual bool IsMock (void) const;
virtual bool IsBridge (void) const;
virtual bool IsPointToPoint() const;
@ -205,7 +205,7 @@ protected:
*
* \param p Packet received
*/
void DoMpiReceive (Ptr<Packet> p, Ptr<IslNetDevice> sender);
void DoMpiReceive (Ptr<Packet> p, Ptr<MockNetDevice> sender);
virtual void DoInitialize (void);
virtual void NotifyNewAggregate (void);
@ -220,7 +220,7 @@ private:
* \param o Other NetDevice
* \return New instance of the NetDevice
*/
IslNetDevice& operator = (const IslNetDevice &o);
MockNetDevice& operator = (const MockNetDevice &o);
/**
* \brief Copy constructor
@ -229,7 +229,7 @@ private:
* \param o Other NetDevice
*/
IslNetDevice (const IslNetDevice &o);
MockNetDevice (const MockNetDevice &o);
/**
* \brief Dispose of the object
@ -242,7 +242,7 @@ private:
* \returns the address of the remote device connected to this device
* through the point to point channel.
*/
Address GetRemote (Ptr<IslNetDevice> senderDevice) const;
Address GetRemote (Ptr<MockNetDevice> senderDevice) const;
/**
* Adds the necessary headers and trailers to a packet of data in order to
@ -266,13 +266,13 @@ private:
* Start Sending a Packet Down the Wire.
*
* The TransmitStart method is the method that is used internally in the
* IslNetDevice to begin the process of sending a packet out on
* MockNetDevice to begin the process of sending a packet out on
* the channel. The corresponding method is called on the channel to let
* it know that the physical device this class represents has virtually
* started sending signals. An event is scheduled for the time at which
* the bits have been completely transmitted.
*
* \see IslChannel::TransmitStart ()
* \see MockChannel::TransmitStart ()
* \see TransmitComplete()
* \param p a reference to the packet to send
* \returns true if success, false on failure
@ -320,14 +320,14 @@ private:
Time m_tInterframeGap;
/**
* The IslChannel to which this IslNetDevice has been
* The MockChannel to which this MockNetDevice has been
* attached.
*/
Ptr<IslChannel> m_channel;
Ptr<MockChannel> m_channel;
/**
* The Queue which this IslNetDevice uses as a packet source.
* Management of this Queue has been delegated to the IslNetDevice
* The Queue which this MockNetDevice uses as a packet source.
* Management of this Queue has been delegated to the MockNetDevice
* and it has the responsibility for deletion.
* \see class DropTailQueue
*/

View file

@ -10,8 +10,8 @@ def build(bld):
module = bld.create_ns3_module('leo', ['core','internet', 'propagation', 'stats', 'traffic', 'flow-monitor', 'applications'])
module.source = [
'model/leo.cc',
'model/isl-net-device.cc',
'model/isl-channel.cc',
'model/mock-net-device.cc',
'model/mock-channel.cc',
'model/isl-propagation-loss-model.cc',
'model/leo-mobility-model.cc',
'helper/leo-helper.cc',
@ -27,8 +27,8 @@ def build(bld):
headers.module = 'leo'
headers.source = [
'model/leo.h',
'model/isl-net-device.h',
'model/isl-channel.h',
'model/mock-net-device.h',
'model/mock-channel.h',
'model/isl-propagation-loss-model.h',
'model/leo-mobility-model.h',
'helper/leo-helper.h',