about summary refs log tree commit diff
path: root/usth/ICT3.16/labworks/4.md
diff options
context:
space:
mode:
Diffstat (limited to 'usth/ICT3.16/labworks/4.md')
-rw-r--r--usth/ICT3.16/labworks/4.md156
1 files changed, 156 insertions, 0 deletions
diff --git a/usth/ICT3.16/labworks/4.md b/usth/ICT3.16/labworks/4.md
new file mode 100644
index 0000000..346daf9
--- /dev/null
+++ b/usth/ICT3.16/labworks/4.md
@@ -0,0 +1,156 @@
+# Network Simulation: Labwork 4
+The code presented in this report is a heavily modified version of the ns-3
+tutorial `third`.
+
+## Wireless Network Topology
+Consider a Wi-Fi network topology of 3 nodes (1 access point AP and 2 stations
+STA1 and STA2) using wireless channel.  The AP is connected to an echo server S
+via LAN channel:
+
+```c++
+NodeContainer p2pNodes;
+p2pNodes.Create (2);  // AP and S
+NodeContainer wifiApNode = p2pNodes.Get (0);
+
+PointToPointHelper pointToPoint;  // LAN channel
+pointToPoint.SetDeviceAttribute ("DataRate", StringValue ("5Mbps"));
+pointToPoint.SetChannelAttribute ("Delay", StringValue ("2ms"));
+NetDeviceContainer p2pDevices = pointToPoint.Install (p2pNodes);
+
+NodeContainer wifiStaNodes;
+wifiStaNodes.Create (2);  // STA 1 and STA2
+
+YansWifiChannelHelper channel = YansWifiChannelHelper::Default ();
+YansWifiPhyHelper phy = YansWifiPhyHelper::Default ();
+phy.SetChannel (channel.Create ());
+
+WifiHelper wifi;
+wifi.SetRemoteStationManager ("ns3::AarfWifiManager");
+
+WifiMacHelper mac;
+Ssid ssid = Ssid ("ns-3-ssid");
+mac.SetType ("ns3::StaWifiMac",
+            "Ssid", SsidValue (ssid),
+            "ActiveProbing", BooleanValue (false));
+NetDeviceContainer staDevices = wifi.Install (phy, mac, wifiStaNodes);
+
+mac.SetType ("ns3::ApWifiMac", "Ssid", SsidValue (ssid));
+NetDeviceContainer apDevices = wifi.Install (phy, mac, wifiApNode);
+
+MobilityHelper mobility;
+mobility.SetPositionAllocator ("ns3::GridPositionAllocator",
+                              "MinX", DoubleValue (0.0),
+                              "MinY", DoubleValue (0.0),
+                              "DeltaX", DoubleValue (5.0),
+                              "DeltaY", DoubleValue (10.0),
+                              "GridWidth", UintegerValue (3),
+                              "LayoutType", StringValue ("RowFirst"));
+
+mobility.SetMobilityModel ("ns3::ConstantPositionMobilityModel");
+mobility.Install (wifiStaNodes);
+mobility.Install (wifiApNode);
+```
+
+## Echo Server
+Implement scenario of STA1 is a client that sends 100 packets within 10 s to S.
+
+```c++
+InternetStackHelper stack;
+stack.Install (p2pNodes);
+stack.Install (wifiStaNodes);
+
+Ipv4AddressHelper address;
+address.SetBase ("10.1.2.0", "255.255.255.0");
+Ipv4InterfaceContainer p2pInterfaces;
+p2pInterfaces = address.Assign (p2pDevices);
+
+address.SetBase ("10.1.1.0", "255.255.255.0");
+address.Assign (staDevices);
+address.Assign (apDevices);
+
+UdpEchoServerHelper echoServer (9);
+
+ApplicationContainer serverApps = echoServer.Install (p2pNodes.Get (1));
+serverApps.Start (Seconds (1.0));
+serverApps.Stop (Seconds (12.0));
+
+UdpEchoClientHelper echoClient (p2pInterfaces.GetAddress (1), 9);
+echoClient.SetAttribute ("MaxPackets", UintegerValue (100));
+echoClient.SetAttribute ("Interval", TimeValue (MilliSeconds (100)));
+echoClient.SetAttribute ("PacketSize", UintegerValue (1024));
+
+ApplicationContainer clientApps = echoClient.Install (wifiStaNodes.Get (0));
+clientApps.Start (Seconds (2.0));
+clientApps.Stop (Seconds (12.0));
+
+Ipv4GlobalRoutingHelper::PopulateRoutingTables ();
+Simulator::Stop (Seconds (12.0));
+```
+
+Capture the pcap trace from the access point, where all traffic in our setup
+has to go through, and run the simulation:
+
+```c++
+phy.EnablePcap ("third", apDevices.Get (0));
+```
+
+The TCP dumped trace is attached as `third-0-1-station`.  There is not much
+to be deduced from it other than that the latency across Wi-Fi is now in
+the order of milliseconds, i.e. tens of times worse than on a typical
+Ethernet configuration.  As expected, there is not any drop due to queuing
+since we set the interval to 100 ms.
+
+In addition, there is Beacon frames (which if I understand correctly
+is to discover devices and keep updated about their stati).  By default
+they are 100 time units or 102.4 ms a part, which explains how the packet
+delivery seems to alternate with the Beacon and Acknowledgement frames.
+
+## Mobile Stations
+Let the two STAs move in a random direction and speed respecting
+to RandomWalk mode:
+
+```c++
+mobility.SetMobilityModel ("ns3::RandomWalk2dMobilityModel", "Bounds",
+                           RectangleValue (Rectangle (-50, 50, -50, 50)));
+mobility.Install (wifiStaNodes);
+```
+
+The TCP dumped trace is attached as `third-0-1-mobile`.  To my surprise,
+there exists only minor differences in delay of the first few packets,
+and the mobile model actually has lower latency:
+
+```diff
+--- third-0-1-station	2021-03-24 22:50:45.137239064 +0700
++++ third-0-1-mobile	2021-03-24 22:46:33.867879542 +0700
+@@ -25,18 +25,18 @@
+ 1.728436 Beacon (ns-3-ssid) [6.0* 9.0 12.0* 18.0 24.0* 36.0 48.0 54.0 Mbit] ESS
+ 1.830836 Beacon (ns-3-ssid) [6.0* 9.0 12.0* 18.0 24.0* 36.0 48.0 54.0 Mbit] ESS
+ 1.933236 Beacon (ns-3-ssid) [6.0* 9.0 12.0* 18.0 24.0* 36.0 48.0 54.0 Mbit] ESS
+-2.006146 ARP, Request who-has 10.1.1.3 (ff:ff:ff:ff:ff:ff) tell 10.1.1.1, length 32
+-2.006162 Acknowledgment RA:00:00:00:00:00:03
+-2.006240 ARP, Request who-has 10.1.1.3 (ff:ff:ff:ff:ff:ff) tell 10.1.1.1, length 32
+-2.006449 ARP, Reply 10.1.1.3 is-at 00:00:00:00:00:05, length 32
+-2.006621 Acknowledgment RA:00:00:00:00:00:05
+-2.008131 IP 10.1.1.1.49153 > 10.1.2.2.9: UDP, length 1024
+-2.008147 Acknowledgment RA:00:00:00:00:00:03
+-2.021537 ARP, Request who-has 10.1.1.1 (ff:ff:ff:ff:ff:ff) tell 10.1.1.3, length 32
+-2.021795 ARP, Reply 10.1.1.1 is-at 00:00:00:00:00:03, length 32
+-2.021811 Acknowledgment RA:00:00:00:00:00:03
+-2.021961 IP 10.1.2.2.9 > 10.1.1.1.49153: UDP, length 1024
+-2.023498 Acknowledgment RA:00:00:00:00:00:05
++2.002146 ARP, Request who-has 10.1.1.3 (ff:ff:ff:ff:ff:ff) tell 10.1.1.1, length 32
++2.002162 Acknowledgment RA:00:00:00:00:00:03
++2.002240 ARP, Request who-has 10.1.1.3 (ff:ff:ff:ff:ff:ff) tell 10.1.1.1, length 32
++2.002449 ARP, Reply 10.1.1.3 is-at 00:00:00:00:00:05, length 32
++2.002621 Acknowledgment RA:00:00:00:00:00:05
++2.004131 IP 10.1.1.1.49153 > 10.1.2.2.9: UDP, length 1024
++2.004147 Acknowledgment RA:00:00:00:00:00:03
++2.014537 ARP, Request who-has 10.1.1.1 (ff:ff:ff:ff:ff:ff) tell 10.1.1.3, length 32
++2.014795 ARP, Reply 10.1.1.1 is-at 00:00:00:00:00:03, length 32
++2.014811 Acknowledgment RA:00:00:00:00:00:03
++2.014961 IP 10.1.2.2.9 > 10.1.1.1.49153: UDP, length 1024
++2.016498 Acknowledgment RA:00:00:00:00:00:05
+ 2.035636 Beacon (ns-3-ssid) [6.0* 9.0 12.0* 18.0 24.0* 36.0 48.0 54.0 Mbit] ESS
+ 2.101510 IP 10.1.1.1.49153 > 10.1.2.2.9: UDP, length 1024
+ 2.101526 Acknowledgment RA:00:00:00:00:00:03
+```