73 lines
1.4 KiB
C++
73 lines
1.4 KiB
C++
#ifndef ETHERNET_GENERATOR_H
|
|
#define ETHERNET_GENERATOR_H
|
|
|
|
#include "ns3/application.h"
|
|
#include "ns3/event-id.h"
|
|
#include "ns3/ptr.h"
|
|
#include <ns3/traced-callback.h>
|
|
#include "ns3/ethernet-net-device.h"
|
|
|
|
namespace ns3
|
|
{
|
|
|
|
class Socket;
|
|
class Packet;
|
|
|
|
|
|
class EthernetGenerator : public Application
|
|
{
|
|
public:
|
|
/**
|
|
* \brief Get the type ID.
|
|
* \return the object TypeId
|
|
*/
|
|
static TypeId GetTypeId();
|
|
|
|
EthernetGenerator();
|
|
|
|
~EthernetGenerator() override;
|
|
|
|
/**
|
|
* \return the total bytes sent by this app
|
|
*/
|
|
|
|
void Setup(Ptr<EthernetNetDevice> net);
|
|
|
|
typedef TracedCallback<Ptr<const Packet>, uint16_t> PacketVlanTraceCallback;
|
|
|
|
protected:
|
|
void DoDispose() override;
|
|
|
|
private:
|
|
void StartApplication() override;
|
|
void StopApplication() override;
|
|
|
|
/**
|
|
* \brief Send a packet
|
|
*/
|
|
void SendBurst();
|
|
void Send();
|
|
|
|
Address m_destAddress;
|
|
int m_payload_size;
|
|
int m_burst_size;
|
|
Time m_period;
|
|
Time m_interframe;
|
|
Time m_offset;
|
|
|
|
uint16_t m_vid;
|
|
uint8_t m_pcp;
|
|
uint8_t m_dei;
|
|
|
|
EventId m_sendEvent; //!< Event to send the next packet
|
|
Ptr<EthernetNetDevice> m_net;
|
|
|
|
PacketVlanTraceCallback m_pktSentTrace;
|
|
|
|
static const uint16_t MIN_PAYLOAD_SIZE = 42; //Min payload size with VLAN
|
|
};
|
|
|
|
} // namespace ns3
|
|
|
|
#endif
|