def setUp(self): synced_data_struct_factory = PiCNSyncDataStructFactory() synced_data_struct_factory.register("cs", ContentStoreMemoryExact) synced_data_struct_factory.register( "fib", ForwardingInformationBaseMemoryPrefix) synced_data_struct_factory.register("pit", PendingInterstTableMemoryExact) synced_data_struct_factory.create_manager() cs = synced_data_struct_factory.manager.cs() fib = synced_data_struct_factory.manager.fib() pit = synced_data_struct_factory.manager.pit() self.chunkLayer: DataOffloadingChunklayerSimple = DataOffloadingChunklayerSimple( cs, pit, fib) self.q1_to_lower = multiprocessing.Queue() self.q1_to_higher = multiprocessing.Queue() self.q1_from_lower = multiprocessing.Queue() self.q1_from_higher = multiprocessing.Queue() self.chunkLayer.queue_to_lower = self.q1_to_lower self.chunkLayer.queue_to_higher = self.q1_to_higher self.chunkLayer.queue_from_lower = self.q1_from_lower self.chunkLayer.queue_from_higher = self.q1_from_higher
def setUp(self): #setup icn_layer self.icn_layer = BasicICNLayer(log_level=255) synced_data_struct_factory = PiCNSyncDataStructFactory() synced_data_struct_factory.register("cs", ContentStoreMemoryExact) synced_data_struct_factory.register( "fib", ForwardingInformationBaseMemoryPrefix) synced_data_struct_factory.register("pit", PendingInterestTableMemoryExact) synced_data_struct_factory.create_manager() cs = synced_data_struct_factory.manager.cs() fib = synced_data_struct_factory.manager.fib() pit = synced_data_struct_factory.manager.pit() cs.set_cs_timeout(2) pit.set_pit_timeout(2) pit.set_pit_retransmits(2) self.icn_layer.cs = cs self.icn_layer.fib = fib self.icn_layer.pit = pit #setup queues icn_routing layer self.queue1_icn_routing_up = multiprocessing.Queue() self.queue1_icn_routing_down = multiprocessing.Queue() #add queues to ICN layer self.icn_layer.queue_from_lower = self.queue1_icn_routing_up self.icn_layer.queue_to_lower = self.queue1_icn_routing_down
def setUp(self): synced_data_struct_factory = PiCNSyncDataStructFactory() synced_data_struct_factory.register( 'fib', ForwardingInformationBaseMemoryPrefix) synced_data_struct_factory.register('rib', TreeRoutingInformationBase) synced_data_struct_factory.register('faceidtable', FaceIDDict) synced_data_struct_factory.create_manager() self.mock_interface = MockInterface(0) self.fidtable = synced_data_struct_factory.manager.faceidtable() self.linklayer = BasicLinkLayer([self.mock_interface], self.fidtable) self.peer = ('127.42.13.37', 6363) self.fib: BaseForwardingInformationBase = synced_data_struct_factory.manager.fib( ) self.rib: BaseRoutingInformationBase = synced_data_struct_factory.manager.rib( ) self.routinglayer = BasicRoutingLayer(self.linklayer, [self.peer]) self.routinglayer.rib = self.rib self.routinglayer.fib = self.fib self.routinglayer.queue_to_higher = self.queue_to_higher = multiprocessing.Queue( ) self.routinglayer.queue_from_higher = self.queue_from_higher = multiprocessing.Queue( ) self.routinglayer.queue_to_lower = self.queue_to_lower = multiprocessing.Queue( ) self.routinglayer.queue_from_lower = self.queue_from_lower = multiprocessing.Queue( )
def setUp(self): synced_data_struct_factory = PiCNSyncDataStructFactory() synced_data_struct_factory.register( 'fib', ForwardingInformationBaseMemoryPrefix) synced_data_struct_factory.register('faceidtable', FaceIDDict) synced_data_struct_factory.create_manager() fib = synced_data_struct_factory.manager.fib() self.faceidtable: FaceIDDict = synced_data_struct_factory.manager.faceidtable( ) # Create a face and an example route self.mock_interface = MockInterface(port=1337) self.linklayer = BasicLinkLayer([self.mock_interface], self.faceidtable) outfid = self.linklayer.faceidtable.get_or_create_faceid( AddressInfo(('127.13.37.42', 4242), 0)) fib.add_fib_entry(Name('/global'), [outfid]) # List of advertised prefixes self.prefixes: List[Tuple[Name, bool]] = [(Name('/test/repos'), False), (Name('/home'), True)] self.autoconflayer = AutoconfigServerLayer( linklayer=self.linklayer, address='127.0.1.1', registration_prefixes=self.prefixes) self.autoconflayer.fib = fib self.autoconflayer.queue_to_higher = self.queue_to_higher = multiprocessing.Queue( ) self.autoconflayer.queue_from_higher = self.queue_from_higher = multiprocessing.Queue( ) self.autoconflayer.queue_to_lower = self.queue_to_lower = multiprocessing.Queue( ) self.autoconflayer.queue_from_lower = self.queue_from_lower = multiprocessing.Queue( )
def __init__(self, port=8500, log_level=255, encoder: BasicEncoder = NdnTlvEncoder): # debug level logger = Logger("Publisher", log_level) # packet encoder encoder.set_log_level(log_level) self.encoder = encoder # create datastruct synced_data_struct_factory1 = PiCNSyncDataStructFactory() synced_data_struct_factory1.register("face_id_table", FaceIDDict) synced_data_struct_factory1.create_manager() face_id_table = synced_data_struct_factory1.manager.face_id_table() # initialize layers self.link_layer = BasicLinkLayer([UDP4Interface(port)], face_id_table, log_level=log_level) self.packet_encoding_layer = BasicPacketEncodingLayer( self.encoder, log_level=log_level) self.repo_layer = RepoLayer(log_level=log_level) self.stack: LayerStack = LayerStack( [self.repo_layer, self.packet_encoding_layer, self.link_layer])
def setUp(self): synced_data_struct_factory = PiCNSyncDataStructFactory() synced_data_struct_factory.register("timeoutPreventionMessageDict", TimeoutPreventionMessageDict) synced_data_struct_factory.register("NFNComputationList", NFNComputationList) synced_data_struct_factory.create_manager() tpmd = synced_data_struct_factory.manager.timeoutPreventionMessageDict() nfncl = synced_data_struct_factory.manager.NFNComputationList(None, None) self.timeoutPreventionLayer = BasicTimeoutPreventionLayer(tpmd, nfncl, log_level=255) self.timeoutPreventionLayer.queue_from_higher = multiprocessing.Queue() self.timeoutPreventionLayer.queue_from_lower = multiprocessing.Queue() self.timeoutPreventionLayer.queue_to_higher = multiprocessing.Queue() self.timeoutPreventionLayer.queue_to_lower = multiprocessing.Queue() self.timeoutPreventionLayer.start_process()
def __init__(self, port=9500, http_port=8080, log_level=255, encoder: BasicEncoder = NdnTlvEncoder, database_path="/tmp", flush_database=False, pem_path=None): # debug level logger = Logger("Repo", log_level) # packet encoder encoder.set_log_level(log_level) self.encoder = encoder # setup data structures synced_data_struct_factory1 = PiCNSyncDataStructFactory() synced_data_struct_factory1.register("face_id_table", FaceIDDict) synced_data_struct_factory1.register("cs", ContentStorePersistentExact) synced_data_struct_factory1.create_manager() face_id_table = synced_data_struct_factory1.manager.face_id_table() storage = synced_data_struct_factory1.manager.cs( db_path=database_path + "/beesens-cs.db") if flush_database: storage.delete_all() # initialize layers self.link_layer = BasicLinkLayer([UDP4Interface(port)], face_id_table, log_level=log_level) self.packet_encoding_layer = BasicPacketEncodingLayer( self.encoder, log_level=log_level) self.storage_layer = StorageLayer(log_level=log_level) self.interface_layer = InterfaceLayer(http_port=http_port, log_level=log_level, pem_path=pem_path, flush_database=flush_database) # setup stack self.stack: LayerStack = LayerStack([ self.interface_layer, self.storage_layer, self.packet_encoding_layer, self.link_layer ]) # pass cs to storage layer self.storage_layer.storage = storage
def __init__(self, database_path, port=9000, log_level=255, encoder: BasicEncoder = None, flush_database=False): # debug level logger = Logger("PushRepo", log_level) # packet encoder if encoder is None: self.encoder = SimpleStringEncoder(log_level=log_level) else: encoder.set_log_level(log_level=log_level) self.encoder = encoder # setup data structures synced_data_struct_factory = PiCNSyncDataStructFactory() synced_data_struct_factory.register("cs", ContentStorePersistentExact) synced_data_struct_factory.register("faceidtable", FaceIDDict) synced_data_struct_factory.create_manager() cs = synced_data_struct_factory.manager.cs(db_path=database_path + "/pushrepo.db") if flush_database: cs.delete_all() faceidtable = synced_data_struct_factory.manager.faceidtable() # default interface interfaces = [UDP4Interface(port)] mgmt_port = interfaces[0].get_port() # initialize layers self.linklayer = BasicLinkLayer(interfaces, faceidtable, log_level=log_level) self.packetencodinglayer = BasicPacketEncodingLayer(self.encoder, log_level=log_level) self.repolayer = PushRepositoryLayer(log_level=log_level) self.lstack: LayerStack = LayerStack([ self.repolayer, self.packetencodinglayer, self.linklayer ]) self.repolayer.cs = cs # mgmt self.mgmt = Mgmt(cs, None, None, self.linklayer, mgmt_port, self.stop_forwarder, log_level=log_level)
def __init__(self, ip: str, port: int, high_level_name: Name, log_level=255): """ :param ip: :param port: :param high_level_name: :param log_level: """ """ Create stack of layers for fetch tool (UDP only) :param ip: IP address of entry node to network :param port: Port address of entry node to network :param high_level_name: Name of high-level object to fetch :param log_level: Log level """ # create encoder self.encoder = NdnTlvEncoder() # create datastruct synced_data_struct_factory1 = PiCNSyncDataStructFactory() synced_data_struct_factory1.register("faceidtable", FaceIDDict) synced_data_struct_factory1.create_manager() faceidtable = synced_data_struct_factory1.manager.faceidtable() # create layers self.link_layer = BasicLinkLayer([UDP4Interface(0)], faceidtable, log_level=log_level) self.packet_encoding_layer = BasicPacketEncodingLayer( self.encoder, log_level=log_level) self.fetch_layer = FetchLayer(log_level) self.layer_stack: LayerStack = LayerStack( [self.fetch_layer, self.packet_encoding_layer, self.link_layer]) # setup face self.face_id = self.link_layer.faceidtable.get_or_create_faceid( AddressInfo((ip, port), 0)) # start all layers in the stack self.layer_stack.start_all() # trigger fetch self.fetch_layer.trigger_fetching(high_level_name, self.face_id)
def setUp(self): synced_data_struct_factory = PiCNSyncDataStructFactory() synced_data_struct_factory.register('faceidtable', FaceIDDict) synced_data_struct_factory.create_manager() self.mock_interface = MockInterface(port=1337) self.faceidtable: FaceIDDict = synced_data_struct_factory.manager.faceidtable() self.linklayer = BasicLinkLayer([self.mock_interface], self.faceidtable) self.repo = MockRepository(Name('/unconfigured')) self.autoconflayer = AutoconfigRepoLayer(name='testrepo', linklayer=self.linklayer, repo=self.repo, addr='127.0.1.1', bcport=4242) self.autoconflayer.queue_to_higher = self.queue_to_higher = multiprocessing.Queue() self.autoconflayer.queue_from_higher = self.queue_from_higher = multiprocessing.Queue() self.autoconflayer.queue_to_lower = self.queue_to_lower = multiprocessing.Queue() self.autoconflayer.queue_from_lower = self.queue_from_lower = multiprocessing.Queue()
def setUp(self): synced_data_struct_factory = PiCNSyncDataStructFactory() synced_data_struct_factory.register('faceidtable', FaceIDDict) synced_data_struct_factory.create_manager() self.mock_interface = MockInterface(port=1337) self.faceidtable: FaceIDDict = synced_data_struct_factory.manager.faceidtable( ) self.linklayer = BasicLinkLayer([self.mock_interface], self.faceidtable) self.autoconflayer = AutoconfigClientLayer(linklayer=self.linklayer, bcport=4242, solicitation_timeout=3.0) self.autoconflayer.queue_to_higher = self.queue_to_higher = multiprocessing.Queue( ) self.autoconflayer.queue_from_higher = self.queue_from_higher = multiprocessing.Queue( ) self.autoconflayer.queue_to_lower = self.queue_to_lower = multiprocessing.Queue( ) self.autoconflayer.queue_from_lower = self.queue_from_lower = multiprocessing.Queue( )
def setUp(self): #setup icn_layer synced_data_struct_factory = PiCNSyncDataStructFactory() synced_data_struct_factory.register("cs", ContentStoreMemoryExact) synced_data_struct_factory.register( "fib", ForwardingInformationBaseMemoryPrefix) synced_data_struct_factory.register("pit", PendingInterstTableMemoryExact) synced_data_struct_factory.register("computation_table", NFNComputationList) synced_data_struct_factory.register("faceidtable", FaceIDDict) synced_data_struct_factory.create_manager() cs = synced_data_struct_factory.manager.cs() fib = synced_data_struct_factory.manager.fib() pit = synced_data_struct_factory.manager.pit() faceidtable = synced_data_struct_factory.manager.faceidtable() self.r2cclient = TimeoutR2CHandler() parser = DefaultNFNParser() comp_table = synced_data_struct_factory.manager.computation_table( self.r2cclient, parser) self.executor = {"PYTHON": NFNPythonExecutor()} self.nfn_layer = BasicNFNLayer(cs, fib, pit, faceidtable, comp_table, self.executor, parser, self.r2cclient, log_level=255) self.nfn_layer.queue_to_lower = multiprocessing.Queue() self.nfn_layer.queue_from_lower = multiprocessing.Queue()
def setUp(self): synced_data_struct_factory = PiCNSyncDataStructFactory() synced_data_struct_factory.register('cs', ContentStoreMemoryExact) synced_data_struct_factory.register('pit', PendingInterstTableMemoryExact) synced_data_struct_factory.register( 'fib', ForwardingInformationBaseMemoryPrefix) synced_data_struct_factory.register('faceidtable', FaceIDDict) synced_data_struct_factory.create_manager() # Set up forwarder cs = synced_data_struct_factory.manager.cs() pit = synced_data_struct_factory.manager.pit() fib = synced_data_struct_factory.manager.fib() prefixes = [(Name('/test/prefix/repos'), True)] # Auto-assign port forwarder_interface = UDP4Interface(0) forwarder_fidtable = synced_data_struct_factory.manager.faceidtable() forwarder_linklayer = BasicLinkLayer([forwarder_interface], forwarder_fidtable) forwarder_port = forwarder_interface.get_port() forwarder_encoder = NdnTlvEncoder() icnlayer = BasicICNLayer() icnlayer.cs = cs icnlayer.pit = pit icnlayer.fib = fib forwarder_autoconfiglayer = AutoconfigServerLayer( forwarder_linklayer, registration_prefixes=prefixes) forwarder_autoconfiglayer.fib = fib self.forwarder = LayerStack([ icnlayer, forwarder_autoconfiglayer, BasicPacketEncodingLayer(forwarder_encoder), forwarder_linklayer ]) # Set up repo repository = MockRepository(Name('/thisshouldbechanged')) repo_chunkifyer = SimpleContentChunkifyer() repo_chunklayer = BasicChunkLayer(repo_chunkifyer) repo_encoder = NdnTlvEncoder() # Auto-assign port repo_interface = UDP4Interface(0) repo_fidtable = synced_data_struct_factory.manager.faceidtable() repo_linklayer = BasicLinkLayer([repo_interface], repo_fidtable) repo_port = repo_interface.get_port() self.repo = LayerStack([ BasicRepositoryLayer(repository), repo_chunklayer, AutoconfigRepoLayer('testrepo', repo_linklayer, repository, '127.0.0.1', forwarder_port), BasicPacketEncodingLayer(repo_encoder), repo_linklayer ]) # Set up fetch client client_chunkifyer = SimpleContentChunkifyer() client_chunklayer = BasicChunkLayer(client_chunkifyer) client_encoder = NdnTlvEncoder() client_interface = UDP4Interface(0) client_fidtable = synced_data_struct_factory.manager.faceidtable() client_linklayer = BasicLinkLayer([client_interface], client_fidtable) self.client = LayerStack([ client_chunklayer, AutoconfigClientLayer(client_linklayer, bcport=forwarder_port), BasicPacketEncodingLayer(client_encoder), client_linklayer ])
def __init__(self, replica_id, port=9500, log_level=255, encoder: BasicEncoder = NdnTlvEncoder): # debug level logger = Logger("Repo", log_level) # packet encoder encoder.set_log_level(log_level) self.encoder = encoder # create datastruct synced_data_struct_factory = PiCNSyncDataStructFactory() synced_data_struct_factory.register("cs", ContentStoreMemoryExact) synced_data_struct_factory.register( "fib", ForwardingInformationBaseMemoryPrefix) synced_data_struct_factory.register("pit", PendingInterestTableMemoryExact) synced_data_struct_factory.register("face_id_table", FaceIDDict) synced_data_struct_factory.create_manager() cs = synced_data_struct_factory.manager.cs() fib = synced_data_struct_factory.manager.fib() pit = synced_data_struct_factory.manager.pit() face_id_table = synced_data_struct_factory.manager.face_id_table() # initialize layers self.link_layer = BasicLinkLayer([UDP4Interface(port)], face_id_table, log_level=log_level) self.packet_encoding_layer = BasicPacketEncodingLayer( self.encoder, log_level=log_level) self.icn_layer = BasicICNLayer(log_level=log_level) self.pinned_computation_layer = PinnedComputationLayer( replica_id, log_level=log_level) # tell icn_layer that there is a higher layer which might satisfy interests self.icn_layer._interest_to_app = True # TODO -- decide here if it should be forwarded upwards or not # self.icn_layer._interest_to_app = lambda interest: interest.name.components[-1] == b"pNFN" # setup stack self.stack: LayerStack = LayerStack([ self.pinned_computation_layer, self.icn_layer, self.packet_encoding_layer, self.link_layer ]) # set CS, FIB, PIT in forwarding layer self.icn_layer.cs = cs self.icn_layer.fib = fib self.icn_layer.pit = pit
def __init__(self, port=9000, log_level=255, encoder: BasicEncoder = None, interfaces: List[BaseInterface] = None, executors: BaseNFNExecutor = None, ageing_interval: int = 3, use_thunks=False): # debug level logger = Logger("NFNForwarder", log_level) logger.info("Start PiCN NFN Forwarder on port " + str(port)) # packet encoder if encoder is None: self.encoder = SimpleStringEncoder(log_level=log_level) else: encoder.set_log_level(log_level) self.encoder = encoder # setup data structures synced_data_struct_factory = PiCNSyncDataStructFactory() synced_data_struct_factory.register("cs", ContentStoreMemoryExact) synced_data_struct_factory.register( "fib", ForwardingInformationBaseMemoryPrefix) synced_data_struct_factory.register("pit", PendingInterstTableMemoryExact) synced_data_struct_factory.register("faceidtable", FaceIDDict) synced_data_struct_factory.register("computation_table", NFNComputationList) synced_data_struct_factory.register("timeoutprevention_dict", TimeoutPreventionMessageDict) if use_thunks: synced_data_struct_factory.register("thunktable", ThunkList) synced_data_struct_factory.register("plantable", PlanTable) synced_data_struct_factory.create_manager() cs = synced_data_struct_factory.manager.cs() fib = synced_data_struct_factory.manager.fib() pit = synced_data_struct_factory.manager.pit() faceidtable = synced_data_struct_factory.manager.faceidtable() self.parser = DefaultNFNParser() if use_thunks: thunktable = synced_data_struct_factory.manager.thunktable() plantable = synced_data_struct_factory.manager.plantable( self.parser) #setup chunkifier self.chunkifier = SimpleContentChunkifyer() # default interface if interfaces is not None: self.interfaces = interfaces mgmt_port = port else: interfaces = [UDP4Interface(port)] mgmt_port = interfaces[0].get_port() # initialize layers self.linklayer = BasicLinkLayer(interfaces, faceidtable, log_level=log_level) self.packetencodinglayer = BasicPacketEncodingLayer( self.encoder, log_level=log_level) self.icnlayer = BasicICNLayer(log_level=log_level, ageing_interval=ageing_interval) self.chunklayer = BasicChunkLayer(self.chunkifier, log_level=log_level) # setup nfn self.icnlayer._interest_to_app = True if executors is None: self.executors = {"PYTHON": NFNPythonExecutor()} else: self.executors = executors self.r2cclient = TimeoutR2CHandler() comp_table = synced_data_struct_factory.manager.computation_table( self.r2cclient, self.parser) self.nfnlayer = BasicNFNLayer(cs, fib, pit, faceidtable, comp_table, self.executors, self.parser, self.r2cclient, log_level=log_level) if use_thunks: self.thunk_layer = BasicThunkLayer(cs, fib, pit, faceidtable, thunktable, plantable, self.parser, log_level=log_level) self.nfnlayer.optimizer = ThunkPlanExecutor( cs, fib, pit, faceidtable, plantable) timeoutprevention_dict = synced_data_struct_factory.manager.timeoutprevention_dict( ) self.timeoutpreventionlayer = BasicTimeoutPreventionLayer( timeoutprevention_dict, comp_table, pit=pit, log_level=log_level) if use_thunks: self.lstack: LayerStack = LayerStack([ self.nfnlayer, self.chunklayer, self.timeoutpreventionlayer, self.thunk_layer, self.icnlayer, self.packetencodinglayer, self.linklayer ]) else: self.lstack: LayerStack = LayerStack([ self.nfnlayer, self.chunklayer, self.timeoutpreventionlayer, self.icnlayer, self.packetencodinglayer, self.linklayer ]) self.icnlayer.cs = cs self.icnlayer.fib = fib self.icnlayer.pit = pit # mgmt self.mgmt = Mgmt(self.icnlayer.cs, self.icnlayer.fib, self.icnlayer.pit, self.linklayer, mgmt_port, self.stop_forwarder, log_level=log_level)
def __init__(self, replica_id, port=9500, log_level=255, encoder: ExtendedNdnTlvEncoder = ExtendedNdnTlvEncoder): # debug level logger = Logger("Server", log_level) # packet encoder encoder.set_log_level(log_level) self.encoder = encoder # create datastruct synced_data_struct_factory = PiCNSyncDataStructFactory() synced_data_struct_factory.register("cs", ContentStoreMemoryExact) synced_data_struct_factory.register( "fib", ForwardingInformationBaseMemoryPrefix) synced_data_struct_factory.register("pit", PendingInterstTableMemoryExact) synced_data_struct_factory.register("face_id_table", FaceIDDict) synced_data_struct_factory.create_manager() cs = synced_data_struct_factory.manager.cs() fib = synced_data_struct_factory.manager.fib() pit = synced_data_struct_factory.manager.pit() face_id_table = synced_data_struct_factory.manager.face_id_table() # initialize layers self.link_layer = BasicLinkLayer([UDP4Interface(port)], face_id_table, log_level=log_level) self.packet_encoding_layer = HeartbeatPacketEncodingLayer( self.encoder, log_level=log_level) self.heartbeat_network_layer = HeartbeatNetworkLayer( log_level=log_level, interest_to_app=True) self.heartbeat_computation_layer = HeartbeatComputationLayer( replica_id, log_level=log_level) # setup stack self.stack: LayerStack = LayerStack([ self.heartbeat_computation_layer, self.heartbeat_network_layer, self.packet_encoding_layer, self.link_layer ]) # set CS, FIB, PIT in forwarding layer self.heartbeat_network_layer.cs = cs self.heartbeat_network_layer.fib = fib self.heartbeat_network_layer.pit = pit
def setUp(self): self.udp4interface1 = UDP4Interface(0) synced_data_struct_factory1 = PiCNSyncDataStructFactory() synced_data_struct_factory1.register("faceidtable", FaceIDDict) synced_data_struct_factory1.create_manager() self.faceidtable1 = synced_data_struct_factory1.manager.faceidtable() self.linklayer1 = BasicLinkLayer([self.udp4interface1], self.faceidtable1) self.linklayer1.queue_to_higher = multiprocessing.Queue() self.linklayer1.queue_from_higher = multiprocessing.Queue() self.udp4interface2 = UDP4Interface(0) synced_data_struct_factory2 = PiCNSyncDataStructFactory() synced_data_struct_factory2.register("faceidtable", FaceIDDict) synced_data_struct_factory2.create_manager() self.faceidtable2 = synced_data_struct_factory2.manager.faceidtable() self.linklayer2 = BasicLinkLayer([self.udp4interface2], self.faceidtable2) self.linklayer2.queue_to_higher = multiprocessing.Queue() self.linklayer2.queue_from_higher = multiprocessing.Queue() self.udp4interface3 = UDP4Interface(0) synced_data_struct_factory3 = PiCNSyncDataStructFactory() synced_data_struct_factory3.register("faceidtable", FaceIDDict) synced_data_struct_factory3.create_manager() self.faceidtable3 = synced_data_struct_factory3.manager.faceidtable() self.linklayer3 = BasicLinkLayer([self.udp4interface3], self.faceidtable3) self.linklayer3.queue_to_higher = multiprocessing.Queue() self.linklayer3.queue_from_higher = multiprocessing.Queue() self.testSock = socket.socket(socket.AF_INET, socket.SOCK_DGRAM) self.testSock.bind(("0.0.0.0", 0)) self.test_port = self.testSock.getsockname()[1]
def setUp(self): synced_data_struct_factory = PiCNSyncDataStructFactory() synced_data_struct_factory.register("cs", ContentStoreMemoryExact) synced_data_struct_factory.register( "fib", ForwardingInformationBaseMemoryPrefix) synced_data_struct_factory.register("pit", PendingInterstTableMemoryExact) synced_data_struct_factory.register("faceidtable", FaceIDDict) synced_data_struct_factory.create_manager() cs = synced_data_struct_factory.manager.cs() fib = synced_data_struct_factory.manager.fib() pit = synced_data_struct_factory.manager.pit() faceidtable = synced_data_struct_factory.manager.faceidtable() interface = UDP4Interface(0) self.linklayer = BasicLinkLayer([interface], faceidtable) self.linklayerport = self.linklayer.interfaces[0].get_port() self.q1 = multiprocessing.Queue() self.linklayer.queue_from_higher = self.q1 self.mgmt = Mgmt(cs, fib, pit, self.linklayer, self.linklayerport) self.testMgmtSock1 = socket.socket(socket.AF_INET, socket.SOCK_STREAM) self.testMgmtSock2 = socket.socket(socket.AF_INET, socket.SOCK_STREAM) self.testMgmtSock3 = socket.socket(socket.AF_INET, socket.SOCK_STREAM) self.mgmt_client = MgmtClient(self.linklayerport)
def __init__(self, port=9000, log_level=255, encoder: BasicEncoder = None, routing: bool = False, peers=None, autoconfig: bool = False, interfaces: List[BaseInterface] = None, ageing_interval: int = 3, node_name: str = None): # debug level logger = Logger("ICNForwarder", log_level) # FIXME: Why isn't this self.logger??? self._node_name = node_name # packet encoder if encoder is None: self.encoder = SimpleStringEncoder(log_level=log_level) else: encoder.set_log_level(log_level=log_level) self.encoder = encoder # setup data structures synced_data_struct_factory = PiCNSyncDataStructFactory() synced_data_struct_factory.register("cs", ContentStoreMemoryExact) synced_data_struct_factory.register( "fib", ForwardingInformationBaseMemoryPrefix) synced_data_struct_factory.register("pit", PendingInterestTableMemoryExact) synced_data_struct_factory.register("rib", TreeRoutingInformationBase) synced_data_struct_factory.register("faceidtable", FaceIDDict) synced_data_struct_factory.create_manager() cs = synced_data_struct_factory.manager.cs() fib = synced_data_struct_factory.manager.fib() pit = synced_data_struct_factory.manager.pit() rib = None if routing: rib = synced_data_struct_factory.manager.rib() faceidtable = synced_data_struct_factory.manager.faceidtable() # default interface if interfaces is not None: self.interfaces = interfaces mgmt_port = port else: interfaces = [UDP4Interface(port)] mgmt_port = interfaces[0].get_port() # initialize layers self.linklayer = BasicLinkLayer(interfaces, faceidtable, log_level=log_level) self.packetencodinglayer = BasicPacketEncodingLayer( self.encoder, log_level=log_level) self.icnlayer = BasicICNLayer(log_level=log_level, ageing_interval=ageing_interval) self.lstack: LayerStack = LayerStack( [self.icnlayer, self.packetencodinglayer, self.linklayer]) if autoconfig: self.autoconfiglayer: AutoconfigServerLayer = AutoconfigServerLayer( linklayer=self.linklayer, address='127.0.0.1', registration_prefixes=[(Name('/testnetwork/repos'), True)], log_level=log_level) self.lstack.insert(self.autoconfiglayer, below_of=self.icnlayer) if routing: self.routinglayer = BasicRoutingLayer(self.linklayer, peers=peers, log_level=log_level) self.lstack.insert(self.routinglayer, below_of=self.icnlayer) self.icnlayer.cs = cs self.icnlayer.fib = fib # ----- by Luc # FIXME: How to pass these parameters to __init__ self.icnlayer.fib.logger = logger self.icnlayer.fib.node_name = self._node_name # ----- by Luc # FIXME: How to pass these parameters to __init__ self.icnlayer.pit = pit self.icnlayer.pit.logger = logger self.icnlayer.pit.node_name = self._node_name # ----- if autoconfig: self.autoconfiglayer.fib = fib if routing: self.routinglayer.rib = rib self.routinglayer.fib = fib # mgmt self.mgmt = Mgmt(cs, fib, pit, self.linklayer, mgmt_port, self.stop_forwarder, log_level=log_level)
def setUp(self): self.encoder1 = self.get_encoder() self.encoder2 = self.get_encoder() self.packetEncodingLayer1 = BasicPacketEncodingLayer( encoder=self.encoder1) self.packetEncodingLayer2 = BasicPacketEncodingLayer( encoder=self.encoder2) self.udp4interface1 = UDP4Interface(0) synced_data_struct_factory1 = PiCNSyncDataStructFactory() synced_data_struct_factory1.register("faceidtable", FaceIDDict) synced_data_struct_factory1.create_manager() self.faceidtable1 = synced_data_struct_factory1.manager.faceidtable() self.linkLayer1 = BasicLinkLayer([self.udp4interface1], self.faceidtable1) self.udp4interface2 = UDP4Interface(0) synced_data_struct_factory2 = PiCNSyncDataStructFactory() synced_data_struct_factory2.register("faceidtable", FaceIDDict) synced_data_struct_factory2.create_manager() self.faceidtable2 = synced_data_struct_factory2.manager.faceidtable() self.linkLayer2 = BasicLinkLayer([self.udp4interface2], self.faceidtable2) self.port1 = self.linkLayer1.interfaces[0].get_port() self.port2 = self.linkLayer2.interfaces[0].get_port() self.q1_fromLower = Queue() self.q1_fromHigher = Queue() self.q1_toLower = Queue() self.q1_toHigher = Queue() self.q2_fromLower = Queue() self.q2_fromHigher = Queue() self.q2_toLower = Queue() self.q2_toHigher = Queue() self.packetEncodingLayer1.queue_from_lower = self.q1_fromLower self.packetEncodingLayer1.queue_from_higher = self.q1_fromHigher self.packetEncodingLayer1.queue_to_lower = self.q1_toLower self.packetEncodingLayer1.queue_to_higher = self.q1_toHigher self.packetEncodingLayer2.queue_from_lower = self.q2_fromLower self.packetEncodingLayer2.queue_from_higher = self.q2_fromHigher self.packetEncodingLayer2.queue_to_lower = self.q2_toLower self.packetEncodingLayer2.queue_to_higher = self.q2_toHigher self.linkLayer1.queue_from_higher = self.q1_toLower #from higher in Linklayer is to Lower from Encoding Layer self.linkLayer1.queue_to_higher = self.q1_fromLower #to higher in Linklayer is from lower from Encoding Layer self.linkLayer2.queue_from_higher = self.q2_toLower # from higher in Linklayer is to Lower from Encoding Layer self.linkLayer2.queue_to_higher = self.q2_fromLower # to higher in Linklayer is from lower from Encoding Layer
def setUp(self): self.parser: DefaultNFNParser = DefaultNFNParser() synced_data_struct_factory = PiCNSyncDataStructFactory() synced_data_struct_factory.register("cs", ContentStoreMemoryExact) synced_data_struct_factory.register( "fib", ForwardingInformationBaseMemoryPrefix) synced_data_struct_factory.register("pit", PendingInterstTableMemoryExact) synced_data_struct_factory.register("computation_table", NFNComputationList) synced_data_struct_factory.register("faceidtable", FaceIDDict) synced_data_struct_factory.create_manager() cs = synced_data_struct_factory.manager.cs() fib = synced_data_struct_factory.manager.fib() pit = synced_data_struct_factory.manager.pit() faceidtable = synced_data_struct_factory.manager.faceidtable() self.r2cclient = TimeoutR2CHandler() parser = DefaultNFNParser() comp_table = synced_data_struct_factory.manager.computation_table( self.r2cclient, parser) self.optimizer: MapReduceOptimizer = MapReduceOptimizer( cs, fib, pit, faceidtable)
def __init__(self, port=9000, log_level=255, encoder: ExtendedNdnTlvEncoder = None, interfaces: List[BaseInterface] = None): # debug level logger = Logger("ICNForwarder", log_level) # packet encoder if encoder is None: self.encoder = () else: encoder.set_log_level(log_level) self.encoder = encoder # setup data structures synced_data_struct_factory = PiCNSyncDataStructFactory() synced_data_struct_factory.register("cs", ContentStoreMemoryExact) synced_data_struct_factory.register( "fib", ForwardingInformationBaseMemoryPrefix) synced_data_struct_factory.register("pit", PendingInterstTableMemoryExact) synced_data_struct_factory.register("face_id_table", FaceIDDict) synced_data_struct_factory.create_manager() cs = synced_data_struct_factory.manager.cs() fib = synced_data_struct_factory.manager.fib() pit = synced_data_struct_factory.manager.pit(pit_timeout=60) face_id_table = synced_data_struct_factory.manager.face_id_table() # default interface if interfaces is not None: self.interfaces = interfaces mgmt_port = port else: interfaces = [UDP4Interface(port)] mgmt_port = interfaces[0].get_port() # initialize layers self.link_layer = BasicLinkLayer(interfaces, face_id_table, log_level=log_level) self.packet_encoding_layer = HeartbeatPacketEncodingLayer( self.encoder, log_level=log_level) self.icn_layer = HeartbeatNetworkLayer(log_level=log_level) self.lstack: LayerStack = LayerStack( [self.icn_layer, self.packet_encoding_layer, self.link_layer]) self.icn_layer.cs = cs self.icn_layer.fib = fib self.icn_layer.pit = pit # mgmt self.mgmt = Mgmt(cs, fib, pit, self.link_layer, mgmt_port, self.stop_forwarder, log_level=log_level)