diff --git a/client.cpp b/client.cpp index 00cc888..4ce2e9e 100644 --- a/client.cpp +++ b/client.cpp @@ -53,7 +53,8 @@ void Client::bind_client() { client_socket = socket(AF_INET, SOCK_DGRAM, IPPROTO_UDP); report_error(client_socket, "Error in creating sockets "); - setsockopt(client_socket, SOL_SOCKET, SO_REUSEADDR, &g_reuse, sizeof(int)); + status = setsockopt(client_socket, SOL_SOCKET, SO_REUSEADDR, &g_reuse, sizeof(int)); + report_error(status, "At Client side - Error in setting socket options"); socklen_t len = sizeof(sockaddr_in); bzero((char *) &client_sock_addr, sizeof(client_sock_addr)); client_sock_addr.sin_family = AF_INET; @@ -61,7 +62,8 @@ void Client::bind_client() { client_sock_addr.sin_port = 0; status = bind(client_socket, (struct sockaddr*)&client_sock_addr, sizeof(client_sock_addr)); report_error(status, "Error in binding"); - getsockname(client_socket, (struct sockaddr*)&client_sock_addr, &len); + status = getsockname(client_socket, (struct sockaddr*)&client_sock_addr, &len); + report_error(status, "At Client side - Error in getting socket name"); client_port = ntohs(client_sock_addr.sin_port); strcpy(client_addr, inet_ntoa(client_sock_addr.sin_addr)); //cout << "client binded with port " << client_port << endl; diff --git a/enodeb.cpp b/enodeb.cpp index 304ed2d..18e59f2 100644 --- a/enodeb.cpp +++ b/enodeb.cpp @@ -152,6 +152,7 @@ void EnodeB::set_tun_data(bool &data_invalid) { data_invalid = false; } else { + cout << "Invalid data received!" << endl; data_invalid = true; } // cout << "Details fetched are: " << "UE IP - " << ue_ip_str << " SGW - port " << tun_data.sgw_port << " SGW addr " << tun_data.sgw_addr << endl; @@ -162,7 +163,7 @@ void EnodeB::set_sgw_num() { if (socket_table.find(tun_data.sgw_addr) != socket_table.end()) num = socket_table[tun_data.sgw_addr]; else { - cout << "At Enodeb: Trying to connect with a new SGW" << endl; + cout << "At Enodeb: Trying to connect with a new SGW" << endl; connect_with_sgw(); socket_table[tun_data.sgw_addr] = pos; pos++; diff --git a/mme.cpp b/mme.cpp index b00e69d..829de22 100644 --- a/mme.cpp +++ b/mme.cpp @@ -193,8 +193,12 @@ void MME::authenticate_ue() { cout << "Authentication is successful for UE - " << ue_num << endl; } else { - cout << "Authentication failed: Please disconnect and connect again with proper authentication" << endl; - handle_exceptions(); + strcpy(reply, "FAILED"); + mme_server.pkt.clear_data(); + mme_server.pkt.fill_data(0, strlen(reply), reply); + mme_server.pkt.make_data_packet(); + mme_server.write_data(); + cout << "Authentication is not successful for UE - " << ue_num << endl; } } diff --git a/notes.txt b/notes.txt index 304d47b..ce8bf59 100644 --- a/notes.txt +++ b/notes.txt @@ -24,6 +24,8 @@ In the future, I might have to add the following in addition to the "constructor - PGW disconnected for no known reason without printing any error message for Threads = 2 and Time = 3s - SGW disconnected for no known reason without printing any error message for Threads = 2, 20 and Time = 3s - PGW is eratic in responding to SGW's Create Session request and Modify session request. In some cases, SGW is not even able to connect with the PGW for 'Create session request'. +- "ERROR: Invalid argument" at PGW while writing data into the rawsocket +- *** Error in `./pgw': corrupted double-linked list: 0x00007fc7d4080d00 *** Findings/Bugs Solved: @@ -31,7 +33,7 @@ Findings/Bugs Solved: - Changing "ulimit -n 4096" will reduce this problem. I can now create upto 1021 + (4096 - 1024) = 4093 connections! - Finding the CPU utilization for a particular process using "top" command: -top -p $(pgrep process_name | tr \\n , | sed 's/,//') +top -p $(pgrep pgw | tr \\n , | sed 's/,//') Things to do: diff --git a/sgw_server.cpp b/sgw_server.cpp index e622d2f..52d461a 100644 --- a/sgw_server.cpp +++ b/sgw_server.cpp @@ -98,5 +98,6 @@ int main(int argc, char *argv[]) { sgw_server.fill_server_details(g_sgw1_port, g_sgw1_addr); sgw_server.bind_server(); sgw_server.listen_accept(); + cout << "Oops! Comes here" << endl; return 0; } diff --git a/sgwc.cpp b/sgwc.cpp index 8089b86..87d8d56 100644 --- a/sgwc.cpp +++ b/sgwc.cpp @@ -96,6 +96,7 @@ void SGWc::create_session_req_from_mme(Server &sgw_server) { set_ue_num(); set_bearer_id(); set_cteid(); + cout << "Create session request has been received at SGW for UE - " << ue_num << endl; } void SGWc::copy_data(Packet &arg) { @@ -162,7 +163,7 @@ void SGWc::handshake_with_pgw() { void SGWc::create_session_res_from_pgw(uint16_t &pgw_uteid) { - cout << "Waiting to read Create session response from PGW" << endl; + cout << "Waiting to read Create session response from PGW for UE - " << ue_num << endl; to_pgw.read_data(); to_pgw.pkt.rem_gtpc_hdr(); set_tun_cdata(); @@ -193,6 +194,7 @@ void SGWc::create_session_res_to_mme(Server &sgw_server) { sgw_server.pkt.add_gtpc_hdr(); sgw_server.pkt.make_data_packet(); sgw_server.write_data(); + cout << "Create session response has been sent to MME for UE - " << ue_num << endl; } void SGWc::modify_session_req_from_mme(Server &sgw_server, uint16_t &enodeb_uteid) { @@ -201,6 +203,7 @@ void SGWc::modify_session_req_from_mme(Server &sgw_server, uint16_t &enodeb_utei sgw_server.pkt.rem_gtpc_hdr(); copy_data(sgw_server.pkt); memcpy(&enodeb_uteid, pkt.data, sizeof(uint16_t)); + cout << "Modify session request has been received at SGW for UE - " << ue_num << endl; } void SGWc::modify_session_res_to_mme(Server &sgw_server, uint16_t &sgw_uteid) { @@ -214,6 +217,7 @@ void SGWc::modify_session_res_to_mme(Server &sgw_server, uint16_t &sgw_uteid) { sgw_server.pkt.add_gtpc_hdr(); sgw_server.pkt.make_data_packet(); sgw_server.write_data(); + cout << "Modify session response has been sent to MME for UE - " << ue_num << endl; } void SGWc::fill_pgw_addr(int &pgw_port, string &pgw_addr) { @@ -262,7 +266,7 @@ void SGWc::erase_bearer_table() { void SGWc::delete_session_res_from_pgw() { string res; - cout << "Waiting to read Delete session response from PGW" << endl; + cout << "Waiting to read Delete session response from PGW for UE - " << ue_num << endl; to_pgw.read_data(); to_pgw.pkt.rem_gtpc_hdr(); memcpy(reply, to_pgw.pkt.data, to_pgw.pkt.data_len); @@ -283,6 +287,7 @@ void SGWc::delete_session_res_to_mme(Server &sgw_server) { sgw_server.pkt.make_data_packet(); sgw_server.write_data(); erase_tun_ctable(); + cout << "Delete session response has been sent to MME for UE - " << ue_num << endl; } void SGWc::erase_tun_ctable() { diff --git a/sgwu.cpp b/sgwu.cpp index 2970216..7273130 100644 --- a/sgwu.cpp +++ b/sgwu.cpp @@ -168,7 +168,7 @@ void SGWu::send_enodeb(Server &sgw_server) { sgw_server.pkt.fill_data(0, pkt.data_len, pkt.data); sgw_server.pkt.make_data_packet(); sgw_server.write_data(); - // cout << "Sent data to the Enodeb successfully" << endl << endl; + cout << "Sent data to Enodeb" << endl << endl; } void SGWu::recv_pgw(int &pgw_num) { @@ -179,6 +179,7 @@ void SGWu::recv_pgw(int &pgw_num) { to_pgw[pgw_num].read_data(); + cout << "Received data from PGW" << endl; copy_data(to_pgw[pgw_num].pkt); pkt.rem_gtpu_hdr(); diff --git a/ue.cpp b/ue.cpp index 462b188..bd0a142 100644 --- a/ue.cpp +++ b/ue.cpp @@ -82,8 +82,7 @@ void UE::authenticate(Client &to_mme) { else { cout << "Authentication is not successful for UE - " << num << endl; handle_exceptions(); - } - + } } unsigned long long UE::get_autn_res(unsigned long long autn, unsigned long long rand) { @@ -126,7 +125,7 @@ void UE::send_traffic() { command = "iperf3 -B " + ip_addr_str + " -c " + sink_addr + " -p " + to_string(sink_port) + rate + mtu + time_limit; cout << command << endl; system(command.c_str()); - cout << "IPERF Traffic successfully sent" << endl; + cout << "IPERF Traffic successfully sent for UE - " << num << endl; // generate_data(); // to_sink.fill_client_details(ip_addr); // to_sink.bind_client();