From 64949975cfcefabcac399fde34b59a6e925e8ebe Mon Sep 17 00:00:00 2001 From: BAILLEUL Quentin Date: Wed, 18 Mar 2026 08:40:42 +0100 Subject: [PATCH] Remove old traffic generator stuff --- contrib/traffic-generator/CMakeLists.txt | 10 +- .../helper/traffic-generator-helper.h | 2 - .../model/ethernet-generator.cc | 4 +- .../model/ethernet-generator.h | 3 +- .../traffic-generator/model/myCustomApp.cc | 119 ------------------ contrib/traffic-generator/model/myCustomApp.h | 66 ---------- .../model/traffic-generator.cc | 8 -- .../model/traffic-generator.h | 20 --- 8 files changed, 6 insertions(+), 226 deletions(-) delete mode 100644 contrib/traffic-generator/model/myCustomApp.cc delete mode 100644 contrib/traffic-generator/model/myCustomApp.h delete mode 100644 contrib/traffic-generator/model/traffic-generator.cc delete mode 100644 contrib/traffic-generator/model/traffic-generator.h diff --git a/contrib/traffic-generator/CMakeLists.txt b/contrib/traffic-generator/CMakeLists.txt index be2800e..cda9167 100644 --- a/contrib/traffic-generator/CMakeLists.txt +++ b/contrib/traffic-generator/CMakeLists.txt @@ -6,19 +6,15 @@ endif() set(examples_as_tests_sources) if(${ENABLE_EXAMPLES}) set(examples_as_tests_sources - #test/traffic-generator-examples-test-suite.cc + #test/traffic-generator-examples-test-suite.cc ) endif() build_lib( LIBNAME traffic-generator - SOURCE_FILES model/traffic-generator.cc - model/ethernet-generator.cc - model/myCustomApp.cc + SOURCE_FILES model/ethernet-generator.cc helper/traffic-generator-helper.cc - HEADER_FILES model/traffic-generator.h - model/ethernet-generator.h - model/myCustomApp.h + HEADER_FILES model/ethernet-generator.h helper/traffic-generator-helper.h LIBRARIES_TO_LINK ${libcore} ${libethernet} diff --git a/contrib/traffic-generator/helper/traffic-generator-helper.h b/contrib/traffic-generator/helper/traffic-generator-helper.h index 51737dc..b1e75dd 100644 --- a/contrib/traffic-generator/helper/traffic-generator-helper.h +++ b/contrib/traffic-generator/helper/traffic-generator-helper.h @@ -1,8 +1,6 @@ #ifndef TRAFFIC_GENERATOR_HELPER_H #define TRAFFIC_GENERATOR_HELPER_H -#include "ns3/traffic-generator.h" - namespace ns3 { diff --git a/contrib/traffic-generator/model/ethernet-generator.cc b/contrib/traffic-generator/model/ethernet-generator.cc index b02437f..3c6464e 100644 --- a/contrib/traffic-generator/model/ethernet-generator.cc +++ b/contrib/traffic-generator/model/ethernet-generator.cc @@ -81,7 +81,7 @@ EthernetGenerator::GetTypeId() "Trace source indicating a packet was given to the netDevice" "by the application", MakeTraceSourceAccessor(&EthernetGenerator::m_pktSentTrace), - "ns3::EthernetGenerator::PacketVlanTraceCallback"); + "ns3::Packet::TracedCallback"); return tid; } @@ -160,7 +160,7 @@ EthernetGenerator::Send() else{ m_net->Send(p, m_destAddress, 0xEDE1, m_vid, m_pcp, m_dei); } - m_pktSentTrace(p, m_vid); + m_pktSentTrace(p); } } // Namespace ns3 diff --git a/contrib/traffic-generator/model/ethernet-generator.h b/contrib/traffic-generator/model/ethernet-generator.h index 20d8b8c..b5602c6 100644 --- a/contrib/traffic-generator/model/ethernet-generator.h +++ b/contrib/traffic-generator/model/ethernet-generator.h @@ -34,7 +34,6 @@ class EthernetGenerator : public Application void Setup(Ptr net); - typedef TracedCallback, uint16_t> PacketVlanTraceCallback; protected: void DoDispose() override; @@ -66,7 +65,7 @@ class EthernetGenerator : public Application EventId m_sendEvent; //!< Event to send the next packet Ptr m_net; - PacketVlanTraceCallback m_pktSentTrace; + TracedCallback> m_pktSentTrace; static const uint16_t MIN_PAYLOAD_SIZE = 42; //Min payload size with VLAN }; diff --git a/contrib/traffic-generator/model/myCustomApp.cc b/contrib/traffic-generator/model/myCustomApp.cc deleted file mode 100644 index fbe841b..0000000 --- a/contrib/traffic-generator/model/myCustomApp.cc +++ /dev/null @@ -1,119 +0,0 @@ -#include "myCustomApp.h" - -#include "ns3/log.h" -#include "ns3/simulator.h" -#include "ns3/socket-factory.h" -#include "ns3/socket.h" -#include "ns3/uinteger.h" -#include "ns3/names.h" -#include "ns3/point-to-point-net-device.h" - -#include -#include - -namespace ns3 -{ - -NS_LOG_COMPONENT_DEFINE("myCustomApp"); - -NS_OBJECT_ENSURE_REGISTERED(myCustomApp); - -TypeId -myCustomApp::GetTypeId() -{ - static TypeId tid = - TypeId("ns3::myCustomApp") - .SetParent() - .SetGroupName("Applications") - .AddConstructor(); - return tid; -} - -myCustomApp::myCustomApp() -{ - NS_LOG_FUNCTION(this); - m_sent = 0; - m_totalTx = 0; - m_totalRx = 0; - m_sendEvent = EventId(); -} - -myCustomApp::~myCustomApp() -{ - NS_LOG_FUNCTION(this); -} - -void -myCustomApp::Setup(Ptr net, int t) -{ - m_net = net; - Packet::EnablePrinting(); - m_sendEvent = Simulator::Schedule(Seconds(t), &myCustomApp::Send, this); - m_net->SetReceiveCallback(MakeCallback(&myCustomApp::RxPacket, this)); -} - -bool -myCustomApp::RxPacket(Ptr dev, Ptr pkt, uint16_t mode, const Address& sender) -{ - m_totalRx = m_totalRx + pkt->GetSize(); - NS_LOG_INFO((Simulator::Now()).As(Time::S) << " \t" << Names::FindName(m_net->GetNode()) << "/" << Names::FindName(m_net) <<" : Pkt rcvd ! " << pkt->ToString()); - return true; -} - -void -myCustomApp::DoDispose() -{ - NS_LOG_FUNCTION(this); - Application::DoDispose(); -} - -void -myCustomApp::StartApplication() -{ - NS_LOG_FUNCTION(this); - - -} - -void -myCustomApp::StopApplication() -{ - NS_LOG_FUNCTION(this); - Simulator::Cancel(m_sendEvent); - NS_LOG_INFO("\tNb bytes rcvd :" << GetTotalRx()); -} - -void -myCustomApp::Send() -{ - NS_LOG_FUNCTION(this); - NS_ASSERT(m_sendEvent.IsExpired()); - - - uint8_t txBuffer[] = "\"Can you tell me where my country lies?\" \\ said the unifaun to his " - "true love's eyes. \\ \"It lies with me!\" cried the Queen of Maybe \\ - " - "for her merchandise, he traded in his prize."; - size_t txBufferSize = sizeof(txBuffer); - Ptr p = Create(txBuffer, txBufferSize); - - NS_LOG_INFO((Simulator::Now()).As(Time::S) << " \t" << Names::FindName(m_net->GetNode()) << "/" << Names::FindName(m_net) <<" : Pkt sent ! " << p->ToString()); - - m_net->Send(p, m_net->GetBroadcast(), 0x800); - - m_sendEvent = Simulator::Schedule(Seconds(2), &myCustomApp::Send, this); - -} - -uint64_t -myCustomApp::GetTotalTx() const -{ - return m_totalTx; -} - -uint64_t -myCustomApp::GetTotalRx() const -{ - return m_totalRx; -} - -} // Namespace ns3 diff --git a/contrib/traffic-generator/model/myCustomApp.h b/contrib/traffic-generator/model/myCustomApp.h deleted file mode 100644 index 0a90ca8..0000000 --- a/contrib/traffic-generator/model/myCustomApp.h +++ /dev/null @@ -1,66 +0,0 @@ -#ifndef MY_CUSTOM_APP_H -#define MY_CUSTOM_APP_H - -#include "ns3/application.h" -#include "ns3/event-id.h" -#include "ns3/ptr.h" -#include -#include "ns3/point-to-point-net-device.h" - -namespace ns3 -{ - -class Socket; -class Packet; - - -class myCustomApp : public Application -{ - public: - /** - * \brief Get the type ID. - * \return the object TypeId - */ - static TypeId GetTypeId(); - - myCustomApp(); - - ~myCustomApp() override; - - /** - * \return the total bytes sent by this app - */ - uint64_t GetTotalTx() const; - uint64_t GetTotalRx() const; - - void Setup(Ptr net, int t); - bool RxPacket(Ptr dev, Ptr pkt, uint16_t mode, const Address& sender); - - protected: - void DoDispose() override; - - private: - void StartApplication() override; - void StopApplication() override; - - /** - * \brief Send a packet - */ - void Send(); - - uint32_t m_count; //!< Maximum number of packets the application will send - Time m_interval; //!< Packet inter-send time - uint32_t m_size; //!< Size of the sent packet (including the SeqTsHeader) - - uint32_t m_sent; //!< Counter for sent packets - uint64_t m_totalRx; //!< Total bytes sent - uint64_t m_totalTx; //!< Total bytes rcvd - Address m_peerAddress; //!< Remote peer address - uint16_t m_peerPort; //!< Remote peer port - EventId m_sendEvent; //!< Event to send the next packet - Ptr m_net; -}; - -} // namespace ns3 - -#endif diff --git a/contrib/traffic-generator/model/traffic-generator.cc b/contrib/traffic-generator/model/traffic-generator.cc deleted file mode 100644 index b598a7f..0000000 --- a/contrib/traffic-generator/model/traffic-generator.cc +++ /dev/null @@ -1,8 +0,0 @@ -#include "traffic-generator.h" - -namespace ns3 -{ - -/* ... */ - -} diff --git a/contrib/traffic-generator/model/traffic-generator.h b/contrib/traffic-generator/model/traffic-generator.h deleted file mode 100644 index b08fdbd..0000000 --- a/contrib/traffic-generator/model/traffic-generator.h +++ /dev/null @@ -1,20 +0,0 @@ -#ifndef TRAFFIC_GENERATOR_H -#define TRAFFIC_GENERATOR_H - -// Add a doxygen group for this module. -// If you have more than one file, this should be in only one of them. -/** - * \defgroup traffic-generator Description of the traffic-generator - */ - -namespace ns3 -{ - -// Each class should be documented using Doxygen, -// and have an \ingroup traffic-generator directive - -/* ... */ - -} - -#endif /* TRAFFIC_GENERATOR_H */