예제 #1
0
 def __enter__(self):
     rrcParameters = self.config.getValue("rrc")
     maxRrcConnectionSetupAttempts, rrcConnectionSetupTimeout = \
         [rrcParameters[k] for k in "maxRrcConnectionSetupAttempts", "rrcConnectionSetupTimeout"]
     self.rrcConnectionEstablishmentProcedureHandler =  \
         RrcConnectionEstablishmentProcedureHandler(
         maxRrcConnectionSetupAttempts, rrcConnectionSetupTimeout,
         self.ioService, self.__onNewRrcConnectionEstablishment__)
     self.mmeAddress = self.config.getValue("mme.address")
     self.enbUeS1apIdGenerator = idGenerator(2**24)
     self.uePool = self.UePool()
예제 #2
0
파일: states.py 프로젝트: BBOZKUS/pyEPS
 def __enter__(self):
     rrcParameters = self.config.getValue("rrc")
     maxRrcConnectionSetupAttempts, rrcConnectionSetupTimeout = \
         [rrcParameters[k] for k in "maxRrcConnectionSetupAttempts", "rrcConnectionSetupTimeout"]
     self.rrcConnectionEstablishmentProcedureHandler =  \
         RrcConnectionEstablishmentProcedureHandler(
         maxRrcConnectionSetupAttempts, rrcConnectionSetupTimeout,
         self.ioService, self.__onNewRrcConnectionEstablishment__)
     self.mmeAddress = self.config.getValue("mme.address")
     self.enbUeS1apIdGenerator = idGenerator(2**24)
     self.uePool = self.UePool()
예제 #3
0
class Registered(EnbState):
    def __init__(self, context):
        super(Registered, self).__init__(context)

    def __enter__(self):
        rrcParameters = self.config.getValue("rrc")
        maxRrcConnectionSetupAttempts, rrcConnectionSetupTimeout = \
            [rrcParameters[k] for k in "maxRrcConnectionSetupAttempts", "rrcConnectionSetupTimeout"]
        self.rrcConnectionEstablishmentProcedureHandler =  \
            RrcConnectionEstablishmentProcedureHandler(
            maxRrcConnectionSetupAttempts, rrcConnectionSetupTimeout,
            self.ioService, self.__onNewRrcConnectionEstablishment__)
        self.mmeAddress = self.config.getValue("mme.address")
        self.enbUeS1apIdGenerator = idGenerator(2**24)
        self.uePool = self.UePool()

    def handleIncomingMessage(self, source, interface, channelInfo, message):
        def handleRrcConnectionSetupEstablishmentProcedureMessages():
            return self.rrcConnectionEstablishmentProcedureHandler.handleIncomingMessage(
                source, interface, channelInfo, message)

        def handleUlInformationTransferMessage():
            nasPdu = message["dedicatedInfoNas"]
            ue = self.uePool.ueByCrnti(channelInfo["cRnti"])
            self.ioService.sendMessage(
                self.mmeAddress,
                *uplinkNasTransport(ue.enbUeS1apId, ue.mmeUeS1apId, nasPdu,
                                    None))
            return True

        def handleDownlinkNasTransportMessage():
            dedicatedInfoNas = message["nasPdu"]
            ue = self.uePool.ueByEnbUeS1apId(message["enbUeS1apId"])
            self.ioService.sendMessage(
                ue.address, *rrcDlInformationTransfer(dedicatedInfoNas))
            return True

        mapping = (
            ("uu", ("randomAccessPreamble", "rrcConnectionRequest",
                    "rrcConnectionSetupComplete"),
             handleRrcConnectionSetupEstablishmentProcedureMessages),
            ("uu", ("rrcUlInformationTransfer", ),
             handleUlInformationTransferMessage),
            ("s1", ("downlinkNasTransport", ),
             handleDownlinkNasTransportMessage),
        )
        for i, m, f in mapping:
            if interface == i and message["messageType"] in m:
                return f()
        return False

    def __onNewRrcConnectionEstablishment__(self, address, cRnti, args):
        enbUeS1apId = self.enbUeS1apIdGenerator.next()
        rrcEstablishmentCause = args["rrcEstablishmentCause"]
        ue = self.Ue(address, cRnti, enbUeS1apId, rrcEstablishmentCause)
        self.uePool.addUe(ue)
        nasPdu = args["dedicatedInfoNas"]
        gummei = self.config.getValue("mme.properties.servedGummeis")[0]
        self.ioService.sendMessage(
            self.mmeAddress,
            *initialUeMessage(enbUeS1apId, nasPdu, None, None,
                              rrcEstablishmentCause, None, None, gummei, None))

    class UePool(object):
        def __init__(self):
            self.uesByCrnti = {}
            self.uesByEnbUeS1apId = {}

        def ueByCrnti(self, cRnti):
            return self.uesByCrnti[cRnti]

        def ueByEnbUeS1apId(self, enbUeS1apId):
            return self.uesByEnbUeS1apId[enbUeS1apId]

        def addUe(self, ue):
            self.uesByCrnti[ue.cRnti] = ue
            self.uesByEnbUeS1apId[ue.enbUeS1apId] = ue

        def removeUe(self, ue):
            del self.uesByCrnti[ue.cRnti]
            del self.uesByEnbUeS1apId[ue.enbUeS1apId]

        def removeUeByCrnti(self, cRnti):
            self.removeUe(self.ueByCrnti[cRnti])

        def removeUeByEnbUeS1apId(self, enbUeS1apId):
            self.removeUe(self.ueByEnbUeS1apId[enbUeS1apId])

        def numUes(self):
            return len(self.uesByCrnti)

    class Ue(object):
        def __init__(self, address, cRnti, enbUeS1apId, rrcEstablishmentCause):
            self.address = address
            self.cRnti = cRnti
            self.enbUeS1apId = enbUeS1apId
            self.mmeUeS1apId = None
            self.rrcEstablishmentCause = rrcEstablishmentCause
