예제 #1
0
    def _initiateBroadcast(cls, message, toMyself):
        cls.logger.debug("Initiating broadcast message %s",
                         message.__class__.__name__)
        # propagation phase
        prop = ProbeStorage.getIdAllOtherProbes()
        if toMyself:
            # make sure we are the first on our list
            prop.insert(0, Identification.PROBE_ID)

        # Only do something if there is something to do
        if len(prop) > 0:
            if len(prop) <= Consts.PROPAGATION_RATE:
                for p in prop:
                    mes = copy.deepcopy(message)
                    mes.targetId = p
                    mes.recipientId = p
                    cls.send(mes)
            else:
                pRate = Consts.PROPAGATION_RATE
                # take targets for first hop out of the list
                sendTo = prop[0:pRate]
                pt = prop[pRate:]
                propTargets = [pt[i::pRate] for i in range(pRate)]
                for i, firstHop in enumerate(sendTo):
                    cls.send(
                        BroadCast(firstHop, Identification.PROBE_ID, message,
                                  propTargets[i]))
예제 #2
0
파일: client.py 프로젝트: netixx/NetProbes
    def _initiateBroadcast(cls, message, toMyself):
        cls.logger.debug("Initiating broadcast message %s", message.__class__.__name__)
        # propagation phase
        prop = ProbeStorage.getIdAllOtherProbes()
        if toMyself:
            # make sure we are the first on our list
            prop.insert(0, Identification.PROBE_ID)

        # Only do something if there is something to do
        if len(prop) > 0:
            if len(prop) <= Consts.PROPAGATION_RATE:
                for p in prop:
                    mes = copy.deepcopy(message)
                    mes.targetId = p
                    mes.recipientId = p
                    cls.send(mes)
            else:
                pRate = Consts.PROPAGATION_RATE
                # take targets for first hop out of the list
                sendTo = prop[0:pRate]
                pt = prop[pRate:]
                propTargets = [pt[i::pRate] for i in range(pRate)]
                for i, firstHop in enumerate(sendTo):
                    cls.send(BroadCast(firstHop, Identification.PROBE_ID, message, propTargets[i]))
예제 #3
0
 def getIdAllOtherProbes(cls):
     return ProbeStorage.getIdAllOtherProbes()
예제 #4
0
파일: tests.py 프로젝트: netixx/NetProbes
 def getIdAllOtherProbes():
     """Returns the Ids of all the other known probes"""
     return ProbeStorage.getIdAllOtherProbes()
예제 #5
0
파일: tests.py 프로젝트: netixx/NetProbes
 def getIdAllOtherProbes():
     """Returns the Ids of all the other known probes"""
     return ProbeStorage.getIdAllOtherProbes()