Flow-Monitor in NS3. A Perfect Tool For Evaluation Purposes. (Throughput, Delay, Jitter, Packet Loss and Other Parameters in NS3)

Flow Monitor:
                A set of evaluation criteria are the focus of every simulation, using which a proposed scheme can be evaluated. In communications, specifically wireless communications, more specifically LTE, major evaluation criteria are:
  • -          Delay (end-to-end mean delay)
  • -          Throughput
  • -          Packet loss ratio
  • -          Mean Jitter
  • -          Mean transmitted packet size (bytes)
  • -          Mean received packet size (bytes)
  • -          Means transmitted bitrate (bit/s)
  • -          Means received bitrate (bit/s)
  • -          Mean hop count
  • -          Lost packets


In any NS3 simulations, you can easily calculate parameters mentioned above using FLOW-MONITOR.

How to use flow-monitor in code:

1-      Include flow-monitor header file.
#include "ns3/flow-monitor-module.h"
2-      Add following code snippet before “Simulator Stop();”. This code will assign a monitor to each node.
Ptr<FlowMonitor> flowMonitor;
FlowMonitorHelper flowHelper;
flowMonitor = flowHelper.InstallAll();
Simulator::Stop(Seconds(simTime));

If you are interested in installing monitor to each node separately, then use “Install” method instead of “InstallAll”. But I would prefer to install flow-monitor on all nodes J .
flowMonitor = flowHelper.Install (nodes);

3-      Finally, we print output to an XML file. Add this line after “Simulator Run();”.
flowMonitor->SerializeToXmlFile("NameOfFile.xml", true, true);


That’s it. Using above three steps, you can easily add flow monitor to all node. The NameOfFile.XML file will be generated in your NS3 directory.

How to visualize output:

The XML file can be viewed by any XML viewer. I found NetAnim (A basic guide to netanim is here) to be the best viewer for the flow monitor.
1-      Open NetAnim (Make sure you see three tabs in netanim, Animator, Stats, and Packets)
2-      Click “Stats” tab
3-      From dropdown menu, select Flow-monitor. (The dropdown menu will show IP-MAC in start)
4-      Click “FlowMon file” button on the right.
5-      Browse to your NS3 directory and select “NameOfFile.XML” file.
6-      The file will display every flow with its parameters and values.
For your convenience J .
 



Using all these values, many evaluation parameters can be calculated. Next section will show you how to calculate those parameters from these values.

Parameters:

Some parameters are directly calculated and rest can be calculated using these formulae.
Throughput (bps): rxBytes*8 / [(timeLastRxPacket/1,000,000,000)- (timeFirstRxPacket/1,000,000,000)]
And
Throughput (Mbps): rxBytes*8 / [(timeLastRxPacket/1,000,000,000)- (timeFirstRxPacket/1,000,000,000)] / 1024 / 1024


 



References and material:
  1. FlowMonitor — a network monitoring framework for the Network Simulator 3 (NS-3), online: http://telecom.inesctec.pt/~gjc/flowmon-presentation.pdf
  2. NS-3 Advanced Tutorial: Visualization and Data Collection, Online: https://www.nsnam.org/tutorials/consortium13/visualization-tutorial.pdf
  3. https://www.nsnam.org/docs/models/html/flow-monitor.html
  4. Throughput: http://comments.gmane.org/gmane.network.simulator.ns3.user/18301
  5. https://groups.google.com/forum/#!topic/ns-3-users/NuScxlCA8H0
  6. https://groups.google.com/forum/#!msg/ns-3-users/Z2pgY6tbJgM/viiOwlfeu4kJ
  7. https://groups.google.com/forum/#!topic/ns-3-users/8rxd2VfHsFg
  8. https://groups.google.com/forum/#!topic/ns-3-users/nXuyOZaazbU

13 comments:

  1. Replies
    1. flowMonitor->SerializeToXmlFile("flow-monitor.xml", true, true);
      This line should be after Simulator::Run () and before Simulator::Destroy ().

      Delete
  2. hello sir,
    the xml file shows no data
    please reply

    ReplyDelete
    Replies
    1. If there is no data then either you have not added flow monitor on the node which is transmitting, or there is no packet flow. Try again from scratch by following the instructions.

      Delete
    2. This comment has been removed by the author.

      Delete
    3. have u shown any data now?

      Delete
  3. Replies
    1. flowMonitor->SerializeToXmlFile("flow-monitor.xml", true, true);
      This line should be after Simulator::Run () and before Simulator::Destroy ().

      Delete
  4. Dear Sir,

    We are thankful to your services about ndnsim.We are giving tips for ndnsim research scholars.Please use our links.

    https://www.youtube.com/channel/UCoojSNObgcYBKxk4IlVH2iw?view_as=subscriber

    http://www.ndnsim.com/

    Thanks

    ReplyDelete
  5. Sir can you share your code. Mine is not working

    ReplyDelete
  6. I tried it for mpi/examples/p2p-nix-distribution code. its not working.

    ReplyDelete

Connecting Arduino Uno with ThingSpeak using ESP 8266 Wi-Fi Module

Connecting Arduino Uno with ThingSpeak using ESP 8266 Wi-Fi Module We will connect ARDUINO with ThingSpeak using TCP Connection and HT...