Skip to content

Commit

Permalink
Merge pull request #58 from @bstevens777
Browse files Browse the repository at this point in the history
  • Loading branch information
hdtuanss committed Mar 31, 2024
1 parent 27c21b5 commit 8747c95
Show file tree
Hide file tree
Showing 1,697 changed files with 79 additions and 928,287 deletions.
74 changes: 2 additions & 72 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -1,78 +1,8 @@
{
"files.associations": {
"cctype": "cpp",
"clocale": "cpp",
"cmath": "cpp",
"csignal": "cpp",
"cstdarg": "cpp",
"cstddef": "cpp",
"cstdio": "cpp",
"cstdlib": "cpp",
"cstring": "cpp",
"ctime": "cpp",
"cwchar": "cpp",
"cwctype": "cpp",
"array": "cpp",
"atomic": "cpp",
"strstream": "cpp",
"*.tcc": "cpp",
"bitset": "cpp",
"cfenv": "cpp",
"chrono": "cpp",
"cinttypes": "cpp",
"codecvt": "cpp",
"complex": "cpp",
"condition_variable": "cpp",
"cstdint": "cpp",
"deque": "cpp",
"forward_list": "cpp",
"list": "cpp",
"unordered_map": "cpp",
"unordered_set": "cpp",
"vector": "cpp",
"exception": "cpp",
"algorithm": "cpp",
"functional": "cpp",
"iterator": "cpp",
"map": "cpp",
"memory": "cpp",
"memory_resource": "cpp",
"numeric": "cpp",
"optional": "cpp",
"random": "cpp",
"ratio": "cpp",
"set": "cpp",
"string": "cpp",
"string_view": "cpp",
"system_error": "cpp",
"tuple": "cpp",
"type_traits": "cpp",
"utility": "cpp",
"fstream": "cpp",
"future": "cpp",
"initializer_list": "cpp",
"iomanip": "cpp",
"iosfwd": "cpp",
"iostream": "cpp",
"istream": "cpp",
"limits": "cpp",
"mutex": "cpp",
"new": "cpp",
"ostream": "cpp",
"shared_mutex": "cpp",
"sstream": "cpp",
"stdexcept": "cpp",
"streambuf": "cpp",
"thread": "cpp",
"typeindex": "cpp",
"typeinfo": "cpp",
"bit": "cpp",
"*.ipp": "cpp",
"compare": "cpp",
"concepts": "cpp",
"numbers": "cpp",
"semaphore": "cpp",
"stop_token": "cpp",
"variant": "cpp"
"chrono": "cpp",
"sstream": "cpp"
}
}
4 changes: 2 additions & 2 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -176,8 +176,8 @@ 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")
# 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}" .
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
18 changes: 9 additions & 9 deletions lib/src/util/RNTIManager.cc
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,7 @@ void RNTIManager::addForbidden(uint16_t rntiStart, uint16_t rntiEnd, uint32_t fo
}

