Beispiel #1
0
 def test_rrcConnectionEstablishmentSuccessSubsequentRrcCompleteIgnored(
         self):
     self.enbResult = None
     temporaryCrnti = 0
     uplinkGrant = 34
     rrcTransactionIdentifier = 0
     interface, channelInfo, message = rrcConnectionRequest(
         temporaryCrnti, "randomValue", 3434, "moSignaling")
     self.enbProcedure.handleRrcEstablishmentMessage(
         (localhost(), 9001), interface, channelInfo, message, {
             "temporaryCrnti": temporaryCrnti,
             "uplinkGrant": uplinkGrant,
             "rrcTransactionIdentifier": rrcTransactionIdentifier
         })
     time.sleep(0.2)
     interface, channelInfo, message = rrcConnectionSetupComplete(
         rrcTransactionIdentifier, 28001,
         {"nasMessageType": "attachRequest"})
     self.enbProcedure.handleRrcEstablishmentMessage(
         (localhost(), 9001), interface, channelInfo, message)
     self.assertEqual(self.enbResult,
                      EnbRrcConnectionEstablishmentProcedure.Success)
     time.sleep(0.2)
     self.enbResult = None
     self.enbProcedure.handleRrcEstablishmentMessage(
         (localhost(), 9001), interface, channelInfo, message)
     time.sleep(0.2)
     self.assertEqual(self.enbResult, None)
Beispiel #2
0
 def test2_twoBearerContextCreation(self):
     bearerResourceHandler = SgwPgwBearerResourceHandler(localhost(), localhost())
     imsi = "2323"
     bearerContextsToBeCreated = [{"epsBearerId": 0, "bearerLevelQos": None},
                                  {"epsBearerId": 1, "bearerLevelQos": None}]
     bearerResourceHandler.allocateBearerResources(imsi, bearerContextsToBeCreated, self.__bearerResourceCompletionCallback__)
     self.assertEqual(self.result, SgwPgwBearerResourceHandler.Success)
Beispiel #3
0
 def test_singleUeRrcEstablishmentSuccess(self):
     time.sleep(0.1)
     temporaryCrnti = 0
     rrcTransactionIdentifier = 0
     self.ueIoServices[0].sendMessage((localhost(), 9000), *rrcConnectionRequest(
         temporaryCrnti, "randomValue", 3434, "moSignaling"))
     self.ueIoServices[0].sendMessage((localhost(), 9000), *rrcConnectionSetupComplete(
         rrcTransactionIdentifier, 28001, {"nasMessageType": "attachRequest"}))
     time.sleep(0.1) # ensure the enb call back is not waiting for rrc complete
     self.assertEqual(self.enb.state.uePool.numUes(), 1)
Beispiel #4
0
 def test_nUeRrcEstablishmentSuccess(self):
     time.sleep(0.1)
     for temporaryCrnti, s in enumerate(self.ueIoServices):
         s.sendMessage((localhost(), 9000), *rrcConnectionRequest(
             temporaryCrnti, "randomValue", 3434, "moSignaling") )
         time.sleep(0.1)  # need this to solve issue of synch
     for rrcTransactionIdentifier, s in enumerate(self.ueIoServices):
         s.sendMessage((localhost(), 9000), *rrcConnectionSetupComplete(
             rrcTransactionIdentifier, 28001, {"nasMessageType": "attachRequest"}))
         time.sleep(0.1)
     time.sleep(0.1) # need this to solve issue of synch
     self.assertEqual(self.enb.state.uePool.numUes(), self.numUes)
Beispiel #5
0
 def test_singleUeRrcEstablishmentSuccess(self):
     time.sleep(0.1)
     temporaryCrnti = 0
     rrcTransactionIdentifier = 0
     self.ueIoServices[0].sendMessage(
         (localhost(), 9000),
         *rrcConnectionRequest(temporaryCrnti, "randomValue", 3434,
                               "moSignaling"))
     self.ueIoServices[0].sendMessage(
         (localhost(), 9000),
         *rrcConnectionSetupComplete(rrcTransactionIdentifier, 28001,
                                     {"nasMessageType": "attachRequest"}))
     time.sleep(
         0.1)  # ensure the enb call back is not waiting for rrc complete
     self.assertEqual(self.enb.state.uePool.numUes(), 1)
Beispiel #6
0
 def test_nUeRrcEstablishmentSuccess(self):
     time.sleep(0.1)
     for temporaryCrnti, s in enumerate(self.ueIoServices):
         s.sendMessage((localhost(), 9000),
                       *rrcConnectionRequest(temporaryCrnti, "randomValue",
                                             3434, "moSignaling"))
         time.sleep(0.1)  # need this to solve issue of synch
     for rrcTransactionIdentifier, s in enumerate(self.ueIoServices):
         s.sendMessage((localhost(), 9000),
                       *rrcConnectionSetupComplete(
                           rrcTransactionIdentifier, 28001,
                           {"nasMessageType": "attachRequest"}))
         time.sleep(0.1)
     time.sleep(0.1)  # need this to solve issue of synch
     self.assertEqual(self.enb.state.uePool.numUes(), self.numUes)
