Agora  1.2.0
Agora project
MacSender Class Reference

#include <mac_sender.h>

Collaboration diagram for MacSender:

Public Member Functions

 MacSender (Config *cfg, std::string &data_filename, size_t mac_packet_length, size_t mac_payload_max_length, size_t packets_per_frame, std::string server_address, size_t server_rx_port, std::function< size_t(size_t)> get_data_symbol_id, size_t core_offset=30, size_t worker_thread_num=1, size_t update_thread_num=1, size_t frame_duration_us=0, size_t inter_frame_delay=0, size_t enable_slow_start=1, bool create_thread_for_master=false)
 Create and optionally start a Sender Client that sends data packets to a agora mac interface. More...
 
 ~MacSender ()
 
void StartTx ()
 
void StartTxfromMain (double *in_frame_start, double *in_frame_end)
 

Static Public Attributes

static constexpr size_t kDequeueBulkSize = 4
 
static constexpr size_t kMessageQueueSize = 1024
 

Private Member Functions

void * MasterThread (size_t tid)
 
void * WorkerThread (size_t tid)
 
void * DataUpdateThread (size_t tid, size_t num_data_sources)
 
uint64_t GetTicksForFrame (size_t frame_id) const
 
size_t GetMaxSymbolId () const
 
void CreateWorkerThreads (size_t num_workers)
 
void UpdateTxBuffer (MacDataReceiver *data_source, gen_tag_t tag)
 
void WriteStatsToFile (size_t tx_frame_count) const
 
void ScheduleFrame (size_t frame)
 
void LoadFrame (size_t frame)
 
size_t TagToTxBuffersIndex (gen_tag_t tag) const
 

Private Attributes

Configcfg_
 
const double freq_ghz_
 
const double ticks_per_usec_
 
const size_t worker_thread_num_
 
const size_t update_thread_num_
 
const size_t enable_slow_start_
 
const size_t core_offset_
 
size_t frame_duration_us_
 
const size_t inter_frame_delay_
 
uint64_t ticks_all_
 
uint64_t ticks_wnd1_
 
uint64_t ticks_wnd2_
 
const uint64_t ticks_inter_frame_
 
moodycamel::ConcurrentQueue< size_t > send_queue_
 
moodycamel::ConcurrentQueue< size_t > completion_queue_
 
moodycamel::ProducerToken ** task_ptok_
 
std::vector< moodycamel::ConcurrentQueue< size_t > > data_update_queue_
 
double * frame_start_
 
double * frame_end_
 
std::vector< std::thread > threads_
 
Table< uint8_t > tx_buffers_
 
size_t tx_buffer_pkt_offset_
 
std::string data_filename_
 
size_t mac_packet_length_
 
size_t mac_payload_max_length_
 
size_t packets_per_frame_
 
const std::string server_address_
 
const size_t server_rx_port_
 
std::function< size_t(size_t)> get_data_symbol_id_
 
const bool has_master_thread_
 

Constructor & Destructor Documentation

◆ MacSender()

MacSender::MacSender ( Config cfg,
std::string &  data_filename,
size_t  mac_packet_length,
size_t  mac_payload_max_length,
size_t  packets_per_frame,
std::string  server_address,
size_t  server_rx_port,
std::function< size_t(size_t)>  get_data_symbol_id,
size_t  core_offset = 30,
size_t  worker_thread_num = 1,
size_t  update_thread_num = 1,
size_t  frame_duration_us = 0,
size_t  inter_frame_delay = 0,
size_t  enable_slow_start = 1,
bool  create_thread_for_master = false 
)

Create and optionally start a Sender Client that sends data packets to a agora mac interface.

Parameters
configThe Agora config
data_filenameName of the file where the data bytes exist
socket_thread_numNumber of worker threads sending packets
mac_packets_per_frameNumber of mac packets in frame
core_offsetThe master thread runs on core [core_offset]. Worker thread i runs on core [core_offset + i]
frame_duration_usThe TTI slot duration in us
inter_frame_delayDelay between frames
enable_slow_startIf 1, the sender initially sends frames in a duration larger than the TTI
Here is the call graph for this function:

◆ ~MacSender()

MacSender::~MacSender ( )
Here is the call graph for this function:

Member Function Documentation

◆ CreateWorkerThreads()

void MacSender::CreateWorkerThreads ( size_t  num_workers)
private
Here is the call graph for this function:
Here is the caller graph for this function:

◆ DataUpdateThread()

void * MacSender::DataUpdateThread ( size_t  tid,
size_t  num_data_sources 
)
private
Todo:
need a list of file names for this
Todo:
need a list of file names for this
Here is the call graph for this function:
Here is the caller graph for this function:

◆ GetMaxSymbolId()

