Пример #1
0
    def __init__(self):
        # {{{

        Splitter_DBS.__init__(self)
        sys.stdout.write(Color.yellow)
        print("Using NTS")
        sys.stdout.write(Color.none)

        # {{{ The IDs of the peers in the team.
        # }}}
        self.ids = {}
        # {{{ The source port steps (smallest difference of the source ports
        # when connecting to different endpoints) of the peers in the team.
        # }}}
        self.port_steps = {}

        # {{{ The last known allocated source port for each peer in the team.
        # }}}
        self.last_source_port = {}

        # {{{ The arriving peers. Key: ID.
        # Value: (serve_socket, peer_address,
        # source_port_to_splitter, source_ports_to_monitors, arrive_time)
        # where source_port_to_splitter is the public source port to splitter
        # and source_ports_to_monitors are the source ports towards monitors.
        # }}}
        self.arriving_peers = {}

        # {{{ The peers that are being incorporated, have closed their TCP
        # connection to splitter and try to connect to all existing peers.
        # They will be removed from team if taking too long to connect to peers.
        # key: peer_id; value: (peer, incorporation_time,
        # source_port_to_splitter, source_ports_to_monitors, serve_socket).
        # The source port values are set when the peer retries incorporation.
        # }}}
        self.incorporating_peers = {}

        # The thread regularly checks if peers are waiting to be incorporated
        # for too long and removes them after a timeout
        threading.Thread(target=self.check_timeout_thread).start()

        # This socket is closed and created again when a new peer arrives,
        # and all incorporated peers with port_step != 0 send a message to this
        # socket to determine the currently allocated source port
        self.extra_socket = None
        # The thread listens to self.extra_socket and reports source ports
        threading.Thread(target=self.listen_extra_socket_thread).start()

        # This message queue stores tuples (message, sender) that will be sent
        # in a dedicated thread instead of the main thread, with a delay between
        # each message to avoid network congestion.
        self.message_queue = Queue.Queue()
        threading.Thread(target=self.send_message_thread).start()
        # An event that is set for each chunk received by the source
        self.chunk_received_event = threading.Event()
Пример #2
0
 def __init__(self):
     Splitter_DBS.__init__(self)
     sys.stdout.write(Color.yellow)
     print("Using FNS")
     sys.stdout.write(Color.none)
Пример #3
0
 def __init__(self):
     Splitter_DBS.__init__(self)
     sys.stdout.write(Color.yellow)
     print("Using FNS")
     sys.stdout.write(Color.none)