Beispiel #7
0
 def setUp(self):
     self.mmeIoService = IoService("mme", 9000)
     self.mmeIoService.start()
     self.mmeParameters = {
         "mmeName": "Istanbul",
         "servedGummeis": [
             (("28603", "28604"), (0, 1, 2), (23, 58, 127)),
             (("00108"), (0,), (12, 13, 14)),
         ],
         "timeToWait": 1,
         "flags": {
             "rejectS1SetupRequestsFromRegisteredEnbs": True
         },
         "criticalityDiagnostics": None,
     }
     self.enbProcedureParameters = lambda globalEnbId, enbName, tac: {
         "globalEnbId": globalEnbId,
         "enbName": enbName,
         "supportedTas": [
             (tac, ("28603", "28604")),
         ],
         "csgIdList": [],
         "defaultPagingDrx": [32, 64, 128],
     }
     self.numEnbs = 2
     self.enbIoServices = [IoService("enb{}".format(i), 9001 + i) for i in range(self.numEnbs)]
     self.enbProcedures = [
         EnbS1SetupProcedure(self.enbProcedureParameters(i, "enb{}".format(i), 59900 + i),
             (localhost(), 9000), s, self.__enbS1SetupProcedureProgressCallback__)
         for i, s in enumerate(self.enbIoServices)]
     [s.start() for s in self.enbIoServices]
     self.numSuccess, self.numWaitingForNextAttempt = 0, 0
Beispiel #8
0
 def setUp(self):
     self.sampleS1SetupRequestParameters = {
         "globalEnbId": 345,
         "enbName": "Taksim",
         "supportedTas": [
             (41433, ("28603", "28604")),
             (41434, ("28603", "28604")),
         ],
         "csgIdList": [101, 122],
         "defaultPagingDrx": [32, 64, 128],
     }
     self.sampleS1SetupResponseParameters = {
         "mmeName": "Istanbul",
         "servedGummeis": [
             (("28603", "28604"), (0, 1, 2), (23, 58, 127)),
             (("00108"), (0,), (12, 13, 14)),
         ],
         "relativeMmeCapacity": 255,
         "criticalityDiagnostics": None,
     }
     self.enbIoService = IoService("enb", 9001)
     self.mmeIoService = IoService("mme", 9000)
     [s.start() for s in self.enbIoService, self.mmeIoService]
     self.procedure = S1SetupProcedure(self.sampleS1SetupRequestParameters,
         (localhost(), 9000), self.enbIoService, self.__procedureProgressCallback__)
     self.enbIoService.addIncomingMessageCallback(self.procedure.handleIncomingMessage)
     self.progress = None
     self.args = None
Beispiel #9
0
 def test_missingS1SetupRequestParameters(self):
     with self.assertRaises(Exception):
         self.procedure = S1SetupProcedure({}, (localhost(), 9000),
             self.enbIoService, self.__procedureProgressCallback__)
         self.enbIoService.addIncomingMessageCallback(self.procedure.handleIncomingMessage)
         self.procedure.execute()
         self.procedure.terminate()
Beispiel #10
0
    def test_rrcConnectionSetupProcedureSuccessful(self):
        time.sleep(0.1)  # Wait for S1 Setup

        def rrcComplete(result):
            self.result = result

        self.result = None
        ueIoService = IoService("ue", 9001)
        ueIoService.start()
        rrcProcedure = RrcConnectionEstablishmentProcedure(
            {
                "maxPrachPreambleAttempts": 5,
                "prachPreambleRepeatDelay": 0.7,
                "macContentionResolutionTimeout": 0.5,
                "rrcConnectionSetupTimeoutT300": 2.0
            }, (localhost(), 9000), ueIoService, rrcComplete, {
                "ueIdentityType": "randomValue",
                "ueIdentityValue": 3434,
                "rrcEstablishmentCause": "moSignaling",
                "selectedPlmnIdentity": 2801,
                "initialNasMessage": {
                    "nasMessageType": "attachRequest"
                },
            })
        rrcProcedure.execute()
        time.sleep(2)
        self.assertEqual(self.result,
                         RrcConnectionEstablishmentProcedure.Success)
        ueIoService.stop()
Beispiel #11
0
 def test_rrcConnectionSetupProcedureSuccessful(self):
     time.sleep(0.1) # Wait for S1 Setup
     def rrcComplete(result):
         self.result = result
     self.result = None
     ueIoService = IoService("ue", 9001)
     ueIoService.start()
     rrcProcedure = RrcConnectionEstablishmentProcedure({
         "maxPrachPreambleAttempts": 5,
         "prachPreambleRepeatDelay": 0.7,
         "macContentionResolutionTimeout": 0.5,
         "rrcConnectionSetupTimeoutT300": 2.0
     }, (localhost(), 9000), ueIoService, rrcComplete, {
         "ueIdentityType": "randomValue",
         "ueIdentityValue": 3434,
         "rrcEstablishmentCause": "moSignaling",
         "selectedPlmnIdentity": 2801,
         "initialNasMessage": {
             "nasMessageType": "attachRequest"
         },
     })
     rrcProcedure.execute()
     time.sleep(2)
     self.assertEqual(self.result, RrcConnectionEstablishmentProcedure.Success)
     ueIoService.stop()
