Steps for conducting the experiment
General Instructions
Follow are the steps to be followed in general to perform the experiments in Advanced Network Technologies Virtual Lab.
- Read the theory about the experiment
- View the simulation provided for a chosen, related problem
- Take the self evaluation to judge your understanding (optional, but recommended)
- Go to the exercises section, choose a problem, and carefully read the problem description
- Write a script (or make necessary changes) to simulate the desired scenario in the code editor just below the problem statement
- Click on the 'Run' button to execute the simulation script
- Simulation with ns2: If the simulation was successful, and was instructed to create a trace file, contents of the trace file would be displayed in the area below the 'Run' button
- Simulation with ns3: If the simulation was successful, output of the program would be displayed in the area below the 'Run' button
- A trace file generated as a result of simulation with ns2 could be used for certain kind of analysis, which would be discussed in a later section
Experiment Specific Instructions
Create two nodes: an access point (AP) and a base station (BS). The BS will sends message to the AP, also the AP will sends a response back to the base station. Since the medium of communication is wireless (over air), the BS could send (or receive) messages to (or from) the AP only when ir is within a certain distance from the AP.
- Create the nodes and hold them in a container:
NodeContainer wifiStaNodes, wifiApNode; wifiStaNodes.Create (nWifi); wifiApNode = wifiStaNodes.Get (0);
- Create channel for communication:
YansWifiChannelHelper channel = YansWifiChannelHelper::Default (); YansWifiPhyHelper phy = YansWifiPhyHelper::Default (); phy.SetChannel (channel.Create ()); WifiHelper wifi = WifiHelper::Default (); wifi.SetRemoteStationManager ("ns3::AarfWifiManager"); NqosWifiMacHelper mac = NqosWifiMacHelper::Default ();
- Set up MAC for base station:
Ssid ssid = Ssid ("ns-3-ssid"); mac.SetType ("ns3::StaWifiMac", "Ssid", SsidValue (ssid), "ActiveProbing", BooleanValue (false)); NetDeviceContainer staDevices; staDevices = wifi.Install (phy, mac, wifiStaNodes.Get (1));
- Set up MAC for AP:
mac.SetType ("ns3::ApWifiMac", "Ssid", SsidValue (ssid), "BeaconGeneration", BooleanValue (true), "BeaconInterval", TimeValue (Seconds (5))); NetDeviceContainer apDevice; apDevice = wifi.Install (phy, mac, wifiApNode);
- Set mobility of the nodes:
MobilityHelper mobility; mobility.SetPositionAllocator ("ns3::GridPositionAllocator", "MinX", DoubleValue (0.0), "MinY", DoubleValue (0.0), "DeltaX", DoubleValue (xDistance), "DeltaY", DoubleValue (10.0), "GridWidth", UintegerValue (3), "LayoutType", StringValue "RowFirst")); mobility.SetMobilityModel ("ns3::ConstantPositionMobilityModel"); mobility.Install (wifiStaNodes);
- Add Internet layers stack:
InternetStackHelper stack; stack.Install (wifiStaNodes);
- Assign IP address to each device:
Ipv4AddressHelper address; Ipv4InterfaceContainer wifiInterfaces, wifiApInterface; address.SetBase "10.1.1.0", "255.255.255.0"); wifiApInterface = address.Assign (apDevice); wifiInterfaces = address.Assign (staDevices);
- Create and setup applications (traffic sink):
UdpEchoServerHelper echoServer (9); // Port # 9 ApplicationContainer serverApps = echoServer.Install (wifiApNode); serverApps.Start (Seconds (1.0)); serverApps.Stop (Seconds (4.0));
- Create and setup applications (traffic source):
UdpEchoClientHelper echoClient (wifiApInterface.GetAddress (0), 9); echoClient.SetAttribute ("MaxPackets", UintegerValue (1)); echoClient.SetAttribute ("Interval", TimeValue (Seconds (1.))); echoClient.SetAttribute ("PacketSize", UintegerValue (1024)); ApplicationContainer clientApps = echoClient.Install (wifiStaNodes.Get (1)); clientApps.Start (Seconds (2.0)); clientApps.Stop (Seconds (3.0)); Ipv4GlobalRoutingHelper::PopulateRoutingTables (); Simulator::Stop (Seconds (4.0));
- Now, verify the distance between two nodes and check for which values of Xdistance you get the reply back from the server.
- For exercise #2, you need to check the number of packet re-transmission that occur in the network. This can be found by counting number of lines that appear in the output.
Trace File Analysis
A simple tool has been provided as part of this lab to analyze the trace files generated after simulation with ns2. A summary of the available options, and usage guide is given below.
Features List
Following is a list of functionalities provided by the Trace Analysis tool:
-
Trace file formats: Following trace file formats are
being supported:
- Wired
- Wireless (new format)
- Satellite -- currently redirects to wired mode
- Mixed -- when both wired and wireless connections are present in the simulation
-
General Statistics: To provide some common statistics
about the simulation being run. Currently displays only the simulation duration.
- Inputs: None
- Output: Text
-
Average Throughput: Computes total # of bytes received
by a node over the entire simulation duration
- Inputs: Node #
- Output: Number
-
Bytes Received: Plots cumulative count of bytes received by
a node over the entire simulation duration
- Inputs: Node #; for wireless scenario, trace levels (AGT, MAC, RTR)
- Output: Graph
-
End-to-end Delay: Plots the end-to-end delay delay encountered
by packets while moving from a source node to the destination node
- Inputs: Source node #, destination node #, scaling factor [optional] -- scaling factor helps to amplify the y-axis values
- Output: Graph
-
Packet Retransmissions: Plots # of retransmission(s) of
a given packet occurs between the source and destination nodes
- Inputs: Source node #, destination node #
- Output: Graph
-
Hop Count: Plots the # of hops traveled by a packet to reach
the destination node from the source node. It counts the destination node as well.
- Inputs: Source node #, source port #, destination node #, destination port #
- Output: Graph
Limitations
- For analyzing the problems in the "Satellite Networks" experiment, please use the Wired mode of analysis
- Analysis of trace files for mixed mode of simulations (wired & wireless) is not supported currently
- Outputs produced do not necessarily have accuracy for scientific publications. In particular, the plot of hop counts may vary a bit from the original count (in wireless mode) in cases when a packet has been forwarded to more than one node.
- The tool currently allows only a single instance of a given type of plot. For example, this doesn't let you plot end-to-end delays between multiple (source, destination) node pairs