Added configuration option for S1AP SCTP bind port

master
Pedro Alvarez 3 years ago
parent 85d7a851fb
commit aae266e848

@ -86,7 +86,7 @@ protected:
namespace net_utils {
bool sctp_init_client(unique_socket* socket, net_utils::socket_type socktype, const char* bind_addr_str);
bool sctp_init_client(unique_socket* socket, net_utils::socket_type socktype, const char* bind_addr_str, int bind_port);
bool sctp_init_server(unique_socket* socket, net_utils::socket_type socktype, const char* bind_addr_str, int port);
} // namespace net_utils

@ -28,6 +28,7 @@ struct s1ap_args_t {
std::string gtp_bind_addr;
std::string gtp_advertise_addr;
std::string s1c_bind_addr;
uint16_t s1c_bind_port;
std::string enb_name;
};

@ -309,9 +309,9 @@ bool sctp_init_socket(unique_socket* socket, net_utils::socket_type socktype, co
return true;
}
bool sctp_init_client(unique_socket* socket, net_utils::socket_type socktype, const char* bind_addr_str)
bool sctp_init_client(unique_socket* socket, net_utils::socket_type socktype, const char* bind_addr_str, int bind_port)
{
return sctp_init_socket(socket, socktype, bind_addr_str, 0);
return sctp_init_socket(socket, socktype, bind_addr_str, bind_port);
}
bool sctp_init_server(unique_socket* socket, net_utils::socket_type socktype, const char* bind_addr_str, int port)

@ -55,8 +55,8 @@ int test_socket_handler()
TESTASSERT(sctp_init_server(&server_socket, socket_type::seqpacket, server_addr, server_port));
logger.info("Listening from fd=%d", server_socket.fd());
TESTASSERT(sctp_init_client(&client_socket, socket_type::seqpacket, "127.0.0.1"));
TESTASSERT(sctp_init_client(&client_socket2, socket_type::seqpacket, "127.0.0.2"));
TESTASSERT(sctp_init_client(&client_socket, socket_type::seqpacket, "127.0.0.1", 0));
TESTASSERT(sctp_init_client(&client_socket2, socket_type::seqpacket, "127.0.0.2", 0));
TESTASSERT(client_socket.connect_to(server_addr, server_port));
TESTASSERT(client_socket2.connect_to(server_addr, server_port));

@ -12,6 +12,7 @@
# gtp_bind_addr: Local IP address to bind for GTP connection
# gtp_advertise_addr: IP address of eNB to advertise for DL GTP-U Traffic
# s1c_bind_addr: Local IP address to bind for S1AP connection
# s1c_bind_port: Source port for S1AP connection (0 means any)
# n_prb: Number of Physical Resource Blocks (6,15,25,50,75,100)
# tm: Transmission mode 1-4 (TM1 default)
# nof_ports: Number of Tx ports (1 port default, set to 2 for TM2/3/4)
@ -24,6 +25,7 @@ mnc = 01
mme_addr = 127.0.1.100
gtp_bind_addr = 127.0.1.1
s1c_bind_addr = 127.0.1.1
s1c_bind_port = 0
n_prb = 50
#tm = 4
#nof_ports = 2

@ -74,6 +74,7 @@ void parse_args(all_args_t* args, int argc, char* argv[])
("enb.gtp_bind_addr", bpo::value<string>(&args->stack.s1ap.gtp_bind_addr)->default_value("192.168.3.1"), "Local IP address to bind for GTP connection")
("enb.gtp_advertise_addr", bpo::value<string>(&args->stack.s1ap.gtp_advertise_addr)->default_value(""), "IP address of eNB to advertise for DL GTP-U Traffic")
("enb.s1c_bind_addr", bpo::value<string>(&args->stack.s1ap.s1c_bind_addr)->default_value("192.168.3.1"), "Local IP address to bind for S1AP connection")
("enb.s1c_bind_port", bpo::value<uint16_t>(&args->stack.s1ap.s1c_bind_port)->default_value(0), "Source port for S1AP connection (0 means any)")
("enb.n_prb", bpo::value<uint32_t>(&args->enb.n_prb)->default_value(25), "Number of PRB")
("enb.nof_ports", bpo::value<uint32_t>(&args->enb.nof_ports)->default_value(1), "Number of ports")
("enb.tm", bpo::value<uint32_t>(&args->enb.transmission_mode)->default_value(1), "Transmission mode (1-8)")

@ -505,7 +505,7 @@ bool ngap::connect_amf()
logger.info("Connecting to AMF %s:%d", args.amf_addr.c_str(), int(AMF_PORT));
// Init SCTP socket and bind it
if (not sctp_init_client(&amf_socket, socket_type::seqpacket, args.ngc_bind_addr.c_str())) {
if (not sctp_init_client(&amf_socket, socket_type::seqpacket, args.ngc_bind_addr.c_str(), 0)) {
return false;
}
logger.info("SCTP socket opened. fd=%d", amf_socket.fd());

@ -476,7 +476,7 @@ bool s1ap::connect_mme()
logger.info("Connecting to MME %s:%d", args.mme_addr.c_str(), int(MME_PORT));
// Init SCTP socket and bind it
if (not sctp_init_client(&mme_socket, socket_type::seqpacket, args.s1c_bind_addr.c_str())) {
if (not sctp_init_client(&mme_socket, socket_type::seqpacket, args.s1c_bind_addr.c_str(), args.s1c_bind_port)) {
return false;
}
logger.info("SCTP socket opened. fd=%d", mme_socket.fd());

Loading…
Cancel
Save