def test_attach_standalone_act_dflt_ber_ctxt_rej_ded_bearer_activation( self, ): """ Attach + PDN connectivity req + activate default EPS bearer reject for secondary PDN + initiate RAR for the secondary PDN + detach""" self._s1ap_wrapper.configUEDevice(1) req = self._s1ap_wrapper.ue_req # APN of the secondary PDN ims = { "apn_name": "ims", # APN-name "qci": 5, # qci "priority": 15, # priority "pre_cap": 0, # preemption-capability "pre_vul": 0, # preemption-vulnerability "mbr_ul": 200000000, # MBR UL "mbr_dl": 100000000, # MBR DL } # UL Flow description #1 ulFlow1 = { "ipv4_dst": "192.168.129.42", # IPv4 destination address "tcp_dst_port": 5002, # TCP dest port "ip_proto": FlowMatch.IPPROTO_TCP, # Protocol Type "direction": FlowMatch.UPLINK, # Direction } # UL Flow description #2 ulFlow2 = { "ipv4_dst": "192.168.129.42", # IPv4 destination address "tcp_dst_port": 5001, # TCP dest port "ip_proto": FlowMatch.IPPROTO_TCP, # Protocol Type "direction": FlowMatch.UPLINK, # Direction } # UL Flow description #3 ulFlow3 = { "ipv4_dst": "192.168.129.64", # IPv4 destination address "tcp_dst_port": 5003, # TCP dest port "ip_proto": FlowMatch.IPPROTO_TCP, # Protocol Type "direction": FlowMatch.UPLINK, # Direction } # UL Flow description #4 ulFlow4 = { "ipv4_dst": "192.168.129.42", # IPv4 destination address "tcp_dst_port": 5004, # TCP dest port "ip_proto": FlowMatch.IPPROTO_TCP, # Protocol Type "direction": FlowMatch.UPLINK, # Direction } # DL Flow description #1 dlFlow1 = { "ipv4_src": "192.168.129.42", # IPv4 source address "tcp_src_port": 5001, # TCP source port "ip_proto": FlowMatch.IPPROTO_TCP, # Protocol Type "direction": FlowMatch.DOWNLINK, # Direction } # DL Flow description #2 dlFlow2 = { "ipv4_src": "192.168.129.64", # IPv4 source address "tcp_src_port": 5002, # TCP source port "ip_proto": FlowMatch.IPPROTO_TCP, # Protocol Type "direction": FlowMatch.DOWNLINK, # Direction } # DL Flow description #3 dlFlow3 = { "ipv4_src": "192.168.129.64", # IPv4 source address "tcp_src_port": 5003, # TCP source port "ip_proto": FlowMatch.IPPROTO_TCP, # Protocol Type "direction": FlowMatch.DOWNLINK, # Direction } # DL Flow description #4 dlFlow4 = { "ipv4_src": "192.168.129.42", # IPv4 source address "tcp_src_port": 5004, # TCP source port "ip_proto": FlowMatch.IPPROTO_TCP, # Protocol Type "direction": FlowMatch.DOWNLINK, # Direction } # Flow list to be configured flow_list = [ ulFlow1, ulFlow2, ulFlow3, ulFlow4, dlFlow1, dlFlow2, dlFlow3, dlFlow4, ] # QoS qos = { "qci": 1, # qci value [1 to 9] "priority": 15, # Range [0-255] "max_req_bw_ul": 10000000, # MAX bw Uplink "max_req_bw_dl": 15000000, # MAX bw Downlink "gbr_ul": 1000000, # GBR Uplink "gbr_dl": 2000000, # GBR Downlink "arp_prio": 15, # ARP priority "pre_cap": 1, # pre-emption capability "pre_vul": 1, # pre-emption vulnerability } policy_id = "ims-voice" # APN list to be configured apn_list = [ims] self._s1ap_wrapper.configAPN( "IMSI" + "".join([str(i) for i in req.imsi]), apn_list, ) print( "************************* Running End to End attach for UE id ", req.ue_id, ) # Attach attach = self._s1ap_wrapper.s1_util.attach( req.ue_id, s1ap_types.tfwCmd.UE_END_TO_END_ATTACH_REQUEST, s1ap_types.tfwCmd.UE_ATTACH_ACCEPT_IND, s1ap_types.ueAttachAccept_t, ) addr = attach.esmInfo.pAddr.addrInfo default_ip = ipaddress.ip_address(bytes(addr[:4])) # Wait on EMM Information from MME self._s1ap_wrapper._s1_util.receive_emm_info() print("Sleeping for 5 seconds") time.sleep(5) # Verify if flow rules are created # No dedicated bearers, so flow list will be empty dl_flow_rules = { default_ip: [], } # 1 UL flow for the default bearer num_ul_flows = 1 self._s1ap_wrapper.s1_util.verify_flow_rules( num_ul_flows, dl_flow_rules, ) print("Sleeping for 5 seconds") time.sleep(5) # Trigger Activate Default EPS Bearer Context Reject indication # so that s1ap tester sends Activate default EPS bearer context reject # instead of Activate default EPS bearer context accept def_ber_rej = s1ap_types.ueActvDfltEpsBearerCtxtRej_t() def_ber_rej.ue_Id = req.ue_id def_ber_rej.bearerId = attach.esmInfo.epsBearerId def_ber_rej.cause = s1ap_types.TFW_EMM_CAUSE_PROT_ERR_UNSP self._s1ap_wrapper._s1_util.issue_cmd( s1ap_types.tfwCmd. UE_STANDALONE_ACTV_DEFAULT_EPS_BEARER_CNTXT_REJECT, def_ber_rej, ) print( "Sent STANDALONE_ACTV_DEFAULT_EPS_BEARER_CNTXT_REJECT indication", ) print("Sleeping for 5 seconds") time.sleep(5) # Send PDN Connectivity Request apn = "ims" self._s1ap_wrapper.sendPdnConnectivityReq(req.ue_id, apn) # Receive PDN CONN RSP/Activate default EPS bearer context request response = self._s1ap_wrapper.s1_util.get_response() self.assertEqual( response.msg_type, s1ap_types.tfwCmd.UE_PDN_CONN_RSP_IND.value, ) act_def_bearer_req = response.cast(s1ap_types.uePdnConRsp_t) print( "************************* Sending Activate default EPS bearer " "context reject for UE id %d and bearer %d" % (req.ue_id, act_def_bearer_req.m.pdnInfo.epsBearerId), ) print("Sleeping for 5 seconds") time.sleep(5) # Dedicated bearer will not be established as the secondary PDN # establishment failed print( "********************** Sending RAR for IMSI", "".join([str(i) for i in req.imsi]), ) self._sessionManager_util.send_ReAuthRequest( "IMSI" + "".join([str(i) for i in req.imsi]), policy_id, flow_list, qos, ) print("Sleeping for 5 seconds") time.sleep(5) # Verify that ovs rules are not created for the secondary pdn and # dedicated bearer as UE rejected the establishment of secondary pdn self._s1ap_wrapper.s1_util.verify_flow_rules( num_ul_flows, dl_flow_rules, ) print("Sleeping for 5 seconds") time.sleep(5) # Now detach the UE print( "************************* Running UE detach (switch-off) for ", "UE id ", req.ue_id, ) self._s1ap_wrapper.s1_util.detach( req.ue_id, s1ap_types.ueDetachType_t.UE_SWITCHOFF_DETACH.value, False, )
def test_attach_standalone_act_dflt_ber_ctxt_rej(self): """ Test case for sending Activate Default EPS Bearer Reject for secondary PDN """ self._s1ap_wrapper.configUEDevice(1) req = self._s1ap_wrapper.ue_req # APN of the secondary PDN ims = { "apn_name": "ims", # APN-name "qci": 5, # qci "priority": 15, # priority "pre_cap": 0, # preemption-capability "pre_vul": 0, # preemption-vulnerability "mbr_ul": 200000000, # MBR UL "mbr_dl": 100000000, # MBR DL } # APN list to be configured apn_list = [ims] self._s1ap_wrapper.configAPN( "IMSI" + "".join([str(i) for i in req.imsi]), apn_list, ) print( "************************* Running End to End attach for UE id ", req.ue_id, ) # Attach attach = self._s1ap_wrapper.s1_util.attach( req.ue_id, s1ap_types.tfwCmd.UE_END_TO_END_ATTACH_REQUEST, s1ap_types.tfwCmd.UE_ATTACH_ACCEPT_IND, s1ap_types.ueAttachAccept_t, ) # Wait on EMM Information from MME self._s1ap_wrapper._s1_util.receive_emm_info() addr = attach.esmInfo.pAddr.addrInfo default_ip = ipaddress.ip_address(bytes(addr[:4])) print("Sleeping for 5 seconds") time.sleep(5) # Trigger Activate Default EPS Bearer Context Reject indication # so that s1ap tester sends Activate default EPS bearer context reject # instead of Activate default EPS bearer context accept def_ber_rej = s1ap_types.ueActvDfltEpsBearerCtxtRej_t() def_ber_rej.ue_Id = req.ue_id def_ber_rej.bearerId = attach.esmInfo.epsBearerId def_ber_rej.cause = s1ap_types.TFW_EMM_CAUSE_PROT_ERR_UNSP self._s1ap_wrapper._s1_util.issue_cmd( s1ap_types.tfwCmd. UE_STANDALONE_ACTV_DEFAULT_EPS_BEARER_CNTXT_REJECT, def_ber_rej, ) print( "Sent STANDALONE_ACTV_DEFAULT_EPS_BEARER_CNTXT_REJECT indication", ) print("Sleeping for 5 seconds") time.sleep(5) # Send PDN Connectivity Request apn = "ims" # PDN Type 1=IPv4, 2=IPv6, 3=IPv4v6 self._s1ap_wrapper.sendPdnConnectivityReq(req.ue_id, apn, pdn_type=3) # Receive PDN CONN RSP/Activate default EPS bearer context request response = self._s1ap_wrapper.s1_util.get_response() self.assertEqual( response.msg_type, s1ap_types.tfwCmd.UE_PDN_CONN_RSP_IND.value, ) act_def_bearer_req = response.cast(s1ap_types.uePdnConRsp_t) print( "************************* Sending Activate default EPS bearer " "context reject for UE id %d and bearer %d" % (req.ue_id, act_def_bearer_req.m.pdnInfo.epsBearerId), ) print("Sleeping for 5 seconds") time.sleep(5) # Verify that ovs rule is not is created for the secondary pdn # as UE rejected the establishment of secondary pdn # 1 UL flow for the default bearer num_ul_flows = 1 # No dedicated bearers, so flow list will be empty dl_flow_rules = { default_ip: [], } self._s1ap_wrapper.s1_util.verify_flow_rules( num_ul_flows, dl_flow_rules, ) print("Sleeping for 5 seconds") time.sleep(5) # Now detach the UE print( "************************* Running UE detach (switch-off) for ", "UE id ", req.ue_id, ) self._s1ap_wrapper.s1_util.detach( req.ue_id, s1ap_types.ueDetachType_t.UE_SWITCHOFF_DETACH.value, False, )
def test_attach_complete_with_ActvDfltBearCtxtRej(self): """ Test Attach test case for sending Activate Default EPS Bearer Reject along with Attach Complete message """ # Ground work. self._s1ap_wrapper.configUEDevice(1) req = self._s1ap_wrapper.ue_req # Trigger Attach Request attach_req = s1ap_types.ueAttachRequest_t() sec_ctxt = s1ap_types.TFW_CREATE_NEW_SECURITY_CONTEXT id_type = s1ap_types.TFW_MID_TYPE_IMSI eps_type = s1ap_types.TFW_EPS_ATTACH_TYPE_EPS_ATTACH pdn_type = s1ap_types.pdn_Type() pdn_type.pres = True pdn_type.pdn_type = 1 attach_req.ue_Id = req.ue_id attach_req.mIdType = id_type attach_req.epsAttachType = eps_type attach_req.useOldSecCtxt = sec_ctxt attach_req.pdnType_pr = pdn_type print("********Triggering Attach Request ") self._s1ap_wrapper._s1_util.issue_cmd( s1ap_types.tfwCmd.UE_ATTACH_REQUEST, attach_req) response = self._s1ap_wrapper.s1_util.get_response() self.assertEqual(response.msg_type, s1ap_types.tfwCmd.UE_AUTH_REQ_IND.value) # Trigger Authentication Response auth_res = s1ap_types.ueAuthResp_t() auth_res.ue_Id = req.ue_id sqnRecvd = s1ap_types.ueSqnRcvd_t() sqnRecvd.pres = 0 auth_res.sqnRcvd = sqnRecvd self._s1ap_wrapper._s1_util.issue_cmd(s1ap_types.tfwCmd.UE_AUTH_RESP, auth_res) response = self._s1ap_wrapper.s1_util.get_response() self.assertEqual(response.msg_type, s1ap_types.tfwCmd.UE_SEC_MOD_CMD_IND.value) # Trigger Security Mode Complete sec_mode_complete = s1ap_types.ueSecModeComplete_t() sec_mode_complete.ue_Id = req.ue_id self._s1ap_wrapper._s1_util.issue_cmd( s1ap_types.tfwCmd.UE_SEC_MOD_COMPLETE, sec_mode_complete) response = self._s1ap_wrapper.s1_util.get_response() self.assertEqual(response.msg_type, s1ap_types.tfwCmd.INT_CTX_SETUP_IND.value) response = self._s1ap_wrapper.s1_util.get_response() self.assertEqual(response.msg_type, s1ap_types.tfwCmd.UE_ATTACH_ACCEPT_IND.value) msg = response.cast(s1ap_types.ueAttachAccept_t) bid = msg.esmInfo.epsBearerId # Trigger Attach Complete with # Activate Default EPS Bearer Context Reject time.sleep(0.2) act_rej = s1ap_types.ueActvDfltEpsBearerCtxtRej_t() act_rej.ue_Id = req.ue_id act_rej.bearerId = bid act_rej.esmCause = s1ap_types.TFW_EMM_CAUSE_REQ_REJ_UNSPECIFIED # Activate Default EPS Bearer Context Reject sent along with # Attach Complete message # Attach Complete + Activate Default EPS Bearer Context Reject self._s1ap_wrapper._s1_util.issue_cmd( s1ap_types.tfwCmd.UE_ACTV_DEFAULT_EPS_BEARER_CNTXT_REJECT, act_rej) # Added delay to ensure S1APTester receives the emm information before # sending the detach request message time.sleep(0.5) print("************************* Running UE detach") # Now detach the UE detach_req = s1ap_types.uedetachReq_t() detach_req.ue_Id = req.ue_id detach_req.ueDetType = ( s1ap_types.ueDetachType_t.UE_SWITCHOFF_DETACH.value) self._s1ap_wrapper._s1_util.issue_cmd( s1ap_types.tfwCmd.UE_DETACH_REQUEST, detach_req) time.sleep(0.5)
def test_attach_act_dflt_ber_ctxt_rej(self): """Test Attach test case for sending Activate Default EPS Bearer Reject along with Attach Complete message""" # Ground work. self._s1ap_wrapper.configUEDevice(1) req = self._s1ap_wrapper.ue_req # Trigger Attach Request attach_req = s1ap_types.ueAttachRequest_t() sec_ctxt = s1ap_types.TFW_CREATE_NEW_SECURITY_CONTEXT id_type = s1ap_types.TFW_MID_TYPE_IMSI eps_type = s1ap_types.TFW_EPS_ATTACH_TYPE_EPS_ATTACH pdn_type = s1ap_types.pdn_Type() pdn_type.pres = True pdn_type.pdn_type = 1 attach_req.ue_Id = req.ue_id attach_req.mIdType = id_type attach_req.epsAttachType = eps_type attach_req.useOldSecCtxt = sec_ctxt attach_req.pdnType_pr = pdn_type print("********Triggering Attach Request ") self._s1ap_wrapper._s1_util.issue_cmd( s1ap_types.tfwCmd.UE_ATTACH_REQUEST, attach_req, ) response = self._s1ap_wrapper.s1_util.get_response() self.assertEqual( response.msg_type, s1ap_types.tfwCmd.UE_AUTH_REQ_IND.value, ) # Trigger Authentication Response auth_res = s1ap_types.ueAuthResp_t() auth_res.ue_Id = req.ue_id sqn_recvd = s1ap_types.ueSqnRcvd_t() sqn_recvd.pres = 0 auth_res.sqnRcvd = sqn_recvd self._s1ap_wrapper._s1_util.issue_cmd( s1ap_types.tfwCmd.UE_AUTH_RESP, auth_res, ) response = self._s1ap_wrapper.s1_util.get_response() self.assertEqual( response.msg_type, s1ap_types.tfwCmd.UE_SEC_MOD_CMD_IND.value, ) # Trigger Security Mode Complete sec_mode_complete = s1ap_types.ueSecModeComplete_t() sec_mode_complete.ue_Id = req.ue_id self._s1ap_wrapper._s1_util.issue_cmd( s1ap_types.tfwCmd.UE_SEC_MOD_COMPLETE, sec_mode_complete, ) # Receive initial context setup and attach accept indication response = (self._s1ap_wrapper._s1_util. receive_initial_ctxt_setup_and_attach_accept()) attach_acc = response.cast(s1ap_types.ueAttachAccept_t) print( "********************** Received attach accept for UE Id:", attach_acc.ue_Id, ) bid = attach_acc.esmInfo.epsBearerId # Trigger Attach Complete with # Activate Default EPS Bearer Context Reject time.sleep(0.2) act_rej = s1ap_types.ueActvDfltEpsBearerCtxtRej_t() act_rej.ue_Id = req.ue_id act_rej.bearerId = bid act_rej.esmCause = s1ap_types.TFW_EMM_CAUSE_REQ_REJ_UNSPECIFIED # Activate Default EPS Bearer Context Reject sent along with # Attach Complete message # Attach Complete + Activate Default EPS Bearer Context Reject self._s1ap_wrapper._s1_util.issue_cmd( s1ap_types.tfwCmd.UE_ACTV_DEFAULT_EPS_BEARER_CNTXT_REJECT, act_rej, ) # Attach Reject response = self._s1ap_wrapper.s1_util.get_response() self.assertEqual( response.msg_type, s1ap_types.tfwCmd.UE_ATTACH_REJECT_IND.value, ) response = self._s1ap_wrapper.s1_util.get_response() self.assertEqual( response.msg_type, s1ap_types.tfwCmd.UE_CTX_REL_IND.value, ) print("******** released UE contexts ********")