Beispiel #12
0
    def setUp(self):
        self.mme = Mme("mme", 8999, {
            "system": {
                "mmeName": "Istanbul",
                "servedGummeis": [
                    (("28603", "28604"), (0, 1, 2), (23, 58, 127)),
                    (("00108"), (0,), (12, 13, 14)),
                ],
                "maximumEnbsAllowed": 2,
            },
            "s1": {
                "s1SetupTimeToWait": 1,
            },
        })
        self.mme.execute()
        self.enb = Enb("enb", 9000, {
            "control": {
                "adminState": True,
            },
            "system": {
                "globalEnbId": 345,
                "enbName": "Taksim",
                "supportedTas": [
                    (127, ("28603", "28604")),
                ],
                "csgIdList": [],
                "defaultPagingDrx": [32, 64, 128],
            },
            "rrc": {
                "maxRrcConnectionSetupAttempts": 5,
                "rrcConnectionSetupTimeout": 0.7,
            },
            "mme": {
                "address": (localhost(), 8999),
                "s1SetupParameters": ConfigPath("system"),
                "properties": None,
            },
        })
        self.enb.execute()
        procedureParameters = {
            "maxPrachPreambleAttempts": 5,
            "prachPreambleRepeatDelay": 0.7,
            "macContentionResolutionTimeout": 0.5,
            "rrcConnectionSetupTimeoutT300": 2.0
        }
        args = lambda i: {
            "ueIdentityType": "randomValue",
            "ueIdentityValue": 3434,
            "rrcEstablishmentCause": "moSignaling",
            "selectedPlmnIdentity": 2801,
            "initialNasMessage": {
                "nasMessageType": "attachRequest"
            },
        }

        self.ueIoServices = [IoService(str(i), 9001 + i) for i in range(20)]
        [s.start() for s in self.ueIoServices]
        self.ueProcedures = [UeRrcConnectionEstablishmentProcedure(procedureParameters, (localhost(), 9000),
            s, self.__procedureCompleteCallback__, args(i)) for i, s in enumerate(self.ueIoServices)]
        self.numSuccess = 0
Beispiel #13
0
 def test_rrcConnectionEstablishmentSuccess(self):
     self.enbResult = None
     temporaryCrnti = 0
     uplinkGrant = 34
     rrcTransactionIdentifier = 0
     interface, channelInfo, message = rrcConnectionRequest(temporaryCrnti, "randomValue", 3434, "moSignaling")
     self.enbProcedure.handleRrcEstablishmentMessage((localhost(), 9001),  interface, channelInfo, message, {
         "temporaryCrnti": temporaryCrnti,
         "uplinkGrant": uplinkGrant, 
         "rrcTransactionIdentifier": rrcTransactionIdentifier
     })
     time.sleep(0.2)
     interface, channelInfo, message = rrcConnectionSetupComplete(rrcTransactionIdentifier, 28001, {"nasMessageType": "attachRequest"})
     self.enbProcedure.handleRrcEstablishmentMessage((localhost(),9001),  interface, channelInfo, message)
     self.assertEqual(self.enbResult,
         EnbRrcConnectionEstablishmentProcedure.Success)
Beispiel #14
0
 def test_noRrcConnectionSetupCompleteReceived(self):
     time.sleep(0.1)
     temporaryCrnti = 0
     self.ueIoServices[0].sendMessage(
         (localhost(), 9000),
         *rrcConnectionRequest(temporaryCrnti, "randomValue", 3434,
                               "moSignaling"))
     time.sleep(2.5)  # more than 3* 0.5 = 1.5 seconds  + 0.5 seconds
Beispiel #15
0
 def test_procedureSuccessful(self):
     self.enbProcedure.start((localhost(), 9001), 0, "cipherAlgo",
                             "integProtAlgo")
     time.sleep(0.1)
     self.ueIoService.sendMessage("enb", *securityModeComplete(0))
     time.sleep(0.1)
     self.assertEqual(self.result,
                      EnbInitialSecurityActivationProcedureHandler.Complete)
Beispiel #16
0
 def test_roamingNotAllowedError(self):
     visitedPlmnId = "47836"
     imsi = "286031595270296"
     mmeAuthProcHandler = MmeAuthProcedureHandler((localhost(), 9000), self.mmeIoService, 1, self.__mmeAuthCompleteCallback__)
     self.mmeIoService.addIncomingMessageCallback(mmeAuthProcHandler.handleIncomingMessage)
     hssAuthProcHandler = HssAuthProcedureHandler(self.hssIoService, self.__hssAuthCompleteCallback__)
     self.hssIoService.addIncomingMessageCallback(hssAuthProcHandler.handleIncomingMessage)
     mmeAuthProcHandler.execute(imsi, visitedPlmnId)
     self.assertEqual(self.mmeSuccessCount,0)
Beispiel #17
0
 def test_missingS1SetupRequestParameters(self):
     with self.assertRaises(Exception):
         self.procedure = S1SetupProcedure(
             {}, (localhost(), 9000), self.enbIoService,
             self.__procedureProgressCallback__)
         self.enbIoService.addIncomingMessageCallback(
             self.procedure.handleIncomingMessage)
         self.procedure.execute()
         self.procedure.terminate()
