Skip to content

Commit

Permalink
September 15 18:23 hours
Browse files Browse the repository at this point in the history
  • Loading branch information
Your Name committed Sep 15, 2015
1 parent 6e59b67 commit eaa6a84
Show file tree
Hide file tree
Showing 8 changed files with 27 additions and 12 deletions.
6 changes: 4 additions & 2 deletions client.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -53,15 +53,17 @@ 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;
client_sock_addr.sin_addr.s_addr = INADDR_ANY;
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;
Expand Down
3 changes: 2 additions & 1 deletion enodeb.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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++;
Expand Down
8 changes: 6 additions & 2 deletions mme.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
}

Expand Down
4 changes: 3 additions & 1 deletion notes.txt
Original file line number Diff line number Diff line change
Expand Up @@ -24,14 +24,16 @@ 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:

- Number of sockets that can be opened simultaneously is 1021. Important thing is that this number(1021) might be fixed for a particular time, because other processes might increase the number of file descriptors at a later time, but I am not sure about this and I think this number should pretty much work fine.
- 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:
Expand Down
1 change: 1 addition & 0 deletions sgw_server.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
9 changes: 7 additions & 2 deletions sgwc.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down Expand Up @@ -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();
Expand Down Expand Up @@ -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) {
Expand All @@ -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) {
Expand All @@ -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) {
Expand Down Expand Up @@ -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);
Expand All @@ -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() {
Expand Down
3 changes: 2 additions & 1 deletion sgwu.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand All @@ -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();

Expand Down
5 changes: 2 additions & 3 deletions ue.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down Expand Up @@ -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();
Expand Down

0 comments on commit eaa6a84

Please sign in to comment.