Agora  1.2.0
Agora project
receiver.h
Go to the documentation of this file.
1 
5 #ifndef RECEIVER_H_
6 #define RECEIVER_H_
7 
8 #include <sys/types.h>
9 #include <unistd.h>
10 
11 #include <algorithm>
12 #include <cassert>
13 #include <chrono>
14 #include <ctime>
15 #include <iostream>
16 #include <mutex>
17 #include <numeric>
18 #include <vector>
19 
20 #include "concurrentqueue.h"
21 #include "config.h"
22 #include "gettime.h"
23 #include "message.h"
24 #include "symbols.h"
25 
26 using ushort = unsigned short;
27 class Receiver {
28  public:
29  explicit Receiver(Config* cfg, size_t rx_thread_num = 1,
30  size_t core_offset = 1);
31 
36  Receiver(Config* cfg, size_t rx_thread_num, size_t core_offset,
38  moodycamel::ProducerToken** in_rx_ptoks);
39  ~Receiver() = default;
40 
50  std::vector<std::thread> StartRecv(Table<char>& in_buffer,
51  size_t in_buffer_length,
52  Table<double>& in_frame_start);
53 
58  void* LoopRecv(size_t tid);
59 
60  private:
61  // Dimension 1: socket_thread
62  // Dimension 2: rx_packet
63  std::vector<std::vector<RxPacket>> rx_packets_;
65 
67 
71  size_t core_id_;
73 };
74 
75 #endif // RECEIVER_H_
Receiver::core_id_
size_t core_id_
Definition: receiver.h:71
Receiver::rx_ptoks_
moodycamel::ProducerToken ** rx_ptoks_
Definition: receiver.h:70
fmt::v8::detail::byte
byte
Definition: core.h:388
udp_comm.h
Declaration file for the UDPComm class. This class is used to send messages and receive messages from...
moodycamel::ProducerToken
Definition: concurrentqueue.h:630
Config::Running
void Running(bool value)
Definition: config.h:33
ushort
unsigned short ushort
Definition: receiver.h:26
Packet::frame_id_
uint32_t frame_id_
Definition: message.h:168
Config::UeAntNum
size_t UeAntNum() const
Definition: config.h:41
Table::Calloc
void Calloc(size_t dim1, size_t dim2, Agora_memory::Alignment_t alignment)
Definition: memory_manage.h:45
kDebugSenderReceiver
static constexpr bool kDebugSenderReceiver
Definition: symbols.h:354
PinToCoreWithOffset
void PinToCoreWithOffset(ThreadType thread_type, size_t core_offset, size_t thread_id, bool allow_reuse, bool verbose)
Definition: utils.cc:157
ReadFromFile
static void ReadFromFile(const std::string &filename, Table< TableType > &data, size_t num_reads, size_t read_elements, size_t element_size)
Definition: main.cc:23
Config::SampsPerSymbol
size_t SampsPerSymbol() const
Definition: config.h:234
fmt::v8::printf
auto printf(const S &fmt, const T &... args) -> int
Definition: printf.h:631
datatype_conversion.h
SignalHandler
Definition: signal_handler.h:14
version_config.h
Agora project version configuration file.
Config::NumChannels
size_t NumChannels() const
Definition: config.h:98
Config::OfdmTxZeroPrefix
size_t OfdmTxZeroPrefix() const
Definition: config.h:211
GetAgoraProjectVersion
const std::string & GetAgoraProjectVersion()
Definition: version_config.h:10
Receiver::Receiver
Receiver(Config *cfg, size_t rx_thread_num=1, size_t core_offset=1)
Definition: receiver.cc:10
AGORA_LOG_INIT
#define AGORA_LOG_INIT()
Definition: logger.h:35
main
int main(int argc, char const *argv[])
Definition: main.cc:7
kTxFilename
static const std::string kTxFilename
Definition: main.cc:20
SignalHandler::GotExitSignal
static bool GotExitSignal()
Definition: signal_handler.cc:23
Config::BsAntNum
size_t BsAntNum() const
Definition: config.h:35
Packet::ant_id_
uint32_t ant_id_
Definition: message.h:171
ThreadType::kMasterTX
@ kMasterTX
network_utils.h
Helper definations for networking.
Receiver::StartRecv
std::vector< std::thread > StartRecv(Table< char > &in_buffer, size_t in_buffer_length, Table< double > &in_frame_start)
Definition: receiver.cc:21
AGORA_LOG_ERROR
#define AGORA_LOG_ERROR(...)
Definition: logger.h:39
TOSTRING
#define TOSTRING(x)
Definition: symbols.h:14
signal_handler.h
Direction::kUplink
@ kUplink
CheckCorrectnessUl
static unsigned int CheckCorrectnessUl(Config const *const cfg)
Definition: main.cc:57
Config::Frame
const FrameStats & Frame() const
Definition: config.h:340
Catch::cerr
std::ostream & cerr()
kDebugPrintDlCorr
static const bool kDebugPrintDlCorr
Definition: main.cc:10
AGORA_LOG_TRACE
#define AGORA_LOG_TRACE(...)
Definition: logger.h:92
rx_tag_t
Definition: message.h:227
RxPacket::Use
void Use()
Definition: message.h:215
Receiver::message_queue_
moodycamel::ConcurrentQueue< EventData > * message_queue_
Definition: receiver.h:69
Table
Definition: memory_manage.h:28
Receiver::~Receiver
~Receiver()=default
Receiver
Definition: receiver.h:27
radio_lib.h
Declaration file for the RadioConfig class.
filename
filename
Definition: parse_all_dl.m:14
Config::UeNum
size_t UeNum() const
Definition: config.h:40
Config::OfdmDataNum
size_t OfdmDataNum() const
Definition: config.h:47
kInputFileDirectory
static const std::string kInputFileDirectory
Definition: main.cc:12
ThreadType::kWorkerRX
@ kWorkerRX
EventData
Definition: message.h:142
Config::BsRruPort
int BsRruPort() const
Definition: config.h:305
ReadFromFileUl
static void ReadFromFileUl(const std::string &filename, Table< uint8_t > &data, int num_bytes_per_ue, Config const *const cfg)
Definition: main.cc:45
Radio::RadioType
RadioType
Definition: radio.h:17
message.h
Self defined functions for message storage and passing.
Table::Free
void Free()
Definition: memory_manage.h:84
TestUeRadioRx
static void TestUeRadioRx(Config *cfg, const uint32_t max_rx, Radio::RadioType type)
Definition: main.cc:227
Config::BsServerPort
int BsServerPort() const
Definition: config.h:304
Receiver::frame_start_
Table< double > * frame_start_
Definition: receiver.h:68
FrameStats::ClientUlPilotSymbols
size_t ClientUlPilotSymbols() const
Definition: framestats.h:73
i
for i
Definition: generate_data.m:107
Config::OfdmCaNum
size_t OfdmCaNum() const
Definition: config.h:45
moodycamel::ConcurrentQueue::enqueue
bool enqueue(T const &item)
Definition: concurrentqueue.h:974
TxRxWorkerRx::RxStatusTracker
Definition: rx_status_tracker.h:17
Catch::cout
std::ostream & cout()
comms-lib.h
Communications Library: a) Generate pilot/preamble sequences b) OFDM modulation.
Config::BsServerAddr
std::string BsServerAddr() const
Definition: config.h:299
Agora_memory::Alignment_t::kAlign64
@ kAlign64
CheckCorrectnessDl
unsigned int CheckCorrectnessDl(Config const *const cfg)
Definition: main.cc:113
Packet
Definition: message.h:164
EventType::kPacketRX
@ kPacketRX
kUseArgos
static constexpr bool kUseArgos
Definition: symbols.h:156
Packet::symbol_id_
uint32_t symbol_id_
Definition: message.h:169
CheckCorrectness
static unsigned int CheckCorrectness(Config const *const cfg)
Definition: main.cc:169
symbols.h
CommsLib::FindBeaconAvx
static int FindBeaconAvx(const std::vector< std::complex< float >> &iq, const std::vector< std::complex< float >> &seq, float corr_scale=1.f)
Correlation and Peak detection of a beacon with Gold code (2 repetitions)
Definition: comms-lib-avx.cc:46
Receiver::rx_thread_num_
size_t rx_thread_num_
Definition: receiver.h:66
ue_num
for ue_num
Definition: parse_all_dl.m:84
Config::LdpcConfig
const LDPCconfig & LdpcConfig(Direction dir) const
Definition: config.h:280
ReadFromFileDl
static void ReadFromFileDl(const std::string &filename, Table< short > &data, int ofdm_size, Config const *const cfg)
Definition: main.cc:51
kIsWorkerTimingEnabled
static constexpr bool kIsWorkerTimingEnabled
Definition: symbols.h:303
RxPacket::RawPacket
Packet * RawPacket()
Definition: message.h:213
FrameStats::NumDLSyms
size_t NumDLSyms() const
Definition: framestats.cc:83
moodycamel::ConcurrentQueue< EventData >
extract_version.data
dictionary data
Definition: extract_version.py:8
kDlCheckFilePrefix
static const std::string kDlCheckFilePrefix
Definition: main.cc:18
Receiver::cfg_
Config * cfg_
Definition: receiver.h:72
agora_comm::ListLocalInterfaces
int ListLocalInterfaces()
Definition: network_utils.cc:28
Radio::kSoapySdrStream
@ kSoapySdrStream
Definition: radio.h:17
user_gui.ue
ue
Definition: user_gui.py:117
GetTime::GetTime
static double GetTime()
Definition: gettime.h:22
FrameStats::NumULSyms
size_t NumULSyms() const
Definition: framestats.cc:85
frame_start
frame_start
Definition: parse_dl_file.m:6
Config::HwFramer
bool HwFramer() const
Definition: config.h:53
Config::NumUeChannels
size_t NumUeChannels() const
Definition: config.h:99
Config
Definition: config.h:26
AGORA_LOG_INFO
#define AGORA_LOG_INFO(...)
Definition: logger.h:62
SyncBeacon
ssize_t SyncBeacon(const std::complex< int16_t > *samples, size_t detect_window, const Config *cfg)
Definition: main.cc:378
simulator.h
Declaration file for the simulator class.
Radio::kSoapySdrSocket
@ kSoapySdrSocket
Definition: radio.h:17
RtAssert
static void RtAssert(bool condition, const char *throw_str)
Definition: utils.h:104
tx_data
end Generate data if GENERATE_DATA tx_data
Definition: generate_data.m:38
AGORA_LOG_SHUTDOWN
#define AGORA_LOG_SHUTDOWN()
Definition: logger.h:36
receiver.h
Declaration file for the receiver class.
rx_status_tracker.h
Implementation of RxStatusTracker helper class.
Receiver::buffers_per_thread_
size_t buffers_per_thread_
Definition: receiver.h:64
AGORA_LOG_WARN
#define AGORA_LOG_WARN(...)
Definition: logger.h:53
Receiver::LoopRecv
void * LoopRecv(size_t tid)
Definition: receiver.cc:45
Config::BeaconLen
size_t BeaconLen() const
Definition: config.h:103
LDPCconfig::NumCbLen
uint32_t NumCbLen() const
Definition: ldpc_config.h:50
to_string
std::string to_string() const
Definition: eth_common.h:64
Config::UeHwFramer
bool UeHwFramer() const
Definition: config.h:54
PrintCoreAssignmentSummary
void PrintCoreAssignmentSummary()
Definition: utils.cc:85
TestBsRadioRx
static void TestBsRadioRx(Config *cfg, const uint32_t max_rx, Radio::RadioType type)
Definition: main.cc:72
RxPacket
Definition: message.h:186
config.h
Declaration file for the configuration class which importants json configuration values into class va...
Receiver::rx_packets_
std::vector< std::vector< RxPacket > > rx_packets_
Definition: receiver.h:63
gettime.h
Config::GoldCf32
const std::vector< std::complex< float > > & GoldCf32() const
Definition: config.h:344
kDebugPrintUlCorr
static const bool kDebugPrintUlCorr
Definition: main.cc:9
SignalHandler::SetupSignalHandlers
void SetupSignalHandlers()
Definition: signal_handler.cc:44
Config::PacketLength
size_t PacketLength() const
Definition: config.h:238
kUlCheckFilePrefix
static const std::string kUlCheckFilePrefix
Definition: main.cc:14
kShrtFltConvFactor
static constexpr float kShrtFltConvFactor
Definition: datatype_conversion.h:18
agora.h
Declaration file for the main agora class.
SignalException
Definition: signal_handler.h:8
Config::NumRadios
size_t NumRadios() const
Definition: config.h:95
DEFINE_string
DEFINE_string(conf_file, TOSTRING(PROJECT_DIRECTORY) "/files/config/ci/tddconfig-sim-both.json", "Config filename")
LDPCconfig::NumBlocksInSymbol
void NumBlocksInSymbol(size_t num_blocks)
Definition: ldpc_config.h:41
client_radio.h
Declaration file for the client radio config class.
DEFINE_uint32
DEFINE_uint32(rx_symbols, 10, "The number of symbols to receive before the program terminates")
concurrentqueue.h
kDecodedFilename
static const std::string kDecodedFilename
Definition: main.cc:16
Config::BsRruAddr
std::string BsRruAddr() const
Definition: config.h:302
RxPacket::Empty
bool Empty() const
Definition: message.h:214
fmt::v8::detail::type
type
Definition: core.h:1131