From 424ec5211c90aa5472c1249a2bef6b6191447f0b Mon Sep 17 00:00:00 2001 From: Harald Welte Date: Tue, 23 Mar 2021 18:20:12 +0100 Subject: [PATCH] SGSN: Some initial SNS tests for IP-SNS in OsmoSGSN Change-Id: I821d998704756fa30278f41d0371051db9d3fc58 --- library/RAW_NS.ttcnpp | 21 +++++--- pcu/osmo-pcu-sns.cfg | 2 + sgsn/SGSN_Tests_NS.ttcn | 69 +++++++++++++++++++++++++- sgsn/SGSN_Tests_SNS.cfg | 72 +++++++++++++++++++++++++++ sgsn/osmo-sgsn.sns.cfg | 105 ++++++++++++++++++++++++++++++++++++++++ 5 files changed, 261 insertions(+), 8 deletions(-) create mode 100644 sgsn/SGSN_Tests_SNS.cfg create mode 100644 sgsn/osmo-sgsn.sns.cfg diff --git a/library/RAW_NS.ttcnpp b/library/RAW_NS.ttcnpp index 76ac0a274..ff7334860 100644 --- a/library/RAW_NS.ttcnpp +++ b/library/RAW_NS.ttcnpp @@ -34,6 +34,7 @@ public type component RAW_NS_CT { #endif var NSConfiguration g_nsconfig; timer g_T_guard; + var boolean g_handle_rx_alive := false; } public altstep as_Tguard() runs on RAW_NS_CT { @@ -99,6 +100,7 @@ function f_ns_exp(template PDU_NS exp_rx, integer idx := 0) runs on RAW_NS_CT re var default d := activate(ax_rx_fail_on_any_ns()); alt { [] NSCP[idx].receive(PDU_NS: exp_rx) -> value nrf { } + [g_handle_rx_alive] as_rx_alive_tx_ack(); } deactivate(d); return nrf; @@ -109,6 +111,7 @@ function f_outgoing_ns_alive(integer idx := 0) runs on RAW_NS_CT { NSCP[idx].send(t_NS_ALIVE); alt { [] NSCP[idx].receive(t_NS_ALIVE_ACK); + [g_handle_rx_alive] as_rx_alive_tx_ack(); [] NSCP[idx].receive { repeat; } } } @@ -122,6 +125,7 @@ function f_outgoing_ns_alive_no_ack(integer idx := 0, float tout := 10.0) runs o [] NSCP[idx].receive(t_NS_ALIVE_ACK) { setverdict(fail, "Received unexpected NS-ALIVE ACK"); } + [g_handle_rx_alive] as_rx_alive_tx_ack(); [] NSCP[idx].receive { repeat; } [] T.timeout { setverdict(pass); @@ -138,6 +142,7 @@ function f_outgoing_ns_reset(integer idx := 0, float tout := 10.0) runs on RAW_N [] NSCP[idx].receive(ts_NS_RESET_ACK(g_nsconfig.nsvc[idx].nsvci, g_nsconfig.nsei)) { setverdict(pass); } + [g_handle_rx_alive] as_rx_alive_tx_ack(); [] NSCP[idx].receive { repeat; } [] T.timeout { setverdict(fail, "Failed to receive a RESET ACK"); @@ -150,6 +155,7 @@ function f_outgoing_ns_block(NsCause cause, integer idx := 0) runs on RAW_NS_CT NSCP[idx].send(ts_NS_BLOCK(cause, g_nsconfig.nsvc[idx].nsvci)); alt { [] NSCP[idx].receive(tr_NS_BLOCK_ACK(g_nsconfig.nsvc[idx].nsvci)); + [g_handle_rx_alive] as_rx_alive_tx_ack(); [] NSCP[idx].receive { repeat; } } } @@ -159,6 +165,7 @@ function f_outgoing_ns_unblock(integer idx := 0) runs on RAW_NS_CT { NSCP[idx].send(t_NS_UNBLOCK); alt { [] NSCP[idx].receive(t_NS_UNBLOCK_ACK); + [g_handle_rx_alive] as_rx_alive_tx_ack(); [] NSCP[idx].receive { repeat; } } } @@ -198,6 +205,7 @@ runs on RAW_NS_CT { [not exp_ack] T.timeout { setverdict(pass); } + [g_handle_rx_alive] as_rx_alive_tx_ack(); [] NSCP[idx].receive { repeat; } } } @@ -298,22 +306,23 @@ runs on RAW_NS_CT { } /* perform outbound SNS-SIZE procedure */ -function f_outgoing_sns_size(template (omit) NsCause cause := omit, integer idx:= 0) +function f_outgoing_sns_size(template (omit) NsCause cause := omit, integer max_nsvcs := 1, + integer num_ip := 1, integer idx:= 0) runs on RAW_NS_CT { log("f_outgoing_sns_size(idx=", idx, ")"); var PDU_NS rx; var NSVCConfiguration nsvc_cfg := g_nsconfig.nsvc[idx]; if (nsvc_cfg.provider.ip.address_family == AF_INET) { - NSCP[idx].send(ts_SNS_SIZE(g_nsconfig.nsei, rst_flag := true, max_nsvcs := 1, - num_v4 := 1, num_v6 := omit) + NSCP[idx].send(ts_SNS_SIZE(g_nsconfig.nsei, rst_flag := true, max_nsvcs := max_nsvcs, + num_v4 := num_ip, num_v6 := omit) ); } else { - NSCP[idx].send(ts_SNS_SIZE(g_nsconfig.nsei, rst_flag := true, max_nsvcs := 1, - num_v4 := omit, num_v6 := 1) + NSCP[idx].send(ts_SNS_SIZE(g_nsconfig.nsei, rst_flag := true, max_nsvcs := max_nsvcs, + num_v4 := omit, num_v6 := num_ip) ); } - /* expect one single SNS-SIZE with RESET flag; 4x v4 EP; no v6 EP */ + /* expect one single SNS-SIZE */ rx := f_ns_exp(tr_SNS_SIZE_ACK(g_nsconfig.nsei, cause), idx); } diff --git a/pcu/osmo-pcu-sns.cfg b/pcu/osmo-pcu-sns.cfg index a8a26bd06..cfe4ccfe8 100644 --- a/pcu/osmo-pcu-sns.cfg +++ b/pcu/osmo-pcu-sns.cfg @@ -23,3 +23,5 @@ pcu gamma 0 pcu-socket /tmp/pcu_bts gb-dialect ip-sns +ns + timer tns-test 10 diff --git a/sgsn/SGSN_Tests_NS.ttcn b/sgsn/SGSN_Tests_NS.ttcn index dd68b05dc..e5d012f23 100644 --- a/sgsn/SGSN_Tests_NS.ttcn +++ b/sgsn/SGSN_Tests_NS.ttcn @@ -47,9 +47,74 @@ testcase TC_NS_connect_alive() runs on RAW_Test_CT { f_clean_ns_codec(); } +/* perform outgoing SNS-SIZE procedure */ +testcase TC_SNS_size() runs on RAW_Test_CT { + f_init_vty(); + f_init_ns_codec(mp_nsconfig[0], guard_secs := 10.0); + g_handle_rx_alive := true; + + f_outgoing_sns_size(); + setverdict(pass); +} + +/* outgoing SNS-SIZE procedure with more BSS side IPs than SGSN can handle */ +testcase TC_SNS_size_too_big() runs on RAW_Test_CT { + f_init_vty(); + f_init_ns_codec(mp_nsconfig[0], guard_secs := 10.0); + g_handle_rx_alive := true; + + f_outgoing_sns_size(cause := NS_CAUSE_INVALID_NR_OF_NSVCS, num_ip := 100); + setverdict(pass); +} + +/* perform outgoing SNS-CONFIG procedure (for BSS) */ +testcase TC_SNS_config_bss() runs on RAW_Test_CT { + f_init_vty(); + f_init_ns_codec(mp_nsconfig[0], guard_secs := 10.0); + g_handle_rx_alive := true; + + f_outgoing_sns_size(); + f_outgoing_sns_config(); + setverdict(pass); +} + +/* perform incoming SNS-CONFIG procedure (for SGSN) */ +testcase TC_SNS_config_sgsn() runs on RAW_Test_CT { + f_init_vty(); + f_init_ns_codec(mp_nsconfig[0], guard_secs := 10.0); + g_handle_rx_alive := true; + + f_outgoing_sns_size(); + f_outgoing_sns_config(); + f_incoming_sns_config(); + setverdict(pass); +} + +/* perform full SNS handshake and then outbound NS-ALIVE */ +testcase TC_SNS_and_alive() runs on RAW_Test_CT { + f_init_vty(); + f_init_ns_codec(mp_nsconfig[0], guard_secs := 120.0); + g_handle_rx_alive := true; + + f_outgoing_sns_size(); + f_outgoing_sns_config(); + f_incoming_sns_config(); + f_outgoing_ns_alive(); + setverdict(pass); +} + control { - execute( TC_NS_connect_alive() ); - execute( TC_NS_connect_reset() ); + + if (mp_nsconfig[0].handle_sns) { + execute( TC_SNS_size() ); + execute( TC_SNS_size_too_big() ); + execute( TC_SNS_config_bss() ); + execute( TC_SNS_config_sgsn() ); + execute( TC_SNS_and_alive() ); + } else { + execute( TC_NS_connect_alive() ); + execute( TC_NS_connect_reset() ); + } } } diff --git a/sgsn/SGSN_Tests_SNS.cfg b/sgsn/SGSN_Tests_SNS.cfg new file mode 100644 index 000000000..d4dcea095 --- /dev/null +++ b/sgsn/SGSN_Tests_SNS.cfg @@ -0,0 +1,72 @@ +[ORDERED_INCLUDE] +# Common configuration, shared between test suites +"../Common.cfg" +# testsuite specific configuration, not expected to change +"./SGSN_Tests.default" + +# Local configuration below + +[LOGGING] + +[TESTPORT_PARAMETERS] +*.SGSNVTY.CTRL_HOSTNAME := "127.0.0.10" + +[MODULE_PARAMETERS] +SGSN_Tests.mp_nsconfig := { + { + handle_sns := true, + nsvc := { + { + provider := { + ip := { + address_family := AF_INET, + local_ip := "127.0.0.103", + remote_ip := "127.0.0.10" + } + } + } + } + }, + { + handle_sns := true, + nsvc := { + { + provider := { + ip := { + address_family := AF_INET, + local_ip := "127.0.0.103", + remote_ip := "127.0.0.10" + } + } + } + } + }, + { + handle_sns := true, + nsvc := { + { + provider := { + ip := { + address_family := AF_INET, + local_ip := "127.0.0.103", + remote_ip := "127.0.0.10" + } + } + } + } + } +} +SGSN_Tests.mp_ranap_cfg := { + { + sctp_addr := { 23908, "127.0.0.103", 2905, "127.0.0.200" } + } +} +SGSN_Tests.mp_hlr_ip := "127.0.0.103" +SGSN_Tests.mp_ggsn_ip := "127.0.0.103" + +[MAIN_CONTROLLER] + +[EXECUTE] +SGSN_Tests.control +SGSN_Tests_Iu.control +SGSN_Tests_NS.control diff --git a/sgsn/osmo-sgsn.sns.cfg b/sgsn/osmo-sgsn.sns.cfg new file mode 100644 index 000000000..69f514783 --- /dev/null +++ b/sgsn/osmo-sgsn.sns.cfg @@ -0,0 +1,105 @@ +! +! OsmoSGSN (1.2.0.46-e77e-dirty) configuration saved from vty +!! +! +log gsmtap 127.0.0.1 + logging level set-all debug + logging filter all 1 +! +log stderr + logging filter all 1 + logging color 1 + logging print category 1 + logging print category-hex 0 + logging timestamp 1 + logging print extended-timestamp 1 + logging print file 1 + logging level all everything + logging level mm debug + logging level pag notice + logging level meas notice + logging level ref notice + logging level gprs debug + logging level lns debug + logging level lbssgp info + logging level llc debug + logging level sndcp debug + logging level slhc notice + logging level ranap info + logging level sua info + logging level v42bis info + logging level lglobal info + logging level llapd notice + logging level linp notice + logging level lmux notice + logging level lmi notice + logging level lmib notice + logging level lsms notice + logging level lctrl notice + logging level lgtp debug + logging level lstats notice + logging level lgsup debug + logging level loap notice + logging level lss7 notice + logging level lsccp info + logging level lsua notice + logging level lm3ua notice + logging level lmgcp notice +! +stats interval 5 +! +line vty + no login + bind 127.0.0.10 +ctrl + bind 127.0.0.10 +! +cs7 instance 0 + point-code 0.23.4 + asp asp-clnt-OsmoSGSN-A 2905 0 m3ua + remote-ip 127.0.0.200 + as as-clnt-OsmoSGSN-A m3ua + asp asp-clnt-OsmoSGSN-A + routing-key 3 0.23.4 +ns + timer tns-block 3 + timer tns-block-retries 3 + timer tns-reset 3 + timer tns-reset-retries 3 + timer tns-test 30 + timer tns-alive 3 + timer tns-alive-retries 10 + bind udp local10 + listen 127.0.0.10 23000 + accept-dynamic-ip-sns + bind udp local10_1 + listen 127.0.0.10 23001 + ip-sns-default bind local10 + !ip-sns-default bind local10_1 +bssgp +sgsn + gtp local-ip 127.0.0.10 + ggsn 0 remote-ip 127.0.0.103 + ggsn 0 gtp-version 1 + gsup remote-ip 127.0.0.103 + gsup remote-port 4222 + auth-policy remote + gsup oap-id 0 + ! apn * ggsn 0 + no cdr filename + no cdr trap + cdr interval 600 + timer t3312 600 + timer t3322 6 + timer t3350 6 + timer t3360 6 + timer t3370 6 + timer t3313 30 + timer t3314 44 + timer t3316 44 + timer t3385 8 + timer t3386 8 + timer t3395 8 + timer t3397 8 + no compression rfc1144 + no compression v42bis