Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

UL/DL Mode, statistic logs, error protection, subtree srsRAN #58

Open
wants to merge 37 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
37 commits
Select commit Hold shift + click to select a range
f7cc6e5
Merge commit 'fbbe32eba09e83750f3e1f0f07a326f918544405' as 'LTESniffe…
Aug 30, 2023
a4a5839
#8 add srsRAN mirror subtree and use local
Aug 30, 2023
cf1444c
#9 fix segault on UL in LTESniffer subtree
Aug 30, 2023
85020b0
#20 add UL and DL mode
bstevens777 Dec 28, 2023
f99dcf0
#27 run default shell script for running code
bstevens777 Dec 28, 2023
b160b64
#20 modified logs w single line using stringstream
bstevens777 Dec 28, 2023
bab9c1b
#27 update share and run scripts
bstevens777 Dec 28, 2023
0d38476
#20 added timestamps, file log tables, code hangs
bstevens777 Dec 29, 2023
0d27d1d
#20 bust file pointer share, commit incorrect
bstevens777 Dec 29, 2023
aeb23f7
#20 issue filewriter not init, need member init
bstevens777 Dec 29, 2023
bda6a25
#20 created vector of file pointers, need init mem
bstevens777 Dec 29, 2023
adfd4d7
#20 all logging working minus rar
bstevens777 Dec 29, 2023
369ee21
#20 all logging working and formatted with mkdir
bstevens777 Dec 29, 2023
787d7e7
#20 fix table file name path conflict
bstevens777 Jan 5, 2024
763d455
#20 big issue not incrementing mcs++,rar sus
bstevens777 Jan 5, 2024
1242971
#20 logging stdout to screen and file
bstevens777 Jan 8, 2024
81f3020
#20 stdout will use tee to file direct
bstevens777 Jan 8, 2024
fb95d68
#20 update dir make, shell runs
bstevens777 Jan 8, 2024
781c471
#20 unbuffer stdout so it prints each line
bstevens777 Jan 8, 2024
7f1b7a5
#20 added control log to see state in grafana
bstevens777 Jan 8, 2024
c7b857f
#20 fix run scripts
bstevens777 Jan 8, 2024
c62a934
#20 fix error on pusch decode sharepointer nullptr
bstevens777 Jan 9, 2024
a8ab6d6
#28 memory errors round #3, ulgrant, clockstr
bstevens777 Jan 9, 2024
6f715b4
#28 better ulgrant check, fix missing piece
bstevens777 Jan 10, 2024
a613a36
#29 mutex rntimanager, having issues...
bstevens777 Jan 10, 2024
49d8d5a
Revert "#29 mutex rntimanager, having issues..."
bstevens777 Jan 10, 2024
3084321
#29 fix lock for MCSTracker, with lockguard
bstevens777 Jan 10, 2024
c294ac5
#29 rntimanager may be iterator issue? +rar issue
bstevens777 Jan 11, 2024
7342de7
#29 rntimanager_map_write_read_lock
bstevens777 Jan 12, 2024
b80f88c
#30 add logs for dropped subframes, uhd error ext
bstevens777 Jan 16, 2024
19c5ec8
#31
chinkey Jan 19, 2024
e8393ad
#31
chinkey Jan 19, 2024
b6c7d7d
#31
chinkey Jan 19, 2024
0bf557b
#31
chinkey Jan 19, 2024
5bb246b
#31
chinkey Jan 19, 2024
b3c0687
#31 clean up code and remove initials
bstevens777 Jan 19, 2024
3eced5d
#31 rm vscode folder
bstevens777 Jan 19, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
/build
/.vscode
71 changes: 0 additions & 71 deletions .vscode/settings.json

This file was deleted.

11 changes: 7 additions & 4 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ message("CMNALIB_LIBRARIES: " ${CMNALIB_LIBRARIES})
# cmnalib also needs glib:

INCLUDE(FindPkgConfig)
pkg_check_modules(GLIB2 REQUIRED glib-2.0)
pkg_check_modules(GLIB2 REQUIRED glib-2.0)

include_directories(${GLIB2_INCLUDE_DIRS})
#link_directories(${GLIB2_LIBRARY_DIRS})
Expand Down Expand Up @@ -176,6 +176,9 @@ else(SRSRAN_FOUND AND NOT FORCE_SUBPROJECT_SRSRAN)
message("Download SRSRAN as a subproject and build it.")

