tcp burst

main
EmaMaker 2023-12-30 09:16:26 +00:00
parent 9c0e3a6217
commit 44a51e10e3
1 changed files with 109 additions and 47 deletions

View File

@ -62,12 +62,18 @@ int main(int argc, char* argv[])
return 1;
}
// if rts disabled, cts threshold to more than max ever sent
Config::SetDefault("ns3::WifiRemoteStationManager::RtsCtsThreshold", (enableRtsCts ? UintegerValue(100) : UintegerValue(2200)));
// All the nodes, each subnet uses a subset of these.
// A node can belong to multiple subnets
NodeContainer allNodes;
allNodes.Create(16);
/* Topologia della Rete*/
/* ######################################################## */
/* ----- Start of Subnets setup ----- */
// Reti PTP
/* SOTTORETE PTP Node 0,2 */
@ -75,7 +81,7 @@ int main(int argc, char* argv[])
nodes02.Add(allNodes.Get(0));
nodes02.Add(allNodes.Get(2));
PointToPointHelper ptph02;
ptph02.SetDeviceAttribute("DataRate", StringValue("00Mbps"));
ptph02.SetDeviceAttribute("DataRate", StringValue("10Mbps"));
ptph02.SetChannelAttribute("Delay", StringValue("200ms"));
NetDeviceContainer ptp02 = ptph02.Install(nodes02);
/* SOTTORETE PTP Node 1,2 */
@ -148,7 +154,6 @@ int main(int argc, char* argv[])
csmah5678.SetChannelAttribute("Delay", TimeValue(MicroSeconds(20)));
NetDeviceContainer csma5678 = csmah5678.Install(nodes5678);
// Rete Wi-Fi AARF 802.11g
/*
Wi-Fi operating in Infrastructure mode, AP is stationary, Stations nodes move with random walk mobility pattern over a bounded square of 30 meters for each side
@ -158,7 +163,7 @@ int main(int argc, char* argv[])
NodeContainer wifiApNode;
wifiApNode.Add(allNodes.Get(9));
// Station devices
// Station devices (e.g. laptops)
NodeContainer wifiStaNodes;
wifiStaNodes.Add(allNodes.Get(10));
wifiStaNodes.Add(allNodes.Get(11));
@ -176,23 +181,20 @@ int main(int argc, char* argv[])
wifi.SetRemoteStationManager("ns3::AarfWifiManager");
// you can do in this way if you want to set a constant data rate
//wifi.SetRemoteStationManager("ns3::ConstantRateWifiManager", "DataMode", StringValue("OfdmRate6Mbps"));
WifiMacHelper mac;
// Infrastructure Mode
Ssid ssid = Ssid("2001600");
// Stations
NetDeviceContainer staDevices;
mac.SetType("ns3::StaWifiMac", "Ssid", SsidValue(ssid), "ActiveProbing", BooleanValue(false));
staDevices = wifi.Install(phy, mac, wifiStaNodes);
// AP
NetDeviceContainer apDevices;
mac.SetType("ns3::ApWifiMac", "Ssid", SsidValue(ssid));
apDevices = wifi.Install(phy, mac, wifiApNode);
// Mobility helper
MobilityHelper mobility;
// Actually needed?
/*mobility.SetPositionAllocator("ns3::GridPositionAllocator",
"MinX",
@ -206,85 +208,141 @@ int main(int argc, char* argv[])
"GridWidth",
UintegerValue(3),
"LayoutType",
StringValue("RowFirst"));
*/
StringValue("RowFirst"));*/
// Stations move with random walk over a square of 30 meters each side
mobility.SetMobilityModel("ns3::RandomWalk2dMobilityModel",
"Bounds",
RectangleValue(Rectangle(-15, 15, -15, 15)));
mobility.Install(wifiStaNodes);
// AP is stationary
mobility.SetMobilityModel("ns3::ConstantPositionMobilityModel");
mobility.Install(wifiApNode);
/* ----- End of subnets setup*/
// TODO: enableRtsCts
/* ######################################################## */
/* IP Addresses*/
/* ---- ROUTING ----- */
// InternetStackHelper for everyone!
InternetStackHelper stack;
stack.Install(allNodes);
// 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
address.SetBase(Ipv4Address("10.1.4.44"), "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
address.SetBase(Ipv4Address("10.1.4.40"), "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
address.SetBase(Ipv4Address("10.1.4.36"), "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
address.SetBase(Ipv4Address("10.1.4.32"), "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
address.SetBase(Ipv4Address("10.1.4.52"), "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
// nodes 1,2
address.SetBase(Ipv4Address("10.1.4.48"), "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
address.SetBase(Ipv4Address("10.1.4.24"), "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
address.SetBase(Ipv4Address("10.1.4.28"), "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
address.SetBase(Ipv4Address("10.1.4.16"), "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);
address.SetBase(Ipv4Address("10.1.4.0"), "255.225.255.240"); // 10.1.9.0/28
Ipv4InterfaceContainer iStations = address.Assign(staDevices);
Ipv4InterfaceContainer iAp = address.Assign(apDevices);
// Set up Routing Table
Ipv4GlobalRoutingHelper::PopulateRoutingTables();
/* ######################################################## */
/* Applications*/
// TCP Burst
/* APPLICATIONS */
/* ----- Start of TCP Burst ----- */
// Server 0 packet sink
// TCP burst traffic of 1821 B for each packet starting at 1.15 s
// Sender: Node 11 Receiver: Server 0
int port0 = 5000;
int port1 = 5001;
// Server 0 that will receive from node 11
Address server0_address1(InetSocketAddress(ipptp02.GetAddress(0), port0));
PacketSinkHelper sinkHelper0_1("ns3::TcpSocketFactory", server0_address1);
ApplicationContainer server0_app1 = sinkHelper0_1.Install(nodes02.Get(0));
server0_app1.Start(Seconds(0));
// Server 0 that will receive from node 15
Address server0_address2(InetSocketAddress(ipptp02.GetAddress(0), port1));
PacketSinkHelper sinkHelper0_2("ns3::TcpSocketFactory", server0_address2);
ApplicationContainer server0_app2 = sinkHelper0_2.Install(nodes02.Get(0));
server0_app2.Start(Seconds(0));
// Server 1 that will receive from node 10
Address server1_address(InetSocketAddress(ipptp12.GetAddress(0), port0));
PacketSinkHelper sinkHelper1("ns3::TcpSocketFactory", server1_address);
ApplicationContainer server1_app = sinkHelper1.Install(nodes12.Get(0));
server1_app.Start(Seconds(0));
// Node 11 that sends to server 0
OnOffHelper onOffHelper_11("ns3::TcpSocketFactory", iStations.GetAddress(1));
onOffHelper_11.SetAttribute("OnTime", StringValue("ns3::ExponentialRandomVariable[Mean=1]"));
onOffHelper_11.SetAttribute("OffTime", StringValue("ns3::ExponentialRandomVariable[Mean=0]"));
onOffHelper_11.SetAttribute("PacketSize", UintegerValue(1821));
AddressValue address0_11(InetSocketAddress(ipptp02.GetAddress(0), port0));
onOffHelper_11.SetAttribute("Remote", address0_11);
onOffHelper_11.SetAttribute("StartTime", StringValue("1.15s"));
ApplicationContainer node11_app;
node11_app.Add(onOffHelper_11.Install(wifiStaNodes.Get(1)));
node11_app.Start(Seconds(1.15));
// Node 15 that sends to server 1
OnOffHelper onOffHelper_10("ns3::TcpSocketFactory", iStations.GetAddress(0));
onOffHelper_10.SetAttribute("OnTime", StringValue("ns3::ExponentialRandomVariable[Mean=1]"));
onOffHelper_10.SetAttribute("OffTime", StringValue("ns3::ExponentialRandomVariable[Mean=0]"));
onOffHelper_10.SetAttribute("PacketSize", UintegerValue(1829));
AddressValue address0_10(InetSocketAddress(InetSocketAddress(ipptp12.GetAddress(0), port0)));
onOffHelper_10.SetAttribute("StartTime", StringValue("3.39s"));
onOffHelper_10.SetAttribute("Remote", address0_10);
ApplicationContainer node10_app;
node10_app.Add(onOffHelper_10.Install(wifiStaNodes.Get(0)));
node10_app.Start(Seconds(3.39));
// Node 15 that sends to server 0
OnOffHelper onOffHelper_15("ns3::TcpSocketFactory", iStations.GetAddress(5));
onOffHelper_15.SetAttribute("OnTime", StringValue("ns3::ExponentialRandomVariable[Mean=1]"));
onOffHelper_15.SetAttribute("OffTime", StringValue("ns3::ExponentialRandomVariable[Mean=0]"));
onOffHelper_15.SetAttribute("PacketSize", UintegerValue(1099));
AddressValue address0_15(InetSocketAddress(ipptp02.GetAddress(0), port1));
onOffHelper_15.SetAttribute("StartTime", StringValue("3.71s"));
onOffHelper_15.SetAttribute("Remote", address0_15);
ApplicationContainer node15_app;
node15_app.Add(onOffHelper_15.Install(wifiStaNodes.Get(5)));
node15_app.Start(Seconds(3.71));
/* ----- End of TCP Burst ----- */
/* ----- Start of UDP Echo ----- */
// UDP Echo application with Client 13 and Server 3
// Size of packet: 1477 Bytes Periodicity: 20ms MaxPackets: 250
@ -295,31 +353,35 @@ int main(int argc, char* argv[])
// 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));
echoClient.SetFill(clientApps.Get(0), "Giulia,Battioni,1986870,Emanuele,Coletta,2001600,Federico,Corsale,1985903,Francesco,Maura,2017683,Marco,Totaro,NonLoSoNonRispondeAiMessaggi");
clientApps.Start(Seconds(0.0));
/* ----- End of UDP Echo ----- */
Ipv4GlobalRoutingHelper::PopulateRoutingTables();
/* ######################################################## */
/* PCAP Tracing */
/* ----- Start of PCAP Tracing ----- */
// Only tracing switches, routers and wifi ap
// Using promiscous mode
if(tracing){
ptph24.EnablePcap("node2 - subnet24", ptp24.Get(0), true);
ptph24.EnablePcap("node4 - subnet24", ptp24.Get(1), true);
ptph49.EnablePcap("node4 - subnet49", ptp49.Get(0), true);
ptph49.EnablePcap("node9 - subnet49", ptp49.Get(1), true);
ptph39.EnablePcap("node3 - subnet39", ptp39.Get(0), true);
ptph39.EnablePcap("node9 - subnet39", ptp39.Get(1), true);
ptph45.EnablePcap("node4 - subnet45", ptp45.Get(0), true);
ptph45.EnablePcap("node5 - subnet45", ptp45.Get(1), true);
ptph35.EnablePcap("node3 - subnet35", ptp35.Get(0), true);
ptph35.EnablePcap("node5 - subnet35", ptp35.Get(1), true);
ptph24.EnablePcap("task-2-subnet24", ptp24.Get(0), true);
ptph24.EnablePcap("task-4-subnet24", ptp24.Get(1), true);
ptph49.EnablePcap("task-4-subnet49", ptp49.Get(0), true);
ptph49.EnablePcap("task-9-subnet49", ptp49.Get(1), true);
ptph39.EnablePcap("task-3-subnet39", ptp39.Get(0), true);
ptph39.EnablePcap("task-9-subnet39", ptp39.Get(1), true);
ptph45.EnablePcap("task-4-subnet45", ptp45.Get(0), true);
ptph45.EnablePcap("task-5-subnet45", ptp45.Get(1), true);
ptph35.EnablePcap("task-3-subnet35", ptp35.Get(0), true);
ptph35.EnablePcap("task-5-subnet35", ptp35.Get(1), true);
}
/* ----- End of PCAP Tracing ----- */
/* ######################################################## */
// Max simulation time: 15s