예제 #4
0
파일: states.py 프로젝트: BBOZKUS/pyEPS
class Registered(EnbState):

    def __init__(self, context):
        super(Registered, self).__init__(context)

    def __enter__(self):
        rrcParameters = self.config.getValue("rrc")
        maxRrcConnectionSetupAttempts, rrcConnectionSetupTimeout = \
            [rrcParameters[k] for k in "maxRrcConnectionSetupAttempts", "rrcConnectionSetupTimeout"]
        self.rrcConnectionEstablishmentProcedureHandler =  \
            RrcConnectionEstablishmentProcedureHandler(
            maxRrcConnectionSetupAttempts, rrcConnectionSetupTimeout,
            self.ioService, self.__onNewRrcConnectionEstablishment__)
        self.mmeAddress = self.config.getValue("mme.address")
        self.enbUeS1apIdGenerator = idGenerator(2**24)
        self.uePool = self.UePool()

    def handleIncomingMessage(self, source, interface, channelInfo, message):
        def handleRrcConnectionSetupEstablishmentProcedureMessages():
            return self.rrcConnectionEstablishmentProcedureHandler.handleIncomingMessage(
                source, interface, channelInfo, message)

        def handleUlInformationTransferMessage():
            nasPdu = message["dedicatedInfoNas"]
            ue = self.uePool.ueByCrnti(channelInfo["cRnti"])
            self.ioService.sendMessage(self.mmeAddress, *uplinkNasTransport(
                ue.enbUeS1apId, ue.mmeUeS1apId, nasPdu, None))
            return True

        def handleDownlinkNasTransportMessage():
            dedicatedInfoNas = message["nasPdu"]
            ue = self.uePool.ueByEnbUeS1apId(message["enbUeS1apId"])
            self.ioService.sendMessage(ue.address, *rrcDlInformationTransfer(
                dedicatedInfoNas))
            return True
        mapping = (
            ("uu", ("randomAccessPreamble", "rrcConnectionRequest", "rrcConnectionSetupComplete"),
                handleRrcConnectionSetupEstablishmentProcedureMessages),
            ("uu", ("rrcUlInformationTransfer",),
                handleUlInformationTransferMessage),
            ("s1", ("downlinkNasTransport",),
                handleDownlinkNasTransportMessage),
        )
        for i, m, f in mapping:
            if interface == i and message["messageType"] in m:
                return f()
        return False

    def __onNewRrcConnectionEstablishment__(self, address, cRnti, args):
        enbUeS1apId = self.enbUeS1apIdGenerator.next()
        rrcEstablishmentCause = args["rrcEstablishmentCause"]
        ue = self.Ue(address, cRnti, enbUeS1apId, rrcEstablishmentCause)
        self.uePool.addUe(ue)
        nasPdu = args["dedicatedInfoNas"]
        gummei = self.config.getValue("mme.properties.servedGummeis")[0]
        self.ioService.sendMessage(self.mmeAddress, *initialUeMessage(
            enbUeS1apId, nasPdu, None, None, rrcEstablishmentCause, None, None, gummei, None))


    class UePool(object):

        def __init__(self):
            self.uesByCrnti = {}
            self.uesByEnbUeS1apId = {}

        def ueByCrnti(self, cRnti):
            return self.uesByCrnti[cRnti]

        def ueByEnbUeS1apId(self, enbUeS1apId):
            return self.uesByEnbUeS1apId[enbUeS1apId]

        def addUe(self, ue):
            self.uesByCrnti[ue.cRnti] = ue
            self.uesByEnbUeS1apId[ue.enbUeS1apId] = ue

        def removeUe(self, ue):
            del self.uesByCrnti[ue.cRnti]
            del self.uesByEnbUeS1apId[ue.enbUeS1apId]

        def removeUeByCrnti(self, cRnti):
            self.removeUe(self.ueByCrnti[cRnti])

        def removeUeByEnbUeS1apId(self, enbUeS1apId):
            self.removeUe(self.ueByEnbUeS1apId[enbUeS1apId])

        def numUes(self):
            return len(self.uesByCrnti)


    class Ue(object):

        def __init__(self, address, cRnti, enbUeS1apId, rrcEstablishmentCause):
            self.address = address
            self.cRnti = cRnti
            self.enbUeS1apId = enbUeS1apId
            self.mmeUeS1apId = None
            self.rrcEstablishmentCause = rrcEstablishmentCause