# Download and unpack srsRAN at configure time
file(MAKE_DIRECTORY "${CMAKE_BINARY_DIR}/srsRAN-src")
file(COPY "${CMAKE_SOURCE_DIR}/srsRAN_4G_mirror/" DESTINATION "${CMAKE_BINARY_DIR}/srsRAN-src")

configure_file(external/cmake/srsRAN.CMakeLists.txt.in srsRAN-download/CMakeLists.txt)
execute_process(COMMAND "${CMAKE_COMMAND}" -G "${CMAKE_GENERATOR}" .
WORKING_DIRECTORY "${CMAKE_BINARY_DIR}/srsRAN-download" )
Expand Down Expand Up @@ -272,7 +275,7 @@ if(CMAKE_C_COMPILER_ID MATCHES "GNU" OR CMAKE_C_COMPILER_ID MATCHES "Clang")
message("MARCH - FLAGS: ${GCC_ARCH}")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -march=${GCC_ARCH} -Wall -Wno-comment -Wno-write-strings -Winline -Wno-unused-result -Wformat -Wmissing-field-initializers -Wtype-limits -std=c99 -D_GNU_SOURCE")

find_package(SSE) # evaluation comes later
find_package(SSE) # evaluation comes later

if(${CMAKE_BUILD_TYPE} STREQUAL "Debug")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -ggdb -O0 -DDEBUG_MODE -DBUILD_TYPE_DEBUG")
Expand All @@ -292,7 +295,7 @@ if(CMAKE_C_COMPILER_ID MATCHES "GNU" OR CMAKE_C_COMPILER_ID MATCHES "Clang")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -DFORCE_STANDARD_RATE")
endif (USE_LTE_RATES)

#find_package(SSE) # moved upwards before BUILD_TYPE-specific flags. -> AVX512 detection/test code gets subject of O3 optimization -> reports availability even if not present
#find_package(SSE) # moved upwards before BUILD_TYPE-specific flags. -> AVX512 detection/test code gets subject of O3 optimization -> reports availability even if not present
if (HAVE_AVX2)
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -mfpmath=sse -mavx2 -DLV_HAVE_AVX2 -DLV_HAVE_AVX -DLV_HAVE_SSE")
else (HAVE_AVX2)
Expand Down Expand Up @@ -380,7 +383,7 @@ set(INCLUDE_DIR include) # PATH to usr/local/include for install
########################################################################
include_directories(${PROJECT_BINARY_DIR}/lib/include)
include_directories(${PROJECT_SOURCE_DIR}/lib/include)
include_directories(${PROJECT_SOURCE_DIR}/src) # for cross includes of top-level applications
include_directories(${PROJECT_SOURCE_DIR}/src) # for cross includes of top-level applications
include_directories(${PROJECT_SOURCE_DIR}/lib)
########################################################################
# Add the subdirectories
Expand Down
4 changes: 2 additions & 2 deletions external/cmake/srsRAN.CMakeLists.txt.in
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ project(srsLTE-download NONE)

