From e90a8924f5ae3fb961b3aef9e8a2606e178c70df Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Deronne?= Date: Wed, 24 Jan 2024 12:52:44 +0100 Subject: [PATCH] network, applications, internet-apps: Add AssignStreams method to application base class --- src/applications/helper/on-off-helper.cc | 6 +----- src/applications/model/onoff-application.h | 9 +-------- src/internet-apps/model/dhcp-client.h | 10 +--------- src/internet-apps/model/radvd.h | 10 +--------- src/network/model/application.cc | 7 +++++++ src/network/model/application.h | 9 +++++++++ 6 files changed, 20 insertions(+), 31 deletions(-) diff --git a/src/applications/helper/on-off-helper.cc b/src/applications/helper/on-off-helper.cc index 5dfcdbc13..12a03300c 100644 --- a/src/applications/helper/on-off-helper.cc +++ b/src/applications/helper/on-off-helper.cc @@ -87,11 +87,7 @@ OnOffHelper::AssignStreams(NodeContainer c, int64_t stream) node = (*i); for (uint32_t j = 0; j < node->GetNApplications(); j++) { - Ptr onoff = DynamicCast(node->GetApplication(j)); - if (onoff) - { - currentStream += onoff->AssignStreams(currentStream); - } + currentStream += node->GetApplication(j)->AssignStreams(currentStream); } } return (currentStream - stream); diff --git a/src/applications/model/onoff-application.h b/src/applications/model/onoff-application.h index 07787c34d..a994abcec 100644 --- a/src/applications/model/onoff-application.h +++ b/src/applications/model/onoff-application.h @@ -122,14 +122,7 @@ class OnOffApplication : public Application */ Ptr GetSocket() const; - /** - * \brief Assign a fixed random variable stream number to the random variables - * used by this model. - * - * \param stream first stream index to use - * \return the number of stream indices assigned by this model - */ - int64_t AssignStreams(int64_t stream); + int64_t AssignStreams(int64_t stream) override; protected: void DoDispose() override; diff --git a/src/internet-apps/model/dhcp-client.h b/src/internet-apps/model/dhcp-client.h index fb65f7492..de342582c 100644 --- a/src/internet-apps/model/dhcp-client.h +++ b/src/internet-apps/model/dhcp-client.h @@ -80,15 +80,7 @@ class DhcpClient : public Application */ Ipv4Address GetDhcpServer(); - /** - * Assign a fixed random variable stream number to the random variables - * used by this model. Return the number of streams (possibly zero) that - * have been assigned. - * - * \param stream First stream index to use - * \return the number of stream indices assigned by this model - */ - int64_t AssignStreams(int64_t stream); + int64_t AssignStreams(int64_t stream) override; protected: void DoDispose() override; diff --git a/src/internet-apps/model/radvd.h b/src/internet-apps/model/radvd.h index 57f62d8e2..a599aeac8 100644 --- a/src/internet-apps/model/radvd.h +++ b/src/internet-apps/model/radvd.h @@ -85,15 +85,7 @@ class Radvd : public Application */ void AddConfiguration(Ptr routerInterface); - /** - * Assign a fixed random variable stream number to the random variables - * used by this model. Return the number of streams (possibly zero) that - * have been assigned. - * - * \param stream first stream index to use - * \return the number of stream indices assigned by this model - */ - int64_t AssignStreams(int64_t stream); + int64_t AssignStreams(int64_t stream) override; protected: void DoDispose() override; diff --git a/src/network/model/application.cc b/src/network/model/application.cc index b28a98f31..2b931d6db 100644 --- a/src/network/model/application.cc +++ b/src/network/model/application.cc @@ -132,4 +132,11 @@ Application::StopApplication() NS_LOG_FUNCTION(this); } +int64_t +Application::AssignStreams(int64_t stream) +{ + NS_LOG_FUNCTION(this << stream); + return 0; +} + } // namespace ns3 diff --git a/src/network/model/application.h b/src/network/model/application.h index bec5b5809..5e3c6a12d 100644 --- a/src/network/model/application.h +++ b/src/network/model/application.h @@ -105,6 +105,15 @@ class Application : public Object */ void SetNode(Ptr node); + /** + * \brief Assign a fixed random variable stream number to the random variables + * used by this Application object. + * + * \param stream first stream index to use + * \return the number of stream indices assigned by this Application object + */ + virtual int64_t AssignStreams(int64_t stream); + /** * \brief Common callback signature for packet delay and address. *