LEFT | RIGHT |
1 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ | 1 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ |
2 /* | 2 /* |
3 * Copyright (c) 2017 Universita' degli Studi di Napoli Federico II | 3 * Copyright (c) 2017 Universita' degli Studi di Napoli Federico II |
4 * | 4 * |
5 * This program is free software; you can redistribute it and/or modify | 5 * This program is free software; you can redistribute it and/or modify |
6 * it under the terms of the GNU General Public License version 2 as | 6 * it under the terms of the GNU General Public License version 2 as |
7 * published by the Free Software Foundation; | 7 * published by the Free Software Foundation; |
8 * | 8 * |
9 * This program is distributed in the hope that it will be useful, | 9 * This program is distributed in the hope that it will be useful, |
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of | 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of |
(...skipping 16 matching lines...) Expand all Loading... |
27 * Also, this example is used to functional testing of the netmap emulation | 27 * Also, this example is used to functional testing of the netmap emulation |
28 * features on real device in ns-3. | 28 * features on real device in ns-3. |
29 * | 29 * |
30 * The output of this example will be a ping response in presence of UDP backgro
und | 30 * The output of this example will be a ping response in presence of UDP backgro
und |
31 * traffic, the backlog in packets in traffic-control qdisc and the bytes inflig
ht in the | 31 * traffic, the backlog in packets in traffic-control qdisc and the bytes inflig
ht in the |
32 * netmap transmission ring. | 32 * netmap transmission ring. |
33 * | 33 * |
34 * The user can enable BQL to reduce the bytes in flight in the netmap transmiss
ion ring | 34 * The user can enable BQL to reduce the bytes in flight in the netmap transmiss
ion ring |
35 * and keep more backlog in traffic-control qdisc. | 35 * and keep more backlog in traffic-control qdisc. |
36 * | 36 * |
37 * e.g., output on a 100 Mbps link, BQL disable, netmap in emulated mode, | |
38 * generic_txqdisc to 0, generic_ringsize to 256: | |
39 * ... | 37 * ... |
40 * 64 bytes from 10.0.1.2: icmp_seq=17 ttl=64 time=124 ms | 38 * 64 bytes from 10.0.1.2: icmp_seq=17 ttl=64 time=124 ms |
41 * 992 packets in the traffic-control queue disc | 39 * 992 packets in the traffic-control queue disc |
42 * 366268 bytes in the netmap tx ring | 40 * 366268 bytes in the netmap tx ring |
43 * 64 bytes from 10.0.1.2: icmp_seq=18 ttl=64 time=145 ms | 41 * 64 bytes from 10.0.1.2: icmp_seq=18 ttl=64 time=145 ms |
44 * 991 packets in the traffic-control queue disc | 42 * 991 packets in the traffic-control queue disc |
45 * 366268 bytes in the netmap tx ring | 43 * 366268 bytes in the netmap tx ring |
46 * 64 bytes from 10.0.1.2: icmp_seq=19 ttl=64 time=145 ms | 44 * 64 bytes from 10.0.1.2: icmp_seq=19 ttl=64 time=145 ms |
47 * 979 packets in the traffic-control queue disc | 45 * 979 packets in the traffic-control queue disc |
48 * 366268 bytes in the netmap tx ring | 46 * 366268 bytes in the netmap tx ring |
49 * 64 bytes from 10.0.1.2: icmp_seq=20 ttl=64 time=146 ms | 47 * 64 bytes from 10.0.1.2: icmp_seq=20 ttl=64 time=146 ms |
50 * 979 packets in the traffic-control queue disc | 48 * 979 packets in the traffic-control queue disc |
51 * 366268 bytes in the netmap tx ring | 49 * 366268 bytes in the netmap tx ring |
52 * 64 bytes from 10.0.1.2: icmp_seq=21 ttl=64 time=145 ms | 50 * 64 bytes from 10.0.1.2: icmp_seq=21 ttl=64 time=145 ms |
53 * 986 packets in the traffic-control queue disc | 51 * 986 packets in the traffic-control queue disc |
54 * 366268 bytes in the netmap tx ring | 52 * 366268 bytes in the netmap tx ring |
55 * 64 bytes from 10.0.1.2: icmp_seq=22 ttl=64 time=146 ms | 53 * 64 bytes from 10.0.1.2: icmp_seq=22 ttl=64 time=146 ms |
56 * 0 packets in the traffic-control queue disc | 54 * 0 packets in the traffic-control queue disc |
57 * 0 bytes in the netmap tx ring | 55 * 0 bytes in the netmap tx ring |
58 * ... | 56 * ... |
59 * | |
60 * When the user enables BQL, the ping response under load is reduced to about 1
20 ms. | |
61 * This is due to the reduction of the bytes inflight in the netmap transmission
ring. | |
62 * | 57 * |
63 * Requirements | 58 * Requirements |
64 * ************ | 59 * ************ |
65 * This script can be used if the host machine provides a netmap installation | 60 * This script can be used if the host machine provides a netmap installation |
66 * and the ns-3 configuration was made with the --enable-sudo option. | 61 * and the ns-3 configuration was made with the --enable-sudo option. |
67 * | 62 * |
68 * Before to use this script, the user must load the netmap kernel module and se
t the | 63 * Before to use this script, the user must load the netmap kernel module and se
t the |
69 * interface in promisc mode. | 64 * interface in promisc mode. |
70 * | 65 * |
71 * Finally, the emulation in netmap mode requires that the ns-3 IP for the emula
ted interface | 66 * Finally, the emulation in netmap mode requires that the ns-3 IP for the emula
ted interface |
72 * must be different from the OS IP for that interface but on the same subnet. C
onversely, the packets | 67 * must be different from the OS IP for that interface but on the same subnet. C
onversely, the packets |
73 * destinated to the OS IP for that interface will be placed in the sw rings of
the netmap. | 68 * destinated to the OS IP for that interface will be placed in the sw rings of
the netmap. |
74 * | 69 * |
75 */ | 70 */ |
76 | 71 |
77 #include "ns3/abort.h" | 72 #include "ns3/abort.h" |
78 #include "ns3/core-module.h" | 73 #include "ns3/core-module.h" |
79 #include "ns3/internet-module.h" | 74 #include "ns3/internet-module.h" |
80 #include "ns3/network-module.h" | 75 #include "ns3/network-module.h" |
81 #include "ns3/fd-net-device-module.h" | 76 #include "ns3/fd-net-device-module.h" |
82 #include "ns3/internet-apps-module.h" | 77 #include "ns3/internet-apps-module.h" |
83 #include "ns3/ipv4-static-routing-helper.h" | 78 #include "ns3/ipv4-static-routing-helper.h" |
84 #include "ns3/ipv4-list-routing-helper.h" | 79 #include "ns3/ipv4-list-routing-helper.h" |
85 #include "ns3/applications-module.h" | 80 #include "ns3/applications-module.h" |
86 #include "ns3/traffic-control-module.h" | 81 #include "ns3/traffic-control-module.h" |
87 | 82 |
88 using namespace ns3; | 83 using namespace ns3; |
89 | 84 |
90 NS_LOG_COMPONENT_DEFINE ("NetmapEmulationPingExample"); | 85 NS_LOG_COMPONENT_DEFINE ("NetmapEmulationPingExample"); |
91 | 86 |
92 static void | 87 static void |
93 StatsSampling (Ptr<QueueDisc> qdisc, Ptr<NetDevice> device, double samplingPerio
d) | 88 StatsSampling (Ptr<QueueDisc> qdisc, Ptr<NetDevice> device, double samplingPerio
d) |
94 { | 89 { |
95 Simulator::Schedule (Seconds (samplingPeriod), &StatsSampling, qdisc, device,
samplingPeriod); | 90 Simulator::Schedule (Seconds (samplingPeriod), &StatsSampling, qdisc, device,
samplingPeriod); |
96 Ptr<NetmapNetDevice> d = DynamicCast<NetmapNetDevice> (device); | 91 Ptr<NetmapNetDevice> d = DynamicCast<NetmapNetDevice> (device); |
97 | 92 |
98 std::cout << qdisc->GetNPackets () << " packets in the traffic-control queue d
isc" << std::endl; | 93 std::cout << qdisc->GetNPackets () << " packets in the traffic-control queue d
isc" << std::endl; |
99 | |
100 if (d) | 94 if (d) |
101 { | 95 { |
102 std::cout << d->GetBytesInNetmapTxRing () << " bytes inflight in the netma
p tx ring" << std::endl; | 96 std::cout << d->GetBytesInNetmapTxRing () << " bytes inflight in the netma
p tx ring" << std::endl; |
103 } | 97 } |
104 } | 98 } |
105 | 99 |
106 static void | 100 static void |
107 PingRtt (std::string context, Time rtt) | 101 PingRtt (std::string context, Time rtt) |
108 { | 102 { |
109 NS_LOG_UNCOND ("Received Response with RTT = " << rtt); | 103 NS_LOG_UNCOND ("Received Response with RTT = " << rtt); |
(...skipping 179 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
289 | 283 |
290 // | 284 // |
291 // Now, do the actual emulation. | 285 // Now, do the actual emulation. |
292 // | 286 // |
293 NS_LOG_INFO ("Run Emulation."); | 287 NS_LOG_INFO ("Run Emulation."); |
294 Simulator::Stop (Seconds (22.0)); | 288 Simulator::Stop (Seconds (22.0)); |
295 Simulator::Run (); | 289 Simulator::Run (); |
296 Simulator::Destroy (); | 290 Simulator::Destroy (); |
297 NS_LOG_INFO ("Done."); | 291 NS_LOG_INFO ("Done."); |
298 } | 292 } |
LEFT | RIGHT |