Beispiel #18
0
 def test_nNoCreateSessionResponseReceived(self):
     self.mmeResult = None
     mmeCreateSessionHandler = MmeCreateSessionHandler((localhost(), 9002), self.mmeIoService, 0.5, 3, self.__mmeCreateSessionCompleteCallback__)
     self.mmeIoService.addIncomingMessageCallback(mmeCreateSessionHandler.handleIncomingMessage)
     for i in range(100):
         imsi = "2867" + str(i)
         createSessionRequestMessage = \
             {"imsi": imsi,
              "senderFteidForControlPlane": {"interfaceType": "ipv4", "teid": i, "address": localhost()},
              "pgwS5S8AddressForContolPlane": {"interfaceType": "ipv4", "teid": 0, 
                                               "address": localhost()}, 
              "pdnAddressAllocation": {"pdnType": "ipv4", "pdnAddressAndPrefix": "0.0.0.0"},
              "bearerContextsToBeCreated": [{"epsBearerId": 0, 
                                            "s1uEnbFteid": {"interfaceType": "ipv4", "teid": 45, "address": localhost()}, 
                                            "bearerLevelQos": None}]
             }
         mmeCreateSessionHandler.execute(imsi, createSessionRequestMessage)
     time.sleep(0.5*3 + 0.5)
     self.assertEqual(self.mmeFailureCount, 100)
Beispiel #19
0
 def test_nCreateSessionProcedureSuccess(self):
     mmeCreateSessionHandler = MmeCreateSessionHandler((localhost(), 9000), self.mmeIoService, 0.5, 3, self.__mmeCreateSessionCompleteCallback__)
     self.mmeIoService.addIncomingMessageCallback(mmeCreateSessionHandler.handleIncomingMessage)        
     sgwPgwBearerResourceHandler = SgwPgwBearerResourceHandler(localhost(), localhost())
     sgwPgwCreateSessionHandler = SgwPgwCreateSessionHandler((localhost(), 9001), localhost(), self.sgwPgwIoService, 
                                                       sgwPgwBearerResourceHandler, self.__sgwPgwCreateSessionCompleteCallback__)
     self.sgwPgwIoService.addIncomingMessageCallback(sgwPgwCreateSessionHandler.handleCreateSessionRequestMessage)
     imsiArray = []
     for i in range(100):
         imsi = "2867" + str(i)
         imsiArray.append(imsi)
         createSessionRequestMessage = \
             {"imsi": imsi,
              "senderFteidForControlPlane": {"interfaceType": "ipv4", "teid": i, "address": localhost()},
              "pgwS5S8AddressForContolPlane": {"interfaceType": "ipv4", "teid": 0, 
                                               "address": localhost()}, 
              "pdnAddressAllocation": {"pdnType": "ipv4", "pdnAddressAndPrefix": "0.0.0.0"},
              "bearerContextsToBeCreated": [{"epsBearerId": 0, 
                                            "bearerLevelQos": None}]
             }
         mmeCreateSessionHandler.execute(imsi, createSessionRequestMessage)
         time.sleep(0.1)
     time.sleep(1.0)
     self.assertEqual(self.mmeSuccessCount, 100)
     self.assertEqual(set(sgwPgwCreateSessionHandler.establishedS11SessionContexts), set(imsiArray))
     mmeTeidsForControlPlane = []
     for i in range(100):
         imsi = "2867" + str(i)
         mmeTeidsForControlPlane.append(sgwPgwCreateSessionHandler.establishedS11SessionContexts[imsi]["mmeFteidForControlPlane"]["teid"])
     self.assertEqual(set(mmeTeidsForControlPlane), set(range(100)))
Beispiel #20
0
 def test_DuplicateCreateSessionRequestProcedureSuccess(self):
     mmeCreateSessionHandler = MmeCreateSessionHandler((localhost(), 9000), self.mmeIoService, 0.5, 3, self.__mmeCreateSessionCompleteCallback__)
     self.mmeIoService.addIncomingMessageCallback(mmeCreateSessionHandler.handleIncomingMessage)        
     sgwPgwBearerResourceHandler = SgwPgwBearerResourceHandler(localhost(), localhost())
     sgwPgwCreateSessionHandler = SgwPgwCreateSessionHandler((localhost(), 9001), localhost(), self.sgwPgwIoService, 
                                                       sgwPgwBearerResourceHandler, self.__sgwPgwCreateSessionCompleteCallback__)
     self.sgwPgwIoService.addIncomingMessageCallback(sgwPgwCreateSessionHandler.handleCreateSessionRequestMessage)
     imsi = "35353"
     createSessionRequestMessage = \
         {"imsi": imsi,
          "senderFteidForControlPlane": {"interfaceType": "ipv4", "teid": 45, "address": localhost()},
          "pgwS5S8AddressForContolPlane": {"interfaceType": "ipv4", "teid": 0, 
                                           "address": localhost()}, 
          "pdnAddressAllocation": {"pdnType": "ipv4", "pdnAddressAndPrefix": "0.0.0.0"},
          "bearerContextsToBeCreated": [{"epsBearerId": 0, 
                                        "bearerLevelQos": None}]
         }
     mmeCreateSessionHandler.execute(imsi, createSessionRequestMessage)
     time.sleep(1.0)
     self.assertEqual(self.mmeResult, MmeCreateSessionHandler.Success)
     self.assertEqual(self.sgwPgwResult, SgwPgwCreateSessionHandler.Success)
     mmeCreateSessionHandler.execute(imsi, createSessionRequestMessage)  # send duplicate message but with a new sequence number
     time.sleep(1.0)
     self.assertEqual(self.mmeResult, MmeCreateSessionHandler.Success)
     self.assertEqual(self.sgwPgwResult, SgwPgwCreateSessionHandler.Success)
