Exctract data from xml file

6,688 views
Skip to first unread message

Anthony Faustine

unread,
Jul 7, 2012, 5:41:03 AM7/7/12
to ns-3-...@googlegroups.com
help how can i extract data from xml file generated by flow monitor
and plot the values on gnuplot say flow no Vs throughput

Massoudi Radhouene

unread,
Jul 7, 2012, 7:03:51 AM7/7/12
to ns-3-...@googlegroups.com
extract with languge awk its very essaiy

2012/7/7 Anthony Faustine <samb...@gmail.com>
help how can i extract data from xml file generated by flow monitor
and plot the values on gnuplot say flow no Vs throughput

--
You received this message because you are subscribed to the Google Groups "ns-3-users" group.
To post to this group, send email to ns-3-...@googlegroups.com.
To unsubscribe from this group, send email to ns-3-users+...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/ns-3-users?hl=en.


Konstantinos

unread,
Jul 8, 2012, 12:09:24 PM7/8/12
to ns-3-...@googlegroups.com
Hi Anthony,

Therey is no need to parse the XML file, even no need to create one if you don't.
You can aceess the flowmonitor data within your simulation script.

Here is an example:

// Print per flow statistics
//This is after Simulator::Run() and assuming monitor is Ptr<FlowMonitor> monitor = flowmon.InstallAll();

monitor->CheckForLostPackets (); Ptr<Ipv4FlowClassifier> classifier = DynamicCast<Ipv4FlowClassifier> (flowmon.GetClassifier ()); std::map<FlowId, FlowMonitor::FlowStats> stats = monitor->GetFlowStats (); for (std::map<FlowId, FlowMonitor::FlowStats>::const_iterator iter = stats.begin (); iter != stats.end (); ++iter) { Ipv4FlowClassifier::FiveTuple t = classifier->FindFlow (iter->first); NS_LOG_UNCOND("Flow ID: " << iter->first << " Src Addr " << t.sourceAddress << " Dst Addr " << t.destinationAddress); NS_LOG_UNCOND("Tx Packets = " << iter->second.txPackets); NS_LOG_UNCOND("Rx Packets = " << iter->second.rxPackets); NS_LOG_UNCOND("Throughput: " << iter->second.rxBytes * 8.0 / (iter->second.timeLastRxPacket.GetSeconds()-iter->second.timeFirstTxPacket.GetSeconds()) / 1024 << " Kbps"); }

So you will have in the output the FlowID with any information you want.
Then you can pipe the output to a file. You can also select cetrain Flows to print and not everything (eg. only data traffic and not the broadcast signalling messages)

Ahmed Alhamdany

unread,
Jul 8, 2012, 3:48:06 PM7/8/12
to ns-3-...@googlegroups.com
Hi  Anthony,
As Konstantinos said, you can plot your flow monitor statistics directly within your script and no need for xml file.

What follows is an extended example of Konstantinos :

// This is after declaring your network infrastructure and protocols

//Gnuplot parameters

 string fileNameWithNoExtension = "FlowVSThroughput";
      string graphicsFileName        = fileNameWithNoExtension + ".png";
      string plotFileName            = fileNameWithNoExtension + ".plt";
      string plotTitle               = "Flow vs Throughput";
      string dataTitle               = "Throughput";

      // Instantiate the plot and set its title.
      Gnuplot gnuplot (graphicsFileName);
      gnuplot.SetTitle (plotTitle);

      // Make the graphics file, which the plot file will be when it
      // is used with Gnuplot, be a PNG file.
      gnuplot.SetTerminal ("png");

      // Set the labels for each axis.
      gnuplot.SetLegend ("Flow", "Throughput");

     
      Gnuplot2dDataset dataset;
      dataset.SetTitle (dataTitle);
      dataset.SetStyle (Gnuplot2dDataset::LINES_POINTS);

  // Flow Monitor
  Ptr<FlowMonitor> monitor;
           FlowMonitorHelper flowmon_helper;
 
           monitor = flowmon_helper.InstallAll();
  NS_LOG_INFO ("Run Simulation.");
   Simulator::Stop (Seconds (TotalTime));
  Simulator::Run ();
  NS_LOG_UNCOND("Flow monitor statistics: ");

 
  // Print per flow statistics
    monitor->CheckForLostPackets ();
    Ptr<Ipv4FlowClassifier> classifier = DynamicCast<Ipv4FlowClassifier>
  (flowmon_helper.GetClassifier ());

    std::map< FlowId, FlowMonitor::FlowStats > stats = monitor->GetFlowStats ();



