Here is my code :
[code]
int main(int argc, char *argv[]) {
//Visualitation
GlobalValue::Bind("SimulatorImplementationType",
StringValue("ns3::VisualSimulatorImpl"));
LogComponentEnable("UdpEchoClientApplication", LOG_LEVEL_INFO);
LogComponentEnable("UdpEchoServerApplication", LOG_LEVEL_INFO);
uint32_t numberNodesZone0 = 4;
uint32_t numberNodesZone1 = 4;
uint32_t numberNodesZone2 = 4;
uint32_t numberNodesZone3 = 4;
/**
* Create the zone 0
*/
NodeContainer nodesZone0;
nodesZone0.Create(numberNodesZone0+1);
/**
* Create the zone 1
*/
NodeContainer nodesZone1;
//nodesZone1.Add(nodesZone0.Get(4));
nodesZone1.Add(nodesZone0.Get(numberNodesZone0));
nodesZone1.Create(numberNodesZone1+1);
/**
* Create the zone 2
*/
NodeContainer nodesZone2;
//nodesZone2.Add(nodesZone1.Get(5));
nodesZone2.Add(nodesZone1.Get(numberNodesZone1+1));
nodesZone2.Create(numberNodesZone2+1);
/**
* Create the zone 3
*/
NodeContainer nodesZone3;
//nodesZone3.Add(nodesZone2.Get(5));
nodesZone3.Add(nodesZone2.Get(numberNodesZone2+1));
nodesZone3.Create(numberNodesZone3);
/* The only way I found to install IP stack then. */
NodeContainer nodesZoneTot;
nodesZoneTot.Add(nodesZone0);
nodesZoneTot.Add(nodesZone3);
unsigned int i=0;
for (i=1; i<=numberNodesZone1+1; i++){
nodesZoneTot.Add(nodesZone1.Get(i));
}
for (i=1; i<numberNodesZone2+1; i++){
nodesZoneTot.Add(nodesZone2.Get(i));
}
/**
* Configure the zone 0
*/
CsmaHelper csmaZone0;
csmaZone0.SetChannelAttribute("DataRate", StringValue("100Mbps"));
csmaZone0.SetChannelAttribute("Delay", TimeValue(NanoSeconds(6560)));
NetDeviceContainer zone0Devices;
zone0Devices = csmaZone0.Install(nodesZone0);
/**
* Configure the zone 1
*/
CsmaHelper csmaZone1;
csmaZone1.SetChannelAttribute("DataRate", StringValue("100Mbps"));
csmaZone1.SetChannelAttribute("Delay", TimeValue(NanoSeconds(6560)));
NetDeviceContainer zone1Devices;
zone1Devices = csmaZone1.Install(nodesZone1);
/**
* Configure the zone 2
*/
CsmaHelper csmaZone2;
csmaZone2.SetChannelAttribute("DataRate", StringValue("100Mbps"));
csmaZone2.SetChannelAttribute("Delay", TimeValue(NanoSeconds(6560)));
NetDeviceContainer zone2Devices;
zone2Devices = csmaZone2.Install(nodesZone2);
/**
* Configure the zone 3
*/
CsmaHelper csmaZone3;
csmaZone3.SetChannelAttribute("DataRate", StringValue("100Mbps"));
csmaZone3.SetChannelAttribute("Delay", TimeValue(NanoSeconds(6560)));
NetDeviceContainer zone3Devices;
zone3Devices = csmaZone3.Install(nodesZone3);
/**
* Apply a full Internet stack
* on nodesZoneTot
*/
InternetStackHelper stack;
stack.Install(nodesZoneTot);
// PCAP CONFIGURATION
csmaZone0.EnablePcapAll("orecas0", true);
//Decommenting these lines doesn't change the issue...
//csmaZone1.EnablePcapAll("orecas1");
//csmaZone2.EnablePcapAll("orecas2");
//csmaZone3.EnablePcapAll("orecas3");
/**
* Configure the IP Stack on the zones
*/
Ipv4AddressHelper addressZone0;
addressZone0.SetBase("192.168.1.0", "255.255.255.0");
Ipv4InterfaceContainer zone0Interfaces;
zone0Interfaces = addressZone0.Assign(zone0Devices);
Ipv4AddressHelper addressZone1;
addressZone1.SetBase("192.168.2.0", "255.255.255.0");
Ipv4InterfaceContainer zone1Interfaces;
zone1Interfaces = addressZone1.Assign(zone1Devices);
Ipv4AddressHelper addressZone2;
addressZone2.SetBase("192.168.3.0", "255.255.255.0");
Ipv4InterfaceContainer zone2Interfaces;
zone2Interfaces = addressZone2.Assign(zone2Devices);
Ipv4AddressHelper addressZone3;
addressZone3.SetBase("192.168.4.0", "255.255.255.0");
Ipv4InterfaceContainer zone3Interfaces;
zone3Interfaces = addressZone3.Assign(zone3Devices);
// Reference an UDP server on node 1 of network 4.0 listening on port 80
int portNumber = 80;
//Echo server : wait for input udp packet and sends them back to the original
sender :
UdpEchoServerHelper echoServer(portNumber);
//Install the echoServer
ApplicationContainer serverApps = echoServer.Install(nodesZone3.Get(2));
serverApps.Start(Seconds(1.0));
serverApps.Stop(Seconds(10.0));
//EchoClient : send udp packet and waits for an echo of this packet :
UdpEchoClientHelper echoClient(zone3Interfaces.GetAddress(2), portNumber);
echoClient.SetAttribute("MaxPackets", UintegerValue(100));
echoClient.SetAttribute("Interval", TimeValue(Seconds(0.5)));
echoClient.SetAttribute("PacketSize", UintegerValue(104));
//Install the echoClient
ApplicationContainer clientApps = echoClient.Install(nodesZone0.Get(2));
clientApps.Start(Seconds(1.0));
clientApps.Stop(Seconds(10.0));
Ipv4GlobalRoutingHelper::PopulateRoutingTables();
Simulator::Run();
Simulator::Destroy();
std::cout << "Sockets closed\n";
return 0;
}
[/code]
Thank you for your help.
Hello everyone,
I have just begun using ns3 simulator, and I have some issues concerning my pcap
files... I hope you can help me on this :) Here is the thing :
I have a simple network with 4 subnetworks N0, N1, N2 and N3 where N0 is sending
UDP packets to N3. I would like to create the pcap files using the command
"EnablePcapAll(std::string prefix, bool promiscuous=false)" in order to then
replay my simulation. The issue is that all my created pcaps are empty, and I
don't understand why...