Beispiel #21
0
 def test_unknownImsiError(self):
     n = 10
     visitedPlmnId = "28603"
     imsi = "286056548201466"
     mmeAuthProcHandler = MmeAuthProcedureHandler((localhost(), 9000), self.mmeIoService, 1, self.__mmeAuthCompleteCallback__)
     self.mmeIoService.addIncomingMessageCallback(mmeAuthProcHandler.handleIncomingMessage)
     hssAuthProcHandler = HssAuthProcedureHandler(self.hssIoService, self.__hssAuthCompleteCallback__)
     self.hssIoService.addIncomingMessageCallback(hssAuthProcHandler.handleIncomingMessage)
     for _ in range(n):
         randomImsi = visitedPlmnId + "".join([str(random.randrange(0, 10)) for __ in range(10)])
         hssAuthProcHandler.knownIMSIs.append(randomImsi)
     mmeAuthProcHandler.execute(imsi, visitedPlmnId)
     self.assertEqual(self.mmeSuccessCount,0)
Beispiel #22
0
 def test_nAuthInfoRetrievalProcedureSuccess(self):
     n = 100
     visitedPlmnId = "28603"
     mmeAuthProcHandler = MmeAuthProcedureHandler((localhost(), 9000), self.mmeIoService, self.__mmeAuthCompleteCallback__)
     self.mmeIoService.addIncomingMessageCallback(mmeAuthProcHandler.handleIncomingMessage)
     hssAuthProcHandler = HssAuthProcedureHandler(self.hssIoService, self.__hssAuthCompleteCallback__)
     self.hssIoService.addIncomingMessageCallback(hssAuthProcHandler.handleIncomingMessage)
     for _ in range(n):
         randomImsi = visitedPlmnId + "".join([str(random.randrange(0, 10)) for __ in range(10)])
         mmeAuthProcHandler.execute(randomImsi, visitedPlmnId)
         time.sleep(0.1)
     time.sleep(1.0)
     self.assertEqual(self.mmeSuccess, n)
     self.assertEqual(self.hssSuccess, n)
Beispiel #23
0
 def test_noRrcConnectionSetupCompleteReceived(self):
     self.enbResult = None
     temporaryCrnti = 0
     uplinkGrant = 34
     rrcTransactionIdentifier = 0
     interface, channelInfo, message = rrcConnectionRequest(temporaryCrnti, "randomValue", 3434, "moSignaling")
     self.enbProcedure.handleRrcEstablishmentMessage((localhost(), 9001),  interface, channelInfo, message, {
         "temporaryCrnti": temporaryCrnti,
         "uplinkGrant": uplinkGrant, 
         "rrcTransactionIdentifier": rrcTransactionIdentifier
     })
     time.sleep(1.7) # more than 3 * 0.5 = 1.5 seconds
     self.assertEqual(self.enbResult,
         EnbRrcConnectionEstablishmentProcedure.ErrorNoRrcConnectionCompleteMessage)
Beispiel #24
0
 def test_nAuthInfoRetrievalProcedureSuccess(self):
     n = 100
     visitedPlmnId = "28603"
     mmeAuthProcHandler = MmeAuthProcedureHandler((localhost(), 9000), self.mmeIoService, self.__mmeAuthCompleteCallback__)
     self.mmeIoService.addIncomingMessageCallback(mmeAuthProcHandler.handleIncomingMessage)
     hssAuthProcHandler = HssAuthProcedureHandler(self.hssIoService, self.__hssAuthCompleteCallback__)
     self.hssIoService.addIncomingMessageCallback(hssAuthProcHandler.handleIncomingMessage)
     for _ in range(n):
         randomImsi = visitedPlmnId + "".join([str(random.randrange(0, 10)) for __ in range(10)])
         mmeAuthProcHandler.execute(randomImsi, visitedPlmnId)
         time.sleep(0.1)
     time.sleep(1.0)
     self.assertEqual(self.mmeSuccess, n)
     self.assertEqual(self.hssSuccess, n)
Beispiel #25
0
 def test_responseTimeoutError(self):
     n = 100
     visitedPlmnId = "28603"
     mmeAuthProcHandler = MmeAuthProcedureHandler((localhost(), 9000), self.mmeIoService, 1, self.__mmeAuthCompleteCallback__)
     self.mmeIoService.addIncomingMessageCallback(mmeAuthProcHandler.handleIncomingMessage)
     hssAuthProcHandler = HssAuthProcedureHandler(self.hssIoService, self.__hssAuthCompleteCallback__)
     self.hssIoService.addIncomingMessageCallback(hssAuthProcHandler.handleIncomingMessage)
     for _ in range(n):
         randomImsi = visitedPlmnId + "".join([str(random.randrange(0, 10)) for __ in range(10)])
         hssAuthProcHandler.knownIMSIs.append(randomImsi)
         mmeAuthProcHandler.execute(randomImsi, visitedPlmnId)
         time.sleep(0.05)
     time.sleep(5.0)
     self.assertEqual(self.mmeSuccessCount, n - mmeAuthProcHandler.timeoutCounter)
Beispiel #26
0
    def test_bulkMessages(self):
        def onIncomingMessage0(source, interface, channelInfo, message):
            self.numSuccess += 1

        def onIncomingMessage1(source, interface, channelInfo, message):
            self.ioservices[1].sendMessage("0", interface, channelInfo, message)

        n = 1000
        delayInBetween = 0.1e-1  # will fail if less than 0.1e-1
        [s.addIncomingMessageCallback(cb) for s, cb in zip(self.ioservices, (onIncomingMessage0, onIncomingMessage1))]
        for _ in range(n):
            time.sleep(delayInBetween)
            self.ioservices[0].sendMessage((localhost(), 9001), "udp", None, {"someKey": "someValue"})
        time.sleep(1.0)
        self.assertEqual(self.numSuccess, n)
