Skip to content

Commit

Permalink
applications: (merges !995) Unify handling of 'MaxPackets attribute i…
Browse files Browse the repository at this point in the history
…s zero'

Treat zero max packets as infinite as PacketSocketClient already does.
  • Loading branch information
a-andre authored and tomhenderson committed Nov 13, 2022
1 parent 40ec1d7 commit adcc13e
Show file tree
Hide file tree
Showing 5 changed files with 55 additions and 48 deletions.
2 changes: 2 additions & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
-------------------------------

Expand Down
13 changes: 7 additions & 6 deletions src/applications/model/udp-client.cc
Original file line number Diff line number Diff line change
Expand Up @@ -50,11 +50,12 @@ UdpClient::GetTypeId()
.SetParent<Application>()
.SetGroupName("Applications")
.AddConstructor<UdpClient>()
.AddAttribute("MaxPackets",
"The maximum number of packets the application will send",
UintegerValue(100),
MakeUintegerAccessor(&UdpClient::m_count),
MakeUintegerChecker<uint32_t>())
.AddAttribute(
"MaxPackets",
"The maximum number of packets the application will send (zero means infinite)",
UintegerValue(100),
MakeUintegerAccessor(&UdpClient::m_count),
MakeUintegerChecker<uint32_t>())
.AddAttribute("Interval",
"The time to wait between packets",
TimeValue(Seconds(1.0)),
Expand Down Expand Up @@ -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);
}
Expand Down
13 changes: 7 additions & 6 deletions src/applications/model/udp-echo-client.cc
Original file line number Diff line number Diff line change
Expand Up @@ -44,11 +44,12 @@ UdpEchoClient::GetTypeId()
.SetParent<Application>()
.SetGroupName("Applications")
.AddConstructor<UdpEchoClient>()
.AddAttribute("MaxPackets",
"The maximum number of packets the application will send",
UintegerValue(100),
MakeUintegerAccessor(&UdpEchoClient::m_count),
MakeUintegerChecker<uint32_t>())
.AddAttribute(
"MaxPackets",
"The maximum number of packets the application will send (zero means infinite)",
UintegerValue(100),
MakeUintegerAccessor(&UdpEchoClient::m_count),
MakeUintegerChecker<uint32_t>())
.AddAttribute("Interval",
"The time to wait between packets",
TimeValue(Seconds(1.0)),
Expand Down Expand Up @@ -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);
}
Expand Down
62 changes: 32 additions & 30 deletions src/internet-apps/model/ping6.cc
Original file line number Diff line number Diff line change
Expand Up @@ -42,35 +42,37 @@ NS_OBJECT_ENSURE_REGISTERED(Ping6);
TypeId
Ping6::GetTypeId()
{
static TypeId tid = TypeId("ns3::Ping6")
.SetParent<Application>()
.SetGroupName("Internet-Apps")
.AddConstructor<Ping6>()
.AddAttribute("MaxPackets",
"The maximum number of packets the application will send",
UintegerValue(100),
MakeUintegerAccessor(&Ping6::m_count),
MakeUintegerChecker<uint32_t>())
.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<uint32_t>());
static TypeId tid =
TypeId("ns3::Ping6")
.SetParent<Application>()
.SetGroupName("Internet-Apps")
.AddConstructor<Ping6>()
.AddAttribute(
"MaxPackets",
"The maximum number of packets the application will send (zero means infinite)",
UintegerValue(100),
MakeUintegerAccessor(&Ping6::m_count),
MakeUintegerChecker<uint32_t>())
.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<uint32_t>());
return tid;
}

Expand Down Expand Up @@ -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);
}
Expand Down
13 changes: 7 additions & 6 deletions src/lte/test/epc-test-s1u-uplink.cc
Original file line number Diff line number Diff line change
Expand Up @@ -125,11 +125,12 @@ EpsBearerTagUdpClient::GetTypeId()
TypeId("ns3::EpsBearerTagUdpClient")
.SetParent<Application>()
.AddConstructor<EpsBearerTagUdpClient>()
.AddAttribute("MaxPackets",
"The maximum number of packets the application will send",
UintegerValue(100),
MakeUintegerAccessor(&EpsBearerTagUdpClient::m_count),
MakeUintegerChecker<uint32_t>())
.AddAttribute(
"MaxPackets",
"The maximum number of packets the application will send (zero means infinite)",
UintegerValue(100),
MakeUintegerAccessor(&EpsBearerTagUdpClient::m_count),
MakeUintegerChecker<uint32_t>())
.AddAttribute("Interval",
"The time to wait between packets",
TimeValue(Seconds(1.0)),
Expand Down Expand Up @@ -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);
}
Expand Down

0 comments on commit adcc13e

Please sign in to comment.