network: Packet socket client does not schedule Send() for bursts of packets

This commit is contained in:
Stefano Avallone
2023-08-09 15:56:22 +02:00
parent b75e2fc7ee
commit afe0c6b0f2
2 changed files with 16 additions and 1 deletions

View File

@@ -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);
}
}
}

View File

@@ -91,6 +91,11 @@ class PacketSocketClient : public Application
/**
* \brief Send a packet
*
* Either <i>Interval</i> and <i>MaxPackets</i> may be zero, but not both. If <i>Interval</i>
* is zero, the PacketSocketClient will send <i>MaxPackets</i> packets without any delay into
* the socket. If <i>MaxPackets</i> is zero, then the PacketSocketClient will send every
* <i>Interval</i> until the application is stopped.
*/
void Send();