Beispiel #27
0
    def test_bulkMessages(self):
        def onIncomingMessage0(source, interface, channelInfo, message):
            self.numSuccess += 1

        def onIncomingMessage1(source, interface, channelInfo, message):
            self.ioservices[1].sendMessage("0", interface, channelInfo, message)

        n = 1000
        delayInBetween = 0.1e-1  # will fail if less than 0.1e-1
        [s.addIncomingMessageCallback(cb) for s, cb in zip(self.ioservices, (onIncomingMessage0, onIncomingMessage1))]
        for _ in range(n):
            time.sleep(delayInBetween)
            self.ioservices[0].sendMessage((localhost(), 9001), "udp", None, {"someKey": "someValue"})
        time.sleep(1.0)
        self.assertEqual(self.numSuccess, n)
Beispiel #28
0
 def test_paging(self):
     msgToAll = {
         "type": "paging-request",
         "id": "1",
     }
     def onIncomingMessage(source, interface, channelInfo, message):
         self.assertEqual(message["id"], "1")
         self.successful = True
     self.successful = False
     self.ioservices[1].addIncomingMessageCallback(onIncomingMessage)
     [s.start() for s in self.ioservices]
     for p in range(9001, 9100):
         self.assertTrue(self.ioservices[0].sendMessage((localhost(), p), "pch", None, msgToAll))
     time.sleep(0.1)
     self.assertTrue(self.successful)
Beispiel #29
0
 def test_paging(self):
     msgToAll = {
         "type": "paging-request",
         "id": "1",
     }
     def onIncomingMessage(source, interface, channelInfo, message):
         self.assertEqual(message["id"], "1")
         self.successful = True
     self.successful = False
     self.ioservices[1].addIncomingMessageCallback(onIncomingMessage)
     [s.start() for s in self.ioservices]
     for p in range(9001, 9100):
         self.assertTrue(self.ioservices[0].sendMessage((localhost(), p), "pch", None, msgToAll))
     time.sleep(0.1)
     self.assertTrue(self.successful)
Beispiel #30
0
 def setUp(self):
     self.mme = Mme(
         "mme", 8999, {
             "system": {
                 "mmeName":
                 "Istanbul",
                 "servedGummeis": [
                     (("28603", "28604"), (0, 1, 2), (23, 58, 127)),
                     (("00108"), (0, ), (12, 13, 14)),
                 ],
                 "maximumEnbsAllowed":
                 2,
             },
             "s1": {
                 "s1SetupTimeToWait": 1,
             },
         })
     self.mme.execute()
     self.enb = Enb(
         "enb", 9000, {
             "control": {
                 "adminState": True,
             },
             "system": {
                 "globalEnbId": 345,
                 "enbName": "Taksim",
                 "supportedTas": [
                     (127, ("28603", "28604")),
                 ],
                 "csgIdList": [],
                 "defaultPagingDrx": [32, 64, 128],
             },
             "rrc": {
                 "maxRrcConnectionSetupAttempts": 5,
                 "rrcConnectionSetupTimeout": 0.7,
             },
             "mme": {
                 "address": (localhost(), 8999),
                 "s1SetupParameters": ConfigPath("system"),
                 "properties": None,
             },
         })
     self.enb.execute()
     self.numUes = 5
     self.ueIoServices = [
         IoService(str(i), 9001 + i) for i in range(self.numUes)
     ]
     [s.start() for s in self.ueIoServices]
Beispiel #31
0
 def test_noRrcConnectionSetupCompleteReceived(self):
     self.enbResult = None
     temporaryCrnti = 0
     uplinkGrant = 34
     rrcTransactionIdentifier = 0
     interface, channelInfo, message = rrcConnectionRequest(
         temporaryCrnti, "randomValue", 3434, "moSignaling")
     self.enbProcedure.handleRrcEstablishmentMessage(
         (localhost(), 9001), interface, channelInfo, message, {
             "temporaryCrnti": temporaryCrnti,
             "uplinkGrant": uplinkGrant,
             "rrcTransactionIdentifier": rrcTransactionIdentifier
         })
     time.sleep(1.7)  # more than 3 * 0.5 = 1.5 seconds
     self.assertEqual(
         self.enbResult, EnbRrcConnectionEstablishmentProcedure.
         ErrorNoRrcConnectionCompleteMessage)
Beispiel #32
0
 def setUp(self):
     self.mme = Mme("mme", 8999, {
         "system": {
             "mmeName": "Istanbul",
             "servedGummeis": [
                 (("28603", "28604"), (0, 1, 2), (23, 58, 127)),
                 (("00108"), (0,), (12, 13, 14)),
             ],
             "maximumEnbsAllowed": 2,
         },
         "s1": {
             "s1SetupTimeToWait": 1,
         },
     })
     self.mme.execute()
     self.enb = Enb("enb", 9000, {
         "control": {
             "adminState": True,
         },
         "system": {
             "globalEnbId": 345,
             "enbName": "Taksim",
             "supportedTas": [
                 (127, ("28603", "28604")),
             ],
             "csgIdList": [],
             "defaultPagingDrx": [32, 64, 128],
         },
         "rrc": {
             "maxRrcConnectionSetupAttempts": 5,
             "rrcConnectionSetupTimeout": 0.7,
         },
         "mme": {
             "address": (localhost(), 8999),
             "s1SetupParameters": ConfigPath("system"),
             "properties": None,
         },
     })
     self.enb.execute()
     self.numUes = 5
     self.ueIoServices = [IoService(str(i), 9001 + i) for i in range(self.numUes)]
     [s.start() for s in self.ueIoServices]
