NS_Emulation: support multiple instances at the same time
The NS_Emulation has configuration values hardcoded or bound to module parameters which prevents multiple instances. Replace the module parameter based configuration with configuration given when starting the NS_Emaulation. Change-Id: I9128f9ad5c372779c38799269393137ba52576cd
This commit is contained in:
parent
f4ac4cea51
commit
2c12b24a47
|
@ -72,7 +72,8 @@ module NS_Emulation {
|
|||
out NsUnitdataRequest;
|
||||
} with { extension "internal" };
|
||||
|
||||
function NSStart() runs on NS_CT {
|
||||
function NSStart(NSConfiguration init_config) runs on NS_CT {
|
||||
config := init_config;
|
||||
f_init();
|
||||
f_ScanEvents();
|
||||
}
|
||||
|
@ -80,7 +81,7 @@ module NS_Emulation {
|
|||
private function f_init() runs on NS_CT {
|
||||
var Result res;
|
||||
/* Connect the UDP socket */
|
||||
res := f_IPL4_connect(NSCP, mp_remote_ip, mp_remote_udp_port, mp_local_ip, mp_local_udp_port, 0, { udp := {}});
|
||||
res := f_IPL4_connect(NSCP, config.remote_ip, config.remote_udp_port, config.local_ip, config.local_udp_port, 0, { udp := {}});
|
||||
if (not ispresent(res.connId)) {
|
||||
setverdict(fail, "Could not connect NS UDP socket, check your configuration");
|
||||
mtc.stop;
|
||||
|
@ -97,6 +98,8 @@ module NS_Emulation {
|
|||
/* NS-User SAP towards the user */
|
||||
port NS_SP_PT NS_SP;
|
||||
|
||||
var NSConfiguration config;
|
||||
|
||||
var NseState g_state := NSE_S_DEAD_BLOCKED;
|
||||
var ConnectionId g_conn_id := -1;
|
||||
|
||||
|
@ -105,24 +108,24 @@ module NS_Emulation {
|
|||
timer Tns_block := 10.0;
|
||||
}
|
||||
|
||||
modulepar {
|
||||
PortNumber mp_local_udp_port := 23000;
|
||||
charstring mp_local_ip := "127.0.0.1";
|
||||
PortNumber mp_remote_udp_port := 21000;
|
||||
charstring mp_remote_ip := "127.0.0.1";
|
||||
Nsvci mp_nsvci := 0;
|
||||
Nsvci mp_nsei := 2342;
|
||||
};
|
||||
type record NSConfiguration {
|
||||
PortNumber local_udp_port,
|
||||
charstring local_ip,
|
||||
PortNumber remote_udp_port,
|
||||
charstring remote_ip,
|
||||
Nsvci nsvci,
|
||||
Nsvci nsei
|
||||
}
|
||||
|
||||
private function f_change_state(NseState new_state) runs on NS_CT {
|
||||
var NseState old_state := g_state;
|
||||
g_state := new_state;
|
||||
log("NS State Transition: ", old_state, " -> ", new_state);
|
||||
NS_SP.send(t_NsStsInd(mp_nsei, mp_nsvci, old_state, new_state));
|
||||
NS_SP.send(t_NsStsInd(config.nsei, config.nsvci, old_state, new_state));
|
||||
}
|
||||
|
||||
private function f_sendReset() runs on NS_CT {
|
||||
NSCP.send(t_NS_Send(g_conn_id, t_NS_RESET(NS_CAUSE_OM_INTERVENTION, mp_nsvci, mp_nsei)));
|
||||
NSCP.send(t_NS_Send(g_conn_id, t_NS_RESET(NS_CAUSE_OM_INTERVENTION, config.nsvci, config.nsei)));
|
||||
g_state := NSE_S_WAIT_RESET;
|
||||
}
|
||||
|
||||
|
@ -137,7 +140,7 @@ module NS_Emulation {
|
|||
}
|
||||
|
||||
private function f_sendBlock(NsCause cause) runs on NS_CT {
|
||||
NSCP.send(t_NS_Send(g_conn_id, t_NS_BLOCK(cause, mp_nsvci)));
|
||||
NSCP.send(t_NS_Send(g_conn_id, t_NS_BLOCK(cause, config.nsvci)));
|
||||
Tns_block.start;
|
||||
}
|
||||
|
||||
|
@ -176,9 +179,9 @@ module NS_Emulation {
|
|||
}
|
||||
|
||||
/* Respond to RESET with correct NSEI/NSVCI */
|
||||
[] NSCP.receive(t_NS_RecvFrom(t_NS_RESET(?, mp_nsvci, mp_nsei))) -> value rf {
|
||||
[] NSCP.receive(t_NS_RecvFrom(t_NS_RESET(?, config.nsvci, config.nsei))) -> value rf {
|
||||
f_change_state(NSE_S_ALIVE_BLOCKED);
|
||||
NSCP.send(t_NS_Send(g_conn_id, t_NS_RESET_ACK(mp_nsvci, mp_nsei)));
|
||||
NSCP.send(t_NS_Send(g_conn_id, t_NS_RESET_ACK(config.nsvci, config.nsei)));
|
||||
}
|
||||
|
||||
/* Respond to RESET with wrong NSEI/NSVCI */
|
||||
|
@ -210,7 +213,7 @@ module NS_Emulation {
|
|||
}
|
||||
} else if (g_state == NSE_S_WAIT_RESET) {
|
||||
alt {
|
||||
[] NSCP.receive(t_NS_RecvFrom(t_NS_RESET_ACK(mp_nsvci, mp_nsei))) -> value rf {
|
||||
[] NSCP.receive(t_NS_RecvFrom(t_NS_RESET_ACK(config.nsvci, config.nsei))) -> value rf {
|
||||
f_change_state(NSE_S_ALIVE_BLOCKED);
|
||||
f_sendAlive();
|
||||
f_sendUnblock();
|
||||
|
@ -219,8 +222,8 @@ module NS_Emulation {
|
|||
} else if (g_state == NSE_S_ALIVE_BLOCKED) {
|
||||
alt {
|
||||
/* bogus block, just respond with ACK */
|
||||
[] NSCP.receive(t_NS_RecvFrom(t_NS_BLOCK(?, mp_nsvci))) -> value rf {
|
||||
NSCP.send(t_NS_Send(g_conn_id, t_NS_BLOCK_ACK(mp_nsvci)));
|
||||
[] NSCP.receive(t_NS_RecvFrom(t_NS_BLOCK(?, config.nsvci))) -> value rf {
|
||||
NSCP.send(t_NS_Send(g_conn_id, t_NS_BLOCK_ACK(config.nsvci)));
|
||||
}
|
||||
/* Respond to UNBLOCK with UNBLOCK-ACK + change state */
|
||||
[] NSCP.receive(t_NS_RecvFrom(t_NS_UNBLOCK)) -> value rf {
|
||||
|
@ -244,26 +247,26 @@ module NS_Emulation {
|
|||
NSCP.send(t_NS_Send(g_conn_id, t_NS_UNBLOCK_ACK));
|
||||
}
|
||||
/* Respond to BLOCK with BLOCK-ACK + change state */
|
||||
[] NSCP.receive(t_NS_RecvFrom(t_NS_BLOCK(?, mp_nsvci))) -> value rf {
|
||||
NSCP.send(t_NS_Send(g_conn_id, t_NS_BLOCK_ACK(mp_nsvci)));
|
||||
[] NSCP.receive(t_NS_RecvFrom(t_NS_BLOCK(?, config.nsvci))) -> value rf {
|
||||
NSCP.send(t_NS_Send(g_conn_id, t_NS_BLOCK_ACK(config.nsvci)));
|
||||
Tns_block.stop;
|
||||
f_change_state(NSE_S_ALIVE_BLOCKED);
|
||||
}
|
||||
[] NSCP.receive(t_NS_RecvFrom(t_NS_BLOCK_ACK(mp_nsvci))) -> value rf {
|
||||
[] NSCP.receive(t_NS_RecvFrom(t_NS_BLOCK_ACK(config.nsvci))) -> value rf {
|
||||
Tns_block.stop;
|
||||
}
|
||||
/* NS-UNITDATA PDU from network to NS-UNITDATA.ind to user */
|
||||
[] NSCP.receive(t_NS_RecvFrom(t_NS_UNITDATA(?, ?, ?))) -> value rf {
|
||||
NS_SP.send(t_NsUdInd(mp_nsei,
|
||||
NS_SP.send(t_NsUdInd(config.nsei,
|
||||
oct2int(rf.msg.pDU_NS_Unitdata.bVCI),
|
||||
rf.msg.pDU_NS_Unitdata.nS_SDU));
|
||||
}
|
||||
/* NS-UNITDATA.req from user to NS-UNITDATA PDU on network */
|
||||
[] NS_SP.receive(t_NsUdReq(mp_nsei, ?, ?, omit)) -> value ud_req {
|
||||
[] NS_SP.receive(t_NsUdReq(config.nsei, ?, ?, omit)) -> value ud_req {
|
||||
/* using raw octetstring PDU */
|
||||
NSCP.send(t_NS_Send(g_conn_id, t_NS_UNITDATA(t_SduCtrlB, ud_req.bvci, ud_req.sdu)));
|
||||
}
|
||||
[] NS_SP.receive(t_NsUdReq(mp_nsei, ?, omit, ?)) -> value ud_req {
|
||||
[] NS_SP.receive(t_NsUdReq(config.nsei, ?, omit, ?)) -> value ud_req {
|
||||
/* using decoded BSSGP PDU that we need to encode first */
|
||||
var octetstring enc := enc_PDU_BSSGP(ud_req.bssgp);
|
||||
NSCP.send(t_NS_Send(g_conn_id, t_NS_UNITDATA(t_SduCtrlB, ud_req.bvci, enc)));
|
||||
|
|
|
@ -11,12 +11,15 @@ ConsoleMask := ERROR | WARNING | TESTCASE | TIMEROP_START | DEBUG_ENCDEC
|
|||
#mp_local_udp_port := 23000
|
||||
#mp_remote_ip := "192.168.100.196"
|
||||
#mp_remote_udp_port := 21000
|
||||
NS_Emulation.mp_local_ip := "127.0.0.1"
|
||||
NS_Emulation.mp_local_udp_port := 23000
|
||||
NS_Emulation.mp_remote_ip := "127.0.0.1"
|
||||
NS_Emulation.mp_remote_udp_port := 23001
|
||||
NS_Emulation.mp_nsei := 1234
|
||||
NS_Emulation.mp_nsvci := 1234
|
||||
PCU_Tests.mp_nsconfig := {
|
||||
local_ip := "127.0.0.1",
|
||||
local_udp_port := 23000,
|
||||
remote_ip := "127.0.0.1",
|
||||
remote_udp_port := 23001,
|
||||
nsvci := 1234,
|
||||
nsei := 1234
|
||||
}
|
||||
|
||||
PCU_Tests.mp_gb_cfg := {
|
||||
nsei := 1234,
|
||||
bvci := 1234,
|
||||
|
|
|
@ -33,6 +33,15 @@ module PCU_Tests {
|
|||
},
|
||||
sgsn_role := true
|
||||
};
|
||||
|
||||
NSConfiguration mp_nsconfig := {
|
||||
local_udp_port := 23000,
|
||||
local_ip := "127.0.0.1",
|
||||
remote_udp_port := 21000,
|
||||
remote_ip := "127.0.0.1",
|
||||
nsvci := 0,
|
||||
nsei := 2342
|
||||
};
|
||||
}
|
||||
|
||||
type component dummy_CT extends BSSGP_Client_CT {
|
||||
|
@ -66,7 +75,7 @@ module PCU_Tests {
|
|||
connect(bssgp_component:BSCP, ns_component:NS_SP);
|
||||
/* connect lower-end of NS emulation to NS_CODEC_PORT (on top of IPl4) */
|
||||
map(ns_component:NSCP, system:NS_CODEC_PORT);
|
||||
ns_component.start(NSStart());
|
||||
ns_component.start(NSStart(mp_nsconfig));
|
||||
bssgp_component.start(BssgpStart(mp_gb_cfg));
|
||||
|
||||
lapdm_component := lapdm_CT.create;
|
||||
|
|
|
@ -20,12 +20,12 @@ FileMask := LOG_ALL | TTCN_MATCHING;
|
|||
|
||||
|
||||
[MODULE_PARAMETERS]
|
||||
#NS_Emulation.mp_local_ip := "192.168.100.239"
|
||||
NS_Emulation.mp_local_udp_port := 21000
|
||||
#NS_Emulation.mp_remote_ip := "192.168.100.196"
|
||||
NS_Emulation.mp_remote_udp_port := 23000
|
||||
NS_Emulation.mp_nsvci := 97
|
||||
NS_Emulation.mp_nsei := 96
|
||||
SGSN_Tests.mp_nsconfig := {
|
||||
local_udp_port := 21000,
|
||||
remote_udp_port := 23000,
|
||||
nsvci := 97,
|
||||
nsei := 96
|
||||
}
|
||||
Osmocom_VTY_Functions.mp_prompt_prefix := "OsmoSGSN";
|
||||
|
||||
[MAIN_CONTROLLER]
|
||||
|
|
|
@ -43,6 +43,15 @@ modulepar {
|
|||
charstring mp_hlr_ip := "127.0.0.1";
|
||||
integer mp_hlr_port := 4222;
|
||||
charstring mp_ggsn_ip := "127.0.0.2";
|
||||
|
||||
NSConfiguration mp_nsconfig := {
|
||||
local_udp_port := 23000,
|
||||
local_ip := "127.0.0.1",
|
||||
remote_udp_port := 21000,
|
||||
remote_ip := "127.0.0.1",
|
||||
nsvci := 0,
|
||||
nsei := 2342
|
||||
};
|
||||
};
|
||||
|
||||
type record GbInstance {
|
||||
|
@ -106,7 +115,7 @@ private function f_init_gb(inout GbInstance gb, charstring id) runs on test_CT {
|
|||
/* connect lower end of NS emulation to NS codec port (on top of IPL4) */
|
||||
map(gb.vc_NS:NSCP, system:NS_CODEC_PORT);
|
||||
|
||||
gb.vc_NS.start(NSStart());
|
||||
gb.vc_NS.start(NSStart(mp_nsconfig));
|
||||
gb.vc_BSSGP.start(BssgpStart(gb.cfg));
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue