From adcc13e93c41fcfa4c4013fa5f598cb300bd0a39 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9=20Apitzsch?= Date: Mon, 20 Jun 2022 18:00:56 +0200 Subject: [PATCH] applications: (merges !995) Unify handling of 'MaxPackets attribute is zero' Treat zero max packets as infinite as PacketSocketClient already does. --- CHANGES.md | 2 + src/applications/model/udp-client.cc | 13 ++--- src/applications/model/udp-echo-client.cc | 13 ++--- src/internet-apps/model/ping6.cc | 62 ++++++++++++----------- src/lte/test/epc-test-s1u-uplink.cc | 13 ++--- 5 files changed, 55 insertions(+), 48 deletions(-) diff --git a/CHANGES.md b/CHANGES.md index 986ba493a..d80e4479c 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -28,6 +28,8 @@ Changes from ns-3.37 to ns-3.38 ### Changed behavior +* (applications) **UdpClient** and **UdpEchoClient** MaxPackets attribute is aligned with other applications, in that the value zero means infinite packets. + Changes from ns-3.36 to ns-3.37 ------------------------------- diff --git a/src/applications/model/udp-client.cc b/src/applications/model/udp-client.cc index a1e002e5a..f5b4c9379 100644 --- a/src/applications/model/udp-client.cc +++ b/src/applications/model/udp-client.cc @@ -50,11 +50,12 @@ UdpClient::GetTypeId() .SetParent() .SetGroupName("Applications") .AddConstructor() - .AddAttribute("MaxPackets", - "The maximum number of packets the application will send", - UintegerValue(100), - MakeUintegerAccessor(&UdpClient::m_count), - MakeUintegerChecker()) + .AddAttribute( + "MaxPackets", + "The maximum number of packets the application will send (zero means infinite)", + UintegerValue(100), + MakeUintegerAccessor(&UdpClient::m_count), + MakeUintegerChecker()) .AddAttribute("Interval", "The time to wait between packets", TimeValue(Seconds(1.0)), @@ -223,7 +224,7 @@ UdpClient::Send() } #endif // NS3_LOG_ENABLE - if (m_sent < m_count) + if (m_sent < m_count || m_count == 0) { m_sendEvent = Simulator::Schedule(m_interval, &UdpClient::Send, this); } diff --git a/src/applications/model/udp-echo-client.cc b/src/applications/model/udp-echo-client.cc index 70cd095cb..ef7531d57 100644 --- a/src/applications/model/udp-echo-client.cc +++ b/src/applications/model/udp-echo-client.cc @@ -44,11 +44,12 @@ UdpEchoClient::GetTypeId() .SetParent() .SetGroupName("Applications") .AddConstructor() - .AddAttribute("MaxPackets", - "The maximum number of packets the application will send", - UintegerValue(100), - MakeUintegerAccessor(&UdpEchoClient::m_count), - MakeUintegerChecker()) + .AddAttribute( + "MaxPackets", + "The maximum number of packets the application will send (zero means infinite)", + UintegerValue(100), + MakeUintegerAccessor(&UdpEchoClient::m_count), + MakeUintegerChecker()) .AddAttribute("Interval", "The time to wait between packets", TimeValue(Seconds(1.0)), @@ -391,7 +392,7 @@ UdpEchoClient::Send() << Inet6SocketAddress::ConvertFrom(m_peerAddress).GetPort()); } - if (m_sent < m_count) + if (m_sent < m_count || m_count == 0) { ScheduleTransmit(m_interval); } diff --git a/src/internet-apps/model/ping6.cc b/src/internet-apps/model/ping6.cc index 55addfde6..90064669e 100644 --- a/src/internet-apps/model/ping6.cc +++ b/src/internet-apps/model/ping6.cc @@ -42,35 +42,37 @@ NS_OBJECT_ENSURE_REGISTERED(Ping6); TypeId Ping6::GetTypeId() { - static TypeId tid = TypeId("ns3::Ping6") - .SetParent() - .SetGroupName("Internet-Apps") - .AddConstructor() - .AddAttribute("MaxPackets", - "The maximum number of packets the application will send", - UintegerValue(100), - MakeUintegerAccessor(&Ping6::m_count), - MakeUintegerChecker()) - .AddAttribute("Interval", - "The time to wait between packets", - TimeValue(Seconds(1.0)), - MakeTimeAccessor(&Ping6::m_interval), - MakeTimeChecker()) - .AddAttribute("RemoteIpv6", - "The Ipv6Address of the outbound packets", - Ipv6AddressValue(), - MakeIpv6AddressAccessor(&Ping6::m_peerAddress), - MakeIpv6AddressChecker()) - .AddAttribute("LocalIpv6", - "Local Ipv6Address of the sender", - Ipv6AddressValue(), - MakeIpv6AddressAccessor(&Ping6::m_localAddress), - MakeIpv6AddressChecker()) - .AddAttribute("PacketSize", - "Size of packets generated", - UintegerValue(100), - MakeUintegerAccessor(&Ping6::m_size), - MakeUintegerChecker()); + static TypeId tid = + TypeId("ns3::Ping6") + .SetParent() + .SetGroupName("Internet-Apps") + .AddConstructor() + .AddAttribute( + "MaxPackets", + "The maximum number of packets the application will send (zero means infinite)", + UintegerValue(100), + MakeUintegerAccessor(&Ping6::m_count), + MakeUintegerChecker()) + .AddAttribute("Interval", + "The time to wait between packets", + TimeValue(Seconds(1.0)), + MakeTimeAccessor(&Ping6::m_interval), + MakeTimeChecker()) + .AddAttribute("RemoteIpv6", + "The Ipv6Address of the outbound packets", + Ipv6AddressValue(), + MakeIpv6AddressAccessor(&Ping6::m_peerAddress), + MakeIpv6AddressChecker()) + .AddAttribute("LocalIpv6", + "Local Ipv6Address of the sender", + Ipv6AddressValue(), + MakeIpv6AddressAccessor(&Ping6::m_localAddress), + MakeIpv6AddressChecker()) + .AddAttribute("PacketSize", + "Size of packets generated", + UintegerValue(100), + MakeUintegerAccessor(&Ping6::m_size), + MakeUintegerChecker()); return tid; } @@ -246,7 +248,7 @@ Ping6::Send() NS_LOG_INFO("Sent " << p->GetSize() << " bytes to " << m_peerAddress); - if (m_sent < m_count) + if (m_sent < m_count || m_count == 0) { ScheduleTransmit(m_interval); } diff --git a/src/lte/test/epc-test-s1u-uplink.cc b/src/lte/test/epc-test-s1u-uplink.cc index 5c4ae74aa..f4f2961e9 100644 --- a/src/lte/test/epc-test-s1u-uplink.cc +++ b/src/lte/test/epc-test-s1u-uplink.cc @@ -125,11 +125,12 @@ EpsBearerTagUdpClient::GetTypeId() TypeId("ns3::EpsBearerTagUdpClient") .SetParent() .AddConstructor() - .AddAttribute("MaxPackets", - "The maximum number of packets the application will send", - UintegerValue(100), - MakeUintegerAccessor(&EpsBearerTagUdpClient::m_count), - MakeUintegerChecker()) + .AddAttribute( + "MaxPackets", + "The maximum number of packets the application will send (zero means infinite)", + UintegerValue(100), + MakeUintegerAccessor(&EpsBearerTagUdpClient::m_count), + MakeUintegerChecker()) .AddAttribute("Interval", "The time to wait between packets", TimeValue(Seconds(1.0)), @@ -241,7 +242,7 @@ EpsBearerTagUdpClient::Send() NS_LOG_INFO("Error while sending " << m_size << " bytes to " << m_peerAddress); } - if (m_sent < m_count) + if (m_sent < m_count || m_count == 0) { m_sendEvent = Simulator::Schedule(m_interval, &EpsBearerTagUdpClient::Send, this); }