Beispiel #33
0
 def test_basicMessaging(self):
     msg0to1 = {
         "content": "Anyone there?",
     }
     msg1to0 = {
         "content": "Yes, there is!",
     }
     def onIncomingMessage0(source, interface, channelInfo, message):
         self.assertEqual(message, msg1to0)
         self.successful = True
     def onIncomingMessage1(source, interface, channelInfo, message):
         self.assertEqual(message, msg0to1)
         self.assertTrue(self.ioservices[1].sendMessage("0", "river", "bottle", msg1to0))
     self.successful = False
     self.ioservices[0].addIncomingMessageCallback(onIncomingMessage0)
     self.ioservices[1].addIncomingMessageCallback(onIncomingMessage1)
     [s.start() for s in self.ioservices]
     self.assertTrue(self.ioservices[0].sendMessage((localhost(), 9001), "air", "smoke", msg0to1))
     time.sleep(0.1)
     self.assertTrue(self.successful)
Beispiel #34
0
 def test_basicMessaging(self):
     msg0to1 = {
         "content": "Anyone there?",
     }
     msg1to0 = {
         "content": "Yes, there is!",
     }
     def onIncomingMessage0(source, interface, channelInfo, message):
         self.assertEqual(message, msg1to0)
         self.successful = True
     def onIncomingMessage1(source, interface, channelInfo, message):
         self.assertEqual(message, msg0to1)
         self.assertTrue(self.ioservices[1].sendMessage("0", "river", "bottle", msg1to0))
     self.successful = False
     self.ioservices[0].addIncomingMessageCallback(onIncomingMessage0)
     self.ioservices[1].addIncomingMessageCallback(onIncomingMessage1)
     [s.start() for s in self.ioservices]
     self.assertTrue(self.ioservices[0].sendMessage((localhost(), 9001), "air", "smoke", msg0to1))
     time.sleep(0.1)
     self.assertTrue(self.successful)
Beispiel #35
0
 def setUp(self):
     self.mmeIoService = IoService("mme", 9000)
     self.mmeIoService.start()
     self.mmeParameters = {
         "mmeName":
         "Istanbul",
         "servedGummeis": [
             (("28603", "28604"), (0, 1, 2), (23, 58, 127)),
             (("00108"), (0, ), (12, 13, 14)),
         ],
         "timeToWait":
         1,
         "flags": {
             "rejectS1SetupRequestsFromRegisteredEnbs": True
         },
         "criticalityDiagnostics":
         None,
     }
     self.enbProcedureParameters = lambda globalEnbId, enbName, tac: {
         "globalEnbId": globalEnbId,
         "enbName": enbName,
         "supportedTas": [
             (tac, ("28603", "28604")),
         ],
         "csgIdList": [],
         "defaultPagingDrx": [32, 64, 128],
     }
     self.numEnbs = 2
     self.enbIoServices = [
         IoService("enb{}".format(i), 9001 + i) for i in range(self.numEnbs)
     ]
     self.enbProcedures = [
         EnbS1SetupProcedure(
             self.enbProcedureParameters(i, "enb{}".format(i),
                                         59900 + i), (localhost(), 9000), s,
             self.__enbS1SetupProcedureProgressCallback__)
         for i, s in enumerate(self.enbIoServices)
     ]
     [s.start() for s in self.enbIoServices]
     self.numSuccess, self.numWaitingForNextAttempt = 0, 0
Beispiel #36
0
 def setUp(self):
     self.enbIoService = IoService("enb", 9000)
     self.ueIoService = IoService("ue", 9001)
     [s.start() for s in self.enbIoService, self.ueIoService]
     procedureParameters = {
         "maxPrachPreambleAttempts": 5,
         "prachPreambleRepeatDelay": 0.7,
         "macContentionResolutionTimeout": 0.5,
         "rrcConnectionSetupTimeoutT300": 2.0
     }
     rrcEstablishmentInputParameters = {
         "ueIdentityType": "randomValue",
         "ueIdentityValue": 3434,
         "rrcEstablishmentCause": "moSignaling",
         "selectedPlmnIdentity": 2801,
         "initialNasMessage": {
          "nasMessageType": "attachRequest"
         }
     }
     self.procedure = RrcConnectionEstablishmentProcedure(
         procedureParameters, (localhost(), 9000),
         self.ueIoService, self.__procedureCompleteCallback__, rrcEstablishmentInputParameters)
Beispiel #37
0
 def setUp(self):
     self.enbIoService = IoService("enb", 9000)
     self.ueIoService = IoService("ue", 9001)
     [s.start() for s in self.enbIoService, self.ueIoService]
     procedureParameters = {
         "maxPrachPreambleAttempts": 5,
         "prachPreambleRepeatDelay": 0.7,
         "macContentionResolutionTimeout": 0.5,
         "rrcConnectionSetupTimeoutT300": 2.0
     }
     rrcEstablishmentInputParameters = {
         "ueIdentityType": "randomValue",
         "ueIdentityValue": 3434,
         "rrcEstablishmentCause": "moSignaling",
         "selectedPlmnIdentity": 2801,
         "initialNasMessage": {
             "nasMessageType": "attachRequest"
         }
     }
     self.procedure = RrcConnectionEstablishmentProcedure(
         procedureParameters, (localhost(), 9000), self.ueIoService,
         self.__procedureCompleteCallback__,
         rrcEstablishmentInputParameters)