double Throughput=0.0;


   for (std::map<FlowId, FlowMonitor::FlowStats>::const_iterator iter =
  stats.begin (); iter != stats.end (); ++iter)
      {
    
    Ipv4FlowClassifier::FiveTuple t = classifier->FindFlow (iter->first);
         NS_LOG_UNCOND("Flow ID: " << iter->first << " Src Addr " <<
  t.sourceAddress << " Dst Addr " << t.destinationAddress);
        NS_LOG_UNCOND("Tx Packets = " << iter->second.txPackets);
        NS_LOG_UNCOND("Rx Packets = " << iter->second.rxPackets);
        Throughput=iter->second.rxBytes * 8.0 /
          (iter->second.timeLastRxPacket.GetSeconds()-iter->second.timeFirstTxPacket.GetSeconds())
          / 1024;
     //NS_LOG_UNCOND("Throughput: " <<  Throughput << " Kbps");
        dataset.Add((double)iter->first,(double) Throughput);
     
      }

      NS_LOG_UNCOND("Done");

//Gnuplot ...continued
 
    gnuplot.AddDataset (dataset);

             // Open the plot file.
             ofstream plotFile (plotFileName.c_str());

             // Write the plot file.
             gnuplot.GenerateOutput (plotFile);

             // Close the plot file.
             plotFile.close ();
  Simulator::Destroy ();

Ahmed Alhamdany

unread,
Jul 8, 2012, 3:50:26 PM7/8/12
to ns-3-...@googlegroups.com
Thank you so much Konstantinos for your example. It is really helpful.

Massoudi Radhouene

unread,
Jul 8, 2012, 6:39:50 PM7/8/12
to ns-3-...@googlegroups.com
please ahmed give me code and include and thinks 

2012/7/8 Ahmed Alhamdany <flower...@gmail.com>
Thank you so much Konstantinos for your example. It is really helpful.

--
You received this message because you are subscribed to the Google Groups "ns-3-users" group.
To view this discussion on the web visit https://groups.google.com/d/msg/ns-3-users/-/5IMn1v3dvKkJ.

Anthony Faustine

unread,
Jul 8, 2012, 11:15:27 PM7/8/12
to ns-3-...@googlegroups.com

Okay thanks for this

--
You received this message because you are subscribed to the Google Groups "ns-3-users" group.
To view this discussion on the web visit https://groups.google.com/d/msg/ns-3-users/-/6iP8GUZ7tVcJ.

Anthony Faustine

unread,
Jul 9, 2012, 6:21:10 AM7/9/12
to ns-3-...@googlegroups.com
Hello bro could you send the complete code..

Leticia

unread,
Jul 21, 2012, 3:24:44 PM7/21/12
to ns-3-...@googlegroups.com
Hi!

I tried to probe the code of Konstantino in my LTE scenario and I have the following exception:
 assert failed. cond="cur->tid != tag.GetInstanceTypeId ()", file=../src/network/model/packet-tag-list.cc, line=139 terminate called without an active exception

Do you have an idea of what can be wrong in the code?

Thank you very much!

Leticia

Konstantinos

unread,
Jul 21, 2012, 7:06:49 PM7/21/12
to ns-3-...@googlegroups.com


On Saturday, 21 July 2012 20:24:44 UTC+1, Leticia wrote:
Hi!

I tried to probe the code of Konstantino in my LTE scenario and I have the following exception:
 assert failed. cond="cur->tid != tag.GetInstanceTypeId ()", file=../src/network/model/packet-tag-list.cc, line=139 terminate called without an active exception


Hi, are you using the EPC in your LTE network? If yes, then you should only install the FlowMonitor on uEs, eNB and any other remote server nodes.
Do not use the InstallAll() because the mgw works only on L2 not L3 so flowmonitor (which works on L3) crashes.
 

Leticia

unread,
Jul 26, 2012, 3:53:23 PM7/26/12
to ns-3-...@googlegroups.com
Thank you very much Konstantinos!Yes I am using EPC! 
I did what you say and  work it well !

Regards 

Leticia

Saulo da Mata

unread,
Jan 17, 2013, 5:05:35 AM1/17/13
to ns-3-...@googlegroups.com
Hi everyone,

I got the same "assert failed" problem and I used the Konstantinos`s tip to solve it. However, when I tried to parse the .xml file with the script flowmon-parse-results.py I got the following error:

File "./flowmon-parse-results.py", line 94, in __init__
    flow_map[flowId].fiveTuple = FiveTuple( flow_cls )
KeyError: 7


Indeed, there is not a <Flow flowId="7" in the <FlowStats> tag, but there is a <Flow flowId="7" in the <Ipv4FlowClassifier> tag (see the attached file).

Anyone else faced this problem?

I`m using the LTE EPC example in ns-3.16.


Thanks.
flow_monitor.xml

Saulo da Mata

unread,
Jan 22, 2013, 4:04:09 AM1/22/13
to ns-3-...@googlegroups.com
Hi guys,