include(ExternalProject)
ExternalProject_Add(srsRAN
GIT_REPOSITORY https://github.com/ShaoPaoLao/srsRAN2.git
GIT_TAG master
# GIT_REPOSITORY https://github.com/ShaoPaoLao/srsRAN2.git
# GIT_TAG master
# GIT_TAG falcon_v0.1
SOURCE_DIR "${CMAKE_BINARY_DIR}/srsRAN-src"
BINARY_DIR "${CMAKE_BINARY_DIR}/srsRAN-build"
Expand Down
7 changes: 6 additions & 1 deletion lib/include/falcon/util/RNTIManager.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,9 @@

#include "Histogram.h"
#include "Interval.h"
#include <mutex>

#include <map>

// DCI minimum average llr for accepting DCI for blind decoding
//#define DCI_MINIMUM_AVG_LLR_BOUND 0.5 //0.5
Expand Down Expand Up @@ -108,12 +111,14 @@ class RNTIManager {
std::vector<std::vector<Interval> > evergreen;
std::vector<std::vector<Interval> > forbidden;
std::vector<bool> active;
std::list<RNTIActiveSetItem> activeSet;
std::map<u_int16_t,RNTIActiveSetItem> activeSet;
std::vector<uint32_t> lastSeen;
std::vector<uint32_t> assocFormatIdx;
uint32_t timestamp;
uint32_t lifetime;
uint32_t threshold;
uint32_t maxCandidatesPerStepPerFormat;
std::vector<int32_t> remainingCandidates;

std::mutex rnti_mutex;
};
34 changes: 22 additions & 12 deletions lib/src/util/RNTIManager.cc
Original file line number Diff line number Diff line change
Expand Up @@ -215,8 +215,12 @@ uint32_t RNTIManager::getAssociatedFormatIdx(uint16_t rnti) {
}

ActivationReason RNTIManager::getActivationReason(uint16_t rnti) {
for(list<RNTIActiveSetItem>::iterator it = activeSet.begin(); it != activeSet.end(); it++) {
if(it->rnti == rnti) return it->reason;
std::lock_guard<std::mutex> lock(rnti_mutex);
std::map<uint16_t,RNTIActiveSetItem>::const_iterator pos = activeSet.find(rnti);
if (pos == activeSet.end()) {
//handle the error
} else {
return pos->second.reason;
}
return RM_ACT_UNSET;
}
Expand All @@ -225,11 +229,11 @@ vector<rnti_manager_active_set_t> RNTIManager::getActiveSet() {
cleanExpired();
vector<rnti_manager_active_set_t> result(activeSet.size());
uint32_t index = 0;
for(list<RNTIActiveSetItem>::iterator it = activeSet.begin(); it != activeSet.end(); it++) {
result[index].rnti = it->rnti;
result[index].reason = it->reason;
result[index].last_seen = timestamp - lastSeen[it->rnti];
result[index].assoc_format_idx = getAssociatedFormatIdx(it->rnti);
for(map<u_int16_t,RNTIActiveSetItem>::iterator it = activeSet.begin(); it != activeSet.end(); it++) {
result[index].rnti = it->second.rnti;
result[index].reason = it->second.reason;
result[index].last_seen = timestamp - lastSeen[it->second.rnti];
result[index].assoc_format_idx = getAssociatedFormatIdx(it->second.rnti);
result[index].frequency = getFrequency(result[index].rnti, result[index].assoc_format_idx);
if(result[index].assoc_format_idx != 0) {
result[index].frequency += getFrequency(result[index].rnti, 0);
Expand Down Expand Up @@ -377,15 +381,19 @@ uint32_t RNTIManager::getLikelyDlFormatIdx(uint16_t rnti) {
void RNTIManager::activateRNTI(uint16_t rnti, ActivationReason reason) {
if(!active[rnti]) {
active[rnti] = true;
activeSet.push_back(RNTIActiveSetItem(rnti, reason));
std::unique_lock<std::mutex> lock(rnti_mutex);
activeSet.insert({rnti,RNTIActiveSetItem(rnti, reason)});
lock.unlock();
}
}

void RNTIManager::deactivateRNTI(uint16_t rnti) {
if(active[rnti]) {
active[rnti] = false;
assocFormatIdx[rnti] = 0;
activeSet.remove(RNTIActiveSetItem(rnti));
std::unique_lock<std::mutex> lock(rnti_mutex);
activeSet.erase(rnti);
lock.unlock();
}
}

Expand All @@ -400,13 +408,15 @@ bool RNTIManager::isExpired(uint16_t rnti) const {
}

void RNTIManager::cleanExpired() {
list<RNTIActiveSetItem>::iterator it = activeSet.begin();
map<u_int16_t,RNTIActiveSetItem>::iterator it = activeSet.begin();
while(it != activeSet.end()) {
if(isExpired(it->rnti)) {
if(isExpired(it->second.rnti)) {
std::unique_lock<std::mutex> lock(rnti_mutex);
it = activeSet.erase(it);
lock.unlock();
}
else {
++it;
it++;
}
}
}
Expand Down
2 changes: 2 additions & 0 deletions run_default.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
#!/bin/bash
/home/LTESniffer_mirror/build/src/LTESniffer -a addr=192.168.30.2,type=x300,clock_source=external,time_source=external -d -A 2 -W 16 -f 2130e6 -u 1730e6 -C -m 2 -z 3
19 changes: 18 additions & 1 deletion src/LTESniffer.cc
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,22 @@ using namespace std;

int main(int argc, char** argv) {
cout << endl;
cout << "LTESniffer" << endl;
cout << "LTESniffer Start!!!" << endl;
cout << endl;

auto now = std::chrono::system_clock::now();
std::time_t cur_time = std::chrono::system_clock::to_time_t(now);
std::string str_cur_time(std::ctime(&cur_time));
for(std::string::iterator it = str_cur_time.begin(); it != str_cur_time.end(); ++it) {
if (*it == ' '){
*it = '_';
} else if (*it == ':'){
*it = '.';
} else if (*it == '\n'){
*it = '.';
}
}

Args args;
ArgManager::parseArgs(args, argc, argv);

Expand All @@ -29,5 +42,9 @@ int main(int argc, char** argv) {

bool success = SnifferCore.run();

cout << endl;
cout << "LTESniffer End!!!" << endl;
cout << endl;

return success ? EXIT_SUCCESS : EXIT_FAILURE;
}
4 changes: 3 additions & 1 deletion src/include/DL_Sniffer_PDSCH.h
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ class PDSCH_Decoder
public:
PDSCH_Decoder(uint32_t idx,
LTESniffer_pcap_writer *pcapwriter,
std::vector<LTESniffer_stat_writer *> *filewriter_objs,
MCSTracking *mcs_tracking,
RNTIManager& rntiManager,
HARQ *harq,
Expand Down Expand Up @@ -149,7 +150,7 @@ class PDSCH_Decoder
void set_target_rnti(uint16_t rnti) {target_rnti = rnti;}
void set_debug_mode(bool debug) { en_debug = debug;}
void set_api_mode(int api_mode_) { api_mode = api_mode_;}
void print_api_dl(uint32_t tti, uint16_t rnti, int ident, std::string value, int msg);
void print_api_dl(uint32_t tti, uint16_t rnti, int ident, std::string value, int msg, uint32_t ta_rnti);

private:
int api_mode = -1;
Expand All @@ -174,6 +175,7 @@ class PDSCH_Decoder
srsran_pdsch_res_t *pdsch_res;
srsran_pdsch_cfg_t *pdsch_cfg; //buffer
LTESniffer_pcap_writer *pcapwriter;
std::vector<LTESniffer_stat_writer *> *filewriter_objs;
RNTIManager &rntiManager;
int mcs_tracking_mode;
MCSTracking *mcs_tracking;
Expand Down
22 changes: 22 additions & 0 deletions src/include/FileWriter.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
/*
* LTE DL_Snifer BWS addition
*/
#pragma once
#include <mutex>

// Define a new class for creating a new thread of stat
class LTESniffer_stat_writer
{
public:
LTESniffer_stat_writer() {enable_write=false; stat_file = NULL; };
void enable(bool en);
void open(const std::string filename);
void close();
void write_stats(std::string);

private:
std::mutex stat_mutex;
bool enable_write;
FILE *stat_file;
void writer(std::string);
};
16 changes: 15 additions & 1 deletion src/include/LTESniffer_Core.h
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
#include "srsran/common/mac_pcap.h"
#include "Phy.h"
#include "PcapWriter.h"
#include "FileWriter.h"
#include "HARQ.h"
#include <ctime>
#include <iostream>
Expand Down Expand Up @@ -65,6 +66,9 @@ using namespace srsran;
#define UL_SNIFFER_UL_OFFSET_32 32
#define UL_SNIFFER_UL_OFFSET_64 64

void write_file_and_console(std::string mystring, LTESniffer_stat_writer* filewriter_obj);
void cell_print(LTESniffer_stat_writer* filewriter_obj, srsran_cell_t* cell, uint32_t sfn);

typedef struct {
cf_t* ta_temp_buffer;
cf_t ta_last_sample[UL_SNIFFER_UL_MAX_OFFSET];
Expand Down Expand Up @@ -95,7 +99,7 @@ class LTESniffer_Core : public SignalHandler {
void resetDCIConsumer();
void refreshShortcutDiscovery(bool val);
void setRNTIThreshold(int val);
void print_api_header();
void print_api_header(LTESniffer_stat_writer *filewriter_obj);
bool run();
void stop();
private:
Expand All @@ -111,6 +115,16 @@ class LTESniffer_Core : public SignalHandler {
std::mutex harq_map_mutex;
Phy *phy;
LTESniffer_pcap_writer pcapwriter;
FILE * errfile;
//FILE * outfile;
std::vector<LTESniffer_stat_writer *> filewriter_objs;
LTESniffer_stat_writer apiwriter;
LTESniffer_stat_writer dlwriter;
LTESniffer_stat_writer dldciwriter;
LTESniffer_stat_writer ulwriter;
LTESniffer_stat_writer uldciwriter;
LTESniffer_stat_writer rarwriter;
LTESniffer_stat_writer otherwriter;
srsran::mac_pcap mac_pcap;
int mcs_tracking_mode;
MCSTracking mcs_tracking;
Expand Down
Loading