Beispiel #38
0
 def setUp(self):
     self.sampleS1SetupRequestParameters = {
         "globalEnbId":
         345,
         "enbName":
         "Taksim",
         "supportedTas": [
             (41433, ("28603", "28604")),
             (41434, ("28603", "28604")),
         ],
         "csgIdList": [101, 122],
         "defaultPagingDrx": [32, 64, 128],
     }
     self.sampleS1SetupResponseParameters = {
         "mmeName":
         "Istanbul",
         "servedGummeis": [
             (("28603", "28604"), (0, 1, 2), (23, 58, 127)),
             (("00108"), (0, ), (12, 13, 14)),
         ],
         "relativeMmeCapacity":
         255,
         "criticalityDiagnostics":
         None,
     }
     self.enbIoService = IoService("enb", 9001)
     self.mmeIoService = IoService("mme", 9000)
     [s.start() for s in self.enbIoService, self.mmeIoService]
     self.procedure = S1SetupProcedure(self.sampleS1SetupRequestParameters,
                                       (localhost(), 9000),
                                       self.enbIoService,
                                       self.__procedureProgressCallback__)
     self.enbIoService.addIncomingMessageCallback(
         self.procedure.handleIncomingMessage)
     self.progress = None
     self.args = None
Beispiel #39
0
    def setUp(self):
        self.mme = Mme(
            "mme", 8999, {
                "system": {
                    "mmeName":
                    "Istanbul",
                    "servedGummeis": [
                        (("28603", "28604"), (0, 1, 2), (23, 58, 127)),
                        (("00108"), (0, ), (12, 13, 14)),
                    ],
                    "maximumEnbsAllowed":
                    2,
                },
                "s1": {
                    "s1SetupTimeToWait": 1,
                },
            })
        self.mme.execute()
        self.enb = Enb(
            "enb", 9000, {
                "control": {
                    "adminState": True,
                },
                "system": {
                    "globalEnbId": 345,
                    "enbName": "Taksim",
                    "supportedTas": [
                        (127, ("28603", "28604")),
                    ],
                    "csgIdList": [],
                    "defaultPagingDrx": [32, 64, 128],
                },
                "rrc": {
                    "maxRrcConnectionSetupAttempts": 5,
                    "rrcConnectionSetupTimeout": 0.7,
                },
                "mme": {
                    "address": (localhost(), 8999),
                    "s1SetupParameters": ConfigPath("system"),
                    "properties": None,
                },
            })
        self.enb.execute()
        procedureParameters = {
            "maxPrachPreambleAttempts": 5,
            "prachPreambleRepeatDelay": 0.7,
            "macContentionResolutionTimeout": 0.5,
            "rrcConnectionSetupTimeoutT300": 2.0
        }
        args = lambda i: {
            "ueIdentityType": "randomValue",
            "ueIdentityValue": 3434,
            "rrcEstablishmentCause": "moSignaling",
            "selectedPlmnIdentity": 2801,
            "initialNasMessage": {
                "nasMessageType": "attachRequest"
            },
        }

        self.ueIoServices = [IoService(str(i), 9001 + i) for i in range(20)]
        [s.start() for s in self.ueIoServices]
        self.ueProcedures = [
            UeRrcConnectionEstablishmentProcedure(
                procedureParameters,
                (localhost(), 9000), s, self.__procedureCompleteCallback__,
                args(i)) for i, s in enumerate(self.ueIoServices)
        ]
        self.numSuccess = 0
Beispiel #40
0
 def test_funcSendMessage(self):
     with self.assertRaises(RuntimeError):
         self.ioservice.sendMessage((localhost(), 9000), "interface", "channelInfo", {"key": "value"})
Beispiel #41
0
 def test_procedureSuccessful(self):
     self.enbProcedure.start((localhost(), 9001), 0, "cipherAlgo", "integProtAlgo")
     time.sleep(0.1)
     self.ueIoService.sendMessage("enb", *securityModeComplete(0))
     time.sleep(0.1)
     self.assertEqual(self.result, EnbInitialSecurityActivationProcedureHandler.Complete)
Beispiel #42
0
 def test_funcSendMessage(self):
     with self.assertRaises(RuntimeError):
         self.ioservice.sendMessage((localhost(), 9000), "interface", "channelInfo", {"key": "value"})
 def test_procedureSuccessful(self):
     self.enbProcedure.start((localhost(), 9001), 0, "12")
     time.sleep(0.1)
     self.mmeIoService.sendMessage("enb", *initialContextSetupRequest(0))
     time.sleep(0.1)
     self.assertEqual(self.result, EnbinitialContextSetupProcedureHandler.Complete)
Beispiel #44
0
 def test_noRrcConnectionSetupCompleteReceived(self):
     time.sleep(0.1)
     temporaryCrnti = 0
     self.ueIoServices[0].sendMessage((localhost(), 9000), *rrcConnectionRequest(temporaryCrnti, "randomValue", 3434, "moSignaling"))
     time.sleep(2.5) # more than 3* 0.5 = 1.5 seconds  + 0.5 seconds