I`m still having problem to parse the .xml file with the script flowmon-parse-results.py.

Could someone send me a .xml file from lena-simple-epc? Maybe I can find what is wrong with mine.

Thanks!


--
You received this message because you are subscribed to the Google Groups "ns-3-users" group.
To view this discussion on the web visit https://groups.google.com/d/msg/ns-3-users/-/Au0qHsLczx8J.

To post to this group, send email to ns-3-...@googlegroups.com.
To unsubscribe from this group, send email to ns-3-users+...@googlegroups.com.

For more options, visit this group at http://groups.google.com/group/ns-3-users?hl=en.



--
Saulo Henrique da Mata
Federal University of Uberlândia - Brazil

Zoraze Ali

unread,
Jan 22, 2013, 7:33:44 AM1/22/13
to ns-3-...@googlegroups.com
Hi Konstantinos,

As you mentioned that we can select only the data traffic to print with the help of flow monitor, can just bit explain it how i can do that ?

Thanks.

Saulo da Mata

unread,
Jan 22, 2013, 12:09:42 PM1/22/13
to ns-3-...@googlegroups.com
Hi everyone

I`ve solved my problem. I thought that I was not supposed to install Flow Monitor only on the Gateway (pgw), but actually it should not be installed in the eNBs as well.

Now I can parse the .xml file using the python script.




Saulo da Mata

Konstantinos

unread,
Jan 22, 2013, 12:14:51 PM1/22/13
to ns-3-...@googlegroups.com
Hi Zoraze,

You can use simple "if" statements to control if you want to print something on the screen.

For example:

