//
// n2-------
// / |
// / |
// n0 ns3----n4-----n5
// \
/ |
// \
/ |
// n1----------------
//
#include <iostream>
#include <fstream>
#include <string>
#include <cassert>
#include "ns3/core-module.h"
#include "ns3/network-module.h"
#include "ns3/internet-module.h"
#include "ns3/point-to-point-module.h"
#include "ns3/applications-module.h"
#include "ns3/ipv4-global-routing-helper.h"
#include "ns3/dce-module.h"
using namespace ns3;
static std::string Ipv4AddressToString (Ipv4Address ad)
{
std::ostringstream oss;
ad.Print (oss);
return oss.str ();
}
NS_LOG_COMPONENT_DEFINE ("DceNavrh");
int
main (int argc, char *argv[])
{
CommandLine cmd;
cmd.Parse (argc, argv);
NodeContainer c;
c.Create (6);
NodeContainer n0n2 = NodeContainer
(c.Get (0), c.Get (2));
NodeContainer n0n1 = NodeContainer (c.Get
(0), c.Get (1));
NodeContainer n2n4 = NodeContainer
(c.Get (2), c.Get (4));
NodeContainer n1n3 = NodeContainer
(c.Get (1), c.Get (3));
NodeContainer n3n4 = NodeContainer
(c.Get (3), c.Get (4));
NodeContainer n1n5 = NodeContainer
(c.Get (1), c.Get (5));
NodeContainer n4n5 = NodeContainer
(c.Get (4), c.Get (5));
DceManagerHelper dceManager;
dceManager.SetNetworkStack
("ns3::LinuxSocketFdFactory", "Library", StringValue ("liblinux.so"));
LinuxStackHelper stack;
stack.Install (c);
PointToPointHelper p2p;
p2p.SetDeviceAttribute
("DataRate", StringValue ("768kbps")); //768kbsp
p2p.SetChannelAttribute
("Delay", StringValue ("0ms"));
NetDeviceContainer d0d2 = p2p.Install
(n0n2);
NetDeviceContainer d0d1 = p2p.Install
(n0n1);
NetDeviceContainer d2d4 = p2p.Install
(n2n4);
NetDeviceContainer d1d3 = p2p.Install
(n1n3);
NetDeviceContainer d3d4 = p2p.Install
(n3n4);
NetDeviceContainer d1d5 = p2p.Install
(n1n5);
NetDeviceContainer d4d5 = p2p.Install
(n4n5);
Ipv4AddressHelper ipv4;
ipv4.SetBase ("10.0.20.0",
"255.255.255.0");
Ipv4InterfaceContainer i0i2 =
ipv4.Assign (d0d2);
ipv4.SetBase ("10.0.10.0",
"255.255.255.0");
Ipv4InterfaceContainer i0i1 =
ipv4.Assign (d0d1);
ipv4.SetBase ("10.20.40.0",
"255.255.255.0");
Ipv4InterfaceContainer i2i4 =
ipv4.Assign (d2d4);
ipv4.SetBase ("10.10.30.0",
"255.255.255.0");
Ipv4InterfaceContainer i1i3 =
ipv4.Assign (d1d3);
ipv4.SetBase ("10.30.40.0",
"255.255.255.0");
Ipv4InterfaceContainer i3i4 =
ipv4.Assign (d3d4);
ipv4.SetBase ("10.10.50.0",
"255.255.255.0");
Ipv4InterfaceContainer i1i5 =
ipv4.Assign (d1d5);
ipv4.SetBase ("10.40.50.0",
"255.255.255.0");
Ipv4InterfaceContainer i4i5 =
ipv4.Assign (d4d5);
Ipv4GlobalRoutingHelper::PopulateRoutingTables ();
dceManager.Install (c);
DceApplicationHelper process;
ApplicationContainer apps;
std::ostringstream oss;
process.SetBinary
("udp-perf");
process.AddArgument
("--duration=100");
process.AddArgument (oss.str ().c_str
());
oss.clear ();
apps = process.Install
(c.Get(0));
apps.Start (Seconds (1.0));
process.SetBinary
("udp-perf");
process.ResetArguments ();
process.AddArgument ("--pktsize=1024");
process.AddArgument (oss.str ().c_str
());
oss.clear ();
process.AddArgument
("--port=9");
process.AddArgument (oss.str ().c_str
());
oss.clear ();
process.AddArgument
("--client");
process.AddArgument (oss.str ().c_str
());
oss.clear ();
oss.str ("");
oss << "--host="
<< Ipv4AddressToString ("10.0.10.1");
process.AddArgument (oss.str ().c_str
());
oss.clear ();
oss.str ("");
process.AddArgument
("--duration=100");
apps = process.Install
(c.Get(5));
apps.Start (Seconds (1.0));
p2p.EnablePcapAll
("merenidce/uzel");
Ptr<Node> n1 = c.Get (1);
Ptr<Ipv4> ipv43 =
n1->GetObject<Ipv4> ();
// The first ifIndex is 0 for loopback, then the first p2p is numbered 1,
// then the next p2p is numbered 2
uint32_t ifIndex3 = 3; // interface 2 on node 1 connecting node 1 with node 5
Simulator::Schedule (Seconds
(60.0),&Ipv4::SetDown,ipv43, ifIndex3);
Simulator::Stop (Seconds
(100.0));
Simulator::Run ();
Simulator::Destroy ();
return 0;
}
thanks a lot for your answer. I tried to change interface number but it didn`t help. Well, it doesn`t show SIGSEGV error now, but the simulation runs and no link failure occurs. So it runs like normal simulation with no failure. I also tried to set down some other interfaces on different nodes, but the result was the same.