|
|
| 25 |
#include "ns3/point-to-point-module.h" |
25 |
#include "ns3/point-to-point-module.h" |
| 26 |
#include "ns3/applications-module.h" |
26 |
#include "ns3/applications-module.h" |
| 27 |
#include "ns3/traffic-control-module.h" |
27 |
#include "ns3/traffic-control-module.h" |
|
|
28 |
#include "ns3/flow-monitor-module.h" |
| 28 |
|
29 |
|
| 29 |
// This simple example shows how to use TrafficControlHelper to install a |
30 |
// This simple example shows how to use TrafficControlHelper to install a |
| 30 |
// QueueDisc on a device. |
31 |
// QueueDisc on a device. |
|
|
| 166 |
apps.Start (Seconds (1.0)); |
167 |
apps.Start (Seconds (1.0)); |
| 167 |
apps.Stop (Seconds (simulationTime + 0.1)); |
168 |
apps.Stop (Seconds (simulationTime + 0.1)); |
| 168 |
|
169 |
|
|
|
170 |
FlowMonitorHelper flowmon; |
| 171 |
Ptr<FlowMonitor> monitor = flowmon.InstallAll(); |
| 172 |
|
| 169 |
Simulator::Stop (Seconds (simulationTime + 0.1)); |
173 |
Simulator::Stop (Seconds (simulationTime + 0.1)); |
| 170 |
Simulator::Run (); |
174 |
Simulator::Run (); |
|
|
175 |
|
| 176 |
Ptr<Ipv4FlowClassifier> classifier = DynamicCast<Ipv4FlowClassifier> (flowmon.GetClassifier ()); |
| 177 |
std::map<FlowId, FlowMonitor::FlowStats> stats = monitor->GetFlowStats (); |
| 178 |
for (std::map<FlowId, FlowMonitor::FlowStats>::const_iterator i = stats.begin (); i != stats.end (); ++i) |
| 179 |
{ |
| 180 |
if (i->first == 1) |
| 181 |
{ |
| 182 |
Ipv4FlowClassifier::FiveTuple t = classifier->FindFlow (i->first); |
| 183 |
std::cout << "Flow " << i->first << " (" << t.sourcePort << " -> " << t.destinationPort << ")\n"; |
| 184 |
std::cout << " Tx Bytes: " << i->second.txBytes << "\n"; |
| 185 |
std::cout << " Tx Offered: " << i->second.txBytes * 8.0 / (i->second.timeLastTxPacket.GetSeconds () - i->second.timeFirstTxPacket.GetSeconds ()) / 1000000 << " Mbps\n"; |
| 186 |
std::cout << " Rx Bytes: " << i->second.rxBytes << "\n"; |
| 187 |
std::cout << " Throughput: " << i->second.rxBytes * 8.0 / (i->second.timeLastRxPacket.GetSeconds () - i->second.timeFirstRxPacket.GetSeconds ()) / 1000000 << " Mbps\n"; |
| 188 |
std::cout << " Mean delay: " << i->second.delaySum.GetSeconds () / i->second.rxPackets << "\n"; |
| 189 |
std::cout << " Mean jitter: " << i->second.jitterSum.GetSeconds () / (i->second.rxPackets - 1) << "\n\n"; |
| 190 |
} |
| 191 |
} |
| 192 |
|
| 171 |
Simulator::Destroy (); |
193 |
Simulator::Destroy (); |
| 172 |
|
194 |
|
| 173 |
double thr = 0; |
195 |
double thr = 0; |