diff --git a/examples/ipv6/CMakeLists.txt b/examples/ipv6/CMakeLists.txt index 094e36e23..2d64ecc16 100644 --- a/examples/ipv6/CMakeLists.txt +++ b/examples/ipv6/CMakeLists.txt @@ -2,18 +2,18 @@ build_example( NAME fragmentation-ipv6 SOURCE_FILES fragmentation-ipv6.cc LIBRARIES_TO_LINK + ${libapplications} ${libcsma} ${libinternet} - ${libinternet-apps} ) build_example( NAME fragmentation-ipv6-two-MTU SOURCE_FILES fragmentation-ipv6-two-MTU.cc LIBRARIES_TO_LINK + ${libapplications} ${libcsma} ${libinternet} - ${libinternet-apps} ) build_example( @@ -74,17 +74,17 @@ build_example( LIBRARIES_TO_LINK ${liblr-wpan} ${libinternet} + ${libinternet-apps} ${libsixlowpan} ${libmobility} - ${libinternet-apps} ) build_example( NAME fragmentation-ipv6-PMTU SOURCE_FILES fragmentation-ipv6-PMTU.cc LIBRARIES_TO_LINK + ${libapplications} ${libcsma} ${libinternet} - ${libinternet-apps} ${libpoint-to-point} ) diff --git a/examples/ipv6/fragmentation-ipv6-PMTU.cc b/examples/ipv6/fragmentation-ipv6-PMTU.cc index 4b941bfde..ae07d171f 100644 --- a/examples/ipv6/fragmentation-ipv6-PMTU.cc +++ b/examples/ipv6/fragmentation-ipv6-PMTU.cc @@ -30,6 +30,7 @@ // // // // - Tracing of queues and packet receptions to file "fragmentation-ipv6-PMTU.tr" +#include "ns3/applications-module.h" #include "ns3/core-module.h" #include "ns3/csma-module.h" #include "ns3/internet-apps-module.h" @@ -60,8 +61,10 @@ main(int argc, char** argv) LogComponentEnable("Icmpv6L4Protocol", LOG_LEVEL_ALL); LogComponentEnable("Ipv6StaticRouting", LOG_LEVEL_ALL); LogComponentEnable("Ipv6Interface", LOG_LEVEL_ALL); - LogComponentEnable("Ping6Application", LOG_LEVEL_ALL); + LogComponentEnable("UdpEchoClientApplication", LOG_LEVEL_ALL); + LogComponentEnable("UdpEchoServerApplication", LOG_LEVEL_ALL); } + LogComponentEnable("UdpEchoClientApplication", LOG_LEVEL_INFO); NS_LOG_INFO("Create nodes."); Ptr n0 = CreateObject(); @@ -121,31 +124,30 @@ main(int argc, char** argv) Ptr routingStream = Create(&std::cout); routingHelper.PrintRoutingTableAt(Seconds(0), r1, routingStream); - /* Create a Ping6 application to send ICMPv6 echo request from r to n2 */ - uint32_t packetSize = 1600; // Packet should fragment as intermediate link MTU is 1500 + // Create an UDP Echo server on n2 + UdpEchoServerHelper echoServer(42); + ApplicationContainer serverApps = echoServer.Install(n2); + serverApps.Start(Seconds(0.0)); + serverApps.Stop(Seconds(30.0)); + uint32_t maxPacketCount = 5; - Time interPacketInterval = Seconds(1.0); - Ping6Helper ping6; - ping6.SetLocal(i2.GetAddress(1, 1)); - ping6.SetRemote(i3.GetAddress(1, 1)); + // Create an UDP Echo client on n1 to send UDP packets to n2 via r1 + uint32_t packetSizeN1 = 1600; // Packet should fragment as intermediate link MTU is 1500 + UdpEchoClientHelper echoClient(i3.GetAddress(1, 1), 42); + echoClient.SetAttribute("PacketSize", UintegerValue(packetSizeN1)); + echoClient.SetAttribute("MaxPackets", UintegerValue(maxPacketCount)); + ApplicationContainer clientAppsN1 = echoClient.Install(n1); + clientAppsN1.Start(Seconds(2.0)); + clientAppsN1.Stop(Seconds(10.0)); - ping6.SetAttribute("MaxPackets", UintegerValue(maxPacketCount)); - ping6.SetAttribute("Interval", TimeValue(interPacketInterval)); - ping6.SetAttribute("PacketSize", UintegerValue(packetSize)); - ApplicationContainer apps = ping6.Install(n1); - apps.Start(Seconds(2.0)); - apps.Stop(Seconds(10.0)); - - /* Create a Ping6 application to send ICMPv6 echo request from n0 to n2 */ - packetSize = 4000; - ping6.SetAttribute("PacketSize", UintegerValue(packetSize)); - - ping6.SetLocal(i1.GetAddress(0, 1)); - ping6.SetRemote(i3.GetAddress(1, 1)); - apps = ping6.Install(n0); - apps.Start(Seconds(11.0)); - apps.Stop(Seconds(20.0)); + // Create an UDP Echo client on n0 to send UDP packets to n2 via r0 and r1 + uint32_t packetSizeN2 = 4000; // Packet should fragment as intermediate link MTU is 1500 + echoClient.SetAttribute("PacketSize", UintegerValue(packetSizeN2)); + echoClient.SetAttribute("MaxPackets", UintegerValue(maxPacketCount)); + ApplicationContainer clientAppsN2 = echoClient.Install(n1); + clientAppsN2.Start(Seconds(11.0)); + clientAppsN2.Stop(Seconds(20.0)); AsciiTraceHelper ascii; csma.EnableAsciiAll(ascii.CreateFileStream("fragmentation-ipv6-PMTU.tr")); diff --git a/examples/ipv6/fragmentation-ipv6-two-MTU.cc b/examples/ipv6/fragmentation-ipv6-two-MTU.cc index df797b4e8..346f923a3 100644 --- a/examples/ipv6/fragmentation-ipv6-two-MTU.cc +++ b/examples/ipv6/fragmentation-ipv6-two-MTU.cc @@ -29,6 +29,7 @@ // // // // - Tracing of queues and packet receptions to file "fragmentation-ipv6-two-mtu.tr" +#include "ns3/applications-module.h" #include "ns3/core-module.h" #include "ns3/csma-module.h" #include "ns3/internet-apps-module.h" @@ -57,8 +58,10 @@ main(int argc, char** argv) LogComponentEnable("Icmpv6L4Protocol", LOG_LEVEL_ALL); LogComponentEnable("Ipv6StaticRouting", LOG_LEVEL_ALL); LogComponentEnable("Ipv6Interface", LOG_LEVEL_ALL); - LogComponentEnable("Ping6Application", LOG_LEVEL_ALL); + LogComponentEnable("UdpEchoClientApplication", LOG_LEVEL_ALL); + LogComponentEnable("UdpEchoServerApplication", LOG_LEVEL_ALL); } + LogComponentEnable("UdpEchoClientApplication", LOG_LEVEL_INFO); NS_LOG_INFO("Create nodes."); Ptr n0 = CreateObject(); @@ -96,21 +99,21 @@ main(int argc, char** argv) Ptr routingStream = Create(&std::cout); routingHelper.PrintRoutingTableAt(Seconds(0), n0, routingStream); - /* Create a Ping6 application to send ICMPv6 echo request from n0 to n1 via r */ + /* Create a UdpEchoClient and UdpEchoServer application to send packets from n0 to n1 via r */ uint32_t packetSize = 4096; uint32_t maxPacketCount = 5; - Time interPacketInterval = Seconds(1.0); - Ping6Helper ping6; - ping6.SetLocal(i1.GetAddress(0, 1)); - ping6.SetRemote(i2.GetAddress(1, 1)); + UdpEchoClientHelper echoClient(i2.GetAddress(1, 1), 42); + echoClient.SetAttribute("PacketSize", UintegerValue(packetSize)); + echoClient.SetAttribute("MaxPackets", UintegerValue(maxPacketCount)); + ApplicationContainer clientApps = echoClient.Install(net1.Get(0)); + clientApps.Start(Seconds(2.0)); + clientApps.Stop(Seconds(20.0)); - ping6.SetAttribute("MaxPackets", UintegerValue(maxPacketCount)); - ping6.SetAttribute("Interval", TimeValue(interPacketInterval)); - ping6.SetAttribute("PacketSize", UintegerValue(packetSize)); - ApplicationContainer apps = ping6.Install(net1.Get(0)); - apps.Start(Seconds(2.0)); - apps.Stop(Seconds(20.0)); + UdpEchoServerHelper echoServer(42); + ApplicationContainer serverApps = echoServer.Install(net2.Get(1)); + serverApps.Start(Seconds(0.0)); + serverApps.Stop(Seconds(30.0)); AsciiTraceHelper ascii; csma.EnableAsciiAll(ascii.CreateFileStream("fragmentation-ipv6-two-mtu.tr")); diff --git a/examples/ipv6/fragmentation-ipv6.cc b/examples/ipv6/fragmentation-ipv6.cc index b216a4be4..ab5c77c2f 100644 --- a/examples/ipv6/fragmentation-ipv6.cc +++ b/examples/ipv6/fragmentation-ipv6.cc @@ -27,6 +27,7 @@ // // // // - Tracing of queues and packet receptions to file "fragmentation-ipv6.tr" +#include "ns3/applications-module.h" #include "ns3/core-module.h" #include "ns3/csma-module.h" #include "ns3/internet-apps-module.h" @@ -55,8 +56,10 @@ main(int argc, char** argv) LogComponentEnable("Icmpv6L4Protocol", LOG_LEVEL_ALL); LogComponentEnable("Ipv6StaticRouting", LOG_LEVEL_ALL); LogComponentEnable("Ipv6Interface", LOG_LEVEL_ALL); - LogComponentEnable("Ping6Application", LOG_LEVEL_ALL); + LogComponentEnable("UdpEchoClientApplication", LOG_LEVEL_ALL); + LogComponentEnable("UdpEchoServerApplication", LOG_LEVEL_ALL); } + LogComponentEnable("UdpEchoClientApplication", LOG_LEVEL_INFO); NS_LOG_INFO("Create nodes."); Ptr n0 = CreateObject(); @@ -93,21 +96,21 @@ main(int argc, char** argv) Ptr routingStream = Create(&std::cout); routingHelper.PrintRoutingTableAt(Seconds(0), n0, routingStream); - /* Create a Ping6 application to send ICMPv6 echo request from n0 to n1 via r */ + /* Create a UdpEchoClient and UdpEchoServer application to send packets from n0 to n1 via r */ uint32_t packetSize = 4096; uint32_t maxPacketCount = 5; - Time interPacketInterval = Seconds(1.0); - Ping6Helper ping6; - ping6.SetLocal(i1.GetAddress(0, 1)); - ping6.SetRemote(i2.GetAddress(1, 1)); + UdpEchoClientHelper echoClient(i2.GetAddress(1, 1), 42); + echoClient.SetAttribute("PacketSize", UintegerValue(packetSize)); + echoClient.SetAttribute("MaxPackets", UintegerValue(maxPacketCount)); + ApplicationContainer clientApps = echoClient.Install(net1.Get(0)); + clientApps.Start(Seconds(2.0)); + clientApps.Stop(Seconds(20.0)); - ping6.SetAttribute("MaxPackets", UintegerValue(maxPacketCount)); - ping6.SetAttribute("Interval", TimeValue(interPacketInterval)); - ping6.SetAttribute("PacketSize", UintegerValue(packetSize)); - ApplicationContainer apps = ping6.Install(net1.Get(0)); - apps.Start(Seconds(2.0)); - apps.Stop(Seconds(20.0)); + UdpEchoServerHelper echoServer(42); + ApplicationContainer serverApps = echoServer.Install(net2.Get(1)); + serverApps.Start(Seconds(0.0)); + serverApps.Stop(Seconds(30.0)); AsciiTraceHelper ascii; csma.EnableAsciiAll(ascii.CreateFileStream("fragmentation-ipv6.tr")); diff --git a/examples/ipv6/icmpv6-redirect.cc b/examples/ipv6/icmpv6-redirect.cc index 83d01989b..0d11e5831 100644 --- a/examples/ipv6/icmpv6-redirect.cc +++ b/examples/ipv6/icmpv6-redirect.cc @@ -120,15 +120,11 @@ main(int argc, char** argv) NS_LOG_INFO("Create Applications."); uint32_t packetSize = 1024; uint32_t maxPacketCount = 5; - Time interPacketInterval = Seconds(1.); - Ping6Helper ping6; + PingHelper ping(iic2.GetAddress(1, 1)); - ping6.SetLocal(iic1.GetAddress(0, 1)); - ping6.SetRemote(iic2.GetAddress(1, 1)); - ping6.SetAttribute("MaxPackets", UintegerValue(maxPacketCount)); - ping6.SetAttribute("Interval", TimeValue(interPacketInterval)); - ping6.SetAttribute("PacketSize", UintegerValue(packetSize)); - ApplicationContainer apps = ping6.Install(sta1); + ping.SetAttribute("Count", UintegerValue(maxPacketCount)); + ping.SetAttribute("Size", UintegerValue(packetSize)); + ApplicationContainer apps = ping.Install(sta1); apps.Start(Seconds(2.0)); apps.Stop(Seconds(10.0)); diff --git a/examples/ipv6/loose-routing-ipv6.cc b/examples/ipv6/loose-routing-ipv6.cc index 1bd6048f3..f18876fd2 100644 --- a/examples/ipv6/loose-routing-ipv6.cc +++ b/examples/ipv6/loose-routing-ipv6.cc @@ -60,7 +60,7 @@ main(int argc, char** argv) if (verbose) { - LogComponentEnable("Ipv6ExtensionLooseRouting", LOG_LEVEL_ALL); + // LogComponentEnable("Ipv6ExtensionLooseRouting", LOG_LEVEL_ALL); LogComponentEnable("Ipv6Extension", LOG_LEVEL_ALL); LogComponentEnable("Ipv6L3Protocol", LOG_LEVEL_ALL); LogComponentEnable("Ipv6StaticRouting", LOG_LEVEL_ALL); @@ -69,6 +69,8 @@ main(int argc, char** argv) LogComponentEnable("NdiscCache", LOG_LEVEL_ALL); } + // LogComponentEnable("Ping", LOG_LEVEL_INFO); + NS_LOG_INFO("Create nodes."); Ptr h0 = CreateObject(); Ptr h1 = CreateObject(); @@ -164,16 +166,16 @@ main(int argc, char** argv) routersAddress.push_back(i6.GetAddress(1, 1)); routersAddress.push_back(i2.GetAddress(0, 1)); - Ping6Helper client; - /* remote address is first routers in RH0 => source routing */ - client.SetRemote(i1.GetAddress(1, 1)); - client.SetAttribute("MaxPackets", UintegerValue(maxPacketCount)); + // remote address is first routers in RH0 => source routing + PingHelper client(i1.GetAddress(1, 1)); + client.SetAttribute("Count", UintegerValue(maxPacketCount)); client.SetAttribute("Interval", TimeValue(interPacketInterval)); - client.SetAttribute("PacketSize", UintegerValue(packetSize)); - client.SetRoutersAddress(routersAddress); + client.SetAttribute("Size", UintegerValue(packetSize)); ApplicationContainer apps = client.Install(h0); + DynamicCast(apps.Get(0))->SetRouters(routersAddress); + apps.Start(Seconds(1.0)); - apps.Stop(Seconds(10.0)); + apps.Stop(Seconds(20.0)); AsciiTraceHelper ascii; csma.EnableAsciiAll(ascii.CreateFileStream("loose-routing-ipv6.tr")); diff --git a/examples/ipv6/ping6.cc b/examples/ipv6/ping6.cc index 95d262e13..2a516bca3 100644 --- a/examples/ipv6/ping6.cc +++ b/examples/ipv6/ping6.cc @@ -43,9 +43,11 @@ int main(int argc, char** argv) { bool verbose = false; + bool allNodes = false; CommandLine cmd(__FILE__); cmd.AddValue("verbose", "turn on log components", verbose); + cmd.AddValue("allNodes", "Ping all the nodes (true) or just one neighbor (false)", allNodes); cmd.Parse(argc, argv); if (verbose) @@ -57,7 +59,7 @@ main(int argc, char** argv) LogComponentEnable("Ipv6ListRouting", LOG_LEVEL_ALL); LogComponentEnable("Ipv6Interface", LOG_LEVEL_ALL); LogComponentEnable("Icmpv6L4Protocol", LOG_LEVEL_ALL); - LogComponentEnable("Ping6Application", LOG_LEVEL_ALL); + LogComponentEnable("Ping", LOG_LEVEL_ALL); LogComponentEnable("NdiscCache", LOG_LEVEL_ALL); } @@ -82,25 +84,18 @@ main(int argc, char** argv) NS_LOG_INFO("Create Applications."); - /* Create a Ping6 application to send ICMPv6 echo request from node zero to - * all-nodes (ff02::1). - */ + // Create a Ping application to send ICMPv6 echo request from node zero uint32_t packetSize = 1024; uint32_t maxPacketCount = 5; - Time interPacketInterval = Seconds(1.); - Ping6Helper ping6; - /* - ping6.SetLocal (i.GetAddress (0, 1)); - ping6.SetRemote (i.GetAddress (1, 1)); - */ - ping6.SetIfIndex(i.GetInterfaceIndex(0)); - ping6.SetRemote(Ipv6Address::GetAllNodesMulticast()); + Ipv6Address destination = allNodes ? Ipv6Address::GetAllNodesMulticast() : i.GetAddress(1, 0); + PingHelper ping(destination); - ping6.SetAttribute("MaxPackets", UintegerValue(maxPacketCount)); - ping6.SetAttribute("Interval", TimeValue(interPacketInterval)); - ping6.SetAttribute("PacketSize", UintegerValue(packetSize)); - ApplicationContainer apps = ping6.Install(n.Get(0)); + ping.SetAttribute("Count", UintegerValue(maxPacketCount)); + ping.SetAttribute("Size", UintegerValue(packetSize)); + ping.SetAttribute("InterfaceAddress", AddressValue(i.GetAddress(0, 0))); + + ApplicationContainer apps = ping.Install(n.Get(0)); apps.Start(Seconds(2.0)); apps.Stop(Seconds(10.0)); diff --git a/examples/ipv6/radvd-two-prefix.cc b/examples/ipv6/radvd-two-prefix.cc index 71c9a4e8a..19a9c2cac 100644 --- a/examples/ipv6/radvd-two-prefix.cc +++ b/examples/ipv6/radvd-two-prefix.cc @@ -27,7 +27,7 @@ // // - R sends RA to n0's subnet (2001:1::/64 and 2001:ABCD::/64); // // - R interface to n0 has two addresses with following prefixes 2001:1::/64 and 2001:ABCD::/64; // // - R sends RA to n1's subnet (2001:2::/64); -// // - n0 ping6 n1. +// // - n0 ping n1. // // // // - Tracing of queues and packet receptions to file "radvd-two-prefix.tr" @@ -98,7 +98,7 @@ main(int argc, char** argv) LogComponentEnable("Ipv6StaticRouting", LOG_LEVEL_ALL); LogComponentEnable("Ipv6Interface", LOG_LEVEL_ALL); LogComponentEnable("RadvdApplication", LOG_LEVEL_ALL); - LogComponentEnable("Ping6Application", LOG_LEVEL_ALL); + LogComponentEnable("Ping", LOG_LEVEL_ALL); } NS_LOG_INFO("Create nodes."); @@ -190,23 +190,18 @@ main(int argc, char** argv) radvdApps.Start(Seconds(1.0)); radvdApps.Stop(Seconds(2.0)); - /* Create a Ping6 application to send ICMPv6 echo request from n0 to n1 via R */ + /* Create a Ping application to send ICMPv6 echo request from n0 to n1 via R */ uint32_t packetSize = 1024; uint32_t maxPacketCount = 8; - Time interPacketInterval = Seconds(1.); - Ping6Helper ping6; - - /* ping6.SetLocal (iic1.GetAddress (0, 1)); */ - ping6.SetRemote( + PingHelper ping( Ipv6Address("2001:2::200:ff:fe00:4")); /* should be n1 address after autoconfiguration */ - ping6.SetIfIndex(iic1.GetInterfaceIndex(0)); + // ping.SetIfIndex(iic1.GetInterfaceIndex(0)); - ping6.SetAttribute("MaxPackets", UintegerValue(maxPacketCount)); - ping6.SetAttribute("Interval", TimeValue(interPacketInterval)); - ping6.SetAttribute("PacketSize", UintegerValue(packetSize)); - ApplicationContainer apps = ping6.Install(net1.Get(0)); + ping.SetAttribute("Count", UintegerValue(maxPacketCount)); + ping.SetAttribute("Size", UintegerValue(packetSize)); + ApplicationContainer apps = ping.Install(net1.Get(0)); apps.Start(Seconds(2.0)); - apps.Stop(Seconds(9.0)); + apps.Stop(Seconds(5.0)); Ipv6StaticRoutingHelper routingHelper; Ptr routingStream = Create(&std::cout); diff --git a/examples/ipv6/radvd.cc b/examples/ipv6/radvd.cc index 0ce2443ec..b3879134a 100644 --- a/examples/ipv6/radvd.cc +++ b/examples/ipv6/radvd.cc @@ -26,7 +26,7 @@ // // router // // - R sends RA to n0's subnet (2001:1::/64); // // - R sends RA to n1's subnet (2001:2::/64); -// // - n0 ping6 n1. +// // - n0 ping n1. // // // // - Tracing of queues and packet receptions to file "radvd.tr" @@ -62,7 +62,7 @@ main(int argc, char** argv) LogComponentEnable("Ipv6StaticRouting", LOG_LEVEL_ALL); LogComponentEnable("Ipv6Interface", LOG_LEVEL_ALL); LogComponentEnable("RadvdApplication", LOG_LEVEL_ALL); - LogComponentEnable("Ping6Application", LOG_LEVEL_ALL); + LogComponentEnable("Ping", LOG_LEVEL_ALL); } NS_LOG_INFO("Create nodes."); @@ -129,21 +129,15 @@ main(int argc, char** argv) radvdApps.Start(Seconds(1.0)); radvdApps.Stop(Seconds(10.0)); - /* Create a Ping6 application to send ICMPv6 echo request from n0 to n1 via R */ + /* Create a Ping application to send ICMPv6 echo request from n0 to n1 via R */ uint32_t packetSize = 1024; uint32_t maxPacketCount = 5; - Time interPacketInterval = Seconds(1.); - Ping6Helper ping6; - - /* ping6.SetLocal (iic1.GetAddress (0, 1)); */ - ping6.SetRemote( + PingHelper ping( Ipv6Address("2001:2::200:ff:fe00:4")); /* should be n1 address after autoconfiguration */ - ping6.SetIfIndex(iic1.GetInterfaceIndex(0)); - ping6.SetAttribute("MaxPackets", UintegerValue(maxPacketCount)); - ping6.SetAttribute("Interval", TimeValue(interPacketInterval)); - ping6.SetAttribute("PacketSize", UintegerValue(packetSize)); - ApplicationContainer apps = ping6.Install(net1.Get(0)); + ping.SetAttribute("Count", UintegerValue(maxPacketCount)); + ping.SetAttribute("Size", UintegerValue(packetSize)); + ApplicationContainer apps = ping.Install(net1.Get(0)); apps.Start(Seconds(2.0)); apps.Stop(Seconds(7.0)); diff --git a/examples/ipv6/wsn-ping6.cc b/examples/ipv6/wsn-ping6.cc index 23c88ebad..14a4cc6e9 100644 --- a/examples/ipv6/wsn-ping6.cc +++ b/examples/ipv6/wsn-ping6.cc @@ -61,7 +61,7 @@ main(int argc, char** argv) LogComponentEnable("Ipv6ListRouting", LOG_LEVEL_ALL); LogComponentEnable("Ipv6Interface", LOG_LEVEL_ALL); LogComponentEnable("Icmpv6L4Protocol", LOG_LEVEL_ALL); - LogComponentEnable("Ping6Application", LOG_LEVEL_ALL); + LogComponentEnable("Ping", LOG_LEVEL_ALL); LogComponentEnable("NdiscCache", LOG_LEVEL_ALL); LogComponentEnable("SixLowPanNetDevice", LOG_LEVEL_ALL); } @@ -111,22 +111,18 @@ main(int argc, char** argv) NS_LOG_INFO("Create Applications."); - /* Create a Ping6 application to send ICMPv6 echo request from node zero to + /* Create a Ping application to send ICMPv6 echo request from node zero to * all-nodes (ff02::1). */ - uint32_t packetSize = 10; + uint32_t packetSize = 16; uint32_t maxPacketCount = 5; Time interPacketInterval = Seconds(1.); - Ping6Helper ping6; + PingHelper ping(i.GetAddress(1, 1)); - ping6.SetLocal(i.GetAddress(0, 1)); - ping6.SetRemote(i.GetAddress(1, 1)); - // ping6.SetRemote (Ipv6Address::GetAllNodesMulticast ()); - - ping6.SetAttribute("MaxPackets", UintegerValue(maxPacketCount)); - ping6.SetAttribute("Interval", TimeValue(interPacketInterval)); - ping6.SetAttribute("PacketSize", UintegerValue(packetSize)); - ApplicationContainer apps = ping6.Install(nodes.Get(0)); + ping.SetAttribute("Count", UintegerValue(maxPacketCount)); + ping.SetAttribute("Interval", TimeValue(interPacketInterval)); + ping.SetAttribute("Size", UintegerValue(packetSize)); + ApplicationContainer apps = ping.Install(nodes.Get(0)); apps.Start(Seconds(2.0)); apps.Stop(Seconds(10.0)); diff --git a/examples/routing/rip-simple-network.cc b/examples/routing/rip-simple-network.cc index 0f95ed6a8..47cbf336b 100644 --- a/examples/routing/rip-simple-network.cc +++ b/examples/routing/rip-simple-network.cc @@ -97,7 +97,7 @@ main(int argc, char** argv) LogComponentEnable("Icmpv4L4Protocol", LOG_LEVEL_ALL); LogComponentEnable("Ipv4L3Protocol", LOG_LEVEL_ALL); LogComponentEnable("ArpCache", LOG_LEVEL_ALL); - LogComponentEnable("V4Ping", LOG_LEVEL_ALL); + LogComponentEnable("Ping", LOG_LEVEL_ALL); } if (SplitHorizon == "NoSplitHorizon") @@ -236,13 +236,13 @@ main(int argc, char** argv) NS_LOG_INFO("Create Applications."); uint32_t packetSize = 1024; Time interPacketInterval = Seconds(1.0); - V4PingHelper ping("10.0.6.2"); + PingHelper ping(Ipv4Address("10.0.6.2")); ping.SetAttribute("Interval", TimeValue(interPacketInterval)); ping.SetAttribute("Size", UintegerValue(packetSize)); if (showPings) { - ping.SetAttribute("Verbose", BooleanValue(true)); + ping.SetAttribute("VerboseMode", EnumValue(Ping::VerboseMode::VERBOSE)); } ApplicationContainer apps = ping.Install(src); apps.Start(Seconds(1.0)); diff --git a/examples/routing/ripng-simple-network.cc b/examples/routing/ripng-simple-network.cc index 64178e02f..4d49ca0fe 100644 --- a/examples/routing/ripng-simple-network.cc +++ b/examples/routing/ripng-simple-network.cc @@ -96,12 +96,7 @@ main(int argc, char** argv) LogComponentEnable("Ipv6Interface", LOG_LEVEL_ALL); LogComponentEnable("Icmpv6L4Protocol", LOG_LEVEL_ALL); LogComponentEnable("NdiscCache", LOG_LEVEL_ALL); - LogComponentEnable("Ping6Application", LOG_LEVEL_ALL); - } - - if (showPings) - { - LogComponentEnable("Ping6Application", LOG_LEVEL_INFO); + LogComponentEnable("Ping", LOG_LEVEL_ALL); } if (SplitHorizon == "NoSplitHorizon") @@ -245,16 +240,16 @@ main(int argc, char** argv) NS_LOG_INFO("Create Applications."); uint32_t packetSize = 1024; - uint32_t maxPacketCount = 100; Time interPacketInterval = Seconds(1.0); - Ping6Helper ping6; + PingHelper ping(iic7.GetAddress(1, 1)); - ping6.SetLocal(iic1.GetAddress(0, 1)); - ping6.SetRemote(iic7.GetAddress(1, 1)); - ping6.SetAttribute("MaxPackets", UintegerValue(maxPacketCount)); - ping6.SetAttribute("Interval", TimeValue(interPacketInterval)); - ping6.SetAttribute("PacketSize", UintegerValue(packetSize)); - ApplicationContainer apps = ping6.Install(src); + ping.SetAttribute("Interval", TimeValue(interPacketInterval)); + ping.SetAttribute("Size", UintegerValue(packetSize)); + if (showPings) + { + ping.SetAttribute("VerboseMode", EnumValue(Ping::VerboseMode::VERBOSE)); + } + ApplicationContainer apps = ping.Install(src); apps.Start(Seconds(1.0)); apps.Stop(Seconds(110.0)); diff --git a/examples/routing/simple-routing-ping6.cc b/examples/routing/simple-routing-ping6.cc index 4ea404e45..0309ed3b5 100644 --- a/examples/routing/simple-routing-ping6.cc +++ b/examples/routing/simple-routing-ping6.cc @@ -98,7 +98,7 @@ main(int argc, char** argv) LogComponentEnable ("Icmpv6L4Protocol", LOG_LEVEL_ALL); LogComponentEnable ("Ipv6StaticRouting", LOG_LEVEL_ALL); LogComponentEnable ("Ipv6Interface", LOG_LEVEL_ALL); - LogComponentEnable ("Ping6Application", LOG_LEVEL_ALL); + LogComponentEnable ("Ping", LOG_LEVEL_ALL); #endif CommandLine cmd(__FILE__); @@ -139,19 +139,14 @@ main(int argc, char** argv) stackHelper.PrintRoutingTable(n0); - /* Create a Ping6 application to send ICMPv6 echo request from n0 to n1 via r */ + /* Create a Ping application to send ICMPv6 echo request from n0 to n1 via r */ uint32_t packetSize = 1024; uint32_t maxPacketCount = 5; - Time interPacketInterval = Seconds(1.); - Ping6Helper ping6; + PingHelper ping(i2.GetAddress(1, 1)); - ping6.SetLocal(i1.GetAddress(0, 1)); - ping6.SetRemote(i2.GetAddress(1, 1)); - - ping6.SetAttribute("MaxPackets", UintegerValue(maxPacketCount)); - ping6.SetAttribute("Interval", TimeValue(interPacketInterval)); - ping6.SetAttribute("PacketSize", UintegerValue(packetSize)); - ApplicationContainer apps = ping6.Install(net1.Get(0)); + ping.SetAttribute("Count", UintegerValue(maxPacketCount)); + ping.SetAttribute("Size", UintegerValue(packetSize)); + ApplicationContainer apps = ping.Install(net1.Get(0)); apps.Start(Seconds(2.0)); apps.Stop(Seconds(20.0)); diff --git a/examples/routing/simple-routing-ping6.py b/examples/routing/simple-routing-ping6.py index aa5952e5b..f14d521d8 100644 --- a/examples/routing/simple-routing-ping6.py +++ b/examples/routing/simple-routing-ping6.py @@ -74,16 +74,17 @@ def main(argv): packetSize = 1024 maxPacketCount = 5 interPacketInterval = ns.Seconds(1.) - ping6 = ns.Ping6Helper() + # ping = ns.PingHelper(i2.GetAddress(1, 1).ConvertTo()) + ping = ns.PingHelper(i2.GetAddress(1, 1).ConvertTo()) - ping6.SetLocal(i1.GetAddress(0, 1)) - ping6.SetRemote(i2.GetAddress(1, 1)) + # ping6.SetLocal(i1.GetAddress(0, 1)) + # ping6.SetRemote(i2.GetAddress(1, 1)) - ping6.SetAttribute("MaxPackets", ns.UintegerValue(maxPacketCount)) - ping6.SetAttribute("Interval", ns.TimeValue(interPacketInterval)) - ping6.SetAttribute("PacketSize", ns.UintegerValue(packetSize)) + ping.SetAttribute("Count", ns.UintegerValue(maxPacketCount)) + ping.SetAttribute("Interval", ns.TimeValue(interPacketInterval)) + ping.SetAttribute("Size", ns.UintegerValue(packetSize)) - apps = ping6.Install(ns.NodeContainer(net1.Get(0))) + apps = ping.Install(ns.NodeContainer(net1.Get(0))) apps.Start(ns.Seconds(2.0)) apps.Stop(ns.Seconds(20.0)) diff --git a/examples/tcp/tcp-validation.cc b/examples/tcp/tcp-validation.cc index 6c71e3751..1bbd0e97d 100644 --- a/examples/tcp/tcp-validation.cc +++ b/examples/tcp/tcp-validation.cc @@ -344,7 +344,7 @@ TraceSecondDctcp(std::ofstream* ofStream, uint32_t bytesMarked, uint32_t bytesAc * \param rtt RTT value. */ void -TracePingRtt(std::ofstream* ofStream, Time rtt) +TracePingRtt(std::ofstream* ofStream, uint16_t, Time rtt) { if (g_validate == "") { @@ -975,12 +975,13 @@ main(int argc, char* argv[]) //////////////////////////////////////////////////////////// // application setup // //////////////////////////////////////////////////////////// - V4PingHelper pingHelper("192.168.1.2"); + PingHelper pingHelper(Ipv4Address("192.168.1.2")); pingHelper.SetAttribute("Interval", TimeValue(pingInterval)); pingHelper.SetAttribute("Size", UintegerValue(pingSize)); + pingHelper.SetAttribute("VerboseMode", EnumValue(Ping::VerboseMode::SILENT)); ApplicationContainer pingContainer = pingHelper.Install(pingServer); - Ptr v4Ping = pingContainer.Get(0)->GetObject(); - v4Ping->TraceConnectWithoutContext("Rtt", MakeBoundCallback(&TracePingRtt, &pingOfStream)); + Ptr ping = pingContainer.Get(0)->GetObject(); + ping->TraceConnectWithoutContext("Rtt", MakeBoundCallback(&TracePingRtt, &pingOfStream)); pingContainer.Start(Seconds(1)); pingContainer.Stop(stopTime - Seconds(1)); diff --git a/examples/traffic-control/queue-discs-benchmark.cc b/examples/traffic-control/queue-discs-benchmark.cc index dab856d7a..c18ac078d 100644 --- a/examples/traffic-control/queue-discs-benchmark.cc +++ b/examples/traffic-control/queue-discs-benchmark.cc @@ -38,13 +38,13 @@ // // The output will consist of a number of ping Rtt such as: // -// /NodeList/0/ApplicationList/2/$ns3::V4Ping/Rtt=111 ms -// /NodeList/0/ApplicationList/2/$ns3::V4Ping/Rtt=111 ms -// /NodeList/0/ApplicationList/2/$ns3::V4Ping/Rtt=110 ms -// /NodeList/0/ApplicationList/2/$ns3::V4Ping/Rtt=111 ms -// /NodeList/0/ApplicationList/2/$ns3::V4Ping/Rtt=111 ms -// /NodeList/0/ApplicationList/2/$ns3::V4Ping/Rtt=112 ms -// /NodeList/0/ApplicationList/2/$ns3::V4Ping/Rtt=111 ms +// /NodeList/0/ApplicationList/2/$ns3::Ping/Rtt=111 ms +// /NodeList/0/ApplicationList/2/$ns3::Ping/Rtt=111 ms +// /NodeList/0/ApplicationList/2/$ns3::Ping/Rtt=110 ms +// /NodeList/0/ApplicationList/2/$ns3::Ping/Rtt=111 ms +// /NodeList/0/ApplicationList/2/$ns3::Ping/Rtt=111 ms +// /NodeList/0/ApplicationList/2/$ns3::Ping/Rtt=112 ms +// /NodeList/0/ApplicationList/2/$ns3::Ping/Rtt=111 ms // // The files output will consist of a trace file with bytes in queue and of a trace file for limits // (when BQL is enabled) both for bottleneck NetDevice on n2, two files with upload and download @@ -116,7 +116,7 @@ GoodputSampling(ApplicationContainer app, Ptr stream, float * \param rtt The RTT. */ static void -PingRtt(std::string context, Time rtt) +PingRtt(std::string context, uint16_t, Time rtt) { std::cout << context << "=" << rtt.GetMilliSeconds() << " ms" << std::endl; } @@ -326,10 +326,11 @@ main(int argc, char* argv[]) sourceApps.Add(onOffHelperDown.Install(n3)); // Configure and install ping - V4PingHelper ping = V4PingHelper(n3Interface.GetAddress(0)); + PingHelper ping(n3Interface.GetAddress(0)); + ping.SetAttribute("VerboseMode", EnumValue(Ping::VerboseMode::QUIET)); ping.Install(n1); - Config::Connect("/NodeList/*/ApplicationList/*/$ns3::V4Ping/Rtt", MakeCallback(&PingRtt)); + Config::Connect("/NodeList/*/ApplicationList/*/$ns3::Ping/Rtt", MakeCallback(&PingRtt)); uploadApp.Start(Seconds(0)); uploadApp.Stop(Seconds(stopTime)); @@ -359,6 +360,8 @@ main(int argc, char* argv[]) FlowMonitorHelper flowHelper; flowMonitor = flowHelper.InstallAll(); + accessLink.EnablePcapAll("queue"); + Simulator::Stop(Seconds(stopTime)); Simulator::Run(); diff --git a/src/aodv/examples/aodv.cc b/src/aodv/examples/aodv.cc index 361cba2e1..498d65a3b 100644 --- a/src/aodv/examples/aodv.cc +++ b/src/aodv/examples/aodv.cc @@ -24,8 +24,8 @@ #include "ns3/internet-module.h" #include "ns3/mobility-module.h" #include "ns3/network-module.h" +#include "ns3/ping-helper.h" #include "ns3/point-to-point-module.h" -#include "ns3/v4ping-helper.h" #include "ns3/yans-wifi-helper.h" #include @@ -46,8 +46,8 @@ using namespace ns3; * * When 1/3 of simulation time has elapsed, one of the nodes is moved out of * range, thereby breaking the topology. By default, this will result in - * only 34 of 100 pings being received. If the step size is reduced - * to cover the gap, then all pings can be received. + * stopping ping replies reception after sequence number 33. If the step size is reduced + * to cover the gap, then also the following pings can be received. */ class AodvExample { @@ -241,8 +241,8 @@ AodvExample::InstallInternetStack() void AodvExample::InstallApplications() { - V4PingHelper ping(interfaces.GetAddress(size - 1)); - ping.SetAttribute("Verbose", BooleanValue(true)); + PingHelper ping(interfaces.GetAddress(size - 1)); + ping.SetAttribute("VerboseMode", EnumValue(Ping::VerboseMode::VERBOSE)); ApplicationContainer p = ping.Install(nodes.Get(0)); p.Start(Seconds(0)); diff --git a/src/csma/examples/csma-ping.cc b/src/csma/examples/csma-ping.cc index 4173ceb42..14389631a 100644 --- a/src/csma/examples/csma-ping.cc +++ b/src/csma/examples/csma-ping.cc @@ -47,25 +47,31 @@ NS_LOG_COMPONENT_DEFINE("CsmaPingExample"); static void SinkRx(Ptr p, const Address& ad) { - // std::cout << *p << std::endl; + std::cout << *p << std::endl; } /** * Ping RTT trace sink * * \param context The context. + * \param seqNo The Sequence Number. * \param rtt The RTT. */ static void -PingRtt(std::string context, Time rtt) +PingRtt(std::string context, uint16_t seqNo, Time rtt) { - // std::cout << context << " " << rtt << std::endl; + std::cout << context << " " << seqNo << " " << rtt << std::endl; } int main(int argc, char* argv[]) { + bool verbose{false}; + CommandLine cmd(__FILE__); + cmd.AddValue("verbose", + "print received background traffic packets and ping RTT values", + verbose); cmd.Parse(argc, argv); // Here, we will explicitly create four nodes. @@ -110,7 +116,7 @@ main(int argc, char* argv[]) apps.Stop(Seconds(11.0)); NS_LOG_INFO("Create pinger"); - V4PingHelper ping = V4PingHelper(addresses.GetAddress(2)); + PingHelper ping(addresses.GetAddress(2)); NodeContainer pingers; pingers.Add(c.Get(0)); pingers.Add(c.Get(1)); @@ -123,11 +129,14 @@ main(int argc, char* argv[]) // first, pcap tracing in non-promiscuous mode csma.EnablePcapAll("csma-ping", false); - // then, print what the packet sink receives. - Config::ConnectWithoutContext("/NodeList/3/ApplicationList/0/$ns3::PacketSink/Rx", - MakeCallback(&SinkRx)); - // finally, print the ping rtts. - Config::Connect("/NodeList/*/ApplicationList/*/$ns3::V4Ping/Rtt", MakeCallback(&PingRtt)); + if (verbose) + { + // then, print what the packet sink receives. + Config::ConnectWithoutContext("/NodeList/3/ApplicationList/0/$ns3::PacketSink/Rx", + MakeCallback(&SinkRx)); + // finally, print the ping rtts. + Config::Connect("/NodeList/*/ApplicationList/*/$ns3::Ping/Rtt", MakeCallback(&PingRtt)); + } Packet::EnablePrinting(); diff --git a/src/fd-net-device/examples/dummy-network.cc b/src/fd-net-device/examples/dummy-network.cc index 3c775b0f9..bae9c1983 100644 --- a/src/fd-net-device/examples/dummy-network.cc +++ b/src/fd-net-device/examples/dummy-network.cc @@ -64,9 +64,9 @@ main(int argc, char* argv[]) addresses.SetBase("10.0.0.0", "255.255.255.0"); Ipv4InterfaceContainer interfaces = addresses.Assign(devices); - Ptr app = CreateObject(); - app->SetAttribute("Remote", Ipv4AddressValue(interfaces.GetAddress(0))); - app->SetAttribute("Verbose", BooleanValue(true)); + Ptr app = CreateObject(); + app->SetAttribute("Destination", AddressValue(interfaces.GetAddress(0))); + app->SetAttribute("VerboseMode", EnumValue(Ping::VerboseMode::VERBOSE)); nodes.Get(1)->AddApplication(app); app->SetStartTime(Seconds(0.0)); app->SetStopTime(Seconds(4.0)); diff --git a/src/fd-net-device/examples/fd-emu-ping.cc b/src/fd-net-device/examples/fd-emu-ping.cc index 50f678653..f2f148b6c 100644 --- a/src/fd-net-device/examples/fd-emu-ping.cc +++ b/src/fd-net-device/examples/fd-emu-ping.cc @@ -94,9 +94,9 @@ using namespace ns3; NS_LOG_COMPONENT_DEFINE("PingEmulationExample"); static void -PingRtt(std::string context, Time rtt) +PingRtt(std::string context, uint16_t seqNo, Time rtt) { - NS_LOG_UNCOND("Received Response with RTT = " << rtt); + NS_LOG_UNCOND("Received " << seqNo << " Response with RTT = " << rtt); } int @@ -269,10 +269,10 @@ main(int argc, char* argv[]) // of a hassle and since there is no law that says we cannot mix the // helper API with the low level API, let's just use the helper. // - NS_LOG_INFO("Create V4Ping Appliation"); - Ptr app = CreateObject(); - app->SetAttribute("Remote", Ipv4AddressValue(remoteIp)); - app->SetAttribute("Verbose", BooleanValue(true)); + NS_LOG_INFO("Create Ping Appliation"); + Ptr app = CreateObject(); + app->SetAttribute("Destination", AddressValue(remoteIp)); + app->SetAttribute("VerboseMode", EnumValue(Ping::VerboseMode::VERBOSE)); node->AddApplication(app); app->SetStartTime(Seconds(1.0)); app->SetStopTime(Seconds(22.0)); diff --git a/src/fd-net-device/examples/fd-tap-ping.cc b/src/fd-net-device/examples/fd-tap-ping.cc index 874eaa9ea..2dd742fd8 100644 --- a/src/fd-net-device/examples/fd-tap-ping.cc +++ b/src/fd-net-device/examples/fd-tap-ping.cc @@ -83,9 +83,9 @@ using namespace ns3; NS_LOG_COMPONENT_DEFINE("TAPPingExample"); static void -PingRtt(std::string context, Time rtt) +PingRtt(std::string context, uint16_t seqNo, Time rtt) { - NS_LOG_UNCOND("Received Response with RTT = " << rtt); + NS_LOG_UNCOND("Received " << seqNo << " Response with RTT = " << rtt); } int @@ -201,10 +201,10 @@ main(int argc, char* argv[]) // of a hassle and since there is no law that says we cannot mix the // helper API with the low level API, let's just use the helper. // - NS_LOG_INFO("Create V4Ping Appliation"); - Ptr app = CreateObject(); - app->SetAttribute("Remote", Ipv4AddressValue(remoteIp)); - app->SetAttribute("Verbose", BooleanValue(true)); + NS_LOG_INFO("Create Ping Appliation"); + Ptr app = CreateObject(); + app->SetAttribute("Destination", AddressValue(remoteIp)); + app->SetAttribute("VerboseMode", EnumValue(Ping::VerboseMode::VERBOSE)); node->AddApplication(app); app->SetStartTime(Seconds(1.0)); app->SetStopTime(Seconds(21.0)); diff --git a/src/fd-net-device/examples/fd-tap-ping6.cc b/src/fd-net-device/examples/fd-tap-ping6.cc index 518e1691f..c0fd4f217 100644 --- a/src/fd-net-device/examples/fd-tap-ping6.cc +++ b/src/fd-net-device/examples/fd-tap-ping6.cc @@ -102,12 +102,12 @@ main(int argc, char* argv[]) // Ipv6AddressHelper ipv6; - ipv6.SetBase(Ipv6Address("2001:0DB8:1::"), Ipv6Prefix(64)); + ipv6.SetBase(Ipv6Address("4001:beef:1::"), Ipv6Prefix(64)); Ipv6InterfaceContainer i1 = ipv6.Assign(devs); i1.SetForwarding(1, true); i1.SetDefaultRouteInAllNodes(1); - ipv6.SetBase(Ipv6Address("2001:0DB8:2::"), Ipv6Prefix(64)); + ipv6.SetBase(Ipv6Address("4001:beef:2::"), Ipv6Prefix(64)); Ipv6Address tapAddr = ipv6.NewAddress(); std::stringstream ss; std::string tapIp; @@ -137,14 +137,20 @@ main(int argc, char* argv[]) uint32_t maxPacketCount = 1; Time interPacketInterval = Seconds(1.0); - Ping6Helper ping6; + PingHelper ping(Ipv6Address(tapIp.c_str())); + ping.SetAttribute("Count", UintegerValue(maxPacketCount)); + ping.SetAttribute("Interval", TimeValue(interPacketInterval)); + ping.SetAttribute("Size", UintegerValue(packetSize)); + ApplicationContainer apps = ping.Install(n); - ping6.SetRemote(tapIp.c_str()); + // Ping6Helper ping6; - ping6.SetAttribute("MaxPackets", UintegerValue(maxPacketCount)); - ping6.SetAttribute("Interval", TimeValue(interPacketInterval)); - ping6.SetAttribute("PacketSize", UintegerValue(packetSize)); - ApplicationContainer apps = ping6.Install(n); + // ping6.SetRemote(tapIp.c_str()); + + // ping6.SetAttribute("MaxPackets", UintegerValue(maxPacketCount)); + // ping6.SetAttribute("Interval", TimeValue(interPacketInterval)); + // ping6.SetAttribute("PacketSize", UintegerValue(packetSize)); + // ApplicationContainer apps = ping6.Install(n); apps.Start(Seconds(2.0)); apps.Stop(Seconds(20.0)); diff --git a/src/fd-net-device/examples/realtime-dummy-network.cc b/src/fd-net-device/examples/realtime-dummy-network.cc index d6d7d365f..20631f529 100644 --- a/src/fd-net-device/examples/realtime-dummy-network.cc +++ b/src/fd-net-device/examples/realtime-dummy-network.cc @@ -67,9 +67,9 @@ main(int argc, char* argv[]) addresses.SetBase("10.0.0.0", "255.255.255.0"); Ipv4InterfaceContainer interfaces = addresses.Assign(devices); - Ptr app = CreateObject(); - app->SetAttribute("Remote", Ipv4AddressValue(interfaces.GetAddress(0))); - app->SetAttribute("Verbose", BooleanValue(true)); + Ptr app = CreateObject(); + app->SetAttribute("Destination", AddressValue(interfaces.GetAddress(0))); + app->SetAttribute("VerboseMode", EnumValue(Ping::VerboseMode::VERBOSE)); nodes.Get(1)->AddApplication(app); app->SetStartTime(Seconds(0.0)); app->SetStopTime(Seconds(4.0)); diff --git a/src/internet-apps/helper/ping6-helper.cc b/src/internet-apps/helper/ping6-helper.cc index 449b70a01..2dfbac18d 100644 --- a/src/internet-apps/helper/ping6-helper.cc +++ b/src/internet-apps/helper/ping6-helper.cc @@ -52,6 +52,9 @@ Ping6Helper::SetAttribute(std::string name, const AttributeValue& value) ApplicationContainer Ping6Helper::Install(NodeContainer c) { +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wdeprecated-declarations" + ApplicationContainer apps; for (NodeContainer::Iterator i = c.Begin(); i != c.End(); ++i) { @@ -65,6 +68,8 @@ Ping6Helper::Install(NodeContainer c) apps.Add(client); } return apps; + +#pragma GCC diagnostic pop } void diff --git a/src/internet-apps/helper/ping6-helper.h b/src/internet-apps/helper/ping6-helper.h index cd29a71fb..543b6bd70 100644 --- a/src/internet-apps/helper/ping6-helper.h +++ b/src/internet-apps/helper/ping6-helper.h @@ -40,6 +40,7 @@ class Ping6Helper /** * \brief Constructor. */ + NS_DEPRECATED_3_38("Use PingHelper instead - the attributes might have been renamed.") Ping6Helper(); /** @@ -74,6 +75,7 @@ class Ping6Helper * when a node has multiple interfaces. * \param ifIndex interface index */ + NS_DEPRECATED_3_38("Use a source address") void SetIfIndex(uint32_t ifIndex); /** diff --git a/src/internet-apps/helper/v4ping-helper.cc b/src/internet-apps/helper/v4ping-helper.cc index cf99de6ff..8b9daec48 100644 --- a/src/internet-apps/helper/v4ping-helper.cc +++ b/src/internet-apps/helper/v4ping-helper.cc @@ -65,10 +65,15 @@ V4PingHelper::Install(NodeContainer c) const Ptr V4PingHelper::InstallPriv(Ptr node) const { +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wdeprecated-declarations" + Ptr app = m_factory.Create(); node->AddApplication(app); return app; + +#pragma GCC diagnostic pop } } // namespace ns3 diff --git a/src/internet-apps/helper/v4ping-helper.h b/src/internet-apps/helper/v4ping-helper.h index 7e1bcb5c9..664f8620e 100644 --- a/src/internet-apps/helper/v4ping-helper.h +++ b/src/internet-apps/helper/v4ping-helper.h @@ -43,6 +43,7 @@ class V4PingHelper * * \param remote The address which should be pinged */ + NS_DEPRECATED_3_38("Use PingHelper instead - the attributes might have been renamed.") V4PingHelper(Ipv4Address remote); /** diff --git a/src/internet-apps/model/ping6.h b/src/internet-apps/model/ping6.h index 1ef057d6f..2fa2e5923 100644 --- a/src/internet-apps/model/ping6.h +++ b/src/internet-apps/model/ping6.h @@ -39,7 +39,8 @@ class Socket; * \ingroup ping6 * \brief A ping6 application. */ -class Ping6 : public Application +class NS_DEPRECATED_3_38("Use Ping instead - the attributes might have been renamed.") Ping6 + : public Application { public: /** diff --git a/src/internet-apps/model/v4ping.h b/src/internet-apps/model/v4ping.h index 3ff550e96..86046a2f8 100644 --- a/src/internet-apps/model/v4ping.h +++ b/src/internet-apps/model/v4ping.h @@ -39,7 +39,8 @@ class Socket; * * Note: The RTT calculated is reported through a trace source. */ -class V4Ping : public Application +class NS_DEPRECATED_3_38("Use Ping instead - the attributes might have been renamed.") V4Ping + : public Application { public: /** diff --git a/src/sixlowpan/examples/example-ping-lr-wpan-beacon.cc b/src/sixlowpan/examples/example-ping-lr-wpan-beacon.cc index 3e251debb..e820166b0 100644 --- a/src/sixlowpan/examples/example-ping-lr-wpan-beacon.cc +++ b/src/sixlowpan/examples/example-ping-lr-wpan-beacon.cc @@ -58,7 +58,7 @@ main(int argc, char** argv) LogComponentEnable("LrWpanMac", LOG_LEVEL_INFO); LogComponentEnable("LrWpanCsmaCa", LOG_LEVEL_INFO); LogComponentEnable("LrWpanHelper", LOG_LEVEL_ALL); - LogComponentEnable("Ping6Application", LOG_LEVEL_INFO); + LogComponentEnable("Ping", LOG_LEVEL_INFO); } NodeContainer nodes; @@ -129,21 +129,18 @@ main(int argc, char** argv) // Send ping packets after the 2nd second of the simulation during the // first 8 seconds of the CAP in the incoming superframe - uint32_t packetSize = 10; + uint32_t packetSize = 16; uint32_t maxPacketCount = 5; Time interPacketInterval = Seconds(1); - Ping6Helper ping6; + PingHelper ping(deviceInterfaces.GetAddress(1, 1)); - ping6.SetLocal(deviceInterfaces.GetAddress(0, 1)); - ping6.SetRemote(deviceInterfaces.GetAddress(1, 1)); - - ping6.SetAttribute("MaxPackets", UintegerValue(maxPacketCount)); - ping6.SetAttribute("Interval", TimeValue(interPacketInterval)); - ping6.SetAttribute("PacketSize", UintegerValue(packetSize)); - ApplicationContainer apps = ping6.Install(nodes.Get(0)); + ping.SetAttribute("Count", UintegerValue(maxPacketCount)); + ping.SetAttribute("Interval", TimeValue(interPacketInterval)); + ping.SetAttribute("Size", UintegerValue(packetSize)); + ApplicationContainer apps = ping.Install(nodes.Get(0)); apps.Start(Seconds(2.0)); - apps.Stop(Seconds(10.0)); + apps.Stop(Seconds(20.0)); AsciiTraceHelper ascii; lrWpanHelper.EnableAsciiAll(ascii.CreateFileStream("Ping-6LoW-lr-wpan-beacon.tr")); diff --git a/src/sixlowpan/examples/example-ping-lr-wpan-mesh-under.cc b/src/sixlowpan/examples/example-ping-lr-wpan-mesh-under.cc index 5b4abaced..66349f9f6 100644 --- a/src/sixlowpan/examples/example-ping-lr-wpan-mesh-under.cc +++ b/src/sixlowpan/examples/example-ping-lr-wpan-mesh-under.cc @@ -44,7 +44,7 @@ main(int argc, char** argv) if (verbose) { - LogComponentEnable("Ping6Application", LOG_LEVEL_ALL); + LogComponentEnable("Ping", LOG_LEVEL_ALL); LogComponentEnable("LrWpanMac", LOG_LEVEL_ALL); LogComponentEnable("LrWpanPhy", LOG_LEVEL_ALL); LogComponentEnable("LrWpanNetDevice", LOG_LEVEL_ALL); @@ -116,21 +116,18 @@ main(int argc, char** argv) dev->SetAttribute("MeshUnderRadius", UintegerValue(10)); } - uint32_t packetSize = 10; + uint32_t packetSize = 16; uint32_t maxPacketCount = 5; Time interPacketInterval = Seconds(1.); - Ping6Helper ping6; + PingHelper ping(wiredDeviceInterfaces.GetAddress(0, 1)); - ping6.SetLocal(wsnDeviceInterfaces.GetAddress(nWsnNodes - 1, 1)); - ping6.SetRemote(wiredDeviceInterfaces.GetAddress(0, 1)); + ping.SetAttribute("Count", UintegerValue(maxPacketCount)); + ping.SetAttribute("Interval", TimeValue(interPacketInterval)); + ping.SetAttribute("Size", UintegerValue(packetSize)); + ApplicationContainer apps = ping.Install(wsnNodes.Get(nWsnNodes - 1)); - ping6.SetAttribute("MaxPackets", UintegerValue(maxPacketCount)); - ping6.SetAttribute("Interval", TimeValue(interPacketInterval)); - ping6.SetAttribute("PacketSize", UintegerValue(packetSize)); - ApplicationContainer apps = ping6.Install(wsnNodes.Get(nWsnNodes - 1)); - - apps.Start(Seconds(1.0)); - apps.Stop(Seconds(10.0)); + apps.Start(Seconds(2.0)); + apps.Stop(Seconds(20.0)); AsciiTraceHelper ascii; lrWpanHelper.EnableAsciiAll(ascii.CreateFileStream("Ping-6LoW-lr-wpan-meshunder-lr-wpan.tr")); @@ -139,7 +136,7 @@ main(int argc, char** argv) csmaHelper.EnableAsciiAll(ascii.CreateFileStream("Ping-6LoW-lr-wpan-meshunder-csma.tr")); csmaHelper.EnablePcapAll(std::string("Ping-6LoW-lr-wpan-meshunder-csma"), true); - Simulator::Stop(Seconds(10)); + Simulator::Stop(Seconds(20)); Simulator::Run(); Simulator::Destroy(); diff --git a/src/sixlowpan/examples/example-ping-lr-wpan.cc b/src/sixlowpan/examples/example-ping-lr-wpan.cc index 13cce627a..4e99b1e5b 100644 --- a/src/sixlowpan/examples/example-ping-lr-wpan.cc +++ b/src/sixlowpan/examples/example-ping-lr-wpan.cc @@ -49,7 +49,7 @@ main(int argc, char** argv) if (verbose) { - LogComponentEnable("Ping6Application", LOG_LEVEL_ALL); + LogComponentEnable("Ping", LOG_LEVEL_ALL); LogComponentEnable("LrWpanMac", LOG_LEVEL_ALL); LogComponentEnable("LrWpanPhy", LOG_LEVEL_ALL); LogComponentEnable("LrWpanNetDevice", LOG_LEVEL_ALL); @@ -107,21 +107,18 @@ main(int argc, char** argv) << deviceInterfaces.GetAddress(1, 1) << std::endl; } - uint32_t packetSize = 10; + uint32_t packetSize = 16; uint32_t maxPacketCount = 5; Time interPacketInterval = Seconds(1.); - Ping6Helper ping6; + PingHelper ping(deviceInterfaces.GetAddress(1, 1)); - ping6.SetLocal(deviceInterfaces.GetAddress(0, 1)); - ping6.SetRemote(deviceInterfaces.GetAddress(1, 1)); + ping.SetAttribute("Count", UintegerValue(maxPacketCount)); + ping.SetAttribute("Interval", TimeValue(interPacketInterval)); + ping.SetAttribute("Size", UintegerValue(packetSize)); + ApplicationContainer apps = ping.Install(nodes.Get(0)); - ping6.SetAttribute("MaxPackets", UintegerValue(maxPacketCount)); - ping6.SetAttribute("Interval", TimeValue(interPacketInterval)); - ping6.SetAttribute("PacketSize", UintegerValue(packetSize)); - ApplicationContainer apps = ping6.Install(nodes.Get(0)); - - apps.Start(Seconds(1.0)); - apps.Stop(Seconds(10.0)); + apps.Start(Seconds(2.0)); + apps.Stop(Seconds(20.0)); if (!disableAsciiTrace) { @@ -138,7 +135,7 @@ main(int argc, char** argv) Ipv6RoutingHelper::PrintNeighborCacheAllAt(Seconds(9), routingStream); } - Simulator::Stop(Seconds(10)); + Simulator::Stop(Seconds(20)); Simulator::Run(); Simulator::Destroy(); diff --git a/src/sixlowpan/examples/example-sixlowpan.cc b/src/sixlowpan/examples/example-sixlowpan.cc index 0f7429a4d..fc9884f40 100644 --- a/src/sixlowpan/examples/example-sixlowpan.cc +++ b/src/sixlowpan/examples/example-sixlowpan.cc @@ -60,7 +60,7 @@ main(int argc, char** argv) if (verbose) { LogComponentEnable("SixLowPanNetDevice", LOG_LEVEL_ALL); - LogComponentEnable("Ping6Application", LOG_LEVEL_ALL); + LogComponentEnable("Ping", LOG_LEVEL_ALL); } Packet::EnablePrinting(); @@ -107,15 +107,12 @@ main(int argc, char** argv) uint32_t packetSize = 200; uint32_t maxPacketCount = 50; Time interPacketInterval = Seconds(1.); - Ping6Helper ping6; + PingHelper ping(i2.GetAddress(1, 1)); - ping6.SetLocal(i1.GetAddress(0, 1)); - ping6.SetRemote(i2.GetAddress(1, 1)); - - ping6.SetAttribute("MaxPackets", UintegerValue(maxPacketCount)); - ping6.SetAttribute("Interval", TimeValue(interPacketInterval)); - ping6.SetAttribute("PacketSize", UintegerValue(packetSize)); - ApplicationContainer apps = ping6.Install(net1.Get(0)); + ping.SetAttribute("Count", UintegerValue(maxPacketCount)); + ping.SetAttribute("Interval", TimeValue(interPacketInterval)); + ping.SetAttribute("Size", UintegerValue(packetSize)); + ApplicationContainer apps = ping.Install(net1.Get(0)); apps.Start(Seconds(5.0)); apps.Stop(Seconds(15.0)); diff --git a/src/sixlowpan/test/example-ping-lr-wpan.reflog b/src/sixlowpan/test/example-ping-lr-wpan.reflog index 4c43d7a75..6410e8a5c 100644 --- a/src/sixlowpan/test/example-ping-lr-wpan.reflog +++ b/src/sixlowpan/test/example-ping-lr-wpan.reflog @@ -1,6 +1,16 @@ Device 0: pseudo-Mac-48 02:00:00:00:00:01, IPv6 Address 2001:2::ff:fe00:1 Device 1: pseudo-Mac-48 02:00:00:00:00:02, IPv6 Address 2001:2::ff:fe00:2 +PING 2001:2::ff:fe00:2 - 16 bytes of data; 64 bytes including ICMP and IPv6 headers. +24 bytes from (2001:2::ff:fe00:2): icmp_seq=0 ttl=64 time=21.536 ms +24 bytes from (2001:2::ff:fe00:2): icmp_seq=1 ttl=64 time=9.312 ms +24 bytes from (2001:2::ff:fe00:2): icmp_seq=2 ttl=64 time=8.992 ms +24 bytes from (2001:2::ff:fe00:2): icmp_seq=3 ttl=64 time=9.952 ms +24 bytes from (2001:2::ff:fe00:2): icmp_seq=4 ttl=64 time=6.752 ms + +--- 2001:2::ff:fe00:2 ping statistics --- +5 packets transmitted, 5 received, 0% packet loss, time 4006ms +rtt min/avg/max/mdev = 6/10.6/21/5.941 ms NDISC Cache of node 0 at time +9s 2001:2::ff:fe00:2 dev 2 lladdr 00-06-02:00:00:00:00:02 REACHABLE NDISC Cache of node 1 at time +9s -2001:2::ff:fe00:1 dev 2 lladdr 00-06-02:00:00:00:00:01 REACHABLE +2001:2::ff:fe00:1 dev 2 lladdr 00-06-02:00:00:00:00:01 REACHABLE \ No newline at end of file diff --git a/src/test/csma-system-test-suite.cc b/src/test/csma-system-test-suite.cc index 1554e9a13..f973c0318 100644 --- a/src/test/csma-system-test-suite.cc +++ b/src/test/csma-system-test-suite.cc @@ -38,13 +38,13 @@ #include "ns3/packet-socket-address.h" #include "ns3/packet-socket-helper.h" #include "ns3/packet.h" +#include "ns3/ping-helper.h" #include "ns3/pointer.h" #include "ns3/simple-channel.h" #include "ns3/simulator.h" #include "ns3/string.h" #include "ns3/test.h" #include "ns3/uinteger.h" -#include "ns3/v4ping-helper.h" #include @@ -784,23 +784,18 @@ class CsmaPingTestCase : public TestCase void DoRun() override; /** * Sink called when a packet is received by a node. - * \param p Received packet (unused). - * \param ad Sender's address (uused). */ - void SinkRx(Ptr p, const Address& ad); + void SinkRx(Ptr, const Address&); /** * Sink called when a PING ois received. - * \param context Context path (unused). - * \param rtt Round Trip Time (unused). */ - void PingRtt(std::string context, Time rtt); + void PingRtt(std::string, uint16_t, Time); /** * Sink called when a packet is dropped. - * \param p Received packet (unused). */ - void DropEvent(Ptr p); + void DropEvent(Ptr); uint32_t m_countSinkRx; //!< Counter of received packets. uint32_t m_countPingRtt; //!< Counter of PING received. @@ -821,19 +816,19 @@ CsmaPingTestCase::~CsmaPingTestCase() } void -CsmaPingTestCase::SinkRx(Ptr p, const Address& ad) +CsmaPingTestCase::SinkRx(Ptr, const Address&) { m_countSinkRx++; } void -CsmaPingTestCase::PingRtt(std::string context, Time rtt) +CsmaPingTestCase::PingRtt(std::string, uint16_t, Time) { m_countPingRtt++; } void -CsmaPingTestCase::DropEvent(Ptr p) +CsmaPingTestCase::DropEvent(Ptr) { m_drops++; } @@ -888,7 +883,7 @@ CsmaPingTestCase::DoRun() apps.Start(Seconds(0.0)); apps.Stop(Seconds(11.0)); - V4PingHelper ping = V4PingHelper(addresses.GetAddress(2)); + PingHelper ping(addresses.GetAddress(2)); NodeContainer pingers; pingers.Add(c.Get(0)); pingers.Add(c.Get(1)); @@ -902,7 +897,7 @@ CsmaPingTestCase::DoRun() MakeCallback(&CsmaPingTestCase::SinkRx, this)); // Trace pings - Config::Connect("/NodeList/*/ApplicationList/*/$ns3::V4Ping/Rtt", + Config::Connect("/NodeList/*/ApplicationList/*/$ns3::Ping/Rtt", MakeCallback(&CsmaPingTestCase::PingRtt, this)); Simulator::Run(); diff --git a/src/traffic-control/examples/fqcodel-l4s-example.cc b/src/traffic-control/examples/fqcodel-l4s-example.cc index b1f518262..8ddec3f5e 100644 --- a/src/traffic-control/examples/fqcodel-l4s-example.cc +++ b/src/traffic-control/examples/fqcodel-l4s-example.cc @@ -322,9 +322,10 @@ TraceN1Rtt(std::ofstream* ofStream, Time oldRtt, Time newRtt) } void -TracePingRtt(std::ofstream* ofStream, Time rtt) +TracePingRtt(std::ofstream* ofStream, uint16_t seqNo, Time rtt) { - *ofStream << Simulator::Now().GetSeconds() << " " << rtt.GetSeconds() * 1000 << std::endl; + *ofStream << Simulator::Now().GetSeconds() << " " << seqNo << " " << rtt.GetSeconds() * 1000 + << std::endl; } void @@ -816,12 +817,12 @@ main(int argc, char* argv[]) // application setup // //////////////////////////////////////////////////////////// - V4PingHelper pingHelper("192.168.1.2"); + PingHelper pingHelper(Ipv4Address("192.168.1.2")); pingHelper.SetAttribute("Interval", TimeValue(pingInterval)); pingHelper.SetAttribute("Size", UintegerValue(pingSize)); ApplicationContainer pingContainer = pingHelper.Install(pingServer); - Ptr v4Ping = pingContainer.Get(0)->GetObject(); - v4Ping->TraceConnectWithoutContext("Rtt", MakeBoundCallback(&TracePingRtt, &pingOfStream)); + Ptr ping = pingContainer.Get(0)->GetObject(); + ping->TraceConnectWithoutContext("Rtt", MakeBoundCallback(&TracePingRtt, &pingOfStream)); pingContainer.Start(Seconds(1)); pingContainer.Stop(stopTime - Seconds(1));