class UdpClient : public Application { public: /** * \brief Get the type ID. * \return the object TypeId */ static TypeId GetTypeId(); UdpClient(); ~UdpClient() override; /** * \brief set the remote address and port * \param ip remote IP address * \param port remote port */ void SetRemote(Address ip, uint16_t port); /** * \brief set the remote address * \param addr remote address */ void SetRemote(Address addr); /** * \return the total bytes sent by this app */ uint64_t GetTotalTx() const; 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_totalTx; //!< Total bytes sent Ptr<Socket> m_socket; //!< Socket Address m_peerAddress; //!< Remote peer address uint16_t m_peerPort; //!< Remote peer port EventId m_sendEvent; //!< Event to send the next packet #ifdef NS3_LOG_ENABLE std::string m_peerAddressString; //!< Remote peer address string #endif // NS3_LOG_ENABLE };
时间: 2024-04-27 16:23:45 浏览: 168
lua-anidb:AniDB.net HTTP API 的客户端库和命令行客户端
这是一个名为UdpClient的C++类,它继承自Application类。该类实现了一个UDP客户端,并允许设置远程地址和端口,以及发送的数据包数量、数据包发送之间的时间间隔和发送的数据包大小等参数。它还提供了一些方法来获取应用程序发送的总字节数以及一些保护和私有方法来处理应用程序的启动、停止和发送数据包等操作。
阅读全文