void RNTIManager::addCandidate(uint16_t rnti, uint32_t formatIdx) {
std::unique_lock<std::mutex> rntiManagerLock(rntiManagerMutex);
std::unique_lock<std::mutex> rntiManagerLock(rnti_mutex);
histograms[formatIdx].add(rnti);
remainingCandidates[formatIdx]--;
}
Expand Down Expand Up @@ -195,7 +195,7 @@ bool RNTIManager::validate(uint16_t rnti, uint32_t formatIdx) {
bool RNTIManager::validateAndRefresh(uint16_t rnti, uint32_t formatIdx) {
bool result = validate(rnti, formatIdx);
if(result) {
std::unique_lock<std::mutex> rntiManagerLock(rntiManagerMutex);
std::unique_lock<std::mutex> rntiManagerLock(rnti_mutex);
lastSeen[rnti] = timestamp;
rntiManagerLock.unlock();
}
Expand All @@ -204,7 +204,7 @@ bool RNTIManager::validateAndRefresh(uint16_t rnti, uint32_t formatIdx) {

void RNTIManager::activateAndRefresh(uint16_t rnti, uint32_t formatIdx, ActivationReason reason) {
activateRNTI(rnti, reason);
std::unique_lock<std::mutex> rntiManagerLock(rntiManagerMutex);
std::unique_lock<std::mutex> rntiManagerLock(rnti_mutex);
lastSeen[rnti] = timestamp;
assocFormatIdx[rnti] = formatIdx;
rntiManagerLock.unlock();
Expand All @@ -219,7 +219,7 @@ uint32_t RNTIManager::getAssociatedFormatIdx(uint16_t rnti) {
}

ActivationReason RNTIManager::getActivationReason(uint16_t rnti) {
std::lock_guard<std::mutex> lock(rnti_mutex);
// 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
Expand All @@ -230,7 +230,7 @@ ActivationReason RNTIManager::getActivationReason(uint16_t rnti) {
}

vector<rnti_manager_active_set_t> RNTIManager::getActiveSet() {
std::unique_lock<std::mutex> rntiManagerLock(rntiManagerMutex);
// std::unique_lock<std::mutex> rntiManagerLock(rnti_mutex);
cleanExpired();
vector<rnti_manager_active_set_t> result(activeSet.size());
uint32_t index = 0;
Expand Down Expand Up @@ -298,7 +298,7 @@ void RNTIManager::getHistogramSummary(uint32_t *buf)
}

bool RNTIManager::isEvergreen(uint16_t rnti, uint32_t formatIdx) {
std::unique_lock<std::mutex> rntiManagerLock(rntiManagerMutex);
// std::unique_lock<std::mutex> rntiManagerLock(rnti_mutex);
const vector<Interval>& intervals = evergreen[formatIdx];
for(vector<Interval>::const_iterator inter = intervals.begin(); inter != intervals.end(); inter++) {
if(inter->matches(rnti)) return true;
Expand All @@ -307,7 +307,7 @@ bool RNTIManager::isEvergreen(uint16_t rnti, uint32_t formatIdx) {
}

bool RNTIManager::isForbidden(uint16_t rnti, uint32_t formatIdx) {
std::unique_lock<std::mutex> rntiManagerLock(rntiManagerMutex);
// std::unique_lock<std::mutex> rntiManagerLock(rnti_mutex);
const vector<Interval>& intervals = forbidden[formatIdx];
for(vector<Interval>::const_iterator inter = intervals.begin(); inter != intervals.end(); inter++) {
if(inter->matches(rnti)) return true;
Expand All @@ -316,7 +316,7 @@ bool RNTIManager::isForbidden(uint16_t rnti, uint32_t formatIdx) {
}

RMValidationResult_t RNTIManager::validateByActiveList(uint16_t rnti, uint32_t formatIdx) {
std::unique_lock<std::mutex> rntiManagerLock(rntiManagerMutex);
// std::unique_lock<std::mutex> rntiManagerLock(rnti_mutex);
if(active[rnti]) { // active RNTI
if(!isExpired(rnti)) { // lifetime check
return RMV_TRUE;
Expand Down Expand Up @@ -387,7 +387,7 @@ uint32_t RNTIManager::getLikelyDlFormatIdx(uint16_t rnti) {
}

void RNTIManager::activateRNTI(uint16_t rnti, ActivationReason reason) {
std::unique_lock<std::mutex> rntiManagerLock(rntiManagerMutex);
// std::unique_lock<std::mutex> rntiManagerLock(rnti_mutex);
if(!active[rnti]) {
active[rnti] = true;
std::unique_lock<std::mutex> lock(rnti_mutex);
Expand Down
9 changes: 5 additions & 4 deletions src/include/Sniffer_dependency.h
Original file line number Diff line number Diff line change
Expand Up @@ -43,10 +43,10 @@
#define UL_MODE 1
#define DL_UL_MODE 2

#define DEBUG_DCI_PRINT 0 // default not print to screen
#define DEBUG_TABLE_PRINT 1 // default print when no SEC/API
#define DEBUG_SEC_PRINT 1 // default print if active
#define FILE_WRITE 1 // write everything to file
#define DEBUG_DCI_PRINT 0 // default not print to screen
#define DEBUG_TABLE_PRINT 1 // default print when no SEC/API
#define DEBUG_SEC_PRINT 1 // default print if active
#define FILE_WRITE 1 // write everything to file

#define UHD_FAIL_LIMIT 5

Expand All @@ -64,6 +64,7 @@
#define MSG_UE_CAP 4
#define MSG_PAGING 5
#define MSG_RAR 6
#define MSG_CON_RECONFIG 7

struct DCI_BASE {
DCI_BASE();
Expand Down
22 changes: 12 additions & 10 deletions src/src/DL_Sniffer_PDSCH.cc
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ int PDSCH_Decoder::decode_imsi_tmsi_paging(uint8_t *sdu_ptr, int length)
mcs_tracking->increase_nof_api_msg();
ret = SRSRAN_SUCCESS;
}
print_api_dl(dl_sf->tti, 65534, ID_IMSI, imsi_str, MSG_PAGING);
// print_api_dl(dl_sf->tti, 65534, ID_IMSI, imsi_str, MSG_PAGING);
// printf("Found IMSI paging\n");
ret = SRSRAN_SUCCESS;
}
Expand Down Expand Up @@ -318,7 +318,7 @@ int PDSCH_Decoder::run_decode(int &mimo_ret,
std::stringstream ss;
ss << std::hex << std::setw(8) << std::setfill('0') << pdu_info.tmsi;
std::string tmsi_str = ss.str();
print_api_dl(tti, cur_rnti, ID_TMSI, tmsi_str, MSG_CON_RECONFIG);
print_api_dl(tti, cur_rnti, ID_TMSI, tmsi_str, MSG_CON_RECONFIG, -1);
}
}
else
Expand Down Expand Up @@ -393,7 +393,7 @@ int PDSCH_Decoder::decode_ul_mode(uint32_t rnti, std::vector<DL_Sniffer_rar_resu
float ta_min = (float) result.ta * 78.12; // ref: https://howltestuffworks.blogspot.com/2014/07/timing-advance-and-time-alignment-timer.html
float ta_max = (float) (result.ta + 1) * 78.12; // meters multiply by 78 meters for shortcut
// {min}-{max} meters ... TA_RNTI does not change per user, does per carrier?
std:string ta_str = std::to_string((int) ta_min) + " to " + std::to_string((int) ta_max) + " m";
std:string ta_str = std::to_string((int) result.ta) ; // + " to " + std::to_string((int) ta_max) + " m"
if (api_mode == 0 || api_mode == 3){
print_api_dl(dl_sf->tti, result.t_crnti, MSG_RAR, ta_str, MSG_RAR, cur_rnti);
//print_api_dl(dl_sf->tti, cur_rnti, MSG_RAR, ta_str, MSG_RAR);
Expand Down Expand Up @@ -845,7 +845,7 @@ void PDSCH_Decoder::run_api_dl_mode(std::string RNTI_name, uint8_t *pdu, uint32_
std::stringstream ss;
ss << std::hex << std::setw(8) << std::setfill('0') << pdu_info.tmsi;
std::string tmsi_str = ss.str();
print_api_dl(tti, cur_rnti, ID_TMSI, tmsi_str, MSG_CON_RECONFIG);
print_api_dl(tti, cur_rnti, ID_TMSI, tmsi_str, MSG_CON_RECONFIG, -1);
mcs_tracking->increase_nof_api_msg();
}
}else{
Expand All @@ -865,7 +865,7 @@ void PDSCH_Decoder::run_api_dl_mode(std::string RNTI_name, uint8_t *pdu, uint32_
std::string con_res_str = temp_con_res_str.substr(3, 8);
// printf("[API] SF: %d-%d Found RRC Connection Setup, Contention Resolution = %s, RNTI = %d \n",
// tti/10, tti%10, con_res_str.c_str(), cur_rnti);
print_api_dl(tti, cur_rnti, ID_CON_RES, con_res_str, MSG_CON_SET);
print_api_dl(tti, cur_rnti, ID_CON_RES, con_res_str, MSG_CON_SET, -1);
mcs_tracking->increase_nof_api_msg();
found_res = true;
}
Expand Down Expand Up @@ -1073,7 +1073,7 @@ int PDSCH_Decoder::decode_dl_mode()
run_api_dl_mode(RNTI_name, pdsch_res[tb].payload, result_length, cur_rnti, tti, tb);
}
}
if (cur_rnti != 65535 && cur_grant->tb[tb].enabled && (target_rnti == 0 || cur_rnti == target_rnti) && en_debug)
if (cur_rnti != 65535 && cur_grant->tb[tb].enabled && (target_rnti == 0 || cur_rnti == target_rnti) && (en_debug || FILE_WRITE))
{
print_debug_dl(table_name, tti, decoding_mem.rnti, dci_fm, mod, decoding_mem.ran_dci_dl->tb[0].mcs_idx, harq_ret[tb],
nof_tb, result_length, pdsch_res[tb].crc, &falcon_ue_dl->q->chest_res);
Expand Down Expand Up @@ -1340,7 +1340,7 @@ void PDSCH_Decoder::print_debug_dl(std::string name,
msg << std::left << std::setw(8) << RED << "FAILED";
}
msg << RESET << std::endl;
if(DEBUG_DCI_PRINT==1){
if(en_debug){
std::cout << msg.str();
}
if(FILE_WRITE==1){
Expand Down Expand Up @@ -1488,6 +1488,8 @@ std::string convert_msg_name_dl(int msg)
case 6:
ret = "Random Access Response";
break;
case 7:
ret = "RRC Reconfiguration";
default:
ret = "-";
break;
Expand Down Expand Up @@ -1516,9 +1518,9 @@ void PDSCH_Decoder::print_api_dl(uint32_t tti, uint16_t rnti, int id, std::strin
msg_api << std::left << std::setw(11) << rnti;
std::string msg_name = convert_msg_name_dl(msg);
msg_api << std::left << std::setw(25) << msg_name;
if(ta_rnti!=-1){
msg_api << std::left << std::setw(2) << "{" << ta_rnti << "}";
}
// if(ta_rnti!=-1){
// msg_api << std::left << std::setw(2) << "{" << ta_rnti << "}";
// }
msg_api << std::endl;

if(DEBUG_SEC_PRINT==1){
Expand Down
6 changes: 3 additions & 3 deletions src/src/FileWriter.cc
Original file line number Diff line number Diff line change
Expand Up @@ -10,21 +10,21 @@ void LTESniffer_stat_writer::enable(bool en)
}
void LTESniffer_stat_writer::open(const std::string filename)
{
fprintf(stdout, "Opening Statistic file\n");
// fprintf(stdout, "Opening Statistic file\n");
stat_file = fopen(filename.c_str(), "w");
if (stat_file == NULL) {
printf("Failed to open file \"%s\" for writing\n", filename.c_str());
}
enable_write = true;
}

void LTESniffer_stat_writer::close()
void LTESniffer_stat_writer::close() // close the file
{
int err = -1;
if (stat_file) {
err = fclose(stat_file);
}
fprintf(stdout, "Closing Statistic file: success %d \n", err==0);
// fprintf(stdout, "Closing Statistic file: success %d \n", err==0);
}

// public method
Expand Down
Loading

0 comments on commit 8747c95

Please sign in to comment.