parent
275caf0540
commit
ffb5006dcd
|
@ -23,6 +23,8 @@ int main(int argc, char* argv[])
|
|||
{
|
||||
// Hello
|
||||
NS_LOG_UNCOND("Hello Task_2001600");
|
||||
LogComponentEnable("UdpEchoClientApplication", LOG_LEVEL_INFO);
|
||||
LogComponentEnable("UdpEchoServerApplication", LOG_LEVEL_INFO);
|
||||
|
||||
/* ### Creazione della Rete ### */
|
||||
|
||||
|
@ -46,7 +48,7 @@ int main(int argc, char* argv[])
|
|||
bool tracing = false;
|
||||
|
||||
// Parse command line arguments
|
||||
// To be passed `./ns3 run task_2001600 --studentId=2001600 --tracing=true --enableRtsCts=true`
|
||||
// To be passed `./ns3 run task_2001600 -- --studentId=2001600 --tracing=true --enableRtsCts=true`
|
||||
CommandLine cmd;
|
||||
cmd.AddValue("studentId", "studentId", studentId);
|
||||
cmd.AddValue("enableRtsCts", "Enable RTS/CTS", enableRtsCts);
|
||||
|
@ -224,25 +226,100 @@ int main(int argc, char* argv[])
|
|||
// InternetStackHelper for everyone!
|
||||
InternetStackHelper stack;
|
||||
stack.Install(allNodes);
|
||||
// TODO: assign IP address to subnets
|
||||
// Assign IP address to subnets
|
||||
Ipv4AddressHelper address;
|
||||
|
||||
// nodes 2,4
|
||||
address.SetBase("10.1.0.0", "255.225.255.252"); // 10.1.0.0/30
|
||||
Ipv4InterfaceContainer ipptp24;
|
||||
ipptp24 = address.Assign(ptp24);
|
||||
|
||||
// nodes 4,5
|
||||
address.SetBase("10.1.1.0", "255.225.255.252"); // 10.1.1.0/30
|
||||
Ipv4InterfaceContainer ipptp45;
|
||||
ipptp45 = address.Assign(ptp45);
|
||||
|
||||
// nodes 3,4
|
||||
address.SetBase("10.1.2.0", "255.225.255.252"); // 10.1.2.0/30
|
||||
Ipv4InterfaceContainer icsma34;
|
||||
icsma34 = address.Assign(csma34);
|
||||
|
||||
// nodes 4,9
|
||||
address.SetBase("10.1.3.0", "255.225.255.252"); // 10.1.3.0/30
|
||||
Ipv4InterfaceContainer ipptp49;
|
||||
ipptp49 = address.Assign(ptp49);
|
||||
|
||||
|
||||
// nodes 0,2
|
||||
address.SetBase("10.1.4.0", "255.225.255.252"); // 10.1.4.0/30
|
||||
Ipv4InterfaceContainer ipptp02;
|
||||
ipptp02 = address.Assign(ptp02);
|
||||
|
||||
// nodes 0,1
|
||||
address.SetBase("10.1.5.0", "255.225.255.252"); // 10.1.5.0/30
|
||||
Ipv4InterfaceContainer ipptp12;
|
||||
ipptp12 = address.Assign(ptp12);
|
||||
|
||||
// nodes 3,5
|
||||
address.SetBase("10.1.8.0", "255.225.255.252"); // 10.1.8.0/30
|
||||
Ipv4InterfaceContainer ipptp35;
|
||||
ipptp35 = address.Assign(ptp35);
|
||||
|
||||
// nodes 3,9
|
||||
address.SetBase("10.1.7.0", "255.225.255.252"); // 10.1.7.0/30
|
||||
Ipv4InterfaceContainer ipptp39;
|
||||
ipptp39 = address.Assign(ptp39);
|
||||
|
||||
// csma nodes
|
||||
address.SetBase("10.1.9.0", "255.225.255.248"); // 10.1.9.0/29
|
||||
Ipv4InterfaceContainer icsma5678;
|
||||
icsma5678 = address.Assign(csma5678);
|
||||
|
||||
// wifi nodes
|
||||
address.SetBase("10.1.6.0", "255.225.255.240"); // 10.1.9.0/28
|
||||
address.Assign(staDevices);
|
||||
address.Assign(apDevices);
|
||||
|
||||
|
||||
/* ######################################################## */
|
||||
/* Applications*/
|
||||
// TODO: applications (Tcp burst, udp echo)
|
||||
// TCP Burst
|
||||
|
||||
// UDP Echo application with Client 13 and Server 3
|
||||
// Size of packet: 1477 Bytes Periodicity: 20ms MaxPackets: 250
|
||||
|
||||
// UDP Echo server
|
||||
UdpEchoServerHelper echoServer(9); // UDP server on port 9
|
||||
ApplicationContainer serverApps = echoServer.Install(allNodes.Get(3));
|
||||
serverApps.Start(Seconds(0.0));
|
||||
|
||||
// UDP Echo client
|
||||
// UDP client targeting server 3 using the IP of the interface connected to the wifi ap
|
||||
|
||||
UdpEchoClientHelper echoClient(ipptp39.GetAddress(0), 9);
|
||||
echoClient.SetAttribute("MaxPackets", UintegerValue(250));
|
||||
echoClient.SetAttribute("Interval", TimeValue(Seconds(1.0)));
|
||||
echoClient.SetAttribute("PacketSize", UintegerValue(1447));
|
||||
|
||||
ApplicationContainer clientApps = echoClient.Install(allNodes.Get(13));
|
||||
clientApps.Start(Seconds(0.0));
|
||||
|
||||
Ipv4GlobalRoutingHelper::PopulateRoutingTables();
|
||||
|
||||
/* ######################################################## */
|
||||
/* PCAP Tracing */
|
||||
if(tracing){
|
||||
ptph24.EnablePcapAll("ptp24", true);
|
||||
ptph35.EnablePcapAll("ptp35", true);
|
||||
ptph45.EnablePcapAll("ptp45", true);
|
||||
ptph39.EnablePcapAll("ptp39", true);
|
||||
ptph49.EnablePcapAll("ptp49", true);
|
||||
}
|
||||
|
||||
/* ######################################################## */
|
||||
// Max simulation time: 15s
|
||||
Simulator::Stop(Seconds(15));
|
||||
|
||||
Simulator::Run();
|
||||
Simulator::Destroy();
|
||||
|
||||
|
|
File diff suppressed because it is too large
Load Diff
Loading…
Reference in New Issue