Esempio n. 1
0
    def test_smf_faulty_far_messages(self):

        #Create Session message with PDR="INSTALL" but no FAR
        cls_sess = CreateSessionUtil("IMSI001010000000001", 100, 1000)
        cls_sess.CreateSessionWithFaultyFar()

        self._util_session_message_handler(cls_sess._set_session,
                                           CauseIE.INVALID_FORWARDING_POLICY)
Esempio n. 2
0
    def test_smf_faulty_pdr_messages(self):
        #Create Session message with pdr_id=0
        cls_sess = CreateSessionUtil("IMSI001010000000001", 100, 1000)
        cls_sess.CreateSessionWithFaultyPDR()

        #Check if wrong PDR returns error
        self._util_session_message_handler(cls_sess._set_session,
                                           CauseIE.MANDATORY_IE_INCORRECT)
Esempio n. 3
0
    def test_smf_faulty_session_messages(self):

        #Wrong session version
        cls_sess = CreateSessionUtil("IMSI001010000000001", 100, 0)
        self._util_session_message_handler(cls_sess._set_session,
                                           CauseIE.SESSION_CONTEXT_NOT_FOUND)

        #Wrong subscriber id
        cls_sess = CreateSessionUtil("", 100, 10)
        self._util_session_message_handler(cls_sess._set_session,
                                           CauseIE.SESSION_CONTEXT_NOT_FOUND)
Esempio n. 4
0
def set_smf_session(client, args):
    cls_sess = CreateSessionUtil(args.subscriber_id, args.session_id, args.version)

    cls_sess.CreateSession(args.subscriber_id, args.pdr_state, args.in_teid, args.out_teid,
                           args.ue_ip_addr, args.gnb_ip_addr,
                           args.del_rule_id, args.add_rule_id, args.ipv4_dst,
                           args.allow, args.priority)

    print (cls_sess._set_session)
    response = client.SetSMFSessions(cls_sess._set_session)
    print (response)
Esempio n. 5
0
    def _util_gen_session_create_request(self,
                                         subs_id="IMSI001010000000001",
                                         session_id=1,
                                         version=2,
                                         pdr_state="ADD",
                                         cause_ie=CauseIE.REQUEST_ACCEPTED):

        cls_sess = CreateSessionUtil(subs_id, session_id, version)

        cls_sess.CreateSession(subs_id, pdr_state, 100, 200, "60.60.60.1",
                               "192.168.10.11")

        #Test case matches values with expected cause_info
        self._util_session_message_handler(cls_sess._set_session, cause_ie)

        return cls_sess._set_session
Esempio n. 6
0
def stress_test5g(client, args):
    """
    attach/detach script for smf session for 5g stress test
    """
    ue_dict = _gen_ue_set(args.number_of_iterations)
    delta_time = 1 / args.attaches_per_sec
    print("Attach every ~{0} seconds".format(delta_time))
    if args.disable_qos:
        print("QOS Disabled")
        apn_ambr = None
    else:
        print("QOS Enabled")
        apn_ambr = AggregatedMaximumBitrate(
            max_bandwidth_ul=1000000000,
            max_bandwidth_dl=1000000000,
        )
    print("Starting attaches")
    timestamp = datetime.now()
    completed_reqs = 0
    for ue in ue_dict:
        grpc_start_timestamp = datetime.now()
        cls_sess = CreateSessionUtil(ue.imsi_str, args.session_id, args.version)
        cls_sess.CreateSession(
            ue.imsi_str, 'ADD', ue.in_teid, ue.out_teid,
            ue.ipv4_src, ue.ipv4_dst,
            '', ue.rule_id, '',
            'allow', 10, apn_ambr=apn_ambr,
        )
        client.SetSMFSessions(cls_sess._set_session)
        grpc_end_timestamp = datetime.now()
        call_duration = (grpc_end_timestamp - grpc_start_timestamp).total_seconds()
        if call_duration < delta_time:
            time.sleep(delta_time - call_duration)
        if completed_reqs % LOG_INCREMENT == 0:
            print("Finished {0}".format(completed_reqs))
        completed_reqs += 1
    duration = (datetime.now() - timestamp).total_seconds()
    print("Finished {0} attaches in {1} seconds".format(len(ue_dict), duration))
    print("Actual attach rate = {0} UEs per sec".format(round(len(ue_dict) / duration)))

    # detach script

    time.sleep(args.time_between_detach)
    print("Starting detaches")
    timestamp = datetime.now()
    completed_reqs = 0
    for ue in ue_dict:
        grpc_start_timestamp = datetime.now()
        cls_sess = CreateSessionUtil(ue.imsi_str, args.session_id, args.version)
        cls_sess.CreateSession(
            ue.imsi_str, 'REMOVE', ue.in_teid, ue.out_teid,
            ue.ipv4_src, ue.ipv4_dst,
            ue.rule_id, '', '',
            'allow', 10,
        )
        client.SetSMFSessions(cls_sess._set_session)
        grpc_end_timestamp = datetime.now()
        call_duration = (grpc_end_timestamp - grpc_start_timestamp).total_seconds()
        if call_duration < delta_time:
            time.sleep(delta_time - call_duration)
        if completed_reqs % LOG_INCREMENT == 0:
            print("Finished {0}".format(completed_reqs))
        completed_reqs += 1
    duration = (datetime.now() - timestamp).total_seconds()
    print("Finished {0} detaches in {1} seconds".format(len(ue_dict), duration))
    print("Actual detach rate = {0} UEs per sec".format(round(len(ue_dict) / duration)))