Esempio n. 1
0
class Splitter():
    def add_args(self, parser):
        parser.add_argument("-s",
                            "--set_of_rules",
                            default="IMS",
                            help="Set of rules (default=\"IMS\")")
        parser.add_argument("-b",
                            "--buffer_size",
                            default=Splitter_DBS.buffer_size,
                            type=int,
                            help="Buffer size (default={})".format(
                                Splitter_DBS.buffer_size))
        parser.add_argument("-p",
                            "--splitter_port",
                            default=Splitter_DBS.splitter_port,
                            type=int,
                            help="Splitter port (default={})".format(
                                Splitter_DBS.splitter_port))
        parser.add_argument(
            "-l",
            "--max_chunk_loss",
            default=Splitter_DBS.max_chunk_loss,
            help="Maximum number of lost chunks per round (default={})".format(
                Splitter_DBS.max_chunk_loss))
        parser.add_argument("-n",
                            "--number_of_monitors",
                            default=Splitter_DBS.number_of_monitors,
                            help="Number of monitors (default={})".format(
                                Splitter_DBS.number_of_monitors))

        if __debug__:
            parser.add_argument("--loglevel",
                                default=logging.ERROR,
                                help="Log level (default={})".format(
                                    logging.getLevelName(logging.ERROR)))
            logging.basicConfig(
                format='%(asctime)s - %(name)s - %(levelname)s - %(message)s')

    def instance(self, args):
        if args.set_of_rules == "DBS" or args.set_of_rules == "IMS":
            Splitter_DBS.splitter_port = int(args.splitter_port)
            Splitter_DBS.max_chunk_loss = int(args.max_chunk_loss)
            Splitter_DBS.number_of_monitors = int(args.number_of_monitors)
            Splitter_DBS.buffer_size = int(args.buffer_size)
            self.splitter = Splitter_DBS("Splitter_DBS")
        if __debug__:
            lg = logging.getLogger("Splitter_DBS")
            lg.setLevel(args.loglevel)

    def run(self, args):
        self.splitter.setup_peer_connection_socket(port=args.splitter_port)
        self.splitter.setup_team_socket()
        self.splitter_address = self.splitter.get_id()
        self.splitter.run()
Esempio n. 2
0
    def run_a_splitter(self, splitter_id):
        Common.BUFFER_SIZE = self.get_buffer_size()
        if self.set_of_rules == "dbs":
            splitter = Splitter_DBS()
        elif self.set_of_rules == "cis":
            splitter = Splitter_STRPEDS()
        elif self.set_of_rules == "cis-sss":
            splitter = Splitter_SSS()

        # splitter.start()
        splitter.setup_peer_connection_socket()
        splitter.setup_team_socket()
        splitter_id['address'] = splitter.get_id()
        splitter.run()
Esempio n. 3
0
    def run_a_splitter(self, splitter_id):
        Common.CHUNK_CADENCE = self.chunk_cadence
        if self.buffer_size == 0:
            Common.BUFFER_SIZE = self.compute_buffer_size()
        else:
            Common.BUFFER_SIZE = self.buffer_size
        self.lg.debug("(definitive) buffer_size={}".format(Common.BUFFER_SIZE))
        if self.set_of_rules == "DBS" or self.set_of_rules == "IMS":
            splitter = Splitter_DBS()
            self.lg.info("simulator: DBS/IMS splitter created")
        elif self.set_of_rules == "CIS":
            splitter = Splitter_STRPEDS()
            self.lg.info("simulator: CIS splitter created")
        elif self.set_of_rules == "CIS-SSS":
            splitter = Splitter_SSS()
            self.lg.info("simulator: CIS-SSS splitter created")

        # splitter.start()
        splitter.setup_peer_connection_socket()
        splitter.setup_team_socket()
        splitter_id['address'] = splitter.get_id()
        splitter.max_number_of_rounds = self.number_of_rounds
        splitter.run()
Esempio n. 4
0
import argparse
import logging
from core.splitter_dbs import Splitter_DBS
from core.common import Common


if __name__ == "__main__":
    parser = argparse.ArgumentParser()
    parser.add_argument("-s", "--set-of-rules",
                        help="set of rules")
    parser.add_argument("-b", "--buffer-size", type=int,
                        help="Buffer size")
    args = parser.parse_args()

    logging.basicConfig(format='%(asctime)s - %(name)s - %(levelname)s - %(message)s')

    Common.BUFFER_SIZE = args.buffer_size
    if args.set_of_rules == "dbs":
        splitter = Splitter_DBS()
    # elif self.set_of_rules == "ims":
        # splitter = Splitter_IMS()

    splitter.setup_peer_connection_socket()
    splitter.setup_team_socket()
    splitter_address = splitter.get_id()
    print("Splitter Address: {}".format(splitter_address))
    splitter.run()