size_t MacSender::GetMaxSymbolId ( ) const
private

◆ GetTicksForFrame()

uint64_t MacSender::GetTicksForFrame ( size_t  frame_id) const
private
Here is the caller graph for this function:

◆ LoadFrame()

void MacSender::LoadFrame ( size_t  frame)
private
Here is the call graph for this function:
Here is the caller graph for this function:

◆ MasterThread()

void * MacSender::MasterThread ( size_t  tid)
private
Here is the call graph for this function:
Here is the caller graph for this function:

◆ ScheduleFrame()

void MacSender::ScheduleFrame ( size_t  frame)
private
Here is the call graph for this function:
Here is the caller graph for this function:

◆ StartTx()

void MacSender::StartTx ( )
Here is the call graph for this function:

◆ StartTxfromMain()

void MacSender::StartTxfromMain ( double *  in_frame_start,
double *  in_frame_end 
)
Here is the call graph for this function:

◆ TagToTxBuffersIndex()

size_t MacSender::TagToTxBuffersIndex ( gen_tag_t  tag) const
inlineprivate
Here is the call graph for this function:
Here is the caller graph for this function:

◆ UpdateTxBuffer()

void MacSender::UpdateTxBuffer ( MacDataReceiver data_source,
gen_tag_t  tag 
)
private
Here is the call graph for this function:
Here is the caller graph for this function:

◆ WorkerThread()

void * MacSender::WorkerThread ( size_t  tid)
private
Todo:
Use assume_aligned<kTxBufferElementAlignment> when code has c++20 support
Here is the call graph for this function:
Here is the caller graph for this function:

◆ WriteStatsToFile()

void MacSender::WriteStatsToFile ( size_t  tx_frame_count) const
private
Here is the call graph for this function:
Here is the caller graph for this function:

Member Data Documentation

◆ cfg_

Config* MacSender::cfg_
private

◆ completion_queue_

moodycamel::ConcurrentQueue<size_t> MacSender::completion_queue_
private

◆ core_offset_

const size_t MacSender::core_offset_
private

◆ data_filename_

std::string MacSender::data_filename_
private

◆ data_update_queue_

std::vector<moodycamel::ConcurrentQueue<size_t> > MacSender::data_update_queue_
private

◆ enable_slow_start_

const size_t MacSender::enable_slow_start_
private

◆ frame_duration_us_

size_t MacSender::frame_duration_us_
private

◆ frame_end_

double* MacSender::frame_end_
private

◆ frame_start_

double* MacSender::frame_start_
private

◆ freq_ghz_

const double MacSender::freq_ghz_
private

◆ get_data_symbol_id_

std::function<size_t(size_t)> MacSender::get_data_symbol_id_
private

◆ has_master_thread_

const bool MacSender::has_master_thread_
private

◆ inter_frame_delay_

const size_t MacSender::inter_frame_delay_
private

◆ kDequeueBulkSize

constexpr size_t MacSender::kDequeueBulkSize = 4
staticconstexpr

◆ kMessageQueueSize

constexpr size_t MacSender::kMessageQueueSize = 1024
staticconstexpr

◆ mac_packet_length_

size_t MacSender::mac_packet_length_
private

◆ mac_payload_max_length_

size_t MacSender::mac_payload_max_length_
private

◆ packets_per_frame_

size_t MacSender::packets_per_frame_
private

◆ send_queue_

moodycamel::ConcurrentQueue<size_t> MacSender::send_queue_
private

◆ server_address_

const std::string MacSender::server_address_
private

◆ server_rx_port_

const size_t MacSender::server_rx_port_
private

◆ task_ptok_

moodycamel::ProducerToken** MacSender::task_ptok_
private

◆ threads_

std::vector<std::thread> MacSender::threads_
private

◆ ticks_all_

uint64_t MacSender::ticks_all_
private

◆ ticks_inter_frame_

const uint64_t MacSender::ticks_inter_frame_
private

◆ ticks_per_usec_

const double MacSender::ticks_per_usec_
private

◆ ticks_wnd1_

uint64_t MacSender::ticks_wnd1_
private

◆ ticks_wnd2_

uint64_t MacSender::ticks_wnd2_
private

◆ tx_buffer_pkt_offset_

size_t MacSender::tx_buffer_pkt_offset_
private

◆ tx_buffers_

Table<uint8_t> MacSender::tx_buffers_
private

◆ update_thread_num_

const size_t MacSender::update_thread_num_
private

◆ worker_thread_num_

const size_t MacSender::worker_thread_num_
private

The documentation for this class was generated from the following files:
MacSender::kMessageQueueSize
static constexpr size_t kMessageQueueSize
Definition: mac_sender.h:22
moodycamel::ConcurrentQueue< size_t >