merge with HEAD
This commit is contained in:
@@ -113,10 +113,10 @@ main (int argc, char *argv[])
|
||||
// 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");
|
||||
CsmaHelper::EnablePcapAll ("csma-broadcast");
|
||||
std::ofstream ascii;
|
||||
ascii.open ("csma-broadcast.tr");
|
||||
CsmaHelper::EnableAscii (ascii);
|
||||
CsmaHelper::EnableAsciiAll (ascii);
|
||||
|
||||
NS_LOG_INFO ("Run Simulation.");
|
||||
Simulator::Run ();
|
||||
|
||||
@@ -172,14 +172,14 @@ main (int argc, char *argv[])
|
||||
//
|
||||
std::ofstream ascii;
|
||||
ascii.open ("csma-multicast.tr");
|
||||
CsmaHelper::EnableAscii (ascii);
|
||||
CsmaHelper::EnableAsciiAll (ascii);
|
||||
|
||||
// Also configure some tcpdump traces; each interface will be traced.
|
||||
// The output files will be named:
|
||||
// csma-multicast.pcap-<nodeId>-<interfaceId>
|
||||
// and can be read by the "tcpdump -r" command (use "-tt" option to
|
||||
// display timestamps correctly)
|
||||
CsmaHelper::EnablePcap ("csma-multicast");
|
||||
CsmaHelper::EnablePcapAll ("csma-multicast");
|
||||
//
|
||||
// Now, do the actual simulation.
|
||||
//
|
||||
|
||||
@@ -128,7 +128,7 @@ main (int argc, char *argv[])
|
||||
NS_LOG_INFO ("Configure Tracing.");
|
||||
std::ofstream ascii;
|
||||
ascii.open ("csma-one-subnet.tr");
|
||||
CsmaHelper::EnableAscii (ascii);
|
||||
CsmaHelper::EnableAsciiAll (ascii);
|
||||
//
|
||||
// Also configure some tcpdump traces; each interface will be traced.
|
||||
// The output files will be named:
|
||||
@@ -136,7 +136,7 @@ main (int argc, char *argv[])
|
||||
// and can be read by the "tcpdump -r" command (use "-tt" option to
|
||||
// display timestamps correctly)
|
||||
//
|
||||
CsmaHelper::EnablePcap ("csma-one-subnet");
|
||||
CsmaHelper::EnablePcapAll ("csma-one-subnet");
|
||||
//
|
||||
// Now, do the actual simulation.
|
||||
//
|
||||
|
||||
@@ -125,10 +125,10 @@ main (int argc, char *argv[])
|
||||
|
||||
std::ofstream ascii;
|
||||
ascii.open ("mixed-global-routing.tr");
|
||||
PointToPointHelper::EnablePcap ("mixed-global-routing");
|
||||
PointToPointHelper::EnableAscii (ascii);
|
||||
CsmaHelper::EnablePcap ("mixed-global-routing");
|
||||
CsmaHelper::EnableAscii (ascii);
|
||||
PointToPointHelper::EnablePcapAll ("mixed-global-routing");
|
||||
PointToPointHelper::EnableAsciiAll (ascii);
|
||||
CsmaHelper::EnablePcapAll ("mixed-global-routing");
|
||||
CsmaHelper::EnableAsciiAll (ascii);
|
||||
|
||||
|
||||
NS_LOG_INFO ("Run Simulation.");
|
||||
|
||||
@@ -166,7 +166,7 @@ main (int argc, char *argv[])
|
||||
"Bounds", RectangleValue (Rectangle (0, 1000, 0, 1000)),
|
||||
"Speed", RandomVariableValue (ConstantVariable (2000)),
|
||||
"Pause", RandomVariableValue (ConstantVariable (0.2)));
|
||||
mobility.Layout (backbone);
|
||||
mobility.Install (backbone);
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
// //
|
||||
@@ -178,17 +178,19 @@ main (int argc, char *argv[])
|
||||
// the "172.16 address space
|
||||
ipAddrs.SetBase ("172.16.0.0", "255.255.255.0");
|
||||
|
||||
|
||||
for (uint32_t i = 0; i < backboneNodes; ++i)
|
||||
{
|
||||
NS_LOG_INFO ("Configuring local area network for backbone node " << i);
|
||||
//
|
||||
// Create a container to manage the nodes of the LAN. Pick one of
|
||||
// the backbone nodes to be part of the LAN and first add it to
|
||||
// the container. Then create the rest of the nodes we'll need.
|
||||
// Create a container to manage the nodes of the LAN. We need
|
||||
// two containers here; one with all of the new nodes, and one
|
||||
// with all of the nodes including new and existing nodes
|
||||
//
|
||||
NodeContainer lan;
|
||||
lan.Add (backbone.Get (i));
|
||||
lan.Create (lanNodes - 1);
|
||||
NodeContainer newLanNodes;
|
||||
newLanNodes.Create (lanNodes - 1);
|
||||
// Now, create the container with all nodes on this link
|
||||
NodeContainer lan (backbone.Get (i), newLanNodes);
|
||||
//
|
||||
// Create the CSMA net devices and install them into the nodes in our
|
||||
// collection.
|
||||
@@ -198,9 +200,9 @@ main (int argc, char *argv[])
|
||||
csma.SetChannelParameter ("Delay", TimeValue (MilliSeconds (2)));
|
||||
NetDeviceContainer lanDevices = csma.Install (lan);
|
||||
//
|
||||
// Add the IPv4 protocol stack to the nodes in our container
|
||||
// Add the IPv4 protocol stack to the new LAN nodes
|
||||
//
|
||||
internet.Install (lan);
|
||||
internet.Install (newLanNodes);
|
||||
//
|
||||
// Assign IPv4 addresses to the device drivers (actually to the
|
||||
// associated IPv4 interfaces) we just created.
|
||||
@@ -227,13 +229,14 @@ main (int argc, char *argv[])
|
||||
{
|
||||
NS_LOG_INFO ("Configuring wireless network for backbone node " << i);
|
||||
//
|
||||
// Create a container to manage the nodes of the network. Pick one of
|
||||
// the backbone nodes to be part of the network and first add it to
|
||||
// the container. Then create the rest of the nodes we'll need.
|
||||
// Create a container to manage the nodes of the LAN. We need
|
||||
// two containers here; one with all of the new nodes, and one
|
||||
// with all of the nodes including new and existing nodes
|
||||
//
|
||||
NodeContainer infra;
|
||||
infra.Add (backbone.Get (i));
|
||||
infra.Create (infraNodes - 1);
|
||||
NodeContainer newInfraNodes;
|
||||
newInfraNodes.Create (infraNodes - 1);
|
||||
// Now, create the container with all nodes on this link
|
||||
NodeContainer infra (backbone.Get (i), newInfraNodes);
|
||||
//
|
||||
// Create another ad hoc network and devices
|
||||
//
|
||||
@@ -244,7 +247,7 @@ main (int argc, char *argv[])
|
||||
|
||||
// Add the IPv4 protocol stack to the nodes in our container
|
||||
//
|
||||
internet.Install (infra);
|
||||
internet.Install (newInfraNodes);
|
||||
//
|
||||
// Assign IPv4 addresses to the device drivers (actually to the associated
|
||||
// IPv4 interfaces) we just created.
|
||||
@@ -272,7 +275,7 @@ main (int argc, char *argv[])
|
||||
"Bounds", RectangleValue (Rectangle (-25, 25, -25, 25)),
|
||||
"Speed", RandomVariableValue (ConstantVariable (30)),
|
||||
"Pause", RandomVariableValue (ConstantVariable (0.4)));
|
||||
mobility.Layout (infra);
|
||||
mobility.Install (infra);
|
||||
}
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
// //
|
||||
@@ -282,7 +285,7 @@ main (int argc, char *argv[])
|
||||
|
||||
NS_LOG_INFO ("Enabling OLSR routing on all backbone nodes");
|
||||
OlsrHelper olsr;
|
||||
olsr.Enable (backbone);
|
||||
olsr.Install (backbone);
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
// //
|
||||
@@ -332,13 +335,13 @@ main (int argc, char *argv[])
|
||||
// asciiTrace.TraceNetDeviceRx ("/NodeList/11|13/DeviceList/0");
|
||||
std::ofstream ascii;
|
||||
ascii.open ("mixed-wireless.tr");
|
||||
WifiHelper::EnableAscii (ascii);
|
||||
CsmaHelper::EnableAscii (ascii);
|
||||
WifiHelper::EnableAsciiAll (ascii);
|
||||
CsmaHelper::EnableAsciiAll (ascii);
|
||||
|
||||
// Let's do a pcap trace on the backbone devices
|
||||
WifiHelper::EnablePcap ("mixed-wireless.pcap", backboneDevices);
|
||||
WifiHelper::EnablePcap ("mixed-wireless", backboneDevices);
|
||||
// Let's additionally trace the application Sink, ifIndex 0
|
||||
CsmaHelper::EnablePcap ("mixed-wireless.pcap", appSink->GetId (), 0);
|
||||
CsmaHelper::EnablePcap ("mixed-wireless", appSink->GetId (), 0);
|
||||
|
||||
#ifdef ENABLE_FOR_TRACING_EXAMPLE
|
||||
Config::Connect ("/NodeList/*/$MobilityModelNotifier/CourseChange",
|
||||
|
||||
@@ -159,8 +159,8 @@ main (int argc, char *argv[])
|
||||
|
||||
std::ofstream ascii;
|
||||
ascii.open ("simple-alternate-routing.tr");
|
||||
PointToPointHelper::EnablePcap ("simple-alternate-routing");
|
||||
PointToPointHelper::EnableAscii (ascii);
|
||||
PointToPointHelper::EnablePcapAll ("simple-alternate-routing");
|
||||
PointToPointHelper::EnableAsciiAll (ascii);
|
||||
|
||||
NS_LOG_INFO ("Run Simulation.");
|
||||
Simulator::Run ();
|
||||
|
||||
@@ -173,8 +173,8 @@ main (int argc, char *argv[])
|
||||
|
||||
std::ofstream ascii;
|
||||
ascii.open ("simple-error-model.tr");
|
||||
PointToPointHelper::EnablePcap ("simple-error-model");
|
||||
PointToPointHelper::EnableAscii (ascii);
|
||||
PointToPointHelper::EnablePcapAll ("simple-error-model");
|
||||
PointToPointHelper::EnableAsciiAll (ascii);
|
||||
|
||||
NS_LOG_INFO ("Run Simulation.");
|
||||
Simulator::Run ();
|
||||
|
||||
@@ -151,8 +151,8 @@ main (int argc, char *argv[])
|
||||
|
||||
std::ofstream ascii;
|
||||
ascii.open ("simple-global-routing.tr");
|
||||
PointToPointHelper::EnablePcap ("simple-global-routing");
|
||||
PointToPointHelper::EnableAscii (ascii);
|
||||
PointToPointHelper::EnablePcapAll ("simple-global-routing");
|
||||
PointToPointHelper::EnableAsciiAll (ascii);
|
||||
|
||||
NS_LOG_INFO ("Run Simulation.");
|
||||
Simulator::Run ();
|
||||
|
||||
@@ -120,7 +120,7 @@ main (int argc, char *argv[])
|
||||
// Enable OLSR
|
||||
NS_LOG_INFO ("Enabling OLSR Routing.");
|
||||
OlsrHelper olsr;
|
||||
olsr.EnableAll ();
|
||||
olsr.InstallAll ();
|
||||
|
||||
// Create the OnOff application to send UDP datagrams of size
|
||||
// 210 bytes at a rate of 448 Kb/s
|
||||
@@ -158,8 +158,8 @@ main (int argc, char *argv[])
|
||||
|
||||
std::ofstream ascii;
|
||||
ascii.open ("simple-point-to-point-olsr.tr");
|
||||
PointToPointHelper::EnablePcap ("simple-point-to-point-olsr");
|
||||
PointToPointHelper::EnableAscii (ascii);
|
||||
PointToPointHelper::EnablePcapAll ("simple-point-to-point-olsr");
|
||||
PointToPointHelper::EnableAsciiAll (ascii);
|
||||
|
||||
Simulator::StopAt (Seconds (30));
|
||||
|
||||
|
||||
@@ -188,9 +188,9 @@ int main (int argc, char *argv[])
|
||||
|
||||
std::ofstream ascii;
|
||||
ascii.open ("tcp-large-transfer.tr");
|
||||
PointToPointHelper::EnableAscii (ascii);
|
||||
PointToPointHelper::EnableAsciiAll (ascii);
|
||||
|
||||
InternetStackHelper::EnablePcap ("tcp-large-transfer");
|
||||
PointToPointHelper::EnablePcapAll ("tcp-large-transfer");
|
||||
|
||||
Simulator::StopAt (Seconds(1000));
|
||||
Simulator::Run ();
|
||||
|
||||
@@ -128,8 +128,8 @@ main (int argc, char *argv[])
|
||||
|
||||
std::ofstream ascii;
|
||||
ascii.open ("udp-echo.tr");
|
||||
CsmaHelper::EnablePcap ("udp-echo");
|
||||
CsmaHelper::EnableAscii (ascii);
|
||||
CsmaHelper::EnablePcapAll ("udp-echo");
|
||||
CsmaHelper::EnableAsciiAll (ascii);
|
||||
|
||||
//
|
||||
// Now, do the actual simulation.
|
||||
|
||||
@@ -126,7 +126,7 @@ Experiment::Run (const WifiHelper &wifi)
|
||||
mobility.SetPositionAllocator (positionAlloc);
|
||||
mobility.SetMobilityModel ("ns3::StaticMobilityModel");
|
||||
|
||||
mobility.Layout (c);
|
||||
mobility.Install (c);
|
||||
|
||||
PacketSocketAddress socket;
|
||||
socket.SetSingleDevice(devices.Get (0)->GetIfIndex ());
|
||||
|
||||
@@ -152,8 +152,8 @@ int main (int argc, char *argv[])
|
||||
wifi.Install (ap, channel);
|
||||
|
||||
// mobility.
|
||||
mobility.Layout (stas);
|
||||
mobility.Layout (ap);
|
||||
mobility.Install (stas);
|
||||
mobility.Install (ap);
|
||||
|
||||
Simulator::Schedule (Seconds (1.0), &AdvancePosition, ap.Get (0));
|
||||
|
||||
|
||||
@@ -68,7 +68,7 @@ main (int argc, char *argv[])
|
||||
n0->AddDevice (net0);
|
||||
|
||||
Ptr<Queue> q = CreateObject<DropTailQueue> ();
|
||||
net0->AddQueue(q);
|
||||
net0->SetQueue(q);
|
||||
|
||||
// At this point, we have created a single node (Node 0) and a
|
||||
// single PointToPointNetDevice (NetDevice 0) and added a
|
||||
|
||||
@@ -37,7 +37,7 @@ int main (int argc, char *argv[])
|
||||
// finalize the setup by attaching to each object
|
||||
// in the input array a position and initializing
|
||||
// this position with the calculated coordinates.
|
||||
mobility.Layout (nodes);
|
||||
mobility.Install (nodes);
|
||||
|
||||
// iterate our nodes and print their position.
|
||||
for (NodeContainer::Iterator j = nodes.Begin ();
|
||||
|
||||
@@ -31,7 +31,7 @@ int main (int argc, char *argv[])
|
||||
"Y", StringValue ("100.0"),
|
||||
"Rho", StringValue ("Uniform:0:30"));
|
||||
mobility.SetMobilityModel ("ns3::StaticMobilityModel");
|
||||
mobility.Layout (c);
|
||||
mobility.Install (c);
|
||||
|
||||
Config::Connect ("/NodeList/*/$ns3::MobilityModelNotifier/CourseChange",
|
||||
MakeCallback (&CourseChange));
|
||||
|
||||
@@ -41,7 +41,7 @@ int main (int argc, char *argv[])
|
||||
"Time", StringValue ("2s"),
|
||||
"Speed", StringValue ("Constant:1.0"),
|
||||
"Bounds", StringValue ("0:200:0:100"));
|
||||
mobility.LayoutAll ();
|
||||
mobility.InstallAll ();
|
||||
Config::Connect ("/NodeList/*/$ns3::MobilityModelNotifier/CourseChange",
|
||||
MakeCallback (&CourseChange));
|
||||
|
||||
|
||||
@@ -34,6 +34,7 @@ namespace ns3 {
|
||||
|
||||
enum {
|
||||
PCAP_ETHERNET = 1,
|
||||
PCAP_PPP = 9,
|
||||
PCAP_RAW_IP = 101,
|
||||
PCAP_80211 = 105,
|
||||
};
|
||||
@@ -42,6 +43,7 @@ PcapWriter::PcapWriter ()
|
||||
{
|
||||
m_writer = 0;
|
||||
}
|
||||
|
||||
PcapWriter::~PcapWriter ()
|
||||
{
|
||||
delete m_writer;
|
||||
@@ -72,6 +74,12 @@ PcapWriter::WriteWifiHeader (void)
|
||||
WriteHeader (PCAP_80211);
|
||||
}
|
||||
|
||||
void
|
||||
PcapWriter::WritePppHeader (void)
|
||||
{
|
||||
WriteHeader (PCAP_PPP);
|
||||
}
|
||||
|
||||
void
|
||||
PcapWriter::WriteHeader (uint32_t network)
|
||||
{
|
||||
@@ -84,9 +92,6 @@ PcapWriter::WriteHeader (uint32_t network)
|
||||
Write32 (network);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
void
|
||||
PcapWriter::WritePacket (Ptr<const Packet> packet)
|
||||
{
|
||||
@@ -108,6 +113,7 @@ PcapWriter::WriteData (uint8_t const*buffer, uint32_t size)
|
||||
{
|
||||
m_writer->write ((char const *)buffer, size);
|
||||
}
|
||||
|
||||
void
|
||||
PcapWriter::Write32 (uint32_t data)
|
||||
{
|
||||
@@ -118,6 +124,7 @@ PcapWriter::Write32 (uint32_t data)
|
||||
buffer[3] = (data >> 24) & 0xff;
|
||||
WriteData (buffer, 4);
|
||||
}
|
||||
|
||||
void
|
||||
PcapWriter::Write16 (uint16_t data)
|
||||
{
|
||||
|
||||
@@ -60,6 +60,8 @@ public:
|
||||
|
||||
void WriteWifiHeader (void);
|
||||
|
||||
void WritePppHeader (void);
|
||||
|
||||
/**
|
||||
* \param packet packet to write to output file
|
||||
*/
|
||||
|
||||
@@ -351,7 +351,7 @@ LogComponentPrintList (void)
|
||||
}
|
||||
}
|
||||
|
||||
void LogRegisterTimePrinter (LogTimePrinter printer)
|
||||
void LogSetTimePrinter (LogTimePrinter printer)
|
||||
{
|
||||
g_logTimePrinter = printer;
|
||||
}
|
||||
|
||||
@@ -308,7 +308,7 @@ void LogComponentPrintList (void);
|
||||
|
||||
typedef void (*LogTimePrinter) (std::ostream &os);
|
||||
|
||||
void LogRegisterTimePrinter (LogTimePrinter);
|
||||
void LogSetTimePrinter (LogTimePrinter);
|
||||
LogTimePrinter LogGetTimePrinter(void);
|
||||
|
||||
|
||||
@@ -374,6 +374,9 @@ public:
|
||||
#define LogComponentDisableAll(level)
|
||||
#define LogRegisterTimePrinter(printer)
|
||||
|
||||
#define LogSetTimePrinter(printer)
|
||||
#define LogGetTimePrinter
|
||||
|
||||
#endif /* LOG_ENABLE */
|
||||
|
||||
#endif // __LOG_H__
|
||||
|
||||
@@ -404,14 +404,14 @@ CsmaNetDevice::Attach (Ptr<CsmaChannel> ch)
|
||||
}
|
||||
|
||||
void
|
||||
CsmaNetDevice::AddQueue (Ptr<Queue> q)
|
||||
CsmaNetDevice::SetQueue (Ptr<Queue> q)
|
||||
{
|
||||
NS_LOG_FUNCTION (this << q);
|
||||
|
||||
m_queue = q;
|
||||
}
|
||||
|
||||
void CsmaNetDevice::AddReceiveErrorModel (Ptr<ErrorModel> em)
|
||||
void CsmaNetDevice::SetReceiveErrorModel (Ptr<ErrorModel> em)
|
||||
{
|
||||
NS_LOG_FUNCTION (em);
|
||||
|
||||
|
||||
@@ -150,7 +150,7 @@ enum CsmaEncapsulationMode {
|
||||
* \param queue a pointer to the queue for which object is assuming
|
||||
* ownership.
|
||||
*/
|
||||
void AddQueue (Ptr<Queue> queue);
|
||||
void SetQueue (Ptr<Queue> queue);
|
||||
/**
|
||||
* Attach a receive ErrorModel to the CsmaNetDevice.
|
||||
*
|
||||
@@ -160,7 +160,7 @@ enum CsmaEncapsulationMode {
|
||||
* @see ErrorModel
|
||||
* @param em a pointer to the ErrorModel
|
||||
*/
|
||||
void AddReceiveErrorModel(Ptr<ErrorModel> em);
|
||||
void SetReceiveErrorModel(Ptr<ErrorModel> em);
|
||||
/**
|
||||
* Receive a packet from a connected CsmaChannel.
|
||||
*
|
||||
|
||||
@@ -29,6 +29,7 @@
|
||||
#include "ns3/pointer.h"
|
||||
#include "point-to-point-net-device.h"
|
||||
#include "point-to-point-channel.h"
|
||||
#include "ppp-header.h"
|
||||
|
||||
NS_LOG_COMPONENT_DEFINE ("PointToPointNetDevice");
|
||||
|
||||
@@ -96,20 +97,19 @@ void
|
||||
PointToPointNetDevice::AddHeader(Ptr<Packet> p, uint16_t protocolNumber)
|
||||
{
|
||||
NS_LOG_FUNCTION_NOARGS ();
|
||||
LlcSnapHeader llc;
|
||||
llc.SetType (protocolNumber);
|
||||
p->AddHeader (llc);
|
||||
NS_ASSERT_MSG (protocolNumber == 0x800,
|
||||
"PointToPointNetDevice::AddHeader(): protocolNumber must be 0x800");
|
||||
PppHeader ppp;
|
||||
p->AddHeader (ppp);
|
||||
}
|
||||
|
||||
bool
|
||||
PointToPointNetDevice::ProcessHeader(Ptr<Packet> p, uint16_t& param)
|
||||
{
|
||||
NS_LOG_FUNCTION_NOARGS ();
|
||||
LlcSnapHeader llc;
|
||||
p->RemoveHeader (llc);
|
||||
|
||||
param = llc.GetType ();
|
||||
|
||||
PppHeader ppp;
|
||||
p->RemoveHeader (ppp);
|
||||
param = 0x800;
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -207,14 +207,14 @@ PointToPointNetDevice::Attach (Ptr<PointToPointChannel> ch)
|
||||
return true;
|
||||
}
|
||||
|
||||
void PointToPointNetDevice::AddQueue (Ptr<Queue> q)
|
||||
void PointToPointNetDevice::SetQueue (Ptr<Queue> q)
|
||||
{
|
||||
NS_LOG_FUNCTION (this << q);
|
||||
|
||||
m_queue = q;
|
||||
}
|
||||
|
||||
void PointToPointNetDevice::AddReceiveErrorModel (Ptr<ErrorModel> em)
|
||||
void PointToPointNetDevice::SetReceiveErrorModel (Ptr<ErrorModel> em)
|
||||
{
|
||||
NS_LOG_FUNCTION ("(" << em << ")");
|
||||
|
||||
|
||||
@@ -121,7 +121,7 @@ public:
|
||||
* @param queue a pointer to the queue for which object is assuming
|
||||
* ownership.
|
||||
*/
|
||||
void AddQueue (Ptr<Queue> queue);
|
||||
void SetQueue (Ptr<Queue> queue);
|
||||
/**
|
||||
* Attach a receive ErrorModel to the PointToPointNetDevice.
|
||||
*
|
||||
@@ -131,7 +131,7 @@ public:
|
||||
* @see ErrorModel
|
||||
* @param em a pointer to the ErrorModel
|
||||
*/
|
||||
void AddReceiveErrorModel(Ptr<ErrorModel> em);
|
||||
void SetReceiveErrorModel(Ptr<ErrorModel> em);
|
||||
/**
|
||||
* Receive a packet from a connected PointToPointChannel.
|
||||
*
|
||||
|
||||
@@ -27,7 +27,7 @@ void
|
||||
PointToPointTest::SendOnePacket (Ptr<PointToPointNetDevice> device)
|
||||
{
|
||||
Ptr<Packet> p = Create<Packet> ();
|
||||
device->Send (p, device->GetBroadcast (), 1);
|
||||
device->Send (p, device->GetBroadcast (), 0x800);
|
||||
}
|
||||
|
||||
|
||||
@@ -44,10 +44,10 @@ PointToPointTest::RunTests (void)
|
||||
|
||||
devA->Attach (channel);
|
||||
devA->SetAddress (Mac48Address::Allocate ());
|
||||
devA->AddQueue (CreateObject<DropTailQueue> ());
|
||||
devA->SetQueue (CreateObject<DropTailQueue> ());
|
||||
devB->Attach (channel);
|
||||
devB->SetAddress (Mac48Address::Allocate ());
|
||||
devB->AddQueue (CreateObject<DropTailQueue> ());
|
||||
devB->SetQueue (CreateObject<DropTailQueue> ());
|
||||
|
||||
a->AddDevice (devA);
|
||||
b->AddDevice (devB);
|
||||
|
||||
82
src/devices/point-to-point/ppp-header.cc
Normal file
82
src/devices/point-to-point/ppp-header.cc
Normal file
@@ -0,0 +1,82 @@
|
||||
/* -*- Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil; -*- */
|
||||
/*
|
||||
* Copyright (c) 2008 University of Washington
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License version 2 as
|
||||
* published by the Free Software Foundation;
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*/
|
||||
|
||||
#include <iostream>
|
||||
#include "ns3/assert.h"
|
||||
#include "ns3/log.h"
|
||||
#include "ns3/header.h"
|
||||
#include "ppp-header.h"
|
||||
|
||||
NS_LOG_COMPONENT_DEFINE ("PppHeader");
|
||||
|
||||
namespace ns3 {
|
||||
|
||||
NS_OBJECT_ENSURE_REGISTERED (PppHeader);
|
||||
|
||||
PppHeader::PppHeader ()
|
||||
{
|
||||
}
|
||||
|
||||
PppHeader::~PppHeader ()
|
||||
{
|
||||
}
|
||||
|
||||
TypeId
|
||||
PppHeader::GetTypeId (void)
|
||||
{
|
||||
static TypeId tid = TypeId ("ns3::PppHeader")
|
||||
.SetParent<Header> ()
|
||||
.AddConstructor<PppHeader> ()
|
||||
;
|
||||
return tid;
|
||||
}
|
||||
|
||||
TypeId
|
||||
PppHeader::GetInstanceTypeId (void) const
|
||||
{
|
||||
return GetTypeId ();
|
||||
}
|
||||
|
||||
void
|
||||
PppHeader::Print (std::ostream &os) const
|
||||
{
|
||||
os << "Point-to-Point Protocol: IP (0x0021)" << std::endl;
|
||||
}
|
||||
|
||||
uint32_t
|
||||
PppHeader::GetSerializedSize (void) const
|
||||
{
|
||||
return 2;
|
||||
}
|
||||
|
||||
void
|
||||
PppHeader::Serialize (Buffer::Iterator start) const
|
||||
{
|
||||
start.WriteHtonU16 (0x0021);
|
||||
}
|
||||
|
||||
uint32_t
|
||||
PppHeader::Deserialize (Buffer::Iterator start)
|
||||
{
|
||||
uint16_t __attribute__((unused))data = start.ReadNtohU16 ();
|
||||
NS_ASSERT_MSG (data == 0x0021, "MyHeader::Deserialize(): "
|
||||
"expected protocol 0x0021");
|
||||
return 2;
|
||||
}
|
||||
|
||||
} // namespace ns3
|
||||
72
src/devices/point-to-point/ppp-header.h
Normal file
72
src/devices/point-to-point/ppp-header.h
Normal file
@@ -0,0 +1,72 @@
|
||||
/* -*- Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil; -*- */
|
||||
/*
|
||||
* Copyright (c) 2008 University of Washington
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License version 2 as
|
||||
* published by the Free Software Foundation;
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*/
|
||||
|
||||
#ifndef PPP_HEADER_H
|
||||
#define PPP_HEADER_H
|
||||
|
||||
#include "ns3/header.h"
|
||||
|
||||
namespace ns3 {
|
||||
|
||||
/**
|
||||
* \brief Packet header for PPP
|
||||
*
|
||||
* This class can be used to add a header to PPP packet. Currently we do not
|
||||
* implement any of the state machine in RFC 1661, we just encapsulate the
|
||||
* inbound packet as an IP version 4 type and send it on. The goal here is
|
||||
* not really to implement the point-to-point protocol, but to encapsulate our
|
||||
* packets in a known protocol so packet sniffers can parse them.
|
||||
*
|
||||
* if PPP is transmitted over a serial link, it will typically be framed in
|
||||
* some way derivative of IBM SDLC (HDLC) with all that that entails.
|
||||
* Thankfully, we don't have to deal with all of that -- we can use our own
|
||||
* protocol for getting bits across the serial link which we call an ns3
|
||||
* Packet. What we do have to worry about is being able to capture PPP frames
|
||||
* which are understandable by Wireshark. All this means is that we need to
|
||||
* teach the PcapWriter about the appropriate data link type (DLT_PPP = 9),
|
||||
* and we need to add a PPP header to each packet. Since we are not using
|
||||
* framed PPP, this just means prepending the sixteen bit PPP protocol number
|
||||
* (0x0021) to the packet. The ns-3 way to do this is via a class that
|
||||
* inherits from class Header.
|
||||
*/
|
||||
class PppHeader : public Header
|
||||
{
|
||||
public:
|
||||
|
||||
/**
|
||||
* \brief Construct an IP version 4 PPP header.
|
||||
*/
|
||||
PppHeader ();
|
||||
|
||||
/**
|
||||
* \brief Destroy an IP version 4 PPP header.
|
||||
*/
|
||||
virtual ~PppHeader ();
|
||||
|
||||
static TypeId GetTypeId (void);
|
||||
virtual TypeId GetInstanceTypeId (void) const;
|
||||
virtual void Print (std::ostream &os) const;
|
||||
virtual void Serialize (Buffer::Iterator start) const;
|
||||
virtual uint32_t Deserialize (Buffer::Iterator start);
|
||||
virtual uint32_t GetSerializedSize (void) const;
|
||||
};
|
||||
|
||||
}; // namespace ns3
|
||||
|
||||
|
||||
#endif /* PPP_HEADER_H */
|
||||
@@ -7,6 +7,7 @@ def build(bld):
|
||||
'point-to-point-net-device.cc',
|
||||
'point-to-point-channel.cc',
|
||||
'point-to-point-test.cc',
|
||||
'ppp-header.cc',
|
||||
]
|
||||
headers = bld.create_obj('ns3header')
|
||||
headers.module = 'point-to-point'
|
||||
|
||||
@@ -103,7 +103,7 @@ CsmaHelper::EnablePcap (std::string filename, NodeContainer n)
|
||||
}
|
||||
|
||||
void
|
||||
CsmaHelper::EnablePcap (std::string filename)
|
||||
CsmaHelper::EnablePcapAll (std::string filename)
|
||||
{
|
||||
EnablePcap (filename, NodeContainer::GetGlobal ());
|
||||
}
|
||||
@@ -150,7 +150,7 @@ CsmaHelper::EnableAscii (std::ostream &os, NodeContainer n)
|
||||
}
|
||||
|
||||
void
|
||||
CsmaHelper::EnableAscii (std::ostream &os)
|
||||
CsmaHelper::EnableAsciiAll (std::ostream &os)
|
||||
{
|
||||
EnableAscii (os, NodeContainer::GetGlobal ());
|
||||
}
|
||||
@@ -174,7 +174,7 @@ CsmaHelper::Install (const NodeContainer &c, Ptr<CsmaChannel> channel)
|
||||
device->SetAddress (Mac48Address::Allocate ());
|
||||
node->AddDevice (device);
|
||||
Ptr<Queue> queue = m_queueFactory.Create<Queue> ();
|
||||
device->AddQueue (queue);
|
||||
device->SetQueue (queue);
|
||||
device->Attach (channel);
|
||||
container.Add (device);
|
||||
}
|
||||
|
||||
@@ -115,7 +115,7 @@ public:
|
||||
* Enable pcap output on each device which is of the
|
||||
* ns3::CsmaNetDevice type
|
||||
*/
|
||||
static void EnablePcap (std::string filename);
|
||||
static void EnablePcapAll (std::string filename);
|
||||
|
||||
/**
|
||||
* \param os output stream
|
||||
@@ -154,7 +154,7 @@ public:
|
||||
* ns3::CsmaNetDevice type and dump that to the specified
|
||||
* stdc++ output stream.
|
||||
*/
|
||||
static void EnableAscii (std::ostream &os);
|
||||
static void EnableAsciiAll (std::ostream &os);
|
||||
|
||||
/**
|
||||
* \param c a set of nodes
|
||||
|
||||
@@ -17,22 +17,48 @@
|
||||
*
|
||||
* Author: Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
|
||||
*/
|
||||
#include "ns3/assert.h"
|
||||
#include "ns3/log.h"
|
||||
#include "ns3/object.h"
|
||||
#include "ns3/ipv4.h"
|
||||
#include "internet-stack-helper.h"
|
||||
#include "ns3/internet-stack.h"
|
||||
#include "ns3/packet-socket-factory.h"
|
||||
#include "ns3/config.h"
|
||||
#include "ns3/simulator.h"
|
||||
|
||||
namespace ns3 {
|
||||
|
||||
std::vector<InternetStackHelper::Trace> InternetStackHelper::m_traces;
|
||||
std::string InternetStackHelper::m_pcapBaseFilename;
|
||||
|
||||
void
|
||||
InternetStackHelper::Cleanup (void)
|
||||
{
|
||||
uint32_t illegal = std::numeric_limits<uint32_t>::max();
|
||||
|
||||
for (std::vector<Trace>::iterator i = m_traces.begin ();
|
||||
i != m_traces.end (); i++)
|
||||
{
|
||||
i->nodeId = illegal;
|
||||
i->interfaceId = illegal;
|
||||
i->writer = 0;
|
||||
}
|
||||
m_traces.clear ();
|
||||
}
|
||||
|
||||
void
|
||||
InternetStackHelper::Install (NodeContainer c)
|
||||
{
|
||||
for (NodeContainer::Iterator i = c.Begin (); i != c.End (); ++i)
|
||||
{
|
||||
Ptr<Node> node = *i;
|
||||
if (node->GetObject<Ipv4> () != 0)
|
||||
{
|
||||
NS_FATAL_ERROR ("InternetStackHelper::Install(): Aggregating "
|
||||
"an InternetStack to a node with an existing Ipv4 object");
|
||||
return;
|
||||
}
|
||||
AddInternetStack (node);
|
||||
Ptr<PacketSocketFactory> factory = CreateObject<PacketSocketFactory> ();
|
||||
node->AggregateObject (factory);
|
||||
@@ -40,8 +66,10 @@ InternetStackHelper::Install (NodeContainer c)
|
||||
}
|
||||
|
||||
void
|
||||
InternetStackHelper::EnablePcap (std::string filename)
|
||||
InternetStackHelper::EnablePcapAll (std::string filename)
|
||||
{
|
||||
Simulator::ScheduleDestroy (&InternetStackHelper::Cleanup);
|
||||
|
||||
InternetStackHelper::m_pcapBaseFilename = filename;
|
||||
Config::Connect ("/NodeList/*/$ns3::Ipv4L3Protocol/Tx",
|
||||
MakeCallback (&InternetStackHelper::LogTxIp));
|
||||
|
||||
@@ -37,7 +37,10 @@ public:
|
||||
* \param c the set of nodes
|
||||
*
|
||||
* For each node in the input container, aggregate implementations
|
||||
* of the ns3::Ipv4, ns3::Udp, and, ns3::Tcp classes.
|
||||
* of the ns3::Ipv4, ns3::Udp, and, ns3::Tcp classes. The program
|
||||
* will assert if this method is called on a container with a node
|
||||
* that already has an Ipv4 object aggregated to it.
|
||||
*
|
||||
*/
|
||||
void Install (NodeContainer c);
|
||||
|
||||
@@ -46,10 +49,18 @@ public:
|
||||
*
|
||||
* Enable pcap output on each protocol instance which is of the
|
||||
* ns3::Ipv4L3Protocol type. Both Tx and Rx events will be logged.
|
||||
*
|
||||
* \warning If you perform multiple simulations in a single script,
|
||||
* each iteration of the simulation will result in the trace files
|
||||
* being overwritten. We don't attempt to anticipate what a user
|
||||
* might actually want to do, so we leave it up to them. If you want
|
||||
* to save any particular data, do so manually at inter-simulation
|
||||
* time.
|
||||
*/
|
||||
static void EnablePcap (std::string filename);
|
||||
static void EnablePcapAll (std::string filename);
|
||||
|
||||
private:
|
||||
static void Cleanup (void);
|
||||
static void LogRxIp (std::string context, Ptr<const Packet> packet, uint32_t deviceId);
|
||||
static void LogTxIp (std::string context, Ptr<const Packet> packet, uint32_t deviceId);
|
||||
static Ptr<PcapWriter> GetStream (uint32_t nodeId, uint32_t interfaceId);
|
||||
|
||||
@@ -124,7 +124,7 @@ MobilityHelper::GetMobilityModelType (void) const
|
||||
}
|
||||
|
||||
void
|
||||
MobilityHelper::Layout (NodeContainer c)
|
||||
MobilityHelper::Install (NodeContainer c)
|
||||
{
|
||||
for (NodeContainer::Iterator i = c.Begin (); i != c.End (); ++i)
|
||||
{
|
||||
@@ -169,9 +169,9 @@ MobilityHelper::Layout (NodeContainer c)
|
||||
}
|
||||
|
||||
void
|
||||
MobilityHelper::LayoutAll (void)
|
||||
MobilityHelper::InstallAll (void)
|
||||
{
|
||||
Layout (NodeContainer::GetGlobal ());
|
||||
Install (NodeContainer::GetGlobal ());
|
||||
}
|
||||
|
||||
} // namespace ns3
|
||||
|
||||
@@ -34,7 +34,7 @@ class MobilityModel;
|
||||
/**
|
||||
* \brief assign positions and mobility models to nodes.
|
||||
*
|
||||
* MobilityHelper::Layout is the most important method here.
|
||||
* MobilityHelper::Install is the most important method here.
|
||||
*/
|
||||
class MobilityHelper
|
||||
{
|
||||
@@ -43,14 +43,14 @@ public:
|
||||
~MobilityHelper ();
|
||||
|
||||
/**
|
||||
* After this method is called, every call to MobilityHelper::Layout
|
||||
* After this method is called, every call to MobilityHelper::Install
|
||||
* will also attach to the new ns3::MobilityModel an ns3::MobilityModelNotifier
|
||||
* which can be used to listen to CourseChange events.
|
||||
*/
|
||||
void EnableNotifier (void);
|
||||
/**
|
||||
* After this method is called, no ns3::MobilityModelNotifier object will
|
||||
* be associated to any new ns3::MobilityModel created by MobilityHelper::Layout.
|
||||
* be associated to any new ns3::MobilityModel created by MobilityHelper::Install.
|
||||
* This will make it impossible to listen to "CourseChange" events from these
|
||||
* new ns3::MobilityModel instances.
|
||||
*/
|
||||
@@ -60,7 +60,7 @@ public:
|
||||
* \param allocator allocate initial node positions
|
||||
*
|
||||
* Set the position allocator which will be used to allocate
|
||||
* the initial position of every node in MobilityModel::Layout.
|
||||
* the initial position of every node in MobilityModel::Install.
|
||||
*/
|
||||
void SetPositionAllocator (Ptr<PositionAllocator> allocator);
|
||||
|
||||
@@ -117,7 +117,7 @@ public:
|
||||
* \param n9 the name of the attribute to set in the mobility model.
|
||||
* \param v9 the value of the attribute to set in the mobility model.
|
||||
*
|
||||
* Calls to MobilityHelper::Layout will create an instance of a matching
|
||||
* Calls to MobilityHelper::Install will create an instance of a matching
|
||||
* mobility model for each node.
|
||||
*/
|
||||
void SetMobilityModel (std::string type,
|
||||
@@ -136,9 +136,9 @@ public:
|
||||
*
|
||||
* Push an item on the top of the stack of "reference mobility models".
|
||||
* The input item should be a node instance to which a mobility model
|
||||
* has already been aggregated (usually by a call to Layout).
|
||||
* has already been aggregated (usually by a call to Install).
|
||||
*
|
||||
* If this this stack is not empty when MobilityHelper::Layout
|
||||
* If this this stack is not empty when MobilityHelper::Install
|
||||
* is called, the model from the top of the stack is used
|
||||
* to create a ns3::HierarchicalMobilityModel to make the
|
||||
* newly-created models define their positions relative to that
|
||||
@@ -171,15 +171,15 @@ public:
|
||||
* position allocator (set through MobilityHelper::SetPositionAllocator).
|
||||
* Optionally, this method will also create and aggregate a
|
||||
* ns3::MobilityModelNotifier to generate 'CourseChange' events based on the
|
||||
* boolean flag set by MobilityHelper::EnableNotifier and MobilityHelper::DisableNotifier.
|
||||
* boolean flag set by MobilityHelper::EnableNotifierAll and MobilityHelper::DisableNotifier.
|
||||
*/
|
||||
void Layout (NodeContainer container);
|
||||
void Install (NodeContainer container);
|
||||
|
||||
/**
|
||||
* Perform the work of MobilityHelper::Layout on _all_ nodes which
|
||||
* Perform the work of MobilityHelper::Install on _all_ nodes which
|
||||
* exist in the simulation.
|
||||
*/
|
||||
void LayoutAll (void);
|
||||
void InstallAll (void);
|
||||
private:
|
||||
|
||||
std::vector<Ptr<MobilityModel> > m_mobilityStack;
|
||||
|
||||
@@ -154,9 +154,9 @@ Ns2MobilityHelper::LayoutObjectStore (const ObjectStore &store) const
|
||||
}
|
||||
|
||||
void
|
||||
Ns2MobilityHelper::Layout (void) const
|
||||
Ns2MobilityHelper::Install (void) const
|
||||
{
|
||||
Layout (NodeList::Begin (), NodeList::End ());
|
||||
Install (NodeList::Begin (), NodeList::End ());
|
||||
}
|
||||
|
||||
} // namespace ns3
|
||||
|
||||
@@ -51,7 +51,7 @@ public:
|
||||
* whose nodeId is matches the nodeId of the nodes in the trace
|
||||
* file.
|
||||
*/
|
||||
void Layout (void) const;
|
||||
void Install (void) const;
|
||||
|
||||
/**
|
||||
* \param begin an iterator which points to the start of the input
|
||||
@@ -65,7 +65,7 @@ public:
|
||||
* the index of the object in the input array.
|
||||
*/
|
||||
template <typename T>
|
||||
void Layout (T begin, T end) const;
|
||||
void Install (T begin, T end) const;
|
||||
private:
|
||||
class ObjectStore
|
||||
{
|
||||
@@ -86,7 +86,7 @@ namespace ns3 {
|
||||
|
||||
template <typename T>
|
||||
void
|
||||
Ns2MobilityHelper::Layout (T begin, T end) const
|
||||
Ns2MobilityHelper::Install (T begin, T end) const
|
||||
{
|
||||
class MyObjectStore : public ObjectStore
|
||||
{
|
||||
|
||||
@@ -51,26 +51,32 @@ OlsrHelper::SetAgent (std::string tid,
|
||||
}
|
||||
|
||||
void
|
||||
OlsrHelper::Enable (NodeContainer container)
|
||||
OlsrHelper::Install (NodeContainer container)
|
||||
{
|
||||
for (NodeContainer::Iterator i = container.Begin (); i != container.End (); ++i)
|
||||
{
|
||||
Ptr<Node> node = *i;
|
||||
Enable (node);
|
||||
Install (node);
|
||||
}
|
||||
}
|
||||
void
|
||||
OlsrHelper::Enable (Ptr<Node> node)
|
||||
OlsrHelper::Install (Ptr<Node> node)
|
||||
{
|
||||
if (node->GetObject<olsr::Agent> () != 0)
|
||||
{
|
||||
NS_FATAL_ERROR ("OlsrHelper::Install(): Aggregating "
|
||||
"an Olsr Agent to a node with an existing Olsr Agent");
|
||||
return;
|
||||
}
|
||||
Ptr<olsr::Agent> agent = m_agentFactory.Create<olsr::Agent> ();
|
||||
agent->SetNode (node);
|
||||
node->AggregateObject (agent);
|
||||
agent->Start ();
|
||||
}
|
||||
void
|
||||
OlsrHelper::EnableAll (void)
|
||||
OlsrHelper::InstallAll (void)
|
||||
{
|
||||
Enable (NodeContainer::GetGlobal ());
|
||||
Install (NodeContainer::GetGlobal ());
|
||||
}
|
||||
|
||||
} // namespace ns3
|
||||
|
||||
@@ -41,9 +41,9 @@ public:
|
||||
std::string n6 = "", const AttributeValue &v6 = EmptyAttributeValue (),
|
||||
std::string n7 = "", const AttributeValue &v7 = EmptyAttributeValue ());
|
||||
|
||||
void Enable (NodeContainer container);
|
||||
void Enable (Ptr<Node> node);
|
||||
void EnableAll (void);
|
||||
void Install (NodeContainer container);
|
||||
void Install (Ptr<Node> node);
|
||||
void InstallAll (void);
|
||||
private:
|
||||
ObjectFactory m_agentFactory;
|
||||
};
|
||||
|
||||
@@ -70,7 +70,7 @@ PointToPointHelper::EnablePcap (std::string filename, uint32_t nodeid, uint32_t
|
||||
oss << filename << "-" << nodeid << "-" << deviceid << ".pcap";
|
||||
Ptr<PcapWriter> pcap = Create<PcapWriter> ();
|
||||
pcap->Open (oss.str ());
|
||||
pcap->WriteEthernetHeader ();
|
||||
pcap->WritePppHeader ();
|
||||
oss.str ("");
|
||||
oss << "/NodeList/" << nodeid << "/DeviceList/" << deviceid << "/$ns3::PointToPointNetDevice/Rx";
|
||||
Config::ConnectWithoutContext (oss.str (), MakeBoundCallback (&PointToPointHelper::RxEvent, pcap));
|
||||
@@ -103,7 +103,7 @@ PointToPointHelper::EnablePcap (std::string filename, NodeContainer n)
|
||||
}
|
||||
|
||||
void
|
||||
PointToPointHelper::EnablePcap (std::string filename)
|
||||
PointToPointHelper::EnablePcapAll (std::string filename)
|
||||
{
|
||||
EnablePcap (filename, NodeContainer::GetGlobal ());
|
||||
}
|
||||
@@ -150,7 +150,7 @@ PointToPointHelper::EnableAscii (std::ostream &os, NodeContainer n)
|
||||
}
|
||||
|
||||
void
|
||||
PointToPointHelper::EnableAscii (std::ostream &os)
|
||||
PointToPointHelper::EnableAsciiAll (std::ostream &os)
|
||||
{
|
||||
EnableAscii (os, NodeContainer::GetGlobal ());
|
||||
}
|
||||
@@ -170,12 +170,12 @@ PointToPointHelper::Install (Ptr<Node> a, Ptr<Node> b)
|
||||
devA->SetAddress (Mac48Address::Allocate ());
|
||||
a->AddDevice (devA);
|
||||
Ptr<Queue> queueA = m_queueFactory.Create<Queue> ();
|
||||
devA->AddQueue (queueA);
|
||||
devA->SetQueue (queueA);
|
||||
Ptr<PointToPointNetDevice> devB = m_deviceFactory.Create<PointToPointNetDevice> ();
|
||||
devB->SetAddress (Mac48Address::Allocate ());
|
||||
b->AddDevice (devB);
|
||||
Ptr<Queue> queueB = m_queueFactory.Create<Queue> ();
|
||||
devB->AddQueue (queueB);
|
||||
devB->SetQueue (queueB);
|
||||
Ptr<PointToPointChannel> channel = m_channelFactory.Create<PointToPointChannel> ();
|
||||
devA->Attach (channel);
|
||||
devB->Attach (channel);
|
||||
|
||||
@@ -114,7 +114,7 @@ public:
|
||||
* Enable pcap output on each device which is of the
|
||||
* ns3::PointToPointNetDevice type
|
||||
*/
|
||||
static void EnablePcap (std::string filename);
|
||||
static void EnablePcapAll (std::string filename);
|
||||
|
||||
/**
|
||||
* \param os output stream
|
||||
@@ -153,7 +153,7 @@ public:
|
||||
* ns3::PointToPointNetDevice type and dump that to the specified
|
||||
* stdc++ output stream.
|
||||
*/
|
||||
static void EnableAscii (std::ostream &os);
|
||||
static void EnableAsciiAll (std::ostream &os);
|
||||
|
||||
/**
|
||||
* \param c a set of nodes
|
||||
|
||||
@@ -184,7 +184,7 @@ WifiHelper::EnablePcap (std::string filename, NodeContainer n)
|
||||
}
|
||||
|
||||
void
|
||||
WifiHelper::EnablePcap (std::string filename)
|
||||
WifiHelper::EnablePcapAll (std::string filename)
|
||||
{
|
||||
EnablePcap (filename, NodeContainer::GetGlobal ());
|
||||
}
|
||||
@@ -225,7 +225,7 @@ WifiHelper::EnableAscii (std::ostream &os, NodeContainer n)
|
||||
}
|
||||
|
||||
void
|
||||
WifiHelper::EnableAscii (std::ostream &os)
|
||||
WifiHelper::EnableAsciiAll (std::ostream &os)
|
||||
{
|
||||
EnableAscii (os, NodeContainer::GetGlobal ());
|
||||
}
|
||||
|
||||
@@ -176,7 +176,7 @@ public:
|
||||
* Enable pcap output on each device which is of the
|
||||
* ns3::WifiNetDevice type
|
||||
*/
|
||||
static void EnablePcap (std::string filename);
|
||||
static void EnablePcapAll (std::string filename);
|
||||
|
||||
/**
|
||||
* \param os output stream
|
||||
@@ -215,7 +215,7 @@ public:
|
||||
* ns3::WifiNetDevice type and dump that to the specified
|
||||
* stdc++ output stream.
|
||||
*/
|
||||
static void EnableAscii (std::ostream &os);
|
||||
static void EnableAsciiAll (std::ostream &os);
|
||||
|
||||
/**
|
||||
* \param c a set of nodes
|
||||
|
||||
@@ -36,11 +36,6 @@ namespace ns3 {
|
||||
void
|
||||
AddInternetStack (Ptr<Node> node)
|
||||
{
|
||||
// This may be called on a node with a previously added stack
|
||||
if (node->GetObject<Ipv4> ())
|
||||
{
|
||||
return;
|
||||
}
|
||||
Ptr<Ipv4L3Protocol> ipv4 = CreateObject<Ipv4L3Protocol> ();
|
||||
Ptr<ArpL3Protocol> arp = CreateObject<ArpL3Protocol> ();
|
||||
ipv4->SetNode (node);
|
||||
|
||||
@@ -370,6 +370,9 @@ int TcpSocket::Send (const uint8_t* buf, uint32_t size)
|
||||
" state " << m_state);
|
||||
Actions_t action = ProcessEvent (APP_SEND);
|
||||
NS_LOG_DEBUG(" action " << action);
|
||||
// We do not model any limit to the buffer, so report that the
|
||||
// maximum is available
|
||||
NotifySend (std::numeric_limits<uint32_t>::max ());
|
||||
if (!ProcessAction (action))
|
||||
{
|
||||
return -1; // Failed, return zero
|
||||
@@ -689,6 +692,9 @@ bool TcpSocket::ProcessPacketAction (Actions_t a, Ptr<Packet> p,
|
||||
if (tcpHeader.GetAckNumber () > m_highestRxAck)
|
||||
{
|
||||
m_highestRxAck = tcpHeader.GetAckNumber ();
|
||||
// We do not model any limit to the buffer, so report that the
|
||||
// maximum is available
|
||||
NotifySend (std::numeric_limits<uint32_t>::max ());
|
||||
}
|
||||
SendPendingData ();
|
||||
break;
|
||||
@@ -1077,6 +1083,9 @@ void TcpSocket::CommonNewAck (SequenceNumber ack, bool skipTimer)
|
||||
NS_LOG_LOGIC ("TCP " << this << " NewAck " << ack
|
||||
<< " numberAck " << (ack - m_highestRxAck)); // Number bytes ack'ed
|
||||
m_highestRxAck = ack; // Note the highest recieved Ack
|
||||
// We do not model any limit to the buffer, so report that the
|
||||
// maximum is available
|
||||
NotifySend (std::numeric_limits<uint32_t>::max ());
|
||||
if (ack > m_nextTxSequence)
|
||||
{
|
||||
m_nextTxSequence = ack; // If advanced
|
||||
|
||||
@@ -262,12 +262,10 @@ Ipv4AddressGeneratorImpl::AddAllocated (const Ipv4Address address)
|
||||
|
||||
NS_ASSERT_MSG (addr, "Ipv4AddressGeneratorImpl::Add(): "
|
||||
"Allocating the broadcast address is not a good idea");
|
||||
|
||||
std::list<Entry>::iterator i;
|
||||
|
||||
std::list<Entry>::iterator i, j;
|
||||
|
||||
for (i = m_entries.begin (), j = m_entries.begin (), ++j;
|
||||
i != m_entries.end ();
|
||||
++i, ++j)
|
||||
for (i = m_entries.begin (); i != m_entries.end (); ++i)
|
||||
{
|
||||
NS_LOG_LOGIC ("examine entry: " << Ipv4Address ((*i).addrLow) <<
|
||||
" to " << Ipv4Address ((*i).addrHigh));
|
||||
@@ -277,11 +275,12 @@ Ipv4AddressGeneratorImpl::AddAllocated (const Ipv4Address address)
|
||||
//
|
||||
if (addr >= (*i).addrLow && addr <= (*i).addrHigh)
|
||||
{
|
||||
NS_LOG_LOGIC ("Ipv4AddressGeneratorImpl::Add(): Address Collision: " << Ipv4Address (addr));
|
||||
NS_LOG_LOGIC ("Ipv4AddressGeneratorImpl::Add(): "
|
||||
"Address Collision: " << Ipv4Address (addr));
|
||||
if (!m_test)
|
||||
{
|
||||
NS_ASSERT_MSG (0,
|
||||
"Ipv4AddressGeneratorImpl::Add(): Address Collision: " << Ipv4Address (addr));
|
||||
NS_ASSERT_MSG (0, "Ipv4AddressGeneratorImpl::Add(): "
|
||||
"Address Collision: " << Ipv4Address (addr));
|
||||
}
|
||||
return false;
|
||||
}
|
||||
@@ -303,6 +302,9 @@ Ipv4AddressGeneratorImpl::AddAllocated (const Ipv4Address address)
|
||||
//
|
||||
if (addr == (*i).addrHigh + 1)
|
||||
{
|
||||
std::list<Entry>::iterator j = i;
|
||||
++j;
|
||||
|
||||
if (j != m_entries.end ())
|
||||
{
|
||||
if (addr == (*j).addrLow)
|
||||
|
||||
@@ -64,11 +64,19 @@ Socket::SetAcceptCallback (
|
||||
m_closeRequested = closeRequested;
|
||||
}
|
||||
|
||||
void
|
||||
Socket::SetSendCallback (Callback<void, Ptr<Socket>, uint32_t> dataSent)
|
||||
bool
|
||||
Socket::SetDataSentCallback (Callback<void, Ptr<Socket>, uint32_t> dataSent)
|
||||
{
|
||||
NS_LOG_FUNCTION_NOARGS ();
|
||||
m_dataSent = dataSent;
|
||||
return true;
|
||||
}
|
||||
|
||||
void
|
||||
Socket::SetSendCallback (Callback<void, Ptr<Socket>, uint32_t> sendCb)
|
||||
{
|
||||
NS_LOG_FUNCTION_NOARGS ();
|
||||
m_sendCb = sendCb;
|
||||
}
|
||||
|
||||
void
|
||||
@@ -78,6 +86,12 @@ Socket::SetRecvCallback (Callback<void, Ptr<Socket>, Ptr<Packet>,const Address&>
|
||||
m_receivedData = receivedData;
|
||||
}
|
||||
|
||||
int Socket::Listen (uint32_t queueLimit)
|
||||
{
|
||||
return 0; //XXX the base class version does nothing
|
||||
}
|
||||
|
||||
|
||||
int Socket::Send (const uint8_t* buf, uint32_t size)
|
||||
{
|
||||
NS_LOG_FUNCTION_NOARGS ();
|
||||
@@ -108,12 +122,6 @@ int Socket::SendTo (const Address &address, const uint8_t* buf, uint32_t size)
|
||||
return SendTo (address,p);
|
||||
}
|
||||
|
||||
int Socket::Listen(uint32_t queueLimit)
|
||||
{
|
||||
return 0; //XXX the base class version does nothing
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
Socket::NotifyCloseCompleted (void)
|
||||
{
|
||||
@@ -202,6 +210,16 @@ Socket::NotifyDataSent (uint32_t size)
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
Socket::NotifySend (uint32_t spaceAvailable)
|
||||
{
|
||||
NS_LOG_FUNCTION_NOARGS ();
|
||||
if (!m_sendCb.IsNull ())
|
||||
{
|
||||
m_sendCb (this, spaceAvailable);
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
Socket::NotifyDataReceived (Ptr<Packet> p, const Address &from)
|
||||
{
|
||||
|
||||
@@ -38,9 +38,11 @@ class Packet;
|
||||
* \brief Define a Socket API based on the BSD Socket API.
|
||||
*
|
||||
* Contrary to the original BSD socket API, this API is asynchronous:
|
||||
* it does not contain blocking calls. Other than that, it tries to stick
|
||||
* to the BSD API to make it easier those who know the BSD API to use
|
||||
* this API.
|
||||
* it does not contain blocking calls. It also uses class ns3::Packet
|
||||
* as a fancy byte buffer, allowing data to be passed across the API
|
||||
* using an ns3::Packet instead of a raw data pointer. Other than that,
|
||||
* it tries to stick to the BSD API to make it easier for those who know
|
||||
* the BSD API to use this API.
|
||||
*/
|
||||
class Socket : public Object
|
||||
{
|
||||
@@ -94,8 +96,8 @@ public:
|
||||
* Or when I call Close ?
|
||||
*/
|
||||
void SetConnectCallback (Callback<void, Ptr<Socket> > connectionSucceeded,
|
||||
Callback<void, Ptr<Socket> > connectionFailed,
|
||||
Callback<void, Ptr<Socket> > halfClose);
|
||||
Callback<void, Ptr<Socket> > connectionFailed,
|
||||
Callback<void, Ptr<Socket> > halfClose);
|
||||
/**
|
||||
* \brief Accept connection requests from remote hosts
|
||||
* \param connectionRequest Callback for connection request from peer.
|
||||
@@ -120,7 +122,34 @@ public:
|
||||
Callback<void, Ptr<Socket>,
|
||||
const Address&> newConnectionCreated,
|
||||
Callback<void, Ptr<Socket> > closeRequested);
|
||||
void SetSendCallback (Callback<void, Ptr<Socket>, uint32_t> dataSent);
|
||||
/**
|
||||
* \brief Notify application when a packet has been sent from transport
|
||||
* protocol (non-standard socket call)
|
||||
* \param dataSent Callback for the event that data is sent from the
|
||||
* underlying transport protocol. This callback is passed a
|
||||
* pointer to the socket, and the number of bytes sent.
|
||||
* \returns whether or not this socket supports this callback. Note
|
||||
* that this is a non-standard socket call. Some socket
|
||||
* implementations in ns-3 may not support this call, so the
|
||||
* user should check this return value to confirm that the
|
||||
* callback is supported.
|
||||
*/
|
||||
virtual bool SetDataSentCallback (Callback<void, Ptr<Socket>, uint32_t> dataSent);
|
||||
/**
|
||||
* \brief Notify application when space in transmit buffer is added
|
||||
*
|
||||
* This callback is intended to notify a
|
||||
* socket that would have been blocked in a blocking socket model
|
||||
* that space is available in the transmit buffer and that it
|
||||
* can call Send() again.
|
||||
*
|
||||
* \param sendCb Callback for the event that the socket transmit buffer
|
||||
* fill level has decreased. This callback is passed a pointer to
|
||||
* the socket, and the number of bytes available for writing
|
||||
* into the buffer (an absolute value). If there is no transmit
|
||||
* buffer limit, a maximum-sized integer is always returned.
|
||||
*/
|
||||
void SetSendCallback (Callback<void, Ptr<Socket>, uint32_t> sendCb);
|
||||
/**
|
||||
* \brief Receive data
|
||||
* \param receivedData Invoked whenever new data is received.
|
||||
@@ -150,7 +179,7 @@ public:
|
||||
* After the Close call, the socket is no longer valid, and cannot
|
||||
* safely be used for subsequent operations.
|
||||
*/
|
||||
virtual int Close(void) = 0;
|
||||
virtual int Close (void) = 0;
|
||||
|
||||
/**
|
||||
* \returns zero on success, -1 on failure.
|
||||
@@ -172,8 +201,15 @@ public:
|
||||
* \brief Initiate a connection to a remote host
|
||||
* \param address Address of remote.
|
||||
*/
|
||||
virtual int Connect(const Address &address) = 0;
|
||||
virtual int Connect (const Address &address) = 0;
|
||||
|
||||
/**
|
||||
* \brief Listen for incoming connections.
|
||||
* \param queueLimit maximum number of incoming request to queue
|
||||
* \returns XXX an error code
|
||||
*/
|
||||
virtual int Listen (uint32_t queueLimit);
|
||||
|
||||
/**
|
||||
* \brief Send data (or dummy data) to the remote host
|
||||
* \param p packet to send
|
||||
@@ -200,14 +236,7 @@ public:
|
||||
* \returns -1 in case of error or the number of bytes copied in the
|
||||
* internal buffer and accepted for transmission.
|
||||
*/
|
||||
virtual int SendTo(const Address &address,Ptr<Packet> p) = 0;
|
||||
|
||||
/**
|
||||
* \brief Listen for incoming connections.
|
||||
* \param queueLimit maximum number of incoming request to queue
|
||||
* \returns XXX an error code
|
||||
*/
|
||||
virtual int Listen(uint32_t queueLimit);
|
||||
virtual int SendTo (const Address &address,Ptr<Packet> p) = 0;
|
||||
|
||||
/**
|
||||
* \brief Send data to a specified peer.
|
||||
@@ -221,7 +250,7 @@ public:
|
||||
* This is provided so as to have an API which is closer in appearance
|
||||
* to that of real network or BSD sockets.
|
||||
*/
|
||||
int SendTo(const Address &address, const uint8_t* buf, uint32_t size);
|
||||
int SendTo (const Address &address, const uint8_t* buf, uint32_t size);
|
||||
|
||||
protected:
|
||||
void NotifyCloseCompleted (void);
|
||||
@@ -232,6 +261,7 @@ protected:
|
||||
void NotifyNewConnectionCreated (Ptr<Socket> socket, const Address &from);
|
||||
void NotifyCloseRequested (void);
|
||||
void NotifyDataSent (uint32_t size);
|
||||
void NotifySend (uint32_t spaceAvailable);
|
||||
void NotifyDataReceived (Ptr<Packet> p, const Address &from);
|
||||
|
||||
Callback<void,Ptr<Socket> > m_closeCompleted;
|
||||
@@ -242,6 +272,7 @@ protected:
|
||||
Callback<bool, Ptr<Socket>, const Address &> m_connectionRequest;
|
||||
Callback<void, Ptr<Socket>, const Address&> m_newConnectionCreated;
|
||||
Callback<void, Ptr<Socket>, uint32_t> m_dataSent;
|
||||
Callback<void, Ptr<Socket>, uint32_t > m_sendCb;
|
||||
Callback<void, Ptr<Socket>, Ptr<Packet>,const Address&> m_receivedData;
|
||||
};
|
||||
|
||||
|
||||
@@ -428,10 +428,16 @@ Simulator::GetPriv (void)
|
||||
{
|
||||
if (m_priv == 0)
|
||||
{
|
||||
LogRegisterTimePrinter (&TimePrinter);
|
||||
/* Note: we call LogSetTimePrinter below _after_ calling CreateObject because
|
||||
* CreateObject can trigger calls to the logging framework which would call
|
||||
* the TimePrinter function above which would call Simulator::Now which would
|
||||
* call Simulator::GetPriv, and, thus, get us in an infinite recursion until the
|
||||
* stack explodes.
|
||||
*/
|
||||
m_priv = CreateObject<SimulatorPrivate> ();
|
||||
Ptr<Scheduler> scheduler = CreateObject<MapScheduler> ();
|
||||
m_priv->SetScheduler (scheduler);
|
||||
LogSetTimePrinter (&TimePrinter);
|
||||
}
|
||||
TRACE_S ("priv " << m_priv);
|
||||
return m_priv;
|
||||
@@ -444,6 +450,12 @@ Simulator::Destroy (void)
|
||||
{
|
||||
return;
|
||||
}
|
||||
/* Note: we have to call LogSetTimePrinter (0) below because if we do not do this,
|
||||
* and restart a simulation after this call to Destroy, (which is legal),
|
||||
* Simulator::GetPriv will trigger again an infinite recursion until the stack
|
||||
* explodes.
|
||||
*/
|
||||
LogSetTimePrinter (0);
|
||||
m_priv->Destroy ();
|
||||
m_priv = 0;
|
||||
}
|
||||
|
||||
30
src/wscript
30
src/wscript
@@ -69,33 +69,27 @@ def create_ns3_module(bld, name, dependencies=()):
|
||||
|
||||
|
||||
def build(bld):
|
||||
Object.register('ns3header', Ns3Header)
|
||||
#Object.register('ns3header', Ns3Header)
|
||||
Action.Action('ns3header', func=_ns3_headers_inst, color='BLUE')
|
||||
Object.register('ns3-module-header', Ns3ModuleHeader)
|
||||
#Object.register('ns3-module-header', Ns3ModuleHeader)
|
||||
Action.Action('gen-ns3-module-header', func=gen_ns3_module_header, color='BLUE')
|
||||
bld.create_ns3_module = types.MethodType(create_ns3_module, bld)
|
||||
|
||||
bld.add_subdirs(list(all_modules))
|
||||
|
||||
for module in all_modules:
|
||||
modheader = bld.create_obj('ns3-module-header')
|
||||
modheader = bld.create_obj('ns3moduleheader')
|
||||
modheader.module = module.split('/')[-1]
|
||||
|
||||
|
||||
class Ns3Header(Object.genobj):
|
||||
class ns3header_taskgen(Object.task_gen):
|
||||
"""A set of NS-3 header files"""
|
||||
def __init__(self, env=None):
|
||||
Object.genobj.__init__(self, 'ns3header')
|
||||
def __init__(self, *features):
|
||||
Object.task_gen.__init__(self, *features)
|
||||
self.inst_var = 'INCLUDEDIR'
|
||||
self.inst_dir = 'ns3'
|
||||
self.sub_dir = None # if not None, header files will be published as ns3/sub_dir/file.h
|
||||
self.module = None # module name
|
||||
self.env = env
|
||||
if not self.env:
|
||||
self.env = Params.g_build.m_allenvs['default']
|
||||
|
||||
def get_valid_types(self):
|
||||
return ['ns3header']
|
||||
|
||||
def apply(self):
|
||||
if self.module is None:
|
||||
@@ -169,17 +163,13 @@ def gen_ns3_module_header(task):
|
||||
return 0
|
||||
|
||||
|
||||
class Ns3ModuleHeader(Object.genobj):
|
||||
class ns3moduleheader_taskgen(Object.task_gen):
|
||||
"""
|
||||
Generates a 'ns3/foo-module.h' header file that includes all
|
||||
public ns3 headers of a certain module.
|
||||
"""
|
||||
def __init__(self, env=None):
|
||||
Object.genobj.__init__(self, 'other')
|
||||
self.install_var = 0
|
||||
self.env = env
|
||||
if not self.env:
|
||||
self.env = Params.g_build.m_allenvs['default'].copy()
|
||||
def __init__(self, *features):
|
||||
Object.task_gen.__init__(self, *features)
|
||||
self.module_name = None
|
||||
|
||||
def apply(self):
|
||||
@@ -187,7 +177,7 @@ class Ns3ModuleHeader(Object.genobj):
|
||||
ns3_dir_node = Params.g_build.m_srcnode.find_dir("ns3")
|
||||
all_headers_inputs = []
|
||||
for ns3headers in Object.g_allobjs:
|
||||
if ns3headers.m_type == 'ns3header':
|
||||
if isinstance(ns3headers, ns3header_taskgen):
|
||||
if ns3headers.module != self.module:
|
||||
continue
|
||||
for source in ns3headers.to_list(ns3headers.source):
|
||||
|
||||
@@ -68,7 +68,7 @@ main (int argc, char *argv[])
|
||||
|
||||
std::ofstream ascii;
|
||||
ascii.open ("tutorial.tr");
|
||||
CsmaHelper::EnableAscii (ascii);
|
||||
CsmaHelper::EnableAsciiAll (ascii);
|
||||
|
||||
Simulator::Run ();
|
||||
Simulator::Destroy ();
|
||||
|
||||
@@ -65,7 +65,7 @@ main (int argc, char *argv[])
|
||||
|
||||
std::ofstream os;
|
||||
os.open ("tutorial.tr");
|
||||
CsmaHelper::EnableAscii (os);
|
||||
CsmaHelper::EnableAsciiAll (os);
|
||||
|
||||
Simulator::Run ();
|
||||
Simulator::Destroy ();
|
||||
|
||||
@@ -61,7 +61,7 @@ main (int argc, char *argv[])
|
||||
apps.Start (Seconds (1.0));
|
||||
apps.Stop (Seconds (10.0));
|
||||
|
||||
CsmaHelper::EnablePcap ("tutorial");
|
||||
CsmaHelper::EnablePcapAll ("tutorial");
|
||||
|
||||
Simulator::Run ();
|
||||
Simulator::Destroy ();
|
||||
|
||||
@@ -137,11 +137,11 @@ main (int argc, char *argv[])
|
||||
|
||||
std::ofstream os;
|
||||
os.open ("tutorial.tr");
|
||||
PointToPointHelper::EnableAscii (os);
|
||||
CsmaHelper::EnableAscii (os);
|
||||
PointToPointHelper::EnableAsciiAll (os);
|
||||
CsmaHelper::EnableAsciiAll (os);
|
||||
|
||||
PointToPointHelper::EnablePcap ("tutorial");
|
||||
CsmaHelper::EnablePcap ("tutorial");
|
||||
PointToPointHelper::EnablePcapAll ("tutorial");
|
||||
CsmaHelper::EnablePcapAll ("tutorial");
|
||||
|
||||
Simulator::Run ();
|
||||
Simulator::Destroy ();
|
||||
|
||||
@@ -71,7 +71,7 @@ main (int argc, char *argv[])
|
||||
|
||||
std::ofstream ascii;
|
||||
ascii.open ("tutorial.tr");
|
||||
PointToPointHelper::EnableAscii (ascii);
|
||||
PointToPointHelper::EnableAsciiAll (ascii);
|
||||
|
||||
Simulator::Run ();
|
||||
Simulator::Destroy ();
|
||||
|
||||
@@ -101,7 +101,7 @@ main (int argc, char *argv[])
|
||||
|
||||
std::ofstream ascii;
|
||||
ascii.open ("tutorial.tr");
|
||||
PointToPointHelper::EnableAscii (ascii);
|
||||
PointToPointHelper::EnableAsciiAll (ascii);
|
||||
|
||||
Simulator::Run ();
|
||||
Simulator::Destroy ();
|
||||
|
||||
@@ -98,7 +98,7 @@ main (int argc, char *argv[])
|
||||
|
||||
std::ofstream ascii;
|
||||
ascii.open ("tutorial.tr");
|
||||
PointToPointHelper::EnableAscii (ascii);
|
||||
PointToPointHelper::EnableAsciiAll (ascii);
|
||||
|
||||
Simulator::Run ();
|
||||
Simulator::Destroy ();
|
||||
|
||||
18
wscript
18
wscript
@@ -6,9 +6,11 @@ import types
|
||||
import optparse
|
||||
import os.path
|
||||
|
||||
import pproc as subprocess
|
||||
|
||||
import Params
|
||||
import Object
|
||||
import pproc as subprocess
|
||||
import ccroot
|
||||
|
||||
Params.g_autoconfig = 1
|
||||
|
||||
@@ -218,6 +220,7 @@ def configure(conf):
|
||||
|
||||
def create_ns3_program(bld, name, dependencies=('simulator',)):
|
||||
program = bld.create_obj('cpp', 'program')
|
||||
program.is_ns3_program = True
|
||||
program.name = name
|
||||
program.target = program.name
|
||||
program.uselib_local = 'ns3'
|
||||
@@ -252,7 +255,7 @@ def build(bld):
|
||||
doxygen()
|
||||
raise SystemExit(0)
|
||||
|
||||
print "Entering directory `%s/build'" % Params.g_build.m_curdirnode.abspath()
|
||||
print "Entering directory `%s'" % os.path.join(Params.g_build.m_curdirnode.abspath(), 'build')
|
||||
# process subfolders from here
|
||||
bld.add_subdirs('src')
|
||||
bld.add_subdirs('samples utils examples tutorial')
|
||||
@@ -300,8 +303,10 @@ def build(bld):
|
||||
lib.target = 'ns3'
|
||||
if env['NS3_ENABLED_MODULES']:
|
||||
lib.add_objects = list(modules)
|
||||
lib.uselib_local = list(modules)
|
||||
else:
|
||||
lib.add_objects = list(env['NS3_MODULES'])
|
||||
lib.uselib_local = list(env['NS3_MODULES'])
|
||||
|
||||
|
||||
def get_command_template():
|
||||
@@ -351,7 +356,7 @@ def _run_waf_check():
|
||||
# --enable-modules=xxx
|
||||
pass
|
||||
else:
|
||||
prog = program_obj.path.find_build(program_obj.get_target_name()).abspath(env)
|
||||
prog = program_obj.path.find_build(ccroot.get_target_name(program_obj)).abspath(env)
|
||||
out = open('doc/introspected-doxygen.h', 'w')
|
||||
if subprocess.Popen([prog], stdout=out, env=proc_env).wait():
|
||||
raise SystemExit(1)
|
||||
@@ -359,12 +364,11 @@ def _run_waf_check():
|
||||
|
||||
run_program('run-tests', get_command_template())
|
||||
|
||||
|
||||
def _find_program(program_name, env):
|
||||
launch_dir = os.path.abspath(Params.g_cwd_launch)
|
||||
found_programs = []
|
||||
for obj in Object.g_allobjs:
|
||||
if obj.m_type != 'program' or not obj.target:
|
||||
if not getattr(obj, 'is_ns3_program', False):
|
||||
continue
|
||||
|
||||
## filter out programs not in the subtree starting at the launch dir
|
||||
@@ -430,7 +434,7 @@ def run_program(program_string, command_template=None):
|
||||
Params.fatal(str(ex))
|
||||
|
||||
try:
|
||||
program_node = program_obj.path.find_build(program_obj.get_target_name())
|
||||
program_node = program_obj.path.find_build(ccroot.get_target_name(program_obj))
|
||||
except AttributeError:
|
||||
Params.fatal("%s does not appear to be a program" % (program_name,))
|
||||
|
||||
@@ -444,7 +448,7 @@ def run_program(program_string, command_template=None):
|
||||
except ValueError, ex:
|
||||
Params.fatal(str(ex))
|
||||
try:
|
||||
program_node = program_obj.path.find_build(program_obj.get_target_name())
|
||||
program_node = program_obj.path.find_build(ccroot.get_target_name(program_obj))
|
||||
except AttributeError:
|
||||
Params.fatal("%s does not appear to be a program" % (program_name,))
|
||||
|
||||
|
||||
Reference in New Issue
Block a user