FrameSimulator API Reference#
Plugins#
FrameSimulatorPlugin#
-
class FrameSimulatorPlugin : public OdinData::IVersionedObject#
Abstract plugin class
All frame simulator plugins must inherit from this class. Once an instance of a plugin is constructed the plugin options are populated from the command line program options with a call to ‘setup’. Once setup successfully the simulation is executed with a call to ‘simulate’.
‘populate_options’ is called by the main executable (FrameSimulatorApp.cpp) to determine the plugin options required
Subclassed by FrameSimulator::FrameSimulatorPluginUDP
Public Functions
-
FrameSimulatorPlugin()#
-
virtual bool setup(const po::variables_map &vm)#
Setup frame simulator plugin class from store of command line options
Derived plugins must additionally call this base method even if overridden
- Parameters:
vm – [in] - store of given command line options
- Returns:
true (false) if required program options are (not) specified and the simulator plugin is not ready to use
-
virtual void simulate() = 0#
-
virtual void populate_options(po::options_description &config)#
Populate boost program options with appropriate command line options for plugin
- Parameters:
config – [out] - boost::program_options::options_description to populate with appropriate plugin command line options
Protected Attributes
-
boost::optional<int> replay_numframes_#
-
boost::optional<float> frame_gap_secs_#
Private Members
-
LoggerPtr logger_#
Pointer to logger
-
FrameSimulatorPlugin()#
FrameSimulatorOption#
-
template<class T>
class FrameSimulatorOption# Helper class for specifying frame simulator plugin command line options specifies argument string for option displayed description and (optional) a default value
Public Functions
-
inline FrameSimulatorOption(const std::string &astr, const std::string &desc)#
constructors for a FrameSimulatorOption
- Parameters:
astr – [in] argument string used for specifying option
desc – [in] description of program option to be displayed
dval – [in] (optional) default value
-
inline const char *get_arg() const#
-
inline std::string get_argstring() const#
-
inline std::string get_description() const#
-
inline bool is_specified(const po::variables_map &vm) const#
-
inline void add_option_to(po::options_description &options) const#
-
inline FrameSimulatorOption(const std::string &astr, const std::string &desc)#
FrameSimulatorPluginUDP#
-
class FrameSimulatorPluginUDP : public FrameSimulator::FrameSimulatorPlugin#
-
Any frame simulator plugin which reads pcap or creates dummy frames to send over a socket should inherit from this class not FrameSimulatorPlugin ‘prepare_packets’ (and then ‘extract_frames’) is called on setup if a pcap file is specified: this takes the content of the pcap file and organises it in frames to store ‘create_frames’ is called on setup if no pcap file is specified ‘replay_frames’ is called by simulate: this will replay the created/stored frames
Subclassed by FrameSimulator::DummyUDPFrameSimulatorPlugin
Public Functions
-
FrameSimulatorPluginUDP()#
Construct a FrameSimulatorPluginUDP setup an instance of the logger initialises curr_frame and curr_port_index for handling assignment of frames to appropriate ports
-
~FrameSimulatorPluginUDP()#
Class destructor closes socket
-
virtual void populate_options(po::options_description &config)#
Populate boost program options with appropriate command line options for plugin /param[out] config - boost::program_options::options_description to populate with appropriate plugin command line options
-
virtual bool setup(const po::variables_map &vm)#
Setup frame simulator plugin class from store of command line options
Derived plugins must additionally call this base method even if overridden
- Parameters:
vm – [in] - store of given command line options
- Returns:
true (false) if required program options are (not) specified and the simulator plugin is not ready to use
-
virtual void simulate()#
Simulate detector by replaying frames
Protected Functions
All Packets should be sent using send_packet /param[in] packet to send /param[in] frame to which packet belongs this ensures each frame is sent to the appropriate destination port
-
virtual void extract_frames(const u_char *data, const int &size) = 0#
Extract frames from pcap read data
-
void prepare_packets(const struct pcap_pkthdr *header, const u_char *buffer)#
Prepare frames from pcap header and data buffer
Prepare frame(s) for replay by processing the pcap file /param[in] header /param[in] buffer calls extract_frames which should be implemented by each parent class to extract frames of the appropriate type
-
virtual void create_frames(const int &num_frames) = 0#
Create dummy frames
-
void replay_frames()#
Replay the extracted or created frames
Replay the stored frames called by simulate
Protected Attributes
-
boost::optional<int> packet_gap_#
-
boost::optional<float> drop_frac_#
-
boost::optional<std::vector<std::string>> drop_packets_#
-
UDPFrames frames_#
Frames
-
int total_packets#
-
int total_bytes#
-
int current_frame_num#
-
int current_subframe_num#
Protected Static Functions
-
static void pkt_callback(u_char *user, const pcap_pkthdr *hdr, const u_char *buffer)#
Packet callback function callback for pcap_loop(m_handle, -1, pkt_callback, reinterpret_cast<u_char *>(this)); /param[in] user - final argument of pcap_loop; this class instance /param[in] hdr - pcap header /param[in] buffer pointer to first byte of chunk of data containing the entire packet
-
FrameSimulatorPluginUDP()#
DummyUDPFrameSimulatorPlugin#
-
class DummyUDPFrameSimulatorPlugin : public FrameSimulator::FrameSimulatorPluginUDP#
-
‘prepare_packets’ (and then ‘extract_frames’) is called on setup if a pcap file is specified: this takes the content of the pcap file and organises it in frames to store ‘create_frames’ is called on setup if no pcap file is specified ‘replay_frames’ is called by simulate: this will replay the created/stored frames
Public Functions
-
DummyUDPFrameSimulatorPlugin()#
Construct an DummyUDPFrameSimulatorPlugin setup an instance of the logger initialises data and frame counts
-
virtual void populate_options(po::options_description &config)#
Populate boost program options with appropriate command line options for plugin /param[out] config - boost::program_options::options_description to populate with appropriate plugin command line options
-
virtual bool setup(const po::variables_map &vm)#
Setup frame simulator plugin class from store of command line options
Derived plugins must additionally call this base method even if overridden
- Parameters:
vm – [in] - store of given command line options
- Returns:
true (false) if required program options are (not) specified and the simulator plugin is not ready to use
-
virtual int get_version_major()#
Get the plugin major version number.
- Returns:
major version number as an integer
-
virtual int get_version_minor()#
Get the plugin minor version number.
- Returns:
minor version number as an integer
-
virtual int get_version_patch()#
Get the plugin patch version number.
- Returns:
patch version number as an integer
-
virtual std::string get_version_short()#
Get the plugin short version (e.g. x.y.z) string.
- Returns:
short version as a string
-
virtual std::string get_version_long()#
Get the plugin long version (e.g. x.y.z-qualifier) string.
- Returns:
long version as a string
Protected Functions
-
virtual void extract_frames(const u_char *data, const int &size)#
Extracts the frames from the pcap data file buffer
- Parameters:
data – [in] - pcap data
size – [in]
-
virtual void create_frames(const int &num_frames)#
Creates a number of frames
- Parameters:
num_frames – - number of frames to create
-
DummyUDPFrameSimulatorPlugin()#