From afe0c6b0f2bd4d50d2a47ca0291e8c7412f15bbc Mon Sep 17 00:00:00 2001 From: Stefano Avallone Date: Wed, 9 Aug 2023 15:56:22 +0200 Subject: [PATCH] network: Packet socket client does not schedule Send() for bursts of packets --- src/network/utils/packet-socket-client.cc | 12 +++++++++++- src/network/utils/packet-socket-client.h | 5 +++++ 2 files changed, 16 insertions(+), 1 deletion(-) diff --git a/src/network/utils/packet-socket-client.cc b/src/network/utils/packet-socket-client.cc index 61eb94f5d..96634f78b 100644 --- a/src/network/utils/packet-socket-client.cc +++ b/src/network/utils/packet-socket-client.cc @@ -183,7 +183,17 @@ PacketSocketClient::Send() if ((m_sent < m_maxPackets) || (m_maxPackets == 0)) { - m_sendEvent = Simulator::Schedule(m_interval, &PacketSocketClient::Send, this); + if (m_interval.IsZero()) + { + NS_ABORT_MSG_IF( + m_maxPackets == 0, + "Generating infinite packets at the same time does not seem to be a good idea"); + Send(); + } + else + { + m_sendEvent = Simulator::Schedule(m_interval, &PacketSocketClient::Send, this); + } } } diff --git a/src/network/utils/packet-socket-client.h b/src/network/utils/packet-socket-client.h index f20d479ea..ac10c73e8 100644 --- a/src/network/utils/packet-socket-client.h +++ b/src/network/utils/packet-socket-client.h @@ -91,6 +91,11 @@ class PacketSocketClient : public Application /** * \brief Send a packet + * + * Either Interval and MaxPackets may be zero, but not both. If Interval + * is zero, the PacketSocketClient will send MaxPackets packets without any delay into + * the socket. If MaxPackets is zero, then the PacketSocketClient will send every + * Interval until the application is stopped. */ void Send();