Example #1
0
class CcnRouter():
    
    def __init__(self, interfaces):
        self.ifaces = {}
        for i, iface in enumerate(interfaces):
            self.ifaces['int'+str(i)] = iface
        self.fib = FIB()
        
    def handlePacket(self,pack):
        if pack.isInterest:
            iface = self.fib.getIface(pack.contentName)
            log.msg('Sending ' + pack.contentName + ' to ' + iface)
            reactor.connectTCP(self.ifaces[iface].peerIP,self.ifaces[iface].peerPort,CcnRouterSendFactory(pack.toStr()))
        else:
            log.msg('Sending ' + pack.contentName + ' to int0')
            reactor.connectTCP(self.ifaces['int0'].peerIP,self.ifaces['int0'].peerPort,CcnRouterSendFactory(pack.toStr()))
            
        
            
    def run(self):
        self._listen()
        reactor.run()
Example #2
0
 def __init__(self, interfaces):
     self.ifaces = {}
     for i, iface in enumerate(interfaces):
         self.ifaces['int'+str(i)] = iface
     self.fib = FIB()