|
|
|
@ -40,6 +40,8 @@ void write_pcap_nr_thread_function(srslte::mac_pcap* pcap_handle, const std::arr
|
|
|
|
|
|
|
|
|
|
int mac_pcap_eutra_test()
|
|
|
|
|
{
|
|
|
|
|
auto& pcap_logger = srslog::fetch_basic_logger("PCAP");
|
|
|
|
|
pcap_logger.info("In mac_pcap_eutra_test");
|
|
|
|
|
std::array<uint8_t, 150> tv = {
|
|
|
|
|
0x21, 0x08, 0x22, 0x80, 0x82, 0x1f, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02,
|
|
|
|
|
0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02,
|
|
|
|
@ -58,16 +60,17 @@ int mac_pcap_eutra_test()
|
|
|
|
|
TESTASSERT(pcap_handle->open("mac_pcap_test.pcap") != SRSLTE_SUCCESS); // open again will fail
|
|
|
|
|
|
|
|
|
|
std::vector<std::thread> writer_threads;
|
|
|
|
|
pcap_logger.info("Start writer_threads");
|
|
|
|
|
|
|
|
|
|
for (uint32_t i = 0; i < num_threads; i++) {
|
|
|
|
|
writer_threads.push_back(std::thread(write_pcap_eutra_thread_function, pcap_handle.get(), tv, num_pdus_per_thread));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
pcap_logger.info("Wait for writer_threads to finish");
|
|
|
|
|
// wait for threads to finish
|
|
|
|
|
for (std::thread& thread : writer_threads) {
|
|
|
|
|
thread.join();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
pcap_logger.info("Close PCAP handle");
|
|
|
|
|
TESTASSERT(pcap_handle->close() == SRSLTE_SUCCESS);
|
|
|
|
|
TESTASSERT(pcap_handle->close() != 0); // closing twice will fail
|
|
|
|
|
|
|
|
|
@ -76,6 +79,8 @@ int mac_pcap_eutra_test()
|
|
|
|
|
|
|
|
|
|
int mac_pcap_nr_test()
|
|
|
|
|
{
|
|
|
|
|
auto& pcap_logger = srslog::fetch_basic_logger("PCAP");
|
|
|
|
|
pcap_logger.info("In mac_pcap_nr_test");
|
|
|
|
|
std::array<uint8_t, 11> tv = {0x42, 0x00, 0x08, 0x11, 0x22, 0x33, 0x44, 0x55, 0x66, 0x77, 0x88};
|
|
|
|
|
|
|
|
|
|
uint32_t num_threads = 10;
|
|
|
|
@ -86,16 +91,19 @@ int mac_pcap_nr_test()
|
|
|
|
|
TESTASSERT(pcap_handle->open("mac_pcap_nr_test.pcap") != SRSLTE_SUCCESS); // open again will fail
|
|
|
|
|
|
|
|
|
|
std::vector<std::thread> writer_threads;
|
|
|
|
|
pcap_logger.info("Start writer_threads");
|
|
|
|
|
|
|
|
|
|
for (uint32_t i = 0; i < num_threads; i++) {
|
|
|
|
|
writer_threads.push_back(std::thread(write_pcap_nr_thread_function, pcap_handle.get(), tv, num_pdus_per_thread));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
pcap_logger.info("Wait for writer_threads to finish");
|
|
|
|
|
// wait for threads to finish
|
|
|
|
|
for (std::thread& thread : writer_threads) {
|
|
|
|
|
thread.join();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
pcap_logger.info("Close PCAP handle");
|
|
|
|
|
TESTASSERT(pcap_handle->close() == SRSLTE_SUCCESS);
|
|
|
|
|
TESTASSERT(pcap_handle->close() != 0); // closing twice will fail
|
|
|
|
|
|
|
|
|
@ -104,6 +112,21 @@ int mac_pcap_nr_test()
|
|
|
|
|
|
|
|
|
|
int main()
|
|
|
|
|
{
|
|
|
|
|
// Start the log backend.
|
|
|
|
|
srslog::init();
|
|
|
|
|
|
|
|
|
|
auto& mac_logger = srslog::fetch_basic_logger("MAC", false);
|
|
|
|
|
mac_logger.set_level(srslog::basic_levels::debug);
|
|
|
|
|
mac_logger.set_hex_dump_max_size(-1);
|
|
|
|
|
|
|
|
|
|
auto& pcap_logger = srslog::fetch_basic_logger("PCAP", false);
|
|
|
|
|
pcap_logger.set_level(srslog::basic_levels::debug);
|
|
|
|
|
pcap_logger.set_hex_dump_max_size(-1);
|
|
|
|
|
|
|
|
|
|
pcap_logger.info("Start mac_pcap_eutra_test");
|
|
|
|
|
TESTASSERT(mac_pcap_eutra_test() == SRSLTE_SUCCESS);
|
|
|
|
|
pcap_logger.info("Start mac_pcap_nr_test");
|
|
|
|
|
TESTASSERT(mac_pcap_nr_test() == SRSLTE_SUCCESS);
|
|
|
|
|
|
|
|
|
|
srslog::flush();
|
|
|
|
|
}
|
|
|
|
|