configure tracing post-topology construction, not before.
This commit is contained in:
@@ -85,14 +85,6 @@ main (int argc, char *argv[])
|
||||
|
||||
NS_LOG_INFO ("Build Topology.");
|
||||
CsmaHelper csma;
|
||||
// Also configure some tcpdump traces; each interface will be traced
|
||||
// The output files will be named
|
||||
// csma-broadcast.pcap-<nodeId>-<interfaceId>
|
||||
// and can be read by the "tcpdump -tt -r" command
|
||||
csma.EnablePcap ("csma-broadcast.pcap");
|
||||
std::ofstream ascii;
|
||||
ascii.open ("csma-broadcast.tr");
|
||||
csma.EnableAscii (ascii);
|
||||
csma.SetChannelParameter ("BitRate", DataRate(5000000));
|
||||
csma.SetChannelParameter ("Delay", MilliSeconds(2));
|
||||
|
||||
@@ -137,6 +129,14 @@ main (int argc, char *argv[])
|
||||
sink.Build (c1.Get (1));
|
||||
|
||||
|
||||
// Also configure some tcpdump traces; each interface will be traced
|
||||
// The output files will be named
|
||||
// csma-broadcast.pcap-<nodeId>-<interfaceId>
|
||||
// and can be read by the "tcpdump -tt -r" command
|
||||
CsmaHelper::EnablePcap ("csma-broadcast.pcap");
|
||||
std::ofstream ascii;
|
||||
ascii.open ("csma-broadcast.tr");
|
||||
CsmaHelper::EnableAscii (ascii);
|
||||
|
||||
NS_LOG_INFO ("Run Simulation.");
|
||||
Simulator::Run ();
|
||||
|
||||
@@ -89,9 +89,6 @@ main (int argc, char *argv[])
|
||||
CommandLine cmd;
|
||||
cmd.Parse (argc, argv);
|
||||
|
||||
std::ofstream ascii;
|
||||
ascii.open ("mixed-global-routing.tr");
|
||||
|
||||
NS_LOG_INFO ("Create nodes.");
|
||||
NodeContainer c;
|
||||
c.Create (7);
|
||||
@@ -106,8 +103,6 @@ main (int argc, char *argv[])
|
||||
// We create the channels first without any IP addressing information
|
||||
NS_LOG_INFO ("Create channels.");
|
||||
PointToPointHelper p2p;
|
||||
p2p.EnablePcap ("mixed-global-routing.pcap");
|
||||
p2p.EnableAscii (ascii);
|
||||
p2p.SetChannelParameter ("BitRate", DataRate (5000000));
|
||||
p2p.SetChannelParameter ("Delay", MilliSeconds (2));
|
||||
NetDeviceContainer d0d2 = p2p.Build (n0n2);
|
||||
@@ -120,8 +115,6 @@ main (int argc, char *argv[])
|
||||
|
||||
// We create the channels first without any IP addressing information
|
||||
CsmaHelper csma;
|
||||
csma.EnablePcap ("mixed-global-routing.pcap");
|
||||
csma.EnableAscii (ascii);
|
||||
csma.SetChannelParameter ("BitRate", DataRate (5000000));
|
||||
csma.SetChannelParameter ("Delay", MilliSeconds (2));
|
||||
NetDeviceContainer d2345 = csma.Build (n2345);
|
||||
@@ -159,6 +152,13 @@ main (int argc, char *argv[])
|
||||
apps.Start (Seconds (1.0));
|
||||
apps.Stop (Seconds (10.0));
|
||||
|
||||
std::ofstream ascii;
|
||||
ascii.open ("mixed-global-routing.tr");
|
||||
PointToPointHelper::EnablePcap ("mixed-global-routing.pcap");
|
||||
PointToPointHelper::EnableAscii (ascii);
|
||||
CsmaHelper::EnablePcap ("mixed-global-routing.pcap");
|
||||
CsmaHelper::EnableAscii (ascii);
|
||||
|
||||
|
||||
NS_LOG_INFO ("Run Simulation.");
|
||||
Simulator::Run ();
|
||||
|
||||
@@ -103,9 +103,6 @@ main (int argc, char *argv[])
|
||||
// DefaultValue::Bind ()s at run-time, via command-line arguments
|
||||
cmd.Parse (argc, argv);
|
||||
|
||||
std::ofstream ascii;
|
||||
ascii.open ("simple-alternate-routing.tr");
|
||||
|
||||
// Here, we will explicitly create four nodes. In more sophisticated
|
||||
// topologies, we could configure a node factory.
|
||||
NS_LOG_INFO ("Create nodes.");
|
||||
@@ -119,8 +116,6 @@ main (int argc, char *argv[])
|
||||
// We create the channels first without any IP addressing information
|
||||
NS_LOG_INFO ("Create channels.");
|
||||
PointToPointHelper p2p;
|
||||
p2p.EnablePcap ("simple-alternate-routing.pcap");
|
||||
p2p.EnableAscii (ascii);
|
||||
p2p.SetChannelParameter ("BitRate", DataRate (5000000));
|
||||
p2p.SetChannelParameter ("Delay", MilliSeconds (2));
|
||||
NetDeviceContainer d0d2 = p2p.Build (n0n2);
|
||||
@@ -180,6 +175,11 @@ main (int argc, char *argv[])
|
||||
apps.Start (Seconds (1.1));
|
||||
apps.Stop (Seconds (10.0));
|
||||
|
||||
std::ofstream ascii;
|
||||
ascii.open ("simple-alternate-routing.tr");
|
||||
PointToPointHelper::EnablePcap ("simple-alternate-routing.pcap");
|
||||
PointToPointHelper::EnableAscii (ascii);
|
||||
|
||||
|
||||
NS_LOG_INFO ("Run Simulation.");
|
||||
Simulator::Run ();
|
||||
|
||||
@@ -71,9 +71,6 @@ main (int argc, char *argv[])
|
||||
CommandLine cmd;
|
||||
cmd.Parse (argc, argv);
|
||||
|
||||
std::ofstream ascii;
|
||||
ascii.open ("simple-error-model.pcap");
|
||||
|
||||
// Here, we will explicitly create four nodes. In more sophisticated
|
||||
// topologies, we could configure a node factory.
|
||||
NS_LOG_INFO ("Create nodes.");
|
||||
@@ -89,8 +86,6 @@ main (int argc, char *argv[])
|
||||
// We create the channels first without any IP addressing information
|
||||
NS_LOG_INFO ("Create channels.");
|
||||
PointToPointHelper p2p;
|
||||
p2p.EnablePcap ("simple-error-model.pcap");
|
||||
p2p.EnableAscii (ascii);
|
||||
p2p.SetChannelParameter ("BitRate", DataRate (5000000));
|
||||
p2p.SetChannelParameter ("Delay", MilliSeconds (2));
|
||||
NetDeviceContainer d0d2 = p2p.Build (n0n2);
|
||||
@@ -166,6 +161,10 @@ main (int argc, char *argv[])
|
||||
pem->SetList (sampleList);
|
||||
d0d2.Get (1)->SetAttribute ("ReceiveErrorModel", pem);
|
||||
|
||||
std::ofstream ascii;
|
||||
ascii.open ("simple-error-model.tr");
|
||||
PointToPointHelper::EnablePcap ("simple-error-model.pcap");
|
||||
PointToPointHelper::EnableAscii (ascii);
|
||||
|
||||
NS_LOG_INFO ("Run Simulation.");
|
||||
Simulator::Run ();
|
||||
|
||||
@@ -130,13 +130,8 @@ int main (int argc, char *argv[])
|
||||
c1.Add (c0.Get (1));
|
||||
c1.Create (1);
|
||||
|
||||
std::ofstream ascii;
|
||||
ascii.open ("tcp-large-transfer.tr");
|
||||
|
||||
// We create the channels first without any IP addressing information
|
||||
PointToPointHelper p2p;
|
||||
p2p.EnablePcap ("tcp-large-transfer.pcap");
|
||||
p2p.EnableAscii (ascii);
|
||||
p2p.SetChannelParameter ("BitRate", DataRate(10000000));
|
||||
p2p.SetChannelParameter ("Delay", MilliSeconds(10));
|
||||
NetDeviceContainer dev0 = p2p.Build (c0);
|
||||
@@ -185,6 +180,12 @@ int main (int argc, char *argv[])
|
||||
Config::ConnectWithoutContext ("/NodeList/*/ApplicationList/*/Rx",
|
||||
MakeCallback (&ApplicationTraceSink));
|
||||
|
||||
std::ofstream ascii;
|
||||
ascii.open ("tcp-large-transfer.tr");
|
||||
PointToPointHelper::EnablePcap ("tcp-large-transfer.pcap");
|
||||
PointToPointHelper::EnableAscii (ascii);
|
||||
|
||||
|
||||
Simulator::StopAt (Seconds(1000));
|
||||
Simulator::Run ();
|
||||
Simulator::Destroy ();
|
||||
|
||||
@@ -82,16 +82,11 @@ main (int argc, char *argv[])
|
||||
InternetStackHelper internet;
|
||||
internet.Build (n);
|
||||
|
||||
std::ofstream ascii;
|
||||
ascii.open ("udp-echo.tr");
|
||||
|
||||
NS_LOG_INFO ("Create channels.");
|
||||
//
|
||||
// Explicitly create the channels required by the topology (shown above).
|
||||
//
|
||||
CsmaHelper csma;
|
||||
csma.EnablePcap ("udp-echo.pcap");
|
||||
csma.EnableAscii (ascii);
|
||||
csma.SetChannelParameter ("BitRate", DataRate(5000000));
|
||||
csma.SetChannelParameter ("Delay", MilliSeconds (2));
|
||||
NetDeviceContainer d = csma.Build (n);
|
||||
@@ -131,6 +126,11 @@ main (int argc, char *argv[])
|
||||
apps.Start (Seconds (2.0));
|
||||
apps.Stop (Seconds (10.0));
|
||||
|
||||
std::ofstream ascii;
|
||||
ascii.open ("udp-echo.tr");
|
||||
CsmaHelper::EnablePcap ("udp-echo.pcap");
|
||||
CsmaHelper::EnableAscii (ascii);
|
||||
|
||||
//
|
||||
// Now, do the actual simulation.
|
||||
//
|
||||
|
||||
@@ -11,8 +11,6 @@
|
||||
namespace ns3 {
|
||||
|
||||
CsmaHelper::CsmaHelper ()
|
||||
: m_pcap (false),
|
||||
m_ascii (false)
|
||||
{
|
||||
m_queueFactory.SetTypeId ("ns3::DropTailQueue");
|
||||
m_deviceFactory.SetTypeId ("ns3::CsmaNetDevice");
|
||||
@@ -46,27 +44,92 @@ CsmaHelper::SetChannelParameter (std::string n1, Attribute v1)
|
||||
}
|
||||
|
||||
void
|
||||
CsmaHelper::EnablePcap (std::string filename)
|
||||
CsmaHelper::EnablePcap (std::string filename, uint32_t nodeid, uint32_t deviceid)
|
||||
{
|
||||
m_pcap = true;
|
||||
m_pcapFilename = filename;
|
||||
std::ostringstream oss;
|
||||
oss << filename << "-" << nodeid << "-" << deviceid;
|
||||
Ptr<PcapWriter> pcap = Create<PcapWriter> ();
|
||||
pcap->Open (oss.str ());
|
||||
pcap->WriteEthernetHeader ();
|
||||
oss.str ("");
|
||||
oss << "/NodeList/" << nodeid << "/DeviceList/" << deviceid << "/$ns3::CsmaNetDevice/Rx";
|
||||
Config::ConnectWithoutContext (oss.str (), MakeBoundCallback (&CsmaHelper::RxEvent, pcap));
|
||||
oss.str ("");
|
||||
oss << "/NodeList/" << nodeid << "/DeviceList/" << deviceid << "/$ns3::CsmaNetDevice/TxQueue/Enqueue";
|
||||
Config::ConnectWithoutContext (oss.str (), MakeBoundCallback (&CsmaHelper::EnqueueEvent, pcap));
|
||||
}
|
||||
void
|
||||
CsmaHelper::DisablePcap (void)
|
||||
CsmaHelper::EnablePcap (std::string filename, NetDeviceContainer d)
|
||||
{
|
||||
m_pcap = false;
|
||||
for (NetDeviceContainer::Iterator i = d.Begin (); i != d.End (); ++i)
|
||||
{
|
||||
Ptr<NetDevice> dev = *i;
|
||||
EnablePcap (filename, dev->GetNode ()->GetId (), dev->GetIfIndex ());
|
||||
}
|
||||
}
|
||||
void
|
||||
CsmaHelper::EnablePcap (std::string filename, NodeContainer n)
|
||||
{
|
||||
NetDeviceContainer devs;
|
||||
for (NodeContainer::Iterator i = n.Begin (); i != n.End (); ++i)
|
||||
{
|
||||
Ptr<Node> node = *i;
|
||||
for (uint32_t j = 0; j < node->GetNDevices (); ++j)
|
||||
{
|
||||
devs.Add (node->GetDevice (j));
|
||||
}
|
||||
}
|
||||
EnablePcap (filename, devs);
|
||||
}
|
||||
|
||||
void
|
||||
CsmaHelper::EnablePcap (std::string filename)
|
||||
{
|
||||
EnablePcap (filename, NodeContainer::GetGlobal ());
|
||||
}
|
||||
|
||||
void
|
||||
CsmaHelper::EnableAscii (std::ostream &os)
|
||||
CsmaHelper::EnableAscii (std::ostream &os, uint32_t nodeid, uint32_t deviceid)
|
||||
{
|
||||
m_ascii = true;
|
||||
m_asciiOs = &os;
|
||||
Packet::EnableMetadata ();
|
||||
std::ostringstream oss;
|
||||
oss << "/NodeList/" << nodeid << "/DeviceList/" << deviceid << "/$ns3::CsmaNetDevice/Rx";
|
||||
Config::Connect (oss.str (), MakeBoundCallback (&CsmaHelper::AsciiEvent, &os));
|
||||
oss.str ("");
|
||||
oss << "/NodeList/" << nodeid << "/DeviceList/" << deviceid << "/$ns3::CsmaNetDevice/TxQueue/Enqueue";
|
||||
Config::Connect (oss.str (), MakeBoundCallback (&CsmaHelper::AsciiEvent, &os));
|
||||
oss.str ("");
|
||||
oss << "/NodeList/" << nodeid << "/DeviceList/" << deviceid << "/$ns3::CsmaNetDevice/TxQueue/Dequeue";
|
||||
Config::Connect (oss.str (), MakeBoundCallback (&CsmaHelper::AsciiEvent, &os));
|
||||
}
|
||||
void
|
||||
CsmaHelper::DisableAscii (void)
|
||||
CsmaHelper::EnableAscii (std::ostream &os, NetDeviceContainer d)
|
||||
{
|
||||
m_ascii = false;
|
||||
for (NetDeviceContainer::Iterator i = d.Begin (); i != d.End (); ++i)
|
||||
{
|
||||
Ptr<NetDevice> dev = *i;
|
||||
EnableAscii (os, dev->GetNode ()->GetId (), dev->GetIfIndex ());
|
||||
}
|
||||
}
|
||||
void
|
||||
CsmaHelper::EnableAscii (std::ostream &os, NodeContainer n)
|
||||
{
|
||||
NetDeviceContainer devs;
|
||||
for (NodeContainer::Iterator i = n.Begin (); i != n.End (); ++i)
|
||||
{
|
||||
Ptr<Node> node = *i;
|
||||
for (uint32_t j = 0; j < node->GetNDevices (); ++j)
|
||||
{
|
||||
devs.Add (node->GetDevice (j));
|
||||
}
|
||||
}
|
||||
EnableAscii (os, devs);
|
||||
}
|
||||
|
||||
void
|
||||
CsmaHelper::EnableAscii (std::ostream &os)
|
||||
{
|
||||
EnableAscii (os, NodeContainer::GetGlobal ());
|
||||
}
|
||||
|
||||
|
||||
@@ -90,31 +153,6 @@ CsmaHelper::Build (const NodeContainer &c, Ptr<CsmaChannel> channel)
|
||||
Ptr<Queue> queue = m_queueFactory.Create<Queue> ();
|
||||
device->AddQueue (queue);
|
||||
device->Attach (channel);
|
||||
if (m_pcap)
|
||||
{
|
||||
std::ostringstream oss;
|
||||
oss << m_pcapFilename << "-" << node->GetId () << "-" << device->GetIfIndex ();
|
||||
std::string filename = oss.str ();
|
||||
Ptr<PcapWriter> pcap = Create<PcapWriter> ();
|
||||
pcap->Open (filename);
|
||||
pcap->WriteEthernetHeader ();
|
||||
device->TraceConnectWithoutContext ("Rx", MakeBoundCallback (&CsmaHelper::RxEvent, pcap));
|
||||
queue->TraceConnectWithoutContext ("Enqueue", MakeBoundCallback (&CsmaHelper::EnqueueEvent, pcap));
|
||||
}
|
||||
if (m_ascii)
|
||||
{
|
||||
Packet::EnableMetadata ();
|
||||
std::ostringstream oss;
|
||||
oss << "/NodeList/" << node->GetId () << "/DeviceList/" << device->GetIfIndex () << "/Rx";
|
||||
Config::Connect (oss.str (), MakeBoundCallback (&CsmaHelper::AsciiEvent, m_asciiOs));
|
||||
oss.str ("");
|
||||
oss << "/NodeList/" << node->GetId () << "/DeviceList/" << device->GetIfIndex () << "/TxQueue/Enqueue";
|
||||
Config::Connect (oss.str (), MakeBoundCallback (&CsmaHelper::AsciiEvent, m_asciiOs));
|
||||
oss.str ("");
|
||||
oss << "/NodeList/" << node->GetId () << "/DeviceList/" << device->GetIfIndex () << "/TxQueue/Dequeue";
|
||||
Config::Connect (oss.str (), MakeBoundCallback (&CsmaHelper::AsciiEvent, m_asciiOs));
|
||||
|
||||
}
|
||||
container.Add (device);
|
||||
}
|
||||
return container;
|
||||
|
||||
@@ -60,35 +60,15 @@ public:
|
||||
*/
|
||||
void SetChannelParameter (std::string n1, Attribute v1);
|
||||
|
||||
/**
|
||||
* \param filename file template to dump pcap traces in.
|
||||
*
|
||||
* Every ns3::CsmaNetDevice created through subsequent calls
|
||||
* to CsmaHelper::Build will be configured to dump
|
||||
* pcap output in a file named filename-nodeid-deviceid.
|
||||
*/
|
||||
void EnablePcap (std::string filename);
|
||||
/**
|
||||
* Every ns3::CsmaNetDevice created through subsequent calls
|
||||
* to CsmaHelper::Build will be configured to not dump any pcap
|
||||
* output.
|
||||
*/
|
||||
void DisablePcap (void);
|
||||
static void EnablePcap (std::string filename, uint32_t nodeid, uint32_t deviceid);
|
||||
static void EnablePcap (std::string filename, NetDeviceContainer d);
|
||||
static void EnablePcap (std::string filename, NodeContainer n);
|
||||
static void EnablePcap (std::string filename);
|
||||
|
||||
/**
|
||||
* \param os an output stream where ascii trace should be sent.
|
||||
*
|
||||
* Every ns3::CsmaNetDevice created through subsequent calls
|
||||
* to CsmaHelper::Build will be configured to dump Rx, EnQueue
|
||||
* and Dequeue events as ascii data in the specified output stream.
|
||||
*/
|
||||
void EnableAscii (std::ostream &os);
|
||||
/**
|
||||
* Every ns3::CsmaNetDevice created through subsequent calls
|
||||
* to CsmaHelper::Build will be configured to not dump any
|
||||
* ascii output.
|
||||
*/
|
||||
void DisableAscii (void);
|
||||
static void EnableAscii (std::ostream &os, uint32_t nodeid, uint32_t deviceid);
|
||||
static void EnableAscii (std::ostream &os, NetDeviceContainer d);
|
||||
static void EnableAscii (std::ostream &os, NodeContainer n);
|
||||
static void EnableAscii (std::ostream &os);
|
||||
|
||||
/**
|
||||
* \param c a set of nodes
|
||||
@@ -116,10 +96,6 @@ private:
|
||||
ObjectFactory m_queueFactory;
|
||||
ObjectFactory m_deviceFactory;
|
||||
ObjectFactory m_channelFactory;
|
||||
bool m_pcap;
|
||||
std::string m_pcapFilename;
|
||||
bool m_ascii;
|
||||
std::ostream *m_asciiOs;
|
||||
};
|
||||
|
||||
|
||||
|
||||
@@ -43,57 +43,93 @@ PointToPointHelper::SetChannelParameter (std::string n1, Attribute v1)
|
||||
m_channelFactory.Set (n1, v1);
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
PointToPointHelper::EnablePcap (std::string filename)
|
||||
{
|
||||
m_pcap = true;
|
||||
m_pcapFilename = filename;
|
||||
}
|
||||
void
|
||||
PointToPointHelper::DisablePcap (void)
|
||||
{
|
||||
m_pcap = false;
|
||||
}
|
||||
|
||||
void
|
||||
PointToPointHelper::EnableAscii (std::ostream &os)
|
||||
{
|
||||
m_ascii = true;
|
||||
m_asciiOs = &os;
|
||||
}
|
||||
void
|
||||
PointToPointHelper::DisableAscii (void)
|
||||
{
|
||||
m_ascii = false;
|
||||
}
|
||||
|
||||
void
|
||||
PointToPointHelper::EnablePcap (Ptr<Node> node, Ptr<NetDevice> device, Ptr<Queue> queue)
|
||||
PointToPointHelper::EnablePcap (std::string filename, uint32_t nodeid, uint32_t deviceid)
|
||||
{
|
||||
std::ostringstream oss;
|
||||
oss << m_pcapFilename << "-" << node->GetId () << "-" << device->GetIfIndex ();
|
||||
std::string filename = oss.str ();
|
||||
oss << filename << "-" << nodeid << "-" << deviceid;
|
||||
Ptr<PcapWriter> pcap = Create<PcapWriter> ();
|
||||
pcap->Open (filename);
|
||||
pcap->Open (oss.str ());
|
||||
pcap->WriteEthernetHeader ();
|
||||
device->TraceConnectWithoutContext ("Rx", MakeBoundCallback (&PointToPointHelper::RxEvent, pcap));
|
||||
queue->TraceConnectWithoutContext ("Enqueue", MakeBoundCallback (&PointToPointHelper::EnqueueEvent, pcap));
|
||||
oss.str ("");
|
||||
oss << "/NodeList/" << nodeid << "/DeviceList/" << deviceid << "/$ns3::PointToPointNetDevice/Rx";
|
||||
Config::ConnectWithoutContext (oss.str (), MakeBoundCallback (&PointToPointHelper::RxEvent, pcap));
|
||||
oss.str ("");
|
||||
oss << "/NodeList/" << nodeid << "/DeviceList/" << deviceid << "/$ns3::PointToPointNetDevice/TxQueue/Enqueue";
|
||||
Config::ConnectWithoutContext (oss.str (), MakeBoundCallback (&PointToPointHelper::EnqueueEvent, pcap));
|
||||
}
|
||||
void
|
||||
PointToPointHelper::EnablePcap (std::string filename, NetDeviceContainer d)
|
||||
{
|
||||
for (NetDeviceContainer::Iterator i = d.Begin (); i != d.End (); ++i)
|
||||
{
|
||||
Ptr<NetDevice> dev = *i;
|
||||
EnablePcap (filename, dev->GetNode ()->GetId (), dev->GetIfIndex ());
|
||||
}
|
||||
}
|
||||
void
|
||||
PointToPointHelper::EnablePcap (std::string filename, NodeContainer n)
|
||||
{
|
||||
NetDeviceContainer devs;
|
||||
for (NodeContainer::Iterator i = n.Begin (); i != n.End (); ++i)
|
||||
{
|
||||
Ptr<Node> node = *i;
|
||||
for (uint32_t j = 0; j < node->GetNDevices (); ++j)
|
||||
{
|
||||
devs.Add (node->GetDevice (j));
|
||||
}
|
||||
}
|
||||
EnablePcap (filename, devs);
|
||||
}
|
||||
|
||||
void
|
||||
PointToPointHelper::EnableAscii (Ptr<Node> node, Ptr<NetDevice> device)
|
||||
PointToPointHelper::EnablePcap (std::string filename)
|
||||
{
|
||||
EnablePcap (filename, NodeContainer::GetGlobal ());
|
||||
}
|
||||
|
||||
void
|
||||
PointToPointHelper::EnableAscii (std::ostream &os, uint32_t nodeid, uint32_t deviceid)
|
||||
{
|
||||
Packet::EnableMetadata ();
|
||||
std::ostringstream oss;
|
||||
oss << "/NodeList/" << node->GetId () << "/DeviceList/" << device->GetIfIndex () << "/Rx";
|
||||
Config::Connect (oss.str (), MakeBoundCallback (&PointToPointHelper::AsciiEvent, m_asciiOs));
|
||||
oss << "/NodeList/" << nodeid << "/DeviceList/" << deviceid << "/$ns3::PointToPointNetDevice/Rx";
|
||||
Config::Connect (oss.str (), MakeBoundCallback (&PointToPointHelper::AsciiEvent, &os));
|
||||
oss.str ("");
|
||||
oss << "/NodeList/" << node->GetId () << "/DeviceList/" << device->GetIfIndex () << "/TxQueue/Enqueue";
|
||||
Config::Connect (oss.str (), MakeBoundCallback (&PointToPointHelper::AsciiEvent, m_asciiOs));
|
||||
oss << "/NodeList/" << nodeid << "/DeviceList/" << deviceid << "/$ns3::PointToPointNetDevice/TxQueue/Enqueue";
|
||||
Config::Connect (oss.str (), MakeBoundCallback (&PointToPointHelper::AsciiEvent, &os));
|
||||
oss.str ("");
|
||||
oss << "/NodeList/" << node->GetId () << "/DeviceList/" << device->GetIfIndex () << "/TxQueue/Dequeue";
|
||||
Config::Connect (oss.str (), MakeBoundCallback (&PointToPointHelper::AsciiEvent, m_asciiOs));
|
||||
oss << "/NodeList/" << nodeid << "/DeviceList/" << deviceid << "/$ns3::PointToPointNetDevice/TxQueue/Dequeue";
|
||||
Config::Connect (oss.str (), MakeBoundCallback (&PointToPointHelper::AsciiEvent, &os));
|
||||
}
|
||||
void
|
||||
PointToPointHelper::EnableAscii (std::ostream &os, NetDeviceContainer d)
|
||||
{
|
||||
for (NetDeviceContainer::Iterator i = d.Begin (); i != d.End (); ++i)
|
||||
{
|
||||
Ptr<NetDevice> dev = *i;
|
||||
EnableAscii (os, dev->GetNode ()->GetId (), dev->GetIfIndex ());
|
||||
}
|
||||
}
|
||||
void
|
||||
PointToPointHelper::EnableAscii (std::ostream &os, NodeContainer n)
|
||||
{
|
||||
NetDeviceContainer devs;
|
||||
for (NodeContainer::Iterator i = n.Begin (); i != n.End (); ++i)
|
||||
{
|
||||
Ptr<Node> node = *i;
|
||||
for (uint32_t j = 0; j < node->GetNDevices (); ++j)
|
||||
{
|
||||
devs.Add (node->GetDevice (j));
|
||||
}
|
||||
}
|
||||
EnableAscii (os, devs);
|
||||
}
|
||||
|
||||
void
|
||||
PointToPointHelper::EnableAscii (std::ostream &os)
|
||||
{
|
||||
EnableAscii (os, NodeContainer::GetGlobal ());
|
||||
}
|
||||
|
||||
NetDeviceContainer
|
||||
@@ -120,17 +156,6 @@ PointToPointHelper::Build (Ptr<Node> a, Ptr<Node> b)
|
||||
Ptr<PointToPointChannel> channel = m_channelFactory.Create<PointToPointChannel> ();
|
||||
devA->Attach (channel);
|
||||
devB->Attach (channel);
|
||||
if (m_pcap)
|
||||
{
|
||||
EnablePcap (a, devA, queueA);
|
||||
EnablePcap (b, devB, queueB);
|
||||
}
|
||||
if (m_ascii)
|
||||
{
|
||||
EnableAscii (a, devA);
|
||||
EnableAscii (b, devB);
|
||||
}
|
||||
|
||||
container.Add (devA);
|
||||
container.Add (devB);
|
||||
|
||||
|
||||
@@ -59,35 +59,15 @@ public:
|
||||
*/
|
||||
void SetChannelParameter (std::string name, Attribute value);
|
||||
|
||||
/**
|
||||
* \param filename file template to dump pcap traces in.
|
||||
*
|
||||
* Every ns3::PointToPointNetDevice created through subsequent calls
|
||||
* to PointToPointHelper::Build will be configured to dump
|
||||
* pcap output in a file named filename-nodeid-deviceid.
|
||||
*/
|
||||
void EnablePcap (std::string filename);
|
||||
/**
|
||||
* Every ns3::PointToPointNetDevice created through subsequent calls
|
||||
* to PointToPointHelper::Build will be configured to not dump any pcap
|
||||
* output.
|
||||
*/
|
||||
void DisablePcap (void);
|
||||
static void EnablePcap (std::string filename, uint32_t nodeid, uint32_t deviceid);
|
||||
static void EnablePcap (std::string filename, NetDeviceContainer d);
|
||||
static void EnablePcap (std::string filename, NodeContainer n);
|
||||
static void EnablePcap (std::string filename);
|
||||
|
||||
/**
|
||||
* \param os an output stream where ascii trace should be sent.
|
||||
*
|
||||
* Every ns3::PointToPointNetDevice created through subsequent calls
|
||||
* to PointToPointHelper::Build will be configured to dump Rx, EnQueue
|
||||
* and Dequeue events as ascii data in the specified output stream.
|
||||
*/
|
||||
void EnableAscii (std::ostream &os);
|
||||
/**
|
||||
* Every ns3::PointToPointNetDevice created through subsequent calls
|
||||
* to PointToPointHelper::Build will be configured to not dump any
|
||||
* ascii output.
|
||||
*/
|
||||
void DisableAscii (void);
|
||||
static void EnableAscii (std::ostream &os, uint32_t nodeid, uint32_t deviceid);
|
||||
static void EnableAscii (std::ostream &os, NetDeviceContainer d);
|
||||
static void EnableAscii (std::ostream &os, NodeContainer n);
|
||||
static void EnableAscii (std::ostream &os);
|
||||
|
||||
/**
|
||||
* \param c a set of nodes
|
||||
@@ -117,10 +97,6 @@ private:
|
||||
ObjectFactory m_queueFactory;
|
||||
ObjectFactory m_channelFactory;
|
||||
ObjectFactory m_deviceFactory;
|
||||
bool m_pcap;
|
||||
std::string m_pcapFilename;
|
||||
bool m_ascii;
|
||||
std::ostream *m_asciiOs;
|
||||
};
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user