Enable both ascii and pcap tracing
This commit is contained in:
@@ -75,7 +75,7 @@ int main (int argc, char *argv[])
|
||||
|
||||
// Users may find it convenient to turn on explicit debugging
|
||||
// for selected modules; the below lines suggest how to do this
|
||||
#if 0
|
||||
#if 0
|
||||
DebugComponentEnable("Object");
|
||||
DebugComponentEnable("Queue");
|
||||
DebugComponentEnable("DropTailQueue");
|
||||
@@ -108,25 +108,32 @@ int main (int argc, char *argv[])
|
||||
// We create the channels first without any IP addressing information
|
||||
PointToPointChannel *channel0 =
|
||||
PointToPointTopology::AddPointToPointLink (
|
||||
n0, Ipv4Address("10.1.1.1"),
|
||||
n2, Ipv4Address("10.1.1.2"),
|
||||
DataRate(5000000), MilliSeconds(2));
|
||||
channel0->Unref ();
|
||||
|
||||
n0, n2, DataRate(5000000), MilliSeconds(2));
|
||||
|
||||
PointToPointChannel *channel1 =
|
||||
PointToPointTopology::AddPointToPointLink (
|
||||
n1, Ipv4Address("10.1.2.1"),
|
||||
n2, Ipv4Address("10.1.2.2"),
|
||||
DataRate(5000000), MilliSeconds(2));
|
||||
channel1->Unref ();
|
||||
|
||||
n1, n2, DataRate(5000000), MilliSeconds(2));
|
||||
|
||||
PointToPointChannel *channel2 =
|
||||
PointToPointTopology::AddPointToPointLink (
|
||||
n2, Ipv4Address("10.1.3.1"),
|
||||
n3, Ipv4Address("10.1.3.2"),
|
||||
DataRate(1500000), MilliSeconds(10));
|
||||
channel2->Unref ();
|
||||
n2, n3, DataRate(1500000), MilliSeconds(10));
|
||||
|
||||
// Later, we add IP addresses.
|
||||
PointToPointTopology::AddIpv4Addresses (
|
||||
channel0, n0, Ipv4Address("10.1.1.1"),
|
||||
n2, Ipv4Address("10.1.1.2"));
|
||||
channel0->Unref ();
|
||||
|
||||
PointToPointTopology::AddIpv4Addresses (
|
||||
channel1, n1, Ipv4Address("10.1.2.1"),
|
||||
n2, Ipv4Address("10.1.2.2"));
|
||||
channel1->Unref ();
|
||||
|
||||
PointToPointTopology::AddIpv4Addresses (
|
||||
channel2, n2, Ipv4Address("10.1.3.1"),
|
||||
n3, Ipv4Address("10.1.3.2"));
|
||||
channel2->Unref ();
|
||||
|
||||
// Create the OnOff application to send UDP datagrams of size
|
||||
// 210 bytes at a rate of 448 Kb/s
|
||||
OnOffApplication* ooff0 = new OnOffApplication(
|
||||
@@ -138,9 +145,11 @@ int main (int argc, char *argv[])
|
||||
DataRate(448000),
|
||||
210);
|
||||
// Add to Node's ApplicationList (takes ownership of pointer)
|
||||
ApplicationList *apl0 = n0->QueryInterface<ApplicationList> (ApplicationList::iid);
|
||||
ApplicationList *apl0 = n0->QueryInterface<ApplicationList>
|
||||
(ApplicationList::iid);
|
||||
apl0->Add(ooff0);
|
||||
apl0->Unref ();
|
||||
|
||||
// Start the application
|
||||
ooff0->Start(Seconds(1.0));
|
||||
ooff0->Stop (Seconds(10.0));
|
||||
@@ -181,14 +190,15 @@ int main (int argc, char *argv[])
|
||||
|
||||
// Configure tracing of all enqueue, dequeue, and NetDevice receive events
|
||||
// Trace output will be sent to the simple-p2p.tr file
|
||||
#if 1
|
||||
AsciiTrace trace ("simple-p2p.tr");
|
||||
trace.TraceAllQueues ();
|
||||
trace.TraceAllNetDeviceRx ();
|
||||
#else
|
||||
PcapTrace trace ("simple-p2p.tr");
|
||||
trace.TraceAllIp ();
|
||||
#endif
|
||||
AsciiTrace asciitrace ("simple-p2p.tr");
|
||||
asciitrace.TraceAllQueues ();
|
||||
asciitrace.TraceAllNetDeviceRx ();
|
||||
|
||||
// Also configure some tcpdump traces; each interface will be traced
|
||||
// The output files will be named simple-p2p.pcap-<nodeId>-<interfaceId>
|
||||
// and can be read by the "tcpdump -r" command
|
||||
PcapTrace pcaptrace ("simple-p2p.pcap");
|
||||
pcaptrace.TraceAllIp ();
|
||||
|
||||
Simulator::Run ();
|
||||
|
||||
|
||||
@@ -22,7 +22,7 @@
|
||||
// Topology helper for ns3.
|
||||
// George F. Riley, Georgia Tech, Spring 2007
|
||||
|
||||
#include "ns3/debug.h"
|
||||
#include <algorithm>
|
||||
#include "ns3/assert.h"
|
||||
|
||||
#include "ns3/nstime.h"
|
||||
@@ -36,58 +36,78 @@
|
||||
#include "p2p-net-device.h"
|
||||
#include "p2p-topology.h"
|
||||
|
||||
#define nil 0
|
||||
|
||||
namespace ns3 {
|
||||
|
||||
PointToPointChannel *
|
||||
PointToPointTopology::AddPointToPointLink(
|
||||
Node* n1,
|
||||
const Ipv4Address& addr1,
|
||||
Node* n2,
|
||||
const Ipv4Address& addr2,
|
||||
const DataRate& bps,
|
||||
const Time& delay)
|
||||
{
|
||||
// Duplex link is assumed to be subnetted as a /30
|
||||
// May run this unnumbered in the future?
|
||||
Ipv4Mask netmask("255.255.255.252");
|
||||
NS_ASSERT (netmask.IsMatch(addr1,addr2));
|
||||
|
||||
// create channel expicitly (XXX no reference counting here yet)
|
||||
PointToPointChannel* channel = new PointToPointChannel(bps, delay);
|
||||
|
||||
PointToPointNetDevice* net1 = new PointToPointNetDevice(n1);
|
||||
net1->AddQueue(Queue::Default().Copy());
|
||||
n1->AddDevice (net1);
|
||||
IIpv4 *ip1 = n1->QueryInterface<IIpv4> (IIpv4::iid);
|
||||
uint32_t index1 = ip1->AddInterface (net1);
|
||||
net1->Attach (channel);
|
||||
net1->Unref ();
|
||||
|
||||
PointToPointNetDevice* net2 = new PointToPointNetDevice(n2);
|
||||
net2->AddQueue(Queue::Default().Copy());
|
||||
n2->AddDevice (net2);
|
||||
net2->Attach (channel);
|
||||
net2->Unref ();
|
||||
|
||||
return channel;
|
||||
}
|
||||
|
||||
bool
|
||||
PointToPointTopology::AddIpv4Addresses(
|
||||
const PointToPointChannel *chan,
|
||||
Node* n1, const Ipv4Address& addr1,
|
||||
Node* n2, const Ipv4Address& addr2)
|
||||
{
|
||||
|
||||
// Duplex link is assumed to be subnetted as a /30
|
||||
// May run this unnumbered in the future?
|
||||
Ipv4Mask netmask("255.255.255.252");
|
||||
NS_ASSERT (netmask.IsMatch(addr1,addr2));
|
||||
|
||||
// The PointToPoint channel is used to find the relevant NetDevices
|
||||
NS_ASSERT (chan->GetNDevices () == 2);
|
||||
NetDevice* nd1 = chan->GetDevice (0);
|
||||
NetDevice* nd2 = chan->GetDevice (1);
|
||||
// Make sure that nd1 belongs to n1 and nd2 to n2
|
||||
if ( (nd1->PeekNode ()->GetId () == n2->GetId () ) &&
|
||||
(nd2->PeekNode ()->GetId () == n1->GetId () ) )
|
||||
{
|
||||
std::swap(nd1, nd2);
|
||||
}
|
||||
NS_ASSERT (nd1->PeekNode ()->GetId () == n1->GetId ());
|
||||
NS_ASSERT (nd2->PeekNode ()->GetId () == n2->GetId ());
|
||||
|
||||
IIpv4 *ip1 = n1->QueryInterface<IIpv4> (IIpv4::iid);
|
||||
uint32_t index1 = ip1->AddInterface (nd1);
|
||||
|
||||
ip1->SetAddress (index1, addr1);
|
||||
ip1->SetNetworkMask (index1, netmask);
|
||||
ip1->SetUp (index1);
|
||||
|
||||
PointToPointNetDevice* net2 = new PointToPointNetDevice(n2);
|
||||
net2->AddQueue(Queue::Default().Copy());
|
||||
n2->AddDevice (net2);
|
||||
IIpv4 *ip2 = n2->QueryInterface<IIpv4> (IIpv4::iid);
|
||||
uint32_t index2 = ip2->AddInterface (net2);
|
||||
net2->Attach (channel);
|
||||
net2->Unref ();
|
||||
uint32_t index2 = ip2->AddInterface (nd2);
|
||||
|
||||
ip2->SetAddress (index2, addr2);
|
||||
ip2->SetNetworkMask (index2, netmask);
|
||||
ip2->SetUp (index2);
|
||||
|
||||
|
||||
ip1->AddHostRouteTo (addr2, index1);
|
||||
ip2->AddHostRouteTo (addr1, index2);
|
||||
|
||||
|
||||
ip1->Unref ();
|
||||
ip2->Unref ();
|
||||
|
||||
return channel;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
#ifdef NOTYET
|
||||
|
||||
@@ -51,10 +51,12 @@ public:
|
||||
* and propagation delay.
|
||||
*/
|
||||
static PointToPointChannel* AddPointToPointLink(
|
||||
Node*, const Ipv4Address&,
|
||||
Node*, Node*, const DataRate&, const Time&);
|
||||
|
||||
static bool AddIpv4Addresses(
|
||||
const PointToPointChannel*,
|
||||
Node*, const Ipv4Address&,
|
||||
const DataRate&,
|
||||
const Time&);
|
||||
Node*, const Ipv4Address&);
|
||||
|
||||
/**
|
||||
* Get the connecting node n1 to node n2
|
||||
|
||||
@@ -80,6 +80,18 @@ NetDevice::GetName(void) const
|
||||
return m_name;
|
||||
}
|
||||
|
||||
void
|
||||
NetDevice::SetIfIndex(uint32_t index)
|
||||
{
|
||||
m_ifIndex = index;
|
||||
}
|
||||
|
||||
uint32_t
|
||||
NetDevice::GetIfIndex(void) const
|
||||
{
|
||||
return m_ifIndex;
|
||||
}
|
||||
|
||||
bool
|
||||
NetDevice::IsLinkUp (void) const
|
||||
{
|
||||
|
||||
@@ -106,6 +106,14 @@ public:
|
||||
* \return name name of the device (e.g. "eth0")
|
||||
*/
|
||||
std::string GetName(void) const;
|
||||
/**
|
||||
* \param index ifIndex of the device
|
||||
*/
|
||||
void SetIfIndex(const uint32_t);
|
||||
/**
|
||||
* \return index ifIndex of the device
|
||||
*/
|
||||
uint32_t GetIfIndex(void) const;
|
||||
/**
|
||||
* \return true if link is up; false otherwise
|
||||
*/
|
||||
@@ -153,6 +161,15 @@ public:
|
||||
* \return whether the Send operation succeeded
|
||||
*/
|
||||
bool Send(Packet& p, const MacAddress& dest, uint16_t protocolNumber);
|
||||
/**
|
||||
* \returns the node base class which contains this network
|
||||
* interface.
|
||||
*
|
||||
* When a subclass needs to get access to the underlying node
|
||||
* base class to print the nodeid for example, it can invoke
|
||||
* this method.
|
||||
*/
|
||||
Node* PeekNode (void) const;
|
||||
|
||||
bool NeedsArp (void) const;
|
||||
|
||||
@@ -195,15 +212,6 @@ public:
|
||||
* down, it notifies its parent class by calling this method.
|
||||
*/
|
||||
void NotifyLinkDown (void);
|
||||
/**
|
||||
* \returns the node base class which contains this network
|
||||
* interface.
|
||||
*
|
||||
* When a subclass needs to get access to the underlying node
|
||||
* base class to print the nodeid for example, it can invoke
|
||||
* this method.
|
||||
*/
|
||||
Node* PeekNode (void) const;
|
||||
|
||||
/**
|
||||
* \param p packet sent from below up to Network Device
|
||||
|
||||
@@ -75,6 +75,7 @@ Node::AddDevice (NetDevice *device)
|
||||
uint32_t index = m_devices.size ();
|
||||
m_devices.push_back (device);
|
||||
DoAddDevice (device);
|
||||
device->SetIfIndex(index);
|
||||
return index;
|
||||
}
|
||||
NetDevice *
|
||||
|
||||
Reference in New Issue
Block a user