67 lines
1.6 KiB
C
67 lines
1.6 KiB
C
|
|
#ifndef MY_CUSTOM_APP_H
|
||
|
|
#define MY_CUSTOM_APP_H
|
||
|
|
|
||
|
|
#include "ns3/application.h"
|
||
|
|
#include "ns3/event-id.h"
|
||
|
|
#include "ns3/ptr.h"
|
||
|
|
#include <ns3/traced-callback.h>
|
||
|
|
#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<PointToPointNetDevice> net, int t);
|
||
|
|
bool RxPacket(Ptr<NetDevice> dev, Ptr<const Packet> 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<PointToPointNetDevice> m_net;
|
||
|
|
};
|
||
|
|
|
||
|
|
} // namespace ns3
|
||
|
|
|
||
|
|
#endif
|