if (t.sourceAddress == Ipv4Address("10.10.10.10"){
  NS_LOG_UNCOND("Flow ID: " << iter->first << " Src Addr " << t.sourceAddress << " Dst Addr " << t.destinationAddress);
  ..
}

will print only the flows that the IP address of the source is 10.10.10.10
Similarly, you can control it for destination IPs, ports etc.

Zoraze Ali

unread,
Jan 22, 2013, 12:28:00 PM1/22/13
to ns-3-...@googlegroups.com
Hi Kostantinos,

Actually i have the following stats from the flow monitor , Now as its mention 2296 bytes transmitted but as i created a packet of 300 bytes using onoff application. So i am interested to get the delay of that particular packet.Below are 7 packets mentioned so how i could know which is my packet out of these 7 because i think signaling bytes are also included in these stats.


<Flow flowId="1" timeFirstTxPacket="+2092792468.0ns" timeFirstRxPacket="+2113000000.0ns" timeLastTxPacket="+9945470707.0ns" timeLastRxPacket="+9964000000.0ns" delaySum="+131887078.0ns" jitterSum="+8730531.0ns" lastDelay="+18529293.0ns" txBytes="2296" rxBytes="2296" txPackets="7" rxPackets="7" lostPackets="0" timesForwarded="0">

Regards,
Zoraze

Zoraze Ali

unread,
Jan 22, 2013, 12:28:18 PM1/22/13
to ns-3-...@googlegroups.com
Hi Kostantinos,

Actually i have the following stats from the flow monitor , Now as its mention 2296 bytes transmitted but as i created a packet of 300 bytes using onoff application. So i am interested to get the delay of that particular packet.Below are 7 packets mentioned so how i could know which is my packet out of these 7 because i think signaling bytes are also included in these stats.


<Flow flowId="1" timeFirstTxPacket="+2092792468.0ns" timeFirstRxPacket="+2113000000.0ns" timeLastTxPacket="+9945470707.0ns" timeLastRxPacket="+9964000000.0ns" delaySum="+131887078.0ns" jitterSum="+8730531.0ns" lastDelay="+18529293.0ns" txBytes="2296" rxBytes="2296" txPackets="7" rxPackets="7" lostPackets="0" timesForwarded="0">

Regards,
Zoraze

On Tuesday, January 22, 2013 6:14:51 PM UTC+1, Konstantinos wrote:

Konstantinos

unread,
Jan 22, 2013, 12:47:12 PM1/22/13
to ns-3-...@googlegroups.com
Is this flow, the one that is generated due to the OnOff application? 
FlowMonitor will only account 'IP' level bytes. No overhead from lower than IP header. So, your 300bytes will become 328 = 300 (application) + 20 (IP) + 8 (udp).
You can reduce by 28bytes your application, if you want to test 300 at the IP level.

Also, what do you mean by which is your packet out of these 7. They are ALL generated from your application. Your application does not sent only one packet and then stops. Based on your data rate / on-off conficuration / simulation time etc will generate packets.

Zoraze Ali

unread,
Jan 22, 2013, 1:22:46 PM1/22/13
to ns-3-...@googlegroups.com
Hi Kostantinos,

Yes that flow was generated due to onoff application . And thanks a lot now i understand it better.

Regards,
Zoraze

Preethi Chandur

unread,
Feb 6, 2013, 1:02:41 AM2/6/13
to ns-3-...@googlegroups.com
Hello Konstantinos,

I am using EPC in my LTE simulation and I want to gather data at the three sector antenna eNB. I have installed FlowMonitor separantely on the UE nodes, eNB and the remotehost, but I am still getting the same error as that of Leticia:


assert failed. cond="cur->tid != tag.GetInstanceTypeId ()", file=../src/network/model/
packet-tag-list.cc, line=139 terminate called without an active exception

Do you think the problem is because of the three sector antenna?

Regards,
Preethi

Dmitry Zvikhachevskiy

unread,
Feb 12, 2013, 8:19:20 AM2/12/13
to ns-3-...@googlegroups.com
hello
Konstantinos
 , i added this code in my script

  Simulator::Run();

monitor->SerializeToXmlFile ("results.xml" , true, true );


 monitor->CheckForLostPackets ();
Ptr<Ipv4FlowClassifier> classifier = DynamicCast<Ipv4FlowClassifier> (flowmon.GetClassifier ());
std::map<FlowId, FlowMonitor::FlowStats> stats = monitor->GetFlowStats ();

for (std::map<FlowId, FlowMonitor::FlowStats>::const_iterator iter = stats.begin (); iter != stats.end (); ++iter)
  {
  Ipv4FlowClassifier::FiveTuple t = classifier->FindFlow (iter->first);

       NS_LOG_UNCOND("Flow ID: " << iter->first << " Src Addr " << t.sourceAddress << " Dst Addr " << t.destinationAddress);
          NS_LOG_UNCOND("Tx Packets = " << iter->second.txPackets);
          NS_LOG_UNCOND("Rx Packets = " << iter->second.rxPackets);
          NS_LOG_UNCOND("Throughput: " << iter->second.rxBytes * 8.0 / (iter->second.timeLastRxPacket.GetSeconds()-iter->second.timeFirstTxPacket.GetSeconds()) / 1024  << " Kbps");
  }

but i got an error

../scratch/lena-simple-epc.cc: In function ‘int main(int, char**)’:
../scratch/lena-simple-epc.cc:218:3: error: incomplete type ‘ns3::Ipv4FlowClassifier’ used in nested name specifier
../scratch/lena-simple-epc.cc:218:33: error: expected ‘;’ before ‘t’
../scratch/lena-simple-epc.cc:220:5: error: ‘t’ was not declared in this scope
In file included from ./ns3/config.h:23:0,
                 from ./ns3/lte-helper.h:24,
                 from ../scratch/lena-simple-epc.cc:21:
./ns3/ptr.h: In function ‘ns3::Ptr<T> ns3::DynamicCast(const ns3::Ptr<T2>&) [with T1 = ns3::Ipv4FlowClassifier, T2 = ns3::FlowClassifier]’:
../scratch/lena-simple-epc.cc:213:95:   instantiated from here
./ns3/ptr.h:375:55: error: cannot dynamic_cast ‘ns3::PeekPointer [with T = ns3::FlowClassifier]((* & p))’ (of type ‘class ns3::FlowClassifier*’) to type ‘struct ns3::Ipv4FlowClassifier*’ (target is not pointer or reference to complete type)
./ns3/ptr.h: In destructor ‘ns3::Ptr<T>::~Ptr() [with T = ns3::Ipv4FlowClassifier]’:
../scratch/lena-simple-epc.cc:213:95:   instantiated from here
./ns3/ptr.h:456:7: error: invalid use of incomplete type ‘struct ns3::Ipv4FlowClassifier’
./ns3/flow-monitor-helper.h:32:7: error: forward declaration of ‘struct ns3::Ipv4FlowClassifier’
./ns3/ptr.h: In member function ‘void ns3::Ptr<T>::Acquire() const [with T = ns3::Ipv4FlowClassifier]’:
./ns3/ptr.h:441:3:   instantiated from ‘ns3::Ptr<T>::Ptr(const ns3::Ptr<T>&) [with T = ns3::Ipv4FlowClassifier, ns3::Ptr<T> = ns3::Ptr<ns3::Ipv4FlowClassifier>]’
../scratch/lena-simple-epc.cc:213:95:   instantiated from here
./ns3/ptr.h:410:7: error: invalid use of incomplete type ‘struct ns3::Ipv4FlowClassifier’
./ns3/flow-monitor-helper.h:32:7: error: forward declaration of ‘struct ns3::Ipv4FlowClassifier’
./ns3/ptr.h: In function ‘ns3::Ptr<T> ns3::DynamicCast(const ns3::Ptr<T2>&) [with T1 = ns3::Ipv4FlowClassifier, T2 = ns3::FlowClassifier]’:
./ns3/ptr.h:376:1: error: control reaches end of non-void function [-Werror=return-type]
cc1plus: all warnings being treated as errors
Waf: Leaving directory `/home/dmitry/lena/build'
Build failed

what does it mean?

Konstantinos

unread,
Feb 12, 2013, 8:23:08 AM2/12/13
to ns-3-...@googlegroups.com
Dear Dmitry,

Have you included the proper header files? "ns3/flowmonitor-module.h"
Message has been deleted

Dmitry Zvikhachevskiy

unread,
Feb 12, 2013, 8:35:36 AM2/12/13
to ns-3-...@googlegroups.com
owwww, thanks, it is working !!!
what is it Tx Packets and Rx packets?
i got
Setting up flow monitor... done !
Simulation started !
Flow ID: 1 Src Addr 1.0.0.2 Dst Addr 7.0.0.2
Tx Packets = 50
Rx Packets = 49
Throughput: 81.9533 Kbps
Flow ID: 2 Src Addr 1.0.0.2 Dst Addr 7.0.0.3
Tx Packets = 50
Rx Packets = 49
Throughput: 81.9533 Kbps
Flow ID: 3 Src Addr 7.0.0.2 Dst Addr 1.0.0.2
Tx Packets = 50
Rx Packets = 49
Throughput: 81.8213 Kbps
Flow ID: 4 Src Addr 7.0.0.2 Dst Addr 7.0.0.3
Tx Packets = 50
Rx Packets = 49
Throughput: 81.9367 Kbps
Flow ID: 5 Src Addr 7.0.0.3 Dst Addr 7.0.0.2
Tx Packets = 50
Rx Packets = 49
Throughput: 81.9367 Kbps
Flow ID: 6 Src Addr 7.0.0.3 Dst Addr 1.0.0.2
Tx Packets = 50
Rx Packets = 49
Throughput: 81.8213 Kbps
Simulation end

if i want to get latency, end to end delay , packet loss what i need to do?
Is it possible to simulate this parameters?
вторник, 12 февраля 2013 г., 13:23:08 UTC пользователь Konstantinos написал:

Konstantinos

unread,
Feb 12, 2013, 9:02:25 AM2/12/13
to ns-3-...@googlegroups.com
Please study the FlowMonitor class and what it can provide before making questions and asking for help.

Zoraze Ali

unread,
Feb 12, 2013, 9:29:32 AM2/12/13
to ns-3-...@googlegroups.com
Hi ,

an any one please give me any suggestion on my question . Here is the link.

https://groups.google.com/d/msg/ns-3-users/mcqxvvFRgBM/cwXuT0ofnScJ

Regards,
Zoraze

Preethi Chandur

unread,
Feb 15, 2013, 5:56:50 AM2/15/13
to ns-3-...@googlegroups.com
Hello Konstantinos,

I want to gather the packet drop, load and throughput statistics at eNB. Can you please let me know what would be the best way to record it? I tried using Flow monitor, but only the statistics of flows from the source and destination are beign displayed. Is there any way of monitoring the flows on a link basis?

Regards,
Preethi

coderc...@gmail.com

unread,
Mar 6, 2013, 1:32:46 PM3/6/13
to ns-3-...@googlegroups.com
Hi,

I am using the EPC example and I am trying to parse the XML file.  My problem is during the parsing itself.  Does flowmon-parse-results.py   need to be altered in any way because I keep getting this error: 

Reading XML file 
Traceback (most recent call last):
  File "scratch/sample-simulator.py", line 144, in <module>
    main( sys.argv )
  File "scratch/sample-simulator.py", line 118, in main
    for event, elem in ElementTree.iterparse( file_obj, events=( "start", "end" ) ):
  File "<string>", line 91, in next
cElementTree.ParseError: not well-formed (invalid token): line 1, column 2

As can be seen from the first line, the parsing has started and managed to print out: Reading XML file 

Any insight please? 



tollelm

unread,
May 1, 2013, 12:19:07 PM5/1/13
to ns-3-...@googlegroups.com
hello 






Konstantinos 
 
I get this output when I run the code 
i dont know what is wrong 
can you help me please 
set terminal pngset output 'FlowVSThroughput.png'
set title 'Flow vs Throughput'set xlabel 'Flow'set ylabel 'Throughput'plot '-'  title 'Throughput' with linespointse
  // Print per flow statistics
    monitor->CheckForLostPackets ();
    Ptr<Ipv4FlowClassifier> classifier = DynamicCast<Ipv4FlowClassifier>
  (flowmon_helper.GetClassifier ());

    std::map< FlowId, FlowMonitor::FlowStats > stats = monitor->GetFlowStats ();



double Throughput=0.0;


   for (std::map<FlowId, FlowMonitor::FlowStats>::const_iterator iter =
  stats.begin (); iter != stats.end (); ++iter)
      {
    
    Ipv4FlowClassifier::FiveTuple t = classifier->FindFlow (iter->first);
         NS_LOG_UNCOND("Flow ID: " << iter->first << " Src Addr " <<
  t.sourceAddress << " Dst Addr " << t.destinationAddress);
        NS_LOG_UNCOND("Tx Packets = " << iter->second.txPackets);
        NS_LOG_UNCOND("Rx Packets = " << iter->second.rxPackets);
        Throughput=iter->second.rxBytes * 8.0 /
          (iter->second.timeLastRxPacket.GetSeconds()-iter->second.timeFirstTxPacket.GetSeconds())
          / 1024;

     //NS_LOG_UNCOND("Throughput: " <<  Throughput << " Kbps");
        dataset.Add((double)iter->first,(double) Throughput);
     
      }

      NS_LOG_UNCOND("Done");

//Gnuplot ...continued
 
    gnuplot.AddDataset (dataset);

             // Open the plot file.
             ofstream plotFile (plotFileName.c_str());

             // Write the plot file.
             gnuplot.GenerateOutput (plotFile);

             // Close the plot file.
             plotFile.close ();
  Simulator::Destroy ();

}


Mary.B

unread,
Nov 4, 2013, 12:47:17 PM11/4/13
to ns-3-...@googlegroups.com
Dear Konstantinos,

I'm new in C++ (have basic background) and ns-3 and I need to complete my project in ns-3.
I need to use something like FlowMonitor to track lost packets flowing form a source to a destination for IPv6 packets and I know that FlowMonitor is available just for IPv4. So, may I ask you please about anything similar to FlowMonitor to use in my case? an example would be highly appreciated.

Cheers,
Mary


On Sunday, July 8, 2012 6:09:24 PM UTC+2, Konstantinos wrote:
Hi Anthony,

Therey is no need to parse the XML file, even no need to create one if you don't.
You can aceess the flowmonitor data within your simulation script.

Here is an example:

// Print per flow statistics
//This is after Simulator::Run() and assuming monitor is Ptr<FlowMonitor> monitor = flowmon.InstallAll();

monitor->CheckForLostPackets (); 
Ptr<Ipv4FlowClassifier> classifier = DynamicCast<Ipv4FlowClassifier> (flowmon.GetClassifier ());
std::map<FlowId, FlowMonitor::FlowStats> stats = monitor->GetFlowStats ();

for (std::map<FlowId, FlowMonitor::FlowStats>::const_iterator iter = stats.begin (); iter != stats.end (); ++iter)
  {
  Ipv4FlowClassifier::FiveTuple t = classifier->FindFlow (iter->first);

 	  NS_LOG_UNCOND("Flow ID: " << iter->first << " Src Addr " << t.sourceAddress << " Dst Addr " << t.destinationAddress);
    	  NS_LOG_UNCOND("Tx Packets = " << iter->second.txPackets);
    	  NS_LOG_UNCOND("Rx Packets = " << iter->second.rxPackets);
    	  NS_LOG_UNCOND("Throughput: " << iter->second.rxBytes * 8.0 / (iter->second.timeLastRxPacket.GetSeconds()-iter->second.timeFirstTxPacket.GetSeconds()) / 1024  << " Kbps");
  }

So you will have in the output the FlowID with any information you want.
Then you can pipe the output to a file. You can also select cetrain Flows to print and not everything (eg. only data traffic and not the broadcast signalling messages)

Konstantinos

unread,
Nov 4, 2013, 3:19:40 PM11/4/13
to ns-3-...@googlegroups.com
You can use the TraceMetrics tool (http://www.tracemetrics.net/) or create your own callbacks with trace sources on IP or upper layers (application) for transmission and reception of packets.
Message has been deleted

Konstantinos Katsaros

unread,
Dec 25, 2013, 5:06:31 PM12/25/13
to asmae ahoudi, ns-3-...@googlegroups.com
Hi,

As the name dictates and the documentation explains, delaysum contains the sum of all end-to-end delays for all received packets of the flow.
So, if you want to find the average delay of one packet of that flow, you have to divide the sum with the total number of received packets, which is the rxpackets.

What do you mean "must calculate average for all flow id"? First of all, there is no MUST, no one forces you. Secondly, it depends on what you want to measure. You can look on the delay on only one flow, or more.

See further discussions in the list for more information.

Please send further queries to the ns-3-users mailing list.

Regards,
Konstantinos

-- 
Konstantinos Katsaros

On Tuesday, 24 December 2013 at 11:33, asmae ahoudi wrote:

hi, i'm new in using ns3.
i want to calculate end to end delay using flow monitor, so i've got an xml file which i read with excel,
this file contains different flow id , so how can i calculate the e2e delay. i search in this mailling list and i've got this formule
delay=delaysum/rxpackets (i didn't undertsand it)
2.did  we must calculate the average for all flow id ??

please i need your answer.


ekim6...@gmail.com

unread,
Apr 6, 2015, 2:24:05 AM4/6/15
to ns-3-...@googlegroups.com

Hi.

I need to measure throughput using flowmonitor for IPv6 network.

I made necessary changes in the same code used for IPv4 as below.

  Simulator::Run ();
  monitor->CheckForLostPackets ();
  Ptr<Ipv6FlowClassifier> classifier = DynamicCast<Ipv6FlowClassifier> (flowmon.GetClassifier ());
  std::map<FlowId, FlowMonitor::FlowStats> stats = monitor->GetFlowStats ();

  for (std::map<FlowId, FlowMonitor::FlowStats>::const_iterator iter = stats.begin (); iter != stats.end (); ++iter)
    {
 Ipv6FlowClassifier::FiveTuple t = classifier->FindFlow (iter->first);

        {
     NS_LOG_UNCOND ( "Flow ID: " << iter->first << " Src Addr " << t.sourceAddress << " Dst Addr " << t.destinationAddress);
     NS_LOG_UNCOND ( "Tx Packets = " << iter->second.txPackets);
     NS_LOG_UNCOND ( "Rx Packets = " << iter->second.rxPackets);
     NS_LOG_UNCOND ( "Throughput: " << iter->second.rxBytes * 8.0 / (iter->second.timeLastRxPacket.GetSeconds()-iter->second.timeFirstTxPacket.GetSeconds()) / 1024  << " Kbps");
        }
    }
  monitor->SerializeToXmlFile("lab-5.flowmon", true, true);

Still it is not showing throughput.
Did anyone try it?
Please help....

ekim6...@gmail.com

unread,
Apr 6, 2015, 2:42:33 AM4/6/15
to ns-3-...@googlegroups.com

With respect to above post....

I am using ns3.21.
Does it support flowmonitor for ipv6?

Tommaso Pecorella

unread,
Apr 6, 2015, 3:25:02 AM4/6/15
to ns-3-...@googlegroups.com
Hi,

first things first. you're replying to a thread started 3 years ago, and whose last message was sent in December 2013. Opening a new one was better, but now it's too late.
Second point, please use some logic. If FlowMonitor does have IPv6 probes, how could it be possible that it wouldn't support IPv6 ? I mean... the developer/maintainer would have done a very bad job (or a very bad joke), don't you think ?
Now, I know him, and he loves to do horrible jokes, but not in this case.

Things to check:
1) are you sure that there IS an IPv6 flow ?
2) see point 1
3) if you're sure, attach the script.

Cheers,

T.

ekim6...@gmail.com

unread,
Apr 6, 2015, 11:34:30 PM4/6/15
to ns-3-...@googlegroups.com

First sorry for replying on old thread. One more time I am replying on the same thread to keep continuation.
 Sorry. Next time I will keep this in mind.

I am attaching the script.

Thank you.
ipv6.cc
myapp.h
ipv6.png

Konstantinos

unread,
Apr 7, 2015, 4:53:45 AM4/7/15
to ns-3-...@googlegroups.com
Hi 

It's a routing issue. The router does not know where to forward the packets, as you have not setup any routing rule.

Tommaso Pecorella

unread,
Apr 7, 2015, 5:48:53 AM4/7/15
to ns-3-...@googlegroups.com
Nah, the routing works. It's set manually in a rather simple way, but it's ok.
The problem is... what is the problem ?

AirTom:ns-3-dev pecos$ ./waf --run scratch/test/test
Waf: Entering directory `/Users/pecos/Development/workspace/ns-3-dev/build'
Waf: Leaving directory `/Users/pecos/Development/workspace/ns-3-dev/build'
'build' finished successfully (4.828s)
Application 1
Application 2
Flow ID: 1 Src Addr 2001:1::200:ff:fe00:3 Dst Addr 2001:2::200:ff:fe00:2
Tx Packets = 12
Rx Packets = 12
Throughput: 0.615492 Kbps
Flow ID: 2 Src Addr 2001:2::200:ff:fe00:2 Dst Addr 2001:1::200:ff:fe00:3
Tx Packets = 8
Rx Packets = 8
Throughput: 0.0719307 Kbps
AirTom:ns-3-dev pecos$ 

Moreover, the pcap screenshot clearly shows that everything is ok.

The problem is in the eye of the beholder.

T.

Ravneet Kaur

unread,
Jan 11, 2016, 3:30:29 AM1/11/16
to ns-3-users
Hii Dmitry ,
can send me your complete code @ ravneet....@gmail.com
Actully I have not found any erorr but also no output. Please help
Message has been deleted
Message has been deleted

Gaijouhn Gaybueh

unread,
Feb 11, 2021, 3:38:10 AM2/11/21
to ns-3-users
Hello everyone, I need your help.
How can I print the transmission "Time" in each of my FLOW ID.
I really want to calculate Delay vs Time, Throughput vs Time and so on
Currently, I am getting the value of Delay, Throughput, Receive and Sent Signal but no Time as seen in the attached file.

Best regards.

Gaijouhn

On Monday, July 9, 2012 at 12:09:24 AM UTC+8 Konstantinos wrote:
Hi Anthony,

Therey is no need to parse the XML file, even no need to create one if you don't.
You can aceess the flowmonitor data within your simulation script.

Here is an example:

// Print per flow statistics
//This is after Simulator::Run() and assuming monitor is Ptr<FlowMonitor> monitor = flowmon.InstallAll();

monitor->CheckForLostPackets (); 
Ptr<Ipv4FlowClassifier> classifier = DynamicCast<Ipv4FlowClassifier> (flowmon.GetClassifier ());
std::map<FlowId, FlowMonitor::FlowStats> stats = monitor->GetFlowStats ();

for (std::map<FlowId, FlowMonitor::FlowStats>::const_iterator iter = stats.begin (); iter != stats.end (); ++iter)
  {
  Ipv4FlowClassifier::FiveTuple t = classifier->FindFlow (iter->first);

 	  NS_LOG_UNCOND("Flow ID: " << iter->first << " Src Addr " << t.sourceAddress << " Dst Addr " << t.destinationAddress);
    	  NS_LOG_UNCOND("Tx Packets = " << iter->second.txPackets);
    	  NS_LOG_UNCOND("Rx Packets = " << iter->second.rxPackets);
    	  NS_LOG_UNCOND("Throughput: " << iter->second.rxBytes * 8.0 / (iter->second.timeLastRxPacket.GetSeconds()-iter->second.timeFirstTxPacket.GetSeconds()) / 1024  << " Kbps");
  }
Flow ID.PNG

Rahul Singh Gulia

unread,
Feb 11, 2021, 10:22:38 AM2/11/21
to ns-3-users
Hi,

Can you share your source file for me to look at it.


R.G.

Gaijouhn Gaybueh

unread,
Feb 11, 2021, 12:53:20 PM2/11/21
to ns-3-...@googlegroups.com
Dear Rahul

Thanks for your response. Please find the attached source file for your perusal.

Best regards.

Gaijouhn Gaybueh
Contact #: +8618627165935

Skype: gaijouhn.gaybueh1


--
Posting to this group should follow these guidelines https://www.nsnam.org/wiki/Ns-3-users-guidelines-for-posting
---
You received this message because you are subscribed to a topic in the Google Groups "ns-3-users" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/ns-3-users/teE-cTfkV_Q/unsubscribe.
To unsubscribe from this group and all its topics, send an email to ns-3-users+...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/ns-3-users/5a56d23e-262b-432f-bfc9-d8c956df8973n%40googlegroups.com.
new-wifi-test.cc

Vaibhav Agarwal

unread,
Feb 12, 2021, 2:58:26 AM2/12/21
to ns-3-...@googlegroups.com
Dear gaijouhn,
I have tried to run your file just to gain some knowledge about ns3. But I am getting an error and don't know how to solve this problem. So if you can help me with this I will be thankful to you.

assert failed. cond="uid <= m_information.size () && uid != 0", +0.000000000s -1 file=../src/core/model/type-id.cc, line=462
terminate called without an active exception
Thanks and Regards,
Vaibhav Agarwal,
Research Scholar
ABV-IIITM, Gwalior.



You received this message because you are subscribed to the Google Groups "ns-3-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to ns-3-users+...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/ns-3-users/CAOKoa9GxR0VQWpgDYD9aah_0V-YSNFT2pLDQX6o1aU6W%2BZQCyA%40mail.gmail.com.

Gaijouhn Gaybueh

unread,
Feb 12, 2021, 8:07:56 AM2/12/21
to ns-3-...@googlegroups.com
Dear Vaibhav

I am sorry. I don't have idea on such error

Gaijouhn Gaybueh
Contact #: +8618627165935

Skype: gaijouhn.gaybueh1

Rahul Singh Gulia

unread,
Apr 13, 2021, 9:41:10 AM4/13/21
to ns-3-users
Hello Gaijouhn,

ns3::PropagationDelayModel class takes care of the propagation delay.
Propagation delay ( Tx-Rx Distance / c (speed of light in vacuum)) can be calculated based on 2 inherited models -> ns3::ConstantSpeedPropagationDelayModel and ns3::RandomPropagationDelayModel with their functions GetDelay().
Kindly look at these classes and function to get your propagation delays.

And for transmission delay (L/R), kindly look at the ns3::PointToPointChannel class for reference. It can calculate your transmission delay based on your data rate and packet length. 

Hope this helps,
R.G

On Thursday, February 11, 2021 at 3:38:10 AM UTC-5 gaijouhn...@gmail.com wrote:

Rahul Singh Gulia

unread,
Apr 13, 2021, 9:50:17 AM4/13/21
to ns-3-users
The code is runs fine Vaibhav. 


assert failed. cond="uid <= m_information.size () && uid != 0", +0.000000000s -1 file=../src/core/model/type-id.cc, line=462

Your error seems to be from /src/core/model , and not  from this code. Please build your ns3 version once again to run this code properly.


Regards,
R.G
Reply all
Reply to author
Forward
0 new messages