From b8b78310fdfb840ff5bf4072c0c2fdf2e6285ccd Mon Sep 17 00:00:00 2001 From: Dan Barrett Date: Tue, 5 Aug 2014 17:14:24 -0400 Subject: [PATCH 001/116] Update README.md --- README.md | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/README.md b/README.md index 10a06630c..7283001e2 100644 --- a/README.md +++ b/README.md @@ -30,10 +30,7 @@ of new XIA releases and events. This list is open to everyone. Related Projects ---------------- - [Native Linux kernel implementation of XIA](https://github.com/AltraMayor/XIA-for-Linux) -- XIA Wireshark plugin - * [Source](https://github.com/cjdoucette/wireshark-xia) - * [32 bit debian packages](https://github.com/cjdoucette/wireshark-xia-pkg-i386) - * [64 bit debian packages](https://github.com/cjdoucette/wireshark-xia-pkg) +- [XIA Wireshark plugin](https://github.com/AltraMayor/XIA-for-Linux/wiki/Debugging-the-Linux-kernel#Wireshark_with_XIA_support) Release 1.1.1 ---------------- From 0eeeb9add049ef8294a82424e392ebc75a806126 Mon Sep 17 00:00:00 2001 From: Rui Meireles Date: Fri, 4 Dec 2015 15:14:05 -0500 Subject: [PATCH 002/116] Inconsequential change just to test permissions --- Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Makefile b/Makefile index 43b51372a..66deb751b 100644 --- a/Makefile +++ b/Makefile @@ -1,4 +1,4 @@ -ifeq ($(wildcard xia.mk),) +ifeq ($(wildcard xia.mk),) $(error You must run configure first) else include xia.mk From 22ba7b1b8b1e810a6a580bf4e029b05805901ff1 Mon Sep 17 00:00:00 2001 From: Rui Meireles Date: Fri, 4 Dec 2015 15:15:04 -0500 Subject: [PATCH 003/116] Revert "Inconsequential change just to test permissions" This reverts commit 0eeeb9add049ef8294a82424e392ebc75a806126. --- Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Makefile b/Makefile index 66deb751b..43b51372a 100644 --- a/Makefile +++ b/Makefile @@ -1,4 +1,4 @@ -ifeq ($(wildcard xia.mk),) +ifeq ($(wildcard xia.mk),) $(error You must run configure first) else include xia.mk From d2b0fc0b6928a21a53a0ca2b0eb219a6fd5f13c0 Mon Sep 17 00:00:00 2001 From: drbarrett Date: Wed, 24 Feb 2016 15:34:23 -0500 Subject: [PATCH 004/116] WOW is this an old bug! How did we not notice this for all these years? --- api/xsocket/Xinit.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/api/xsocket/Xinit.c b/api/xsocket/Xinit.c index e34eb455b..d46026ead 100644 --- a/api/xsocket/Xinit.c +++ b/api/xsocket/Xinit.c @@ -183,8 +183,8 @@ __InitXSocket::__InitXSocket() snprintf(__XSocketConf::master_conf, BUF_SIZE, "%s%s", XrootDir(root, BUF_SIZE), "/etc/xsockconf.ini"); if ((rc = readlink("/proc/self/exe", buf, sizeof(buf) - 1)) != -1) { - section_name = basename(buf); buf[rc] = 0; + section_name = basename(buf); } const char * section_name_env = getenv("XSOCKCONF_SECTION"); From 81946236cbb05be734aeacba175ce096f927dfad Mon Sep 17 00:00:00 2001 From: mirrorZ Date: Mon, 14 Oct 2019 23:19:30 -0400 Subject: [PATCH 005/116] exp files --- tools/overlay/client.conf | 7 + tools/overlay/clientconfig.proto | 14 ++ tools/overlay/configurer.cpp | 62 +++++++++ tools/overlay/demo.conf | 17 ++- tools/overlay/xiaclientconfigurator.py | 37 +++++ tools/overlay/xiaclienthelper.py | 182 +++++++++++++++++++++++++ tools/overlay/xiaconfighelper.py | 14 ++ tools/overlay/xiaconfigurator.py | 25 ++++ 8 files changed, 349 insertions(+), 9 deletions(-) create mode 100644 tools/overlay/client.conf create mode 100644 tools/overlay/clientconfig.proto create mode 100644 tools/overlay/configurer.cpp create mode 100644 tools/overlay/xiaclientconfigurator.py create mode 100644 tools/overlay/xiaclienthelper.py diff --git a/tools/overlay/client.conf b/tools/overlay/client.conf new file mode 100644 index 000000000..568ed237e --- /dev/null +++ b/tools/overlay/client.conf @@ -0,0 +1,7 @@ +[c1] +Routers = r1, r2 +Default = r2 + +[c2] +Routers = r1 +Default = r1 \ No newline at end of file diff --git a/tools/overlay/clientconfig.proto b/tools/overlay/clientconfig.proto new file mode 100644 index 000000000..c87137855 --- /dev/null +++ b/tools/overlay/clientconfig.proto @@ -0,0 +1,14 @@ +syntax = "proto2"; + +package clientconfig; + +message Config { + message RouterInfo { + required string name = 1; + required string ipaddr = 2; + required string port = 3; + required string AD = 4; + required string HID = 5; + } +} + diff --git a/tools/overlay/configurer.cpp b/tools/overlay/configurer.cpp new file mode 100644 index 000000000..3f8b12d18 --- /dev/null +++ b/tools/overlay/configurer.cpp @@ -0,0 +1,62 @@ +#define CONFFILE "local.conf" +#define THEIR_ADDR "THEIR_ADDR" // The THEIR_ADDR entry in config file +#define CLIENT_AID "CLIENT_AID" // The CLIENT_AID entry in config file +#define SERVER_AID "SERVER_AID" // The SERVER_AID entry in config file +#define TICKET_STORE "TICKET_STORE" + + +// create port + + +void getmy_dag(GraphPtr mydag) { + + // bind on config port + + // set up tcp connection and send ping to configurator + + // listen for config string + + // fill mydag + + // connect to the xia router from the dag + + // spin up a thread to listen for future update + +} + +void update_mydag(GraphPtr mydag, socket config_socket) { + + // listen + + // data + + // bind socket + + // make connection + + // update mydag + + // clean up the old connection +} + +auto conf = LocalConfig::get_instance(CONFFILE); + auto server_addr = conf.get(THEIR_ADDR); + auto server_aid = conf.get(SERVER_AID); + auto client_aid = conf.get(CLIENT_AID); + const auto ticket_store_filename = conf.get(TICKET_STORE); + GraphPtr mydag; + sockaddr_x my_address; + int my_addrlen; + + +// A socket to talk to server on + //sockfd = socket(server_address.ss_family, SOCK_DGRAM, IPPROTO_UDP); + sockfd = picoquic_xia_open_server_socket(client_aid.c_str(), mydag); + if(sockfd == INVALID_SOCKET) { + goto client_done; + } + std::cout << "CLIENTADDR: " << mydag->dag_string() << std::endl; + mydag->fill_sockaddr(&my_address); + my_addrlen = sizeof(sockaddr_x); + printf("Created socket to talk to server\n"); + state = 1; // socket created \ No newline at end of file diff --git a/tools/overlay/demo.conf b/tools/overlay/demo.conf index 05ac2b52e..1f918da2b 100644 --- a/tools/overlay/demo.conf +++ b/tools/overlay/demo.conf @@ -1,13 +1,12 @@ [r1] -ControlAddress = 172.16.148.166 -Interfaces = ens33,ens38 -HostInterface = ens33 +ControlAddress = 127.0.0.1 +Interfaces = lo +HostInterface = lo NameServer = true -Route_r2 = ens38 -> ens33:r2 +Route_r2 = lo ->wlp1s0:r2 [r2] -ControlAddress = 172.16.252.131 -Interfaces = ens33,ens38 -HostInterface = ens38 -Route_r1 = ens33 -> ens38:r1 -Xcache = true +ControlAddress = 10.0.0.46 +Interfaces = wlp1s0 +HostInterface = wlp1s0 +Route_r1 = wlp1s0 ->lo:r1 \ No newline at end of file diff --git a/tools/overlay/xiaclientconfigurator.py b/tools/overlay/xiaclientconfigurator.py new file mode 100644 index 000000000..c08e23094 --- /dev/null +++ b/tools/overlay/xiaclientconfigurator.py @@ -0,0 +1,37 @@ + +from ConfigParser import RawConfigParser + +class XIAClientConfigReader: + def __init__(self, config_filename): + self.routers = {} + self.default_router = {} + + # Read in the config file + parser = RawConfigParser() + parser.read(config_filename) + + # Router names are the section names in the config file + clients = parser.sections() + if len(clients) == 0: + print "ERROR: No sections found in config file" + + # Read in info into our internal data structures + for client in clients: + + # Interface names for each router (comma separated list) + routers = parser.get(client, 'Routers') + routers = routers.replace(' ', '') + self.routers[client] = routers.split(',') + + self.default_router[client] = parser.get(client, 'Default') + + def clients(self): + return self.routers.keys() + + + +if __name__ == "__main__": + config = XIAClientConfigReader("client.conf") + for client in config.clients(): + print client + ':' + print config.routers[client] \ No newline at end of file diff --git a/tools/overlay/xiaclienthelper.py b/tools/overlay/xiaclienthelper.py new file mode 100644 index 000000000..8b6fd8176 --- /dev/null +++ b/tools/overlay/xiaclienthelper.py @@ -0,0 +1,182 @@ +# Python standard libraries +import os +import sys +import subprocess + +# Install python-twisted package for this functionality +from twisted.internet.protocol import Protocol, Factory +from twisted.protocols.basic import Int32StringReceiver +from twisted.internet import reactor + +# Bring in xia and overlay tools into path +srcdir = os.getcwd()[:os.getcwd().rindex('xia-core')+len('xia-core')] +sys.path.append(os.path.join(srcdir, 'bin')) +sys.path.append(os.path.join(srcdir, 'tools/overlay')) + +# XIA libraries +import xiapyutils +from clickcontrol import ClickControl + +# XIA Overlay configuration libraries and definitions +import configrequest_pb2 +import xiaconfigdefs +from xiaconfigdefs import ROUTER_CLICK + +import interfaces + +picoquic_directory = "../picoquic" + +class Helper(Int32StringReceiver): + def __init__(self, common_data, addr): + self.common_data = common_data + self.addr = addr + + def connectionMade(self): + self.sendString(xiaconfigdefs.HELPER_GREETING); + + def connectionLost(self, reason): + # Clean up any state created in common_data for this connection + print "Connection to client lost" + + def handleInterfaceRequest(self, request): + print "Got interface request" + + # Fill in interface information + for if_info in request.ifrequest.interfaces: + if_info.ipaddr = interfaces.get_ip_addr(if_info.name) + if_info.macaddr = interfaces.get_mac_addr(if_info.name) + + # Send the if_request back to the requestor + self.sendString(request.SerializeToString()) + + def handleRouterConfRequest(self, request): + conf_file = os.path.join(xiapyutils.xia_srcdir(), ROUTER_CLICK) + with open(conf_file, 'w') as config: + config.write(request.routerconf.configfile) + #print "Got router.click file:\n-----------------------" + #print request.routerconf.configfile + #print "---------------------------" + response = configrequest_pb2.Request() + response.type = configrequest_pb2.Request.ROUTER_CONF + self.sendString(response.SerializeToString()) + + def handleRoutesRequest(self, request): + print "Got IP routes to configure" + for route_cmd in request.routes.route_cmds: + print route_cmd + subprocess.check_call(route_cmd, shell=True) + request.routes.result = True + self.sendString(request.SerializeToString()) + + def getXcacheAID(self): + with open("xcache.local.conf", 'r') as localconf: + for line in localconf: + if not line.startswith('XCACHE_AID'): + continue + param, aid = line.strip().split('=') + print "Xcache XID", aid + return aid + print "ERROR getting XcacheAID" + print "must call from picoquic dir and have xcache.local.conf" + return '' + + def registerXcache(self, hostname, aid): + print "Confighelper: registering Xcache" + with ClickControl() as click: + return click.assignXcacheAID(hostname, aid) + + def handleStartXcacheRequest(self, request): + print "Got request to start Xcache", request.startxcache.command + cwd = os.getcwd() + os.chdir(picoquic_directory) + subprocess.check_call(request.startxcache.command, shell=True) + aid = self.getXcacheAID() + os.chdir(cwd) + hostname = request.startxcache.hostname + request.startxcache.result = self.registerXcache(hostname, aid) + self.sendString(request.SerializeToString()) + + # If the request came without a resolv.conf, this router is a nameserver + # and a new resolv.conf file will be sent back in response + # + # Otherwise, this is a regular router that will be started with the + # given resolv.conf file. Response will not have a resolv.conf + def handleStartXIARequest(self, request): + resolvconfreceived = False + # If a resolv.conf was sent, write it to storage for router to use + if len(request.startxia.resolvconf) > 0: + resolvconffile = os.path.join(xiapyutils.xia_srcdir(), + 'etc/resolv.conf') + print 'Writing:', resolvconffile + with open(resolvconffile, 'w') as resolvconf: + resolvconf.write(request.startxia.resolvconf) + resolvconfreceived = True + + print "Got request to restart XIA:", request.startxia.command + stopcmd = request.startxia.command.replace("restart", "stop") + startcmd = request.startxia.command.replace("restart", "start") + + print "Stopping XIA:", stopcmd + subprocess.call(stopcmd, shell=True) + + print "Starting XIA:", startcmd + subprocess.check_call(startcmd, shell=True) + + # We're done starting a non-nameserver router + if resolvconfreceived: + response = configrequest_pb2.Request() + response.type = configrequest_pb2.Request.START_XIA + self.sendString(response.SerializeToString()) + return + + # Send resolv.conf from the nameserver back for other routers to use + conffile = os.path.join(xiapyutils.xia_srcdir(), 'etc/resolv.conf') + with open(conffile, 'r') as resolvconf: + request.startxia.resolvconf = resolvconf.read() + self.sendString(request.SerializeToString()) + + def handleGatherXIDsRequest(self, request): + xdag_cmd = os.path.join(xiapyutils.xia_srcdir(), 'bin/xdag') + xdag_out = subprocess.check_output(xdag_cmd, shell=True) + router, re, ad, hid = xdag_out.split() + request.gatherxids.ad = ad + request.gatherxids.hid = hid + self.sendString(request.SerializeToString()) + + def handleConfigRequest(self, request): + if request.type == configrequest_pb2.Request.IFACE_INFO: + self.handleInterfaceRequest(request) + elif request.type == configrequest_pb2.Request.ROUTER_CONF: + self.handleRouterConfRequest(request) + elif request.type == configrequest_pb2.Request.IP_ROUTES: + self.handleRoutesRequest(request) + elif request.type == configrequest_pb2.Request.START_XIA: + self.handleStartXIARequest(request) + elif request.type == configrequest_pb2.Request.GATHER_XIDS: + self.handleGatherXIDsRequest(request) + elif request.type == configrequest_pb2.Request.START_XCACHE: + self.handleStartXcacheRequest(request) + else: + print "ERROR: Unknown config request" + + def stringReceived(self, request): + #try: + # Convert request into protobuf and handle the request + conf_request = configrequest_pb2.Request() + conf_request.ParseFromString(request) + self.handleConfigRequest(conf_request); + #except: + #print "ERROR: invalid data instead of request" + #self.transport.loseConnection(); + +class HelperFactory(Factory): + + def __init__(self): + self.common_data = {} + + def buildProtocol(self, addr): + return Helper(self.common_data, addr) + +# Run helper service +reactor.listenTCP(xiaconfigdefs.HELPER_PORT, HelperFactory()) +reactor.run() diff --git a/tools/overlay/xiaconfighelper.py b/tools/overlay/xiaconfighelper.py index 8b6fd8176..591dca988 100644 --- a/tools/overlay/xiaconfighelper.py +++ b/tools/overlay/xiaconfighelper.py @@ -2,6 +2,7 @@ import os import sys import subprocess +import inspect # Install python-twisted package for this functionality from twisted.internet.protocol import Protocol, Factory @@ -28,17 +29,21 @@ class Helper(Int32StringReceiver): def __init__(self, common_data, addr): + print inspect.stack()[0][3] self.common_data = common_data self.addr = addr def connectionMade(self): + print inspect.stack()[0][3] self.sendString(xiaconfigdefs.HELPER_GREETING); def connectionLost(self, reason): + print inspect.stack()[0][3] # Clean up any state created in common_data for this connection print "Connection to client lost" def handleInterfaceRequest(self, request): + print inspect.stack()[0][3] print "Got interface request" # Fill in interface information @@ -50,6 +55,7 @@ def handleInterfaceRequest(self, request): self.sendString(request.SerializeToString()) def handleRouterConfRequest(self, request): + print inspect.stack()[0][3] conf_file = os.path.join(xiapyutils.xia_srcdir(), ROUTER_CLICK) with open(conf_file, 'w') as config: config.write(request.routerconf.configfile) @@ -61,6 +67,7 @@ def handleRouterConfRequest(self, request): self.sendString(response.SerializeToString()) def handleRoutesRequest(self, request): + print inspect.stack()[0][3] print "Got IP routes to configure" for route_cmd in request.routes.route_cmds: print route_cmd @@ -69,6 +76,7 @@ def handleRoutesRequest(self, request): self.sendString(request.SerializeToString()) def getXcacheAID(self): + print inspect.stack()[0][3] with open("xcache.local.conf", 'r') as localconf: for line in localconf: if not line.startswith('XCACHE_AID'): @@ -81,11 +89,13 @@ def getXcacheAID(self): return '' def registerXcache(self, hostname, aid): + print inspect.stack()[0][3] print "Confighelper: registering Xcache" with ClickControl() as click: return click.assignXcacheAID(hostname, aid) def handleStartXcacheRequest(self, request): + print inspect.stack()[0][3] print "Got request to start Xcache", request.startxcache.command cwd = os.getcwd() os.chdir(picoquic_directory) @@ -102,6 +112,7 @@ def handleStartXcacheRequest(self, request): # Otherwise, this is a regular router that will be started with the # given resolv.conf file. Response will not have a resolv.conf def handleStartXIARequest(self, request): + print inspect.stack()[0][3] resolvconfreceived = False # If a resolv.conf was sent, write it to storage for router to use if len(request.startxia.resolvconf) > 0: @@ -136,6 +147,7 @@ def handleStartXIARequest(self, request): self.sendString(request.SerializeToString()) def handleGatherXIDsRequest(self, request): + print inspect.stack()[0][3] xdag_cmd = os.path.join(xiapyutils.xia_srcdir(), 'bin/xdag') xdag_out = subprocess.check_output(xdag_cmd, shell=True) router, re, ad, hid = xdag_out.split() @@ -144,6 +156,7 @@ def handleGatherXIDsRequest(self, request): self.sendString(request.SerializeToString()) def handleConfigRequest(self, request): + print inspect.stack()[0][3] if request.type == configrequest_pb2.Request.IFACE_INFO: self.handleInterfaceRequest(request) elif request.type == configrequest_pb2.Request.ROUTER_CONF: @@ -160,6 +173,7 @@ def handleConfigRequest(self, request): print "ERROR: Unknown config request" def stringReceived(self, request): + print inspect.stack()[0][3] #try: # Convert request into protobuf and handle the request conf_request = configrequest_pb2.Request() diff --git a/tools/overlay/xiaconfigurator.py b/tools/overlay/xiaconfigurator.py index ddf648108..42762031c 100644 --- a/tools/overlay/xiaconfigurator.py +++ b/tools/overlay/xiaconfigurator.py @@ -30,19 +30,24 @@ from xiaconfigreader import XIAConfigReader from routerclick import RouterClick +import inspect + class ConfigClient(Int32StringReceiver): def __init__(self, router, configurator, xid_wait): + print inspect.stack()[0][3] self.router = router self.configurator = configurator self.initialized = False self.xid_wait = xid_wait def connectionLost(self, reason): + print inspect.stack()[0][3] self.configurator.protocol_instances.remove(self) if len(self.configurator.protocol_instances) == 0: reactor.stop() def stringReceived(self, data): + print inspect.stack()[0][3] if not self.initialized: # Get greeting from server and send a request for interfaces if data == "Helper Ready": @@ -80,6 +85,7 @@ def stringReceived(self, data): def handleInterfaceInfoResponse(self, response): # Got interface information + print inspect.stack()[0][3] print "Got interface info for:", self.router if response.type != configrequest_pb2.Request.IFACE_INFO: print "ERROR: Invalid response to iface_info request" @@ -101,6 +107,7 @@ def handleInterfaceInfoResponse(self, response): self.sendString(request.SerializeToString()) def waitForResolvConf(self): + print inspect.stack()[0][3] if len(self.configurator.resolvconf) == 0: reactor.callLater(0.1, self.waitForResolvConf) else: @@ -112,6 +119,7 @@ def waitForResolvConf(self): self.sendString(request.SerializeToString()) def handleRouterConfResponse(self, response): + print inspect.stack()[0][3] # The router.click was successfully deployed if response.type != configrequest_pb2.Request.ROUTER_CONF: print "ERROR: Invalid router config response" @@ -134,6 +142,7 @@ def handleRouterConfResponse(self, response): # commands to start XIA on other routers with that file def handleStartXIAResponse(self, response): # Will have resolvconf field if nameserver started + print inspect.stack()[0][3] if response.type != configrequest_pb2.Request.START_XIA: print "ERROR: Invalid start XIA response" self.transport.loseConnection() @@ -151,6 +160,7 @@ def handleStartXIAResponse(self, response): self.sendString(request.SerializeToString()) def sendIPRoutesRequest(self): + print inspect.stack()[0][3] request = configrequest_pb2.Request() request.type = configrequest_pb2.Request.IP_ROUTES @@ -179,6 +189,7 @@ def sendIPRoutesRequest(self): self.sendString(request.SerializeToString()) def handleIPRoutesResponse(self, response): + print inspect.stack()[0][3] if response.type != configrequest_pb2.Request.IP_ROUTES: print "ERROR: Invalid IP route config response" self.transport.loseConnection() @@ -200,6 +211,7 @@ def handleIPRoutesResponse(self, response): self.transport.loseConnection() def handleStartXcacheResponse(self, response): + print inspect.stack()[0][3] if response.type != configrequest_pb2.Request.START_XCACHE: print "ERROR: Failed to start Xcache on", self.router self.transport.loseConnection() @@ -211,6 +223,7 @@ def handleStartXcacheResponse(self, response): self.transport.loseConnection() def handleGatherXIDsResponse(self, response): + print inspect.stack()[0][3] if response.type != configrequest_pb2.Request.GATHER_XIDS: print "ERROR: Invalid gather XIDs response" self.transport.loseConnection() @@ -222,6 +235,7 @@ def handleGatherXIDsResponse(self, response): class XIAConfigurator: def __init__(self, config): + print inspect.stack()[0][3] self.config = config self.protocol_instances = [] self.nameserver = self.config.nameserver @@ -238,6 +252,7 @@ def __init__(self, config): # All routers sent in their AD, HID. Send IP routes to all routers def sendIPRoutes(self, result): + print inspect.stack()[0][3] for (success, protocol) in result: if success: print "Sending IP routes to {}".format(protocol.router) @@ -246,9 +261,11 @@ def sendIPRoutes(self, result): print "ERROR: failure sending IP routes for a protocol" def gotProtocol(self, protocol): + print inspect.stack()[0][3] self.protocol_instances.append(protocol) def configure(self): + print inspect.stack()[0][3] xid_waiters = [] for router in self.config.routers(): @@ -276,3 +293,11 @@ def configure(self): config = XIAConfigReader(conf_file) configurator = XIAConfigurator(config) configurator.configure() + clientConfig = XIAClientConfigReader(client.conf) + + + clientConfig = XIAClientConfigReader("client.conf") + for client in clientConfig.clients(): + print client + ':' + for router in clientConfig.routers[client]: + print configurator.xids[router] From 0b62920a2d2668ae9d86b84e6e045d6cd738161f Mon Sep 17 00:00:00 2001 From: mirrorZ Date: Tue, 15 Oct 2019 05:07:32 +0000 Subject: [PATCH 006/116] class name fixes --- tools/overlay/client.conf | 4 ++-- tools/overlay/demo.conf | 20 ++++++++++--------- ...nfigurator.py => xiaclientconfigreader.py} | 0 tools/overlay/xiaconfigurator.py | 13 ++++++------ 4 files changed, 20 insertions(+), 17 deletions(-) rename tools/overlay/{xiaclientconfigurator.py => xiaclientconfigreader.py} (100%) diff --git a/tools/overlay/client.conf b/tools/overlay/client.conf index 568ed237e..816ba55d3 100644 --- a/tools/overlay/client.conf +++ b/tools/overlay/client.conf @@ -1,6 +1,6 @@ [c1] -Routers = r1, r2 -Default = r2 +Routers = r1 +Default = r1 [c2] Routers = r1 diff --git a/tools/overlay/demo.conf b/tools/overlay/demo.conf index 1f918da2b..f4051d1fc 100644 --- a/tools/overlay/demo.conf +++ b/tools/overlay/demo.conf @@ -1,12 +1,14 @@ [r1] -ControlAddress = 127.0.0.1 -Interfaces = lo -HostInterface = lo +ControlAddress = 10.0.5.130 +Interfaces = ens34,ens39 +HostInterface = ens34 NameServer = true -Route_r2 = lo ->wlp1s0:r2 +#Route_r2 = ens39 -> ens34:r2 + +# [r2] +# ControlAddress = 10.0.5.128 +# Interfaces = ens34,ens38 +# HostInterface = ens34 +# Route_r1 = ens34 -> ens39:r1 +# Xcache = true -[r2] -ControlAddress = 10.0.0.46 -Interfaces = wlp1s0 -HostInterface = wlp1s0 -Route_r1 = wlp1s0 ->lo:r1 \ No newline at end of file diff --git a/tools/overlay/xiaclientconfigurator.py b/tools/overlay/xiaclientconfigreader.py similarity index 100% rename from tools/overlay/xiaclientconfigurator.py rename to tools/overlay/xiaclientconfigreader.py diff --git a/tools/overlay/xiaconfigurator.py b/tools/overlay/xiaconfigurator.py index 42762031c..e13e7c07c 100644 --- a/tools/overlay/xiaconfigurator.py +++ b/tools/overlay/xiaconfigurator.py @@ -28,11 +28,12 @@ import configrequest_pb2 from xiaconfigreader import XIAConfigReader +from xiaclientconfigreader import XIAClientConfigReader from routerclick import RouterClick import inspect -class ConfigClient(Int32StringReceiver): +class ConfigRouter(Int32StringReceiver): def __init__(self, router, configurator, xid_wait): print inspect.stack()[0][3] self.router = router @@ -278,8 +279,8 @@ def configure(self): xid_wait = defer.Deferred() xid_waiters.append(xid_wait) - # Link ConfigClient protocol instance to endpoint - d = connectProtocol(endpoint, ConfigClient(router, self, xid_wait)) + # Link ConfigRouter protocol instance to endpoint + d = connectProtocol(endpoint, ConfigRouter(router, self, xid_wait)) d.addCallback(self.gotProtocol) # Callback called, when all routers have collected their XIDs @@ -293,10 +294,10 @@ def configure(self): config = XIAConfigReader(conf_file) configurator = XIAConfigurator(config) configurator.configure() - clientConfig = XIAClientConfigReader(client.conf) - - clientConfig = XIAClientConfigReader("client.conf") + print "===============================================================" + + clientConfig = XIAClientConfigReader('tools/overlay/client.conf') for client in clientConfig.clients(): print client + ':' for router in clientConfig.routers[client]: From e2dc9cb4fddec097e5fd9c0fd12b4236878e4435 Mon Sep 17 00:00:00 2001 From: mirrorZ Date: Tue, 15 Oct 2019 12:25:35 -0400 Subject: [PATCH 007/116] wip --- tools/overlay/client.conf | 4 +++ tools/overlay/clientconfig.proto | 3 ++ tools/overlay/xiaclientconfigreader.py | 4 +++ tools/overlay/xiaconfigurator.py | 44 ++++++++++++++++++++++++++ 4 files changed, 55 insertions(+) diff --git a/tools/overlay/client.conf b/tools/overlay/client.conf index 816ba55d3..7c28116fe 100644 --- a/tools/overlay/client.conf +++ b/tools/overlay/client.conf @@ -1,7 +1,11 @@ [c1] +ControlAddress = 10.0.1.128 +ControlPort = 8750 Routers = r1 Default = r1 [c2] +ControlAddress = 10.0.2.129 +ControlPort = 8750 Routers = r1 Default = r1 \ No newline at end of file diff --git a/tools/overlay/clientconfig.proto b/tools/overlay/clientconfig.proto index c87137855..57474afe9 100644 --- a/tools/overlay/clientconfig.proto +++ b/tools/overlay/clientconfig.proto @@ -3,6 +3,9 @@ syntax = "proto2"; package clientconfig; message Config { + enum RequestType { + CLIENT_CONFIG = 0; + } message RouterInfo { required string name = 1; required string ipaddr = 2; diff --git a/tools/overlay/xiaclientconfigreader.py b/tools/overlay/xiaclientconfigreader.py index c08e23094..80eabacb4 100644 --- a/tools/overlay/xiaclientconfigreader.py +++ b/tools/overlay/xiaclientconfigreader.py @@ -5,6 +5,8 @@ class XIAClientConfigReader: def __init__(self, config_filename): self.routers = {} self.default_router = {} + self.control_addr = {} + self.control_port = {} # Read in the config file parser = RawConfigParser() @@ -24,6 +26,8 @@ def __init__(self, config_filename): self.routers[client] = routers.split(',') self.default_router[client] = parser.get(client, 'Default') + self.control_addr[client] = parser.get(client, 'ControlAddress') + self.control_port[client] = parser.get(client, 'ControlPort') def clients(self): return self.routers.keys() diff --git a/tools/overlay/xiaconfigurator.py b/tools/overlay/xiaconfigurator.py index e13e7c07c..4497fd608 100644 --- a/tools/overlay/xiaconfigurator.py +++ b/tools/overlay/xiaconfigurator.py @@ -26,6 +26,7 @@ import xiaconfigdefs import configrequest_pb2 +import clientconfig_pb2 from xiaconfigreader import XIAConfigReader from xiaclientconfigreader import XIAClientConfigReader @@ -234,6 +235,31 @@ def handleGatherXIDsResponse(self, response): self.configurator.xids[self.router] = (ad, hid) self.xid_wait.callback(self) +class ConfigClient(Int32StringReceiver): + def __init__(self, client, configurator): + print inspect.stack()[0][3] + self.client = client + self.configurator = configurator + + def connectionLost(self, reason): + self.configurator.connected_clients.remove(self) + if len(self.configurator.connected_clients) == 0 + reactor.stop() + + def connectionMade(self): + self.sendConfig() + + def sendConfig(self): + response = clientconfig_pb2.Config() + response.type = clientconfig_pb2.Config.CLIENT_CONFIG + response.name = self.client + response.router_addr = self.default_router + response.AD = self.ad + response.HID = self.hid + + self.sendString(response.SerializeToString()) + + class XIAConfigurator: def __init__(self, config): print inspect.stack()[0][3] @@ -243,6 +269,7 @@ def __init__(self, config): self.resolvconf = "" self.xids = {} # router: (ad, hid) self.iface_addrs = {} # (router, iface_name) : ipaddr + self.connected_clients = [] print self.nameserver, 'is the nameserver' print 'Here are the routers we know of' @@ -289,6 +316,21 @@ def configure(self): reactor.run() + def addClient(self, client): + self.connected_clients.append(client) + + def configureClient(self, clientConfig): + for client in clientConfig.clients(): + endpoint = TCP4ClientEndpoint(reactor, + clientConfig.control_addr(client), + clientConfig.control_port(client)) + + d = connectProtocol(endpoint, ConfigClient(client, self, )) + d.addCallback(self.addClient) + + reactor.run() + + if __name__ == "__main__": conf_file = os.path.join(xiapyutils.xia_srcdir(), 'tools/overlay/demo.conf') config = XIAConfigReader(conf_file) @@ -301,4 +343,6 @@ def configure(self): for client in clientConfig.clients(): print client + ':' for router in clientConfig.routers[client]: + clientConfig.ad[client] = configurator.xids[router][0] + clientConfig.hid[client] = configurator.xids[router][1] print configurator.xids[router] From 784b5fe465012e02b4e5862300c701acc679730d Mon Sep 17 00:00:00 2001 From: mirrorZ Date: Wed, 16 Oct 2019 22:40:53 -0400 Subject: [PATCH 008/116] Add client helper tester --- tools/overlay/client.conf | 4 +- tools/overlay/xiaclienthelper.py | 151 +++---------------------------- 2 files changed, 15 insertions(+), 140 deletions(-) diff --git a/tools/overlay/client.conf b/tools/overlay/client.conf index 7c28116fe..5aae3fdf9 100644 --- a/tools/overlay/client.conf +++ b/tools/overlay/client.conf @@ -1,11 +1,11 @@ [c1] ControlAddress = 10.0.1.128 -ControlPort = 8750 +ControlPort = 8295 Routers = r1 Default = r1 [c2] ControlAddress = 10.0.2.129 -ControlPort = 8750 +ControlPort = 8295 Routers = r1 Default = r1 \ No newline at end of file diff --git a/tools/overlay/xiaclienthelper.py b/tools/overlay/xiaclienthelper.py index 8b6fd8176..069a3534c 100644 --- a/tools/overlay/xiaclienthelper.py +++ b/tools/overlay/xiaclienthelper.py @@ -2,6 +2,7 @@ import os import sys import subprocess +import inspect # Install python-twisted package for this functionality from twisted.internet.protocol import Protocol, Factory @@ -15,12 +16,9 @@ # XIA libraries import xiapyutils -from clickcontrol import ClickControl # XIA Overlay configuration libraries and definitions -import configrequest_pb2 -import xiaconfigdefs -from xiaconfigdefs import ROUTER_CLICK +import clientconfig_pb2 import interfaces @@ -28,146 +26,23 @@ class Helper(Int32StringReceiver): def __init__(self, common_data, addr): + print inspect.stack()[0][3] self.common_data = common_data self.addr = addr - def connectionMade(self): - self.sendString(xiaconfigdefs.HELPER_GREETING); - def connectionLost(self, reason): + print inspect.stack()[0][3] # Clean up any state created in common_data for this connection print "Connection to client lost" - def handleInterfaceRequest(self, request): - print "Got interface request" - - # Fill in interface information - for if_info in request.ifrequest.interfaces: - if_info.ipaddr = interfaces.get_ip_addr(if_info.name) - if_info.macaddr = interfaces.get_mac_addr(if_info.name) - - # Send the if_request back to the requestor - self.sendString(request.SerializeToString()) - - def handleRouterConfRequest(self, request): - conf_file = os.path.join(xiapyutils.xia_srcdir(), ROUTER_CLICK) - with open(conf_file, 'w') as config: - config.write(request.routerconf.configfile) - #print "Got router.click file:\n-----------------------" - #print request.routerconf.configfile - #print "---------------------------" - response = configrequest_pb2.Request() - response.type = configrequest_pb2.Request.ROUTER_CONF - self.sendString(response.SerializeToString()) - - def handleRoutesRequest(self, request): - print "Got IP routes to configure" - for route_cmd in request.routes.route_cmds: - print route_cmd - subprocess.check_call(route_cmd, shell=True) - request.routes.result = True - self.sendString(request.SerializeToString()) - - def getXcacheAID(self): - with open("xcache.local.conf", 'r') as localconf: - for line in localconf: - if not line.startswith('XCACHE_AID'): - continue - param, aid = line.strip().split('=') - print "Xcache XID", aid - return aid - print "ERROR getting XcacheAID" - print "must call from picoquic dir and have xcache.local.conf" - return '' - - def registerXcache(self, hostname, aid): - print "Confighelper: registering Xcache" - with ClickControl() as click: - return click.assignXcacheAID(hostname, aid) - - def handleStartXcacheRequest(self, request): - print "Got request to start Xcache", request.startxcache.command - cwd = os.getcwd() - os.chdir(picoquic_directory) - subprocess.check_call(request.startxcache.command, shell=True) - aid = self.getXcacheAID() - os.chdir(cwd) - hostname = request.startxcache.hostname - request.startxcache.result = self.registerXcache(hostname, aid) - self.sendString(request.SerializeToString()) - - # If the request came without a resolv.conf, this router is a nameserver - # and a new resolv.conf file will be sent back in response - # - # Otherwise, this is a regular router that will be started with the - # given resolv.conf file. Response will not have a resolv.conf - def handleStartXIARequest(self, request): - resolvconfreceived = False - # If a resolv.conf was sent, write it to storage for router to use - if len(request.startxia.resolvconf) > 0: - resolvconffile = os.path.join(xiapyutils.xia_srcdir(), - 'etc/resolv.conf') - print 'Writing:', resolvconffile - with open(resolvconffile, 'w') as resolvconf: - resolvconf.write(request.startxia.resolvconf) - resolvconfreceived = True - - print "Got request to restart XIA:", request.startxia.command - stopcmd = request.startxia.command.replace("restart", "stop") - startcmd = request.startxia.command.replace("restart", "start") - - print "Stopping XIA:", stopcmd - subprocess.call(stopcmd, shell=True) - - print "Starting XIA:", startcmd - subprocess.check_call(startcmd, shell=True) - - # We're done starting a non-nameserver router - if resolvconfreceived: - response = configrequest_pb2.Request() - response.type = configrequest_pb2.Request.START_XIA - self.sendString(response.SerializeToString()) - return - - # Send resolv.conf from the nameserver back for other routers to use - conffile = os.path.join(xiapyutils.xia_srcdir(), 'etc/resolv.conf') - with open(conffile, 'r') as resolvconf: - request.startxia.resolvconf = resolvconf.read() - self.sendString(request.SerializeToString()) - - def handleGatherXIDsRequest(self, request): - xdag_cmd = os.path.join(xiapyutils.xia_srcdir(), 'bin/xdag') - xdag_out = subprocess.check_output(xdag_cmd, shell=True) - router, re, ad, hid = xdag_out.split() - request.gatherxids.ad = ad - request.gatherxids.hid = hid - self.sendString(request.SerializeToString()) - - def handleConfigRequest(self, request): - if request.type == configrequest_pb2.Request.IFACE_INFO: - self.handleInterfaceRequest(request) - elif request.type == configrequest_pb2.Request.ROUTER_CONF: - self.handleRouterConfRequest(request) - elif request.type == configrequest_pb2.Request.IP_ROUTES: - self.handleRoutesRequest(request) - elif request.type == configrequest_pb2.Request.START_XIA: - self.handleStartXIARequest(request) - elif request.type == configrequest_pb2.Request.GATHER_XIDS: - self.handleGatherXIDsRequest(request) - elif request.type == configrequest_pb2.Request.START_XCACHE: - self.handleStartXcacheRequest(request) - else: - print "ERROR: Unknown config request" + def stringReceived(self, recvd_conf): + print inspect.stack()[0][3] + conf = clientconfig_pb2.ClientConfig() + conf.ParseFromString(recvd_conf) + self.handleConfig(conf) - def stringReceived(self, request): - #try: - # Convert request into protobuf and handle the request - conf_request = configrequest_pb2.Request() - conf_request.ParseFromString(request) - self.handleConfigRequest(conf_request); - #except: - #print "ERROR: invalid data instead of request" - #self.transport.loseConnection(); + def handleConfig(self, config): + print config class HelperFactory(Factory): @@ -178,5 +53,5 @@ def buildProtocol(self, addr): return Helper(self.common_data, addr) # Run helper service -reactor.listenTCP(xiaconfigdefs.HELPER_PORT, HelperFactory()) -reactor.run() +reactor.listenTCP(8295, HelperFactory()) +reactor.run() \ No newline at end of file From a6c39984ff75ee540510d23e0d8c40812df77c56 Mon Sep 17 00:00:00 2001 From: mirrorZ Date: Thu, 17 Oct 2019 04:17:11 +0000 Subject: [PATCH 009/116] config update --- tools/overlay/client.conf | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/tools/overlay/client.conf b/tools/overlay/client.conf index 5aae3fdf9..e3d56a4b0 100644 --- a/tools/overlay/client.conf +++ b/tools/overlay/client.conf @@ -1,11 +1,11 @@ [c1] -ControlAddress = 10.0.1.128 +ControlAddress = 10.0.6.130 ControlPort = 8295 Routers = r1 Default = r1 -[c2] -ControlAddress = 10.0.2.129 -ControlPort = 8295 -Routers = r1 -Default = r1 \ No newline at end of file +# [c2] +# ControlAddress = 10.0.2.129 +# ControlPort = 8295 +# Routers = r1 +# Default = r1 \ No newline at end of file From 6b825f3622f460c1423a32573763fdf7e133d953 Mon Sep 17 00:00:00 2001 From: mirrorZ Date: Thu, 17 Oct 2019 06:00:29 +0000 Subject: [PATCH 010/116] fixes for the configurator --- tools/overlay/xiaclientconfigreader.py | 4 +++- tools/overlay/xiaconfigurator.py | 15 +++++++++------ 2 files changed, 12 insertions(+), 7 deletions(-) diff --git a/tools/overlay/xiaclientconfigreader.py b/tools/overlay/xiaclientconfigreader.py index 80eabacb4..c7ff263f4 100644 --- a/tools/overlay/xiaclientconfigreader.py +++ b/tools/overlay/xiaclientconfigreader.py @@ -7,6 +7,8 @@ def __init__(self, config_filename): self.default_router = {} self.control_addr = {} self.control_port = {} + self.ad = {} + self.hid = {} # Read in the config file parser = RawConfigParser() @@ -38,4 +40,4 @@ def clients(self): config = XIAClientConfigReader("client.conf") for client in config.clients(): print client + ':' - print config.routers[client] \ No newline at end of file + print config.routers[client] diff --git a/tools/overlay/xiaconfigurator.py b/tools/overlay/xiaconfigurator.py index 4497fd608..d6f5882fd 100644 --- a/tools/overlay/xiaconfigurator.py +++ b/tools/overlay/xiaconfigurator.py @@ -45,9 +45,8 @@ def __init__(self, router, configurator, xid_wait): def connectionLost(self, reason): print inspect.stack()[0][3] self.configurator.protocol_instances.remove(self) - if len(self.configurator.protocol_instances) == 0: + if len(self.configurator.protocol_instances) == 0: reactor.stop() - def stringReceived(self, data): print inspect.stack()[0][3] if not self.initialized: @@ -243,7 +242,7 @@ def __init__(self, client, configurator): def connectionLost(self, reason): self.configurator.connected_clients.remove(self) - if len(self.configurator.connected_clients) == 0 + if len(self.configurator.connected_clients) == 0: reactor.stop() def connectionMade(self): @@ -298,6 +297,7 @@ def configure(self): for router in self.config.routers(): # Endpoint for client connection + endpoint = TCP4ClientEndpoint(reactor, self.config.control_addr(router), xiaconfigdefs.HELPER_PORT) @@ -321,11 +321,12 @@ def addClient(self, client): def configureClient(self, clientConfig): for client in clientConfig.clients(): + endpoint = TCP4ClientEndpoint(reactor, - clientConfig.control_addr(client), - clientConfig.control_port(client)) + clientConfig.control_addr[client], + int(clientConfig.control_port[client])) - d = connectProtocol(endpoint, ConfigClient(client, self, )) + d = connectProtocol(endpoint, ConfigClient(client, self)) d.addCallback(self.addClient) reactor.run() @@ -346,3 +347,5 @@ def configureClient(self, clientConfig): clientConfig.ad[client] = configurator.xids[router][0] clientConfig.hid[client] = configurator.xids[router][1] print configurator.xids[router] + + configurator.configureClient(clientConfig) From 0fc5b045b939df8d733d7350a9e020943947f8ac Mon Sep 17 00:00:00 2001 From: mirrorZ Date: Thu, 17 Oct 2019 09:25:45 -0400 Subject: [PATCH 011/116] split into client configurator.py --- tools/overlay/xiaclientconfigreader.py | 4 +- tools/overlay/xiaclientconfigurator.py | 119 +++++++++++++++++++++++++ tools/overlay/xiaconfigurator.py | 53 +---------- 3 files changed, 124 insertions(+), 52 deletions(-) create mode 100644 tools/overlay/xiaclientconfigurator.py diff --git a/tools/overlay/xiaclientconfigreader.py b/tools/overlay/xiaclientconfigreader.py index c7ff263f4..4ca7021f4 100644 --- a/tools/overlay/xiaclientconfigreader.py +++ b/tools/overlay/xiaclientconfigreader.py @@ -1,4 +1,5 @@ + from ConfigParser import RawConfigParser class XIAClientConfigReader: @@ -17,7 +18,7 @@ def __init__(self, config_filename): # Router names are the section names in the config file clients = parser.sections() if len(clients) == 0: - print "ERROR: No sections found in config file" + print "ERROR: No sections found in config file" # Read in info into our internal data structures for client in clients: @@ -35,7 +36,6 @@ def clients(self): return self.routers.keys() - if __name__ == "__main__": config = XIAClientConfigReader("client.conf") for client in config.clients(): diff --git a/tools/overlay/xiaclientconfigurator.py b/tools/overlay/xiaclientconfigurator.py new file mode 100644 index 000000000..b08a87b16 --- /dev/null +++ b/tools/overlay/xiaclientconfigurator.py @@ -0,0 +1,119 @@ + +# XIA network configuration service + +# Starts with a config file with format: +# [] +# ControlAddress = +# HostInterface = +# Peer_ = : +# where, lets the router have a number of peers +# + +import os +import sys + +from twisted.internet import reactor +from twisted.internet import defer +from twisted.internet.protocol import Protocol, ClientFactory +from twisted.protocols.basic import Int32StringReceiver +from twisted.internet.endpoints import TCP4ClientEndpoint, connectProtocol + +# Bring in xia and overlay tools into path +srcdir = os.getcwd()[:os.getcwd().rindex('xia-core')+len('xia-core')] +sys.path.append(os.path.join(srcdir, 'bin')) +sys.path.append(os.path.join(srcdir, 'tools/overlay')) + +import xiapyutils +import clientconfig_pb2 + +from ConfigParser import RawConfigParser + +import inspect + +class XIAClientConfigReader: + def __init__(self, config_filename): + self.routers = {} + self.default_router = {} + self.control_addr = {} + self.control_port = {} + self.ad = {} + self.hid = {} + + # Read in the config file + parser = RawConfigParser() + parser.read(config_filename) + + # Router names are the section names in the config file + clients = parser.sections() + if len(clients) == 0: + print "ERROR: No sections found in config file" + + # Read in info into our internal data structures + for client in clients: + + # Interface names for each router (comma separated list) + routers = parser.get(client, 'Routers') + routers = routers.replace(' ', '') + self.routers[client] = routers.split(',') + + self.default_router[client] = parser.get(client, 'Default') + self.control_addr[client] = parser.get(client, 'ControlAddress') + self.control_port[client] = parser.get(client, 'ControlPort') + + def clients(self): + return self.routers.keys() + +class ConfigClient(Int32StringReceiver): + def __init__(self, client, configurator): + print inspect.stack()[0][3] + self.client = client + self.configurator = configurator + + def connectionLost(self, reason): + self.configurator.connected_clients.remove(self) + if len(self.configurator.connected_clients) == 0: + reactor.stop() + + def connectionMade(self): + self.sendConfig() + + def sendConfig(self): + response = clientconfig_pb2.Config() + response.type = clientconfig_pb2.Config.CLIENT_CONFIG + response.name = self.client + response.router_addr = self.default_router + response.AD = self.ad + response.HID = self.hid + + self.sendString(response.SerializeToString()) + + +class XIAClientConfigurator(): + def __init__(self, configurator): + self.configurator = configurator + self.connected_clients = {} + + clientConfig = XIAClientConfigReader('tools/overlay/client.conf') + for client in clientConfig.clients(): + print client + ':' + for router in clientConfig.routers[client]: + clientConfig.ad[client] = configurator.xids[router][0] + clientConfig.hid[client] = configurator.xids[router][1] + print configurator.xids[router] + + self.clientConfig = clientConfig + + def configureClient(self): + for client in self.clientConfig.clients(): + + endpoint = TCP4ClientEndpoint(reactor, + self.clientConfig.control_addr[client], + int(self.clientConfig.control_port[client])) + + d = connectProtocol(endpoint, self.ConfigClient(client, self)) + d.addCallback(self.addClient) + + reactor.run() + + def addClient(self, client): + self.connected_clients.append(client) diff --git a/tools/overlay/xiaconfigurator.py b/tools/overlay/xiaconfigurator.py index d6f5882fd..d1b0ff280 100644 --- a/tools/overlay/xiaconfigurator.py +++ b/tools/overlay/xiaconfigurator.py @@ -28,8 +28,7 @@ import configrequest_pb2 import clientconfig_pb2 -from xiaconfigreader import XIAConfigReader -from xiaclientconfigreader import XIAClientConfigReader +from xiaclientconfiguurator import XIAClientConfigurator from routerclick import RouterClick import inspect @@ -234,30 +233,6 @@ def handleGatherXIDsResponse(self, response): self.configurator.xids[self.router] = (ad, hid) self.xid_wait.callback(self) -class ConfigClient(Int32StringReceiver): - def __init__(self, client, configurator): - print inspect.stack()[0][3] - self.client = client - self.configurator = configurator - - def connectionLost(self, reason): - self.configurator.connected_clients.remove(self) - if len(self.configurator.connected_clients) == 0: - reactor.stop() - - def connectionMade(self): - self.sendConfig() - - def sendConfig(self): - response = clientconfig_pb2.Config() - response.type = clientconfig_pb2.Config.CLIENT_CONFIG - response.name = self.client - response.router_addr = self.default_router - response.AD = self.ad - response.HID = self.hid - - self.sendString(response.SerializeToString()) - class XIAConfigurator: def __init__(self, config): @@ -316,21 +291,6 @@ def configure(self): reactor.run() - def addClient(self, client): - self.connected_clients.append(client) - - def configureClient(self, clientConfig): - for client in clientConfig.clients(): - - endpoint = TCP4ClientEndpoint(reactor, - clientConfig.control_addr[client], - int(clientConfig.control_port[client])) - - d = connectProtocol(endpoint, ConfigClient(client, self)) - d.addCallback(self.addClient) - - reactor.run() - if __name__ == "__main__": conf_file = os.path.join(xiapyutils.xia_srcdir(), 'tools/overlay/demo.conf') @@ -340,12 +300,5 @@ def configureClient(self, clientConfig): print "===============================================================" - clientConfig = XIAClientConfigReader('tools/overlay/client.conf') - for client in clientConfig.clients(): - print client + ':' - for router in clientConfig.routers[client]: - clientConfig.ad[client] = configurator.xids[router][0] - clientConfig.hid[client] = configurator.xids[router][1] - print configurator.xids[router] - - configurator.configureClient(clientConfig) + clientConfigurator = XIAClientConfigurator() + clientConfigurator.configureClient(clientConfig) From aeae93dad8101157bc796ebbe50c9ba2962623d5 Mon Sep 17 00:00:00 2001 From: mirrorZ Date: Thu, 17 Oct 2019 15:29:48 +0000 Subject: [PATCH 012/116] client configurator proto fixes --- tools/overlay/clientconfig.proto | 15 ++---- tools/overlay/xiaclientconfigurator.py | 63 +++++++++++--------------- tools/overlay/xiaconfigurator.py | 16 +++---- 3 files changed, 39 insertions(+), 55 deletions(-) diff --git a/tools/overlay/clientconfig.proto b/tools/overlay/clientconfig.proto index 57474afe9..9b4a18440 100644 --- a/tools/overlay/clientconfig.proto +++ b/tools/overlay/clientconfig.proto @@ -3,15 +3,10 @@ syntax = "proto2"; package clientconfig; message Config { - enum RequestType { - CLIENT_CONFIG = 0; - } - message RouterInfo { - required string name = 1; - required string ipaddr = 2; - required string port = 3; - required string AD = 4; - required string HID = 5; - } + required string name = 1; + required string ipaddr = 2; + required string port = 3; + required string AD = 4; + required string HID = 5; } diff --git a/tools/overlay/xiaclientconfigurator.py b/tools/overlay/xiaclientconfigurator.py index b08a87b16..bd391d401 100644 --- a/tools/overlay/xiaclientconfigurator.py +++ b/tools/overlay/xiaclientconfigurator.py @@ -1,14 +1,3 @@ - -# XIA network configuration service - -# Starts with a config file with format: -# [] -# ControlAddress = -# HostInterface = -# Peer_ = : -# where, lets the router have a number of peers -# - import os import sys @@ -64,14 +53,15 @@ def clients(self): return self.routers.keys() class ConfigClient(Int32StringReceiver): - def __init__(self, client, configurator): + def __init__(self, client, clientConfigurator): print inspect.stack()[0][3] self.client = client - self.configurator = configurator + self.clientConfigurator = clientConfigurator def connectionLost(self, reason): - self.configurator.connected_clients.remove(self) - if len(self.configurator.connected_clients) == 0: + #self.connected_clients.remove(self) + self.clientConfigurator.connected_clients -= 1 + if self.clientConfigurator.connected_clients == 0: reactor.stop() def connectionMade(self): @@ -79,41 +69,40 @@ def connectionMade(self): def sendConfig(self): response = clientconfig_pb2.Config() - response.type = clientconfig_pb2.Config.CLIENT_CONFIG + print "-----------------------------------" response.name = self.client - response.router_addr = self.default_router - response.AD = self.ad - response.HID = self.hid + response.router_addr = self.clientConfigurator.clientConfig.default_router[self.client] + response.AD = self.clientConfigurator.clientConfig.ad[self.client] + response.HID =self.clientConfigurator.clientConfig.hid[self.client] self.sendString(response.SerializeToString()) class XIAClientConfigurator(): def __init__(self, configurator): - self.configurator = configurator - self.connected_clients = {} + self.connected_clients = 0 clientConfig = XIAClientConfigReader('tools/overlay/client.conf') - for client in clientConfig.clients(): - print client + ':' - for router in clientConfig.routers[client]: - clientConfig.ad[client] = configurator.xids[router][0] - clientConfig.hid[client] = configurator.xids[router][1] - print configurator.xids[router] + for client in clientConfig.clients(): + print client + ':' + for router in clientConfig.routers[client]: + clientConfig.ad[client] = configurator.xids[router][0] + clientConfig.hid[client] = configurator.xids[router][1] + print configurator.xids[router] - self.clientConfig = clientConfig + self.clientConfig = clientConfig def configureClient(self): - for client in self.clientConfig.clients(): + for client in self.clientConfig.clients(): - endpoint = TCP4ClientEndpoint(reactor, - self.clientConfig.control_addr[client], - int(self.clientConfig.control_port[client])) + endpoint = TCP4ClientEndpoint(reactor, + self.clientConfig.control_addr[client], + int(self.clientConfig.control_port[client])) - d = connectProtocol(endpoint, self.ConfigClient(client, self)) - d.addCallback(self.addClient) + d = connectProtocol(endpoint, ConfigClient(client, self)) + d.addCallback(self.addClient) - reactor.run() + #reactor.run() - def addClient(self, client): - self.connected_clients.append(client) + def addClient(self): + self.connected_clients += 1 diff --git a/tools/overlay/xiaconfigurator.py b/tools/overlay/xiaconfigurator.py index d1b0ff280..1fdd2ba3b 100644 --- a/tools/overlay/xiaconfigurator.py +++ b/tools/overlay/xiaconfigurator.py @@ -28,7 +28,8 @@ import configrequest_pb2 import clientconfig_pb2 -from xiaclientconfiguurator import XIAClientConfigurator +from xiaconfigreader import XIAConfigReader +from xiaclientconfigurator import XIAClientConfigurator from routerclick import RouterClick import inspect @@ -44,8 +45,12 @@ def __init__(self, router, configurator, xid_wait): def connectionLost(self, reason): print inspect.stack()[0][3] self.configurator.protocol_instances.remove(self) - if len(self.configurator.protocol_instances) == 0: - reactor.stop() + if len(self.configurator.protocol_instances) == 0: + print "===============================================================" + clientConfigurator = XIAClientConfigurator(self.configurator) + clientConfigurator.configureClient() + # reactor.stop() + def stringReceived(self, data): print inspect.stack()[0][3] if not self.initialized: @@ -297,8 +302,3 @@ def configure(self): config = XIAConfigReader(conf_file) configurator = XIAConfigurator(config) configurator.configure() - - print "===============================================================" - - clientConfigurator = XIAClientConfigurator() - clientConfigurator.configureClient(clientConfig) From 0afcb75b3259c4e86dcda34bbfc4c9408fa743fb Mon Sep 17 00:00:00 2001 From: mirrorZ Date: Thu, 17 Oct 2019 11:32:51 -0400 Subject: [PATCH 013/116] fix client proto --- tools/overlay/xiaclientconfigurator.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/tools/overlay/xiaclientconfigurator.py b/tools/overlay/xiaclientconfigurator.py index bd391d401..92d448ca7 100644 --- a/tools/overlay/xiaclientconfigurator.py +++ b/tools/overlay/xiaclientconfigurator.py @@ -71,7 +71,8 @@ def sendConfig(self): response = clientconfig_pb2.Config() print "-----------------------------------" response.name = self.client - response.router_addr = self.clientConfigurator.clientConfig.default_router[self.client] + response.ipaddr = self.clientConfigurator.clientConfig.default_router[self.client] + response.port = "8792" response.AD = self.clientConfigurator.clientConfig.ad[self.client] response.HID =self.clientConfigurator.clientConfig.hid[self.client] From 52e22484696113333954be59862fd37a0c612120 Mon Sep 17 00:00:00 2001 From: mirrorZ Date: Thu, 17 Oct 2019 11:43:29 -0400 Subject: [PATCH 014/116] client helper use new proto --- tools/overlay/xiaclienthelper.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/overlay/xiaclienthelper.py b/tools/overlay/xiaclienthelper.py index 069a3534c..2ccf9ee83 100644 --- a/tools/overlay/xiaclienthelper.py +++ b/tools/overlay/xiaclienthelper.py @@ -37,7 +37,7 @@ def connectionLost(self, reason): def stringReceived(self, recvd_conf): print inspect.stack()[0][3] - conf = clientconfig_pb2.ClientConfig() + conf = clientconfig_pb2.Config() conf.ParseFromString(recvd_conf) self.handleConfig(conf) From e24330fdf8a81497c6feffdb58b94bb0e503c32c Mon Sep 17 00:00:00 2001 From: mirrorZ Date: Thu, 17 Oct 2019 11:47:39 -0400 Subject: [PATCH 015/116] stop reactor in client helper --- tools/overlay/xiaclienthelper.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/tools/overlay/xiaclienthelper.py b/tools/overlay/xiaclienthelper.py index 2ccf9ee83..1cf07792b 100644 --- a/tools/overlay/xiaclienthelper.py +++ b/tools/overlay/xiaclienthelper.py @@ -34,6 +34,7 @@ def connectionLost(self, reason): print inspect.stack()[0][3] # Clean up any state created in common_data for this connection print "Connection to client lost" + rector.stop() def stringReceived(self, recvd_conf): print inspect.stack()[0][3] @@ -42,6 +43,7 @@ def stringReceived(self, recvd_conf): self.handleConfig(conf) def handleConfig(self, config): + print "handle config" print config class HelperFactory(Factory): From 1945e0349006ceb48c701f8100493fd34fc3c5da Mon Sep 17 00:00:00 2001 From: mirrorZ Date: Thu, 17 Oct 2019 17:16:58 +0000 Subject: [PATCH 016/116] debug --- tools/overlay/xiaclientconfigurator.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/tools/overlay/xiaclientconfigurator.py b/tools/overlay/xiaclientconfigurator.py index 92d448ca7..63df8fba0 100644 --- a/tools/overlay/xiaclientconfigurator.py +++ b/tools/overlay/xiaclientconfigurator.py @@ -76,6 +76,10 @@ def sendConfig(self): response.AD = self.clientConfigurator.clientConfig.ad[self.client] response.HID =self.clientConfigurator.clientConfig.hid[self.client] + print "Sending" + print response + print "-----------------------------------" + self.sendString(response.SerializeToString()) From 1f64ac6fa366ab7a3fd4cf817b32d3516575f80e Mon Sep 17 00:00:00 2001 From: mirrorZ Date: Thu, 17 Oct 2019 17:21:03 +0000 Subject: [PATCH 017/116] debug --- tools/overlay/xiaclienthelper.py | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/tools/overlay/xiaclienthelper.py b/tools/overlay/xiaclienthelper.py index 1cf07792b..144474f78 100644 --- a/tools/overlay/xiaclienthelper.py +++ b/tools/overlay/xiaclienthelper.py @@ -34,17 +34,24 @@ def connectionLost(self, reason): print inspect.stack()[0][3] # Clean up any state created in common_data for this connection print "Connection to client lost" - rector.stop() - def stringReceived(self, recvd_conf): + def stringReceived(self, recvd_conf): + print "----------------------------------------------" print inspect.stack()[0][3] + print recvd_conf conf = clientconfig_pb2.Config() conf.ParseFromString(recvd_conf) + + print "Received" + print conf + print "----------------------------------------------" self.handleConfig(conf) def handleConfig(self, config): print "handle config" print config + reactor.stop() + class HelperFactory(Factory): @@ -56,4 +63,4 @@ def buildProtocol(self, addr): # Run helper service reactor.listenTCP(8295, HelperFactory()) -reactor.run() \ No newline at end of file +reactor.run() From ecf1ad079232b80d9e269c2dcd56374368ec7437 Mon Sep 17 00:00:00 2001 From: mirrorZ Date: Sun, 20 Oct 2019 12:47:11 -0400 Subject: [PATCH 018/116] add mobility config --- tools/overlay/xiaclientconfigurator.py | 60 +++++++++++++++----------- 1 file changed, 36 insertions(+), 24 deletions(-) diff --git a/tools/overlay/xiaclientconfigurator.py b/tools/overlay/xiaclientconfigurator.py index 63df8fba0..3215acdac 100644 --- a/tools/overlay/xiaclientconfigurator.py +++ b/tools/overlay/xiaclientconfigurator.py @@ -65,49 +65,61 @@ def connectionLost(self, reason): reactor.stop() def connectionMade(self): - self.sendConfig() + # configure with default router + self.sendConfig(self.clientConfigurator.clientConfig.default_router[self.client]) - def sendConfig(self): + if self.client == 'r2': #todo: make configurable + self.mobilityConfig() + + def sendConfig(self, router): response = clientconfig_pb2.Config() print "-----------------------------------" response.name = self.client - response.ipaddr = self.clientConfigurator.clientConfig.default_router[self.client] + response.ipaddr = router response.port = "8792" - response.AD = self.clientConfigurator.clientConfig.ad[self.client] - response.HID =self.clientConfigurator.clientConfig.hid[self.client] + response.AD = self.clientConfigurator.clientConfig.ad[router] + response.HID =self.clientConfigurator.clientConfig.hid[router] - print "Sending" + print "Sending config to " + self.client print response print "-----------------------------------" self.sendString(response.SerializeToString()) + def mobilityConfig(self): + t = 60*2 + for router in self.clientConfigurator.routers[client]: + reactor.callLater(t, self.sendConfig, router) + t = t + 60*2 + class XIAClientConfigurator(): def __init__(self, configurator): - self.connected_clients = 0 + self.connected_clients = 0 - clientConfig = XIAClientConfigReader('tools/overlay/client.conf') - for client in clientConfig.clients(): - print client + ':' - for router in clientConfig.routers[client]: - clientConfig.ad[client] = configurator.xids[router][0] - clientConfig.hid[client] = configurator.xids[router][1] - print configurator.xids[router] + clientConfig = XIAClientConfigReader('tools/overlay/client.conf') + for client in clientConfig.clients(): + print client + ':' + for router in clientConfig.routers[client]: + clientConfig.ad[router] = configurator.xids[router][0] + clientConfig.hid[router] = configurator.xids[router][1] + print configurator.xids[router] - self.clientConfig = clientConfig + self.clientConfig = clientConfig def configureClient(self): - for client in self.clientConfig.clients(): - - endpoint = TCP4ClientEndpoint(reactor, - self.clientConfig.control_addr[client], - int(self.clientConfig.control_port[client])) + for client in self.clientConfig.clients(): + endpoint = TCP4ClientEndpoint(reactor, + self.clientConfig.control_addr[client], + int(self.clientConfig.control_port[client])) - d = connectProtocol(endpoint, ConfigClient(client, self)) - d.addCallback(self.addClient) + d = connectProtocol(endpoint, ConfigClient(client, self)) + d.addCallback(self.addClient) #reactor.run() - def addClient(self): - self.connected_clients += 1 + def addClient(self): + self.connected_clients += 1 + + def runMobilityExperiment(self): + From 3cee6d4ca85967bcd3f4cffa26c76a1b691734bc Mon Sep 17 00:00:00 2001 From: mirrorZ Date: Sun, 20 Oct 2019 17:09:16 +0000 Subject: [PATCH 019/116] client helper keep listening --- tools/overlay/xiaclienthelper.py | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/tools/overlay/xiaclienthelper.py b/tools/overlay/xiaclienthelper.py index 144474f78..667500729 100644 --- a/tools/overlay/xiaclienthelper.py +++ b/tools/overlay/xiaclienthelper.py @@ -36,21 +36,18 @@ def connectionLost(self, reason): print "Connection to client lost" def stringReceived(self, recvd_conf): - print "----------------------------------------------" print inspect.stack()[0][3] - print recvd_conf conf = clientconfig_pb2.Config() conf.ParseFromString(recvd_conf) - print "Received" - print conf - print "----------------------------------------------" self.handleConfig(conf) def handleConfig(self, config): - print "handle config" + print "----------------------------------------------" + print "Received" print config - reactor.stop() + print "----------------------------------------------" + #reactor.stop() class HelperFactory(Factory): From 808b7a0a85fd6e0c0d0f0c5498fcd79b54d97ff4 Mon Sep 17 00:00:00 2001 From: mirrorZ Date: Sun, 20 Oct 2019 13:57:37 -0400 Subject: [PATCH 020/116] Client needs to know its local interface to connect to for connecting to the router --- tools/overlay/client.conf | 5 +++-- tools/overlay/demo.conf | 14 ++++++++------ tools/overlay/xiaclientconfigreader.py | 6 ++++++ tools/overlay/xiaconfigreader.py | 1 + 4 files changed, 18 insertions(+), 8 deletions(-) diff --git a/tools/overlay/client.conf b/tools/overlay/client.conf index e3d56a4b0..237f9c1d8 100644 --- a/tools/overlay/client.conf +++ b/tools/overlay/client.conf @@ -1,7 +1,8 @@ [c1] -ControlAddress = 10.0.6.130 +ControlAddress = 10.0.1.130 ControlPort = 8295 -Routers = r1 +Routers = r1, r2 +Interfaces = ens40, ens39 Default = r1 # [c2] diff --git a/tools/overlay/demo.conf b/tools/overlay/demo.conf index f4051d1fc..8bbec64d9 100644 --- a/tools/overlay/demo.conf +++ b/tools/overlay/demo.conf @@ -1,14 +1,16 @@ [r1] -ControlAddress = 10.0.5.130 -Interfaces = ens34,ens39 -HostInterface = ens34 +ControlAddress = 10.0.1.129 +Interfaces = ens34,ens35,ens39 +HostInterface = ens35 +HostAddr = 10.0.2.129 NameServer = true #Route_r2 = ens39 -> ens34:r2 # [r2] -# ControlAddress = 10.0.5.128 -# Interfaces = ens34,ens38 -# HostInterface = ens34 +# ControlAddress = 10.0.1.132 +# Interfaces = ens34,ens35,ens40 +# HostInterface = ens35 +# HostAddr = 10.0.6.128 # Route_r1 = ens34 -> ens39:r1 # Xcache = true diff --git a/tools/overlay/xiaclientconfigreader.py b/tools/overlay/xiaclientconfigreader.py index 4ca7021f4..1413a8a71 100644 --- a/tools/overlay/xiaclientconfigreader.py +++ b/tools/overlay/xiaclientconfigreader.py @@ -4,10 +4,14 @@ class XIAClientConfigReader: def __init__(self, config_filename): + #client metadata self.routers = {} self.default_router = {} self.control_addr = {} self.control_port = {} + #router metadata + self.ifaces = {} + self.router_addr = {} self.ad = {} self.hid = {} @@ -28,6 +32,8 @@ def __init__(self, config_filename): routers = routers.replace(' ', '') self.routers[client] = routers.split(',') + # todo plug in interfaces + self.default_router[client] = parser.get(client, 'Default') self.control_addr[client] = parser.get(client, 'ControlAddress') self.control_port[client] = parser.get(client, 'ControlPort') diff --git a/tools/overlay/xiaconfigreader.py b/tools/overlay/xiaconfigreader.py index ebcf8cf09..84c282dab 100644 --- a/tools/overlay/xiaconfigreader.py +++ b/tools/overlay/xiaconfigreader.py @@ -5,6 +5,7 @@ def __init__(self, config_filename): self.control_addrs = {} # router: ctrl_addr self.router_ifaces = {} # router: [iface1,...] self.host_ifaces = {} # router: host_iface + self.host_ipaddrs = {} # router: host ipaddr # todo fill this self.route_info = {} # router: (dest,our_iface,their_iface,their_name) self.xcache = {} # router: runs_xcache self.nameserver = "" From de88ac473114c81d5f67a19a7849df55e8c1480c Mon Sep 17 00:00:00 2001 From: mirrorZ Date: Mon, 21 Oct 2019 00:28:28 -0400 Subject: [PATCH 021/116] update --- tools/overlay/xiaclientconfigurator.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/overlay/xiaclientconfigurator.py b/tools/overlay/xiaclientconfigurator.py index 3215acdac..192ed203d 100644 --- a/tools/overlay/xiaclientconfigurator.py +++ b/tools/overlay/xiaclientconfigurator.py @@ -75,7 +75,7 @@ def sendConfig(self, router): response = clientconfig_pb2.Config() print "-----------------------------------" response.name = self.client - response.ipaddr = router + response.ipaddr = self.clientConfigurator.clientConfig.router_addr[router] response.port = "8792" response.AD = self.clientConfigurator.clientConfig.ad[router] response.HID =self.clientConfigurator.clientConfig.hid[router] From 9a1258484a870f1a85fdc9bb8358ea5aa40ba383 Mon Sep 17 00:00:00 2001 From: mirrorZ Date: Wed, 23 Oct 2019 23:42:10 +0000 Subject: [PATCH 022/116] some config change --- tools/overlay/client.conf | 6 ++- tools/overlay/xiaclientconfigurator.py | 56 +++++++++++++------------- 2 files changed, 31 insertions(+), 31 deletions(-) diff --git a/tools/overlay/client.conf b/tools/overlay/client.conf index 237f9c1d8..5165e818f 100644 --- a/tools/overlay/client.conf +++ b/tools/overlay/client.conf @@ -1,8 +1,10 @@ [c1] ControlAddress = 10.0.1.130 ControlPort = 8295 -Routers = r1, r2 -Interfaces = ens40, ens39 +Routers = r1 +Interfaces = ens40 +#Routers = r1, r2 +#Interfaces = ens40, ens39 Default = r1 # [c2] diff --git a/tools/overlay/xiaclientconfigurator.py b/tools/overlay/xiaclientconfigurator.py index 192ed203d..10191fa9a 100644 --- a/tools/overlay/xiaclientconfigurator.py +++ b/tools/overlay/xiaclientconfigurator.py @@ -94,32 +94,30 @@ def mobilityConfig(self): class XIAClientConfigurator(): - def __init__(self, configurator): - self.connected_clients = 0 - - clientConfig = XIAClientConfigReader('tools/overlay/client.conf') - for client in clientConfig.clients(): - print client + ':' - for router in clientConfig.routers[client]: - clientConfig.ad[router] = configurator.xids[router][0] - clientConfig.hid[router] = configurator.xids[router][1] - print configurator.xids[router] - - self.clientConfig = clientConfig - - def configureClient(self): - for client in self.clientConfig.clients(): - endpoint = TCP4ClientEndpoint(reactor, - self.clientConfig.control_addr[client], - int(self.clientConfig.control_port[client])) - - d = connectProtocol(endpoint, ConfigClient(client, self)) - d.addCallback(self.addClient) - - #reactor.run() - - def addClient(self): - self.connected_clients += 1 - - def runMobilityExperiment(self): - + def __init__(self, configurator): + self.connected_clients = 0 + + clientConfig = XIAClientConfigReader('tools/overlay/client.conf') + for client in clientConfig.clients(): + print client + ':' + for router in clientConfig.routers[client]: + clientConfig.ad[router] = configurator.xids[router][0] + clientConfig.hid[router] = configurator.xids[router][1] + print configurator.xids[router] + + self.clientConfig = clientConfig + + def configureClient(self): + for client in self.clientConfig.clients(): + endpoint = TCP4ClientEndpoint(reactor, + self.clientConfig.control_addr[client], + int(self.clientConfig.control_port[client])) + + d = connectProtocol(endpoint, ConfigClient(client, self)) + d.addCallback(self.addClient) + + #reactor.run() + + def addClient(self): + self.connected_clients += 1 + From 004b9b6f8bbb73cac8b9ce2b77b4dde35f6c43a4 Mon Sep 17 00:00:00 2001 From: mirrorZ Date: Wed, 23 Oct 2019 20:59:45 -0400 Subject: [PATCH 023/116] update --- tools/overlay/xiaclientconfigreader.py | 9 ++++++++- tools/overlay/xiaclientconfigurator.py | 1 + tools/overlay/xiaconfigreader.py | 3 +++ 3 files changed, 12 insertions(+), 1 deletion(-) diff --git a/tools/overlay/xiaclientconfigreader.py b/tools/overlay/xiaclientconfigreader.py index 1413a8a71..db727a5a6 100644 --- a/tools/overlay/xiaclientconfigreader.py +++ b/tools/overlay/xiaclientconfigreader.py @@ -32,12 +32,19 @@ def __init__(self, config_filename): routers = routers.replace(' ', '') self.routers[client] = routers.split(',') - # todo plug in interfaces + ifaces = parser.get(client, 'Interfaces') + ifaces = ifaces.replace(' '. '') + self.ifaces[client] = [] + r_iface = [] + for i, iface in ifaces: + r_iface[routers[i]] = iface + self.ifaces[client] = r_iface self.default_router[client] = parser.get(client, 'Default') self.control_addr[client] = parser.get(client, 'ControlAddress') self.control_port[client] = parser.get(client, 'ControlPort') + def clients(self): return self.routers.keys() diff --git a/tools/overlay/xiaclientconfigurator.py b/tools/overlay/xiaclientconfigurator.py index 192ed203d..2fccc9600 100644 --- a/tools/overlay/xiaclientconfigurator.py +++ b/tools/overlay/xiaclientconfigurator.py @@ -27,6 +27,7 @@ def __init__(self, config_filename): self.control_port = {} self.ad = {} self.hid = {} + self.router_addr = {} # Read in the config file parser = RawConfigParser() diff --git a/tools/overlay/xiaconfigreader.py b/tools/overlay/xiaconfigreader.py index 84c282dab..fed25e09c 100644 --- a/tools/overlay/xiaconfigreader.py +++ b/tools/overlay/xiaconfigreader.py @@ -28,6 +28,9 @@ def __init__(self, config_filename): # AID host interface for each router self.host_ifaces[router] = parser.get(router, 'HostInterface') + # IP Address of host iface + self.host_ipaddrs[router] = parser.get[router, 'HostAddr'] + # Check if this is a nameserver try: if parser.getboolean(router, "NameServer"): From 1d55d49f73470c44ac84d1fcba9e79905380094e Mon Sep 17 00:00:00 2001 From: mirrorZ Date: Wed, 23 Oct 2019 21:03:20 -0400 Subject: [PATCH 024/116] update --- tools/overlay/xiaconfigreader.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/overlay/xiaconfigreader.py b/tools/overlay/xiaconfigreader.py index fed25e09c..190ec9924 100644 --- a/tools/overlay/xiaconfigreader.py +++ b/tools/overlay/xiaconfigreader.py @@ -29,7 +29,7 @@ def __init__(self, config_filename): self.host_ifaces[router] = parser.get(router, 'HostInterface') # IP Address of host iface - self.host_ipaddrs[router] = parser.get[router, 'HostAddr'] + self.host_ipaddrs[router] = parser.get(router, 'HostAddr') # Check if this is a nameserver try: From 55c65671544b0bf8ef95a25c26b74e0fd72f7cbd Mon Sep 17 00:00:00 2001 From: mirrorZ Date: Thu, 24 Oct 2019 02:08:29 +0000 Subject: [PATCH 025/116] some fixes --- tools/overlay/xiaclientconfigurator.py | 4 ++-- tools/overlay/xiaconfigurator.py | 3 ++- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/tools/overlay/xiaclientconfigurator.py b/tools/overlay/xiaclientconfigurator.py index f09bc01d5..beafab208 100644 --- a/tools/overlay/xiaclientconfigurator.py +++ b/tools/overlay/xiaclientconfigurator.py @@ -76,7 +76,7 @@ def sendConfig(self, router): response = clientconfig_pb2.Config() print "-----------------------------------" response.name = self.client - response.ipaddr = self.clientConfigurator.clientConfig.router_addr[router] + response.ipaddr = self.clientConfigurator.clientConfig.config.router_addr[router] response.port = "8792" response.AD = self.clientConfigurator.clientConfig.ad[router] response.HID =self.clientConfigurator.clientConfig.hid[router] @@ -121,4 +121,4 @@ def configureClient(self): def addClient(self): self.connected_clients += 1 - + diff --git a/tools/overlay/xiaconfigurator.py b/tools/overlay/xiaconfigurator.py index 1fdd2ba3b..35747716e 100644 --- a/tools/overlay/xiaconfigurator.py +++ b/tools/overlay/xiaconfigurator.py @@ -47,9 +47,10 @@ def connectionLost(self, reason): self.configurator.protocol_instances.remove(self) if len(self.configurator.protocol_instances) == 0: print "===============================================================" + print self.configurator.config clientConfigurator = XIAClientConfigurator(self.configurator) clientConfigurator.configureClient() - # reactor.stop() + #reactor.stop() def stringReceived(self, data): print inspect.stack()[0][3] From 01f25d7ecb738262d9f4224ec74f549ece888e4b Mon Sep 17 00:00:00 2001 From: mirrorZ Date: Thu, 24 Oct 2019 02:34:34 +0000 Subject: [PATCH 026/116] fix typo --- tools/overlay/xiaclientconfigurator.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/tools/overlay/xiaclientconfigurator.py b/tools/overlay/xiaclientconfigurator.py index beafab208..353086325 100644 --- a/tools/overlay/xiaclientconfigurator.py +++ b/tools/overlay/xiaclientconfigurator.py @@ -76,7 +76,7 @@ def sendConfig(self, router): response = clientconfig_pb2.Config() print "-----------------------------------" response.name = self.client - response.ipaddr = self.clientConfigurator.clientConfig.config.router_addr[router] + response.ipaddr = self.clientConfigurator.clientConfig.router_addr[router] response.port = "8792" response.AD = self.clientConfigurator.clientConfig.ad[router] response.HID =self.clientConfigurator.clientConfig.hid[router] @@ -104,6 +104,7 @@ def __init__(self, configurator): for router in clientConfig.routers[client]: clientConfig.ad[router] = configurator.xids[router][0] clientConfig.hid[router] = configurator.xids[router][1] + clientConfig.router_addr[router] = configurator.config.host_ipaddrs[router] print configurator.xids[router] self.clientConfig = clientConfig From e38c07346878dabb280357431512c95eb9c0124e Mon Sep 17 00:00:00 2001 From: mirrorZ Date: Wed, 23 Oct 2019 22:39:40 -0400 Subject: [PATCH 027/116] add r2 --- tools/overlay/demo.conf | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/tools/overlay/demo.conf b/tools/overlay/demo.conf index 8bbec64d9..14c45d8f1 100644 --- a/tools/overlay/demo.conf +++ b/tools/overlay/demo.conf @@ -4,13 +4,13 @@ Interfaces = ens34,ens35,ens39 HostInterface = ens35 HostAddr = 10.0.2.129 NameServer = true -#Route_r2 = ens39 -> ens34:r2 +Route_r2 = ens39 -> ens34:r2 -# [r2] -# ControlAddress = 10.0.1.132 -# Interfaces = ens34,ens35,ens40 -# HostInterface = ens35 -# HostAddr = 10.0.6.128 -# Route_r1 = ens34 -> ens39:r1 -# Xcache = true +[r2] +ControlAddress = 10.0.1.132 +Interfaces = ens34,ens35,ens40 +HostInterface = ens35 +HostAddr = 10.0.6.128 +Route_r1 = ens34 -> ens39:r1 +Xcache = true From 0b5c26d6fe2429e3e4f7e1bea2327d69b58c4e20 Mon Sep 17 00:00:00 2001 From: mirrorZ Date: Wed, 23 Oct 2019 22:48:13 -0400 Subject: [PATCH 028/116] mobility --- tools/overlay/xiaclientconfigurator.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/tools/overlay/xiaclientconfigurator.py b/tools/overlay/xiaclientconfigurator.py index 353086325..3f30706dd 100644 --- a/tools/overlay/xiaclientconfigurator.py +++ b/tools/overlay/xiaclientconfigurator.py @@ -69,7 +69,7 @@ def connectionMade(self): # configure with default router self.sendConfig(self.clientConfigurator.clientConfig.default_router[self.client]) - if self.client == 'r2': #todo: make configurable + if self.client == 'c1': #todo: make configurable self.mobilityConfig() def sendConfig(self, router): @@ -88,10 +88,11 @@ def sendConfig(self, router): self.sendString(response.SerializeToString()) def mobilityConfig(self): - t = 60*2 + t = 10 for router in self.clientConfigurator.routers[client]: + print "Adding a call for " + router reactor.callLater(t, self.sendConfig, router) - t = t + 60*2 + t = t + 10*2 class XIAClientConfigurator(): From bb3437a0e396deaff8a383c1c31e1072fb4dafe4 Mon Sep 17 00:00:00 2001 From: mirrorZ Date: Wed, 23 Oct 2019 22:50:20 -0400 Subject: [PATCH 029/116] Routers belong to clientconfig --- tools/overlay/xiaclientconfigurator.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/overlay/xiaclientconfigurator.py b/tools/overlay/xiaclientconfigurator.py index 3f30706dd..14d0b8440 100644 --- a/tools/overlay/xiaclientconfigurator.py +++ b/tools/overlay/xiaclientconfigurator.py @@ -89,7 +89,7 @@ def sendConfig(self, router): def mobilityConfig(self): t = 10 - for router in self.clientConfigurator.routers[client]: + for router in self.clientConfigurator.clientConfig.routers[client]: print "Adding a call for " + router reactor.callLater(t, self.sendConfig, router) t = t + 10*2 From aabf42e2b1ad6451765bc3912c690bbbe8dd90f1 Mon Sep 17 00:00:00 2001 From: mirrorZ Date: Wed, 23 Oct 2019 22:51:37 -0400 Subject: [PATCH 030/116] I did mean self.client --- tools/overlay/xiaclientconfigurator.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/overlay/xiaclientconfigurator.py b/tools/overlay/xiaclientconfigurator.py index 14d0b8440..de837c978 100644 --- a/tools/overlay/xiaclientconfigurator.py +++ b/tools/overlay/xiaclientconfigurator.py @@ -89,7 +89,7 @@ def sendConfig(self, router): def mobilityConfig(self): t = 10 - for router in self.clientConfigurator.clientConfig.routers[client]: + for router in self.clientConfigurator.clientConfig.routers[self.client]: print "Adding a call for " + router reactor.callLater(t, self.sendConfig, router) t = t + 10*2 From cce054e08292a868907e73d13dec4838f7dd80f6 Mon Sep 17 00:00:00 2001 From: mirrorZ Date: Thu, 24 Oct 2019 01:42:44 -0400 Subject: [PATCH 031/116] add r2 for c1 --- tools/overlay/client.conf | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/tools/overlay/client.conf b/tools/overlay/client.conf index 5165e818f..d8310b3b7 100644 --- a/tools/overlay/client.conf +++ b/tools/overlay/client.conf @@ -1,10 +1,10 @@ [c1] ControlAddress = 10.0.1.130 ControlPort = 8295 -Routers = r1 -Interfaces = ens40 -#Routers = r1, r2 -#Interfaces = ens40, ens39 +# Routers = r1 +# Interfaces = ens40 +Routers = r1, r2 +Interfaces = ens40, ens39 Default = r1 # [c2] From ec4e6a2e127d4a92997a064e53511b632f78375f Mon Sep 17 00:00:00 2001 From: mirrorZ Date: Thu, 24 Oct 2019 01:51:26 -0400 Subject: [PATCH 032/116] Add client iface --- tools/overlay/clientconfig.proto | 7 ++++--- tools/overlay/xiaclientconfigurator.py | 1 + 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/tools/overlay/clientconfig.proto b/tools/overlay/clientconfig.proto index 9b4a18440..203c3a65f 100644 --- a/tools/overlay/clientconfig.proto +++ b/tools/overlay/clientconfig.proto @@ -5,8 +5,9 @@ package clientconfig; message Config { required string name = 1; required string ipaddr = 2; - required string port = 3; - required string AD = 4; - required string HID = 5; + required string iface = 3; + required string port = 4; + required string AD = 5; + required string HID = 6; } diff --git a/tools/overlay/xiaclientconfigurator.py b/tools/overlay/xiaclientconfigurator.py index de837c978..b4db5c657 100644 --- a/tools/overlay/xiaclientconfigurator.py +++ b/tools/overlay/xiaclientconfigurator.py @@ -77,6 +77,7 @@ def sendConfig(self, router): print "-----------------------------------" response.name = self.client response.ipaddr = self.clientConfigurator.clientConfig.router_addr[router] + response.iface = self.clientConfigurator.clientConfig.router_iface[router] response.port = "8792" response.AD = self.clientConfigurator.clientConfig.ad[router] response.HID =self.clientConfigurator.clientConfig.hid[router] From bc9e4aac250043b06d74a7cde7e3876a37f3b121 Mon Sep 17 00:00:00 2001 From: mirrorZ Date: Thu, 24 Oct 2019 02:01:25 -0400 Subject: [PATCH 033/116] fix typo --- tools/overlay/xiaclientconfigreader.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/tools/overlay/xiaclientconfigreader.py b/tools/overlay/xiaclientconfigreader.py index db727a5a6..b84e276ed 100644 --- a/tools/overlay/xiaclientconfigreader.py +++ b/tools/overlay/xiaclientconfigreader.py @@ -10,7 +10,7 @@ def __init__(self, config_filename): self.control_addr = {} self.control_port = {} #router metadata - self.ifaces = {} + self.router_iface = {} self.router_addr = {} self.ad = {} self.hid = {} @@ -34,11 +34,11 @@ def __init__(self, config_filename): ifaces = parser.get(client, 'Interfaces') ifaces = ifaces.replace(' '. '') - self.ifaces[client] = [] + self.router_iface[client] = [] r_iface = [] for i, iface in ifaces: r_iface[routers[i]] = iface - self.ifaces[client] = r_iface + self.router_iface[client] = r_iface self.default_router[client] = parser.get(client, 'Default') self.control_addr[client] = parser.get(client, 'ControlAddress') From abaf4f30b99bf15709d2ddea28d30a9b017ee79d Mon Sep 17 00:00:00 2001 From: mirrorZ Date: Thu, 24 Oct 2019 02:17:24 -0400 Subject: [PATCH 034/116] fix typo --- tools/overlay/xiaclientconfigurator.py | 1 + 1 file changed, 1 insertion(+) diff --git a/tools/overlay/xiaclientconfigurator.py b/tools/overlay/xiaclientconfigurator.py index b4db5c657..3dbb6d590 100644 --- a/tools/overlay/xiaclientconfigurator.py +++ b/tools/overlay/xiaclientconfigurator.py @@ -107,6 +107,7 @@ def __init__(self, configurator): clientConfig.ad[router] = configurator.xids[router][0] clientConfig.hid[router] = configurator.xids[router][1] clientConfig.router_addr[router] = configurator.config.host_ipaddrs[router] + clientConfig.router_iface[router] = configurator.config.host_ifaces[router] print configurator.xids[router] self.clientConfig = clientConfig From 3061529e8fbbe5277fd37641472d89dceaf5725b Mon Sep 17 00:00:00 2001 From: mirrorZ Date: Thu, 24 Oct 2019 02:21:14 -0400 Subject: [PATCH 035/116] fix typo --- tools/overlay/xiaclientconfigurator.py | 1 + 1 file changed, 1 insertion(+) diff --git a/tools/overlay/xiaclientconfigurator.py b/tools/overlay/xiaclientconfigurator.py index 3dbb6d590..5486eef46 100644 --- a/tools/overlay/xiaclientconfigurator.py +++ b/tools/overlay/xiaclientconfigurator.py @@ -28,6 +28,7 @@ def __init__(self, config_filename): self.ad = {} self.hid = {} self.router_addr = {} + self.router_iface = {} # Read in the config file parser = RawConfigParser() From de46355d02f4cc48462556b5b3fd3e18b293bbfc Mon Sep 17 00:00:00 2001 From: mirrorZ Date: Thu, 24 Oct 2019 10:33:03 -0400 Subject: [PATCH 036/116] Correct client - router iface --- tools/overlay/xiaclientconfigurator.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/tools/overlay/xiaclientconfigurator.py b/tools/overlay/xiaclientconfigurator.py index 5486eef46..fb0f50320 100644 --- a/tools/overlay/xiaclientconfigurator.py +++ b/tools/overlay/xiaclientconfigurator.py @@ -78,7 +78,7 @@ def sendConfig(self, router): print "-----------------------------------" response.name = self.client response.ipaddr = self.clientConfigurator.clientConfig.router_addr[router] - response.iface = self.clientConfigurator.clientConfig.router_iface[router] + response.iface = self.clientConfigurator.clientConfig.router_iface[self.client][router] response.port = "8792" response.AD = self.clientConfigurator.clientConfig.ad[router] response.HID =self.clientConfigurator.clientConfig.hid[router] @@ -108,7 +108,6 @@ def __init__(self, configurator): clientConfig.ad[router] = configurator.xids[router][0] clientConfig.hid[router] = configurator.xids[router][1] clientConfig.router_addr[router] = configurator.config.host_ipaddrs[router] - clientConfig.router_iface[router] = configurator.config.host_ifaces[router] print configurator.xids[router] self.clientConfig = clientConfig From 29494efbc4a4fd5469410c46a3f761f89be13235 Mon Sep 17 00:00:00 2001 From: mirrorZ Date: Thu, 24 Oct 2019 10:36:24 -0400 Subject: [PATCH 037/116] last change didn't work --- tools/overlay/xiaclientconfigurator.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/tools/overlay/xiaclientconfigurator.py b/tools/overlay/xiaclientconfigurator.py index fb0f50320..734808d3c 100644 --- a/tools/overlay/xiaclientconfigurator.py +++ b/tools/overlay/xiaclientconfigurator.py @@ -78,7 +78,7 @@ def sendConfig(self, router): print "-----------------------------------" response.name = self.client response.ipaddr = self.clientConfigurator.clientConfig.router_addr[router] - response.iface = self.clientConfigurator.clientConfig.router_iface[self.client][router] + response.iface = self.clientConfigurator.clientConfig.router_iface[router] response.port = "8792" response.AD = self.clientConfigurator.clientConfig.ad[router] response.HID =self.clientConfigurator.clientConfig.hid[router] @@ -108,6 +108,7 @@ def __init__(self, configurator): clientConfig.ad[router] = configurator.xids[router][0] clientConfig.hid[router] = configurator.xids[router][1] clientConfig.router_addr[router] = configurator.config.host_ipaddrs[router] + clientConfig.router_iface[router] = clientConfig[client][router] print configurator.xids[router] self.clientConfig = clientConfig From 8075cede2e7e0e52d6621426dbaa8d35792ab88b Mon Sep 17 00:00:00 2001 From: mirrorZ Date: Thu, 24 Oct 2019 10:40:54 -0400 Subject: [PATCH 038/116] Edit the wrong file --- tools/overlay/xiaclientconfigurator.py | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/tools/overlay/xiaclientconfigurator.py b/tools/overlay/xiaclientconfigurator.py index 734808d3c..58a993964 100644 --- a/tools/overlay/xiaclientconfigurator.py +++ b/tools/overlay/xiaclientconfigurator.py @@ -37,7 +37,7 @@ def __init__(self, config_filename): # Router names are the section names in the config file clients = parser.sections() if len(clients) == 0: - print "ERROR: No sections found in config file" + print "ERROR: No sections found in config file" # Read in info into our internal data structures for client in clients: @@ -47,6 +47,14 @@ def __init__(self, config_filename): routers = routers.replace(' ', '') self.routers[client] = routers.split(',') + ifaces = parser.get(client, 'Interfaces') + ifaces = ifaces.replace(' '. '') + self.router_iface[client] = [] + r_iface = [] + for i, iface in ifaces: + r_iface[routers[i]] = iface + self.router_iface[client] = r_iface + self.default_router[client] = parser.get(client, 'Default') self.control_addr[client] = parser.get(client, 'ControlAddress') self.control_port[client] = parser.get(client, 'ControlPort') @@ -78,7 +86,7 @@ def sendConfig(self, router): print "-----------------------------------" response.name = self.client response.ipaddr = self.clientConfigurator.clientConfig.router_addr[router] - response.iface = self.clientConfigurator.clientConfig.router_iface[router] + response.iface = self.clientConfigurator.clientConfig.router_iface[self.client][router] response.port = "8792" response.AD = self.clientConfigurator.clientConfig.ad[router] response.HID =self.clientConfigurator.clientConfig.hid[router] @@ -108,7 +116,6 @@ def __init__(self, configurator): clientConfig.ad[router] = configurator.xids[router][0] clientConfig.hid[router] = configurator.xids[router][1] clientConfig.router_addr[router] = configurator.config.host_ipaddrs[router] - clientConfig.router_iface[router] = clientConfig[client][router] print configurator.xids[router] self.clientConfig = clientConfig From 200f614d7f4b6d6764533b174a330a0b35ea5c53 Mon Sep 17 00:00:00 2001 From: mirrorZ Date: Thu, 24 Oct 2019 10:42:34 -0400 Subject: [PATCH 039/116] Fix syntax error --- tools/overlay/xiaclientconfigurator.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/overlay/xiaclientconfigurator.py b/tools/overlay/xiaclientconfigurator.py index 58a993964..3d38f5a78 100644 --- a/tools/overlay/xiaclientconfigurator.py +++ b/tools/overlay/xiaclientconfigurator.py @@ -48,7 +48,7 @@ def __init__(self, config_filename): self.routers[client] = routers.split(',') ifaces = parser.get(client, 'Interfaces') - ifaces = ifaces.replace(' '. '') + ifaces = ifaces.replace(' ', '') self.router_iface[client] = [] r_iface = [] for i, iface in ifaces: From 35faa6d2aaf044b3ec6b8d39c5eaad904b4925c9 Mon Sep 17 00:00:00 2001 From: mirrorZ Date: Thu, 24 Oct 2019 10:47:59 -0400 Subject: [PATCH 040/116] make list of ifaces --- tools/overlay/xiaclientconfigurator.py | 1 + 1 file changed, 1 insertion(+) diff --git a/tools/overlay/xiaclientconfigurator.py b/tools/overlay/xiaclientconfigurator.py index 3d38f5a78..034b8a00f 100644 --- a/tools/overlay/xiaclientconfigurator.py +++ b/tools/overlay/xiaclientconfigurator.py @@ -49,6 +49,7 @@ def __init__(self, config_filename): ifaces = parser.get(client, 'Interfaces') ifaces = ifaces.replace(' ', '') + ifaces = ifaces.split(',') self.router_iface[client] = [] r_iface = [] for i, iface in ifaces: From f6623cb72f5f0128dd381f2e2a550d4a4bad15a6 Mon Sep 17 00:00:00 2001 From: mirrorZ Date: Thu, 24 Oct 2019 10:49:38 -0400 Subject: [PATCH 041/116] last change didn't work --- tools/overlay/xiaclientconfigurator.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/tools/overlay/xiaclientconfigurator.py b/tools/overlay/xiaclientconfigurator.py index 034b8a00f..1b8697822 100644 --- a/tools/overlay/xiaclientconfigurator.py +++ b/tools/overlay/xiaclientconfigurator.py @@ -47,9 +47,9 @@ def __init__(self, config_filename): routers = routers.replace(' ', '') self.routers[client] = routers.split(',') - ifaces = parser.get(client, 'Interfaces') - ifaces = ifaces.replace(' ', '') - ifaces = ifaces.split(',') + iface = parser.get(client, 'Interfaces') + iface = iface.replace(' ', '') + ifaces = iface.split(',') self.router_iface[client] = [] r_iface = [] for i, iface in ifaces: From c076ec900d6750bd8ab1713735de6fce297073b5 Mon Sep 17 00:00:00 2001 From: mirrorZ Date: Thu, 24 Oct 2019 11:03:52 -0400 Subject: [PATCH 042/116] fix iface gathering for client --- tools/overlay/xiaclientconfigurator.py | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/tools/overlay/xiaclientconfigurator.py b/tools/overlay/xiaclientconfigurator.py index 1b8697822..b685d7c85 100644 --- a/tools/overlay/xiaclientconfigurator.py +++ b/tools/overlay/xiaclientconfigurator.py @@ -45,15 +45,16 @@ def __init__(self, config_filename): # Interface names for each router (comma separated list) routers = parser.get(client, 'Routers') routers = routers.replace(' ', '') - self.routers[client] = routers.split(',') + router_list = routers.split(',') + self.routers[client] = router_list iface = parser.get(client, 'Interfaces') iface = iface.replace(' ', '') ifaces = iface.split(',') - self.router_iface[client] = [] - r_iface = [] - for i, iface in ifaces: - r_iface[routers[i]] = iface + self.router_iface[client] = {} + r_iface = {} + for i in range(len(ifaces)): + r_iface[router_list[i]] = ifaces[i] self.router_iface[client] = r_iface self.default_router[client] = parser.get(client, 'Default') @@ -134,4 +135,3 @@ def configureClient(self): def addClient(self): self.connected_clients += 1 - From f0eee5d89ca5ee25c6c35e168623cf1cf3489711 Mon Sep 17 00:00:00 2001 From: mirrorZ Date: Thu, 21 Nov 2019 14:45:41 -0500 Subject: [PATCH 043/116] some local changes --- tools/overlay/client.conf | 6 +++--- tools/overlay/demo.conf | 32 +++++++++++++++++++------------- tools/overlay/xiaconfigurator.py | 8 +++++--- 3 files changed, 27 insertions(+), 19 deletions(-) diff --git a/tools/overlay/client.conf b/tools/overlay/client.conf index d8310b3b7..b182ce718 100644 --- a/tools/overlay/client.conf +++ b/tools/overlay/client.conf @@ -1,10 +1,10 @@ [c1] -ControlAddress = 10.0.1.130 +ControlAddress = 127.0.0.1 #10.0.1.130 ControlPort = 8295 # Routers = r1 # Interfaces = ens40 -Routers = r1, r2 -Interfaces = ens40, ens39 +Routers = r1 #, r2 +Interfaces = lo #ens40 , ens39 Default = r1 # [c2] diff --git a/tools/overlay/demo.conf b/tools/overlay/demo.conf index 14c45d8f1..b07aeb098 100644 --- a/tools/overlay/demo.conf +++ b/tools/overlay/demo.conf @@ -1,16 +1,22 @@ +# [r1] +# ControlAddress = 10.0.1.129 +# Interfaces = ens34,ens35,ens39 +# HostInterface = ens35 +# HostAddr = 10.0.2.129 +# NameServer = true +# Route_r2 = ens39 -> ens34:r2 [r1] -ControlAddress = 10.0.1.129 -Interfaces = ens34,ens35,ens39 -HostInterface = ens35 -HostAddr = 10.0.2.129 -NameServer = true -Route_r2 = ens39 -> ens34:r2 +ControlAddress = 127.0.0.1 +Interfaces = lo +HostInterface = lo +HostAddr = 127.0.0.1 +NameServer = true -[r2] -ControlAddress = 10.0.1.132 -Interfaces = ens34,ens35,ens40 -HostInterface = ens35 -HostAddr = 10.0.6.128 -Route_r1 = ens34 -> ens39:r1 -Xcache = true +# [r2] +# ControlAddress = 10.0.1.132 +# Interfaces = ens34,ens35,ens40 +# HostInterface = ens35 +# HostAddr = 10.0.6.128 +# Route_r1 = ens34 -> ens39:r1 +# Xcache = true diff --git a/tools/overlay/xiaconfigurator.py b/tools/overlay/xiaconfigurator.py index 35747716e..ab91de70b 100644 --- a/tools/overlay/xiaconfigurator.py +++ b/tools/overlay/xiaconfigurator.py @@ -48,9 +48,11 @@ def connectionLost(self, reason): if len(self.configurator.protocol_instances) == 0: print "===============================================================" print self.configurator.config - clientConfigurator = XIAClientConfigurator(self.configurator) - clientConfigurator.configureClient() - #reactor.stop() + + # configure client after last router is configured + #clientConfigurator = XIAClientConfigurator(self.configurator) + #clientConfigurator.configureClient() + reactor.stop() def stringReceived(self, data): print inspect.stack()[0][3] From 77ba84291c212d087fafc636f0f0b09807ad7410 Mon Sep 17 00:00:00 2001 From: mirrorZ Date: Thu, 21 Nov 2019 20:40:14 +0000 Subject: [PATCH 044/116] Some progress --- tools/overlay/client.conf | 10 +++++----- tools/overlay/demo.conf | 18 ++++++------------ tools/overlay/xiaconfigurator.py | 6 +++--- 3 files changed, 14 insertions(+), 20 deletions(-) diff --git a/tools/overlay/client.conf b/tools/overlay/client.conf index b182ce718..b64fd21f4 100644 --- a/tools/overlay/client.conf +++ b/tools/overlay/client.conf @@ -1,10 +1,10 @@ [c1] -ControlAddress = 127.0.0.1 #10.0.1.130 +ControlAddress = 10.0.1.130 ControlPort = 8295 -# Routers = r1 -# Interfaces = ens40 -Routers = r1 #, r2 -Interfaces = lo #ens40 , ens39 +Routers = r1 +Interfaces = ens40 +Routers = r1 +Interfaces = ens40 Default = r1 # [c2] diff --git a/tools/overlay/demo.conf b/tools/overlay/demo.conf index b07aeb098..8bbec64d9 100644 --- a/tools/overlay/demo.conf +++ b/tools/overlay/demo.conf @@ -1,16 +1,10 @@ -# [r1] -# ControlAddress = 10.0.1.129 -# Interfaces = ens34,ens35,ens39 -# HostInterface = ens35 -# HostAddr = 10.0.2.129 -# NameServer = true -# Route_r2 = ens39 -> ens34:r2 [r1] -ControlAddress = 127.0.0.1 -Interfaces = lo -HostInterface = lo -HostAddr = 127.0.0.1 -NameServer = true +ControlAddress = 10.0.1.129 +Interfaces = ens34,ens35,ens39 +HostInterface = ens35 +HostAddr = 10.0.2.129 +NameServer = true +#Route_r2 = ens39 -> ens34:r2 # [r2] # ControlAddress = 10.0.1.132 diff --git a/tools/overlay/xiaconfigurator.py b/tools/overlay/xiaconfigurator.py index ab91de70b..cb4159944 100644 --- a/tools/overlay/xiaconfigurator.py +++ b/tools/overlay/xiaconfigurator.py @@ -50,9 +50,9 @@ def connectionLost(self, reason): print self.configurator.config # configure client after last router is configured - #clientConfigurator = XIAClientConfigurator(self.configurator) - #clientConfigurator.configureClient() - reactor.stop() + clientConfigurator = XIAClientConfigurator(self.configurator) + clientConfigurator.configureClient() + #reactor.stop() def stringReceived(self, data): print inspect.stack()[0][3] From 49608799e0aaa127624b36261c0c74a441cba067 Mon Sep 17 00:00:00 2001 From: mirrorZ Date: Fri, 22 Nov 2019 01:53:27 +0000 Subject: [PATCH 045/116] Some progress --- tools/overlay/xiaclientconfigurator.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/tools/overlay/xiaclientconfigurator.py b/tools/overlay/xiaclientconfigurator.py index b685d7c85..bfae44a52 100644 --- a/tools/overlay/xiaclientconfigurator.py +++ b/tools/overlay/xiaclientconfigurator.py @@ -80,8 +80,8 @@ def connectionMade(self): # configure with default router self.sendConfig(self.clientConfigurator.clientConfig.default_router[self.client]) - if self.client == 'c1': #todo: make configurable - self.mobilityConfig() + # if self.client == 'c1': #todo: make configurable + # self.mobilityConfig() def sendConfig(self, router): response = clientconfig_pb2.Config() @@ -94,7 +94,7 @@ def sendConfig(self, router): response.HID =self.clientConfigurator.clientConfig.hid[router] print "Sending config to " + self.client - print response + print response.SerializeToString() print "-----------------------------------" self.sendString(response.SerializeToString()) From da6c38d42226b0c713441f4afff07214a796739a Mon Sep 17 00:00:00 2001 From: mirrorZ Date: Thu, 21 Nov 2019 21:24:53 -0500 Subject: [PATCH 046/116] debug --- tools/overlay/xiaclientconfigurator.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/tools/overlay/xiaclientconfigurator.py b/tools/overlay/xiaclientconfigurator.py index b685d7c85..553ac4f94 100644 --- a/tools/overlay/xiaclientconfigurator.py +++ b/tools/overlay/xiaclientconfigurator.py @@ -94,7 +94,9 @@ def sendConfig(self, router): response.HID =self.clientConfigurator.clientConfig.hid[router] print "Sending config to " + self.client - print response + print response.SerializeToString() + print "Length " + print len(response.SerializeToString()) print "-----------------------------------" self.sendString(response.SerializeToString()) From d70d4420aef4822db767acb2555cb96f46500fb8 Mon Sep 17 00:00:00 2001 From: mirrorZ Date: Fri, 22 Nov 2019 03:30:18 +0000 Subject: [PATCH 047/116] Some progress --- tools/overlay/xiaclientconfigurator.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/tools/overlay/xiaclientconfigurator.py b/tools/overlay/xiaclientconfigurator.py index e8e5715fe..c79bdfa4d 100644 --- a/tools/overlay/xiaclientconfigurator.py +++ b/tools/overlay/xiaclientconfigurator.py @@ -94,9 +94,9 @@ def sendConfig(self, router): response.HID =self.clientConfigurator.clientConfig.hid[router] print "Sending config to " + self.client - print response.SerializeToString() - print "Length " - print len(response.SerializeToString()) + print response.SerializeToString() + print "Length " + print len(response.SerializeToString()) print "-----------------------------------" self.sendString(response.SerializeToString()) From 4b888137d6e768bbce2a50b56c02792d97ce7616 Mon Sep 17 00:00:00 2001 From: mirrorZ Date: Fri, 22 Nov 2019 03:54:23 +0000 Subject: [PATCH 048/116] Some progress --- tools/overlay/xiaclientconfigurator.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/overlay/xiaclientconfigurator.py b/tools/overlay/xiaclientconfigurator.py index c79bdfa4d..788d386df 100644 --- a/tools/overlay/xiaclientconfigurator.py +++ b/tools/overlay/xiaclientconfigurator.py @@ -94,12 +94,12 @@ def sendConfig(self, router): response.HID =self.clientConfigurator.clientConfig.hid[router] print "Sending config to " + self.client + self.sendString(response.SerializeToString()) print response.SerializeToString() print "Length " print len(response.SerializeToString()) print "-----------------------------------" - self.sendString(response.SerializeToString()) def mobilityConfig(self): t = 10 From 5ae2b69a15ee8f0ab2665e7f5576e97dd6899413 Mon Sep 17 00:00:00 2001 From: mirrorZ Date: Tue, 26 Nov 2019 10:11:35 -0500 Subject: [PATCH 049/116] add serverdag --- tools/overlay/client.conf | 3 +-- tools/overlay/clientconfig.proto | 1 + tools/overlay/xiaclientconfigreader.py | 3 ++- tools/overlay/xiaclientconfigurator.py | 3 +++ 4 files changed, 7 insertions(+), 3 deletions(-) diff --git a/tools/overlay/client.conf b/tools/overlay/client.conf index b64fd21f4..cad7c869e 100644 --- a/tools/overlay/client.conf +++ b/tools/overlay/client.conf @@ -3,9 +3,8 @@ ControlAddress = 10.0.1.130 ControlPort = 8295 Routers = r1 Interfaces = ens40 -Routers = r1 -Interfaces = ens40 Default = r1 +ServerDag = "RE AD:04f61c792990ec39f0af16c6a7c35b6807a61a63 HID:691b1cb51735f5dbbe42282b68e34f96cbfa39b2 AID:69a4e068880cd40549405dfda6e794b0c7fdf192" # [c2] # ControlAddress = 10.0.2.129 diff --git a/tools/overlay/clientconfig.proto b/tools/overlay/clientconfig.proto index 203c3a65f..32dedd837 100644 --- a/tools/overlay/clientconfig.proto +++ b/tools/overlay/clientconfig.proto @@ -9,5 +9,6 @@ message Config { required string port = 4; required string AD = 5; required string HID = 6; + required string serverdag = 7; } diff --git a/tools/overlay/xiaclientconfigreader.py b/tools/overlay/xiaclientconfigreader.py index b84e276ed..256328255 100644 --- a/tools/overlay/xiaclientconfigreader.py +++ b/tools/overlay/xiaclientconfigreader.py @@ -14,6 +14,7 @@ def __init__(self, config_filename): self.router_addr = {} self.ad = {} self.hid = {} + self.serverdag = {} # Read in the config file parser = RawConfigParser() @@ -43,7 +44,7 @@ def __init__(self, config_filename): self.default_router[client] = parser.get(client, 'Default') self.control_addr[client] = parser.get(client, 'ControlAddress') self.control_port[client] = parser.get(client, 'ControlPort') - + self.serverdag[client] = parser.get(client, 'ServerDag') def clients(self): return self.routers.keys() diff --git a/tools/overlay/xiaclientconfigurator.py b/tools/overlay/xiaclientconfigurator.py index 788d386df..1471b6f99 100644 --- a/tools/overlay/xiaclientconfigurator.py +++ b/tools/overlay/xiaclientconfigurator.py @@ -29,6 +29,7 @@ def __init__(self, config_filename): self.hid = {} self.router_addr = {} self.router_iface = {} + self.serverdag = {} # Read in the config file parser = RawConfigParser() @@ -60,6 +61,7 @@ def __init__(self, config_filename): self.default_router[client] = parser.get(client, 'Default') self.control_addr[client] = parser.get(client, 'ControlAddress') self.control_port[client] = parser.get(client, 'ControlPort') + self.serverdag[client] = parser.get(client, 'ServerDag') def clients(self): return self.routers.keys() @@ -92,6 +94,7 @@ def sendConfig(self, router): response.port = "8792" response.AD = self.clientConfigurator.clientConfig.ad[router] response.HID =self.clientConfigurator.clientConfig.hid[router] + response.serverdag = self.clientConfigurator.clientConfig.serverdag[self.client] print "Sending config to " + self.client self.sendString(response.SerializeToString()) From ad9f0d9cee50798b2642baa03ce4d9df1b3a9b5e Mon Sep 17 00:00:00 2001 From: mirrorZ Date: Tue, 26 Nov 2019 13:35:35 -0500 Subject: [PATCH 050/116] add serverdag --- tools/overlay/xiaclientconfigurator.py | 1 + 1 file changed, 1 insertion(+) diff --git a/tools/overlay/xiaclientconfigurator.py b/tools/overlay/xiaclientconfigurator.py index 1471b6f99..b39adaa22 100644 --- a/tools/overlay/xiaclientconfigurator.py +++ b/tools/overlay/xiaclientconfigurator.py @@ -95,6 +95,7 @@ def sendConfig(self, router): response.AD = self.clientConfigurator.clientConfig.ad[router] response.HID =self.clientConfigurator.clientConfig.hid[router] response.serverdag = self.clientConfigurator.clientConfig.serverdag[self.client] + print "Adding serverdag " + response.serverdag print "Sending config to " + self.client self.sendString(response.SerializeToString()) From c81766b362d732ecc12b1b1789c59e975a4af681 Mon Sep 17 00:00:00 2001 From: mirrorZ Date: Tue, 26 Nov 2019 19:01:25 +0000 Subject: [PATCH 051/116] fix typo --- tools/overlay/client.conf | 3 +-- tools/overlay/xiaclientconfigurator.py | 1 + 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/tools/overlay/client.conf b/tools/overlay/client.conf index cad7c869e..e172b9d97 100644 --- a/tools/overlay/client.conf +++ b/tools/overlay/client.conf @@ -4,8 +4,7 @@ ControlPort = 8295 Routers = r1 Interfaces = ens40 Default = r1 -ServerDag = "RE AD:04f61c792990ec39f0af16c6a7c35b6807a61a63 HID:691b1cb51735f5dbbe42282b68e34f96cbfa39b2 AID:69a4e068880cd40549405dfda6e794b0c7fdf192" - +ServerDag = RE AD:04f61c792990ec39f0af16c6a7c35b6807a61a63 HID:691b1cb51735f5dbbe42282b68e34f96cbfa39b2 AID:69a4e068880cd40549405dfda6e794b0c7fdf192 # [c2] # ControlAddress = 10.0.2.129 # ControlPort = 8295 diff --git a/tools/overlay/xiaclientconfigurator.py b/tools/overlay/xiaclientconfigurator.py index b39adaa22..44d597805 100644 --- a/tools/overlay/xiaclientconfigurator.py +++ b/tools/overlay/xiaclientconfigurator.py @@ -95,6 +95,7 @@ def sendConfig(self, router): response.AD = self.clientConfigurator.clientConfig.ad[router] response.HID =self.clientConfigurator.clientConfig.hid[router] response.serverdag = self.clientConfigurator.clientConfig.serverdag[self.client] + print "Adding ad " + response.AD print "Adding serverdag " + response.serverdag print "Sending config to " + self.client From 1c9fd1efd05168d67b1a0ab7f28f83c9e2463018 Mon Sep 17 00:00:00 2001 From: mirrorZ Date: Tue, 26 Nov 2019 23:22:35 -0500 Subject: [PATCH 052/116] configure aid from configurator --- tools/overlay/client.conf | 1 + tools/overlay/clientconfig.proto | 13 +++++++------ tools/overlay/xiaclientconfigurator.py | 5 +++-- 3 files changed, 11 insertions(+), 8 deletions(-) diff --git a/tools/overlay/client.conf b/tools/overlay/client.conf index e172b9d97..e77549c68 100644 --- a/tools/overlay/client.conf +++ b/tools/overlay/client.conf @@ -1,4 +1,5 @@ [c1] +AID = AID:69a4e068880cd40549405dfda6e794b0c7fdf195 ControlAddress = 10.0.1.130 ControlPort = 8295 Routers = r1 diff --git a/tools/overlay/clientconfig.proto b/tools/overlay/clientconfig.proto index 32dedd837..268954ca0 100644 --- a/tools/overlay/clientconfig.proto +++ b/tools/overlay/clientconfig.proto @@ -4,11 +4,12 @@ package clientconfig; message Config { required string name = 1; - required string ipaddr = 2; - required string iface = 3; - required string port = 4; - required string AD = 5; - required string HID = 6; - required string serverdag = 7; + required string AID = 2; + required string ipaddr = 3; + required string iface = 4; + required string port = 5; + required string AD = 6; + required string HID = 7; + required string serverdag = 8; } diff --git a/tools/overlay/xiaclientconfigurator.py b/tools/overlay/xiaclientconfigurator.py index 44d597805..9ccabde55 100644 --- a/tools/overlay/xiaclientconfigurator.py +++ b/tools/overlay/xiaclientconfigurator.py @@ -25,6 +25,7 @@ def __init__(self, config_filename): self.default_router = {} self.control_addr = {} self.control_port = {} + self.aid = {} self.ad = {} self.hid = {} self.router_addr = {} @@ -62,6 +63,7 @@ def __init__(self, config_filename): self.control_addr[client] = parser.get(client, 'ControlAddress') self.control_port[client] = parser.get(client, 'ControlPort') self.serverdag[client] = parser.get(client, 'ServerDag') + self.aid[client] = parser.get(client, 'AID') def clients(self): return self.routers.keys() @@ -92,11 +94,10 @@ def sendConfig(self, router): response.ipaddr = self.clientConfigurator.clientConfig.router_addr[router] response.iface = self.clientConfigurator.clientConfig.router_iface[self.client][router] response.port = "8792" + response.AID = self.clientConfigurator.clientConfig.aid[self.client] response.AD = self.clientConfigurator.clientConfig.ad[router] response.HID =self.clientConfigurator.clientConfig.hid[router] response.serverdag = self.clientConfigurator.clientConfig.serverdag[self.client] - print "Adding ad " + response.AD - print "Adding serverdag " + response.serverdag print "Sending config to " + self.client self.sendString(response.SerializeToString()) From d42efc2d3072cdedd5642757fa87cb692b04f275 Mon Sep 17 00:00:00 2001 From: mirrorZ Date: Wed, 27 Nov 2019 10:16:25 -0500 Subject: [PATCH 053/116] Update conf --- tools/overlay/client.conf | 16 ++++++++++------ tools/overlay/demo.conf | 16 +++++++--------- 2 files changed, 17 insertions(+), 15 deletions(-) diff --git a/tools/overlay/client.conf b/tools/overlay/client.conf index e77549c68..92ee84c05 100644 --- a/tools/overlay/client.conf +++ b/tools/overlay/client.conf @@ -5,9 +5,13 @@ ControlPort = 8295 Routers = r1 Interfaces = ens40 Default = r1 -ServerDag = RE AD:04f61c792990ec39f0af16c6a7c35b6807a61a63 HID:691b1cb51735f5dbbe42282b68e34f96cbfa39b2 AID:69a4e068880cd40549405dfda6e794b0c7fdf192 -# [c2] -# ControlAddress = 10.0.2.129 -# ControlPort = 8295 -# Routers = r1 -# Default = r1 \ No newline at end of file +ServerDag = RE AD:04f61c792990ec39f0af16c6a7c35b6807a61a63 HID:691b1cb51735f5dbbe42282b68e34f96cbfa39b2 AID:69a4e068880cd40549405dfda6e794b0c7fdf1924 + +[c2] +AID = AID:69a4e068880cd40549405dfda6e794b0c7fdf1924 +ControlAddress = 10.0.1.133 +ControlPort = 8295 +Routers = r2 +Interfaces = ens34 +Default = r2 +ServerDag = "" \ No newline at end of file diff --git a/tools/overlay/demo.conf b/tools/overlay/demo.conf index 8bbec64d9..7a232412f 100644 --- a/tools/overlay/demo.conf +++ b/tools/overlay/demo.conf @@ -4,13 +4,11 @@ Interfaces = ens34,ens35,ens39 HostInterface = ens35 HostAddr = 10.0.2.129 NameServer = true -#Route_r2 = ens39 -> ens34:r2 - -# [r2] -# ControlAddress = 10.0.1.132 -# Interfaces = ens34,ens35,ens40 -# HostInterface = ens35 -# HostAddr = 10.0.6.128 -# Route_r1 = ens34 -> ens39:r1 -# Xcache = true +Route_r2 = ens39 -> ens34:r2 +[r2] +ControlAddress = 10.0.1.132 +Interfaces = ens34,ens39,ens40 +HostInterface = ens39 +HostAddr = 10.0.4.129 +Route_r1 = ens34 -> ens39:r1 From 5095bca30fea6965cb9f280667ddfd18516c9370 Mon Sep 17 00:00:00 2001 From: mirrorZ Date: Wed, 27 Nov 2019 10:58:59 -0500 Subject: [PATCH 054/116] Update conf --- tools/overlay/client.conf | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/overlay/client.conf b/tools/overlay/client.conf index 92ee84c05..bd29f814b 100644 --- a/tools/overlay/client.conf +++ b/tools/overlay/client.conf @@ -5,7 +5,7 @@ ControlPort = 8295 Routers = r1 Interfaces = ens40 Default = r1 -ServerDag = RE AD:04f61c792990ec39f0af16c6a7c35b6807a61a63 HID:691b1cb51735f5dbbe42282b68e34f96cbfa39b2 AID:69a4e068880cd40549405dfda6e794b0c7fdf1924 +ServerDag = RE AD:0e947b9eaee9f664c84308363cb7f254bee2bbd8 HID:d4ab91c2e203a3af6eb5a23dc26bc841e5efff16 AID:69a4e068880cd40549405dfda6e794b0c7fdf1924 [c2] AID = AID:69a4e068880cd40549405dfda6e794b0c7fdf1924 From e615d42bd29a578d7324b425346e109b538b15e2 Mon Sep 17 00:00:00 2001 From: mirrorZ Date: Thu, 28 Nov 2019 20:36:44 -0500 Subject: [PATCH 055/116] Update conf --- tools/overlay/client.conf | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tools/overlay/client.conf b/tools/overlay/client.conf index bd29f814b..d52d7ab53 100644 --- a/tools/overlay/client.conf +++ b/tools/overlay/client.conf @@ -5,10 +5,10 @@ ControlPort = 8295 Routers = r1 Interfaces = ens40 Default = r1 -ServerDag = RE AD:0e947b9eaee9f664c84308363cb7f254bee2bbd8 HID:d4ab91c2e203a3af6eb5a23dc26bc841e5efff16 AID:69a4e068880cd40549405dfda6e794b0c7fdf1924 +ServerDag = RE AD:0e947b9eaee9f664c84308363cb7f254bee2bbd8 HID:d4ab91c2e203a3af6eb5a23dc26bc841e5efff16 AID:69a4e068880cd40549405dfda6e794b0c7fdf192 [c2] -AID = AID:69a4e068880cd40549405dfda6e794b0c7fdf1924 +AID = AID:69a4e068880cd40549405dfda6e794b0c7fdf192 ControlAddress = 10.0.1.133 ControlPort = 8295 Routers = r2 From fa5ec731839f3fa7300cf8c68f02d1a44377b63c Mon Sep 17 00:00:00 2001 From: mirrorZ Date: Thu, 28 Nov 2019 20:47:16 -0500 Subject: [PATCH 056/116] Update conf --- tools/overlay/client.conf | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/overlay/client.conf b/tools/overlay/client.conf index d52d7ab53..272a00f90 100644 --- a/tools/overlay/client.conf +++ b/tools/overlay/client.conf @@ -14,4 +14,4 @@ ControlPort = 8295 Routers = r2 Interfaces = ens34 Default = r2 -ServerDag = "" \ No newline at end of file +ServerDag = RE AID:69a4e068880cd40549405dfda6e794b0c7fdf192 \ No newline at end of file From 279098d32a24c0fc096e2e5fc1b34105345f9035 Mon Sep 17 00:00:00 2001 From: mirrorZ Date: Thu, 28 Nov 2019 22:11:59 -0500 Subject: [PATCH 057/116] some fixes --- tools/overlay/xiaclientconfigurator.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/overlay/xiaclientconfigurator.py b/tools/overlay/xiaclientconfigurator.py index 9ccabde55..f22407839 100644 --- a/tools/overlay/xiaclientconfigurator.py +++ b/tools/overlay/xiaclientconfigurator.py @@ -93,7 +93,7 @@ def sendConfig(self, router): response.name = self.client response.ipaddr = self.clientConfigurator.clientConfig.router_addr[router] response.iface = self.clientConfigurator.clientConfig.router_iface[self.client][router] - response.port = "8792" + response.port = "8770" response.AID = self.clientConfigurator.clientConfig.aid[self.client] response.AD = self.clientConfigurator.clientConfig.ad[router] response.HID =self.clientConfigurator.clientConfig.hid[router] From b11908c3d546625eab388a3de28390f558873806 Mon Sep 17 00:00:00 2001 From: mirrorZ Date: Fri, 29 Nov 2019 02:24:16 -0500 Subject: [PATCH 058/116] Update conf --- tools/overlay/demo.conf | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tools/overlay/demo.conf b/tools/overlay/demo.conf index 7a232412f..18e198bf3 100644 --- a/tools/overlay/demo.conf +++ b/tools/overlay/demo.conf @@ -1,6 +1,6 @@ [r1] ControlAddress = 10.0.1.129 -Interfaces = ens34,ens35,ens39 +Interfaces = ens35,ens39,ens34 HostInterface = ens35 HostAddr = 10.0.2.129 NameServer = true @@ -8,7 +8,7 @@ Route_r2 = ens39 -> ens34:r2 [r2] ControlAddress = 10.0.1.132 -Interfaces = ens34,ens39,ens40 +Interfaces = ens39,ens40,ens34 HostInterface = ens39 HostAddr = 10.0.4.129 Route_r1 = ens34 -> ens39:r1 From 4f78409200e1bac59ed9a5b38868e5ea77d521fb Mon Sep 17 00:00:00 2001 From: mirrorZ Date: Sat, 30 Nov 2019 13:13:58 -0500 Subject: [PATCH 059/116] debug --- click/elements/xia/xiaxidroutetable.cc | 3 +++ 1 file changed, 3 insertions(+) diff --git a/click/elements/xia/xiaxidroutetable.cc b/click/elements/xia/xiaxidroutetable.cc index 8b7e395af..cce9e2236 100644 --- a/click/elements/xia/xiaxidroutetable.cc +++ b/click/elements/xia/xiaxidroutetable.cc @@ -151,7 +151,10 @@ XIAXIDRouteTable::set_handler(const String &conf, Element *e, void *thunk, Error int port; if (!cp_integer(str_copy, &port)) + { + printf("got invalid port %d", port); return errh->error("invalid port: ", str_copy.c_str()); + } String str = xid_str + "," + String(port) + ",,0"; From 40ede1f0a3e76c4985d72d36a42225b223cb4bb3 Mon Sep 17 00:00:00 2001 From: mirrorZ Date: Sun, 1 Dec 2019 00:23:49 -0500 Subject: [PATCH 060/116] debug --- click/elements/xia/fidrouteengine.cc | 3 +++ click/elements/xia/xiaxidroutetable.cc | 23 ++++++++++++++++------- 2 files changed, 19 insertions(+), 7 deletions(-) diff --git a/click/elements/xia/fidrouteengine.cc b/click/elements/xia/fidrouteengine.cc index fcf7558e2..46cfbd538 100644 --- a/click/elements/xia/fidrouteengine.cc +++ b/click/elements/xia/fidrouteengine.cc @@ -192,7 +192,10 @@ int FIDRouteEngine::set_handler(const String &conf, Element *e, void *thunk, Err int port; if (!cp_integer(str_copy, &port)) + { + printf("got invalid port %d", port); return errh->error("invalid port: ", str_copy.c_str()); + } String str = xid_str + "," + String(port) + ",,0"; diff --git a/click/elements/xia/xiaxidroutetable.cc b/click/elements/xia/xiaxidroutetable.cc index cce9e2236..4816abb8c 100644 --- a/click/elements/xia/xiaxidroutetable.cc +++ b/click/elements/xia/xiaxidroutetable.cc @@ -152,7 +152,7 @@ XIAXIDRouteTable::set_handler(const String &conf, Element *e, void *thunk, Error int port; if (!cp_integer(str_copy, &port)) { - printf("got invalid port %d", port); + printf("got invalid port %d at %d", port, __LINE__); return errh->error("invalid port: ", str_copy.c_str()); } @@ -182,8 +182,10 @@ XIAXIDRouteTable::set_handler4(const String &conf, Element *e, void *thunk, Erro xid_str = args[0]; if (!cp_integer(args[1], &port)) - return errh->error("invalid port: ", conf.c_str()); - + { + printf("got invalid port %d at %d", port, __LINE__); + return errh->error("invalid port: ", args[1].c_str()); + } if (args.size() == 4) { if (!cp_integer(args[3], &flags)) return errh->error("invalid flags: ", conf.c_str()); @@ -252,8 +254,10 @@ XIAXIDRouteTable::set_udpnext(const String &conf, Element *e, void *thunk, Error xid_str = args[0]; // Second argument is the interface that matching packet should go out on - if(!cp_integer(args[1], &port)) { - return errh->error("Invalid port: ", conf.c_str()); + if(!cp_integer(args[1], &port)) + { + printf("got invalid port %d at %d", port, __LINE__); + return errh->error("invalid port: ", args[1].c_str()); } // Third argument should be IPaddr:port of next hop @@ -274,8 +278,10 @@ XIAXIDRouteTable::set_udpnext(const String &conf, Element *e, void *thunk, Error return errh->error("Invalid ipaddr: ", ipaddrstr.c_str()); } int ipport = atoi(portstr.c_str()); - if(ipport < 0 || ipport > 65535) { - return errh->error("Invalid port: ", portstr.c_str()); + if(ipport < 0 || ipport > 65535) + { + printf("got invalid port %d at %d", port, __LINE__); + return errh->error("invalid port: ", portstr.c_str()); } // Convert address to a sockaddr_in and save into forwarding table @@ -447,7 +453,10 @@ XIAXIDRouteTable::generate_routes_handler(const String &conf, Element *e, void * String port_str = cp_shift_spacevec(conf_copy); int port; if (!cp_integer(port_str, &port)) + { + printf("got invalid port %d at %d", port, __LINE__); return errh->error("invalid port: ", port_str.c_str()); + } #if CLICK_USERLEVEL unsigned short xsubi[3]; From 73c4df5c336281d1ac6714ebcd8d80e09f8f23cd Mon Sep 17 00:00:00 2001 From: mirrorZ Date: Sun, 1 Dec 2019 01:10:03 -0500 Subject: [PATCH 061/116] debug --- click/elements/xia/fidrouteengine.cc | 3 +++ click/elements/xia/xiaxidroutetable.cc | 10 +++++----- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/click/elements/xia/fidrouteengine.cc b/click/elements/xia/fidrouteengine.cc index 46cfbd538..eb7132599 100644 --- a/click/elements/xia/fidrouteengine.cc +++ b/click/elements/xia/fidrouteengine.cc @@ -222,7 +222,10 @@ int FIDRouteEngine::set_handler4(const String &conf, Element *e, void *thunk, Er xid_str = args[0]; if (!cp_integer(args[1], &port)) + { + printf("Invalid port %d in %d ", port, __LINE__); return errh->error("invalid port: ", conf.c_str()); + } if (args.size() == 4) { if (!cp_integer(args[3], &flags)) diff --git a/click/elements/xia/xiaxidroutetable.cc b/click/elements/xia/xiaxidroutetable.cc index 4816abb8c..6361eb997 100644 --- a/click/elements/xia/xiaxidroutetable.cc +++ b/click/elements/xia/xiaxidroutetable.cc @@ -153,7 +153,7 @@ XIAXIDRouteTable::set_handler(const String &conf, Element *e, void *thunk, Error if (!cp_integer(str_copy, &port)) { printf("got invalid port %d at %d", port, __LINE__); - return errh->error("invalid port: ", str_copy.c_str()); + return errh->error("invalid port 1: ", str_copy.c_str()); } String str = xid_str + "," + String(port) + ",,0"; @@ -184,7 +184,7 @@ XIAXIDRouteTable::set_handler4(const String &conf, Element *e, void *thunk, Erro if (!cp_integer(args[1], &port)) { printf("got invalid port %d at %d", port, __LINE__); - return errh->error("invalid port: ", args[1].c_str()); + return errh->error("invalid port 2: ", args[1].c_str()); } if (args.size() == 4) { if (!cp_integer(args[3], &flags)) @@ -257,7 +257,7 @@ XIAXIDRouteTable::set_udpnext(const String &conf, Element *e, void *thunk, Error if(!cp_integer(args[1], &port)) { printf("got invalid port %d at %d", port, __LINE__); - return errh->error("invalid port: ", args[1].c_str()); + return errh->error("invalid port 3: ", args[1].c_str()); } // Third argument should be IPaddr:port of next hop @@ -281,7 +281,7 @@ XIAXIDRouteTable::set_udpnext(const String &conf, Element *e, void *thunk, Error if(ipport < 0 || ipport > 65535) { printf("got invalid port %d at %d", port, __LINE__); - return errh->error("invalid port: ", portstr.c_str()); + return errh->error("invalid port 4: ", portstr.c_str()); } // Convert address to a sockaddr_in and save into forwarding table @@ -455,7 +455,7 @@ XIAXIDRouteTable::generate_routes_handler(const String &conf, Element *e, void * if (!cp_integer(port_str, &port)) { printf("got invalid port %d at %d", port, __LINE__); - return errh->error("invalid port: ", port_str.c_str()); + return errh->error("invalid port 5: ", port_str.c_str()); } #if CLICK_USERLEVEL From f4e10cbd6109a51ab10cfec13fbd2ffadf30c32a Mon Sep 17 00:00:00 2001 From: mirrorZ Date: Sun, 1 Dec 2019 01:23:10 -0500 Subject: [PATCH 062/116] debug --- click/elements/xia/xiaxidroutetable.cc | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/click/elements/xia/xiaxidroutetable.cc b/click/elements/xia/xiaxidroutetable.cc index 6361eb997..6dbb22d74 100644 --- a/click/elements/xia/xiaxidroutetable.cc +++ b/click/elements/xia/xiaxidroutetable.cc @@ -183,7 +183,10 @@ XIAXIDRouteTable::set_handler4(const String &conf, Element *e, void *thunk, Erro if (!cp_integer(args[1], &port)) { - printf("got invalid port %d at %d", port, __LINE__); + FILE *fp; + fp = fopen("xrout", "w+"); + fprintf(fp, "The port was %s -> %d \n", args[1], port); + fclose(fp); return errh->error("invalid port 2: ", args[1].c_str()); } if (args.size() == 4) { From c5dd4d25dc02876e7966277e4e960d7e3c6c64a1 Mon Sep 17 00:00:00 2001 From: mirrorZ Date: Sun, 1 Dec 2019 01:27:29 -0500 Subject: [PATCH 063/116] debug --- click/elements/xia/xiaxidroutetable.cc | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/click/elements/xia/xiaxidroutetable.cc b/click/elements/xia/xiaxidroutetable.cc index 6dbb22d74..b547c1bc2 100644 --- a/click/elements/xia/xiaxidroutetable.cc +++ b/click/elements/xia/xiaxidroutetable.cc @@ -173,7 +173,9 @@ XIAXIDRouteTable::set_handler4(const String &conf, Element *e, void *thunk, Erro unsigned flags = 0; String xid_str; XID *nexthop = NULL; - + FILE *fp; + fp = fopen("xrout", "w+"); + fprintf(fp, "conf recvd %s \n", conf); cp_argvec(conf, args); if (args.size() < 2 || args.size() > 4) @@ -183,8 +185,6 @@ XIAXIDRouteTable::set_handler4(const String &conf, Element *e, void *thunk, Erro if (!cp_integer(args[1], &port)) { - FILE *fp; - fp = fopen("xrout", "w+"); fprintf(fp, "The port was %s -> %d \n", args[1], port); fclose(fp); return errh->error("invalid port 2: ", args[1].c_str()); From 76c14c32d0fac8b9c558fe8a0030dc342eaaf7a0 Mon Sep 17 00:00:00 2001 From: mirrorZ Date: Sun, 1 Dec 2019 01:31:18 -0500 Subject: [PATCH 064/116] debug --- click/elements/xia/xiaxidroutetable.cc | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/click/elements/xia/xiaxidroutetable.cc b/click/elements/xia/xiaxidroutetable.cc index b547c1bc2..78146f0a6 100644 --- a/click/elements/xia/xiaxidroutetable.cc +++ b/click/elements/xia/xiaxidroutetable.cc @@ -156,7 +156,12 @@ XIAXIDRouteTable::set_handler(const String &conf, Element *e, void *thunk, Error return errh->error("invalid port 1: ", str_copy.c_str()); } + FILE *fp; + fp = fopen("xrout", "w+"); + String str = xid_str + "," + String(port) + ",,0"; + fprintf(fp, "sending str %s \n", str); + fclose(fp); return set_handler4(str, e, thunk, errh); } From dd9b3b85a01720752b0bb7141f25e276f6a7eb1a Mon Sep 17 00:00:00 2001 From: mirrorZ Date: Sun, 1 Dec 2019 01:34:34 -0500 Subject: [PATCH 065/116] debug --- click/elements/xia/fidrouteengine.cc | 4 ++++ click/elements/xia/xiaxidroutetable.cc | 4 ++-- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/click/elements/xia/fidrouteengine.cc b/click/elements/xia/fidrouteengine.cc index eb7132599..b02d883f2 100644 --- a/click/elements/xia/fidrouteengine.cc +++ b/click/elements/xia/fidrouteengine.cc @@ -198,6 +198,10 @@ int FIDRouteEngine::set_handler(const String &conf, Element *e, void *thunk, Err } String str = xid_str + "," + String(port) + ",,0"; + FILE *fp; + fp = fopen("xrout", "w+"); + fprintf(fp, "sending str %s \n", str.c_str()); + fclose(fp); return set_handler4(str, e, thunk, errh); } diff --git a/click/elements/xia/xiaxidroutetable.cc b/click/elements/xia/xiaxidroutetable.cc index 78146f0a6..578a92ca5 100644 --- a/click/elements/xia/xiaxidroutetable.cc +++ b/click/elements/xia/xiaxidroutetable.cc @@ -180,7 +180,7 @@ XIAXIDRouteTable::set_handler4(const String &conf, Element *e, void *thunk, Erro XID *nexthop = NULL; FILE *fp; fp = fopen("xrout", "w+"); - fprintf(fp, "conf recvd %s \n", conf); + fprintf(fp, "conf recvd %s \n", conf.c_str()); cp_argvec(conf, args); if (args.size() < 2 || args.size() > 4) @@ -190,7 +190,7 @@ XIAXIDRouteTable::set_handler4(const String &conf, Element *e, void *thunk, Erro if (!cp_integer(args[1], &port)) { - fprintf(fp, "The port was %s -> %d \n", args[1], port); + fprintf(fp, "The port was %s -> %d \n", args[1].c_str(), port); fclose(fp); return errh->error("invalid port 2: ", args[1].c_str()); } From 40b3d8cedff9e21c7f217b9d4ea2dda17a5a53ad Mon Sep 17 00:00:00 2001 From: mirrorZ Date: Sun, 1 Dec 2019 01:58:06 -0500 Subject: [PATCH 066/116] debug --- click/elements/xia/xiaxidroutetable.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/click/elements/xia/xiaxidroutetable.cc b/click/elements/xia/xiaxidroutetable.cc index 578a92ca5..e9e6f9833 100644 --- a/click/elements/xia/xiaxidroutetable.cc +++ b/click/elements/xia/xiaxidroutetable.cc @@ -179,7 +179,7 @@ XIAXIDRouteTable::set_handler4(const String &conf, Element *e, void *thunk, Erro String xid_str; XID *nexthop = NULL; FILE *fp; - fp = fopen("xrout", "w+"); + fp = fopen("xrout", "a"); fprintf(fp, "conf recvd %s \n", conf.c_str()); cp_argvec(conf, args); From a54f5129d3cb70230e580a5cfa65787df99f63ac Mon Sep 17 00:00:00 2001 From: mirrorZ Date: Sun, 1 Dec 2019 02:03:16 -0500 Subject: [PATCH 067/116] debug --- click/elements/xia/xiaxidroutetable.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/click/elements/xia/xiaxidroutetable.cc b/click/elements/xia/xiaxidroutetable.cc index e9e6f9833..df3a19444 100644 --- a/click/elements/xia/xiaxidroutetable.cc +++ b/click/elements/xia/xiaxidroutetable.cc @@ -160,7 +160,7 @@ XIAXIDRouteTable::set_handler(const String &conf, Element *e, void *thunk, Error fp = fopen("xrout", "w+"); String str = xid_str + "," + String(port) + ",,0"; - fprintf(fp, "sending str %s \n", str); + fprintf(fp, "sending str %s \n", str.c_str()); fclose(fp); return set_handler4(str, e, thunk, errh); From 24bdc405dee51e2903573696c983c5947538571b Mon Sep 17 00:00:00 2001 From: mirrorZ Date: Sun, 1 Dec 2019 02:30:57 -0500 Subject: [PATCH 068/116] debug --- click/elements/xia/xiaxidroutetable.cc | 5 ----- tools/overlay/client.conf | 2 +- 2 files changed, 1 insertion(+), 6 deletions(-) diff --git a/click/elements/xia/xiaxidroutetable.cc b/click/elements/xia/xiaxidroutetable.cc index df3a19444..8c3aa29c5 100644 --- a/click/elements/xia/xiaxidroutetable.cc +++ b/click/elements/xia/xiaxidroutetable.cc @@ -156,12 +156,7 @@ XIAXIDRouteTable::set_handler(const String &conf, Element *e, void *thunk, Error return errh->error("invalid port 1: ", str_copy.c_str()); } - FILE *fp; - fp = fopen("xrout", "w+"); - String str = xid_str + "," + String(port) + ",,0"; - fprintf(fp, "sending str %s \n", str.c_str()); - fclose(fp); return set_handler4(str, e, thunk, errh); } diff --git a/tools/overlay/client.conf b/tools/overlay/client.conf index 272a00f90..4c55ba2b6 100644 --- a/tools/overlay/client.conf +++ b/tools/overlay/client.conf @@ -5,7 +5,7 @@ ControlPort = 8295 Routers = r1 Interfaces = ens40 Default = r1 -ServerDag = RE AD:0e947b9eaee9f664c84308363cb7f254bee2bbd8 HID:d4ab91c2e203a3af6eb5a23dc26bc841e5efff16 AID:69a4e068880cd40549405dfda6e794b0c7fdf192 +ServerDag = RE AD:1ff8cb8d5d0afeee9e3af7dfc0099a52e4764916 HID:c71d04d17f225ffc71ba6bf31a673e51386c533c AID:69a4e068880cd40549405dfda6e794b0c7fdf192 [c2] AID = AID:69a4e068880cd40549405dfda6e794b0c7fdf192 From ea97fc122e82be05d8a0ab024f2c6bb09ea3c089 Mon Sep 17 00:00:00 2001 From: mirrorZ Date: Sun, 1 Dec 2019 02:32:31 -0500 Subject: [PATCH 069/116] debug --- tools/overlay/client.conf | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/tools/overlay/client.conf b/tools/overlay/client.conf index 4c55ba2b6..a7152b33b 100644 --- a/tools/overlay/client.conf +++ b/tools/overlay/client.conf @@ -1,3 +1,12 @@ +[c2] +AID = AID:69a4e068880cd40549405dfda6e794b0c7fdf192 +ControlAddress = 10.0.1.133 +ControlPort = 8295 +Routers = r2 +Interfaces = ens34 +Default = r2 +ServerDag = RE AID:69a4e068880cd40549405dfda6e794b0c7fdf192 + [c1] AID = AID:69a4e068880cd40549405dfda6e794b0c7fdf195 ControlAddress = 10.0.1.130 @@ -6,12 +15,3 @@ Routers = r1 Interfaces = ens40 Default = r1 ServerDag = RE AD:1ff8cb8d5d0afeee9e3af7dfc0099a52e4764916 HID:c71d04d17f225ffc71ba6bf31a673e51386c533c AID:69a4e068880cd40549405dfda6e794b0c7fdf192 - -[c2] -AID = AID:69a4e068880cd40549405dfda6e794b0c7fdf192 -ControlAddress = 10.0.1.133 -ControlPort = 8295 -Routers = r2 -Interfaces = ens34 -Default = r2 -ServerDag = RE AID:69a4e068880cd40549405dfda6e794b0c7fdf192 \ No newline at end of file From d11d09e0287367ab36909e170f75a206e696f78b Mon Sep 17 00:00:00 2001 From: mirrorZ Date: Sun, 1 Dec 2019 21:18:59 -0500 Subject: [PATCH 070/116] Some clean up --- click/elements/xia/fidrouteengine.cc | 10 ---- click/elements/xia/xiaxidroutetable.cc | 33 ++++---------- tools/overlay/configurer.cpp | 62 ------------------------- tools/overlay/xiaclientconfigreader.py | 57 ----------------------- tools/overlay/xiaclienthelper.py | 63 -------------------------- 5 files changed, 9 insertions(+), 216 deletions(-) delete mode 100644 tools/overlay/configurer.cpp delete mode 100644 tools/overlay/xiaclientconfigreader.py delete mode 100644 tools/overlay/xiaclienthelper.py diff --git a/click/elements/xia/fidrouteengine.cc b/click/elements/xia/fidrouteengine.cc index b02d883f2..fcf7558e2 100644 --- a/click/elements/xia/fidrouteengine.cc +++ b/click/elements/xia/fidrouteengine.cc @@ -192,16 +192,9 @@ int FIDRouteEngine::set_handler(const String &conf, Element *e, void *thunk, Err int port; if (!cp_integer(str_copy, &port)) - { - printf("got invalid port %d", port); return errh->error("invalid port: ", str_copy.c_str()); - } String str = xid_str + "," + String(port) + ",,0"; - FILE *fp; - fp = fopen("xrout", "w+"); - fprintf(fp, "sending str %s \n", str.c_str()); - fclose(fp); return set_handler4(str, e, thunk, errh); } @@ -226,10 +219,7 @@ int FIDRouteEngine::set_handler4(const String &conf, Element *e, void *thunk, Er xid_str = args[0]; if (!cp_integer(args[1], &port)) - { - printf("Invalid port %d in %d ", port, __LINE__); return errh->error("invalid port: ", conf.c_str()); - } if (args.size() == 4) { if (!cp_integer(args[3], &flags)) diff --git a/click/elements/xia/xiaxidroutetable.cc b/click/elements/xia/xiaxidroutetable.cc index 8c3aa29c5..8b7e395af 100644 --- a/click/elements/xia/xiaxidroutetable.cc +++ b/click/elements/xia/xiaxidroutetable.cc @@ -151,10 +151,7 @@ XIAXIDRouteTable::set_handler(const String &conf, Element *e, void *thunk, Error int port; if (!cp_integer(str_copy, &port)) - { - printf("got invalid port %d at %d", port, __LINE__); - return errh->error("invalid port 1: ", str_copy.c_str()); - } + return errh->error("invalid port: ", str_copy.c_str()); String str = xid_str + "," + String(port) + ",,0"; @@ -173,9 +170,7 @@ XIAXIDRouteTable::set_handler4(const String &conf, Element *e, void *thunk, Erro unsigned flags = 0; String xid_str; XID *nexthop = NULL; - FILE *fp; - fp = fopen("xrout", "a"); - fprintf(fp, "conf recvd %s \n", conf.c_str()); + cp_argvec(conf, args); if (args.size() < 2 || args.size() > 4) @@ -184,11 +179,8 @@ XIAXIDRouteTable::set_handler4(const String &conf, Element *e, void *thunk, Erro xid_str = args[0]; if (!cp_integer(args[1], &port)) - { - fprintf(fp, "The port was %s -> %d \n", args[1].c_str(), port); - fclose(fp); - return errh->error("invalid port 2: ", args[1].c_str()); - } + return errh->error("invalid port: ", conf.c_str()); + if (args.size() == 4) { if (!cp_integer(args[3], &flags)) return errh->error("invalid flags: ", conf.c_str()); @@ -257,10 +249,8 @@ XIAXIDRouteTable::set_udpnext(const String &conf, Element *e, void *thunk, Error xid_str = args[0]; // Second argument is the interface that matching packet should go out on - if(!cp_integer(args[1], &port)) - { - printf("got invalid port %d at %d", port, __LINE__); - return errh->error("invalid port 3: ", args[1].c_str()); + if(!cp_integer(args[1], &port)) { + return errh->error("Invalid port: ", conf.c_str()); } // Third argument should be IPaddr:port of next hop @@ -281,10 +271,8 @@ XIAXIDRouteTable::set_udpnext(const String &conf, Element *e, void *thunk, Error return errh->error("Invalid ipaddr: ", ipaddrstr.c_str()); } int ipport = atoi(portstr.c_str()); - if(ipport < 0 || ipport > 65535) - { - printf("got invalid port %d at %d", port, __LINE__); - return errh->error("invalid port 4: ", portstr.c_str()); + if(ipport < 0 || ipport > 65535) { + return errh->error("Invalid port: ", portstr.c_str()); } // Convert address to a sockaddr_in and save into forwarding table @@ -456,10 +444,7 @@ XIAXIDRouteTable::generate_routes_handler(const String &conf, Element *e, void * String port_str = cp_shift_spacevec(conf_copy); int port; if (!cp_integer(port_str, &port)) - { - printf("got invalid port %d at %d", port, __LINE__); - return errh->error("invalid port 5: ", port_str.c_str()); - } + return errh->error("invalid port: ", port_str.c_str()); #if CLICK_USERLEVEL unsigned short xsubi[3]; diff --git a/tools/overlay/configurer.cpp b/tools/overlay/configurer.cpp deleted file mode 100644 index 3f8b12d18..000000000 --- a/tools/overlay/configurer.cpp +++ /dev/null @@ -1,62 +0,0 @@ -#define CONFFILE "local.conf" -#define THEIR_ADDR "THEIR_ADDR" // The THEIR_ADDR entry in config file -#define CLIENT_AID "CLIENT_AID" // The CLIENT_AID entry in config file -#define SERVER_AID "SERVER_AID" // The SERVER_AID entry in config file -#define TICKET_STORE "TICKET_STORE" - - -// create port - - -void getmy_dag(GraphPtr mydag) { - - // bind on config port - - // set up tcp connection and send ping to configurator - - // listen for config string - - // fill mydag - - // connect to the xia router from the dag - - // spin up a thread to listen for future update - -} - -void update_mydag(GraphPtr mydag, socket config_socket) { - - // listen - - // data - - // bind socket - - // make connection - - // update mydag - - // clean up the old connection -} - -auto conf = LocalConfig::get_instance(CONFFILE); - auto server_addr = conf.get(THEIR_ADDR); - auto server_aid = conf.get(SERVER_AID); - auto client_aid = conf.get(CLIENT_AID); - const auto ticket_store_filename = conf.get(TICKET_STORE); - GraphPtr mydag; - sockaddr_x my_address; - int my_addrlen; - - -// A socket to talk to server on - //sockfd = socket(server_address.ss_family, SOCK_DGRAM, IPPROTO_UDP); - sockfd = picoquic_xia_open_server_socket(client_aid.c_str(), mydag); - if(sockfd == INVALID_SOCKET) { - goto client_done; - } - std::cout << "CLIENTADDR: " << mydag->dag_string() << std::endl; - mydag->fill_sockaddr(&my_address); - my_addrlen = sizeof(sockaddr_x); - printf("Created socket to talk to server\n"); - state = 1; // socket created \ No newline at end of file diff --git a/tools/overlay/xiaclientconfigreader.py b/tools/overlay/xiaclientconfigreader.py deleted file mode 100644 index 256328255..000000000 --- a/tools/overlay/xiaclientconfigreader.py +++ /dev/null @@ -1,57 +0,0 @@ - - -from ConfigParser import RawConfigParser - -class XIAClientConfigReader: - def __init__(self, config_filename): - #client metadata - self.routers = {} - self.default_router = {} - self.control_addr = {} - self.control_port = {} - #router metadata - self.router_iface = {} - self.router_addr = {} - self.ad = {} - self.hid = {} - self.serverdag = {} - - # Read in the config file - parser = RawConfigParser() - parser.read(config_filename) - - # Router names are the section names in the config file - clients = parser.sections() - if len(clients) == 0: - print "ERROR: No sections found in config file" - - # Read in info into our internal data structures - for client in clients: - - # Interface names for each router (comma separated list) - routers = parser.get(client, 'Routers') - routers = routers.replace(' ', '') - self.routers[client] = routers.split(',') - - ifaces = parser.get(client, 'Interfaces') - ifaces = ifaces.replace(' '. '') - self.router_iface[client] = [] - r_iface = [] - for i, iface in ifaces: - r_iface[routers[i]] = iface - self.router_iface[client] = r_iface - - self.default_router[client] = parser.get(client, 'Default') - self.control_addr[client] = parser.get(client, 'ControlAddress') - self.control_port[client] = parser.get(client, 'ControlPort') - self.serverdag[client] = parser.get(client, 'ServerDag') - - def clients(self): - return self.routers.keys() - - -if __name__ == "__main__": - config = XIAClientConfigReader("client.conf") - for client in config.clients(): - print client + ':' - print config.routers[client] diff --git a/tools/overlay/xiaclienthelper.py b/tools/overlay/xiaclienthelper.py deleted file mode 100644 index 667500729..000000000 --- a/tools/overlay/xiaclienthelper.py +++ /dev/null @@ -1,63 +0,0 @@ -# Python standard libraries -import os -import sys -import subprocess -import inspect - -# Install python-twisted package for this functionality -from twisted.internet.protocol import Protocol, Factory -from twisted.protocols.basic import Int32StringReceiver -from twisted.internet import reactor - -# Bring in xia and overlay tools into path -srcdir = os.getcwd()[:os.getcwd().rindex('xia-core')+len('xia-core')] -sys.path.append(os.path.join(srcdir, 'bin')) -sys.path.append(os.path.join(srcdir, 'tools/overlay')) - -# XIA libraries -import xiapyutils - -# XIA Overlay configuration libraries and definitions -import clientconfig_pb2 - -import interfaces - -picoquic_directory = "../picoquic" - -class Helper(Int32StringReceiver): - def __init__(self, common_data, addr): - print inspect.stack()[0][3] - self.common_data = common_data - self.addr = addr - - def connectionLost(self, reason): - print inspect.stack()[0][3] - # Clean up any state created in common_data for this connection - print "Connection to client lost" - - def stringReceived(self, recvd_conf): - print inspect.stack()[0][3] - conf = clientconfig_pb2.Config() - conf.ParseFromString(recvd_conf) - - self.handleConfig(conf) - - def handleConfig(self, config): - print "----------------------------------------------" - print "Received" - print config - print "----------------------------------------------" - #reactor.stop() - - -class HelperFactory(Factory): - - def __init__(self): - self.common_data = {} - - def buildProtocol(self, addr): - return Helper(self.common_data, addr) - -# Run helper service -reactor.listenTCP(8295, HelperFactory()) -reactor.run() From edfed0890d3c5a95d4e5d1c54edb39ee0b9add48 Mon Sep 17 00:00:00 2001 From: mirrorZ Date: Sun, 1 Dec 2019 21:20:25 -0500 Subject: [PATCH 071/116] Some clean up --- README.md | 23 +++++++++++------------ 1 file changed, 11 insertions(+), 12 deletions(-) diff --git a/README.md b/README.md index 175b0d510..9c0e16775 100644 --- a/README.md +++ b/README.md @@ -1,30 +1,29 @@ XIA-core ======= -[![Build Status](https://travis-ci.org/XIA-Project/xia-core.svg?branch=xia-v2)](https://travis-ci.org/XIA-Project/xia-core) We are proud to announce version 1.0 of XIA (eXpressive Internet Architecture). XIA (eXpressive Internet Architecture) is a joint research project between Carnegie Mellon University, Boston University, and the University of Wisconsin -at Madison. +at Madison. Information and papers on XIA are available on the [XIA project page](http://cs.cmu.edu/~xia) -XIA design information can be found on the [XIA Wiki](https://github.com/XIA-Project/xia-core/wiki). +XIA design information can be found on the [XIA Wiki](https://github.com/XIA-Project/xia-core/wiki). Information on building and using XIA is also available on the wiki. The main git branch will always contain the most recently released version of -XIA. Other branches will contain ongoing development or research projects and +XIA. Other branches will contain ongoing development or research projects and are not guaranteed to function correctly. If you are interested in using one of the other branches, contact us at the address above for status of the branch. Contact ------- -- Support and general XIA usage questions should be sent to the support email address . +- Support and general XIA usage questions should be sent to the support email address . This address is monitored by several of the XIA developers and we strive to respond in a timely fashion. -- [XIA-Users](https://mailman.srv.cs.cmu.edu/mailman/listinfo/xia-users) is an unmoderated general discussion mailing -list for XIA. Everyone is welcome to join and participate in the discussion, whether you are an XIA user or developer, -or are just curious about to know more about XIA. This is the place to post ideas, share problems and solutions, -and discuss the design and goals of XIA. -- [XIA-Announce](https://mailman.srv.cs.cmu.edu/mailman/listinfo/xia-announce) is a read-only list for announcements +- [XIA-Users](https://mailman.srv.cs.cmu.edu/mailman/listinfo/xia-users) is an unmoderated general discussion mailing +list for XIA. Everyone is welcome to join and participate in the discussion, whether you are an XIA user or developer, +or are just curious about to know more about XIA. This is the place to post ideas, share problems and solutions, +and discuss the design and goals of XIA. +- [XIA-Announce](https://mailman.srv.cs.cmu.edu/mailman/listinfo/xia-announce) is a read-only list for announcements of new XIA releases and events. This list is open to everyone. @@ -72,7 +71,7 @@ with Xcode 4.x. An update to the Click code will be required for use with Xcode * More compatability with Berleley sockets added to the Xsocket API. * Fixed routing issues that could occur between hosts in the same AD. * Many bug fixes. - + Release 1.0 ---------------- * Added support for 4IDs which gives XIA the ability to be encapsulated in IP @@ -93,7 +92,7 @@ such as PlanetLab. * Setting up an XIA network is more automated, for example, most nodes can be brought up with a single command. * Communication between the application level and Click has been changed so that -root access is no longer requried to run XIA. This allows XIA to be used on +root access is no longer requried to run XIA. This allows XIA to be used on PlanetLab nodes where root access is not available. * XIA now works on the latest releases of Fedora and Ubuntu. * Various bug fixes. From de0df2b4aa8bd2920681ea67a87f6ecd121d4514 Mon Sep 17 00:00:00 2001 From: mirrorZ Date: Mon, 2 Dec 2019 01:28:12 -0500 Subject: [PATCH 072/116] Add demo2.conf --- tools/overlay/demo2.conf | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) create mode 100644 tools/overlay/demo2.conf diff --git a/tools/overlay/demo2.conf b/tools/overlay/demo2.conf new file mode 100644 index 000000000..362ddd5e6 --- /dev/null +++ b/tools/overlay/demo2.conf @@ -0,0 +1,22 @@ +[r1] +ControlAddress = 10.0.1.129 +Interfaces = ens35,ens39,ens34,ens40 +HostInterface = ens35 +HostAddr = 10.0.2.129 +NameServer = true +Route_r2 = ens39 -> ens34:r2 +Route_r3 = ens40 -> ens39:r3 + +[r2] +ControlAddress = 10.0.1.132 +Interfaces = ens39,ens40,ens34,ens41 +HostInterface = ens39 +HostAddr = 10.0.4.129 +Route_r1 = ens34 -> ens39:r1 +Route_r3 = ens41 -> ens40:r3 + +[r3] +ControlAddress = 10.0.1.134 +Interfaces = ens38,ens39,ens40 +Route_r1 = ens39 -> ens40:r1 +Route_r2 = ens40 -> ens41:r2 \ No newline at end of file From 153d2b2297a4f66a1a0b1e3b76e04824e4560c72 Mon Sep 17 00:00:00 2001 From: mirrorZ Date: Mon, 2 Dec 2019 11:38:43 -0500 Subject: [PATCH 073/116] update server dag str --- tools/overlay/client.conf | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/tools/overlay/client.conf b/tools/overlay/client.conf index a7152b33b..216938710 100644 --- a/tools/overlay/client.conf +++ b/tools/overlay/client.conf @@ -14,4 +14,5 @@ ControlPort = 8295 Routers = r1 Interfaces = ens40 Default = r1 -ServerDag = RE AD:1ff8cb8d5d0afeee9e3af7dfc0099a52e4764916 HID:c71d04d17f225ffc71ba6bf31a673e51386c533c AID:69a4e068880cd40549405dfda6e794b0c7fdf192 +#ServerDag = RE AD:1ff8cb8d5d0afeee9e3af7dfc0099a52e4764916 HID:c71d04d17f225ffc71ba6bf31a673e51386c533c AID:69a4e068880cd40549405dfda6e794b0c7fdf192 +ServerDag = RE (AD:cc8249bfea9de0461ae4127ebcd3b0ed0b6338e9 HID:813f0679821b6ba19602daf5a0471d62b721b4eb) AD:1ff8cb8d5d0afeee9e3af7dfc0099a52e4764916 HID:c71d04d17f225ffc71ba6bf31a673e51386c533c AID:69a4e068880cd40549405dfda6e794b0c7fdf192 From 0c18691036f2e9ce9f10509ab85b7d58633ab145 Mon Sep 17 00:00:00 2001 From: mirrorZ Date: Mon, 2 Dec 2019 11:40:39 -0500 Subject: [PATCH 074/116] update server dag str --- tools/overlay/client.conf | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/overlay/client.conf b/tools/overlay/client.conf index 216938710..ee3cde7f2 100644 --- a/tools/overlay/client.conf +++ b/tools/overlay/client.conf @@ -15,4 +15,4 @@ Routers = r1 Interfaces = ens40 Default = r1 #ServerDag = RE AD:1ff8cb8d5d0afeee9e3af7dfc0099a52e4764916 HID:c71d04d17f225ffc71ba6bf31a673e51386c533c AID:69a4e068880cd40549405dfda6e794b0c7fdf192 -ServerDag = RE (AD:cc8249bfea9de0461ae4127ebcd3b0ed0b6338e9 HID:813f0679821b6ba19602daf5a0471d62b721b4eb) AD:1ff8cb8d5d0afeee9e3af7dfc0099a52e4764916 HID:c71d04d17f225ffc71ba6bf31a673e51386c533c AID:69a4e068880cd40549405dfda6e794b0c7fdf192 +ServerDag = RE ( AD:cc8249bfea9de0461ae4127ebcd3b0ed0b6338e9 HID:813f0679821b6ba19602daf5a0471d62b721b4eb ) AD:1ff8cb8d5d0afeee9e3af7dfc0099a52e4764916 HID:c71d04d17f225ffc71ba6bf31a673e51386c533c AID:69a4e068880cd40549405dfda6e794b0c7fdf192 From af1e706e7b3840f534bb3d2b5d40bd5dbc8da1c6 Mon Sep 17 00:00:00 2001 From: mirrorZ Date: Mon, 2 Dec 2019 21:50:07 +0000 Subject: [PATCH 075/116] Add route for r2->r1 when using fallback --- tools/overlay/demo1.conf | 14 ++++++++++++++ tools/overlay/demo2.conf | 7 +++++-- 2 files changed, 19 insertions(+), 2 deletions(-) create mode 100644 tools/overlay/demo1.conf diff --git a/tools/overlay/demo1.conf b/tools/overlay/demo1.conf new file mode 100644 index 000000000..18e198bf3 --- /dev/null +++ b/tools/overlay/demo1.conf @@ -0,0 +1,14 @@ +[r1] +ControlAddress = 10.0.1.129 +Interfaces = ens35,ens39,ens34 +HostInterface = ens35 +HostAddr = 10.0.2.129 +NameServer = true +Route_r2 = ens39 -> ens34:r2 + +[r2] +ControlAddress = 10.0.1.132 +Interfaces = ens39,ens40,ens34 +HostInterface = ens39 +HostAddr = 10.0.4.129 +Route_r1 = ens34 -> ens39:r1 diff --git a/tools/overlay/demo2.conf b/tools/overlay/demo2.conf index 362ddd5e6..4a2f54daf 100644 --- a/tools/overlay/demo2.conf +++ b/tools/overlay/demo2.conf @@ -4,7 +4,7 @@ Interfaces = ens35,ens39,ens34,ens40 HostInterface = ens35 HostAddr = 10.0.2.129 NameServer = true -Route_r2 = ens39 -> ens34:r2 +#Route_r2 = ens39 -> ens34:r2 Route_r3 = ens40 -> ens39:r3 [r2] @@ -12,11 +12,14 @@ ControlAddress = 10.0.1.132 Interfaces = ens39,ens40,ens34,ens41 HostInterface = ens39 HostAddr = 10.0.4.129 -Route_r1 = ens34 -> ens39:r1 +#Route_r1 = ens34 -> ens39:r1 Route_r3 = ens41 -> ens40:r3 +Route_r1 = ens41 -> ens40:r3 [r3] ControlAddress = 10.0.1.134 Interfaces = ens38,ens39,ens40 +HostInterface = ens39 +HostAddr = 10.0.2.130 Route_r1 = ens39 -> ens40:r1 Route_r2 = ens40 -> ens41:r2 \ No newline at end of file From a5ad85386c4d83c0434a6a5bddf6dae414293ee5 Mon Sep 17 00:00:00 2001 From: mirrorZ Date: Fri, 13 Dec 2019 15:40:30 -0500 Subject: [PATCH 076/116] turn on mobility --- tools/overlay/client.conf | 1 + tools/overlay/demo2.conf | 4 ++-- tools/overlay/xiaclientconfigurator.py | 6 +++--- 3 files changed, 6 insertions(+), 5 deletions(-) diff --git a/tools/overlay/client.conf b/tools/overlay/client.conf index ee3cde7f2..9c2d1184b 100644 --- a/tools/overlay/client.conf +++ b/tools/overlay/client.conf @@ -16,3 +16,4 @@ Interfaces = ens40 Default = r1 #ServerDag = RE AD:1ff8cb8d5d0afeee9e3af7dfc0099a52e4764916 HID:c71d04d17f225ffc71ba6bf31a673e51386c533c AID:69a4e068880cd40549405dfda6e794b0c7fdf192 ServerDag = RE ( AD:cc8249bfea9de0461ae4127ebcd3b0ed0b6338e9 HID:813f0679821b6ba19602daf5a0471d62b721b4eb ) AD:1ff8cb8d5d0afeee9e3af7dfc0099a52e4764916 HID:c71d04d17f225ffc71ba6bf31a673e51386c533c AID:69a4e068880cd40549405dfda6e794b0c7fdf192 +Mobile = true diff --git a/tools/overlay/demo2.conf b/tools/overlay/demo2.conf index 362ddd5e6..29f69c68e 100644 --- a/tools/overlay/demo2.conf +++ b/tools/overlay/demo2.conf @@ -4,7 +4,7 @@ Interfaces = ens35,ens39,ens34,ens40 HostInterface = ens35 HostAddr = 10.0.2.129 NameServer = true -Route_r2 = ens39 -> ens34:r2 +#Route_r2 = ens39 -> ens34:r2 Route_r3 = ens40 -> ens39:r3 [r2] @@ -12,7 +12,7 @@ ControlAddress = 10.0.1.132 Interfaces = ens39,ens40,ens34,ens41 HostInterface = ens39 HostAddr = 10.0.4.129 -Route_r1 = ens34 -> ens39:r1 +#Route_r1 = ens34 -> ens39:r1 Route_r3 = ens41 -> ens40:r3 [r3] diff --git a/tools/overlay/xiaclientconfigurator.py b/tools/overlay/xiaclientconfigurator.py index f22407839..be54324b4 100644 --- a/tools/overlay/xiaclientconfigurator.py +++ b/tools/overlay/xiaclientconfigurator.py @@ -84,8 +84,8 @@ def connectionMade(self): # configure with default router self.sendConfig(self.clientConfigurator.clientConfig.default_router[self.client]) - # if self.client == 'c1': #todo: make configurable - # self.mobilityConfig() + if self.client == 'c1': #todo: make configurable + self.mobilityConfig() def sendConfig(self, router): response = clientconfig_pb2.Config() @@ -108,7 +108,7 @@ def sendConfig(self, router): def mobilityConfig(self): - t = 10 + t = 5 for router in self.clientConfigurator.clientConfig.routers[self.client]: print "Adding a call for " + router reactor.callLater(t, self.sendConfig, router) From 3ac80785f1b94ae3a407002cce8c9553adb75c7f Mon Sep 17 00:00:00 2001 From: Chandrika Parimoo Date: Fri, 13 Dec 2019 16:41:04 -0500 Subject: [PATCH 077/116] some cleanup --- tools/overlay/client.conf | 3 +-- .../conf/mobility/client_mobility.conf | 18 ++++++++++++++ .../mobility/mobility.conf} | 0 .../conf/server_dag/client_server_dag.conf | 17 +++++++++++++ .../server_dag/server_dag.conf} | 0 tools/overlay/xiaclientconfigurator.py | 19 ++++++++------- tools/overlay/xiaconfigurator.py | 24 +++++-------------- 7 files changed, 53 insertions(+), 28 deletions(-) create mode 100644 tools/overlay/conf/mobility/client_mobility.conf rename tools/overlay/{demo1.conf => conf/mobility/mobility.conf} (100%) create mode 100644 tools/overlay/conf/server_dag/client_server_dag.conf rename tools/overlay/{demo2.conf => conf/server_dag/server_dag.conf} (100%) diff --git a/tools/overlay/client.conf b/tools/overlay/client.conf index 9c2d1184b..1daf26a66 100644 --- a/tools/overlay/client.conf +++ b/tools/overlay/client.conf @@ -14,6 +14,5 @@ ControlPort = 8295 Routers = r1 Interfaces = ens40 Default = r1 -#ServerDag = RE AD:1ff8cb8d5d0afeee9e3af7dfc0099a52e4764916 HID:c71d04d17f225ffc71ba6bf31a673e51386c533c AID:69a4e068880cd40549405dfda6e794b0c7fdf192 -ServerDag = RE ( AD:cc8249bfea9de0461ae4127ebcd3b0ed0b6338e9 HID:813f0679821b6ba19602daf5a0471d62b721b4eb ) AD:1ff8cb8d5d0afeee9e3af7dfc0099a52e4764916 HID:c71d04d17f225ffc71ba6bf31a673e51386c533c AID:69a4e068880cd40549405dfda6e794b0c7fdf192 +ServerDag = RE AD:1ff8cb8d5d0afeee9e3af7dfc0099a52e4764916 HID:c71d04d17f225ffc71ba6bf31a673e51386c533c AID:69a4e068880cd40549405dfda6e794b0c7fdf192 Mobile = true diff --git a/tools/overlay/conf/mobility/client_mobility.conf b/tools/overlay/conf/mobility/client_mobility.conf new file mode 100644 index 000000000..74eb8d95a --- /dev/null +++ b/tools/overlay/conf/mobility/client_mobility.conf @@ -0,0 +1,18 @@ +[c2] +AID = AID:69a4e068880cd40549405dfda6e794b0c7fdf192 +ControlAddress = 10.0.1.133 +ControlPort = 8295 +Routers = r2 +Interfaces = ens34 +Default = r2 +ServerDag = RE AID:69a4e068880cd40549405dfda6e794b0c7fdf192 + +[c1] +AID = AID:69a4e068880cd40549405dfda6e794b0c7fdf195 +ControlAddress = 10.0.1.130 +ControlPort = 8295 +Routers = r1 +Interfaces = ens40 +Default = r1 +ServerDag = RE AD:1ff8cb8d5d0afeee9e3af7dfc0099a52e4764916 HID:c71d04d17f225ffc71ba6bf31a673e51386c533c AID:69a4e068880cd40549405dfda6e794b0c7fdf192 +Mobile = true \ No newline at end of file diff --git a/tools/overlay/demo1.conf b/tools/overlay/conf/mobility/mobility.conf similarity index 100% rename from tools/overlay/demo1.conf rename to tools/overlay/conf/mobility/mobility.conf diff --git a/tools/overlay/conf/server_dag/client_server_dag.conf b/tools/overlay/conf/server_dag/client_server_dag.conf new file mode 100644 index 000000000..e5c073a73 --- /dev/null +++ b/tools/overlay/conf/server_dag/client_server_dag.conf @@ -0,0 +1,17 @@ +[c2] +AID = AID:69a4e068880cd40549405dfda6e794b0c7fdf192 +ControlAddress = 10.0.1.133 +ControlPort = 8295 +Routers = r2 +Interfaces = ens34 +Default = r2 +ServerDag = RE AID:69a4e068880cd40549405dfda6e794b0c7fdf192 + +[c1] +AID = AID:69a4e068880cd40549405dfda6e794b0c7fdf195 +ControlAddress = 10.0.1.130 +ControlPort = 8295 +Routers = r1 +Interfaces = ens40 +Default = r1 +ServerDag = RE ( AD:cc8249bfea9de0461ae4127ebcd3b0ed0b6338e9 HID:813f0679821b6ba19602daf5a0471d62b721b4eb ) AD:1ff8cb8d5d0afeee9e3af7dfc0099a52e4764916 HID:c71d04d17f225ffc71ba6bf31a673e51386c533c AID:69a4e068880cd40549405dfda6e794b0c7fdf192 diff --git a/tools/overlay/demo2.conf b/tools/overlay/conf/server_dag/server_dag.conf similarity index 100% rename from tools/overlay/demo2.conf rename to tools/overlay/conf/server_dag/server_dag.conf diff --git a/tools/overlay/xiaclientconfigurator.py b/tools/overlay/xiaclientconfigurator.py index be54324b4..6268f8d79 100644 --- a/tools/overlay/xiaclientconfigurator.py +++ b/tools/overlay/xiaclientconfigurator.py @@ -17,7 +17,7 @@ from ConfigParser import RawConfigParser -import inspect +mobility_time = 5 class XIAClientConfigReader: def __init__(self, config_filename): @@ -31,6 +31,7 @@ def __init__(self, config_filename): self.router_addr = {} self.router_iface = {} self.serverdag = {} + self.mobile = {} # Read in the config file parser = RawConfigParser() @@ -64,13 +65,15 @@ def __init__(self, config_filename): self.control_port[client] = parser.get(client, 'ControlPort') self.serverdag[client] = parser.get(client, 'ServerDag') self.aid[client] = parser.get(client, 'AID') + self.mobile[client] = False + if parser.get(client, 'Mobile'): + self.mobile = True def clients(self): return self.routers.keys() class ConfigClient(Int32StringReceiver): def __init__(self, client, clientConfigurator): - print inspect.stack()[0][3] self.client = client self.clientConfigurator = clientConfigurator @@ -84,12 +87,15 @@ def connectionMade(self): # configure with default router self.sendConfig(self.clientConfigurator.clientConfig.default_router[self.client]) - if self.client == 'c1': #todo: make configurable + if self.clientConfigurator.clientConfig.mobile[self.client]: + print "Making " + self.client + "mobile" self.mobilityConfig() def sendConfig(self, router): response = clientconfig_pb2.Config() print "-----------------------------------" + print "Sending config to " + self.client + print "-----------------------------------" response.name = self.client response.ipaddr = self.clientConfigurator.clientConfig.router_addr[router] response.iface = self.clientConfigurator.clientConfig.router_iface[self.client][router] @@ -99,20 +105,17 @@ def sendConfig(self, router): response.HID =self.clientConfigurator.clientConfig.hid[router] response.serverdag = self.clientConfigurator.clientConfig.serverdag[self.client] - print "Sending config to " + self.client self.sendString(response.SerializeToString()) print response.SerializeToString() - print "Length " - print len(response.SerializeToString()) print "-----------------------------------" def mobilityConfig(self): - t = 5 + t = mobility_time for router in self.clientConfigurator.clientConfig.routers[self.client]: print "Adding a call for " + router reactor.callLater(t, self.sendConfig, router) - t = t + 10*2 + t = t + mobility_time class XIAClientConfigurator(): diff --git a/tools/overlay/xiaconfigurator.py b/tools/overlay/xiaconfigurator.py index cb4159944..e7a523419 100644 --- a/tools/overlay/xiaconfigurator.py +++ b/tools/overlay/xiaconfigurator.py @@ -36,26 +36,22 @@ class ConfigRouter(Int32StringReceiver): def __init__(self, router, configurator, xid_wait): - print inspect.stack()[0][3] + self.router = router self.configurator = configurator self.initialized = False self.xid_wait = xid_wait def connectionLost(self, reason): - print inspect.stack()[0][3] self.configurator.protocol_instances.remove(self) if len(self.configurator.protocol_instances) == 0: - print "===============================================================" - print self.configurator.config - + print "Going to configure clients now" # configure client after last router is configured clientConfigurator = XIAClientConfigurator(self.configurator) clientConfigurator.configureClient() #reactor.stop() def stringReceived(self, data): - print inspect.stack()[0][3] if not self.initialized: # Get greeting from server and send a request for interfaces if data == "Helper Ready": @@ -93,7 +89,6 @@ def stringReceived(self, data): def handleInterfaceInfoResponse(self, response): # Got interface information - print inspect.stack()[0][3] print "Got interface info for:", self.router if response.type != configrequest_pb2.Request.IFACE_INFO: print "ERROR: Invalid response to iface_info request" @@ -115,7 +110,6 @@ def handleInterfaceInfoResponse(self, response): self.sendString(request.SerializeToString()) def waitForResolvConf(self): - print inspect.stack()[0][3] if len(self.configurator.resolvconf) == 0: reactor.callLater(0.1, self.waitForResolvConf) else: @@ -127,7 +121,6 @@ def waitForResolvConf(self): self.sendString(request.SerializeToString()) def handleRouterConfResponse(self, response): - print inspect.stack()[0][3] # The router.click was successfully deployed if response.type != configrequest_pb2.Request.ROUTER_CONF: print "ERROR: Invalid router config response" @@ -150,7 +143,6 @@ def handleRouterConfResponse(self, response): # commands to start XIA on other routers with that file def handleStartXIAResponse(self, response): # Will have resolvconf field if nameserver started - print inspect.stack()[0][3] if response.type != configrequest_pb2.Request.START_XIA: print "ERROR: Invalid start XIA response" self.transport.loseConnection() @@ -168,7 +160,6 @@ def handleStartXIAResponse(self, response): self.sendString(request.SerializeToString()) def sendIPRoutesRequest(self): - print inspect.stack()[0][3] request = configrequest_pb2.Request() request.type = configrequest_pb2.Request.IP_ROUTES @@ -197,7 +188,6 @@ def sendIPRoutesRequest(self): self.sendString(request.SerializeToString()) def handleIPRoutesResponse(self, response): - print inspect.stack()[0][3] if response.type != configrequest_pb2.Request.IP_ROUTES: print "ERROR: Invalid IP route config response" self.transport.loseConnection() @@ -219,7 +209,6 @@ def handleIPRoutesResponse(self, response): self.transport.loseConnection() def handleStartXcacheResponse(self, response): - print inspect.stack()[0][3] if response.type != configrequest_pb2.Request.START_XCACHE: print "ERROR: Failed to start Xcache on", self.router self.transport.loseConnection() @@ -231,7 +220,7 @@ def handleStartXcacheResponse(self, response): self.transport.loseConnection() def handleGatherXIDsResponse(self, response): - print inspect.stack()[0][3] + if response.type != configrequest_pb2.Request.GATHER_XIDS: print "ERROR: Invalid gather XIDs response" self.transport.loseConnection() @@ -244,7 +233,6 @@ def handleGatherXIDsResponse(self, response): class XIAConfigurator: def __init__(self, config): - print inspect.stack()[0][3] self.config = config self.protocol_instances = [] self.nameserver = self.config.nameserver @@ -262,7 +250,7 @@ def __init__(self, config): # All routers sent in their AD, HID. Send IP routes to all routers def sendIPRoutes(self, result): - print inspect.stack()[0][3] + for (success, protocol) in result: if success: print "Sending IP routes to {}".format(protocol.router) @@ -271,11 +259,11 @@ def sendIPRoutes(self, result): print "ERROR: failure sending IP routes for a protocol" def gotProtocol(self, protocol): - print inspect.stack()[0][3] + self.protocol_instances.append(protocol) def configure(self): - print inspect.stack()[0][3] + xid_waiters = [] for router in self.config.routers(): From 1b415718281d22d512d6702e6704a4b5952681cf Mon Sep 17 00:00:00 2001 From: mirrorZ Date: Fri, 13 Dec 2019 19:33:12 -0500 Subject: [PATCH 078/116] mobile parser fix --- tools/overlay/xiaclientconfigurator.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tools/overlay/xiaclientconfigurator.py b/tools/overlay/xiaclientconfigurator.py index 6268f8d79..04fac322d 100644 --- a/tools/overlay/xiaclientconfigurator.py +++ b/tools/overlay/xiaclientconfigurator.py @@ -66,7 +66,7 @@ def __init__(self, config_filename): self.serverdag[client] = parser.get(client, 'ServerDag') self.aid[client] = parser.get(client, 'AID') self.mobile[client] = False - if parser.get(client, 'Mobile'): + if parser.getboolean(router, "Mobile"): self.mobile = True def clients(self): @@ -105,7 +105,7 @@ def sendConfig(self, router): response.HID =self.clientConfigurator.clientConfig.hid[router] response.serverdag = self.clientConfigurator.clientConfig.serverdag[self.client] - self.sendString(response.SerializeToString()) + self.sendString(response.SerializeoString()) print response.SerializeToString() print "-----------------------------------" From c8232c813eb38a42119c0a521073ab625d8ea51d Mon Sep 17 00:00:00 2001 From: mirrorZ Date: Sat, 14 Dec 2019 00:36:07 +0000 Subject: [PATCH 079/116] fix typo --- tools/overlay/xiaclientconfigurator.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/overlay/xiaclientconfigurator.py b/tools/overlay/xiaclientconfigurator.py index 04fac322d..adcd3e7db 100644 --- a/tools/overlay/xiaclientconfigurator.py +++ b/tools/overlay/xiaclientconfigurator.py @@ -66,7 +66,7 @@ def __init__(self, config_filename): self.serverdag[client] = parser.get(client, 'ServerDag') self.aid[client] = parser.get(client, 'AID') self.mobile[client] = False - if parser.getboolean(router, "Mobile"): + if parser.getboolean(client, "Mobile"): self.mobile = True def clients(self): From b6c6a71122d837ab07bfc7504955d4c6d0b35c64 Mon Sep 17 00:00:00 2001 From: mirrorZ Date: Sat, 14 Dec 2019 00:45:02 +0000 Subject: [PATCH 080/116] some fixes --- tools/overlay/xiaclientconfigurator.py | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/tools/overlay/xiaclientconfigurator.py b/tools/overlay/xiaclientconfigurator.py index adcd3e7db..45244ff6b 100644 --- a/tools/overlay/xiaclientconfigurator.py +++ b/tools/overlay/xiaclientconfigurator.py @@ -66,8 +66,11 @@ def __init__(self, config_filename): self.serverdag[client] = parser.get(client, 'ServerDag') self.aid[client] = parser.get(client, 'AID') self.mobile[client] = False - if parser.getboolean(client, "Mobile"): - self.mobile = True + try: + if parser.getboolean(client, "Mobile"): + self.mobile[client] = True + except: + pass def clients(self): return self.routers.keys() @@ -87,7 +90,7 @@ def connectionMade(self): # configure with default router self.sendConfig(self.clientConfigurator.clientConfig.default_router[self.client]) - if self.clientConfigurator.clientConfig.mobile[self.client]: + if self.clientConfigurator.clientConfig.mobile[self.client] == True: print "Making " + self.client + "mobile" self.mobilityConfig() @@ -105,7 +108,7 @@ def sendConfig(self, router): response.HID =self.clientConfigurator.clientConfig.hid[router] response.serverdag = self.clientConfigurator.clientConfig.serverdag[self.client] - self.sendString(response.SerializeoString()) + self.sendString(response.SerializeToString()) print response.SerializeToString() print "-----------------------------------" From 1824a7c271bd797eb2268e3753d70c6165f893d6 Mon Sep 17 00:00:00 2001 From: mirrorZ Date: Sat, 14 Dec 2019 19:06:12 -0500 Subject: [PATCH 081/116] disconnect from clients after each config --- tools/overlay/xiaclientconfigurator.py | 21 ++++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-) diff --git a/tools/overlay/xiaclientconfigurator.py b/tools/overlay/xiaclientconfigurator.py index 45244ff6b..dba4bdb34 100644 --- a/tools/overlay/xiaclientconfigurator.py +++ b/tools/overlay/xiaclientconfigurator.py @@ -82,6 +82,7 @@ def __init__(self, client, clientConfigurator): def connectionLost(self, reason): #self.connected_clients.remove(self) + print "Lost connection with " + self.client self.clientConfigurator.connected_clients -= 1 if self.clientConfigurator.connected_clients == 0: reactor.stop() @@ -92,7 +93,11 @@ def connectionMade(self): if self.clientConfigurator.clientConfig.mobile[self.client] == True: print "Making " + self.client + "mobile" - self.mobilityConfig() + # We don't want to recursively do this, disable mobility + self.clientConfigurator.clientConfig.mobile[self.client] = False + for router in self.clientConfigurator.clientConfig.routers[self.client]: + print "Adding a call for " + router + reactor.callLater(mobility_time, self.client, self.mobilityConfig, router) def sendConfig(self, router): response = clientconfig_pb2.Config() @@ -113,12 +118,14 @@ def sendConfig(self, router): print "-----------------------------------" - def mobilityConfig(self): - t = mobility_time - for router in self.clientConfigurator.clientConfig.routers[self.client]: - print "Adding a call for " + router - reactor.callLater(t, self.sendConfig, router) - t = t + mobility_time + def mobilityConfig(self, client, router): + # new default router + self.clientConfigurator.clientConfig.default_router[client] = router + endpoint = TCP4ClientEndpoint(reactor, self.clientConfig.control_addr[client], + int(self.clientConfig.control_port[client])) + + d = connectProtocol(endpoint, ConfigClient(client, self)) + d.addCallback(self.addClient) class XIAClientConfigurator(): From 225c3ebbcbe461bb143483c771049aa02c518632 Mon Sep 17 00:00:00 2001 From: mirrorZ Date: Sat, 14 Dec 2019 19:14:08 -0500 Subject: [PATCH 082/116] fix args --- tools/overlay/xiaclientconfigurator.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/overlay/xiaclientconfigurator.py b/tools/overlay/xiaclientconfigurator.py index dba4bdb34..8c10606ba 100644 --- a/tools/overlay/xiaclientconfigurator.py +++ b/tools/overlay/xiaclientconfigurator.py @@ -97,7 +97,7 @@ def connectionMade(self): self.clientConfigurator.clientConfig.mobile[self.client] = False for router in self.clientConfigurator.clientConfig.routers[self.client]: print "Adding a call for " + router - reactor.callLater(mobility_time, self.client, self.mobilityConfig, router) + reactor.callLater(mobility_time, self.mobilityConfig, self.client, router) def sendConfig(self, router): response = clientconfig_pb2.Config() From 60ce905be38a15fbe475b79439f802f33ce107fb Mon Sep 17 00:00:00 2001 From: mirrorZ Date: Sat, 14 Dec 2019 19:16:20 -0500 Subject: [PATCH 083/116] fix params to tcp endpoint --- tools/overlay/xiaclientconfigurator.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tools/overlay/xiaclientconfigurator.py b/tools/overlay/xiaclientconfigurator.py index 8c10606ba..36a9f1d54 100644 --- a/tools/overlay/xiaclientconfigurator.py +++ b/tools/overlay/xiaclientconfigurator.py @@ -121,8 +121,8 @@ def sendConfig(self, router): def mobilityConfig(self, client, router): # new default router self.clientConfigurator.clientConfig.default_router[client] = router - endpoint = TCP4ClientEndpoint(reactor, self.clientConfig.control_addr[client], - int(self.clientConfig.control_port[client])) + endpoint = TCP4ClientEndpoint(reactor, self.clientConfig.clientConfigurator.control_addr[client], + int(self.clientConfig.clientConfigurator.control_port[client])) d = connectProtocol(endpoint, ConfigClient(client, self)) d.addCallback(self.addClient) From b80fa8fc735f35facfe6c77046aec1de54fef676 Mon Sep 17 00:00:00 2001 From: mirrorZ Date: Sat, 14 Dec 2019 19:18:21 -0500 Subject: [PATCH 084/116] continue fixing --- tools/overlay/xiaclientconfigurator.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tools/overlay/xiaclientconfigurator.py b/tools/overlay/xiaclientconfigurator.py index 36a9f1d54..0cc293c2d 100644 --- a/tools/overlay/xiaclientconfigurator.py +++ b/tools/overlay/xiaclientconfigurator.py @@ -121,8 +121,8 @@ def sendConfig(self, router): def mobilityConfig(self, client, router): # new default router self.clientConfigurator.clientConfig.default_router[client] = router - endpoint = TCP4ClientEndpoint(reactor, self.clientConfig.clientConfigurator.control_addr[client], - int(self.clientConfig.clientConfigurator.control_port[client])) + endpoint = TCP4ClientEndpoint(reactor, self.clientConfigurator.clientConfig.control_addr[client], + int(self.clientConfigurator.clientConfig.control_port[client])) d = connectProtocol(endpoint, ConfigClient(client, self)) d.addCallback(self.addClient) From bd695dabc631617929a847fd0f4627cb6333598b Mon Sep 17 00:00:00 2001 From: mirrorZ Date: Sat, 14 Dec 2019 19:21:17 -0500 Subject: [PATCH 085/116] continue fixing --- tools/overlay/xiaclientconfigurator.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tools/overlay/xiaclientconfigurator.py b/tools/overlay/xiaclientconfigurator.py index 0cc293c2d..2d6c8985f 100644 --- a/tools/overlay/xiaclientconfigurator.py +++ b/tools/overlay/xiaclientconfigurator.py @@ -89,6 +89,7 @@ def connectionLost(self, reason): def connectionMade(self): # configure with default router + self.clientConfigurator.connected_clients += 1 self.sendConfig(self.clientConfigurator.clientConfig.default_router[self.client]) if self.clientConfigurator.clientConfig.mobile[self.client] == True: @@ -125,7 +126,6 @@ def mobilityConfig(self, client, router): int(self.clientConfigurator.clientConfig.control_port[client])) d = connectProtocol(endpoint, ConfigClient(client, self)) - d.addCallback(self.addClient) class XIAClientConfigurator(): @@ -150,7 +150,7 @@ def configureClient(self): int(self.clientConfig.control_port[client])) d = connectProtocol(endpoint, ConfigClient(client, self)) - d.addCallback(self.addClient) + #d.addCallback(self.addClient) #reactor.run() From 5db26c079992685576a3aa553ccb61c462d4f2af Mon Sep 17 00:00:00 2001 From: mirrorZ Date: Sat, 14 Dec 2019 19:25:14 -0500 Subject: [PATCH 086/116] continue fixing --- tools/overlay/xiaclientconfigurator.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/tools/overlay/xiaclientconfigurator.py b/tools/overlay/xiaclientconfigurator.py index 2d6c8985f..cd0e016e9 100644 --- a/tools/overlay/xiaclientconfigurator.py +++ b/tools/overlay/xiaclientconfigurator.py @@ -79,17 +79,19 @@ class ConfigClient(Int32StringReceiver): def __init__(self, client, clientConfigurator): self.client = client self.clientConfigurator = clientConfigurator + self.connected_clients = 0 def connectionLost(self, reason): #self.connected_clients.remove(self) print "Lost connection with " + self.client - self.clientConfigurator.connected_clients -= 1 + self.connected_clients -= 1 if self.clientConfigurator.connected_clients == 0: + print "!!!!!!!!!!! Stopping the configurator !!!!!!!!!!!!!" reactor.stop() def connectionMade(self): # configure with default router - self.clientConfigurator.connected_clients += 1 + self.connected_clients += 1 self.sendConfig(self.clientConfigurator.clientConfig.default_router[self.client]) if self.clientConfigurator.clientConfig.mobile[self.client] == True: From d1671ef98f9ff2a32cdd46fc79c655f3a0f410c1 Mon Sep 17 00:00:00 2001 From: mirrorZ Date: Sat, 14 Dec 2019 19:26:46 -0500 Subject: [PATCH 087/116] continue fixing --- tools/overlay/xiaclientconfigurator.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/overlay/xiaclientconfigurator.py b/tools/overlay/xiaclientconfigurator.py index cd0e016e9..c927109f0 100644 --- a/tools/overlay/xiaclientconfigurator.py +++ b/tools/overlay/xiaclientconfigurator.py @@ -87,7 +87,7 @@ def connectionLost(self, reason): self.connected_clients -= 1 if self.clientConfigurator.connected_clients == 0: print "!!!!!!!!!!! Stopping the configurator !!!!!!!!!!!!!" - reactor.stop() + #reactor.stop() def connectionMade(self): # configure with default router From 0d14c0a3b8a179dabed11ec19476888a1350c244 Mon Sep 17 00:00:00 2001 From: mirrorZ Date: Sat, 14 Dec 2019 19:29:18 -0500 Subject: [PATCH 088/116] continue fixing --- tools/overlay/xiaclientconfigurator.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/overlay/xiaclientconfigurator.py b/tools/overlay/xiaclientconfigurator.py index c927109f0..02bf6bd7d 100644 --- a/tools/overlay/xiaclientconfigurator.py +++ b/tools/overlay/xiaclientconfigurator.py @@ -127,7 +127,7 @@ def mobilityConfig(self, client, router): endpoint = TCP4ClientEndpoint(reactor, self.clientConfigurator.clientConfig.control_addr[client], int(self.clientConfigurator.clientConfig.control_port[client])) - d = connectProtocol(endpoint, ConfigClient(client, self)) + d = connectProtocol(endpoint, ConfigClient(client, self.clientConfigurator)) class XIAClientConfigurator(): From 0106d92d7e11d9e34473274dd381972657f757fa Mon Sep 17 00:00:00 2001 From: mirrorZ Date: Sat, 14 Dec 2019 21:14:43 -0500 Subject: [PATCH 089/116] do not connect to the same router --- tools/overlay/xiaclientconfigurator.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/tools/overlay/xiaclientconfigurator.py b/tools/overlay/xiaclientconfigurator.py index 02bf6bd7d..6efa8fe5a 100644 --- a/tools/overlay/xiaclientconfigurator.py +++ b/tools/overlay/xiaclientconfigurator.py @@ -99,8 +99,9 @@ def connectionMade(self): # We don't want to recursively do this, disable mobility self.clientConfigurator.clientConfig.mobile[self.client] = False for router in self.clientConfigurator.clientConfig.routers[self.client]: - print "Adding a call for " + router - reactor.callLater(mobility_time, self.mobilityConfig, self.client, router) + if router != self.clientConfigurator.clientConfig.default_router[self.client]: + print "Adding a call for " + router + reactor.callLater(mobility_time, self.mobilityConfig, self.client, router) def sendConfig(self, router): response = clientconfig_pb2.Config() From a11c43dcc74b85775ecae4e957c1b98fe9b0545d Mon Sep 17 00:00:00 2001 From: mirrorZ Date: Sat, 14 Dec 2019 21:18:24 -0500 Subject: [PATCH 090/116] continue fixing --- tools/overlay/xiaclientconfigurator.py | 1 + 1 file changed, 1 insertion(+) diff --git a/tools/overlay/xiaclientconfigurator.py b/tools/overlay/xiaclientconfigurator.py index 6efa8fe5a..09e5aae55 100644 --- a/tools/overlay/xiaclientconfigurator.py +++ b/tools/overlay/xiaclientconfigurator.py @@ -99,6 +99,7 @@ def connectionMade(self): # We don't want to recursively do this, disable mobility self.clientConfigurator.clientConfig.mobile[self.client] = False for router in self.clientConfigurator.clientConfig.routers[self.client]: + print "\n Checking out router " + router + "\n" if router != self.clientConfigurator.clientConfig.default_router[self.client]: print "Adding a call for " + router reactor.callLater(mobility_time, self.mobilityConfig, self.client, router) From a92030995ddf7b7276df576953e9969b6725279a Mon Sep 17 00:00:00 2001 From: mirrorZ Date: Sat, 14 Dec 2019 21:24:04 -0500 Subject: [PATCH 091/116] Update conf --- tools/overlay/client.conf | 4 ++-- tools/overlay/conf/mobility/client_mobility.conf | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/tools/overlay/client.conf b/tools/overlay/client.conf index 1daf26a66..f5ec80dec 100644 --- a/tools/overlay/client.conf +++ b/tools/overlay/client.conf @@ -11,8 +11,8 @@ ServerDag = RE AID:69a4e068880cd40549405dfda6e794b0c7fdf192 AID = AID:69a4e068880cd40549405dfda6e794b0c7fdf195 ControlAddress = 10.0.1.130 ControlPort = 8295 -Routers = r1 -Interfaces = ens40 +Routers = r1,r2 +Interfaces = ens40,ens39 Default = r1 ServerDag = RE AD:1ff8cb8d5d0afeee9e3af7dfc0099a52e4764916 HID:c71d04d17f225ffc71ba6bf31a673e51386c533c AID:69a4e068880cd40549405dfda6e794b0c7fdf192 Mobile = true diff --git a/tools/overlay/conf/mobility/client_mobility.conf b/tools/overlay/conf/mobility/client_mobility.conf index 74eb8d95a..3c1e61ded 100644 --- a/tools/overlay/conf/mobility/client_mobility.conf +++ b/tools/overlay/conf/mobility/client_mobility.conf @@ -11,8 +11,8 @@ ServerDag = RE AID:69a4e068880cd40549405dfda6e794b0c7fdf192 AID = AID:69a4e068880cd40549405dfda6e794b0c7fdf195 ControlAddress = 10.0.1.130 ControlPort = 8295 -Routers = r1 -Interfaces = ens40 +Routers = r1,r2 +Interfaces = ens40,ens39 Default = r1 ServerDag = RE AD:1ff8cb8d5d0afeee9e3af7dfc0099a52e4764916 HID:c71d04d17f225ffc71ba6bf31a673e51386c533c AID:69a4e068880cd40549405dfda6e794b0c7fdf192 Mobile = true \ No newline at end of file From 7e7906be8ce87de097e27d48094bb5316b9dd5a2 Mon Sep 17 00:00:00 2001 From: mirrorZ Date: Sun, 15 Dec 2019 03:27:22 -0500 Subject: [PATCH 092/116] Update conf --- tools/overlay/client.conf | 4 ++-- tools/overlay/conf/mobility/client_mobility.conf | 4 ++-- tools/overlay/conf/mobility/mobility.conf | 14 ++++++++++++-- tools/overlay/demo.conf | 14 ++++++++++++-- 4 files changed, 28 insertions(+), 8 deletions(-) diff --git a/tools/overlay/client.conf b/tools/overlay/client.conf index f5ec80dec..f26400a40 100644 --- a/tools/overlay/client.conf +++ b/tools/overlay/client.conf @@ -11,8 +11,8 @@ ServerDag = RE AID:69a4e068880cd40549405dfda6e794b0c7fdf192 AID = AID:69a4e068880cd40549405dfda6e794b0c7fdf195 ControlAddress = 10.0.1.130 ControlPort = 8295 -Routers = r1,r2 -Interfaces = ens40,ens39 +Routers = r1,r3 +Interfaces = ens40,ens41 Default = r1 ServerDag = RE AD:1ff8cb8d5d0afeee9e3af7dfc0099a52e4764916 HID:c71d04d17f225ffc71ba6bf31a673e51386c533c AID:69a4e068880cd40549405dfda6e794b0c7fdf192 Mobile = true diff --git a/tools/overlay/conf/mobility/client_mobility.conf b/tools/overlay/conf/mobility/client_mobility.conf index 3c1e61ded..2af753fa5 100644 --- a/tools/overlay/conf/mobility/client_mobility.conf +++ b/tools/overlay/conf/mobility/client_mobility.conf @@ -11,8 +11,8 @@ ServerDag = RE AID:69a4e068880cd40549405dfda6e794b0c7fdf192 AID = AID:69a4e068880cd40549405dfda6e794b0c7fdf195 ControlAddress = 10.0.1.130 ControlPort = 8295 -Routers = r1,r2 -Interfaces = ens40,ens39 +Routers = r1,r3 +Interfaces = ens40,ens41 Default = r1 ServerDag = RE AD:1ff8cb8d5d0afeee9e3af7dfc0099a52e4764916 HID:c71d04d17f225ffc71ba6bf31a673e51386c533c AID:69a4e068880cd40549405dfda6e794b0c7fdf192 Mobile = true \ No newline at end of file diff --git a/tools/overlay/conf/mobility/mobility.conf b/tools/overlay/conf/mobility/mobility.conf index 18e198bf3..c47d71e1c 100644 --- a/tools/overlay/conf/mobility/mobility.conf +++ b/tools/overlay/conf/mobility/mobility.conf @@ -1,14 +1,24 @@ [r1] ControlAddress = 10.0.1.129 -Interfaces = ens35,ens39,ens34 +Interfaces = ens35,ens39,ens34,ens40 HostInterface = ens35 HostAddr = 10.0.2.129 NameServer = true Route_r2 = ens39 -> ens34:r2 +Route_r3 = ens40 -> ens39:r3 [r2] ControlAddress = 10.0.1.132 -Interfaces = ens39,ens40,ens34 +Interfaces = ens39,ens40,ens34,ens41 HostInterface = ens39 HostAddr = 10.0.4.129 Route_r1 = ens34 -> ens39:r1 +Route_r3 = ens41 -> ens40:r3 + +[r3] +ControlAddress = 10.0.1.134 +Interfaces = ens38,ens39,ens40 +HostInterface = ens41 +HostAddr = 10.0.3.134 +Route_r1 = ens39 -> ens40:r1 +Route_r2 = ens40 -> ens41:r2 \ No newline at end of file diff --git a/tools/overlay/demo.conf b/tools/overlay/demo.conf index 18e198bf3..c47d71e1c 100644 --- a/tools/overlay/demo.conf +++ b/tools/overlay/demo.conf @@ -1,14 +1,24 @@ [r1] ControlAddress = 10.0.1.129 -Interfaces = ens35,ens39,ens34 +Interfaces = ens35,ens39,ens34,ens40 HostInterface = ens35 HostAddr = 10.0.2.129 NameServer = true Route_r2 = ens39 -> ens34:r2 +Route_r3 = ens40 -> ens39:r3 [r2] ControlAddress = 10.0.1.132 -Interfaces = ens39,ens40,ens34 +Interfaces = ens39,ens40,ens34,ens41 HostInterface = ens39 HostAddr = 10.0.4.129 Route_r1 = ens34 -> ens39:r1 +Route_r3 = ens41 -> ens40:r3 + +[r3] +ControlAddress = 10.0.1.134 +Interfaces = ens38,ens39,ens40 +HostInterface = ens41 +HostAddr = 10.0.3.134 +Route_r1 = ens39 -> ens40:r1 +Route_r2 = ens40 -> ens41:r2 \ No newline at end of file From 6006d93eff4a5c1fcf6541b20cb729ddedd0ad3b Mon Sep 17 00:00:00 2001 From: mirrorZ Date: Mon, 16 Dec 2019 08:21:52 +0000 Subject: [PATCH 093/116] fix --- tools/overlay/demo.conf | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/overlay/demo.conf b/tools/overlay/demo.conf index c47d71e1c..660b26222 100644 --- a/tools/overlay/demo.conf +++ b/tools/overlay/demo.conf @@ -17,7 +17,7 @@ Route_r3 = ens41 -> ens40:r3 [r3] ControlAddress = 10.0.1.134 -Interfaces = ens38,ens39,ens40 +Interfaces = ens38,ens39,ens40,ens41 HostInterface = ens41 HostAddr = 10.0.3.134 Route_r1 = ens39 -> ens40:r1 From 153f8c8227c244557749b07e81516fe4a110e2bb Mon Sep 17 00:00:00 2001 From: mirrorZ Date: Mon, 16 Dec 2019 09:36:19 -0500 Subject: [PATCH 094/116] some updates --- tools/overlay/conf/mobility/client_mobility.conf | 2 +- tools/overlay/conf/mobility/mobility.conf | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/tools/overlay/conf/mobility/client_mobility.conf b/tools/overlay/conf/mobility/client_mobility.conf index 2af753fa5..f26400a40 100644 --- a/tools/overlay/conf/mobility/client_mobility.conf +++ b/tools/overlay/conf/mobility/client_mobility.conf @@ -15,4 +15,4 @@ Routers = r1,r3 Interfaces = ens40,ens41 Default = r1 ServerDag = RE AD:1ff8cb8d5d0afeee9e3af7dfc0099a52e4764916 HID:c71d04d17f225ffc71ba6bf31a673e51386c533c AID:69a4e068880cd40549405dfda6e794b0c7fdf192 -Mobile = true \ No newline at end of file +Mobile = true diff --git a/tools/overlay/conf/mobility/mobility.conf b/tools/overlay/conf/mobility/mobility.conf index c47d71e1c..660b26222 100644 --- a/tools/overlay/conf/mobility/mobility.conf +++ b/tools/overlay/conf/mobility/mobility.conf @@ -17,7 +17,7 @@ Route_r3 = ens41 -> ens40:r3 [r3] ControlAddress = 10.0.1.134 -Interfaces = ens38,ens39,ens40 +Interfaces = ens38,ens39,ens40,ens41 HostInterface = ens41 HostAddr = 10.0.3.134 Route_r1 = ens39 -> ens40:r1 From 45f32e0b3142c6dcb0b245deaf01133bb120c1d8 Mon Sep 17 00:00:00 2001 From: mirrorZ Date: Mon, 16 Dec 2019 09:45:14 -0500 Subject: [PATCH 095/116] lsa debug --- daemons/xrouted/xrouted.cc | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/daemons/xrouted/xrouted.cc b/daemons/xrouted/xrouted.cc index b15b2b045..486bcc567 100644 --- a/daemons/xrouted/xrouted.cc +++ b/daemons/xrouted/xrouted.cc @@ -101,13 +101,15 @@ int sendHello() // send LinkStateAdvertisement message (flooding) int sendLSA() { + printf("*****sending LSA *******\n"); int buflen, rc; string message; Node n_ad(route_state.myAD); Node n_hid(route_state.myHID); - Xroute::XrouteMsg msg; + Xroute:: + msg; Xroute::LSAMsg *lsa = msg.mutable_lsa(); Xroute::Node *node = lsa->mutable_node(); Xroute::XID *ad = node->mutable_ad(); @@ -138,6 +140,7 @@ int sendLSA() } // printf("sending %s\n", msg.DebugString().c_str()); + printf("******sending %s ********\n", msg.c_str()); msg.SerializeToString(&message); buflen = message.length(); From 332fe0deb0976edff5e5d3d394aa8994eeac8163 Mon Sep 17 00:00:00 2001 From: mirrorZ Date: Mon, 16 Dec 2019 09:47:41 -0500 Subject: [PATCH 096/116] lsa debug --- daemons/xrouted/xrouted.cc | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/daemons/xrouted/xrouted.cc b/daemons/xrouted/xrouted.cc index 486bcc567..3641f2782 100644 --- a/daemons/xrouted/xrouted.cc +++ b/daemons/xrouted/xrouted.cc @@ -108,8 +108,7 @@ int sendLSA() Node n_ad(route_state.myAD); Node n_hid(route_state.myHID); - Xroute:: - msg; + Xroute::XrouteMsg msg; Xroute::LSAMsg *lsa = msg.mutable_lsa(); Xroute::Node *node = lsa->mutable_node(); Xroute::XID *ad = node->mutable_ad(); @@ -140,8 +139,7 @@ int sendLSA() } // printf("sending %s\n", msg.DebugString().c_str()); - printf("******sending %s ********\n", msg.c_str()); - + printf("******sending %s********\n", msg.c_str()); msg.SerializeToString(&message); buflen = message.length(); From b6b0b6d7b533b52172635426c97defe59705b0db Mon Sep 17 00:00:00 2001 From: mirrorZ Date: Mon, 16 Dec 2019 09:48:39 -0500 Subject: [PATCH 097/116] lsa debug --- daemons/xrouted/xrouted.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/daemons/xrouted/xrouted.cc b/daemons/xrouted/xrouted.cc index 3641f2782..601b9330a 100644 --- a/daemons/xrouted/xrouted.cc +++ b/daemons/xrouted/xrouted.cc @@ -139,8 +139,8 @@ int sendLSA() } // printf("sending %s\n", msg.DebugString().c_str()); - printf("******sending %s********\n", msg.c_str()); msg.SerializeToString(&message); + printf("******sending %s********\n", message.c_str()); buflen = message.length(); rc = Xsendto(route_state.sock, message.c_str(), buflen, 0, (struct sockaddr*)&route_state.ddag, sizeof(sockaddr_x)); From 3e8eb2dc69921d3f61d9e4b76dd1f872d2f5ce4c Mon Sep 17 00:00:00 2001 From: mirrorZ Date: Mon, 16 Dec 2019 09:56:04 -0500 Subject: [PATCH 098/116] lsa debug --- daemons/xrouted/xrouted.cc | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/daemons/xrouted/xrouted.cc b/daemons/xrouted/xrouted.cc index 601b9330a..56b1da4f5 100644 --- a/daemons/xrouted/xrouted.cc +++ b/daemons/xrouted/xrouted.cc @@ -101,7 +101,6 @@ int sendHello() // send LinkStateAdvertisement message (flooding) int sendLSA() { - printf("*****sending LSA *******\n"); int buflen, rc; string message; @@ -138,9 +137,8 @@ int sendLSA() hid->set_id(p_hid.id(), XID_SIZE); } -// printf("sending %s\n", msg.DebugString().c_str()); + printf(" **** sending %s\n", msg.DebugString().c_str()); msg.SerializeToString(&message); - printf("******sending %s********\n", message.c_str()); buflen = message.length(); rc = Xsendto(route_state.sock, message.c_str(), buflen, 0, (struct sockaddr*)&route_state.ddag, sizeof(sockaddr_x)); @@ -265,7 +263,7 @@ int processLSA(const Xroute::XrouteMsg& msg) string neighborAD, neighborHID, myAD; string destAD, destHID; -// printf("processLSA: %s\n", lsa.DebugString().c_str()); + printf(" *** processLSA: %s\n", lsa.DebugString().c_str()); // fix me once we don't need to rebroadcast the lsa const Xroute::LSAMsg& lsa = msg.lsa(); From 5b7160b127ddea3d84790af8f77b8f11f1f3069b Mon Sep 17 00:00:00 2001 From: mirrorZ Date: Mon, 16 Dec 2019 09:56:58 -0500 Subject: [PATCH 099/116] lsa debug --- daemons/xrouted/xrouted.cc | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/daemons/xrouted/xrouted.cc b/daemons/xrouted/xrouted.cc index 56b1da4f5..dc1d6dc26 100644 --- a/daemons/xrouted/xrouted.cc +++ b/daemons/xrouted/xrouted.cc @@ -263,11 +263,11 @@ int processLSA(const Xroute::XrouteMsg& msg) string neighborAD, neighborHID, myAD; string destAD, destHID; - printf(" *** processLSA: %s\n", lsa.DebugString().c_str()); - // fix me once we don't need to rebroadcast the lsa const Xroute::LSAMsg& lsa = msg.lsa(); + printf(" *** processLSA: %s\n", lsa.DebugString().c_str()); + Xroute::XID a = lsa.node().ad(); Xroute::XID h = lsa.node().hid(); From ebf9afc802d0dbdb7f8211519b4b6e4fb2dc37fd Mon Sep 17 00:00:00 2001 From: mirrorZ Date: Mon, 16 Dec 2019 10:02:16 -0500 Subject: [PATCH 100/116] lsa debug --- daemons/xrouted/xrouted.cc | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/daemons/xrouted/xrouted.cc b/daemons/xrouted/xrouted.cc index dc1d6dc26..ec9512782 100644 --- a/daemons/xrouted/xrouted.cc +++ b/daemons/xrouted/xrouted.cc @@ -136,8 +136,7 @@ int sendLSA() hid->set_type(p_hid.type()); hid->set_id(p_hid.id(), XID_SIZE); } - - printf(" **** sending %s\n", msg.DebugString().c_str()); + msg.SerializeToString(&message); buflen = message.length(); From 64de05e3117681000634ae8b8c225035e6f86540 Mon Sep 17 00:00:00 2001 From: mirrorZ Date: Mon, 16 Dec 2019 10:17:48 -0500 Subject: [PATCH 101/116] lsa debug --- daemons/xrouted/xrouted.cc | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/daemons/xrouted/xrouted.cc b/daemons/xrouted/xrouted.cc index ec9512782..ae8673b11 100644 --- a/daemons/xrouted/xrouted.cc +++ b/daemons/xrouted/xrouted.cc @@ -81,6 +81,8 @@ int sendHello() // printf("sending %s\n", msg.DebugString().c_str()); + printf("**** sending lsa with ddag %s and num_neighbors %d \n", + route_state.ddag.dag_string().c_str(), route_state.num_neighbors); msg.SerializeToString(&message); buflen = message.length(); @@ -136,7 +138,7 @@ int sendLSA() hid->set_type(p_hid.type()); hid->set_id(p_hid.id(), XID_SIZE); } - + msg.SerializeToString(&message); buflen = message.length(); From 382273b459ae612a4af7f2fea7408ca05fdd0cb3 Mon Sep 17 00:00:00 2001 From: mirrorZ Date: Mon, 16 Dec 2019 10:24:55 -0500 Subject: [PATCH 102/116] lsa debug --- daemons/xrouted/xrouted.cc | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/daemons/xrouted/xrouted.cc b/daemons/xrouted/xrouted.cc index ae8673b11..71f30dd98 100644 --- a/daemons/xrouted/xrouted.cc +++ b/daemons/xrouted/xrouted.cc @@ -81,8 +81,7 @@ int sendHello() // printf("sending %s\n", msg.DebugString().c_str()); - printf("**** sending lsa with ddag %s and num_neighbors %d \n", - route_state.ddag.dag_string().c_str(), route_state.num_neighbors); + printf("**** sending lsa with and num_neighbors %d \n", route_state.num_neighbors); msg.SerializeToString(&message); buflen = message.length(); From a71b6b6aa3e5582181f2ecda24c61f60745c5f00 Mon Sep 17 00:00:00 2001 From: mirrorZ Date: Thu, 6 Feb 2020 20:09:42 -0500 Subject: [PATCH 103/116] Add neighbor table in routing core --- click/elements/xia/xiaoverlaysocket.cc | 2 - click/elements/xia/xiaxidroutetable.cc | 62 ++++++++++++++++++++------ click/elements/xia/xiaxidroutetable.hh | 16 ++++++- daemons/common/XIARouter.cc | 23 ++++++++++ daemons/common/XIARouter.hh | 2 + tools/overlay/demo.conf | 36 +++++++-------- 6 files changed, 106 insertions(+), 35 deletions(-) diff --git a/click/elements/xia/xiaoverlaysocket.cc b/click/elements/xia/xiaoverlaysocket.cc index 04ca7ca50..fe9c5b71f 100644 --- a/click/elements/xia/xiaoverlaysocket.cc +++ b/click/elements/xia/xiaoverlaysocket.cc @@ -68,8 +68,6 @@ XIAOverlaySocket::selected(int fd, int) else { // datagram server, find out who we are talking to len = recvfrom(_active, _rq->data(), _rq->length(), MSG_TRUNC, (struct sockaddr *)&from, &from_len); - printf("XIAOverlaySocket::selected rcvd pkt of len %d\n", len); - printf("from: %s:%d\n", IPAddress(from.in.sin_addr).unparse().c_str(), ntohs(from.in.sin_port)); if (_family == AF_INET && !allowed(IPAddress(from.in.sin_addr))) { if (_verbose) diff --git a/click/elements/xia/xiaxidroutetable.cc b/click/elements/xia/xiaxidroutetable.cc index 8b7e395af..48497e170 100644 --- a/click/elements/xia/xiaxidroutetable.cc +++ b/click/elements/xia/xiaxidroutetable.cc @@ -31,13 +31,14 @@ XIAXIDRouteTable::~XIAXIDRouteTable() int XIAXIDRouteTable::configure(Vector & /*conf*/, ErrorHandler * /*errh*/) { - //click_chatter("XIAXIDRouteTable: configuring %s\n", this->name().c_str()); + //printf("XIAXIDRouteTable: configuring %s\n", this->name().c_str()); _principal_type_enabled = 1; _rtdata.port = -1; _rtdata.flags = 0; _rtdata.nexthop = NULL; + _ntable.count = 0; return 0; } @@ -68,11 +69,13 @@ XIAXIDRouteTable::add_handlers() add_read_handler("list", list_routes_handler, 0); add_write_handler("enabled", write_handler, (void *)PRINCIPAL_TYPE_ENABLED); add_read_handler("enabled", read_handler, (void *)PRINCIPAL_TYPE_ENABLED); + add_read_handler("neighbor", list_neighbor_handler, 0); } String XIAXIDRouteTable::read_handler(Element *e, void *thunk) { + printf("******called %s \n", __FUNCTION__); XIAXIDRouteTable *t = (XIAXIDRouteTable *) e; switch ((intptr_t)thunk) { case PRINCIPAL_TYPE_ENABLED: @@ -86,6 +89,7 @@ XIAXIDRouteTable::read_handler(Element *e, void *thunk) int XIAXIDRouteTable::write_handler(const String &str, Element *e, void *thunk, ErrorHandler * /*errh*/) { + printf("******called %s \n", __FUNCTION__); XIAXIDRouteTable *t = (XIAXIDRouteTable *) e; switch ((intptr_t)thunk) { case PRINCIPAL_TYPE_ENABLED: @@ -96,9 +100,10 @@ XIAXIDRouteTable::write_handler(const String &str, Element *e, void *thunk, Erro } void -XIAXIDRouteTable::add_entry_to_tbl_str(String& tbl, String xid, +XIAXIDRouteTable::add_entry_to_tbl_str(Element *e, String& tbl, String xid, XIARouteData* xrd) { + printf("******called %s \n", __FUNCTION__); // XID tbl += xid + ","; // port @@ -112,6 +117,15 @@ XIAXIDRouteTable::add_entry_to_tbl_str(String& tbl, String xid, } else { tbl += String("") + ","; } + if(xrd->flags == NEIGHBOR) + { + XIAXIDNeighbor neighbor; + XIAXIDRouteTable* table = static_cast(e); + neighbor.addr = String(inet_ntoa(xrd->nexthop_in->sin_addr)) + + ":" + String(ntohs(xrd->nexthop_in->sin_port)); + table->_ntable.neighbors[table->_ntable.count] = neighbor; + table->_ntable.count += 1; + } // flags tbl += String(xrd->flags) + "\n"; } @@ -119,27 +133,41 @@ XIAXIDRouteTable::add_entry_to_tbl_str(String& tbl, String xid, String XIAXIDRouteTable::list_routes_handler(Element *e, void * /*thunk */) { + printf("******called %s \n", __FUNCTION__); XIAXIDRouteTable* table = static_cast(e); XIARouteData *xrd = &table->_rtdata; // get the default route String tbl; - add_entry_to_tbl_str(tbl, "-", xrd); + add_entry_to_tbl_str(e, tbl, "-", xrd); // get the rest for(auto& it : table->_rts) { String xid = it.first.unparse(); xrd = it.second; - add_entry_to_tbl_str(tbl, xid, xrd); + add_entry_to_tbl_str(e, tbl, xid, xrd); } return tbl; } +String +XIAXIDRouteTable::list_neighbor_handler(Element *e, void *) +{ + XIAXIDRouteTable* table = static_cast(e); + String ntable; + for(int i=0; i_ntable.count; i++) + { + String n = table->_ntable.neighbors[i].addr + ","; + ntable += n; + } + return ntable; +} + int XIAXIDRouteTable::set_handler(const String &conf, Element *e, void *thunk, ErrorHandler *errh) { // handle older style route entries - + printf("******called %s \n", __FUNCTION__); String str_copy = conf; String xid_str = cp_shift_spacevec(str_copy); @@ -161,7 +189,7 @@ XIAXIDRouteTable::set_handler(const String &conf, Element *e, void *thunk, Error int XIAXIDRouteTable::set_handler4(const String &conf, Element *e, void *thunk, ErrorHandler *errh) { - XIAXIDRouteTable* table = static_cast(e); + printf("******called %s \n", __FUNCTION__); XIAXIDRouteTable* table = static_cast(e); bool add_mode = !thunk; @@ -233,6 +261,7 @@ XIAXIDRouteTable::set_handler4(const String &conf, Element *e, void *thunk, Erro int XIAXIDRouteTable::set_udpnext(const String &conf, Element *e, void *thunk, ErrorHandler *errh) { + printf("******called %s \n", __FUNCTION__); XIAXIDRouteTable* table = static_cast(e); bool add_mode = !thunk; Vector args; @@ -315,6 +344,7 @@ XIAXIDRouteTable::set_udpnext(const String &conf, Element *e, void *thunk, Error int XIAXIDRouteTable::remove_handler(const String &xid_str, Element *e, void *, ErrorHandler *errh) { + printf("******called %s \n", __FUNCTION__); XIAXIDRouteTable* table = static_cast(e); if (xid_str.length() == 0) @@ -355,6 +385,7 @@ XIAXIDRouteTable::remove_handler(const String &xid_str, Element *e, void *, Erro int XIAXIDRouteTable::load_routes_handler(const String &conf, Element *e, void *, ErrorHandler *errh) { + printf("******called %s \n", __FUNCTION__); #if CLICK_USERLEVEL std::ifstream in_f(conf.c_str()); if (!in_f.is_open()) @@ -377,7 +408,7 @@ XIAXIDRouteTable::load_routes_handler(const String &conf, Element *e, void *, Er c++; } - click_chatter("loaded %d entries", c); + printf("loaded %d entries", c); return 0; #elif CLICK_LINUXMODLE @@ -398,7 +429,7 @@ XIAXIDRouteTable::load_routes_handler(const String &conf, Element *e, void *, Er file_read(filp, curpos, buf, 1020); char * eol = strchr(buf, '\n'); if (eol==NULL) { - click_chatter("Error at %s %d\n", __FUNCTION__, __LINE__); + printf("Error at %s %d\n", __FUNCTION__, __LINE__); break; } curpos+=(eol+1-buf); @@ -407,14 +438,14 @@ XIAXIDRouteTable::load_routes_handler(const String &conf, Element *e, void *, Er continue; if (set_handler(buf, e, 0, errh) != 0) { - click_chatter("Error at %s %d\n", __FUNCTION__, __LINE__); + printf("Error at %s %d\n", __FUNCTION__, __LINE__); return -1; } c++; } set_fs(old_fs); - click_chatter("XIA routing table loaded %d entries", c); + printf("XIA routing table loaded %d entries", c); return 0; #endif } @@ -422,6 +453,7 @@ XIAXIDRouteTable::load_routes_handler(const String &conf, Element *e, void *, Er int XIAXIDRouteTable::generate_routes_handler(const String &conf, Element *e, void *, ErrorHandler *errh) { + printf("******called %s \n", __FUNCTION__); #if CLICK_USERLEVEL XIAXIDRouteTable* table = dynamic_cast(e); #else @@ -460,7 +492,7 @@ XIAXIDRouteTable::generate_routes_handler(const String &conf, Element *e, void * struct click_xia_xid xid_d; xid_d.type = xid_type; - if (port<0) click_chatter("Random %d ports", -port); + if (port<0) printf("Random %d ports", -port); for (int i = 0; i < count; i++) { @@ -485,7 +517,7 @@ XIAXIDRouteTable::generate_routes_handler(const String &conf, Element *e, void * #else *reinterpret_cast(xid) = static_cast(prandom32(&state)); if (i%5000==0) - click_chatter("random value %x", *reinterpret_cast(xid)); + printf("random value %x", *reinterpret_cast(xid)); #endif xid += sizeof(uint32_t); } @@ -504,14 +536,14 @@ XIAXIDRouteTable::generate_routes_handler(const String &conf, Element *e, void * random = random % (-port); xrd->port = random; if (i%5000 == 0) - click_chatter("Random port for XID %s #%d: %d ",XID(xid_d).unparse_pretty(e).c_str(), i, random); + printf("Random port for XID %s #%d: %d ",XID(xid_d).unparse_pretty(e).c_str(), i, random); } else xrd->port = port; table->_rts[XID(xid_d)] = xrd; } - click_chatter("generated %d entries", count); + printf("generated %d entries", count); return 0; } @@ -519,6 +551,7 @@ XIAXIDRouteTable::generate_routes_handler(const String &conf, Element *e, void * void XIAXIDRouteTable::push(int /*in_ether_port*/, Packet *p) { + printf("******called %s \n", __FUNCTION__); int port; //in_ether_port = XIA_PAINT_ANNO(p); @@ -593,6 +626,7 @@ XIAXIDRouteTable::push(int /*in_ether_port*/, Packet *p) int XIAXIDRouteTable::lookup_route(Packet *p) { + printf("******called %s \n", __FUNCTION__); const struct click_xia* hdr = p->xia_header(); int last = hdr->last; if (last == LAST_NODE_DEFAULT) diff --git a/click/elements/xia/xiaxidroutetable.hh b/click/elements/xia/xiaxidroutetable.hh index 76ee2a99d..1205d47be 100644 --- a/click/elements/xia/xiaxidroutetable.hh +++ b/click/elements/xia/xiaxidroutetable.hh @@ -38,9 +38,12 @@ so use the XIACheckDest element before using this element. #define REDIRECT -5 #define UNREACHABLE -6 #define FALLBACK -7 +#define NEIGHBOR 7 #define XIA_UDP_NEXTHOP 5 +#define MAX_NEIGHBOR_CNT 1024 //todo: arbitrary value at this point + enum { PRINCIPAL_TYPE_ENABLED, ROUTE_TABLE_HID, FWD_TABLE_DAG, XCACHE_SID }; typedef struct { @@ -50,6 +53,15 @@ typedef struct { std::unique_ptr nexthop_in; } XIARouteData; +typedef struct { + String addr; +} XIAXIDNeighbor; + +typedef struct { + int count; + XIAXIDNeighbor neighbors[MAX_NEIGHBOR_CNT]; +} XIAXIDNeighborTable; + class XIAXIDRouteTable : public Element { public: XIAXIDRouteTable(); @@ -80,12 +92,14 @@ protected: static String read_handler(Element *e, void *thunk); static int write_handler(const String &str, Element *e, void *thunk, ErrorHandler *errh); - static void add_entry_to_tbl_str(String& tbl, String xid, XIARouteData* xrd); + static void add_entry_to_tbl_str(Element *e, String& tbl, String xid, XIARouteData* xrd); static String list_routes_handler(Element *e, void *thunk); + static String list_neighbor_handler(Element *e, void *); HashTable _rts; XIARouteData _rtdata; uint32_t _drops; + XIAXIDNeighborTable _ntable; int _principal_type_enabled; }; diff --git a/daemons/common/XIARouter.cc b/daemons/common/XIARouter.cc index d6b82c69b..42b408536 100644 --- a/daemons/common/XIARouter.cc +++ b/daemons/common/XIARouter.cc @@ -69,6 +69,29 @@ int XIARouter::listRouters(std::vector &rlist) return 0; } +int XIARouter::getNeighbors(std::string xidtype, std::vector &neighbors) +{ + if (!connected()) + return XR_NOT_CONNECTED; + + std::string table = _router + "/xrc/n/proc/rt_" + xidtype; + + std::string neighborStr; + if ((_cserr = _cs.read(table, "neighbor", neighborStr)) != 0) + return XR_CLICK_ERROR; + + std::string::size_type beg = 0; + for (auto end = 0; (end = neighborStr.find(',', end)) != std::string::npos; ++end) + { + neighbors.push_back(neighborStr.substr(beg, end - beg)); + beg = end + 1; + } + + printf("Retuning neighbors\n"); + return 0; +} + + // get the current set of route entries, return value is number of entries returned or < 0 on err int XIARouter::getRoutes(std::string xidtype, std::vector &xrt) { diff --git a/daemons/common/XIARouter.hh b/daemons/common/XIARouter.hh index f285e7fb2..3161b5e03 100644 --- a/daemons/common/XIARouter.hh +++ b/daemons/common/XIARouter.hh @@ -89,6 +89,8 @@ public: int addRoute(const std::string &xid, int port, const std::string &next, unsigned long flags); int setRoute(const std::string &xid, int port, const std::string &next, unsigned long flags); int delRoute(const std::string &xid); + int getNeighbors(std::string xidtype, std::vector &neighbors); + const char *cserror(); private: diff --git a/tools/overlay/demo.conf b/tools/overlay/demo.conf index 660b26222..097f120ef 100644 --- a/tools/overlay/demo.conf +++ b/tools/overlay/demo.conf @@ -1,24 +1,24 @@ [r1] -ControlAddress = 10.0.1.129 +ControlAddress = 10.0.1.128 Interfaces = ens35,ens39,ens34,ens40 HostInterface = ens35 -HostAddr = 10.0.2.129 +HostAddr = 10.0.2.128 NameServer = true -Route_r2 = ens39 -> ens34:r2 -Route_r3 = ens40 -> ens39:r3 +# Route_r2 = ens39 -> ens34:r2 +# Route_r3 = ens40 -> ens39:r3 -[r2] -ControlAddress = 10.0.1.132 -Interfaces = ens39,ens40,ens34,ens41 -HostInterface = ens39 -HostAddr = 10.0.4.129 -Route_r1 = ens34 -> ens39:r1 -Route_r3 = ens41 -> ens40:r3 +# [r2] +# ControlAddress = 10.0.1.132 +# Interfaces = ens39,ens40,ens34,ens41 +# HostInterface = ens39 +# HostAddr = 10.0.4.129 +# Route_r1 = ens34 -> ens39:r1 +# Route_r3 = ens41 -> ens40:r3 -[r3] -ControlAddress = 10.0.1.134 -Interfaces = ens38,ens39,ens40,ens41 -HostInterface = ens41 -HostAddr = 10.0.3.134 -Route_r1 = ens39 -> ens40:r1 -Route_r2 = ens40 -> ens41:r2 \ No newline at end of file +# [r3] +# ControlAddress = 10.0.1.134 +# Interfaces = ens38,ens39,ens40,ens41 +# HostInterface = ens41 +# HostAddr = 10.0.3.134 +# Route_r1 = ens39 -> ens40:r1 +# Route_r2 = ens40 -> ens41:r2 From 01eabb9df217d8f807c228c764c4bb61a4950607 Mon Sep 17 00:00:00 2001 From: mirrorZ Date: Tue, 12 May 2020 10:10:16 -0400 Subject: [PATCH 104/116] xrouted element - route state to be moved --- click/conf/xia_router_lib.click | 1 + click/elements/xia/xiaoverlayrouted.cc | 116 +++++++++++++++++++++++++ click/elements/xia/xiaxidroutetable.cc | 24 ++--- click/elements/xia/xroute.proto | 91 +++++++++++++++++++ daemons/xrouted/xrouted.cc | 2 +- tools/overlay/demo.conf | 14 +-- tools/overlay/routerclick.py | 2 + 7 files changed, 230 insertions(+), 20 deletions(-) create mode 100644 click/elements/xia/xiaoverlayrouted.cc create mode 100644 click/elements/xia/xroute.proto diff --git a/click/conf/xia_router_lib.click b/click/conf/xia_router_lib.click index 8b56e1de0..ecc356d6d 100644 --- a/click/conf/xia_router_lib.click +++ b/click/conf/xia_router_lib.click @@ -384,6 +384,7 @@ elementclass XIARouter2Port { }; // 4-port router node + elementclass XIARouter4Port { $click_port, $hostname, $external_ip, $mac0, $mac1, $mac2, $mac3 | diff --git a/click/elements/xia/xiaoverlayrouted.cc b/click/elements/xia/xiaoverlayrouted.cc new file mode 100644 index 000000000..6d73d2861 --- /dev/null +++ b/click/elements/xia/xiaoverlayrouted.cc @@ -0,0 +1,116 @@ +#include +#include "xiaoverlayrouted.hh" +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include "xroute.pb.h" + +RouteState route_state; +XIARouter xr; + +#define SID_XOVERLAY "SID:1110000000000000000000000000000000001111" + +CLICK_DECLS + +XIAOverlayRouted::XIAOverlayRouted() +{ +} + +XIAOverlayRouted::~XIAOverlayRouted() +{ +} + +std::string sendHello() +{ + int buflen, rc; + string message; + Node n_ad(route_state.myAD); + Node n_hid(route_state.myHID); + Node n_sid(SID_XOVERLAY); + + Xroute::XrouteMsg msg; + Xroute::HelloMsg *hello = msg.mutable_hello(); + Xroute::Node *node = hello->mutable_node(); + Xroute::XID *ad = node->mutable_ad(); + Xroute::XID *hid = node->mutable_hid(); + Xroute::XID *sid = node->mutable_sid(); + + msg.set_type(Xroute::HELLO_MSG); + msg.set_version(Xroute::XROUTE_PROTO_VERSION); + hello->set_flags(route_state.flags); + ad ->set_type(n_ad.type()); + ad ->set_id(n_ad.id(), XID_SIZE); + hid->set_type(n_hid.type()); + hid->set_id(n_hid.id(), XID_SIZE); + sid->set_type(n_sid.type()); + sid->set_id(n_sid.id(), XID_SIZE); + + +// printf("sending %s\n", msg.DebugString().c_str()); + // printf("**** sending lsa with and num_neighbors %d \n", route_state.num_neighbors); + + msg.SerializeToString(&message); + return message; +} + +void XIAOverlayRouted::push(int port, Packet *p_in) +{ + printf("In overlay\n"); + std::string msg = sendHello(); + + struct click_ip *ip; + struct click_udp *udp; + WritablePacket *q = Packet::make(sizeof(*ip) + sizeof(*udp) + len(msg)); + memset(q->data(), '\0', q->length()); + ip = (struct click_ip *) q->data(); + udp = (struct click_udp *) (ip + 1); + memcpy(q + sizeof(*ip) + sizeof(*udp), msg.c_str, len(msg)); + + ip->ip_v = 4; + ip->ip_hl = 5; + ip->ip_tos = 0x10; + ip->ip_len = htons(q->length()); + ip->ip_id = htons(0); // what is this used for exactly? + ip->ip_off = htons(IP_DF); + ip->ip_ttl = 255; + ip->ip_p = IP_PROTO_UDP; + ip->ip_sum = 0; + struct in_addr *saddr = malloc(sizeof(struct in_addr)); + struct in_addr *daddr = malloc(sizeof(struct in_addr)); + assert(saddr); + assert(daddr); + inet_aton("10.0.1.128", &saddr->saddr); + inet_aton("10.0.1.130", &daddr->saddr); + ip->ip_src = saddr; + ip->ip_dst = daddr; + + + udp->uh_sport = htons(8772); + udp->uh_dport = htons(8772); + udp->ulen = htons(len(msg)); + + q->set_ip_header(ip, ip->ip_hl << 2); + + output(0).push(q); +} + + +CLICK_ENDDECLS +EXPORT_ELEMENT(XIAOverlayRouted) +ELEMENT_MT_SAFE(XIAOverlayRouted) \ No newline at end of file diff --git a/click/elements/xia/xiaxidroutetable.cc b/click/elements/xia/xiaxidroutetable.cc index 48497e170..e2dd576e5 100644 --- a/click/elements/xia/xiaxidroutetable.cc +++ b/click/elements/xia/xiaxidroutetable.cc @@ -75,7 +75,7 @@ XIAXIDRouteTable::add_handlers() String XIAXIDRouteTable::read_handler(Element *e, void *thunk) { - printf("******called %s \n", __FUNCTION__); + // printf("******called %s \n", __FUNCTION__); XIAXIDRouteTable *t = (XIAXIDRouteTable *) e; switch ((intptr_t)thunk) { case PRINCIPAL_TYPE_ENABLED: @@ -89,7 +89,7 @@ XIAXIDRouteTable::read_handler(Element *e, void *thunk) int XIAXIDRouteTable::write_handler(const String &str, Element *e, void *thunk, ErrorHandler * /*errh*/) { - printf("******called %s \n", __FUNCTION__); + // printf("******called %s \n", __FUNCTION__); XIAXIDRouteTable *t = (XIAXIDRouteTable *) e; switch ((intptr_t)thunk) { case PRINCIPAL_TYPE_ENABLED: @@ -103,7 +103,7 @@ void XIAXIDRouteTable::add_entry_to_tbl_str(Element *e, String& tbl, String xid, XIARouteData* xrd) { - printf("******called %s \n", __FUNCTION__); + // printf("******called %s \n", __FUNCTION__); // XID tbl += xid + ","; // port @@ -133,7 +133,7 @@ XIAXIDRouteTable::add_entry_to_tbl_str(Element *e, String& tbl, String xid, String XIAXIDRouteTable::list_routes_handler(Element *e, void * /*thunk */) { - printf("******called %s \n", __FUNCTION__); + // printf("******called %s \n", __FUNCTION__); XIAXIDRouteTable* table = static_cast(e); XIARouteData *xrd = &table->_rtdata; @@ -167,7 +167,7 @@ int XIAXIDRouteTable::set_handler(const String &conf, Element *e, void *thunk, ErrorHandler *errh) { // handle older style route entries - printf("******called %s \n", __FUNCTION__); + // printf("******called %s \n", __FUNCTION__); String str_copy = conf; String xid_str = cp_shift_spacevec(str_copy); @@ -189,7 +189,7 @@ XIAXIDRouteTable::set_handler(const String &conf, Element *e, void *thunk, Error int XIAXIDRouteTable::set_handler4(const String &conf, Element *e, void *thunk, ErrorHandler *errh) { - printf("******called %s \n", __FUNCTION__); XIAXIDRouteTable* table = static_cast(e); + XIAXIDRouteTable* table = static_cast(e); bool add_mode = !thunk; @@ -261,7 +261,7 @@ XIAXIDRouteTable::set_handler4(const String &conf, Element *e, void *thunk, Erro int XIAXIDRouteTable::set_udpnext(const String &conf, Element *e, void *thunk, ErrorHandler *errh) { - printf("******called %s \n", __FUNCTION__); + // printf("******called %s \n", __FUNCTION__); XIAXIDRouteTable* table = static_cast(e); bool add_mode = !thunk; Vector args; @@ -344,7 +344,7 @@ XIAXIDRouteTable::set_udpnext(const String &conf, Element *e, void *thunk, Error int XIAXIDRouteTable::remove_handler(const String &xid_str, Element *e, void *, ErrorHandler *errh) { - printf("******called %s \n", __FUNCTION__); + // printf("******called %s \n", __FUNCTION__); XIAXIDRouteTable* table = static_cast(e); if (xid_str.length() == 0) @@ -385,7 +385,7 @@ XIAXIDRouteTable::remove_handler(const String &xid_str, Element *e, void *, Erro int XIAXIDRouteTable::load_routes_handler(const String &conf, Element *e, void *, ErrorHandler *errh) { - printf("******called %s \n", __FUNCTION__); + // printf("******called %s \n", __FUNCTION__); #if CLICK_USERLEVEL std::ifstream in_f(conf.c_str()); if (!in_f.is_open()) @@ -453,7 +453,7 @@ XIAXIDRouteTable::load_routes_handler(const String &conf, Element *e, void *, Er int XIAXIDRouteTable::generate_routes_handler(const String &conf, Element *e, void *, ErrorHandler *errh) { - printf("******called %s \n", __FUNCTION__); + // printf("******called %s \n", __FUNCTION__); #if CLICK_USERLEVEL XIAXIDRouteTable* table = dynamic_cast(e); #else @@ -551,7 +551,7 @@ XIAXIDRouteTable::generate_routes_handler(const String &conf, Element *e, void * void XIAXIDRouteTable::push(int /*in_ether_port*/, Packet *p) { - printf("******called %s \n", __FUNCTION__); + // printf("******called %s \n", __FUNCTION__); int port; //in_ether_port = XIA_PAINT_ANNO(p); @@ -626,7 +626,7 @@ XIAXIDRouteTable::push(int /*in_ether_port*/, Packet *p) int XIAXIDRouteTable::lookup_route(Packet *p) { - printf("******called %s \n", __FUNCTION__); + // printf("******called %s \n", __FUNCTION__); const struct click_xia* hdr = p->xia_header(); int last = hdr->last; if (last == LAST_NODE_DEFAULT) diff --git a/click/elements/xia/xroute.proto b/click/elements/xia/xroute.proto new file mode 100644 index 000000000..79f6eda20 --- /dev/null +++ b/click/elements/xia/xroute.proto @@ -0,0 +1,91 @@ +syntax = "proto2"; +/* +** xrouted message definitions +*/ + +package Xroute; +//syntax = "proto2"; + +enum constants { + XROUTE_PROTO_VERSION = 1; +} + +message XID { + required uint32 type = 1; // should use the XID type values from xia.h + required bytes id = 2; // must be 20 bytes long +} + +message Node { + required XID ad = 1; + required XID hid = 2; + optional XID sid = 3; + optional uint32 flags = 4; +} + +message TableEntry { + required Node node = 1; + required uint32 interface = 2; + optional uint32 flags = 3; +} + +message HelloMsg { + required Node node = 1; + optional uint32 flags = 2; +} + +message LSAMsg { + required Node node = 1; + optional uint32 flags = 2; + repeated Node peers = 3; +} + +message HostJoinMsg { + required string hid = 1; + required uint32 interface = 2; + optional uint32 flags = 3; +} + +// FIXME: make this use the XID type at some point +message HostLeaveMsg { + required string hid = 1; +} + +message TableUpdateMsg { + required Node from = 1; + required Node to = 2; + repeated TableEntry route = 3; +} + +message GlobalLSAMsg { + required Node from = 1; +} + +message ConfigMsg { + required string ad = 1; + required string controller_dag = 2; +} + +enum msg_type { + HELLO_MSG = 1; // local router hello msg. still needed? + LSA_MSG = 2; // router announcement -> controller + HOST_JOIN_MSG = 3; // add host route from xnetjd + HOST_LEAVE_MSG = 4; // host leaving network + TABLE_UPDATE_MSG = 5; // new tables from controller -> router + GLOBAL_LSA_MSG = 6; // lsa between controllers in different ADs + CONFIG_MSG = 7; // router configuration info from xnetjd +} + +message XrouteMsg { + required uint32 version = 1; + required msg_type type = 2; + + oneof payload { + HelloMsg hello = 3; + LSAMsg lsa = 4; + TableUpdateMsg table_update = 5; + GlobalLSAMsg global_lsa = 6; + HostJoinMsg host_join = 7; + HostLeaveMsg host_leave = 8; + ConfigMsg config = 9; + } +} diff --git a/daemons/xrouted/xrouted.cc b/daemons/xrouted/xrouted.cc index 71f30dd98..61b72c863 100644 --- a/daemons/xrouted/xrouted.cc +++ b/daemons/xrouted/xrouted.cc @@ -81,7 +81,7 @@ int sendHello() // printf("sending %s\n", msg.DebugString().c_str()); - printf("**** sending lsa with and num_neighbors %d \n", route_state.num_neighbors); + // printf("**** sending lsa with and num_neighbors %d \n", route_state.num_neighbors); msg.SerializeToString(&message); buflen = message.length(); diff --git a/tools/overlay/demo.conf b/tools/overlay/demo.conf index 097f120ef..2bce1d84e 100644 --- a/tools/overlay/demo.conf +++ b/tools/overlay/demo.conf @@ -4,15 +4,15 @@ Interfaces = ens35,ens39,ens34,ens40 HostInterface = ens35 HostAddr = 10.0.2.128 NameServer = true -# Route_r2 = ens39 -> ens34:r2 +Route_r2 = ens39 -> ens34:r2 # Route_r3 = ens40 -> ens39:r3 -# [r2] -# ControlAddress = 10.0.1.132 -# Interfaces = ens39,ens40,ens34,ens41 -# HostInterface = ens39 -# HostAddr = 10.0.4.129 -# Route_r1 = ens34 -> ens39:r1 +[r2] +ControlAddress = 10.0.1.130 +Interfaces = ens39,ens40,ens34,ens41 +HostInterface = ens39 +HostAddr = 10.0.4.129 +Route_r1 = ens34 -> ens39:r1 # Route_r3 = ens41 -> ens40:r3 # [r3] diff --git a/tools/overlay/routerclick.py b/tools/overlay/routerclick.py index 96f38e472..70711855f 100644 --- a/tools/overlay/routerclick.py +++ b/tools/overlay/routerclick.py @@ -43,6 +43,8 @@ def to_string(self): if (index < num_interfaces): (iface_name, ipaddr, macaddr) = self.interfaces[index] rstr += '\nosock{}::XIAOverlaySocket("UDP", {}, {}, SNAPLEN 65536) -> [{}]{}[{}] -> osock{};\n'.format(index, ipaddr, 8770, index, self.name, index, index) + rstr += '\nrsock{}::XIAOverlaySocket("UDP", {}, {}, SNAPLEN 65536) -> rd{}::XIAOverlayRouted() -> Discard;\n'.format(index, ipaddr, 8772, index) + else: rstr += '\nIdle -> [{}]{}[{}] -> Discard;\n'.format( index, self.name, index) From a26388faa7be6848ea6df40c00cb9766bb848dc9 Mon Sep 17 00:00:00 2001 From: mirrorZ Date: Sat, 16 May 2020 23:42:53 -0400 Subject: [PATCH 105/116] Compile xiaoverlayrouted --- click/elements/xia/xiaoverlayrouted.cc | 782 +++++++++++++++++- click/elements/xia/xiaoverlayrouted.hh | 410 +++++++++ .../{elements/xia => userlevel}/xroute.proto | 0 3 files changed, 1167 insertions(+), 25 deletions(-) create mode 100644 click/elements/xia/xiaoverlayrouted.hh rename click/{elements/xia => userlevel}/xroute.proto (100%) diff --git a/click/elements/xia/xiaoverlayrouted.cc b/click/elements/xia/xiaoverlayrouted.cc index 6d73d2861..254fad00b 100644 --- a/click/elements/xia/xiaoverlayrouted.cc +++ b/click/elements/xia/xiaoverlayrouted.cc @@ -1,32 +1,764 @@ #include -#include "xiaoverlayrouted.hh" #include #include +#include +#include #include -#include +#include +#include "xiaoverlayrouted.hh" + +RouteState route_state; +XIARouter xr; + +#define XID_SIZE CLICK_XIA_XID_ID_LEN + +#define SID_XOVERLAY "SID:1110000000000000000000000000000000001111" + +CLICK_DECLS + + #include #include #include -#include -#include #include -#include -#include -#include -#include -#include -#include #include +#include #include -#include -#include "xroute.pb.h" +#include +#include +#include +#include +#include -RouteState route_state; -XIARouter xr; +#define INCLUDE_TEST_CODE 0 -#define SID_XOVERLAY "SID:1110000000000000000000000000000000001111" -CLICK_DECLS +#define check_init() do { if (!_init) return init_err; } while (false); + +ControlSocketClient::err_t +ControlSocketClient::configure(unsigned int host_ip, unsigned short port) +{ + + if (_init) + return reinit_err; + + _host = host_ip; + _port = port; + + _fd = socket(PF_INET, SOCK_STREAM, 0); + if (_fd < 0) + return sys_err; + + /* + * connect to remote ControlSocket + */ + struct sockaddr_in sa; + memset(&sa, 0, sizeof(sa)); + sa.sin_family = AF_INET; + sa.sin_addr.s_addr = _host; + sa.sin_port = htons(port); + + char namebuf[32]; + snprintf(namebuf, 32, "%u.%u.%u.%u:%hu", + (_host & 0xff) >> 0, + (_host & 0xff00) >> 8, + (_host & 0xff0000) >> 16, + (_host & 0xff000000) >> 24, + port); + _name = namebuf; + + int res = connect(_fd, (struct sockaddr *) &sa, sizeof(sa)); + if (res < 0) { + int save_errno = errno; + ::close(_fd); + errno = save_errno; + return sys_err; + } + + int major, minor; + size_t slash, dot; + + /* + * check that we get the expected banner + */ + string buf; + err_t err = readline(buf); + if (err != no_err) { + int save_errno = errno; + ::close(_fd); + errno = save_errno; + return err; + } + + slash = buf.find('/'); + dot = (slash != string::npos ? buf.find('.', slash + 1) : string::npos); + if (slash == string::npos || dot == string::npos) { + ::close(_fd); + return click_err; /* bad format */ + } + + /* + * check ControlSocket protocol version + */ + major = atoi(buf.substr(slash + 1, dot - slash - 1).c_str()); + minor = atoi(buf.substr(dot + 1, buf.size() - dot - 1).c_str()); + if (major != PROTOCOL_MAJOR_VERSION || + minor < PROTOCOL_MINOR_VERSION) { + ::close(_fd); + return click_err; /* wrong version */ + } + + _init = true; + return no_err; +} + + +ControlSocketClient::err_t +ControlSocketClient::close() +{ + check_init(); + _init = false; + int res = ::close(_fd); + if (res < 1) + return sys_err; + else + return no_err; +} + + +ControlSocketClient::err_t +ControlSocketClient::readline(string &buf) +{ + assert(_fd); + +#define MAX_LINE_SZ 1024 /* arbitrary... to prevent weirdness */ + + /* + * keep calling read() to get one character at a time, until we get + * a line. not very ``efficient'', but who cares? + */ + char c = 0; + buf.resize(0); + do { + int res = ::read(_fd, (void *) &c, 1); + if (res < 0) + return sys_err; + if (res != 1) + return sys_err; + buf += c; + if (buf.size() > MAX_LINE_SZ) + return click_err; + } + while (c != '\n'); + + return no_err; +} + + +int +ControlSocketClient::get_resp_code(string line) +{ + if (line.size() < 3) + return -1; + return atoi(line.substr(0, 3).c_str()); +} + + +int +ControlSocketClient::get_data_len(string line) +{ + unsigned int i; + for (i = 0; i < line.size() && !isdigit((unsigned char) line[i]); i++) + ; // scan string + if (i == line.size()) + return -1; + return atoi(line.substr(i, line.size() - i).c_str()); +} + + +ControlSocketClient::err_t +ControlSocketClient::read(string el, string handler, string &response) +{ + check_init(); + + if (el.size() > 0) + handler = el + "." + handler; + string cmd = "READ " + handler + "\n"; + + int res = ::write(_fd, cmd.c_str(), cmd.size()); + if (res < 0) + return sys_err; + if ((size_t) res != cmd.size()) + return sys_err; + + string cmd_resp; + string line; + do { + err_t err = readline(line); + if (err != no_err) + return err; + if (line.size() < 4) + return click_err; + cmd_resp += line; + } + while (line[3] == '-'); + + int code = get_resp_code(line); + if (code != CODE_OK && code != CODE_OK_WARN) + return handle_err_code(code); + + res = readline(line); + if (res < 0) + return click_err; + int num = get_data_len(line); + if (num < 0) + return click_err; + + response.resize(0); + if (num == 0) + return no_err; + + char *buf = new char[num]; + int num_read = 0; + while (num_read < num) { + res = ::read(_fd, buf + num_read, num - num_read); + if (res < 0) { + delete[] buf; + return sys_err; + } + num_read += res; + } + + response.append(buf, num); + delete[] buf; + + return no_err; +} + + +ControlSocketClient::err_t +ControlSocketClient::read(string el, string handler, char *buf, int &bufsz) +{ + string resp; + err_t err = read(el, handler, resp); + if (err != no_err) + return err; + + bufsz = min((size_t) bufsz, resp.size()); + + memcpy(buf, resp.c_str(), bufsz); + if (resp.size() > (size_t) bufsz) + return too_short; + else + return no_err; +} + + +ControlSocketClient::err_t +ControlSocketClient::write(string el, string handler, const char *buf, int bufsz) +{ + check_init(); + + if (el.size() > 0) + handler = el + "." + handler; + char cbuf[10]; + snprintf(cbuf, sizeof(cbuf), "%d", bufsz); + string cmd = "WRITEDATA " + handler + " " + cbuf + "\n"; + + int res = ::write(_fd, cmd.c_str(), cmd.size()); + if (res < 0) + return sys_err; + if ((size_t) res != cmd.size()) + return sys_err; + + res = ::write(_fd, buf, bufsz); + if (res < 0) + return sys_err; + if (res != bufsz) + return sys_err; + + string cmd_resp; + string line; + do { + err_t err = readline(line); + if (err != no_err) + return err; + if (line.size() < 4) + return click_err; + cmd_resp += line; + } + while (line[3] == '-'); + + int code = get_resp_code(line); + if (code != CODE_OK && code != CODE_OK_WARN) + { +// cout << "CCCC " << code << endl; + return handle_err_code(code); + } + + return no_err; +} + + +ControlSocketClient::err_t +ControlSocketClient::write(string el, string handler, string data) +{ + return write(el, handler, data.c_str(), data.size()); +} + + +ControlSocketClient::err_t +ControlSocketClient::handle_err_code(int code) +{ + switch (code) { + case CODE_SYNTAX_ERR: return click_err; break; + case CODE_UNIMPLEMENTED: return click_err; break; + case CODE_NO_ELEMENT: return no_element; break; + case CODE_NO_HANDLER: return no_handler; break; + case CODE_HANDLER_ERR: return handler_err; break; + case CODE_PERMISSION: return handler_no_perm; break; + default: return click_err; break; + } + return click_err; +} + + + +vector +ControlSocketClient::split(string s, size_t offset, char terminator) +{ + vector v; + size_t pos = offset; + size_t len = s.size(); + while (pos < len) { + size_t start = pos; + while (pos < len && s[pos] != terminator) + pos++; + if (start < pos || pos < len) + v.push_back(s.substr(start, pos - start)); + pos++; + } + return v; +} + + +ControlSocketClient::err_t +ControlSocketClient::get_config_el_names(vector &els) +{ + string resp; + err_t err = read("", "list", resp); + if (err != no_err) + return err; + + /* parse how many els */ + int i = resp.find('\n'); + int num = atoi(resp.substr(0, i).c_str()); + + + els = split(resp, i + 1, '\n'); + if (els.size() != (size_t) num) + return handler_bad_format; + + return no_err; +} + + +ControlSocketClient::err_t +ControlSocketClient::get_string_vec(string el, string h, vector &v) +{ + string resp; + err_t err = read(el, h, resp); + if (err != no_err) + return err; + + v = split(resp, 0, '\n'); + return no_err; +} + + +ControlSocketClient::err_t +ControlSocketClient::get_el_handlers(string el, vector &handlers) +{ + vector v; + vector vh; + + string buf; + err_t err = read(el, "handlers", buf); + if (err != no_err) + return err; + + vh = split(buf, 0, '\n'); + for (vector::iterator i = vh.begin(); i != vh.end(); i++) { + string &s = *i; + size_t j; + for (j = 0; j < s.size() && !isspace((unsigned char) s[j]); j++) + ; /* find record split -- don't use s.find because could be any whitespace */ + if (j == s.size()) + return click_err; + handler_info_t hi; + hi.element_name = el; + hi.handler_name = trim(s.substr(0, j)); + while (j < s.size() && isspace((unsigned char) s[j])) + j++; + for ( ; j < s.size(); j++) { + if (tolower((unsigned char) s[j]) == 'r') + hi.can_read = true; + else if (tolower((unsigned char) s[j]) == 'w') + hi.can_write = true; + else if (isspace((unsigned char) s[j])) + break; + } + v.push_back(hi); + } + + handlers = v; + return no_err; +} + + +ControlSocketClient::err_t +ControlSocketClient::check_handler(string el, string h, bool is_write, bool &exists) +{ + check_init(); + + if (el.size() > 0) + h = el + "." + h; + string cmd = (is_write ? "CHECKWRITE " : "CHECKREAD ") + h + "\n"; + + int res = ::write(_fd, cmd.c_str(), cmd.size()); + if (res < 0) + return sys_err; + if ((size_t) res != cmd.size()) + return sys_err; + + string cmd_resp; + string line; + do { + err_t err = readline(line); + if (err != no_err) + return err; + if (line.size() < 4) + return click_err; + cmd_resp += line; + } + while (line[3] == '-'); + + int code = get_resp_code(line); + switch (code) { + case CODE_OK: + case CODE_OK_WARN: + exists = true; + return no_err;; + case CODE_NO_ELEMENT: + case CODE_NO_HANDLER: + case CODE_HANDLER_ERR: + case CODE_PERMISSION: + exists = false; + return no_err; + case CODE_UNIMPLEMENTED: + if (el.size() == 0) + return handle_err_code(code); /* no workaround for top-level router handlers */ + else + return check_handler_workaround(el, h, is_write, exists); + default: + return handle_err_code(code); + } +} + + + +ControlSocketClient::err_t +ControlSocketClient::check_handler_workaround(string el, string h, bool is_write, bool &exists) +{ + /* + * If talking to an old ControlSocket, try the "handlers" handler + * instead. + */ + + vector v; + err_t err = get_el_handlers(el, v); + if (err != no_err) + return err; + + for (vector::iterator i = v.begin(); i != v.end(); i++) { + if (i->handler_name == h) { + if ((is_write && i->can_write) || + (!is_write && i->can_read)) + exists = true; + else + exists = false; + return no_err; + } + } + + exists = false; + return no_err; +} + + +string +ControlSocketClient::trim(string s) +{ + size_t start, end; + for (start = 0; start < s.size() && isspace((unsigned char) s[start]); start++) + ; /* */ + for (end = s.size(); end > 0 && isspace((unsigned char) s[end - 1]); end--) + ; /* */ + + if (start >= end) + return ""; + + return s.substr(start, end - start); +} + +int XIARouter::connect(std::string clickHost, unsigned short controlPort) +{ + struct hostent *h; + + if (_connected) + return XR_ALREADY_CONNECTED; + + if ((h = gethostbyname(clickHost.c_str())) == NULL) + return XR_BAD_HOSTNAME; + + unsigned addr = *(unsigned*)h->h_addr; + + if ((_cserr = _cs.configure(addr, controlPort)) != 0) + return XR_NOT_CONNECTED; + + _connected = true; + return XR_OK; +} + +void XIARouter::close() +{ + if (_connected) + _cserr = _cs.close(); + _connected = false; +} + +int XIARouter::version(std::string &ver) +{ + if (!connected()) + return XR_NOT_CONNECTED; + + if ((_cserr = _cs.get_router_version(ver)) == 0) + return XR_OK; + return XR_CLICK_ERROR; +} + +int XIARouter::listRouters(std::vector &rlist) +{ + vector elements; + size_t n; + + if (!connected()) + return XR_NOT_CONNECTED; + + if ((_cserr = _cs.get_config_el_names(elements)) != 0) + return XR_CLICK_ERROR; + + vector::iterator it; + for (it = elements.begin(); it < elements.end(); it++) { + + // cheap way of finding host and router devices, they both have a /xrc element + if ((n = (*it).find("/xrc")) != string::npos) { + rlist.push_back((*it).substr(0, n)); + } + } + return 0; +} + +int XIARouter::getNeighbors(std::string xidtype, std::vector &neighbors) +{ + if (!connected()) + return XR_NOT_CONNECTED; + + std::string table = _router + "/xrc/n/proc/rt_" + xidtype; + + std::string neighborStr; + if ((_cserr = _cs.read(table, "neighbor", neighborStr)) != 0) + return XR_CLICK_ERROR; + + std::string::size_type beg = 0; + for (auto end = 0; (end = neighborStr.find(',', end)) != std::string::npos; ++end) + { + neighbors.push_back(neighborStr.substr(beg, end - beg)); + beg = end + 1; + } + + printf("Retuning neighbors\n"); + return 0; +} + + +// get the current set of route entries, return value is number of entries returned or < 0 on err +int XIARouter::getRoutes(std::string xidtype, std::vector &xrt) +{ + std::string result; + vector lines; + int n = 0; + + if (!connected()) + return XR_NOT_CONNECTED; + + if (xidtype.length() == 0) + return XR_INVALID_XID; + + if (getRouter().length() == 0) + return XR_ROUTER_NOT_SET; + + std::string table = _router + "/xrc/n/proc/rt_" + xidtype; + + if ((_cserr = _cs.read(table, "list", result)) != 0) + return XR_CLICK_ERROR; + + unsigned start = 0; + unsigned current = 0; + unsigned len = result.length(); + string line; + + xrt.clear(); + while (current < len) { + start = current; + while (current < len && result[current] != '\n') { + current++; + } + + if (start < current || current < len) { + line = result.substr(start, current - start); + + XIARouteEntry entry; + unsigned start, next; + string s; + int port; + + start = 0; + next = line.find(","); + entry.xid = line.substr(start, next - start); + + start = next + 1; + next = line.find(",", start); + s = line.substr(start, next - start); + port = atoi(s.c_str()); + entry.port = port; + + start = next + 1; + next = line.find(",", start); + entry.nextHop = line.substr(start, next - start); + + start = next + 1; + s = line.substr(start, line.length() - start); + entry.flags = atoi(s.c_str()); + + xrt.push_back(entry); + n++; + } + current++; + } + + return n; +} + +std::string XIARouter::itoa(signed i) +{ + std::string s; + std::stringstream ss; + + ss << i; + s = ss.str(); + return s; +} + +int XIARouter::updateRoute(string cmd, const std::string &xid, int port, const std::string &next, unsigned long flags) +{ + string xidtype; + string mutableXID(xid); + size_t n; + + if (!connected()) + return XR_NOT_CONNECTED; + + if (mutableXID.length() == 0) + return XR_INVALID_XID; + + if (next.length() > 0 && next.find(":") == string::npos) + return XR_INVALID_XID; + + n = mutableXID.find(":"); + if (n == string::npos || n >= sizeof(xidtype)) + return XR_INVALID_XID; + + if (getRouter().length() == 0) + return XR_ROUTER_NOT_SET; + + xidtype = mutableXID.substr(0, n); + + std::string table = _router + "/xrc/n/proc/rt_" + xidtype; + + string default_xid("-"); + if (mutableXID.compare(n+1, 1, default_xid) == 0) + mutableXID = default_xid; + + std::string entry; + + // remove command only takes an xid + if (cmd == "remove") + entry = mutableXID; + else + entry = mutableXID + "," + itoa(port) + "," + next + "," + itoa(flags); + + if ((_cserr = _cs.write(table, cmd, entry)) != 0) + return XR_CLICK_ERROR; + + return XR_OK; +} + +int XIARouter::addRoute(const std::string &xid, int port, const std::string &next, unsigned long flags) +{ + return updateRoute("add4", xid, port, next, flags); +} + +int XIARouter::setRoute(const std::string &xid, int port, const std::string &next, unsigned long flags) +{ + return updateRoute("set4", xid, port, next, flags); +} + +int XIARouter::delRoute(const std::string &xid) +{ + string next = ""; + return updateRoute("remove", xid, 0, next, 0); +} + +const char *XIARouter::cserror() +{ + switch(_cserr) { + case ControlSocketClient::no_err: + return "no error"; + case ControlSocketClient::sys_err: + return "O/S or networking error, check errno for more information"; + case ControlSocketClient::init_err: + return "tried to perform operation on an unconfigured ControlSocketClient"; + case ControlSocketClient::reinit_err: + return "tried to re-configure the client before close()ing it"; + case ControlSocketClient::no_element: + return "specified element does not exist"; + case ControlSocketClient::no_handler: + return "specified handler does not exist"; + case ControlSocketClient::handler_no_perm: + return "router denied access to the specified handler"; + case ControlSocketClient::handler_err: + return "handler returned an error"; + case ControlSocketClient::handler_bad_format: + return "bad format in calling handler"; + case ControlSocketClient::click_err: + return "unexpected response or error from the router"; + case ControlSocketClient::too_short: + return "user buffer was too short"; + } + return "unknown"; +} + XIAOverlayRouted::XIAOverlayRouted() { @@ -76,11 +808,11 @@ void XIAOverlayRouted::push(int port, Packet *p_in) struct click_ip *ip; struct click_udp *udp; - WritablePacket *q = Packet::make(sizeof(*ip) + sizeof(*udp) + len(msg)); + WritablePacket *q = Packet::make(sizeof(*ip) + sizeof(*udp) + msg.length()); memset(q->data(), '\0', q->length()); ip = (struct click_ip *) q->data(); udp = (struct click_udp *) (ip + 1); - memcpy(q + sizeof(*ip) + sizeof(*udp), msg.c_str, len(msg)); + memcpy(q + sizeof(*ip) + sizeof(*udp), msg.c_str(), msg.length()); ip->ip_v = 4; ip->ip_hl = 5; @@ -91,19 +823,19 @@ void XIAOverlayRouted::push(int port, Packet *p_in) ip->ip_ttl = 255; ip->ip_p = IP_PROTO_UDP; ip->ip_sum = 0; - struct in_addr *saddr = malloc(sizeof(struct in_addr)); - struct in_addr *daddr = malloc(sizeof(struct in_addr)); + struct in_addr *saddr = (struct in_addr *)malloc(sizeof(struct in_addr)); + struct in_addr *daddr = (struct in_addr *)malloc(sizeof(struct in_addr)); assert(saddr); assert(daddr); - inet_aton("10.0.1.128", &saddr->saddr); - inet_aton("10.0.1.130", &daddr->saddr); - ip->ip_src = saddr; - ip->ip_dst = daddr; + inet_aton("10.0.1.128", saddr); + inet_aton("10.0.1.130", daddr); + ip->ip_src = *saddr; + ip->ip_dst = *daddr; udp->uh_sport = htons(8772); udp->uh_dport = htons(8772); - udp->ulen = htons(len(msg)); + udp->uh_ulen = htons(msg.length()); q->set_ip_header(ip, ip->ip_hl << 2); diff --git a/click/elements/xia/xiaoverlayrouted.hh b/click/elements/xia/xiaoverlayrouted.hh new file mode 100644 index 000000000..6256781e5 --- /dev/null +++ b/click/elements/xia/xiaoverlayrouted.hh @@ -0,0 +1,410 @@ +#ifndef CLICK_XIAOVERLAYROUTED_HH +#define CLICK_XIAOVERLAYROUTED_HH +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include "../../userlevel/xroute.pb.h" + +using namespace std; + +CLICK_DECLS + +#define F_CORE_ROUTER 0x0002 // node is an internal router +#define F_EDGE_ROUTER 0x0004 // node is an edge router +#define F_CONTROLLER 0x0008 // node is a controller +#define F_IP_GATEWAY 0x0010 // router is a dual stack router +#define F_STATIC_ROUTE 0x0100 // route entry was added manually and should not expire + +// Main loop iterates every 1000 usec = 1 ms = 0.001 sec +#define MAIN_LOOP_USEC 1000 +#define MAIN_LOOP_MSEC 50 // .05 sec +#define RECV_ITERS 2 +#define HELLO_ITERS 2 +#define LSA_ITERS 8 +#define CALC_DIJKSTRA_INTERVAL 4 +#define MAX_HOP_COUNT 50 +#define MAX_XID_SIZE 64 +#define MAX_DAG_SIZE 512 + +#define XR_OK 0 +#define XR_NOT_CONNECTED -1 +#define XR_ALREADY_CONNECTED -2 +#define XR_CLICK_ERROR -3 +#define XR_ROUTE_EXISTS -4 +#define XR_ROUTE_DOESNT_EXIST -5 +#define XR_NOT_XIA -6 +#define XR_ROUTER_NOT_SET -7 +#define XR_BAD_HOSTNAME -8 +#define XR_INVALID_XID -9 + +#define TOTAL_SPECIAL_CASES 8 +#define DESTINED_FOR_DISCARD -1 +#define DESTINED_FOR_LOCALHOST -2 +#define DESTINED_FOR_DHCP -3 +#define DESTINED_FOR_BROADCAST -4 +#define REDIRECT -5 +#define UNREACHABLE -6 +#define FALLBACK -7 + +/* + * NB: obscure implementation note: this class does not handle EINTR + * errors from any of the read/write calls. If this is relevant to + * your program, this class may not do the ``right thing'' + */ + +class ControlSocketClient +{ +public: + ControlSocketClient() : _init(false), _fd(0) { } + ControlSocketClient(ControlSocketClient &) : _init(false), _fd(0) { } + + enum err_t { + no_err = 0, + sys_err, /* O/S or networking error, check errno for more information */ + init_err, /* tried to perform operation on an unconfigured ControlSocketClient */ + reinit_err, /* tried to re-configure the client before close()ing it */ + no_element, /* specified element does not exist */ + no_handler, /* specified handler does not exist */ + handler_no_perm, /* router denied access to the specified handler */ + handler_err, /* handler returned an error */ + handler_bad_format, /* bad format in calling handler */ + click_err, /* unexpected response or error from the router */ + too_short /* user buffer was too short */ + }; + + /* + * Configure a new ControlSocketClient. + * HOST_IP is IP address (in network byte order) of the machine that user-level click is running on + * PORT is the IP port the ControlSocket is listening on. + * Returns: no_err, sys_err, reinit_err, click_err + * If returns no_err, the client is properly configured; otherwise the client is unconfigured. + */ + err_t configure(unsigned int host_ip, unsigned short port); + + /* + * Close a configured client. + * Returns: no_err, sys_err, init_err + * In any case, the client is left unconfigured. + */ + err_t close(); + + /* + * Return a string describing the ControlSocket's host and port. + * Requires: object is configured + */ + const string name() { assert(_init); return _name; } + + + /* + * NB: the following functions return data about or send data to the + * click router via the ControlSocket. Unless otherwise noted, the + * data returned or sent is undefined unless the function's return + * value is no_err. + */ + + /* + * Get a string containing the router's configuration + * (get_router_config) or flattened configuration + * (get_router_flat_config). + * CONFIG is filled with the configuration; existing contents are replaced. + * Returns: no_err, no_handler, handler_err, handler_no_perm, sys_err, init_err, click_err + */ + err_t get_router_config(string &config) { return read("", "config", config); } + err_t get_router_flat_config(string &config) { return read("", "flatconfig", config); } + + /* + * Get a string containing the router's version + * VERS is filled with the version; existing contents are replaced. + * Returns: no_err, no_handler, handler_err, handler_no_perm, sys_err, init_err, click_err + */ + err_t get_router_version(string &vers) { err_t err = read("", "version", vers); /*vers = trim(vers);*/ return err; } + + /* + * Get the names of the elements in the the current router configuration. + * ELS is filled with the names, existing contents are replaced. + * Returns: no_err, no_handler, handler_err, handler_no_perm, sys_err, init_err, click_err + */ + err_t get_config_el_names(vector &els); + + /* + * Get the names of the element types that the router knows about. + * CLASSES is filled with the names, existing contents are replaced. + * Returns: no_err, no_handler, handler_err, handler_no_perm, sys_err, init_err, click_err + */ + err_t get_router_classes(vector &classes) { return get_string_vec("", "classes", classes); } + + /* + * Get the names of the packages that the router knows about. + * PACKAGES is filled with the names, existing contents are replaced. + * Returns: no_err, no_handler, handler_err, handler_no_perm, sys_err, init_err, click_err + */ + err_t get_router_packages(vector &pkgs) { return get_string_vec("", "packages", pkgs); } + + /* + * Get the names of the current router configuration requirements. + * REQS is filled with the names, existing contents are replaced. + * Returns: no_err, no_handler, handler_err, handler_no_perm, sys_err, init_err, click_err + */ + err_t get_config_reqs(vector &reqs) { return get_string_vec("", "requirements", reqs); } + + struct handler_info_t { + string element_name; + string handler_name; + bool can_read; + bool can_write; + handler_info_t() : can_read(false), can_write(false) { } + }; + + /* + * Get the information about an element's handlers in the current router configuration. + * EL is the element's name. + * HANDLERS is filled with the handler info, existing contents are replaced. + * Returns: no_err, no_element, handler_err, handler_no_perm, sys_err, init_err, click_err + */ + err_t get_el_handlers(string el, vector &handlers); + + /* + * Check whether a read/write handler exists. + * EL is the element's name. + * H is the handler's name. + * IS_WRITE true to check for write handler, otherwise check read handler. + * EXISTS is filled with true if the handler exists, otherwise false. + * Returns: no_err, sys_err, init_err, click_err + */ + err_t check_handler(string el, string h, bool is_write, bool &exists); +protected: + err_t check_handler_workaround(string el, string h, bool is_write, bool &exists); + +public: + /* + * Return the results of reading a handler. + * EL is the element's name. + * HANDLER is the handler name. + * RESPONSE is filled with the handler's output, existing contents are replaced. + * If NAME is not empty, calls``NAME.HANDLER''; otherwise calls ``HANDLER'' + * Returns: no_err, no_element, no_handler, handler_err, handler_no_perm, sys_err, init_err, click_err + */ + err_t read(string el, string handler, string &response); + + /* + * Return the results of reading a handler. + * EL is the element's name. + * HANDLER is the handler name. + * BUF receives the data. + * BUFSZ is the size of BUF, and recieves the actual number of characters placed into BUF. + * If NAME is not empty, calls``NAME.HANDLER''; otherwise calls ``HANDLER'' + * Returns: no_err, no_element, no_handler, handler_err, handler_no_perm, sys_err, init_err, click_err, too_short + * If returns too_short, the operation succeeded, but returned more than BUFSZ characters; the first BUFSZ + * characters of the result are placed into BUF, and BUFSZ is unchanged. + */ + err_t read(string el, string handler, char *buf, int &bufsz); + + /* + * Write data to an element's handler. + * EL is the element's name. + * HANDLER is the handler name. + * DATA contains the data. No terminating '\0' is written. + * If NAME is not empty, calls``NAME.HANDLER''; otherwise calls ``HANDLER'' + * Returns: no_err, no_element, no_handler, handler_err, handler_no_perm, sys_err, init_err, click_err + */ + err_t write(string el, string handler, string data); + + /* + * Write data to an element's handler. + * EL is the element's name. + * HANDLER is the handler name. + * BUF contains the data. + * BUFSZ is the number of characters to be written from BUF. + * If NAME is not empty, calls``NAME.HANDLER''; otherwise calls ``HANDLER'' + * Returns: no_err, no_element, no_handler, handler_err, handler_no_perm, sys_err, init_err, click_err + */ + err_t write(string el, string handler, const char *buf, int bufsz); + + /* + * sugar, for reading and writing handlers. + */ + err_t read(handler_info_t h, string &response) { return read(h.element_name, h.handler_name, response); } + err_t read(handler_info_t h, char *buf, int &bufsz) { return read(h.element_name, h.handler_name, buf, bufsz); } + err_t write(handler_info_t h, string data) { return write(h.element_name, h.handler_name, data); } + err_t write(handler_info_t h, const char *buf, int bufsz) { return write(h.element_name, h.handler_name, buf, bufsz); } + + + ~ControlSocketClient() { if (_init) ::close(_fd); } + +private: + bool _init; + + unsigned int _host; + unsigned short _port; + int _fd; + int _protocol_minor_version; + + string _name; + + enum { + CODE_OK = 200, + CODE_OK_WARN = 220, + CODE_SYNTAX_ERR = 500, + CODE_UNIMPLEMENTED = 501, + CODE_NO_ELEMENT = 510, + CODE_NO_HANDLER = 511, + CODE_HANDLER_ERR = 520, + CODE_PERMISSION = 530, + CODE_NO_ROUTER = 540, + + PROTOCOL_MAJOR_VERSION = 1, + PROTOCOL_MINOR_VERSION = 0 + }; + + /* Try to read a '\n'-terminated line (including the '\n') from the + * socket. */ + err_t readline(string &buf); + + int get_resp_code(string line); + int get_data_len(string line); + err_t handle_err_code(int code); + + err_t get_string_vec(string el, string h, vector &v); + vector split(string s, size_t offset, char terminator); + string trim(string s); +}; + +typedef struct { + std::string xid; + std::string nextHop; + unsigned short port; + unsigned long flags; +} XIARouteEntry; + +class XIARouter { +public: + XIARouter(const char *_rtr = "router0") { _connected = false; + _cserr = ControlSocketClient::no_err; _router = _rtr; }; + ~XIARouter() { if (connected()) close(); }; + + // connect to click + int connect(std::string clickHost = "localhost", unsigned short controlPort = 7777); + int connected() { return _connected; }; + void close(); + + // returns the click version in + int version(std::string &ver); + + // returns the error code from the underlying click control socket interface + ControlSocketClient::err_t ControlSocketError() { return _cserr; }; + + // return a vector of router devices click knows about (host0, router1, ....) + int listRouters(std::vector &rlist); + + // specify which router to operate on, must be called before adding/removing routes + // defaults to router0 + void setRouter(std::string r) { _router = r; }; + std::string getRouter() { return _router; }; + + // get the current set of route entries, return value is number of entries returned or < 0 on err + int getRoutes(std::string xidtype, std::vector &xrt); + + // returns 0 success, < 0 on error + int addRoute(const std::string &xid, int port, const std::string &next, unsigned long flags); + int setRoute(const std::string &xid, int port, const std::string &next, unsigned long flags); + int delRoute(const std::string &xid); + int getNeighbors(std::string xidtype, std::vector &neighbors); + + + const char *cserror(); +private: + bool _connected; + std::string _router; + ControlSocketClient _cs; + ControlSocketClient::err_t _cserr; + + int updateRoute(std::string cmd, const std::string &xid, int port, const std::string &next, unsigned long flags); + string itoa(signed); +}; + +typedef struct { + std::string dest; // destination AD or HID + std::string nextHop; // nexthop HID + int32_t port; // interface (outgoing port) + uint32_t flags; // flag +} RouteEntry; + +typedef struct { + std::string AD; // neigbor AD + std::string HID; // neighbor HID + int32_t cost; // link cost + int32_t port; // interface (outgoing port) +} NeighborEntry; + + +typedef struct { + std::string dest; // destination AD or HID + int32_t num_neighbors; // number of neighbors of dest AD + std::vector neighbor_list; // neighbor AD list + + bool checked; // used for calculating the shortest path + int32_t cost; // cost from myAD to destAD + std::string prevNode; // previous node along the shortest path from myAD to destAD + +} NodeStateEntry; // extracted from incoming LSA + +typedef struct RouteState { + int32_t sock; // socket for routing process + + sockaddr_x sdag; + sockaddr_x ddag; + + char myAD[MAX_XID_SIZE]; // this router AD + char myHID[MAX_XID_SIZE]; // this router HID + char my4ID[MAX_XID_SIZE]; // not used + + uint32_t flags; + std::string dual_router_AD; // AD (with dual router) -- default AD for 4ID traffic + int32_t num_neighbors; // number of neighbor routers + int32_t hello_lsa_ratio; // frequency ratio of hello:lsa (for timer purpose) + int32_t calc_dijstra_ticks; + + std::map ADrouteTable; // map DestAD to route entry + std::map HIDrouteTable; // map DestHID to route entry + + std::map neighborTable; // map neighborAD to neighbor entry + + std::map networkTable; // map DestAD to NodeState entry + +} RouteState; + + + +class XIAOverlayRouted : public Element { + +public: + + XIAOverlayRouted(); + ~XIAOverlayRouted(); + + const char *class_name() const { return "XIAOverlayRouted"; } + const char *port_count() const { return "1/1"; } + const char *processing() const { return PUSH; } + + void push(int, Packet *); + +}; + +CLICK_ENDDECLS +#endif diff --git a/click/elements/xia/xroute.proto b/click/userlevel/xroute.proto similarity index 100% rename from click/elements/xia/xroute.proto rename to click/userlevel/xroute.proto From f14a1fa2b85ef96642760efe50004726567f547d Mon Sep 17 00:00:00 2001 From: mirrorZ Date: Sat, 16 May 2020 23:50:44 -0400 Subject: [PATCH 106/116] Missing Makefile.in --- click/userlevel/Makefile.in | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/click/userlevel/Makefile.in b/click/userlevel/Makefile.in index 49f0771cc..52ebdafdd 100644 --- a/click/userlevel/Makefile.in +++ b/click/userlevel/Makefile.in @@ -72,7 +72,7 @@ GENERIC_OBJS = string.o straccum.o nameinfo.o \ routerthread.o router.o master.o timerset.o selectset.o handlercall.o notifier.o \ integers.o md5.o crc32.o in_cksum.o iptable.o \ archive.o userutils.o driver.o \ - xid.o xidpair.o xidtuple.o xiapath.o xiaheader.o xiautil.o xia.pb.o \ + xid.o xidpair.o xidtuple.o xiapath.o xiaheader.o xiautil.o xia.pb.o xroute.pb.o\ xiasecurity.o \ xiamigrate.o \ xiarendezvous.o \ @@ -141,6 +141,9 @@ all: $(INSTALLPROGS) $(INSTALLLIBS) xia.pb.cc: xia.proto protoc --cpp_out=. xia.proto +xroute.pb.cc: xroute.proto + protoc --cpp_out=. xroute.proto + ifneq ($(MAKECMDGOALS),clean) -include $(ELEMENTSCONF).mk endif @@ -167,6 +170,8 @@ $(ELEMENTSCONF).cc: $(ELEMENTSCONF).conf $(CLICK_BUILDTOOL) $(call verbose_cmd,$(CLICK_BUILDTOOL) elem2export < $(ELEMENTSCONF).conf >,CREATE,$(ELEMENTSCONF).cc) @rm -f $(ELEMENTSCONF).d echo '#include "xia.pb.h"' | cat - $(ELEMENTSCONF).cc > temp && mv temp $(ELEMENTSCONF).cc + echo '#include "xroute.pb.h"' | cat - $(ELEMENTSCONF).cc > temp && mv temp $(ELEMENTSCONF).cc + DEPFILES := $(wildcard *.d) ifneq ($(DEPFILES),) @@ -189,7 +194,7 @@ uninstall: clean: rm -f *.d *.o $(INSTALLPROGS) $(ELEMENTSCONF).mk $(ELEMENTSCONF).cc elements.conf elements.csmk libclick.a - rm -f xia.pb.h xia.pb.cc + rm -f xia.pb.h xia.pb.cc xroute.pb.cc @-for i in $(INSTALLPROGS); do rm -f ../bin/$$i; done clean-lib: rm -f $(LIBOBJS) libclick.a From b67de5ec49ca5525a8cbed329fa5b3128b6ffab6 Mon Sep 17 00:00:00 2001 From: mirrorZ Date: Tue, 19 May 2020 23:32:19 -0400 Subject: [PATCH 107/116] SendHello overlay --- click/elements/xia/xiaoverlayrouted.cc | 39 +++++++++++++++++++++----- tools/overlay/routerclick.py | 8 +++--- 2 files changed, 36 insertions(+), 11 deletions(-) diff --git a/click/elements/xia/xiaoverlayrouted.cc b/click/elements/xia/xiaoverlayrouted.cc index 254fad00b..727958390 100644 --- a/click/elements/xia/xiaoverlayrouted.cc +++ b/click/elements/xia/xiaoverlayrouted.cc @@ -5,6 +5,8 @@ #include #include #include +#include +#include "click/dagaddr.hpp" #include "xiaoverlayrouted.hh" RouteState route_state; @@ -29,6 +31,7 @@ CLICK_DECLS #include #include #include +#include #define INCLUDE_TEST_CODE 0 @@ -762,6 +765,25 @@ const char *XIARouter::cserror() XIAOverlayRouted::XIAOverlayRouted() { + + FILE *f = fopen("etc/resolv.conf", "r"); + if (!f) { + printf("Failed to open resolv.conf \n"); + return; + } + char ad[100], hid[100], re[100]; + fscanf(f,"%s %s %s", re, ad, hid); + fclose(f); + + strcpy(route_state.myAD, ad); + strcpy(route_state.myHID, hid); + + route_state.num_neighbors = 0; // number of neighbor routers + route_state.calc_dijstra_ticks = 0; + + route_state.flags = F_EDGE_ROUTER; + + route_state.dual_router_AD = "NULL"; } XIAOverlayRouted::~XIAOverlayRouted() @@ -786,15 +808,15 @@ std::string sendHello() msg.set_type(Xroute::HELLO_MSG); msg.set_version(Xroute::XROUTE_PROTO_VERSION); hello->set_flags(route_state.flags); - ad ->set_type(n_ad.type()); - ad ->set_id(n_ad.id(), XID_SIZE); + ad->set_type(n_ad.type()); + ad->set_id(n_ad.id(), XID_SIZE); hid->set_type(n_hid.type()); hid->set_id(n_hid.id(), XID_SIZE); sid->set_type(n_sid.type()); sid->set_id(n_sid.id(), XID_SIZE); -// printf("sending %s\n", msg.DebugString().c_str()); + printf("XIAOverlayRouted: %s\n", msg.DebugString().c_str()); // printf("**** sending lsa with and num_neighbors %d \n", route_state.num_neighbors); msg.SerializeToString(&message); @@ -803,7 +825,6 @@ std::string sendHello() void XIAOverlayRouted::push(int port, Packet *p_in) { - printf("In overlay\n"); std::string msg = sendHello(); struct click_ip *ip; @@ -825,8 +846,8 @@ void XIAOverlayRouted::push(int port, Packet *p_in) ip->ip_sum = 0; struct in_addr *saddr = (struct in_addr *)malloc(sizeof(struct in_addr)); struct in_addr *daddr = (struct in_addr *)malloc(sizeof(struct in_addr)); - assert(saddr); - assert(daddr); + // assert(saddr); + // assert(daddr); inet_aton("10.0.1.128", saddr); inet_aton("10.0.1.130", daddr); ip->ip_src = *saddr; @@ -838,11 +859,15 @@ void XIAOverlayRouted::push(int port, Packet *p_in) udp->uh_ulen = htons(msg.length()); q->set_ip_header(ip, ip->ip_hl << 2); + q->set_dst_ip_anno(IPAddress(*daddr)); + SET_DST_PORT_ANNO(q, htons(8772)); + printf("XIAOverlayRouted: Pushing packet \n"); output(0).push(q); } CLICK_ENDDECLS EXPORT_ELEMENT(XIAOverlayRouted) -ELEMENT_MT_SAFE(XIAOverlayRouted) \ No newline at end of file +ELEMENT_MT_SAFE(XIAOverlayRouted) +ELEMENT_LIBS(-lprotobuf -L../../api/lib -ldagaddr) diff --git a/tools/overlay/routerclick.py b/tools/overlay/routerclick.py index 70711855f..0b9b96cfd 100644 --- a/tools/overlay/routerclick.py +++ b/tools/overlay/routerclick.py @@ -43,11 +43,11 @@ def to_string(self): if (index < num_interfaces): (iface_name, ipaddr, macaddr) = self.interfaces[index] rstr += '\nosock{}::XIAOverlaySocket("UDP", {}, {}, SNAPLEN 65536) -> [{}]{}[{}] -> osock{};\n'.format(index, ipaddr, 8770, index, self.name, index, index) - rstr += '\nrsock{}::XIAOverlaySocket("UDP", {}, {}, SNAPLEN 65536) -> rd{}::XIAOverlayRouted() -> Discard;\n'.format(index, ipaddr, 8772, index) - + rstr += '\nrsock{}::XIAOverlaySocket("UDP", {}, {}, SNAPLEN 65536) -> rd{}::XIAOverlayRouted() -> of{}::XIAOverlayFilter() -> rsock{};\n'.format(index, ipaddr, 8772, index, index, index) + rstr += '\nof{}[{}] -> [{}]of{};\n'.format(index, 1, 1 , index) + rstr += '\nof{}[{}] -> Discard; \n of{}[{}] -> Discard; \n'.format(index, 2, index, 3) else: - rstr += '\nIdle -> [{}]{}[{}] -> Discard;\n'.format( - index, self.name, index) + rstr += '\nIdle -> [{}]{}[{}] -> Discard;\n'.format(index, self.name, index) #(iface_name, ipaddr, macaddr) = self.interfaces[0] #rstr += '\nSocket("UDP", {}, 8769, SNAPLEN 65536) -> [4]{}\n'.format( From 411cc9855f214d5447cbd2409d7930311d8cf898 Mon Sep 17 00:00:00 2001 From: mirrorZ Date: Fri, 22 May 2020 20:21:53 -0400 Subject: [PATCH 108/116] sending and receiving hello msg --- click/elements/xia/xiaoverlayrouted.cc | 142 +++++++++++++++++++++++-- click/elements/xia/xiaoverlaysocket.cc | 65 ++++++----- 2 files changed, 164 insertions(+), 43 deletions(-) diff --git a/click/elements/xia/xiaoverlayrouted.cc b/click/elements/xia/xiaoverlayrouted.cc index 727958390..7e7fee96a 100644 --- a/click/elements/xia/xiaoverlayrouted.cc +++ b/click/elements/xia/xiaoverlayrouted.cc @@ -816,25 +816,144 @@ std::string sendHello() sid->set_id(n_sid.id(), XID_SIZE); - printf("XIAOverlayRouted: %s\n", msg.DebugString().c_str()); + // printf("XIAOverlayRouted: %s\n", msg.DebugString().c_str()); // printf("**** sending lsa with and num_neighbors %d \n", route_state.num_neighbors); msg.SerializeToString(&message); return message; } +// process an incoming Hello message +int processHello(const Xroute::HelloMsg &msg, int interface) +{ + string neighborAD, neighborHID, myAD; + uint32_t flags = 0; + + Xroute::XID xad = msg.node().ad(); + Xroute::XID xhid = msg.node().hid(); + + Node ad(xad.type(), xad.id().c_str(), 0); + Node hid(xhid.type(), xhid.id().c_str(), 0); + + neighborAD = ad. to_string(); + neighborHID = hid.to_string(); + + if (msg.has_flags()) { + flags = msg.flags(); + } + + /* Procedure: + 1. fill in the neighbor table + 2. update my entry in the networkTable + */ + // 1. fill in the neighbor table + + // fill in the table + map::iterator it; + it=route_state.neighborTable.find(neighborAD); + if(it == route_state.neighborTable.end()) { + // if no entry yet + NeighborEntry entry; + entry.AD = neighborAD; + entry.HID = neighborHID; + entry.cost = 1; // for now, same cost + + entry.port = interface; + + route_state.neighborTable[neighborAD] = entry; + + // increase the neighbor count + route_state.num_neighbors++; + + // FIXME: HACK until we get new routing daemon implemented + // we haven't seen this AD before, so just go ahead and add a route for it's HID + // the AD route will be set later when tables are processed + xr.setRoute(neighborHID, interface, neighborHID, flags); + } + + // 2. update my entry in the networkTable + myAD = route_state.myAD; + + map::iterator it2; + it2=route_state.networkTable.find(myAD); + + if(it2 != route_state.networkTable.end()) { + + // For now, delete my entry in networkTable (... we will re-insert the updated entry shortly) + route_state.networkTable.erase (it2); + } + + NodeStateEntry entry; + entry.dest = myAD; + entry.num_neighbors = route_state.num_neighbors; + + map::iterator it3; + for ( it3=route_state.neighborTable.begin() ; it3 != route_state.neighborTable.end(); it3++ ) { + + // fill my neighbors into my entry in the networkTable + entry.neighbor_list.push_back(it3->second.AD); + } + + route_state.networkTable[myAD] = entry; + + return 1; +} + void XIAOverlayRouted::push(int port, Packet *p_in) { - std::string msg = sendHello(); + struct click_ip *ip; + struct click_udp *udp; + - struct click_ip *ip; - struct click_udp *udp; - WritablePacket *q = Packet::make(sizeof(*ip) + sizeof(*udp) + msg.length()); - memset(q->data(), '\0', q->length()); - ip = (struct click_ip *) q->data(); - udp = (struct click_udp *) (ip + 1); - memcpy(q + sizeof(*ip) + sizeof(*udp), msg.c_str(), msg.length()); + size_t a = sizeof(*ip) + sizeof(*udp); + Xroute::XrouteMsg xmsg; + if(p_in->length() == 116) { + + ip = (struct click_ip *) p_in->data(); + udp = (struct click_udp *) (ip + 1); + // printf("Adding %ld\n dst port: %d", a, ntohs(udp->uh_dport)); + size_t mlen = p_in->length()-a; + string cs(((const char *)(udp + 1)), mlen); + // write(1, cs.c_str(), mlen); + // std::string s (((const char *)p_in->data()+ a), p_in->length()-a); + // printf("Data: %s Got: %s size : %d\n", p_in->data() + 28, s.c_str(), s.length()); + + if(!xmsg.ParseFromString(cs)) { + printf("XIAOverlayRouted : could not understand packet\n"); + // printf("Got: %s size : %d\n", s.c_str(), s.length()); + } + } + std::string msg = sendHello(); + // if(!xmsg.ParseFromString(msg)) { + // printf("Made not fine \n"); + // } + // else { + // printf("Made all fine \n"); + // } + + size_t qsize = sizeof(*ip) + sizeof(*udp) + msg.length(); + WritablePacket *q = Packet::make(qsize); + memset(q->data(), '0', q->length()); + ip = (struct click_ip *) q->data(); + udp = (struct click_udp *) (ip + 1); + char *data = (char *)(udp+1); + // printf("Ptrs : %u %u %u\n", ip, udp, data); + // printf("Before (%d) : \n", q->length()); + // write(1, q->data(), q->length()); + memcpy(data, msg.c_str(), msg.length()); + // printf("\n\nAfter (%d) : \n", q->length()); + // write(1, q->data(), q->length()); + // printf("\n"); + + + // string cs(((const char *)(udp + 1)), msg.length()); + // if(!xmsg.ParseFromString(cs)) { + // printf("right here\n"); + // } + // else { + // printf("Somewhere else\n"); + // } ip->ip_v = 4; ip->ip_hl = 5; ip->ip_tos = 0x10; @@ -862,7 +981,10 @@ void XIAOverlayRouted::push(int port, Packet *p_in) q->set_dst_ip_anno(IPAddress(*daddr)); SET_DST_PORT_ANNO(q, htons(8772)); - printf("XIAOverlayRouted: Pushing packet \n"); + printf("XIAOverlayRouted: Pushing packet len %d: %d + %d + %d\n", q->length(), sizeof(*ip), sizeof(*udp), msg.length()); + // printf("Pushing data : "); + // write(1, q->data(), q->length()); + // printf("\n"); output(0).push(q); } diff --git a/click/elements/xia/xiaoverlaysocket.cc b/click/elements/xia/xiaoverlaysocket.cc index fe9c5b71f..dc16632a5 100644 --- a/click/elements/xia/xiaoverlaysocket.cc +++ b/click/elements/xia/xiaoverlaysocket.cc @@ -125,12 +125,10 @@ XIAOverlaySocket::selected(int fd, int) int XIAOverlaySocket::write_packet(Packet *p) { - int len; - - - assert(_active >= 0); + int len; + assert(_active >= 0); - while (p->length()) { + while (p->length()) { struct sockaddr_in dest; dest.sin_family = AF_INET; dest.sin_port = DST_PORT_ANNO(p); @@ -146,35 +144,36 @@ XIAOverlaySocket::write_packet(Packet *p) printf("XIAOverlaySocket: ERROR xia hdr != p->data\n"); } - if (_socktype != SOCK_DGRAM) { - click_chatter("XIAOverlaySocket: ERROR: not datagram socket"); - p->kill(); - return -1; - } - len = sendto(_active, p->data(), p->length(), 0, - (struct sockaddr *)&dest, sizeof(dest)); - // error - if (len < 0) { - // out of memory or would block - if (errno == ENOBUFS || errno == EAGAIN) { - return -1; - } else if (errno == EINTR) { - continue; - } else { - if(_verbose) { - click_chatter("%s: %s", declaration().c_str(), - strerror(errno)); - } - close_active(); - break; - } - } else { - // this segment OK - p->pull(len); - } + if (_socktype != SOCK_DGRAM) { + click_chatter("XIAOverlaySocket: ERROR: not datagram socket"); + p->kill(); + return -1; } - p->kill(); - return 0; + printf("Sending len %d\n", p->length()); + len = sendto(_active, p->data(), p->length(), 0, + (struct sockaddr *)&dest, sizeof(dest)); + // error + if (len < 0) { + // out of memory or would block + if (errno == ENOBUFS || errno == EAGAIN) { + return -1; + } else if (errno == EINTR) { + continue; + } else { + if(_verbose) { + click_chatter("%s: %s", declaration().c_str(), + strerror(errno)); + } + close_active(); + break; + } + } else { + // this segment OK + p->pull(len); + } + } + p->kill(); + return 0; } void From 9a4c5490d80781c922227dbfb2f67a311695254b Mon Sep 17 00:00:00 2001 From: mirrorZ Date: Sun, 24 May 2020 04:49:00 -0400 Subject: [PATCH 109/116] send router sid from configurator --- click/elements/xia/xiaoverlayrouted.cc | 124 +++---------------------- click/elements/xia/xiaxidroutetable.hh | 32 +++---- tools/overlay/xiaconfigreader.py | 7 +- tools/overlay/xiaconfigurator.py | 9 ++ 4 files changed, 46 insertions(+), 126 deletions(-) diff --git a/click/elements/xia/xiaoverlayrouted.cc b/click/elements/xia/xiaoverlayrouted.cc index 7e7fee96a..6f3538cd4 100644 --- a/click/elements/xia/xiaoverlayrouted.cc +++ b/click/elements/xia/xiaoverlayrouted.cc @@ -823,82 +823,6 @@ std::string sendHello() return message; } -// process an incoming Hello message -int processHello(const Xroute::HelloMsg &msg, int interface) -{ - string neighborAD, neighborHID, myAD; - uint32_t flags = 0; - - Xroute::XID xad = msg.node().ad(); - Xroute::XID xhid = msg.node().hid(); - - Node ad(xad.type(), xad.id().c_str(), 0); - Node hid(xhid.type(), xhid.id().c_str(), 0); - - neighborAD = ad. to_string(); - neighborHID = hid.to_string(); - - if (msg.has_flags()) { - flags = msg.flags(); - } - - /* Procedure: - 1. fill in the neighbor table - 2. update my entry in the networkTable - */ - // 1. fill in the neighbor table - - // fill in the table - map::iterator it; - it=route_state.neighborTable.find(neighborAD); - if(it == route_state.neighborTable.end()) { - // if no entry yet - NeighborEntry entry; - entry.AD = neighborAD; - entry.HID = neighborHID; - entry.cost = 1; // for now, same cost - - entry.port = interface; - - route_state.neighborTable[neighborAD] = entry; - - // increase the neighbor count - route_state.num_neighbors++; - - // FIXME: HACK until we get new routing daemon implemented - // we haven't seen this AD before, so just go ahead and add a route for it's HID - // the AD route will be set later when tables are processed - xr.setRoute(neighborHID, interface, neighborHID, flags); - } - - // 2. update my entry in the networkTable - myAD = route_state.myAD; - - map::iterator it2; - it2=route_state.networkTable.find(myAD); - - if(it2 != route_state.networkTable.end()) { - - // For now, delete my entry in networkTable (... we will re-insert the updated entry shortly) - route_state.networkTable.erase (it2); - } - - NodeStateEntry entry; - entry.dest = myAD; - entry.num_neighbors = route_state.num_neighbors; - - map::iterator it3; - for ( it3=route_state.neighborTable.begin() ; it3 != route_state.neighborTable.end(); it3++ ) { - - // fill my neighbors into my entry in the networkTable - entry.neighbor_list.push_back(it3->second.AD); - } - - route_state.networkTable[myAD] = entry; - - return 1; -} - void XIAOverlayRouted::push(int port, Packet *p_in) { struct click_ip *ip; @@ -907,30 +831,29 @@ void XIAOverlayRouted::push(int port, Packet *p_in) size_t a = sizeof(*ip) + sizeof(*udp); Xroute::XrouteMsg xmsg; - if(p_in->length() == 116) { + if(p_in->length() > a) { ip = (struct click_ip *) p_in->data(); udp = (struct click_udp *) (ip + 1); - // printf("Adding %ld\n dst port: %d", a, ntohs(udp->uh_dport)); size_t mlen = p_in->length()-a; string cs(((const char *)(udp + 1)), mlen); - // write(1, cs.c_str(), mlen); - // std::string s (((const char *)p_in->data()+ a), p_in->length()-a); - // printf("Data: %s Got: %s size : %d\n", p_in->data() + 28, s.c_str(), s.length()); - if(!xmsg.ParseFromString(cs)) { printf("XIAOverlayRouted : could not understand packet\n"); - // printf("Got: %s size : %d\n", s.c_str(), s.length()); + } + else { + if(xmsg.type() == Xroute::HELLO_MSG) { + printf("Received hello message from %s\n",inet_ntoa(ip->ip_src)); + } + else if(xmsg.type() == Xroute::LSA_MSG) { + ; + } + else { + printf("Unknown msg type \n"); + } } } std::string msg = sendHello(); - // if(!xmsg.ParseFromString(msg)) { - // printf("Made not fine \n"); - // } - // else { - // printf("Made all fine \n"); - // } size_t qsize = sizeof(*ip) + sizeof(*udp) + msg.length(); WritablePacket *q = Packet::make(qsize); @@ -938,22 +861,8 @@ void XIAOverlayRouted::push(int port, Packet *p_in) ip = (struct click_ip *) q->data(); udp = (struct click_udp *) (ip + 1); char *data = (char *)(udp+1); - // printf("Ptrs : %u %u %u\n", ip, udp, data); - // printf("Before (%d) : \n", q->length()); - // write(1, q->data(), q->length()); memcpy(data, msg.c_str(), msg.length()); - // printf("\n\nAfter (%d) : \n", q->length()); - // write(1, q->data(), q->length()); - // printf("\n"); - - - // string cs(((const char *)(udp + 1)), msg.length()); - // if(!xmsg.ParseFromString(cs)) { - // printf("right here\n"); - // } - // else { - // printf("Somewhere else\n"); - // } + ip->ip_v = 4; ip->ip_hl = 5; ip->ip_tos = 0x10; @@ -965,8 +874,8 @@ void XIAOverlayRouted::push(int port, Packet *p_in) ip->ip_sum = 0; struct in_addr *saddr = (struct in_addr *)malloc(sizeof(struct in_addr)); struct in_addr *daddr = (struct in_addr *)malloc(sizeof(struct in_addr)); - // assert(saddr); - // assert(daddr); + assert(saddr); + assert(daddr); inet_aton("10.0.1.128", saddr); inet_aton("10.0.1.130", daddr); ip->ip_src = *saddr; @@ -982,9 +891,6 @@ void XIAOverlayRouted::push(int port, Packet *p_in) SET_DST_PORT_ANNO(q, htons(8772)); printf("XIAOverlayRouted: Pushing packet len %d: %d + %d + %d\n", q->length(), sizeof(*ip), sizeof(*udp), msg.length()); - // printf("Pushing data : "); - // write(1, q->data(), q->length()); - // printf("\n"); output(0).push(q); } diff --git a/click/elements/xia/xiaxidroutetable.hh b/click/elements/xia/xiaxidroutetable.hh index 1205d47be..dbe67b12a 100644 --- a/click/elements/xia/xiaxidroutetable.hh +++ b/click/elements/xia/xiaxidroutetable.hh @@ -47,10 +47,10 @@ so use the XIACheckDest element before using this element. enum { PRINCIPAL_TYPE_ENABLED, ROUTE_TABLE_HID, FWD_TABLE_DAG, XCACHE_SID }; typedef struct { - int port; - unsigned flags; - XID *nexthop; - std::unique_ptr nexthop_in; + int port; + unsigned flags; + XID *nexthop; + std::unique_ptr nexthop_in; } XIARouteData; typedef struct { @@ -67,17 +67,17 @@ class XIAXIDRouteTable : public Element { public: XIAXIDRouteTable(); ~XIAXIDRouteTable(); - const char *class_name() const { return "XIAXIDRouteTable"; } - const char *port_count() const { return "-/-"; } - const char *processing() const { return PUSH; } + const char *class_name() const { return "XIAXIDRouteTable"; } + const char *port_count() const { return "-/-"; } + const char *processing() const { return PUSH; } int configure(Vector &, ErrorHandler *); void add_handlers(); void push(int in_ether_port, Packet *); - int set_enabled(int e); - int get_enabled(); + int set_enabled(int e); + int get_enabled(); protected: int lookup_route(Packet *); @@ -85,23 +85,23 @@ protected: static int set_handler(const String &conf, Element *e, void *thunk, ErrorHandler *errh); static int set_handler4(const String &conf, Element *e, void *thunk, ErrorHandler *errh); - static int set_udpnext(const String &conf, Element *e, void *thunk, ErrorHandler *errh); + static int set_udpnext(const String &conf, Element *e, void *thunk, ErrorHandler *errh); static int remove_handler(const String &conf, Element *e, void *, ErrorHandler *errh); static int load_routes_handler(const String &conf, Element *e, void *, ErrorHandler *errh); static int generate_routes_handler(const String &conf, Element *e, void *, ErrorHandler *errh); - static String read_handler(Element *e, void *thunk); - static int write_handler(const String &str, Element *e, void *thunk, ErrorHandler *errh); + static String read_handler(Element *e, void *thunk); + static int write_handler(const String &str, Element *e, void *thunk, ErrorHandler *errh); - static void add_entry_to_tbl_str(Element *e, String& tbl, String xid, XIARouteData* xrd); + static void add_entry_to_tbl_str(Element *e, String& tbl, String xid, XIARouteData* xrd); static String list_routes_handler(Element *e, void *thunk); static String list_neighbor_handler(Element *e, void *); - HashTable _rts; - XIARouteData _rtdata; + HashTable _rts; + XIARouteData _rtdata; uint32_t _drops; XIAXIDNeighborTable _ntable; - int _principal_type_enabled; + int _principal_type_enabled; }; CLICK_ENDDECLS diff --git a/tools/overlay/xiaconfigreader.py b/tools/overlay/xiaconfigreader.py index 190ec9924..ca560d53b 100644 --- a/tools/overlay/xiaconfigreader.py +++ b/tools/overlay/xiaconfigreader.py @@ -1,4 +1,5 @@ from ConfigParser import RawConfigParser +import genkeys class XIAConfigReader: def __init__(self, config_filename): @@ -9,7 +10,8 @@ def __init__(self, config_filename): self.route_info = {} # router: (dest,our_iface,their_iface,their_name) self.xcache = {} # router: runs_xcache self.nameserver = "" - + self.sid = {} # router : routing sid + # Read in the config file parser = RawConfigParser() parser.read(config_filename) @@ -31,6 +33,9 @@ def __init__(self, config_filename): # IP Address of host iface self.host_ipaddrs[router] = parser.get(router, 'HostAddr') + # Routing SID + self.sid[router] = genkeys.create_new_SID() + # Check if this is a nameserver try: if parser.getboolean(router, "NameServer"): diff --git a/tools/overlay/xiaconfigurator.py b/tools/overlay/xiaconfigurator.py index e7a523419..92558d193 100644 --- a/tools/overlay/xiaconfigurator.py +++ b/tools/overlay/xiaconfigurator.py @@ -19,6 +19,7 @@ # Bring in xia and overlay tools into path srcdir = os.getcwd()[:os.getcwd().rindex('xia-core')+len('xia-core')] + sys.path.append(os.path.join(srcdir, 'bin')) sys.path.append(os.path.join(srcdir, 'tools/overlay')) @@ -169,6 +170,8 @@ def sendIPRoutesRequest(self): # Destination router, our interface, nexthop iface, nexthop name dest, our_iface, next_iface, next_name = route + print("Adding route : ") + print(route) # Convert dest router name to corresponding AD dest_ad, dest_hid = self.configurator.xids[dest] @@ -185,6 +188,11 @@ def sendIPRoutesRequest(self): route = "./bin/xroute -a AD,{},{},{}:{}".format( dest_ad, port, ipaddr, next_port) request.routes.route_cmds.append(route) + dest_sid = self.configurator.config.sid[dest] + sid_route = "./bin/xroute -a SID,{},{},{}:{},{}".format( + dest_sid, port, ipaddr, 8772, 7) + print("Sending %s" %sid_route) + request.routes.route_cmds.append(sid_route) self.sendString(request.SerializeToString()) def handleIPRoutesResponse(self, response): @@ -241,6 +249,7 @@ def __init__(self, config): self.iface_addrs = {} # (router, iface_name) : ipaddr self.connected_clients = [] + print self.nameserver, 'is the nameserver' print 'Here are the routers we know of' for router in self.config.routers(): From a82f995dd5329ba37e4f9a5ce5c837780dc2e76c Mon Sep 17 00:00:00 2001 From: mirrorZ Date: Tue, 26 May 2020 00:55:12 -0400 Subject: [PATCH 110/116] Read from xid table --- bin/xroute | 2 +- click/elements/xia/xiaoverlayrouted.cc | 90 ++++++++++++++++++++++---- click/elements/xia/xiaoverlayrouted.hh | 6 ++ click/elements/xia/xiaxidroutetable.cc | 38 +++++++---- click/elements/xia/xiaxidroutetable.hh | 5 +- 5 files changed, 113 insertions(+), 28 deletions(-) diff --git a/bin/xroute b/bin/xroute index 09227d28e..049bbcf39 100755 --- a/bin/xroute +++ b/bin/xroute @@ -567,7 +567,7 @@ class XrouteApp: self.errorExit("port not specified") cmd = "%s/xrc/n/proc/rt_%s.set4 %s,%s,%s,%s" % (self.device, table, xid, port, nexthop, flags) - print cmd + print("Writing %s" %cmd) self.writeData(cmd) print "added route for %s:%s" % (table, self.config.getAlias(xid)) diff --git a/click/elements/xia/xiaoverlayrouted.cc b/click/elements/xia/xiaoverlayrouted.cc index 6f3538cd4..407dbd18c 100644 --- a/click/elements/xia/xiaoverlayrouted.cc +++ b/click/elements/xia/xiaoverlayrouted.cc @@ -8,9 +8,10 @@ #include #include "click/dagaddr.hpp" #include "xiaoverlayrouted.hh" +#include +#include +#include -RouteState route_state; -XIARouter xr; #define XID_SIZE CLICK_XIA_XID_ID_LEN @@ -42,15 +43,19 @@ ControlSocketClient::err_t ControlSocketClient::configure(unsigned int host_ip, unsigned short port) { - if (_init) + if (_init) { + printf("reinit_err\n"); return reinit_err; + } _host = host_ip; _port = port; _fd = socket(PF_INET, SOCK_STREAM, 0); - if (_fd < 0) + if (_fd < 0) { + printf("socker err \n"); return sys_err; + } /* * connect to remote ControlSocket @@ -75,6 +80,7 @@ ControlSocketClient::configure(unsigned int host_ip, unsigned short port) int save_errno = errno; ::close(_fd); errno = save_errno; + printf("connect err\n"); return sys_err; } @@ -90,6 +96,7 @@ ControlSocketClient::configure(unsigned int host_ip, unsigned short port) int save_errno = errno; ::close(_fd); errno = save_errno; + printf("readline err \n"); return err; } @@ -97,6 +104,7 @@ ControlSocketClient::configure(unsigned int host_ip, unsigned short port) dot = (slash != string::npos ? buf.find('.', slash + 1) : string::npos); if (slash == string::npos || dot == string::npos) { ::close(_fd); + printf("click err \n"); return click_err; /* bad format */ } @@ -108,6 +116,7 @@ ControlSocketClient::configure(unsigned int host_ip, unsigned short port) if (major != PROTOCOL_MAJOR_VERSION || minor < PROTOCOL_MINOR_VERSION) { ::close(_fd); + printf("version err \n"); return click_err; /* wrong version */ } @@ -521,13 +530,16 @@ int XIARouter::connect(std::string clickHost, unsigned short controlPort) if (_connected) return XR_ALREADY_CONNECTED; - if ((h = gethostbyname(clickHost.c_str())) == NULL) + if ((h = gethostbyname(clickHost.c_str())) == NULL) { return XR_BAD_HOSTNAME; + } unsigned addr = *(unsigned*)h->h_addr; - if ((_cserr = _cs.configure(addr, controlPort)) != 0) + if ((_cserr = _cs.configure(addr, controlPort)) != 0) { + printf("\nXIAROUTER: XR_NOT_CONNECTED\n"); return XR_NOT_CONNECTED; + } _connected = true; return XR_OK; @@ -574,27 +586,73 @@ int XIARouter::listRouters(std::vector &rlist) int XIARouter::getNeighbors(std::string xidtype, std::vector &neighbors) { - if (!connected()) + printf("In getNeighbors\n"); + if (!connected()) { + printf("Not connected \n"); return XR_NOT_CONNECTED; + } std::string table = _router + "/xrc/n/proc/rt_" + xidtype; std::string neighborStr; - if ((_cserr = _cs.read(table, "neighbor", neighborStr)) != 0) + if ((_cserr = _cs.read(table, "neighbor", neighborStr)) != 0) { + printf("couldn't read\n"); return XR_CLICK_ERROR; + } std::string::size_type beg = 0; for (auto end = 0; (end = neighborStr.find(',', end)) != std::string::npos; ++end) { + printf("Pushing \n"); neighbors.push_back(neighborStr.substr(beg, end - beg)); beg = end + 1; } - printf("Retuning neighbors\n"); + printf("\n\n ------- Returning \n"); + for(int i=0; i &neighbors) +{ + + // Vectore = router()->elements(); + // for(int i=0; iname().c_str()); + // } + + String name = _hostname + String("/xrc/n/proc/rt_SID"); + Element *e = router()->find(name); + if(e) { + printf("found element\n"); + String result = HandlerCall::call_read(e, "neighbor"); + printf("Returned from read %s\n", result.c_str()); + std::string neighborStr(result.c_str (), result.length()); + + std::string::size_type beg = 0; + for (auto end = 0; (end = neighborStr.find(',', end)) != std::string::npos; ++end) + { + printf("Pushing \n %s", neighborStr.substr(beg, end - beg).c_str()); + neighbors.push_back(neighborStr.substr(beg, end - beg)); + beg = end + 1; + } + + for(int i=0; i &xrt) { @@ -784,13 +842,18 @@ XIAOverlayRouted::XIAOverlayRouted() route_state.flags = F_EDGE_ROUTER; route_state.dual_router_AD = "NULL"; + char *hostname = (char *)malloc(32); + assert(hostname); + gethostname(hostname, 32); + _hostname = String(hostname, strlen(hostname)); } XIAOverlayRouted::~XIAOverlayRouted() { } -std::string sendHello() +std::string +XIAOverlayRouted::sendHello() { int buflen, rc; string message; @@ -828,7 +891,6 @@ void XIAOverlayRouted::push(int port, Packet *p_in) struct click_ip *ip; struct click_udp *udp; - size_t a = sizeof(*ip) + sizeof(*udp); Xroute::XrouteMsg xmsg; if(p_in->length() > a) { @@ -855,6 +917,10 @@ void XIAOverlayRouted::push(int port, Packet *p_in) std::string msg = sendHello(); + std::vector n; + getNeighbors(n); + printf("\n**********************\n"); + size_t qsize = sizeof(*ip) + sizeof(*udp) + msg.length(); WritablePacket *q = Packet::make(qsize); memset(q->data(), '0', q->length()); @@ -877,7 +943,7 @@ void XIAOverlayRouted::push(int port, Packet *p_in) assert(saddr); assert(daddr); inet_aton("10.0.1.128", saddr); - inet_aton("10.0.1.130", daddr); + inet_aton("10.0.1.131", daddr); ip->ip_src = *saddr; ip->ip_dst = *daddr; diff --git a/click/elements/xia/xiaoverlayrouted.hh b/click/elements/xia/xiaoverlayrouted.hh index 6256781e5..fed137dc2 100644 --- a/click/elements/xia/xiaoverlayrouted.hh +++ b/click/elements/xia/xiaoverlayrouted.hh @@ -393,6 +393,10 @@ typedef struct RouteState { class XIAOverlayRouted : public Element { + RouteState route_state; + XIARouter xr; + String _hostname; + public: XIAOverlayRouted(); @@ -403,6 +407,8 @@ public: const char *processing() const { return PUSH; } void push(int, Packet *); + std::string sendHello(); + int getNeighbors(std::vector &neighbors); }; diff --git a/click/elements/xia/xiaxidroutetable.cc b/click/elements/xia/xiaxidroutetable.cc index e2dd576e5..437240133 100644 --- a/click/elements/xia/xiaxidroutetable.cc +++ b/click/elements/xia/xiaxidroutetable.cc @@ -117,21 +117,12 @@ XIAXIDRouteTable::add_entry_to_tbl_str(Element *e, String& tbl, String xid, } else { tbl += String("") + ","; } - if(xrd->flags == NEIGHBOR) - { - XIAXIDNeighbor neighbor; - XIAXIDRouteTable* table = static_cast(e); - neighbor.addr = String(inet_ntoa(xrd->nexthop_in->sin_addr)) + - ":" + String(ntohs(xrd->nexthop_in->sin_port)); - table->_ntable.neighbors[table->_ntable.count] = neighbor; - table->_ntable.count += 1; - } // flags tbl += String(xrd->flags) + "\n"; } String -XIAXIDRouteTable::list_routes_handler(Element *e, void * /*thunk */) +XIAXIDRouteTable::list_routes_handler(Element *e, void *thunk) { // printf("******called %s \n", __FUNCTION__); XIAXIDRouteTable* table = static_cast(e); @@ -153,11 +144,12 @@ XIAXIDRouteTable::list_routes_handler(Element *e, void * /*thunk */) String XIAXIDRouteTable::list_neighbor_handler(Element *e, void *) { + XIAXIDRouteTable* table = static_cast(e); String ntable; for(int i=0; i_ntable.count; i++) { - String n = table->_ntable.neighbors[i].addr + ","; + String n = table->_ntable.neighbors[i]->addr + ","; ntable += n; } return ntable; @@ -293,8 +285,26 @@ XIAXIDRouteTable::set_udpnext(const String &conf, Element *e, void *thunk, Error } String ipaddrstr = nxthop.substring(0, separator_offset); String portstr = nxthop.substring(separator_offset+1); - printf("XIAXIDRouteTable: ip: %s, port: %s\n", - ipaddrstr.c_str(), portstr.c_str()); + + + if(args.size() > 3) { + int flags; + XIARouteData *xrd = &table->_rtdata; + if (!cp_integer(args[3], &flags)) + return errh->error("invalid flags: ", conf.c_str()); + + if(flags == NEIGHBOR) + { + XIAXIDNeighbor *neighbor = (XIAXIDNeighbor *)malloc(sizeof(XIAXIDNeighbor)); + String s = ipaddrstr + ":" + portstr; + neighbor->addr.append(s.c_str(), s.length()); + printf("XIAXIDRouteTable: Adding neighbor %s\n", neighbor->addr.c_str()); + table->_ntable.neighbors[table->_ntable.count] = neighbor; + table->_ntable.count += 1; + printf("XIAXIDRouteTable: neighbor count %d \n", table->_ntable.count); + } + } + struct in_addr ipaddr; if(inet_aton(ipaddrstr.c_str(), &ipaddr) == 0) { return errh->error("Invalid ipaddr: ", ipaddrstr.c_str()); @@ -338,6 +348,8 @@ XIAXIDRouteTable::set_udpnext(const String &conf, Element *e, void *thunk, Error xrd->nexthop_in = std::move(addr); table->_rts[xid] = xrd; } + + return 0; } diff --git a/click/elements/xia/xiaxidroutetable.hh b/click/elements/xia/xiaxidroutetable.hh index dbe67b12a..e5f10d595 100644 --- a/click/elements/xia/xiaxidroutetable.hh +++ b/click/elements/xia/xiaxidroutetable.hh @@ -38,7 +38,8 @@ so use the XIACheckDest element before using this element. #define REDIRECT -5 #define UNREACHABLE -6 #define FALLBACK -7 -#define NEIGHBOR 7 +#define NEIGHBOR 263 +//7 #define XIA_UDP_NEXTHOP 5 @@ -59,7 +60,7 @@ typedef struct { typedef struct { int count; - XIAXIDNeighbor neighbors[MAX_NEIGHBOR_CNT]; + XIAXIDNeighbor *neighbors[MAX_NEIGHBOR_CNT]; } XIAXIDNeighborTable; class XIAXIDRouteTable : public Element { public: From 0b458c449878b4b5f6866054d34d88eb3e1ffcba Mon Sep 17 00:00:00 2001 From: mirrorZ Date: Wed, 27 May 2020 21:45:02 -0400 Subject: [PATCH 111/116] hello back and forth --- click/elements/xia/xiaoverlayrouted.cc | 101 ++++++++++++------------- click/elements/xia/xiaoverlayrouted.hh | 2 +- click/elements/xia/xiaxidroutetable.cc | 32 +++++--- click/elements/xia/xiaxidroutetable.hh | 10 +-- tools/overlay/routerclick.py | 28 ++++++- 5 files changed, 97 insertions(+), 76 deletions(-) diff --git a/click/elements/xia/xiaoverlayrouted.cc b/click/elements/xia/xiaoverlayrouted.cc index 407dbd18c..a4d4ac1fc 100644 --- a/click/elements/xia/xiaoverlayrouted.cc +++ b/click/elements/xia/xiaoverlayrouted.cc @@ -586,9 +586,7 @@ int XIARouter::listRouters(std::vector &rlist) int XIARouter::getNeighbors(std::string xidtype, std::vector &neighbors) { - printf("In getNeighbors\n"); if (!connected()) { - printf("Not connected \n"); return XR_NOT_CONNECTED; } @@ -603,14 +601,9 @@ int XIARouter::getNeighbors(std::string xidtype, std::vector &neigh std::string::size_type beg = 0; for (auto end = 0; (end = neighborStr.find(',', end)) != std::string::npos; ++end) { - printf("Pushing \n"); neighbors.push_back(neighborStr.substr(beg, end - beg)); beg = end + 1; } - - printf("\n\n ------- Returning \n"); - for(int i=0; i &neighbors) { - // Vectore = router()->elements(); - // for(int i=0; iname().c_str()); - // } String name = _hostname + String("/xrc/n/proc/rt_SID"); Element *e = router()->find(name); if(e) { - printf("found element\n"); String result = HandlerCall::call_read(e, "neighbor"); - printf("Returned from read %s\n", result.c_str()); std::string neighborStr(result.c_str (), result.length()); std::string::size_type beg = 0; + printf("iterating over neighbors\n"); for (auto end = 0; (end = neighborStr.find(',', end)) != std::string::npos; ++end) { - printf("Pushing \n %s", neighborStr.substr(beg, end - beg).c_str()); neighbors.push_back(neighborStr.substr(beg, end - beg)); beg = end + 1; } - for(int i=0; ilength()); Xroute::XrouteMsg xmsg; if(p_in->length() > a) { @@ -917,47 +901,60 @@ void XIAOverlayRouted::push(int port, Packet *p_in) std::string msg = sendHello(); - std::vector n; - getNeighbors(n); - printf("\n**********************\n"); size_t qsize = sizeof(*ip) + sizeof(*udp) + msg.length(); WritablePacket *q = Packet::make(qsize); memset(q->data(), '0', q->length()); - ip = (struct click_ip *) q->data(); + ip = (struct click_ip *) q->data(); udp = (struct click_udp *) (ip + 1); char *data = (char *)(udp+1); memcpy(data, msg.c_str(), msg.length()); - ip->ip_v = 4; - ip->ip_hl = 5; - ip->ip_tos = 0x10; - ip->ip_len = htons(q->length()); - ip->ip_id = htons(0); // what is this used for exactly? - ip->ip_off = htons(IP_DF); - ip->ip_ttl = 255; - ip->ip_p = IP_PROTO_UDP; - ip->ip_sum = 0; - struct in_addr *saddr = (struct in_addr *)malloc(sizeof(struct in_addr)); - struct in_addr *daddr = (struct in_addr *)malloc(sizeof(struct in_addr)); - assert(saddr); - assert(daddr); - inet_aton("10.0.1.128", saddr); - inet_aton("10.0.1.131", daddr); - ip->ip_src = *saddr; - ip->ip_dst = *daddr; - - - udp->uh_sport = htons(8772); - udp->uh_dport = htons(8772); - udp->uh_ulen = htons(msg.length()); - - q->set_ip_header(ip, ip->ip_hl << 2); - q->set_dst_ip_anno(IPAddress(*daddr)); - SET_DST_PORT_ANNO(q, htons(8772)); - - printf("XIAOverlayRouted: Pushing packet len %d: %d + %d + %d\n", q->length(), sizeof(*ip), sizeof(*udp), msg.length()); - output(0).push(q); + ip->ip_v = 4; + ip->ip_hl = 5; + ip->ip_tos = 0x10; + ip->ip_len = htons(q->length()); + ip->ip_id = htons(0); // what is this used for exactly? + ip->ip_off = htons(IP_DF); + ip->ip_ttl = 255; + ip->ip_p = IP_PROTO_UDP; + ip->ip_sum = 0; + struct in_addr *saddr = (struct in_addr *)malloc(sizeof(struct in_addr)); + struct in_addr *daddr = (struct in_addr *)malloc(sizeof(struct in_addr)); + assert(saddr); + assert(daddr); + inet_aton("10.0.1.128", saddr); + ip->ip_src = *saddr; + + udp->uh_sport = htons(8772); + udp->uh_dport = htons(8772); + udp->uh_ulen = htons(msg.length()); + + q->set_ip_header(ip, ip->ip_hl << 2); + + printf("\n**********************\n getting neighbors\n"); + std::vector neighbors; + getNeighbors(neighbors); + for(int i=0; iip_dst = *daddr; + q->set_dst_ip_anno(IPAddress(*daddr)); + SET_DST_PORT_ANNO(q, htons(8772)); + pos = neighbors[i].find_first_of("-") + 1; + std::string portstr(neighbors[i].c_str(), pos, neighbors[i].length() - pos); + int port = std::stoi(portstr); + printf("Port %d\n", port); + + printf("XIAOverlayRouted: Pushing packet len %d to %s\n", q->length(), inet_ntoa(*daddr)); + output(port).push(q); + } + printf("\n**********************\n"); + } diff --git a/click/elements/xia/xiaoverlayrouted.hh b/click/elements/xia/xiaoverlayrouted.hh index fed137dc2..14204fc18 100644 --- a/click/elements/xia/xiaoverlayrouted.hh +++ b/click/elements/xia/xiaoverlayrouted.hh @@ -403,7 +403,7 @@ public: ~XIAOverlayRouted(); const char *class_name() const { return "XIAOverlayRouted"; } - const char *port_count() const { return "1/1"; } + const char *port_count() const { return "1/3"; } const char *processing() const { return PUSH; } void push(int, Packet *); diff --git a/click/elements/xia/xiaxidroutetable.cc b/click/elements/xia/xiaxidroutetable.cc index 437240133..60f06d981 100644 --- a/click/elements/xia/xiaxidroutetable.cc +++ b/click/elements/xia/xiaxidroutetable.cc @@ -38,7 +38,6 @@ XIAXIDRouteTable::configure(Vector & /*conf*/, ErrorHandler * /*errh*/) _rtdata.port = -1; _rtdata.flags = 0; _rtdata.nexthop = NULL; - _ntable.count = 0; return 0; } @@ -147,9 +146,11 @@ XIAXIDRouteTable::list_neighbor_handler(Element *e, void *) XIAXIDRouteTable* table = static_cast(e); String ntable; - for(int i=0; i_ntable.count; i++) + for(unsigned i=0; i_ntable.size(); i++) { - String n = table->_ntable.neighbors[i]->addr + ","; + String addr = *(table->_ntable[i]->addr); + String n = String(addr + "-" + std::to_string(table->_ntable[i]->iface).c_str() + ","); + printf("Adding %s\n", n.c_str()); ntable += n; } return ntable; @@ -210,6 +211,7 @@ XIAXIDRouteTable::set_handler4(const String &conf, Element *e, void *thunk, Erro String nxthop = args[2]; // If nexthop is less than 40 chars, it is an IP:port if(nxthop.length() < CLICK_XIA_XID_ID_LEN*2) { + printf("XIAXIDRouteTable: Calling udpnext\n"); return set_udpnext(conf, e, thunk, errh); } nexthop = new XID; @@ -253,7 +255,7 @@ XIAXIDRouteTable::set_handler4(const String &conf, Element *e, void *thunk, Erro int XIAXIDRouteTable::set_udpnext(const String &conf, Element *e, void *thunk, ErrorHandler *errh) { - // printf("******called %s \n", __FUNCTION__); + printf("******called %s \n", __FUNCTION__); XIAXIDRouteTable* table = static_cast(e); bool add_mode = !thunk; Vector args; @@ -286,22 +288,28 @@ XIAXIDRouteTable::set_udpnext(const String &conf, Element *e, void *thunk, Error String ipaddrstr = nxthop.substring(0, separator_offset); String portstr = nxthop.substring(separator_offset+1); - if(args.size() > 3) { int flags; - XIARouteData *xrd = &table->_rtdata; + // XIARouteData *xrd = &table->_rtdata; if (!cp_integer(args[3], &flags)) return errh->error("invalid flags: ", conf.c_str()); + printf("XIAXIDRouteTable: Going into the neighbor block \n"); if(flags == NEIGHBOR) { XIAXIDNeighbor *neighbor = (XIAXIDNeighbor *)malloc(sizeof(XIAXIDNeighbor)); - String s = ipaddrstr + ":" + portstr; - neighbor->addr.append(s.c_str(), s.length()); - printf("XIAXIDRouteTable: Adding neighbor %s\n", neighbor->addr.c_str()); - table->_ntable.neighbors[table->_ntable.count] = neighbor; - table->_ntable.count += 1; - printf("XIAXIDRouteTable: neighbor count %d \n", table->_ntable.count); + if(!neighbor) { + printf("XIAXIDRouteTable: allocation failed\n"); + } + String *s = new String(ipaddrstr + ":" + portstr); + neighbor->addr = s; + neighbor->iface = port; + printf("XIAXIDRouteTable: Adding neighbor %s at port %d\n", (*(neighbor->addr)).c_str(), + neighbor->iface); + table->_ntable.push_back(neighbor); + printf("XIAXIDRoutable: Pushed %s\n", (*(table->_ntable[0]->addr)).c_str()); + // table->_ntable.count += 1; + printf("XIAXIDRouteTable: neighbor count %ld \n", table->_ntable.size()); } } diff --git a/click/elements/xia/xiaxidroutetable.hh b/click/elements/xia/xiaxidroutetable.hh index e5f10d595..2024f141c 100644 --- a/click/elements/xia/xiaxidroutetable.hh +++ b/click/elements/xia/xiaxidroutetable.hh @@ -55,14 +55,10 @@ typedef struct { } XIARouteData; typedef struct { - String addr; + String *addr; // ip:port + int iface; // outgoing iface to the neighbor } XIAXIDNeighbor; -typedef struct { - int count; - XIAXIDNeighbor *neighbors[MAX_NEIGHBOR_CNT]; -} XIAXIDNeighborTable; - class XIAXIDRouteTable : public Element { public: XIAXIDRouteTable(); @@ -100,7 +96,7 @@ protected: HashTable _rts; XIARouteData _rtdata; uint32_t _drops; - XIAXIDNeighborTable _ntable; + std::vector _ntable; int _principal_type_enabled; }; diff --git a/tools/overlay/routerclick.py b/tools/overlay/routerclick.py index 0b9b96cfd..aa2e2d473 100644 --- a/tools/overlay/routerclick.py +++ b/tools/overlay/routerclick.py @@ -42,12 +42,32 @@ def to_string(self): for index in range(4): if (index < num_interfaces): (iface_name, ipaddr, macaddr) = self.interfaces[index] - rstr += '\nosock{}::XIAOverlaySocket("UDP", {}, {}, SNAPLEN 65536) -> [{}]{}[{}] -> osock{};\n'.format(index, ipaddr, 8770, index, self.name, index, index) - rstr += '\nrsock{}::XIAOverlaySocket("UDP", {}, {}, SNAPLEN 65536) -> rd{}::XIAOverlayRouted() -> of{}::XIAOverlayFilter() -> rsock{};\n'.format(index, ipaddr, 8772, index, index, index) - rstr += '\nof{}[{}] -> [{}]of{};\n'.format(index, 1, 1 , index) - rstr += '\nof{}[{}] -> Discard; \n of{}[{}] -> Discard; \n'.format(index, 2, index, 3) + rstr += '\nosock{}::XIAOverlaySocket("UDP", {}, {}, SNAPLEN 65536) -> [{}]{}[{}] -> osock{};'.format(index, ipaddr, 8770, index, self.name, index, index) else: rstr += '\nIdle -> [{}]{}[{}] -> Discard;\n'.format(index, self.name, index) + + + rstr += '\n' + for index in range(4): + if (index < num_interfaces): + (iface_name, ipaddr, macaddr) = self.interfaces[index] + rstr += 'rsock{}::XIAOverlaySocket("UDP", {}, {}, SNAPLEN 65536) -> rd{}::XIAOverlayRouted();\n'.format(index, ipaddr, 8772, index, index) + + rstr += '\n' + for index in range(4): + if (index < num_interfaces): + for i in range(0,3): + if (i < num_interfaces): + rstr += 'rd{}[{}] -> of{}::XIAOverlayFilter() -> rsock{};\n'.format(index, i, index*10+i, i) + + rstr += '\n' + for index in range(4): + if (index < num_interfaces): + for i in range(0,3): + if (i < num_interfaces): + rstr += 'of{}[{}] -> [{}]of{};\n'.format(index*10+i, 1, 1 , index*10+i) + rstr += 'of{}[{}] -> Discard; \n of{}[{}] -> Discard; \n'.format(index*10+i, 2, index*10+i, 3) + #(iface_name, ipaddr, macaddr) = self.interfaces[0] #rstr += '\nSocket("UDP", {}, 8769, SNAPLEN 65536) -> [4]{}\n'.format( From c33e16fbcd0e395e028a4003302b6fd0bcd76799 Mon Sep 17 00:00:00 2001 From: mirrorZ Date: Fri, 12 Jun 2020 01:05:56 -0400 Subject: [PATCH 112/116] Fill neighborTable --- click/conf/xia_router_lib.click | 21 + click/elements/xia/xiaoverlayrouted.cc | 1058 ++++++++---------------- click/elements/xia/xiaoverlayrouted.hh | 314 +------ click/elements/xia/xiaxidroutetable.cc | 184 ++++- click/elements/xia/xiaxidroutetable.hh | 12 + daemons/xrouted/xrouted.cc | 4 - daemons/xrouted/xrouted.hh | 4 - tools/overlay/routerclick.py | 45 +- 8 files changed, 596 insertions(+), 1046 deletions(-) diff --git a/click/conf/xia_router_lib.click b/click/conf/xia_router_lib.click index ecc356d6d..23ec57372 100644 --- a/click/conf/xia_router_lib.click +++ b/click/conf/xia_router_lib.click @@ -362,6 +362,27 @@ elementclass XIARoutingCore { // For get and put cid } +elementclass XIAOverlayRouter { + of0::XIAOverlayFilter(); + of1::XIAOverlayFilter(); + of2::XIAOverlayFilter(); + of3::XIAOverlayFilter(); + + rd::XIAOverlayRouted(); + + input -> rd; + rd[0] -> of0 -> [0]output; + rd[1] -> of1 -> [1]output; + rd[2] -> of2 -> [2]output; + rd[3] -> of3 -> [3]output; + + // discard remaining of ports + of0[1]->[1]of0; of0[2]->Discard; of0[3]->Discard; + of1[1]->[1]of1; of1[2]->Discard; of1[3]->Discard; + of2[1]->[1]of2; of2[2]->Discard; of2[3]->Discard; + of3[1]->[1]of3; of3[2]->Discard; of3[3]->Discard; +} + // 2-port router elementclass XIARouter2Port { $click_port, $hostname, $external_ip, $mac0, $mac1, | diff --git a/click/elements/xia/xiaoverlayrouted.cc b/click/elements/xia/xiaoverlayrouted.cc index a4d4ac1fc..900212455 100644 --- a/click/elements/xia/xiaoverlayrouted.cc +++ b/click/elements/xia/xiaoverlayrouted.cc @@ -10,6 +10,7 @@ #include "xiaoverlayrouted.hh" #include #include +#include #include @@ -39,770 +40,298 @@ CLICK_DECLS #define check_init() do { if (!_init) return init_err; } while (false); -ControlSocketClient::err_t -ControlSocketClient::configure(unsigned int host_ip, unsigned short port) -{ - - if (_init) { - printf("reinit_err\n"); - return reinit_err; - } - - _host = host_ip; - _port = port; - - _fd = socket(PF_INET, SOCK_STREAM, 0); - if (_fd < 0) { - printf("socker err \n"); - return sys_err; - } - - /* - * connect to remote ControlSocket - */ - struct sockaddr_in sa; - memset(&sa, 0, sizeof(sa)); - sa.sin_family = AF_INET; - sa.sin_addr.s_addr = _host; - sa.sin_port = htons(port); - - char namebuf[32]; - snprintf(namebuf, 32, "%u.%u.%u.%u:%hu", - (_host & 0xff) >> 0, - (_host & 0xff00) >> 8, - (_host & 0xff0000) >> 16, - (_host & 0xff000000) >> 24, - port); - _name = namebuf; - - int res = connect(_fd, (struct sockaddr *) &sa, sizeof(sa)); - if (res < 0) { - int save_errno = errno; - ::close(_fd); - errno = save_errno; - printf("connect err\n"); - return sys_err; - } - - int major, minor; - size_t slash, dot; - - /* - * check that we get the expected banner - */ - string buf; - err_t err = readline(buf); - if (err != no_err) { - int save_errno = errno; - ::close(_fd); - errno = save_errno; - printf("readline err \n"); - return err; - } - - slash = buf.find('/'); - dot = (slash != string::npos ? buf.find('.', slash + 1) : string::npos); - if (slash == string::npos || dot == string::npos) { - ::close(_fd); - printf("click err \n"); - return click_err; /* bad format */ - } - - /* - * check ControlSocket protocol version - */ - major = atoi(buf.substr(slash + 1, dot - slash - 1).c_str()); - minor = atoi(buf.substr(dot + 1, buf.size() - dot - 1).c_str()); - if (major != PROTOCOL_MAJOR_VERSION || - minor < PROTOCOL_MINOR_VERSION) { - ::close(_fd); - printf("version err \n"); - return click_err; /* wrong version */ - } - - _init = true; - return no_err; -} - - -ControlSocketClient::err_t -ControlSocketClient::close() -{ - check_init(); - _init = false; - int res = ::close(_fd); - if (res < 1) - return sys_err; - else - return no_err; -} - - -ControlSocketClient::err_t -ControlSocketClient::readline(string &buf) -{ - assert(_fd); - -#define MAX_LINE_SZ 1024 /* arbitrary... to prevent weirdness */ - - /* - * keep calling read() to get one character at a time, until we get - * a line. not very ``efficient'', but who cares? - */ - char c = 0; - buf.resize(0); - do { - int res = ::read(_fd, (void *) &c, 1); - if (res < 0) - return sys_err; - if (res != 1) - return sys_err; - buf += c; - if (buf.size() > MAX_LINE_SZ) - return click_err; - } - while (c != '\n'); - - return no_err; -} - - -int -ControlSocketClient::get_resp_code(string line) -{ - if (line.size() < 3) - return -1; - return atoi(line.substr(0, 3).c_str()); -} - - -int -ControlSocketClient::get_data_len(string line) -{ - unsigned int i; - for (i = 0; i < line.size() && !isdigit((unsigned char) line[i]); i++) - ; // scan string - if (i == line.size()) - return -1; - return atoi(line.substr(i, line.size() - i).c_str()); -} - - -ControlSocketClient::err_t -ControlSocketClient::read(string el, string handler, string &response) -{ - check_init(); - - if (el.size() > 0) - handler = el + "." + handler; - string cmd = "READ " + handler + "\n"; - - int res = ::write(_fd, cmd.c_str(), cmd.size()); - if (res < 0) - return sys_err; - if ((size_t) res != cmd.size()) - return sys_err; - - string cmd_resp; - string line; - do { - err_t err = readline(line); - if (err != no_err) - return err; - if (line.size() < 4) - return click_err; - cmd_resp += line; - } - while (line[3] == '-'); - - int code = get_resp_code(line); - if (code != CODE_OK && code != CODE_OK_WARN) - return handle_err_code(code); - - res = readline(line); - if (res < 0) - return click_err; - int num = get_data_len(line); - if (num < 0) - return click_err; - - response.resize(0); - if (num == 0) - return no_err; - - char *buf = new char[num]; - int num_read = 0; - while (num_read < num) { - res = ::read(_fd, buf + num_read, num - num_read); - if (res < 0) { - delete[] buf; - return sys_err; - } - num_read += res; - } - - response.append(buf, num); - delete[] buf; - - return no_err; -} - - -ControlSocketClient::err_t -ControlSocketClient::read(string el, string handler, char *buf, int &bufsz) -{ - string resp; - err_t err = read(el, handler, resp); - if (err != no_err) - return err; - - bufsz = min((size_t) bufsz, resp.size()); - - memcpy(buf, resp.c_str(), bufsz); - if (resp.size() > (size_t) bufsz) - return too_short; - else - return no_err; -} - - -ControlSocketClient::err_t -ControlSocketClient::write(string el, string handler, const char *buf, int bufsz) -{ - check_init(); - - if (el.size() > 0) - handler = el + "." + handler; - char cbuf[10]; - snprintf(cbuf, sizeof(cbuf), "%d", bufsz); - string cmd = "WRITEDATA " + handler + " " + cbuf + "\n"; - - int res = ::write(_fd, cmd.c_str(), cmd.size()); - if (res < 0) - return sys_err; - if ((size_t) res != cmd.size()) - return sys_err; - - res = ::write(_fd, buf, bufsz); - if (res < 0) - return sys_err; - if (res != bufsz) - return sys_err; - - string cmd_resp; - string line; - do { - err_t err = readline(line); - if (err != no_err) - return err; - if (line.size() < 4) - return click_err; - cmd_resp += line; - } - while (line[3] == '-'); - - int code = get_resp_code(line); - if (code != CODE_OK && code != CODE_OK_WARN) - { -// cout << "CCCC " << code << endl; - return handle_err_code(code); - } - - return no_err; -} - - -ControlSocketClient::err_t -ControlSocketClient::write(string el, string handler, string data) -{ - return write(el, handler, data.c_str(), data.size()); -} - - -ControlSocketClient::err_t -ControlSocketClient::handle_err_code(int code) -{ - switch (code) { - case CODE_SYNTAX_ERR: return click_err; break; - case CODE_UNIMPLEMENTED: return click_err; break; - case CODE_NO_ELEMENT: return no_element; break; - case CODE_NO_HANDLER: return no_handler; break; - case CODE_HANDLER_ERR: return handler_err; break; - case CODE_PERMISSION: return handler_no_perm; break; - default: return click_err; break; - } - return click_err; -} - - - -vector -ControlSocketClient::split(string s, size_t offset, char terminator) -{ - vector v; - size_t pos = offset; - size_t len = s.size(); - while (pos < len) { - size_t start = pos; - while (pos < len && s[pos] != terminator) - pos++; - if (start < pos || pos < len) - v.push_back(s.substr(start, pos - start)); - pos++; - } - return v; -} - - -ControlSocketClient::err_t -ControlSocketClient::get_config_el_names(vector &els) -{ - string resp; - err_t err = read("", "list", resp); - if (err != no_err) - return err; - - /* parse how many els */ - int i = resp.find('\n'); - int num = atoi(resp.substr(0, i).c_str()); - - - els = split(resp, i + 1, '\n'); - if (els.size() != (size_t) num) - return handler_bad_format; - - return no_err; -} - - -ControlSocketClient::err_t -ControlSocketClient::get_string_vec(string el, string h, vector &v) -{ - string resp; - err_t err = read(el, h, resp); - if (err != no_err) - return err; - - v = split(resp, 0, '\n'); - return no_err; -} +// void XIARouter::close() +// { +// if (_connected) +// _cserr = _cs.close(); +// _connected = false; +// } + +// int XIARouter::version(std::string &ver) +// { +// if (!connected()) +// return XR_NOT_CONNECTED; + +// if ((_cserr = _cs.get_router_version(ver)) == 0) +// return XR_OK; +// return XR_CLICK_ERROR; +// } + +// int XIARouter::listRouters(std::vector &rlist) +// { +// vector elements; +// size_t n; + +// if (!connected()) +// return XR_NOT_CONNECTED; + +// if ((_cserr = _cs.get_config_el_names(elements)) != 0) +// return XR_CLICK_ERROR; + +// vector::iterator it; +// for (it = elements.begin(); it < elements.end(); it++) { + +// // cheap way of finding host and router devices, they both have a /xrc element +// if ((n = (*it).find("/xrc")) != string::npos) { +// rlist.push_back((*it).substr(0, n)); +// } +// } +// return 0; +// } + +// int XIARouter::getNeighbors(std::string xidtype, std::vector &neighbors) +// { +// if (!connected()) { +// return XR_NOT_CONNECTED; +// } + +// std::string table = _router + "/xrc/n/proc/rt_" + xidtype; + +// std::string neighborStr; +// if ((_cserr = _cs.read(table, "neighbor", neighborStr)) != 0) { +// printf("couldn't read\n"); +// return XR_CLICK_ERROR; +// } + +// std::string::size_type beg = 0; +// for (auto end = 0; (end = neighborStr.find(',', end)) != std::string::npos; ++end) +// { +// neighbors.push_back(neighborStr.substr(beg, end - beg)); +// beg = end + 1; +// } +// return 0; +// } -ControlSocketClient::err_t -ControlSocketClient::get_el_handlers(string el, vector &handlers) -{ - vector v; - vector vh; - - string buf; - err_t err = read(el, "handlers", buf); - if (err != no_err) - return err; - - vh = split(buf, 0, '\n'); - for (vector::iterator i = vh.begin(); i != vh.end(); i++) { - string &s = *i; - size_t j; - for (j = 0; j < s.size() && !isspace((unsigned char) s[j]); j++) - ; /* find record split -- don't use s.find because could be any whitespace */ - if (j == s.size()) - return click_err; - handler_info_t hi; - hi.element_name = el; - hi.handler_name = trim(s.substr(0, j)); - while (j < s.size() && isspace((unsigned char) s[j])) - j++; - for ( ; j < s.size(); j++) { - if (tolower((unsigned char) s[j]) == 'r') - hi.can_read = true; - else if (tolower((unsigned char) s[j]) == 'w') - hi.can_write = true; - else if (isspace((unsigned char) s[j])) - break; - } - v.push_back(hi); - } +// get the current set of route entries, return value is number of entries returned or < 0 on err +// int XIARouter::getRoutes(std::string xidtype, std::vector &xrt) +// { +// std::string result; +// vector lines; +// int n = 0; - handlers = v; - return no_err; -} +// if (!connected()) +// return XR_NOT_CONNECTED; +// if (xidtype.length() == 0) +// return XR_INVALID_XID; -ControlSocketClient::err_t -ControlSocketClient::check_handler(string el, string h, bool is_write, bool &exists) -{ - check_init(); - - if (el.size() > 0) - h = el + "." + h; - string cmd = (is_write ? "CHECKWRITE " : "CHECKREAD ") + h + "\n"; - - int res = ::write(_fd, cmd.c_str(), cmd.size()); - if (res < 0) - return sys_err; - if ((size_t) res != cmd.size()) - return sys_err; - - string cmd_resp; - string line; - do { - err_t err = readline(line); - if (err != no_err) - return err; - if (line.size() < 4) - return click_err; - cmd_resp += line; - } - while (line[3] == '-'); - - int code = get_resp_code(line); - switch (code) { - case CODE_OK: - case CODE_OK_WARN: - exists = true; - return no_err;; - case CODE_NO_ELEMENT: - case CODE_NO_HANDLER: - case CODE_HANDLER_ERR: - case CODE_PERMISSION: - exists = false; - return no_err; - case CODE_UNIMPLEMENTED: - if (el.size() == 0) - return handle_err_code(code); /* no workaround for top-level router handlers */ - else - return check_handler_workaround(el, h, is_write, exists); - default: - return handle_err_code(code); - } -} +// if (getRouter().length() == 0) +// return XR_ROUTER_NOT_SET; +// std::string table = _router + "/xrc/n/proc/rt_" + xidtype; +// if ((_cserr = _cs.read(table, "list", result)) != 0) +// return XR_CLICK_ERROR; -ControlSocketClient::err_t -ControlSocketClient::check_handler_workaround(string el, string h, bool is_write, bool &exists) -{ - /* - * If talking to an old ControlSocket, try the "handlers" handler - * instead. - */ - - vector v; - err_t err = get_el_handlers(el, v); - if (err != no_err) - return err; - - for (vector::iterator i = v.begin(); i != v.end(); i++) { - if (i->handler_name == h) { - if ((is_write && i->can_write) || - (!is_write && i->can_read)) - exists = true; - else - exists = false; - return no_err; - } - } +// unsigned start = 0; +// unsigned current = 0; +// unsigned len = result.length(); +// string line; - exists = false; - return no_err; -} +// xrt.clear(); +// while (current < len) { +// start = current; +// while (current < len && result[current] != '\n') { +// current++; +// } +// if (start < current || current < len) { +// line = result.substr(start, current - start); -string -ControlSocketClient::trim(string s) -{ - size_t start, end; - for (start = 0; start < s.size() && isspace((unsigned char) s[start]); start++) - ; /* */ - for (end = s.size(); end > 0 && isspace((unsigned char) s[end - 1]); end--) - ; /* */ +// XIARouteEntry entry; +// unsigned start, next; +// string s; +// int port; - if (start >= end) - return ""; +// start = 0; +// next = line.find(","); +// entry.xid = line.substr(start, next - start); - return s.substr(start, end - start); -} +// start = next + 1; +// next = line.find(",", start); +// s = line.substr(start, next - start); +// port = atoi(s.c_str()); +// entry.port = port; -int XIARouter::connect(std::string clickHost, unsigned short controlPort) -{ - struct hostent *h; +// start = next + 1; +// next = line.find(",", start); +// entry.nextHop = line.substr(start, next - start); - if (_connected) - return XR_ALREADY_CONNECTED; +// start = next + 1; +// s = line.substr(start, line.length() - start); +// entry.flags = atoi(s.c_str()); - if ((h = gethostbyname(clickHost.c_str())) == NULL) { - return XR_BAD_HOSTNAME; - } +// xrt.push_back(entry); +// n++; +// } +// current++; +// } - unsigned addr = *(unsigned*)h->h_addr; +// return n; +// } - if ((_cserr = _cs.configure(addr, controlPort)) != 0) { - printf("\nXIAROUTER: XR_NOT_CONNECTED\n"); - return XR_NOT_CONNECTED; - } - - _connected = true; - return XR_OK; -} +// std::string XIARouter::itoa(signed i) +// { +// std::string s; +// std::stringstream ss; -void XIARouter::close() -{ - if (_connected) - _cserr = _cs.close(); - _connected = false; -} +// ss << i; +// s = ss.str(); +// return s; +// } -int XIARouter::version(std::string &ver) -{ - if (!connected()) - return XR_NOT_CONNECTED; +// int XIARouter::updateRoute(string cmd, const std::string &xid, int port, const std::string &next, unsigned long flags) +// { +// string xidtype; +// string mutableXID(xid); +// size_t n; - if ((_cserr = _cs.get_router_version(ver)) == 0) - return XR_OK; - return XR_CLICK_ERROR; -} +// if (!connected()) +// return XR_NOT_CONNECTED; -int XIARouter::listRouters(std::vector &rlist) -{ - vector elements; - size_t n; +// if (mutableXID.length() == 0) +// return XR_INVALID_XID; - if (!connected()) - return XR_NOT_CONNECTED; +// if (next.length() > 0 && next.find(":") == string::npos) +// return XR_INVALID_XID; - if ((_cserr = _cs.get_config_el_names(elements)) != 0) - return XR_CLICK_ERROR; +// n = mutableXID.find(":"); +// if (n == string::npos || n >= sizeof(xidtype)) +// return XR_INVALID_XID; - vector::iterator it; - for (it = elements.begin(); it < elements.end(); it++) { +// if (getRouter().length() == 0) +// return XR_ROUTER_NOT_SET; - // cheap way of finding host and router devices, they both have a /xrc element - if ((n = (*it).find("/xrc")) != string::npos) { - rlist.push_back((*it).substr(0, n)); - } - } - return 0; -} +// xidtype = mutableXID.substr(0, n); -int XIARouter::getNeighbors(std::string xidtype, std::vector &neighbors) -{ - if (!connected()) { - return XR_NOT_CONNECTED; - } - - std::string table = _router + "/xrc/n/proc/rt_" + xidtype; - - std::string neighborStr; - if ((_cserr = _cs.read(table, "neighbor", neighborStr)) != 0) { - printf("couldn't read\n"); - return XR_CLICK_ERROR; - } - - std::string::size_type beg = 0; - for (auto end = 0; (end = neighborStr.find(',', end)) != std::string::npos; ++end) - { - neighbors.push_back(neighborStr.substr(beg, end - beg)); - beg = end + 1; - } - return 0; -} - - -int -XIAOverlayRouted::getNeighbors(std::vector &neighbors) -{ +// std::string table = _router + "/xrc/n/proc/rt_" + xidtype; - - String name = _hostname + String("/xrc/n/proc/rt_SID"); - Element *e = router()->find(name); - if(e) { - String result = HandlerCall::call_read(e, "neighbor"); - std::string neighborStr(result.c_str (), result.length()); - - std::string::size_type beg = 0; - printf("iterating over neighbors\n"); - for (auto end = 0; (end = neighborStr.find(',', end)) != std::string::npos; ++end) - { - neighbors.push_back(neighborStr.substr(beg, end - beg)); - beg = end + 1; - } - - } - else { - printf("Element %s not found \n", name.c_str()); - } - printf("Returning\n"); - return 0; +// string default_xid("-"); +// if (mutableXID.compare(n+1, 1, default_xid) == 0) +// mutableXID = default_xid; + +// std::string entry; + +// // remove command only takes an xid +// if (cmd == "remove") +// entry = mutableXID; +// else +// entry = mutableXID + "," + itoa(port) + "," + next + "," + itoa(flags); + +// if ((_cserr = _cs.write(table, cmd, entry)) != 0) +// return XR_CLICK_ERROR; + +// return XR_OK; +// } + +// int XIARouter::addRoute(const std::string &xid, int port, const std::string &next, unsigned long flags) +// { +// return updateRoute("add4", xid, port, next, flags); +// } + +// int XIARouter::setRoute(const std::string &xid, int port, const std::string &next, unsigned long flags) +// { +// return updateRoute("set4", xid, port, next, flags); +// } + +// int XIARouter::delRoute(const std::string &xid) +// { +// string next = ""; +// return updateRoute("remove", xid, 0, next, 0); +// } + +// const char *XIARouter::cserror() +// { +// switch(_cserr) { +// case ControlSocketClient::no_err: +// return "no error"; +// case ControlSocketClient::sys_err: +// return "O/S or networking error, check errno for more information"; +// case ControlSocketClient::init_err: +// return "tried to perform operation on an unconfigured ControlSocketClient"; +// case ControlSocketClient::reinit_err: +// return "tried to re-configure the client before close()ing it"; +// case ControlSocketClient::no_element: +// return "specified element does not exist"; +// case ControlSocketClient::no_handler: +// return "specified handler does not exist"; +// case ControlSocketClient::handler_no_perm: +// return "router denied access to the specified handler"; +// case ControlSocketClient::handler_err: +// return "handler returned an error"; +// case ControlSocketClient::handler_bad_format: +// return "bad format in calling handler"; +// case ControlSocketClient::click_err: +// return "unexpected response or error from the router"; +// case ControlSocketClient::too_short: +// return "user buffer was too short"; +// } +// return "unknown"; +// } + + +void +XIAOverlayRouted::add_handlers() +{ + add_write_handler("neighbor", add_neighbor, 0); } - -// get the current set of route entries, return value is number of entries returned or < 0 on err -int XIARouter::getRoutes(std::string xidtype, std::vector &xrt) +int +XIAOverlayRouted::add_neighbor(const String &conf, Element *e, void *thunk, ErrorHandler *errh) { - std::string result; - vector lines; - int n = 0; - - if (!connected()) - return XR_NOT_CONNECTED; - - if (xidtype.length() == 0) - return XR_INVALID_XID; - - if (getRouter().length() == 0) - return XR_ROUTER_NOT_SET; - - std::string table = _router + "/xrc/n/proc/rt_" + xidtype; - - if ((_cserr = _cs.read(table, "list", result)) != 0) - return XR_CLICK_ERROR; - - unsigned start = 0; - unsigned current = 0; - unsigned len = result.length(); - string line; - - xrt.clear(); - while (current < len) { - start = current; - while (current < len && result[current] != '\n') { - current++; - } - - if (start < current || current < len) { - line = result.substr(start, current - start); - - XIARouteEntry entry; - unsigned start, next; - string s; - int port; - - start = 0; - next = line.find(","); - entry.xid = line.substr(start, next - start); - - start = next + 1; - next = line.find(",", start); - s = line.substr(start, next - start); - port = atoi(s.c_str()); - entry.port = port; - - start = next + 1; - next = line.find(",", start); - entry.nextHop = line.substr(start, next - start); - - start = next + 1; - s = line.substr(start, line.length() - start); - entry.flags = atoi(s.c_str()); - - xrt.push_back(entry); - n++; - } - current++; - } + printf("Called add neighbor\n"); + XIAOverlayRouted *r = static_cast(e); - return n; -} + Vector args; + cp_argvec(conf, args); -std::string XIARouter::itoa(signed i) -{ - std::string s; - std::stringstream ss; + if (args.size() != 4) + return errh->error("Invalid args: ", conf.c_str()); - ss << i; - s = ss.str(); - return s; -} + int port = 0; + String addr, sid, ad, hid; -int XIARouter::updateRoute(string cmd, const std::string &xid, int port, const std::string &next, unsigned long flags) -{ - string xidtype; - string mutableXID(xid); - size_t n; + if (!cp_string(args[0], &addr)) + return errh->error("Invalid addr"); - if (!connected()) - return XR_NOT_CONNECTED; + if (!cp_string(args[1], &ad)) + return errh->error("Invalid AD"); - if (mutableXID.length() == 0) - return XR_INVALID_XID; + // if (!cp_string(args[2], &hid)) + // return errh->error("Invalid HID"); - if (next.length() > 0 && next.find(":") == string::npos) - return XR_INVALID_XID; + if (!cp_string(args[2], &sid)) + return errh->error("Invalid SID"); - n = mutableXID.find(":"); - if (n == string::npos || n >= sizeof(xidtype)) - return XR_INVALID_XID; - - if (getRouter().length() == 0) - return XR_ROUTER_NOT_SET; - - xidtype = mutableXID.substr(0, n); - - std::string table = _router + "/xrc/n/proc/rt_" + xidtype; - - string default_xid("-"); - if (mutableXID.compare(n+1, 1, default_xid) == 0) - mutableXID = default_xid; - - std::string entry; - - // remove command only takes an xid - if (cmd == "remove") - entry = mutableXID; - else - entry = mutableXID + "," + itoa(port) + "," + next + "," + itoa(flags); - - if ((_cserr = _cs.write(table, cmd, entry)) != 0) - return XR_CLICK_ERROR; - - return XR_OK; -} + if (!cp_integer(args[3], &port)) + return errh->error("Invalid port"); + -int XIARouter::addRoute(const std::string &xid, int port, const std::string &next, unsigned long flags) -{ - return updateRoute("add4", xid, port, next, flags); -} + printf("Adding NeighborEntry addr:%s AD:%s SID:%s port:%d\n", + addr.c_str(), ad.c_str(), sid.c_str(), port); -int XIARouter::setRoute(const std::string &xid, int port, const std::string &next, unsigned long flags) -{ - return updateRoute("set4", xid, port, next, flags); -} + NeighborEntry *entry = new NeighborEntry(); + entry->addr.append(addr.c_str()); + entry->AD.append(ad.c_str()); + entry->SID.append(sid.c_str()); + entry->port = port; -int XIARouter::delRoute(const std::string &xid) -{ - string next = ""; - return updateRoute("remove", xid, 0, next, 0); -} + //todo: check if the entry already exits + r->route_state.neighborTable[entry->AD] = entry; -const char *XIARouter::cserror() -{ - switch(_cserr) { - case ControlSocketClient::no_err: - return "no error"; - case ControlSocketClient::sys_err: - return "O/S or networking error, check errno for more information"; - case ControlSocketClient::init_err: - return "tried to perform operation on an unconfigured ControlSocketClient"; - case ControlSocketClient::reinit_err: - return "tried to re-configure the client before close()ing it"; - case ControlSocketClient::no_element: - return "specified element does not exist"; - case ControlSocketClient::no_handler: - return "specified handler does not exist"; - case ControlSocketClient::handler_no_perm: - return "router denied access to the specified handler"; - case ControlSocketClient::handler_err: - return "handler returned an error"; - case ControlSocketClient::handler_bad_format: - return "bad format in calling handler"; - case ControlSocketClient::click_err: - return "unexpected response or error from the router"; - case ControlSocketClient::too_short: - return "user buffer was too short"; - } - return "unknown"; + return 0; } +// int +// XIAOverlayRouted::getNeighbors(std::vector &neighbors) +// { + +// for(int i=0; imutable_node(); +// Xroute::XID *ad = node->mutable_ad(); +// Xroute::XID *hid = node->mutable_hid(); + +// msg.set_type(Xroute::LSA_MSG); +// msg.set_version(Xroute::XROUTE_PROTO_VERSION); + +// lsa->set_flags(route_state.flags); +// ad ->set_type(n_ad.type()); +// ad ->set_id(n_ad.id(), XID_SIZE); +// hid->set_type(n_hid.type()); +// hid->set_id(n_hid.id(), XID_SIZE); + +// map::iterator it; +// for ( it=route_state.neighborTable.begin() ; it != route_state.neighborTable.end(); it++ ) { +// Node p_ad(it->second.AD); +// Node p_hid(it->second.HID); + +// node = lsa->add_peers(); +// ad = node->mutable_ad(); +// hid = node->mutable_hid(); + +// ad ->set_type(p_ad.type()); +// ad ->set_id(p_ad.id(), XID_SIZE); +// hid->set_type(p_hid.type()); +// hid->set_id(p_hid.id(), XID_SIZE); +// } + +// msg.SerializeToString(&message); +// buflen = message.length(); + +// rc = Xsendto(route_state.sock, message.c_str(), buflen, 0, (struct sockaddr*)&route_state.ddag, sizeof(sockaddr_x)); +// if (rc < 0) { +// // error! +// syslog(LOG_WARNING, "unable to send lsa msg: %s", strerror(errno)); + +// } else if (rc != (int)message.length()) { +// syslog(LOG_WARNING, "ERROR sending lsa. Tried sending %d bytes but rc=%d", buflen, rc); +// rc = -1; +// } + +// return rc; +// } + std::string XIAOverlayRouted::sendHello() { @@ -933,26 +516,45 @@ void XIAOverlayRouted::push(int port, Packet *p_in) q->set_ip_header(ip, ip->ip_hl << 2); printf("\n**********************\n getting neighbors\n"); - std::vector neighbors; - getNeighbors(neighbors); - for(int i=0; i neighbors; + // getNeighbors(neighbors); + // // for(int i=0; iip_dst = *daddr; + // q->set_dst_ip_anno(IPAddress(*daddr)); + // SET_DST_PORT_ANNO(q, htons(8772)); + // pos = neighbors[i].find_first_of("-") + 1; + // std::string portstr(neighbors[i].c_str(), pos, neighbors[i].length() - pos); + // int port = std::stoi(portstr); + // printf("Port %d\n", port); + + // printf("XIAOverlayRouted: Pushing packet len %d to %s\n", q->length(), inet_ntoa(*daddr)); + // output(port).push(q); + // } + // + + std::map::iterator it; + for(it=route_state.neighborTable.begin(); it != route_state.neighborTable.end(); it++) { + String dst(it->first.c_str()); - size_t pos = neighbors[i].find_first_of(":"); - String dst(neighbors[i].c_str(), pos); printf("dst : %s\n", dst.c_str()); inet_aton(dst.c_str(), daddr); ip->ip_dst = *daddr; q->set_dst_ip_anno(IPAddress(*daddr)); SET_DST_PORT_ANNO(q, htons(8772)); - pos = neighbors[i].find_first_of("-") + 1; - std::string portstr(neighbors[i].c_str(), pos, neighbors[i].length() - pos); - int port = std::stoi(portstr); + int port = it->second->port; printf("Port %d\n", port); printf("XIAOverlayRouted: Pushing packet len %d to %s\n", q->length(), inet_ntoa(*daddr)); output(port).push(q); + } + printf("\n**********************\n"); } diff --git a/click/elements/xia/xiaoverlayrouted.hh b/click/elements/xia/xiaoverlayrouted.hh index 14204fc18..426a2b1ff 100644 --- a/click/elements/xia/xiaoverlayrouted.hh +++ b/click/elements/xia/xiaoverlayrouted.hh @@ -62,229 +62,6 @@ CLICK_DECLS #define UNREACHABLE -6 #define FALLBACK -7 -/* - * NB: obscure implementation note: this class does not handle EINTR - * errors from any of the read/write calls. If this is relevant to - * your program, this class may not do the ``right thing'' - */ - -class ControlSocketClient -{ -public: - ControlSocketClient() : _init(false), _fd(0) { } - ControlSocketClient(ControlSocketClient &) : _init(false), _fd(0) { } - - enum err_t { - no_err = 0, - sys_err, /* O/S or networking error, check errno for more information */ - init_err, /* tried to perform operation on an unconfigured ControlSocketClient */ - reinit_err, /* tried to re-configure the client before close()ing it */ - no_element, /* specified element does not exist */ - no_handler, /* specified handler does not exist */ - handler_no_perm, /* router denied access to the specified handler */ - handler_err, /* handler returned an error */ - handler_bad_format, /* bad format in calling handler */ - click_err, /* unexpected response or error from the router */ - too_short /* user buffer was too short */ - }; - - /* - * Configure a new ControlSocketClient. - * HOST_IP is IP address (in network byte order) of the machine that user-level click is running on - * PORT is the IP port the ControlSocket is listening on. - * Returns: no_err, sys_err, reinit_err, click_err - * If returns no_err, the client is properly configured; otherwise the client is unconfigured. - */ - err_t configure(unsigned int host_ip, unsigned short port); - - /* - * Close a configured client. - * Returns: no_err, sys_err, init_err - * In any case, the client is left unconfigured. - */ - err_t close(); - - /* - * Return a string describing the ControlSocket's host and port. - * Requires: object is configured - */ - const string name() { assert(_init); return _name; } - - - /* - * NB: the following functions return data about or send data to the - * click router via the ControlSocket. Unless otherwise noted, the - * data returned or sent is undefined unless the function's return - * value is no_err. - */ - - /* - * Get a string containing the router's configuration - * (get_router_config) or flattened configuration - * (get_router_flat_config). - * CONFIG is filled with the configuration; existing contents are replaced. - * Returns: no_err, no_handler, handler_err, handler_no_perm, sys_err, init_err, click_err - */ - err_t get_router_config(string &config) { return read("", "config", config); } - err_t get_router_flat_config(string &config) { return read("", "flatconfig", config); } - - /* - * Get a string containing the router's version - * VERS is filled with the version; existing contents are replaced. - * Returns: no_err, no_handler, handler_err, handler_no_perm, sys_err, init_err, click_err - */ - err_t get_router_version(string &vers) { err_t err = read("", "version", vers); /*vers = trim(vers);*/ return err; } - - /* - * Get the names of the elements in the the current router configuration. - * ELS is filled with the names, existing contents are replaced. - * Returns: no_err, no_handler, handler_err, handler_no_perm, sys_err, init_err, click_err - */ - err_t get_config_el_names(vector &els); - - /* - * Get the names of the element types that the router knows about. - * CLASSES is filled with the names, existing contents are replaced. - * Returns: no_err, no_handler, handler_err, handler_no_perm, sys_err, init_err, click_err - */ - err_t get_router_classes(vector &classes) { return get_string_vec("", "classes", classes); } - - /* - * Get the names of the packages that the router knows about. - * PACKAGES is filled with the names, existing contents are replaced. - * Returns: no_err, no_handler, handler_err, handler_no_perm, sys_err, init_err, click_err - */ - err_t get_router_packages(vector &pkgs) { return get_string_vec("", "packages", pkgs); } - - /* - * Get the names of the current router configuration requirements. - * REQS is filled with the names, existing contents are replaced. - * Returns: no_err, no_handler, handler_err, handler_no_perm, sys_err, init_err, click_err - */ - err_t get_config_reqs(vector &reqs) { return get_string_vec("", "requirements", reqs); } - - struct handler_info_t { - string element_name; - string handler_name; - bool can_read; - bool can_write; - handler_info_t() : can_read(false), can_write(false) { } - }; - - /* - * Get the information about an element's handlers in the current router configuration. - * EL is the element's name. - * HANDLERS is filled with the handler info, existing contents are replaced. - * Returns: no_err, no_element, handler_err, handler_no_perm, sys_err, init_err, click_err - */ - err_t get_el_handlers(string el, vector &handlers); - - /* - * Check whether a read/write handler exists. - * EL is the element's name. - * H is the handler's name. - * IS_WRITE true to check for write handler, otherwise check read handler. - * EXISTS is filled with true if the handler exists, otherwise false. - * Returns: no_err, sys_err, init_err, click_err - */ - err_t check_handler(string el, string h, bool is_write, bool &exists); -protected: - err_t check_handler_workaround(string el, string h, bool is_write, bool &exists); - -public: - /* - * Return the results of reading a handler. - * EL is the element's name. - * HANDLER is the handler name. - * RESPONSE is filled with the handler's output, existing contents are replaced. - * If NAME is not empty, calls``NAME.HANDLER''; otherwise calls ``HANDLER'' - * Returns: no_err, no_element, no_handler, handler_err, handler_no_perm, sys_err, init_err, click_err - */ - err_t read(string el, string handler, string &response); - - /* - * Return the results of reading a handler. - * EL is the element's name. - * HANDLER is the handler name. - * BUF receives the data. - * BUFSZ is the size of BUF, and recieves the actual number of characters placed into BUF. - * If NAME is not empty, calls``NAME.HANDLER''; otherwise calls ``HANDLER'' - * Returns: no_err, no_element, no_handler, handler_err, handler_no_perm, sys_err, init_err, click_err, too_short - * If returns too_short, the operation succeeded, but returned more than BUFSZ characters; the first BUFSZ - * characters of the result are placed into BUF, and BUFSZ is unchanged. - */ - err_t read(string el, string handler, char *buf, int &bufsz); - - /* - * Write data to an element's handler. - * EL is the element's name. - * HANDLER is the handler name. - * DATA contains the data. No terminating '\0' is written. - * If NAME is not empty, calls``NAME.HANDLER''; otherwise calls ``HANDLER'' - * Returns: no_err, no_element, no_handler, handler_err, handler_no_perm, sys_err, init_err, click_err - */ - err_t write(string el, string handler, string data); - - /* - * Write data to an element's handler. - * EL is the element's name. - * HANDLER is the handler name. - * BUF contains the data. - * BUFSZ is the number of characters to be written from BUF. - * If NAME is not empty, calls``NAME.HANDLER''; otherwise calls ``HANDLER'' - * Returns: no_err, no_element, no_handler, handler_err, handler_no_perm, sys_err, init_err, click_err - */ - err_t write(string el, string handler, const char *buf, int bufsz); - - /* - * sugar, for reading and writing handlers. - */ - err_t read(handler_info_t h, string &response) { return read(h.element_name, h.handler_name, response); } - err_t read(handler_info_t h, char *buf, int &bufsz) { return read(h.element_name, h.handler_name, buf, bufsz); } - err_t write(handler_info_t h, string data) { return write(h.element_name, h.handler_name, data); } - err_t write(handler_info_t h, const char *buf, int bufsz) { return write(h.element_name, h.handler_name, buf, bufsz); } - - - ~ControlSocketClient() { if (_init) ::close(_fd); } - -private: - bool _init; - - unsigned int _host; - unsigned short _port; - int _fd; - int _protocol_minor_version; - - string _name; - - enum { - CODE_OK = 200, - CODE_OK_WARN = 220, - CODE_SYNTAX_ERR = 500, - CODE_UNIMPLEMENTED = 501, - CODE_NO_ELEMENT = 510, - CODE_NO_HANDLER = 511, - CODE_HANDLER_ERR = 520, - CODE_PERMISSION = 530, - CODE_NO_ROUTER = 540, - - PROTOCOL_MAJOR_VERSION = 1, - PROTOCOL_MINOR_VERSION = 0 - }; - - /* Try to read a '\n'-terminated line (including the '\n') from the - * socket. */ - err_t readline(string &buf); - - int get_resp_code(string line); - int get_data_len(string line); - err_t handle_err_code(int code); - - err_t get_string_vec(string el, string h, vector &v); - vector split(string s, size_t offset, char terminator); - string trim(string s); -}; - typedef struct { std::string xid; std::string nextHop; @@ -292,51 +69,43 @@ typedef struct { unsigned long flags; } XIARouteEntry; -class XIARouter { -public: - XIARouter(const char *_rtr = "router0") { _connected = false; - _cserr = ControlSocketClient::no_err; _router = _rtr; }; - ~XIARouter() { if (connected()) close(); }; - - // connect to click - int connect(std::string clickHost = "localhost", unsigned short controlPort = 7777); - int connected() { return _connected; }; - void close(); - - // returns the click version in - int version(std::string &ver); +// class XIARouter { +// public: +// XIARouter(const char *_rtr = "router0") { _connected = false; +// _cserr = ControlSocketClient::no_err; _router = _rtr; }; +// ~XIARouter() { if (connected()) close(); }; - // returns the error code from the underlying click control socket interface - ControlSocketClient::err_t ControlSocketError() { return _cserr; }; +// // connect to click +// int connect(std::string clickHost = "localhost", unsigned short controlPort = 7777); +// int connected() { return _connected; }; +// void close(); - // return a vector of router devices click knows about (host0, router1, ....) - int listRouters(std::vector &rlist); +// // returns the click version in +// int version(std::string &ver); - // specify which router to operate on, must be called before adding/removing routes - // defaults to router0 - void setRouter(std::string r) { _router = r; }; - std::string getRouter() { return _router; }; +// // return a vector of router devices click knows about (host0, router1, ....) +// int listRouters(std::vector &rlist); - // get the current set of route entries, return value is number of entries returned or < 0 on err - int getRoutes(std::string xidtype, std::vector &xrt); +// // specify which router to operate on, must be called before adding/removing routes +// // defaults to router0 +// void setRouter(std::string r) { _router = r; }; +// std::string getRouter() { return _router; }; - // returns 0 success, < 0 on error - int addRoute(const std::string &xid, int port, const std::string &next, unsigned long flags); - int setRoute(const std::string &xid, int port, const std::string &next, unsigned long flags); - int delRoute(const std::string &xid); - int getNeighbors(std::string xidtype, std::vector &neighbors); +// // get the current set of route entries, return value is number of entries returned or < 0 on err +// int getRoutes(std::string xidtype, std::vector &xrt); +// // returns 0 success, < 0 on error +// int addRoute(const std::string &xid, int port, const std::string &next, unsigned long flags); +// int setRoute(const std::string &xid, int port, const std::string &next, unsigned long flags); +// int delRoute(const std::string &xid); +// int getNeighbors(std::string xidtype, std::vector &neighbors); - const char *cserror(); -private: - bool _connected; - std::string _router; - ControlSocketClient _cs; - ControlSocketClient::err_t _cserr; - - int updateRoute(std::string cmd, const std::string &xid, int port, const std::string &next, unsigned long flags); - string itoa(signed); -}; +// private: +// bool _connected; +// std::string _router; +// int updateRoute(std::string cmd, const std::string &xid, int port, const std::string &next, unsigned long flags); +// string itoa(signed); +// }; typedef struct { std::string dest; // destination AD or HID @@ -348,6 +117,8 @@ typedef struct { typedef struct { std::string AD; // neigbor AD std::string HID; // neighbor HID + std::string SID; // neighbor SID + std::string addr; // overlay addr int32_t cost; // link cost int32_t port; // interface (outgoing port) } NeighborEntry; @@ -367,10 +138,8 @@ typedef struct { typedef struct RouteState { int32_t sock; // socket for routing process - sockaddr_x sdag; - sockaddr_x ddag; - char myAD[MAX_XID_SIZE]; // this router AD + char myOverlaySID[MAX_XID_SIZE]; // this router overlay SID char myHID[MAX_XID_SIZE]; // this router HID char my4ID[MAX_XID_SIZE]; // not used @@ -382,9 +151,7 @@ typedef struct RouteState { std::map ADrouteTable; // map DestAD to route entry std::map HIDrouteTable; // map DestHID to route entry - - std::map neighborTable; // map neighborAD to neighbor entry - + std::map neighborTable; // map neighborAD to neighbor entry std::map networkTable; // map DestAD to NodeState entry } RouteState; @@ -393,23 +160,28 @@ typedef struct RouteState { class XIAOverlayRouted : public Element { +void add_handlers(); + +protected: + static int add_neighbor(const String &conf, Element *e, void *thunk, ErrorHandler *errh); + RouteState route_state; - XIARouter xr; + // XIARouter xr; String _hostname; - + public: XIAOverlayRouted(); ~XIAOverlayRouted(); const char *class_name() const { return "XIAOverlayRouted"; } - const char *port_count() const { return "1/3"; } + const char *port_count() const { return "1/4"; } const char *processing() const { return PUSH; } void push(int, Packet *); std::string sendHello(); - int getNeighbors(std::vector &neighbors); + // int getNeighbors(std::vector &neighbors); }; CLICK_ENDDECLS diff --git a/click/elements/xia/xiaxidroutetable.cc b/click/elements/xia/xiaxidroutetable.cc index 60f06d981..74f84a347 100644 --- a/click/elements/xia/xiaxidroutetable.cc +++ b/click/elements/xia/xiaxidroutetable.cc @@ -9,6 +9,12 @@ #include #include #include + +#include +#include +#include + + #if CLICK_USERLEVEL #include #include @@ -16,11 +22,17 @@ #include #include + + #endif CLICK_DECLS XIAXIDRouteTable::XIAXIDRouteTable(): _drops(0) { + char *hostname = (char *)malloc(32); + assert(hostname); + gethostname(hostname, 32); + _hostname = String(hostname, strlen(hostname)); } XIAXIDRouteTable::~XIAXIDRouteTable() @@ -68,7 +80,8 @@ XIAXIDRouteTable::add_handlers() add_read_handler("list", list_routes_handler, 0); add_write_handler("enabled", write_handler, (void *)PRINCIPAL_TYPE_ENABLED); add_read_handler("enabled", read_handler, (void *)PRINCIPAL_TYPE_ENABLED); - add_read_handler("neighbor", list_neighbor_handler, 0); + add_write_handler("addIP", add_ip_handler, 0); + add_read_handler("listIP", list_ip_handler, 0); } String @@ -141,18 +154,17 @@ XIAXIDRouteTable::list_routes_handler(Element *e, void *thunk) } String -XIAXIDRouteTable::list_neighbor_handler(Element *e, void *) +XIAXIDRouteTable::list_ip_handler(Element *e, void *) { XIAXIDRouteTable* table = static_cast(e); String ntable; - for(unsigned i=0; i_ntable.size(); i++) - { - String addr = *(table->_ntable[i]->addr); - String n = String(addr + "-" + std::to_string(table->_ntable[i]->iface).c_str() + ","); - printf("Adding %s\n", n.c_str()); - ntable += n; - } + HashTable::iterator it; + for(it = table->_nts.begin(); it != table->_nts.end(); it++) { + ntable += String(it->first + "," + it->second->AD->c_str() + "," + + it->second->SID->c_str() + ";"); + } + return ntable; } @@ -211,7 +223,7 @@ XIAXIDRouteTable::set_handler4(const String &conf, Element *e, void *thunk, Erro String nxthop = args[2]; // If nexthop is less than 40 chars, it is an IP:port if(nxthop.length() < CLICK_XIA_XID_ID_LEN*2) { - printf("XIAXIDRouteTable: Calling udpnext\n"); + printf("XIAXIDRouteTable: Calling udpnext nts %lld\n", (unsigned long)&table->_nts); return set_udpnext(conf, e, thunk, errh); } nexthop = new XID; @@ -252,11 +264,69 @@ XIAXIDRouteTable::set_handler4(const String &conf, Element *e, void *thunk, Erro return 0; } +int +XIAXIDRouteTable::add_ip_handler(const String &conf, Element *e, void *thunk, ErrorHandler *errh) +{ + printf("In add ip handler\n"); + XIAXIDRouteTable* table = static_cast(e); + + Vector args; + String xid_str, ipstr; + + cp_argvec(conf, args); + + if (args.size() != 2) { + printf("1 %ld\n", args.size()); + return errh->error("Invalid route(need 2 entries): ", conf.c_str()); + } + + if (!cp_string(args[0], &ipstr)) { + printf("3\n"); + return errh->error("Invalid ipaddr arg"); + } + + if (!cp_string(args[1], &xid_str)) { + printf("2\n"); + return errh->error("Invalid xid arg"); + } + + HashTable::iterator it = table->_nts.find(ipstr); + XIAXIDAddr *n; + if(it == table->_nts.end()) { + printf("XIAXIDNeighbor: %s does not exist in HT %d \n", + ipstr.c_str(), table->_nts.size()); + n = new XIAXIDAddr(); + table->_nts[ipstr] = n; + } + else { + n = it->second; + } + + std::string *s = new std::string(xid_str.c_str()); + + if(xid_str.starts_with("AD")) { + n->AD = s; + printf("Added AD for %s : %s\n", ipstr.c_str(), table->_nts[ipstr]->AD->c_str()); + } + else if(xid_str.starts_with("HID")) + { + n->HID = s; + printf("Added HID for %s : %s\n", ipstr.c_str(), table->_nts[ipstr]->HID->c_str()); + } + else if(xid_str.starts_with("SID")) { + n->SID = s; + printf("Added SID for %s : %s\n", ipstr.c_str(), table->_nts[ipstr]->SID->c_str()); + } + + return 0; +} + int XIAXIDRouteTable::set_udpnext(const String &conf, Element *e, void *thunk, ErrorHandler *errh) { - printf("******called %s \n", __FUNCTION__); + XIAXIDRouteTable* table = static_cast(e); + printf("******called %s table : %lld\n", __FUNCTION__, (unsigned long)table); bool add_mode = !thunk; Vector args; int port = 0; @@ -288,6 +358,20 @@ XIAXIDRouteTable::set_udpnext(const String &conf, Element *e, void *thunk, Error String ipaddrstr = nxthop.substring(0, separator_offset); String portstr = nxthop.substring(separator_offset+1); + String ename = table->_hostname + String("/xrc/n/proc/rt_IP"); + Element *ne = e->router()->find(ename); + if(ne) { + printf("XIAXIDRoutetable: Calling write\n"); + int ret = HandlerCall::call_write(ne, "addIP", ipaddrstr + "," + xid_str); + if (ret) + return errh->error("Failed to call write\n"); + } + else { + printf("Element %s not found \n", ename.c_str()); + return errh->error("Failed to find element : \n", ename.c_str()); + } + + if(args.size() > 3) { int flags; // XIARouteData *xrd = &table->_rtdata; @@ -297,19 +381,73 @@ XIAXIDRouteTable::set_udpnext(const String &conf, Element *e, void *thunk, Error printf("XIAXIDRouteTable: Going into the neighbor block \n"); if(flags == NEIGHBOR) { - XIAXIDNeighbor *neighbor = (XIAXIDNeighbor *)malloc(sizeof(XIAXIDNeighbor)); - if(!neighbor) { - printf("XIAXIDRouteTable: allocation failed\n"); + Vector ve = e->router()->elements(); + for(int i=0; iname().c_str()); + } + + String ename = table->_hostname + String("/xrc/n/proc/rt_IP"); + Element *ne = e->router()->find(ename); + if(ne) { + String result = HandlerCall::call_read(ne, "listIP"); + std::string rstr(result.c_str (), result.length()); + + std::string::size_type beg = 0; + printf("Returned %s\n", rstr.c_str()); + String ad, sid; + for (auto end = 0; (end = rstr.find(';', end)) != std::string::npos; end++) + { + std::string n(rstr.substr(beg, end - beg)); + printf("N : %s\n", n.c_str()); + Vectorargs; + String c(n.c_str()); + cp_argvec(c, args); + if(args.size() != 3) { + printf("List IP did not return all args %d\n", args.size()); + return errh->error("Not all args"); + } + if(args[0].equals(ipaddrstr)) { + cp_string(args[1], &ad); + cp_string(args[2], &sid); + break; + } + beg = end + 1; + } + String rname = "rd/rd"; + Element *re = e->router()->find(rname); + if(re) { + if(HandlerCall::call_write(re, "neighbor", + ipaddrstr + "," + ad + "," + sid + "," + portstr)) { + printf("Failed to write to xrouted\n"); + } + else { + printf("Written\n"); + } + } + + + } + else { + printf("Element %s not found \n", ename.c_str()); } - String *s = new String(ipaddrstr + ":" + portstr); - neighbor->addr = s; - neighbor->iface = port; - printf("XIAXIDRouteTable: Adding neighbor %s at port %d\n", (*(neighbor->addr)).c_str(), - neighbor->iface); - table->_ntable.push_back(neighbor); - printf("XIAXIDRoutable: Pushed %s\n", (*(table->_ntable[0]->addr)).c_str()); - // table->_ntable.count += 1; - printf("XIAXIDRouteTable: neighbor count %ld \n", table->_ntable.size()); + // XIAXIDNeighbor *neighbor = (XIAXIDNeighbor *)malloc(sizeof(XIAXIDNeighbor)); + // if(!neighbor) { + // printf("XIAXIDRouteTable: allocation failed\n"); + // } + // String *s = new String(ipaddrstr + ":" + portstr); + // neighbor->addr = s; + // neighbor->iface = port; + // printf("XIAXIDRouteTable: Adding neighbor %s at port %d\n", (*(neighbor->addr)).c_str(), + // neighbor->iface); + // table->_ntable.push_back(neighbor); + // printf("XIAXIDRoutable: Pushed %s\n", (*(table->_ntable[0]->addr)).c_str()); + // // table->_ntable.count += 1; + // printf("XIAXIDRouteTable: neighbor count %ld \n", table->_ntable.size()); + // + // + // printf("neighbor entry found %s %s %s %s\n", ipaddrstr.c_str(), + // table->_nts[ipaddrstr]->AD->c_str(), table->_nts[ipaddrstr]->HID->c_str(), table->_nts[ipaddrstr]->SID->c_str()); + } } diff --git a/click/elements/xia/xiaxidroutetable.hh b/click/elements/xia/xiaxidroutetable.hh index 2024f141c..3cd564c27 100644 --- a/click/elements/xia/xiaxidroutetable.hh +++ b/click/elements/xia/xiaxidroutetable.hh @@ -54,9 +54,17 @@ typedef struct { std::unique_ptr nexthop_in; } XIARouteData; + +typedef struct { + std::string *AD; + std::string *HID; + std::string *SID; +} XIAXIDAddr; + typedef struct { String *addr; // ip:port int iface; // outgoing iface to the neighbor + String *AD; } XIAXIDNeighbor; class XIAXIDRouteTable : public Element { public: @@ -82,6 +90,7 @@ protected: static int set_handler(const String &conf, Element *e, void *thunk, ErrorHandler *errh); static int set_handler4(const String &conf, Element *e, void *thunk, ErrorHandler *errh); + static int add_ip_handler(const String &conf, Element *e, void *thunk, ErrorHandler *errh); static int set_udpnext(const String &conf, Element *e, void *thunk, ErrorHandler *errh); static int remove_handler(const String &conf, Element *e, void *, ErrorHandler *errh); static int load_routes_handler(const String &conf, Element *e, void *, ErrorHandler *errh); @@ -92,10 +101,13 @@ protected: static void add_entry_to_tbl_str(Element *e, String& tbl, String xid, XIARouteData* xrd); static String list_routes_handler(Element *e, void *thunk); static String list_neighbor_handler(Element *e, void *); + static String list_ip_handler(Element *e, void *); HashTable _rts; + HashTable _nts; XIARouteData _rtdata; uint32_t _drops; + String _hostname; std::vector _ntable; int _principal_type_enabled; diff --git a/daemons/xrouted/xrouted.cc b/daemons/xrouted/xrouted.cc index 61b72c863..ced98d9d0 100644 --- a/daemons/xrouted/xrouted.cc +++ b/daemons/xrouted/xrouted.cc @@ -266,8 +266,6 @@ int processLSA(const Xroute::XrouteMsg& msg) // fix me once we don't need to rebroadcast the lsa const Xroute::LSAMsg& lsa = msg.lsa(); - printf(" *** processLSA: %s\n", lsa.DebugString().c_str()); - Xroute::XID a = lsa.node().ad(); Xroute::XID h = lsa.node().hid(); @@ -287,8 +285,6 @@ int processLSA(const Xroute::XrouteMsg& msg) return 1; } - - map::iterator it = route_state.networkTable.find(destAD); if(it != route_state.networkTable.end()) { // For now, delete this dest AD entry in networkTable diff --git a/daemons/xrouted/xrouted.hh b/daemons/xrouted/xrouted.hh index 1a8f96f7b..04993160d 100644 --- a/daemons/xrouted/xrouted.hh +++ b/daemons/xrouted/xrouted.hh @@ -41,10 +41,6 @@ using namespace std; #define MAX_XID_SIZE 64 #define MAX_DAG_SIZE 512 - - - - #define BFID "FID:FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF" #define SID_XROUTE "SID:1110000000000000000000000000000000001112" #define NULL_4ID "IP:4500000000010000fafa00000000000000000000" diff --git a/tools/overlay/routerclick.py b/tools/overlay/routerclick.py index aa2e2d473..63d9061a4 100644 --- a/tools/overlay/routerclick.py +++ b/tools/overlay/routerclick.py @@ -46,31 +46,44 @@ def to_string(self): else: rstr += '\nIdle -> [{}]{}[{}] -> Discard;\n'.format(index, self.name, index) - - rstr += '\n' + rstr += '\n rd :: XIAOverlayRouter();\n' for index in range(4): if (index < num_interfaces): (iface_name, ipaddr, macaddr) = self.interfaces[index] - rstr += 'rsock{}::XIAOverlaySocket("UDP", {}, {}, SNAPLEN 65536) -> rd{}::XIAOverlayRouted();\n'.format(index, ipaddr, 8772, index, index) - - rstr += '\n' - for index in range(4): - if (index < num_interfaces): - for i in range(0,3): - if (i < num_interfaces): - rstr += 'rd{}[{}] -> of{}::XIAOverlayFilter() -> rsock{};\n'.format(index, i, index*10+i, i) + rstr += 'rsock{}::XIAOverlaySocket("UDP", {}, {}, SNAPLEN 65536) -> rd;\n'.format(index, ipaddr, 8772) rstr += '\n' for index in range(4): if (index < num_interfaces): - for i in range(0,3): - if (i < num_interfaces): - rstr += 'of{}[{}] -> [{}]of{};\n'.format(index*10+i, 1, 1 , index*10+i) - rstr += 'of{}[{}] -> Discard; \n of{}[{}] -> Discard; \n'.format(index*10+i, 2, index*10+i, 3) + rstr += 'rd[{}] -> rsock{};\n'.format(index, index) + + + # rstr += '\n' + # for index in range(4): + # if (index < num_interfaces): + # (iface_name, ipaddr, macaddr) = self.interfaces[index] + # rstr += 'rsock{}::XIAOverlaySocket("UDP", {}, {}, SNAPLEN 65536) -> rd{}::XIAOverlayRouted();\n'.format(index, ipaddr, 8772, index, index) + + # rstr += '\n' + # for index in range(4): + # if (index < num_interfaces): + # for i in range(0,3): + # if (i < num_interfaces): + # rstr += 'rd{}[{}] -> of{}::XIAOverlayFilter() -> rsock{};\n'.format(index, i, index*10+i, i) + + # rstr += '\n' + # for index in range(4): + # if (index < num_interfaces): + # for i in range(0,3): + # if (i < num_interfaces): + # rstr += 'of{}[{}] -> [{}]of{};\n'.format(index*10+i, 1, 1 , index*10+i) + # rstr += 'of{}[{}] -> Discard; \n of{}[{}] -> Discard; \n'.format(index*10+i, 2, index*10+i, 3) + - #(iface_name, ipaddr, macaddr) = self.interfaces[0] - #rstr += '\nSocket("UDP", {}, 8769, SNAPLEN 65536) -> [4]{}\n'.format( + # rstr += '\n' + # (iface_name, ipaddr, macaddr) = self.interfaces[0] + # rstr += '\nSocket("UDP", {}, 8769, SNAPLEN 65536) -> [4]{}\n'.format( # ipaddr, self.name) rstr += '\nControlSocket(tcp, 7777);\n' return rstr From 7ef7ef1d403c01c2db32fb2518723593aa7c6267 Mon Sep 17 00:00:00 2001 From: mirrorZ Date: Sun, 14 Jun 2020 02:05:30 -0400 Subject: [PATCH 113/116] send and process lsa --- click/elements/xia/xiaoverlayrouted.cc | 238 ++++++++++++++++--------- click/elements/xia/xiaoverlayrouted.hh | 4 + click/elements/xia/xiaxidroutetable.cc | 6 +- click/userlevel/xroute.proto | 2 +- 4 files changed, 159 insertions(+), 91 deletions(-) diff --git a/click/elements/xia/xiaoverlayrouted.cc b/click/elements/xia/xiaoverlayrouted.cc index 900212455..10ff6b2c3 100644 --- a/click/elements/xia/xiaoverlayrouted.cc +++ b/click/elements/xia/xiaoverlayrouted.cc @@ -336,17 +336,19 @@ XIAOverlayRouted::add_neighbor(const String &conf, Element *e, void *thunk, Erro XIAOverlayRouted::XIAOverlayRouted() { - FILE *f = fopen("etc/resolv.conf", "r"); + FILE *f = fopen("etc/address.conf", "r"); if (!f) { printf("Failed to open resolv.conf \n"); return; } + char *hostname = (char *)malloc(32); char ad[100], hid[100], re[100]; - fscanf(f,"%s %s %s", re, ad, hid); + fscanf(f,"%s %s %s %s", hostname, re, ad, hid); fclose(f); - strcpy(route_state.myAD, ad); - strcpy(route_state.myHID, hid); + strcpy(route_state.myAD, ad+1); + strncpy(route_state.myHID, hid, XID_SIZE); + route_state.num_neighbors = 0; // number of neighbor routers route_state.calc_dijstra_ticks = 0; @@ -354,69 +356,60 @@ XIAOverlayRouted::XIAOverlayRouted() route_state.flags = F_EDGE_ROUTER; route_state.dual_router_AD = "NULL"; - char *hostname = (char *)malloc(32); assert(hostname); - gethostname(hostname, 32); + // gethostname(hostname, 32); _hostname = String(hostname, strlen(hostname)); + printf("\n----XIAOverlayRouted: Started with ad: %s hid: %s hostname: %s----\n", route_state.myAD, + route_state.myHID, _hostname.c_str()); + c = 0; } XIAOverlayRouted::~XIAOverlayRouted() { } -// std::string -// XIAOverlayRouted::sendLSA() { -// int buflen, rc; -// string message; - -// Node n_ad(route_state.myAD); -// Node n_hid(route_state.myHID); - -// Xroute::XrouteMsg msg; -// Xroute::LSAMsg *lsa = msg.mutable_lsa(); -// Xroute::Node *node = lsa->mutable_node(); -// Xroute::XID *ad = node->mutable_ad(); -// Xroute::XID *hid = node->mutable_hid(); - -// msg.set_type(Xroute::LSA_MSG); -// msg.set_version(Xroute::XROUTE_PROTO_VERSION); - -// lsa->set_flags(route_state.flags); -// ad ->set_type(n_ad.type()); -// ad ->set_id(n_ad.id(), XID_SIZE); -// hid->set_type(n_hid.type()); -// hid->set_id(n_hid.id(), XID_SIZE); - -// map::iterator it; -// for ( it=route_state.neighborTable.begin() ; it != route_state.neighborTable.end(); it++ ) { -// Node p_ad(it->second.AD); -// Node p_hid(it->second.HID); - -// node = lsa->add_peers(); -// ad = node->mutable_ad(); -// hid = node->mutable_hid(); - -// ad ->set_type(p_ad.type()); -// ad ->set_id(p_ad.id(), XID_SIZE); -// hid->set_type(p_hid.type()); -// hid->set_id(p_hid.id(), XID_SIZE); -// } - -// msg.SerializeToString(&message); -// buflen = message.length(); - -// rc = Xsendto(route_state.sock, message.c_str(), buflen, 0, (struct sockaddr*)&route_state.ddag, sizeof(sockaddr_x)); -// if (rc < 0) { -// // error! -// syslog(LOG_WARNING, "unable to send lsa msg: %s", strerror(errno)); +std::string +XIAOverlayRouted::sendLSA() { + string message; + + Node n_ad(route_state.myAD); + printf("XIAOverlayRouted: sending lsa with ad %s\n", n_ad.to_string().c_str()); + // Node n_hid(route_state.myHID); + + Xroute::XrouteMsg msg; + Xroute::LSAMsg *lsa = msg.mutable_lsa(); + Xroute::Node *node = lsa->mutable_node(); + Xroute::XID *ad = node->mutable_ad(); + // Xroute::XID *hid = node->mutable_hid(); + + msg.set_type(Xroute::LSA_MSG); + msg.set_version(Xroute::XROUTE_PROTO_VERSION); + + lsa->set_flags(route_state.flags); + ad ->set_type(n_ad.type()); + ad ->set_id(n_ad.id(), XID_SIZE); + // hid->set_type(n_hid.type()); + // hid->set_id(n_hid.id(), XID_SIZE); + + map::iterator it; + for ( it=route_state.neighborTable.begin() ; it != route_state.neighborTable.end(); it++ ) { + Node p_ad(it->second->AD); + // Node p_hid(it->second.HID); + + node = lsa->add_peers(); + ad = node->mutable_ad(); + // hid = node->mutable_hid(); + + ad ->set_type(p_ad.type()); + ad ->set_id(p_ad.id(), XID_SIZE); + // hid->set_type(p_hid.type()); + // hid->set_id(p_hid.id(), XID_SIZE); + } -// } else if (rc != (int)message.length()) { -// syslog(LOG_WARNING, "ERROR sending lsa. Tried sending %d bytes but rc=%d", buflen, rc); -// rc = -1; -// } + msg.SerializeToString(&message); -// return rc; -// } + return message; +} std::string XIAOverlayRouted::sendHello() @@ -452,7 +445,89 @@ XIAOverlayRouted::sendHello() return message; } -void XIAOverlayRouted::push(int port, Packet *p_in) +int +XIAOverlayRouted::processLSA(const Xroute::XrouteMsg &msg) { + + string neighborAD, neighborHID, myAD; + string destAD, destHID; + + // fix me once we don't need to rebroadcast the lsa + const Xroute::LSAMsg& lsa = msg.lsa(); + + Xroute::XID a = lsa.node().ad(); + + Node ad(a.type(), a.id().c_str(), 0); + + destAD = ad.to_string(); + printf("\n\nIn processLSA with destAD %s\n", destAD.c_str()); + // FIXME: this only allows for a single dual stack router in the network + if (lsa.flags() & F_IP_GATEWAY) { + route_state.dual_router_AD = destAD; + } + + if (destAD.compare(route_state.myAD) == 0) { + // skip if from me + return 1; + } + + printf("In processLSA\n"); + + map::iterator it = route_state.networkTable.find(destAD); + if(it != route_state.networkTable.end()) { + // For now, delete this dest AD entry in networkTable + // (... we will re-insert the updated entry shortly) + route_state.networkTable.erase (it); + } + + // don't bother if there's nothing there??? + if (lsa.peers_size() == 0) { + return 1; + } + + + // 2. Update the network table + NodeStateEntry entry; + entry.dest = destAD; + entry.num_neighbors = lsa.peers_size(); + + for (int i = 0; i < lsa.peers_size(); i++) { + + Node a(lsa.peers(i).ad().type(), lsa.peers(i).ad().id().c_str(), 0); +// Node h(lsa.peers(i).hid().type(), lsa.peers(i).hid().id().c_str(), 0); + + neighborAD = a.to_string(); +// neighborHID = h.to_string(); + + // fill the neighbors into the corresponding networkTable entry + entry.neighbor_list.push_back(neighborAD); + printf("Adding neighbor entry %s\n", neighborAD.c_str()); + } + + route_state.networkTable[destAD] = entry; + + + // printf("LSA received src=%s, num_neighbors=%d \n", + // (route_state.networkTable[destAD].dest).c_str(), + // route_state.networkTable[destAD].num_neighbors ); + + + // route_state.calc_dijstra_ticks++; + + // if (route_state.calc_dijstra_ticks == CALC_DIJKSTRA_INTERVAL) { + // // Calculate Shortest Path algorithm + // syslog(LOG_DEBUG, "Calcuating shortest paths\n"); + // calcShortestPath(); + // route_state.calc_dijstra_ticks = 0; + + // // update Routing table (click routing table as well) + // updateClickRoutingTable(); + // } + + return 1; +} + +void +XIAOverlayRouted::push(int port, Packet *p_in) { struct click_ip *ip; struct click_udp *udp; @@ -474,7 +549,9 @@ void XIAOverlayRouted::push(int port, Packet *p_in) printf("Received hello message from %s\n",inet_ntoa(ip->ip_src)); } else if(xmsg.type() == Xroute::LSA_MSG) { - ; + printf("Received LSA_MSG from %s\n", inet_ntoa(ip->ip_src)); + processLSA(xmsg); + // 5. rebroadcast this LSA } else { printf("Unknown msg type \n"); @@ -482,7 +559,9 @@ void XIAOverlayRouted::push(int port, Packet *p_in) } } - std::string msg = sendHello(); + // std::string msg = sendHello(); + std::string msg = sendLSA(); + c++; size_t qsize = sizeof(*ip) + sizeof(*udp) + msg.length(); @@ -502,12 +581,12 @@ void XIAOverlayRouted::push(int port, Packet *p_in) ip->ip_ttl = 255; ip->ip_p = IP_PROTO_UDP; ip->ip_sum = 0; - struct in_addr *saddr = (struct in_addr *)malloc(sizeof(struct in_addr)); + // struct in_addr *saddr = (struct in_addr *)malloc(sizeof(struct in_addr)); struct in_addr *daddr = (struct in_addr *)malloc(sizeof(struct in_addr)); - assert(saddr); + // assert(saddr); assert(daddr); - inet_aton("10.0.1.128", saddr); - ip->ip_src = *saddr; + // inet_aton("10.0.1.128", saddr); + // ip->ip_src = *saddr; udp->uh_sport = htons(8772); udp->uh_dport = htons(8772); @@ -515,32 +594,17 @@ void XIAOverlayRouted::push(int port, Packet *p_in) q->set_ip_header(ip, ip->ip_hl << 2); - printf("\n**********************\n getting neighbors\n"); - // std::vector neighbors; - // getNeighbors(neighbors); - // // for(int i=0; iip_dst = *daddr; - // q->set_dst_ip_anno(IPAddress(*daddr)); - // SET_DST_PORT_ANNO(q, htons(8772)); - // pos = neighbors[i].find_first_of("-") + 1; - // std::string portstr(neighbors[i].c_str(), pos, neighbors[i].length() - pos); - // int port = std::stoi(portstr); - // printf("Port %d\n", port); - - // printf("XIAOverlayRouted: Pushing packet len %d to %s\n", q->length(), inet_ntoa(*daddr)); - // output(port).push(q); - // } - // + + if(c>1) { + output(port).push(q); + return; + } + + printf("\n**********************\n getting neighbors c :%d\n", c); std::map::iterator it; for(it=route_state.neighborTable.begin(); it != route_state.neighborTable.end(); it++) { - String dst(it->first.c_str()); + String dst(it->second->addr.c_str()); printf("dst : %s\n", dst.c_str()); inet_aton(dst.c_str(), daddr); diff --git a/click/elements/xia/xiaoverlayrouted.hh b/click/elements/xia/xiaoverlayrouted.hh index 426a2b1ff..d8b9af0b5 100644 --- a/click/elements/xia/xiaoverlayrouted.hh +++ b/click/elements/xia/xiaoverlayrouted.hh @@ -168,6 +168,7 @@ protected: RouteState route_state; // XIARouter xr; String _hostname; + int c; public: @@ -180,6 +181,9 @@ public: void push(int, Packet *); std::string sendHello(); + std::string sendLSA(); + int processLSA(const Xroute::XrouteMsg &msg); + // int getNeighbors(std::vector &neighbors); }; diff --git a/click/elements/xia/xiaxidroutetable.cc b/click/elements/xia/xiaxidroutetable.cc index 74f84a347..7f899029d 100644 --- a/click/elements/xia/xiaxidroutetable.cc +++ b/click/elements/xia/xiaxidroutetable.cc @@ -416,12 +416,12 @@ XIAXIDRouteTable::set_udpnext(const String &conf, Element *e, void *thunk, Error String rname = "rd/rd"; Element *re = e->router()->find(rname); if(re) { - if(HandlerCall::call_write(re, "neighbor", - ipaddrstr + "," + ad + "," + sid + "," + portstr)) { + String nentry(ipaddrstr + "," + ad + "," + sid + "," + std::to_string(port).c_str()); + if(HandlerCall::call_write(re, "neighbor", nentry)) { printf("Failed to write to xrouted\n"); } else { - printf("Written\n"); + printf("Written %s\n", nentry.c_str()); } } diff --git a/click/userlevel/xroute.proto b/click/userlevel/xroute.proto index 79f6eda20..5b9206b04 100644 --- a/click/userlevel/xroute.proto +++ b/click/userlevel/xroute.proto @@ -17,7 +17,7 @@ message XID { message Node { required XID ad = 1; - required XID hid = 2; + optional XID hid = 2; optional XID sid = 3; optional uint32 flags = 4; } From 0efa1b77a3ff73b2124cb0953a316175f703a40f Mon Sep 17 00:00:00 2001 From: mirrorZ Date: Tue, 16 Jun 2020 00:21:10 -0400 Subject: [PATCH 114/116] routing --- click/elements/xia/xiaoverlayrouted.cc | 634 ++++++++---------- click/elements/xia/xiaoverlayrouted.hh | 48 +- click/elements/xia/xiaxidroutetable.cc | 35 +- .../io_engine/driver/kcompat_ethtool.c | 2 +- tools/overlay/client.conf | 6 +- tools/overlay/demo.conf | 14 +- 6 files changed, 344 insertions(+), 395 deletions(-) diff --git a/click/elements/xia/xiaoverlayrouted.cc b/click/elements/xia/xiaoverlayrouted.cc index 10ff6b2c3..959aca2c2 100644 --- a/click/elements/xia/xiaoverlayrouted.cc +++ b/click/elements/xia/xiaoverlayrouted.cc @@ -41,236 +41,6 @@ CLICK_DECLS #define check_init() do { if (!_init) return init_err; } while (false); -// void XIARouter::close() -// { -// if (_connected) -// _cserr = _cs.close(); -// _connected = false; -// } - -// int XIARouter::version(std::string &ver) -// { -// if (!connected()) -// return XR_NOT_CONNECTED; - -// if ((_cserr = _cs.get_router_version(ver)) == 0) -// return XR_OK; -// return XR_CLICK_ERROR; -// } - -// int XIARouter::listRouters(std::vector &rlist) -// { -// vector elements; -// size_t n; - -// if (!connected()) -// return XR_NOT_CONNECTED; - -// if ((_cserr = _cs.get_config_el_names(elements)) != 0) -// return XR_CLICK_ERROR; - -// vector::iterator it; -// for (it = elements.begin(); it < elements.end(); it++) { - -// // cheap way of finding host and router devices, they both have a /xrc element -// if ((n = (*it).find("/xrc")) != string::npos) { -// rlist.push_back((*it).substr(0, n)); -// } -// } -// return 0; -// } - -// int XIARouter::getNeighbors(std::string xidtype, std::vector &neighbors) -// { -// if (!connected()) { -// return XR_NOT_CONNECTED; -// } - -// std::string table = _router + "/xrc/n/proc/rt_" + xidtype; - -// std::string neighborStr; -// if ((_cserr = _cs.read(table, "neighbor", neighborStr)) != 0) { -// printf("couldn't read\n"); -// return XR_CLICK_ERROR; -// } - -// std::string::size_type beg = 0; -// for (auto end = 0; (end = neighborStr.find(',', end)) != std::string::npos; ++end) -// { -// neighbors.push_back(neighborStr.substr(beg, end - beg)); -// beg = end + 1; -// } -// return 0; -// } - -// get the current set of route entries, return value is number of entries returned or < 0 on err -// int XIARouter::getRoutes(std::string xidtype, std::vector &xrt) -// { -// std::string result; -// vector lines; -// int n = 0; - -// if (!connected()) -// return XR_NOT_CONNECTED; - -// if (xidtype.length() == 0) -// return XR_INVALID_XID; - -// if (getRouter().length() == 0) -// return XR_ROUTER_NOT_SET; - -// std::string table = _router + "/xrc/n/proc/rt_" + xidtype; - -// if ((_cserr = _cs.read(table, "list", result)) != 0) -// return XR_CLICK_ERROR; - -// unsigned start = 0; -// unsigned current = 0; -// unsigned len = result.length(); -// string line; - -// xrt.clear(); -// while (current < len) { -// start = current; -// while (current < len && result[current] != '\n') { -// current++; -// } - -// if (start < current || current < len) { -// line = result.substr(start, current - start); - -// XIARouteEntry entry; -// unsigned start, next; -// string s; -// int port; - -// start = 0; -// next = line.find(","); -// entry.xid = line.substr(start, next - start); - -// start = next + 1; -// next = line.find(",", start); -// s = line.substr(start, next - start); -// port = atoi(s.c_str()); -// entry.port = port; - -// start = next + 1; -// next = line.find(",", start); -// entry.nextHop = line.substr(start, next - start); - -// start = next + 1; -// s = line.substr(start, line.length() - start); -// entry.flags = atoi(s.c_str()); - -// xrt.push_back(entry); -// n++; -// } -// current++; -// } - -// return n; -// } - -// std::string XIARouter::itoa(signed i) -// { -// std::string s; -// std::stringstream ss; - -// ss << i; -// s = ss.str(); -// return s; -// } - -// int XIARouter::updateRoute(string cmd, const std::string &xid, int port, const std::string &next, unsigned long flags) -// { -// string xidtype; -// string mutableXID(xid); -// size_t n; - -// if (!connected()) -// return XR_NOT_CONNECTED; - -// if (mutableXID.length() == 0) -// return XR_INVALID_XID; - -// if (next.length() > 0 && next.find(":") == string::npos) -// return XR_INVALID_XID; - -// n = mutableXID.find(":"); -// if (n == string::npos || n >= sizeof(xidtype)) -// return XR_INVALID_XID; - -// if (getRouter().length() == 0) -// return XR_ROUTER_NOT_SET; - -// xidtype = mutableXID.substr(0, n); - -// std::string table = _router + "/xrc/n/proc/rt_" + xidtype; - -// string default_xid("-"); -// if (mutableXID.compare(n+1, 1, default_xid) == 0) -// mutableXID = default_xid; - -// std::string entry; - -// // remove command only takes an xid -// if (cmd == "remove") -// entry = mutableXID; -// else -// entry = mutableXID + "," + itoa(port) + "," + next + "," + itoa(flags); - -// if ((_cserr = _cs.write(table, cmd, entry)) != 0) -// return XR_CLICK_ERROR; - -// return XR_OK; -// } - -// int XIARouter::addRoute(const std::string &xid, int port, const std::string &next, unsigned long flags) -// { -// return updateRoute("add4", xid, port, next, flags); -// } - -// int XIARouter::setRoute(const std::string &xid, int port, const std::string &next, unsigned long flags) -// { -// return updateRoute("set4", xid, port, next, flags); -// } - -// int XIARouter::delRoute(const std::string &xid) -// { -// string next = ""; -// return updateRoute("remove", xid, 0, next, 0); -// } - -// const char *XIARouter::cserror() -// { -// switch(_cserr) { -// case ControlSocketClient::no_err: -// return "no error"; -// case ControlSocketClient::sys_err: -// return "O/S or networking error, check errno for more information"; -// case ControlSocketClient::init_err: -// return "tried to perform operation on an unconfigured ControlSocketClient"; -// case ControlSocketClient::reinit_err: -// return "tried to re-configure the client before close()ing it"; -// case ControlSocketClient::no_element: -// return "specified element does not exist"; -// case ControlSocketClient::no_handler: -// return "specified handler does not exist"; -// case ControlSocketClient::handler_no_perm: -// return "router denied access to the specified handler"; -// case ControlSocketClient::handler_err: -// return "handler returned an error"; -// case ControlSocketClient::handler_bad_format: -// return "bad format in calling handler"; -// case ControlSocketClient::click_err: -// return "unexpected response or error from the router"; -// case ControlSocketClient::too_short: -// return "user buffer was too short"; -// } -// return "unknown"; -// } - - void XIAOverlayRouted::add_handlers() { @@ -323,41 +93,30 @@ XIAOverlayRouted::add_neighbor(const String &conf, Element *e, void *thunk, Erro return 0; } -// int -// XIAOverlayRouted::getNeighbors(std::vector &neighbors) -// { - -// for(int i=0; imutable_node(); - Xroute::XID *ad = node->mutable_ad(); - Xroute::XID *hid = node->mutable_hid(); - Xroute::XID *sid = node->mutable_sid(); - - msg.set_type(Xroute::HELLO_MSG); - msg.set_version(Xroute::XROUTE_PROTO_VERSION); - hello->set_flags(route_state.flags); - ad->set_type(n_ad.type()); - ad->set_id(n_ad.id(), XID_SIZE); - hid->set_type(n_hid.type()); - hid->set_id(n_hid.id(), XID_SIZE); - sid->set_type(n_sid.type()); - sid->set_id(n_sid.id(), XID_SIZE); - - - // printf("XIAOverlayRouted: %s\n", msg.DebugString().c_str()); - // printf("**** sending lsa with and num_neighbors %d \n", route_state.num_neighbors); - - msg.SerializeToString(&message); - return message; + int buflen, rc; + string message; + Node n_ad(route_state.myAD); + Node n_hid(route_state.myHID); + Node n_sid(SID_XOVERLAY); + + Xroute::XrouteMsg msg; + Xroute::HelloMsg *hello = msg.mutable_hello(); + Xroute::Node *node = hello->mutable_node(); + Xroute::XID *ad = node->mutable_ad(); + Xroute::XID *hid = node->mutable_hid(); + Xroute::XID *sid = node->mutable_sid(); + + msg.set_type(Xroute::HELLO_MSG); + msg.set_version(Xroute::XROUTE_PROTO_VERSION); + hello->set_flags(route_state.flags); + ad->set_type(n_ad.type()); + ad->set_id(n_ad.id(), XID_SIZE); + hid->set_type(n_hid.type()); + hid->set_id(n_hid.id(), XID_SIZE); + sid->set_type(n_sid.type()); + sid->set_id(n_sid.id(), XID_SIZE); + + msg.SerializeToString(&message); + return message; } int @@ -506,65 +261,233 @@ XIAOverlayRouted::processLSA(const Xroute::XrouteMsg &msg) { route_state.networkTable[destAD] = entry; - // printf("LSA received src=%s, num_neighbors=%d \n", - // (route_state.networkTable[destAD].dest).c_str(), - // route_state.networkTable[destAD].num_neighbors ); + printf("LSA received src=%s, num_neighbors=%d \n", + (route_state.networkTable[destAD].dest).c_str(), + route_state.networkTable[destAD].num_neighbors ); // route_state.calc_dijstra_ticks++; // if (route_state.calc_dijstra_ticks == CALC_DIJKSTRA_INTERVAL) { // // Calculate Shortest Path algorithm - // syslog(LOG_DEBUG, "Calcuating shortest paths\n"); - // calcShortestPath(); - // route_state.calc_dijstra_ticks = 0; + printf("Calcuating shortest paths\n"); + calcShortestPath(); + route_state.calc_dijstra_ticks = 0; - // // update Routing table (click routing table as well) - // updateClickRoutingTable(); + // update Routing table (click routing table as well) + updateClickRoutingTable(); // } return 1; } -void -XIAOverlayRouted::push(int port, Packet *p_in) -{ - struct click_ip *ip; - struct click_udp *udp; - - size_t a = sizeof(*ip) + sizeof(*udp); - printf("XIAOverlayRouted: received packet of %d\n", p_in->length()); - Xroute::XrouteMsg xmsg; - if(p_in->length() > a) { +void +XIAOverlayRouted::calcShortestPath() { - ip = (struct click_ip *) p_in->data(); - udp = (struct click_udp *) (ip + 1); - size_t mlen = p_in->length()-a; - string cs(((const char *)(udp + 1)), mlen); - if(!xmsg.ParseFromString(cs)) { - printf("XIAOverlayRouted : could not understand packet\n"); + // first, clear the current routing table + route_state.ADrouteTable.clear(); + + map::iterator it1; + for ( it1=route_state.networkTable.begin() ; it1 != route_state.networkTable.end();) { + + // filter out an abnormal case + if(it1->second.num_neighbors == 0 || (it1->second.dest).empty() ) { + route_state.networkTable.erase (it1++); + } else { + ++it1; } - else { - if(xmsg.type() == Xroute::HELLO_MSG) { - printf("Received hello message from %s\n",inet_ntoa(ip->ip_src)); + } + + + // work on a copy of the table + map table; + table = route_state.networkTable; + + for ( it1=route_state.networkTable.begin() ; it1 != route_state.networkTable.end(); it1++ ) { + // initialize the checking variable + it1->second.checked = false; + it1->second.cost = 10000000; + } + + // compute shortest path + // initialization + string myAD, tempAD; + myAD = route_state.myAD; + route_state.networkTable[myAD].checked = true; + route_state.networkTable[myAD].cost = 0; + table.erase(myAD); + + vector::iterator it2; + for ( it2=route_state.networkTable[myAD].neighbor_list.begin() ; it2 < route_state.networkTable[myAD].neighbor_list.end(); it2++ ) { + + tempAD = (*it2).c_str(); + route_state.networkTable[tempAD].cost = 1; + route_state.networkTable[tempAD].prevNode = myAD; + } + + // loop + while (!table.empty()) { + int minCost = 10000000; + string selectedAD, tmpAD; + for ( it1=table.begin() ; it1 != table.end(); it1++ ) { + tmpAD = it1->second.dest; + if (route_state.networkTable[tmpAD].cost < minCost) { + minCost = route_state.networkTable[tmpAD].cost; + selectedAD = tmpAD; } - else if(xmsg.type() == Xroute::LSA_MSG) { - printf("Received LSA_MSG from %s\n", inet_ntoa(ip->ip_src)); - processLSA(xmsg); - // 5. rebroadcast this LSA + } + if(selectedAD.empty()) { + return; + } + + table.erase(selectedAD); + route_state.networkTable[selectedAD].checked = true; + + for ( it2=route_state.networkTable[selectedAD].neighbor_list.begin() ; it2 < route_state.networkTable[selectedAD].neighbor_list.end(); it2++ ) { + tempAD = (*it2).c_str(); + if (route_state.networkTable[tempAD].checked != true) { + if (route_state.networkTable[tempAD].cost > route_state.networkTable[selectedAD].cost + 1) { + route_state.networkTable[tempAD].cost = route_state.networkTable[selectedAD].cost + 1; + route_state.networkTable[tempAD].prevNode = selectedAD; + } } - else { - printf("Unknown msg type \n"); + } + } + + string tempAD1, tempAD2; + int hop_count; + // set up the nexthop + for ( it1=route_state.networkTable.begin() ; it1 != route_state.networkTable.end(); it1++ ) { + + tempAD1 = it1->second.dest; + if ( myAD.compare(tempAD1) != 0 ) { + tempAD2 = tempAD1; + hop_count = 0; + while (route_state.networkTable[tempAD2].prevNode.compare(myAD)!=0 && hop_count < MAX_HOP_COUNT) { + tempAD2 = route_state.networkTable[tempAD2].prevNode; + hop_count++; + } + if(hop_count < MAX_HOP_COUNT) { + route_state.ADrouteTable[tempAD1].dest = tempAD1; + // route_state.ADrouteTable[tempAD1].nextHop = route_state.neighborTable[tempAD2].HID; + route_state.ADrouteTable[tempAD1].nextHop = route_state.neighborTable[tempAD2]->AD; + route_state.ADrouteTable[tempAD1].port = route_state.neighborTable[tempAD2]->port; } } } + // printRoutingTable(); +} - // std::string msg = sendHello(); - std::string msg = sendLSA(); - c++; +void +XIAOverlayRouted::updateClickRoutingTable() { + + int rc, port; + uint32_t flags; + string destXID, nexthopXID; + string default_AD("AD:-"), default_HID("HID:-"), default_4ID("IP:-"); + + map::iterator it1; + for ( it1=route_state.ADrouteTable.begin() ; it1 != route_state.ADrouteTable.end(); it1++ ) { + destXID = it1->second.dest; + nexthopXID = it1->second.nextHop; + port = it1->second.port; + flags = it1->second.flags; + + if ((rc = updateRoute("set4", destXID, port, nexthopXID, flags)) != 0) + printf("error setting route %d", rc); + + // set default AD for 4ID traffic + if (!(route_state.flags & F_IP_GATEWAY) && destXID.compare(route_state.dual_router_AD) == 0) { + if ((rc = updateRoute("set4", default_4ID, port, nexthopXID, flags)) != 0) + printf("error setting route %d", rc); + } + } + // listRoutes("AD"); + // listRoutes("HID"); +} + +String XIAOverlayRouted::itoa(signed i) +{ + std::string s; + std::stringstream ss; + + ss << i; + s = ss.str(); + return String(s.c_str()); +} + +int +XIAOverlayRouted::updateRoute(string cmd, const std::string &xid, int port, + const std::string &next, unsigned long flags) +{ + string xidtype; + string mutableXID(xid); + size_t n; + + if (mutableXID.length() == 0) + return 1; + + if (next.length() > 0 && next.find(":") == string::npos) + return 1; + + n = mutableXID.find(":"); + if (n == string::npos || n >= sizeof(xidtype)) + return 1; + + xidtype = mutableXID.substr(0, n); + + std::string table = std::string(_hostname.c_str()) + "/xrc/n/proc/rt_" + xidtype; + + string default_xid("-"); + if (mutableXID.compare(n+1, 1, default_xid) == 0) + mutableXID = default_xid; + + String entry; + + // remove command only takes an xid + if (cmd == "remove") + entry = mutableXID.c_str(); + else { + String sep(","); + entry = String(mutableXID.c_str()) + sep + itoa(port) + sep + String(next.c_str()) + sep + itoa(flags); + } + + Element *re = this->router()->find(String(table.c_str())); + if(re) { + int ret = HandlerCall::call_write(re, cmd.c_str(), entry); + if(ret) + { + printf("HandlerCall failed\n"); + return 2; + } + } + else { + printf("Element not found"); + return 2; + } + + return 0; +} + +void +XIAOverlayRouted::neighbor_broadcast(std::string msg) { + std::map::iterator it; + for(it=route_state.neighborTable.begin(); it != route_state.neighborTable.end(); it++) { + String dst(it->second->addr.c_str()); + int port = it->second->port; + _push_msg(msg, dst, port); + } +} + +void +XIAOverlayRouted::_push_msg(std::string msg, String dst, int port) { + + struct click_ip *ip; + struct click_udp *udp; size_t qsize = sizeof(*ip) + sizeof(*udp) + msg.length(); + WritablePacket *q = Packet::make(qsize); memset(q->data(), '0', q->length()); ip = (struct click_ip *) q->data(); @@ -581,6 +504,8 @@ XIAOverlayRouted::push(int port, Packet *p_in) ip->ip_ttl = 255; ip->ip_p = IP_PROTO_UDP; ip->ip_sum = 0; + + //todo: fill source address // struct in_addr *saddr = (struct in_addr *)malloc(sizeof(struct in_addr)); struct in_addr *daddr = (struct in_addr *)malloc(sizeof(struct in_addr)); // assert(saddr); @@ -588,6 +513,7 @@ XIAOverlayRouted::push(int port, Packet *p_in) // inet_aton("10.0.1.128", saddr); // ip->ip_src = *saddr; + //todo: make this configurable udp->uh_sport = htons(8772); udp->uh_dport = htons(8772); udp->uh_ulen = htons(msg.length()); @@ -595,29 +521,63 @@ XIAOverlayRouted::push(int port, Packet *p_in) q->set_ip_header(ip, ip->ip_hl << 2); + inet_aton(dst.c_str(), daddr); + ip->ip_dst = *daddr; + q->set_dst_ip_anno(IPAddress(*daddr)); + SET_DST_PORT_ANNO(q, htons(8772)); + // int port = it->second->port; + printf("XIAOverlayRouted: Pushing packet len %d to %s, port :%d\n", + q->length(), inet_ntoa(*daddr), port); + output(port).push(q); + +} + +void +XIAOverlayRouted::push(int port, Packet *p_in) +{ + struct click_ip *ip; + struct click_udp *udp; + + size_t a = sizeof(*ip) + sizeof(*udp); + printf("XIAOverlayRouted: received packet of %d\n", p_in->length()); + Xroute::XrouteMsg xmsg; + if(p_in->length() > a) { + + ip = (struct click_ip *) p_in->data(); + udp = (struct click_udp *) (ip + 1); + size_t mlen = p_in->length()-a; + string cs(((const char *)(udp + 1)), mlen); + if(!xmsg.ParseFromString(cs)) { + printf("XIAOverlayRouted : could not understand packet\n"); + } + else { + if(xmsg.type() == Xroute::HELLO_MSG) { + printf("Received hello message from %s\n",inet_ntoa(ip->ip_src)); + } + else if(xmsg.type() == Xroute::LSA_MSG) { + printf("Received LSA_MSG from %s\n", inet_ntoa(ip->ip_src)); + processLSA(xmsg); + // 5. rebroadcast this LSA + } + else { + printf("Unknown msg type \n"); + } + } + } + + // std::string msg = sendHello(); + std::string msg = sendLSA(); + c++; + if(c>1) { + WritablePacket *q = Packet::make(1); output(port).push(q); return; } printf("\n**********************\n getting neighbors c :%d\n", c); - std::map::iterator it; - for(it=route_state.neighborTable.begin(); it != route_state.neighborTable.end(); it++) { - String dst(it->second->addr.c_str()); - - printf("dst : %s\n", dst.c_str()); - inet_aton(dst.c_str(), daddr); - ip->ip_dst = *daddr; - q->set_dst_ip_anno(IPAddress(*daddr)); - SET_DST_PORT_ANNO(q, htons(8772)); - int port = it->second->port; - printf("Port %d\n", port); - - printf("XIAOverlayRouted: Pushing packet len %d to %s\n", q->length(), inet_ntoa(*daddr)); - output(port).push(q); - - } + neighbor_broadcast(msg); printf("\n**********************\n"); diff --git a/click/elements/xia/xiaoverlayrouted.hh b/click/elements/xia/xiaoverlayrouted.hh index d8b9af0b5..8ce6fdc59 100644 --- a/click/elements/xia/xiaoverlayrouted.hh +++ b/click/elements/xia/xiaoverlayrouted.hh @@ -123,7 +123,6 @@ typedef struct { int32_t port; // interface (outgoing port) } NeighborEntry; - typedef struct { std::string dest; // destination AD or HID int32_t num_neighbors; // number of neighbors of dest AD @@ -135,6 +134,7 @@ typedef struct { } NodeStateEntry; // extracted from incoming LSA + typedef struct RouteState { int32_t sock; // socket for routing process @@ -160,32 +160,40 @@ typedef struct RouteState { class XIAOverlayRouted : public Element { -void add_handlers(); + void add_handlers(); + String itoa(signed i); + std::string sendHello(); + std::string sendLSA(); + int processLSA(const Xroute::XrouteMsg &msg); + void updateClickRoutingTable(); + int updateRoute(string cmd, const std::string &xid, int port, + const std::string &next, unsigned long flags); + void calcShortestPath(); + void neighbor_broadcast(std::string msg); + void _push_msg(std::string msg, String dst, int port); -protected: - static int add_neighbor(const String &conf, Element *e, void *thunk, ErrorHandler *errh); + protected: + static int add_neighbor(const String &conf, Element *e, void *thunk, ErrorHandler *errh); - RouteState route_state; - // XIARouter xr; - String _hostname; - int c; - -public: + RouteState route_state; + // XIARouter xr; + String _hostname; + int c; + + public: - XIAOverlayRouted(); - ~XIAOverlayRouted(); + XIAOverlayRouted(); + ~XIAOverlayRouted(); - const char *class_name() const { return "XIAOverlayRouted"; } - const char *port_count() const { return "1/4"; } - const char *processing() const { return PUSH; } + const char *class_name() const { return "XIAOverlayRouted"; } + const char *port_count() const { return "1/4"; } + const char *processing() const { return PUSH; } + + void push(int, Packet *); - void push(int, Packet *); - std::string sendHello(); - std::string sendLSA(); - int processLSA(const Xroute::XrouteMsg &msg); - // int getNeighbors(std::vector &neighbors); + // int getNeighbors(std::vector &neighbors); }; CLICK_ENDDECLS diff --git a/click/elements/xia/xiaxidroutetable.cc b/click/elements/xia/xiaxidroutetable.cc index 7f899029d..6acbe1697 100644 --- a/click/elements/xia/xiaxidroutetable.cc +++ b/click/elements/xia/xiaxidroutetable.cc @@ -293,8 +293,6 @@ XIAXIDRouteTable::add_ip_handler(const String &conf, Element *e, void *thunk, Er HashTable::iterator it = table->_nts.find(ipstr); XIAXIDAddr *n; if(it == table->_nts.end()) { - printf("XIAXIDNeighbor: %s does not exist in HT %d \n", - ipstr.c_str(), table->_nts.size()); n = new XIAXIDAddr(); table->_nts[ipstr] = n; } @@ -326,7 +324,7 @@ XIAXIDRouteTable::set_udpnext(const String &conf, Element *e, void *thunk, Error { XIAXIDRouteTable* table = static_cast(e); - printf("******called %s table : %lld\n", __FUNCTION__, (unsigned long)table); + // printf("******called %s table : %lld\n", __FUNCTION__, (unsigned long)table); bool add_mode = !thunk; Vector args; int port = 0; @@ -361,7 +359,7 @@ XIAXIDRouteTable::set_udpnext(const String &conf, Element *e, void *thunk, Error String ename = table->_hostname + String("/xrc/n/proc/rt_IP"); Element *ne = e->router()->find(ename); if(ne) { - printf("XIAXIDRoutetable: Calling write\n"); + printf("XIAXIDRoutetable: Calling write \n"); int ret = HandlerCall::call_write(ne, "addIP", ipaddrstr + "," + xid_str); if (ret) return errh->error("Failed to call write\n"); @@ -381,10 +379,10 @@ XIAXIDRouteTable::set_udpnext(const String &conf, Element *e, void *thunk, Error printf("XIAXIDRouteTable: Going into the neighbor block \n"); if(flags == NEIGHBOR) { - Vector ve = e->router()->elements(); - for(int i=0; iname().c_str()); - } + // Vector ve = e->router()->elements(); + // for(int i=0; iname().c_str()); + // } String ename = table->_hostname + String("/xrc/n/proc/rt_IP"); Element *ne = e->router()->find(ename); @@ -425,29 +423,10 @@ XIAXIDRouteTable::set_udpnext(const String &conf, Element *e, void *thunk, Error } } - } else { printf("Element %s not found \n", ename.c_str()); - } - // XIAXIDNeighbor *neighbor = (XIAXIDNeighbor *)malloc(sizeof(XIAXIDNeighbor)); - // if(!neighbor) { - // printf("XIAXIDRouteTable: allocation failed\n"); - // } - // String *s = new String(ipaddrstr + ":" + portstr); - // neighbor->addr = s; - // neighbor->iface = port; - // printf("XIAXIDRouteTable: Adding neighbor %s at port %d\n", (*(neighbor->addr)).c_str(), - // neighbor->iface); - // table->_ntable.push_back(neighbor); - // printf("XIAXIDRoutable: Pushed %s\n", (*(table->_ntable[0]->addr)).c_str()); - // // table->_ntable.count += 1; - // printf("XIAXIDRouteTable: neighbor count %ld \n", table->_ntable.size()); - // - // - // printf("neighbor entry found %s %s %s %s\n", ipaddrstr.c_str(), - // table->_nts[ipaddrstr]->AD->c_str(), table->_nts[ipaddrstr]->HID->c_str(), table->_nts[ipaddrstr]->SID->c_str()); - + } } } diff --git a/experiments/io_engine/driver/kcompat_ethtool.c b/experiments/io_engine/driver/kcompat_ethtool.c index 388fb21e6..a8fd8883f 100644 --- a/experiments/io_engine/driver/kcompat_ethtool.c +++ b/experiments/io_engine/driver/kcompat_ethtool.c @@ -1,4 +1,4 @@ -/******************************************************************************* +leme/******************************************************************************* Intel 10 Gigabit PCI Express Linux driver Copyright(c) 1999 - 2009 Intel Corporation. diff --git a/tools/overlay/client.conf b/tools/overlay/client.conf index f26400a40..b414f0920 100644 --- a/tools/overlay/client.conf +++ b/tools/overlay/client.conf @@ -11,8 +11,10 @@ ServerDag = RE AID:69a4e068880cd40549405dfda6e794b0c7fdf192 AID = AID:69a4e068880cd40549405dfda6e794b0c7fdf195 ControlAddress = 10.0.1.130 ControlPort = 8295 -Routers = r1,r3 -Interfaces = ens40,ens41 +# Routers = r1,r3 +# Interfaces = ens40,ens41 +Routers = r1 +Interfaces = ens40 Default = r1 ServerDag = RE AD:1ff8cb8d5d0afeee9e3af7dfc0099a52e4764916 HID:c71d04d17f225ffc71ba6bf31a673e51386c533c AID:69a4e068880cd40549405dfda6e794b0c7fdf192 Mobile = true diff --git a/tools/overlay/demo.conf b/tools/overlay/demo.conf index 2bce1d84e..ca7f2bd1d 100644 --- a/tools/overlay/demo.conf +++ b/tools/overlay/demo.conf @@ -5,7 +5,7 @@ HostInterface = ens35 HostAddr = 10.0.2.128 NameServer = true Route_r2 = ens39 -> ens34:r2 -# Route_r3 = ens40 -> ens39:r3 +Route_r3 = ens40 -> ens39:r3 [r2] ControlAddress = 10.0.1.130 @@ -15,10 +15,10 @@ HostAddr = 10.0.4.129 Route_r1 = ens34 -> ens39:r1 # Route_r3 = ens41 -> ens40:r3 -# [r3] -# ControlAddress = 10.0.1.134 -# Interfaces = ens38,ens39,ens40,ens41 -# HostInterface = ens41 -# HostAddr = 10.0.3.134 -# Route_r1 = ens39 -> ens40:r1 +[r3] +ControlAddress = 10.0.1.132 +Interfaces = ens38,ens39,ens40,ens41 +HostInterface = ens41 +HostAddr = 10.0.3.134 +Route_r1 = ens39 -> ens40:r1 # Route_r2 = ens40 -> ens41:r2 From 58a4942fc5936363b54e476b85c300ec280392be Mon Sep 17 00:00:00 2001 From: mirrorZ Date: Tue, 16 Jun 2020 02:00:48 -0400 Subject: [PATCH 115/116] Add events conf --- click/elements/xia/xiaoverlayrouted.cc | 16 ++++++++++- click/elements/xia/xiaoverlayrouted.hh | 39 +------------------------- click/elements/xia/xiaxidroutetable.hh | 1 + tools/overlay/events.conf | 10 +++++++ 4 files changed, 27 insertions(+), 39 deletions(-) create mode 100644 tools/overlay/events.conf diff --git a/click/elements/xia/xiaoverlayrouted.cc b/click/elements/xia/xiaoverlayrouted.cc index 959aca2c2..f90ce1b47 100644 --- a/click/elements/xia/xiaoverlayrouted.cc +++ b/click/elements/xia/xiaoverlayrouted.cc @@ -375,7 +375,18 @@ XIAOverlayRouted::calcShortestPath() { } } } - // printRoutingTable(); + printRoutingTable(); +} + +void +XIAOverlayRouted::printRoutingTable() { + + printf("AD Routing table at %s", route_state.myAD); + map::iterator it1; + for ( it1=route_state.ADrouteTable.begin() ; it1 != route_state.ADrouteTable.end(); it1++ ) { + printf("Dest=%s, NextHop=%s, Port=%d, Flags=%u", (it1->second.dest).c_str(), + (it1->second.nextHop).c_str(), (it1->second.port), (it1->second.flags) ); + } } @@ -437,6 +448,7 @@ XIAOverlayRouted::updateRoute(string cmd, const std::string &xid, int port, xidtype = mutableXID.substr(0, n); + std::string table = std::string(_hostname.c_str()) + "/xrc/n/proc/rt_" + xidtype; string default_xid("-"); @@ -453,6 +465,8 @@ XIAOverlayRouted::updateRoute(string cmd, const std::string &xid, int port, entry = String(mutableXID.c_str()) + sep + itoa(port) + sep + String(next.c_str()) + sep + itoa(flags); } + printf("\nXIAOverlayRouted: updateRoute for %s \n",entry.c_str()); + Element *re = this->router()->find(String(table.c_str())); if(re) { int ret = HandlerCall::call_write(re, cmd.c_str(), entry); diff --git a/click/elements/xia/xiaoverlayrouted.hh b/click/elements/xia/xiaoverlayrouted.hh index 8ce6fdc59..067a831f6 100644 --- a/click/elements/xia/xiaoverlayrouted.hh +++ b/click/elements/xia/xiaoverlayrouted.hh @@ -69,44 +69,6 @@ typedef struct { unsigned long flags; } XIARouteEntry; -// class XIARouter { -// public: -// XIARouter(const char *_rtr = "router0") { _connected = false; -// _cserr = ControlSocketClient::no_err; _router = _rtr; }; -// ~XIARouter() { if (connected()) close(); }; - -// // connect to click -// int connect(std::string clickHost = "localhost", unsigned short controlPort = 7777); -// int connected() { return _connected; }; -// void close(); - -// // returns the click version in -// int version(std::string &ver); - -// // return a vector of router devices click knows about (host0, router1, ....) -// int listRouters(std::vector &rlist); - -// // specify which router to operate on, must be called before adding/removing routes -// // defaults to router0 -// void setRouter(std::string r) { _router = r; }; -// std::string getRouter() { return _router; }; - -// // get the current set of route entries, return value is number of entries returned or < 0 on err -// int getRoutes(std::string xidtype, std::vector &xrt); - -// // returns 0 success, < 0 on error -// int addRoute(const std::string &xid, int port, const std::string &next, unsigned long flags); -// int setRoute(const std::string &xid, int port, const std::string &next, unsigned long flags); -// int delRoute(const std::string &xid); -// int getNeighbors(std::string xidtype, std::vector &neighbors); - -// private: -// bool _connected; -// std::string _router; -// int updateRoute(std::string cmd, const std::string &xid, int port, const std::string &next, unsigned long flags); -// string itoa(signed); -// }; - typedef struct { std::string dest; // destination AD or HID std::string nextHop; // nexthop HID @@ -171,6 +133,7 @@ class XIAOverlayRouted : public Element { void calcShortestPath(); void neighbor_broadcast(std::string msg); void _push_msg(std::string msg, String dst, int port); + void printRoutingTable(); protected: static int add_neighbor(const String &conf, Element *e, void *thunk, ErrorHandler *errh); diff --git a/click/elements/xia/xiaxidroutetable.hh b/click/elements/xia/xiaxidroutetable.hh index 3cd564c27..0bcef2104 100644 --- a/click/elements/xia/xiaxidroutetable.hh +++ b/click/elements/xia/xiaxidroutetable.hh @@ -83,6 +83,7 @@ class XIAXIDRouteTable : public Element { public: int set_enabled(int e); int get_enabled(); + void printRoutingTable(); protected: int lookup_route(Packet *); diff --git a/tools/overlay/events.conf b/tools/overlay/events.conf new file mode 100644 index 000000000..d1832f251 --- /dev/null +++ b/tools/overlay/events.conf @@ -0,0 +1,10 @@ +[e1] +add_r1 = r2, r3 +add_r2 = r1 +add_r3 = r1 +duration = 20 + +[e2] +remove_r1 = r3 +remove_r3 = r1 +duration = 30 \ No newline at end of file From 9bdb52dfd16d4dbaf49197e93b25e1f8428b7203 Mon Sep 17 00:00:00 2001 From: mirrorZ Date: Tue, 16 Jun 2020 02:25:08 -0400 Subject: [PATCH 116/116] Cleanup --- README.md | 36 +++++++--------- bin/xroute | 2 +- click/elements/xia/xiaoverlayrouted.cc | 2 +- click/elements/xia/xiaxidroutetable.cc | 42 +++++++------------ daemons/common/XIARouter.cc | 23 ---------- daemons/common/XIARouter.hh | 1 - daemons/xrouted/xrouted.cc | 3 -- .../io_engine/driver/kcompat_ethtool.c | 2 +- tools/overlay/xiaconfighelper.py | 18 +------- 9 files changed, 34 insertions(+), 95 deletions(-) diff --git a/README.md b/README.md index 9c0e16775..9158a35fb 100644 --- a/README.md +++ b/README.md @@ -1,29 +1,30 @@ XIA-core ======= +[![Build Status](https://travis-ci.org/XIA-Project/xia-core.svg?branch=xia-v2)](https://travis-ci.org/XIA-Project/xia-core) We are proud to announce version 1.0 of XIA (eXpressive Internet Architecture). XIA (eXpressive Internet Architecture) is a joint research project between Carnegie Mellon University, Boston University, and the University of Wisconsin -at Madison. +at Madison. Information and papers on XIA are available on the [XIA project page](http://cs.cmu.edu/~xia) -XIA design information can be found on the [XIA Wiki](https://github.com/XIA-Project/xia-core/wiki). +XIA design information can be found on the [XIA Wiki](https://github.com/XIA-Project/xia-core/wiki). Information on building and using XIA is also available on the wiki. The main git branch will always contain the most recently released version of -XIA. Other branches will contain ongoing development or research projects and +XIA. Other branches will contain ongoing development or research projects and are not guaranteed to function correctly. If you are interested in using one of the other branches, contact us at the address above for status of the branch. Contact ------- -- Support and general XIA usage questions should be sent to the support email address . +- Support and general XIA usage questions should be sent to the support email address . This address is monitored by several of the XIA developers and we strive to respond in a timely fashion. -- [XIA-Users](https://mailman.srv.cs.cmu.edu/mailman/listinfo/xia-users) is an unmoderated general discussion mailing -list for XIA. Everyone is welcome to join and participate in the discussion, whether you are an XIA user or developer, -or are just curious about to know more about XIA. This is the place to post ideas, share problems and solutions, -and discuss the design and goals of XIA. -- [XIA-Announce](https://mailman.srv.cs.cmu.edu/mailman/listinfo/xia-announce) is a read-only list for announcements +- [XIA-Users](https://mailman.srv.cs.cmu.edu/mailman/listinfo/xia-users) is an unmoderated general discussion mailing +list for XIA. Everyone is welcome to join and participate in the discussion, whether you are an XIA user or developer, +or are just curious about to know more about XIA. This is the place to post ideas, share problems and solutions, +and discuss the design and goals of XIA. +- [XIA-Announce](https://mailman.srv.cs.cmu.edu/mailman/listinfo/xia-announce) is a read-only list for announcements of new XIA releases and events. This list is open to everyone. @@ -32,18 +33,13 @@ Related Projects - [Native Linux kernel implementation of XIA](https://github.com/AltraMayor/XIA-for-Linux) - [XIA Wireshark plugin](https://github.com/AltraMayor/XIA-for-Linux/wiki/Debugging-the-Linux-kernel#Wireshark_with_XIA_support) -Release 1.2 +Release 2.0 ----------- -* Intrinsic security for HID and SID principal types -* Mobility Support - - Active session migration - - Mobile service migration via rendezvous service. -* The xwrap interposition library now converts unmodified sockets applications to run over XIA (experimental) +* Intrinsic Security (add information) +* The xwrap interposition now converts unmodified sockets applications to run over XIA (experimental) * API changes - Non-blocking I/O is now supported - - The Xlisten call is no longer optional in server applications -* Syslog support in click and the daemon apps -* Many fixes + - The Xlisten call is required in server applications Release 1.1.1 ---------------- @@ -71,7 +67,7 @@ with Xcode 4.x. An update to the Click code will be required for use with Xcode * More compatability with Berleley sockets added to the Xsocket API. * Fixed routing issues that could occur between hosts in the same AD. * Many bug fixes. - + Release 1.0 ---------------- * Added support for 4IDs which gives XIA the ability to be encapsulated in IP @@ -92,7 +88,7 @@ such as PlanetLab. * Setting up an XIA network is more automated, for example, most nodes can be brought up with a single command. * Communication between the application level and Click has been changed so that -root access is no longer requried to run XIA. This allows XIA to be used on +root access is no longer requried to run XIA. This allows XIA to be used on PlanetLab nodes where root access is not available. * XIA now works on the latest releases of Fedora and Ubuntu. * Various bug fixes. diff --git a/bin/xroute b/bin/xroute index 049bbcf39..09227d28e 100755 --- a/bin/xroute +++ b/bin/xroute @@ -567,7 +567,7 @@ class XrouteApp: self.errorExit("port not specified") cmd = "%s/xrc/n/proc/rt_%s.set4 %s,%s,%s,%s" % (self.device, table, xid, port, nexthop, flags) - print("Writing %s" %cmd) + print cmd self.writeData(cmd) print "added route for %s:%s" % (table, self.config.getAlias(xid)) diff --git a/click/elements/xia/xiaoverlayrouted.cc b/click/elements/xia/xiaoverlayrouted.cc index f90ce1b47..e5c7e1e86 100644 --- a/click/elements/xia/xiaoverlayrouted.cc +++ b/click/elements/xia/xiaoverlayrouted.cc @@ -103,6 +103,7 @@ XIAOverlayRouted::XIAOverlayRouted() return; } char *hostname = (char *)malloc(32); + assert(hostname); char ad[100], hid[100], re[100]; fscanf(f,"%s %s %s %s", hostname, re, ad, hid); fclose(f); @@ -116,7 +117,6 @@ XIAOverlayRouted::XIAOverlayRouted() route_state.flags = F_EDGE_ROUTER; route_state.dual_router_AD = "NULL"; - assert(hostname); _hostname = String(hostname, strlen(hostname)); printf("\n----XIAOverlayRouted: Started with ad: %s hid: %s hostname: %s----\n", route_state.myAD, route_state.myHID, _hostname.c_str()); diff --git a/click/elements/xia/xiaxidroutetable.cc b/click/elements/xia/xiaxidroutetable.cc index 6acbe1697..a7390f73e 100644 --- a/click/elements/xia/xiaxidroutetable.cc +++ b/click/elements/xia/xiaxidroutetable.cc @@ -31,8 +31,15 @@ XIAXIDRouteTable::XIAXIDRouteTable(): _drops(0) { char *hostname = (char *)malloc(32); assert(hostname); - gethostname(hostname, 32); - _hostname = String(hostname, strlen(hostname)); + FILE *f = fopen("etc/address.conf", "r"); + if (!f) { + printf("Failed to open address.conf \n"); + return; + } + fscanf(f,"%s", hostname); + fclose(f); + + _hostname = String(hostname, strlen(hostname)); } XIAXIDRouteTable::~XIAXIDRouteTable() @@ -43,8 +50,6 @@ XIAXIDRouteTable::~XIAXIDRouteTable() int XIAXIDRouteTable::configure(Vector & /*conf*/, ErrorHandler * /*errh*/) { - //printf("XIAXIDRouteTable: configuring %s\n", this->name().c_str()); - _principal_type_enabled = 1; _rtdata.port = -1; @@ -87,7 +92,6 @@ XIAXIDRouteTable::add_handlers() String XIAXIDRouteTable::read_handler(Element *e, void *thunk) { - // printf("******called %s \n", __FUNCTION__); XIAXIDRouteTable *t = (XIAXIDRouteTable *) e; switch ((intptr_t)thunk) { case PRINCIPAL_TYPE_ENABLED: @@ -101,7 +105,6 @@ XIAXIDRouteTable::read_handler(Element *e, void *thunk) int XIAXIDRouteTable::write_handler(const String &str, Element *e, void *thunk, ErrorHandler * /*errh*/) { - // printf("******called %s \n", __FUNCTION__); XIAXIDRouteTable *t = (XIAXIDRouteTable *) e; switch ((intptr_t)thunk) { case PRINCIPAL_TYPE_ENABLED: @@ -115,7 +118,6 @@ void XIAXIDRouteTable::add_entry_to_tbl_str(Element *e, String& tbl, String xid, XIARouteData* xrd) { - // printf("******called %s \n", __FUNCTION__); // XID tbl += xid + ","; // port @@ -136,7 +138,6 @@ XIAXIDRouteTable::add_entry_to_tbl_str(Element *e, String& tbl, String xid, String XIAXIDRouteTable::list_routes_handler(Element *e, void *thunk) { - // printf("******called %s \n", __FUNCTION__); XIAXIDRouteTable* table = static_cast(e); XIARouteData *xrd = &table->_rtdata; @@ -172,7 +173,6 @@ int XIAXIDRouteTable::set_handler(const String &conf, Element *e, void *thunk, ErrorHandler *errh) { // handle older style route entries - // printf("******called %s \n", __FUNCTION__); String str_copy = conf; String xid_str = cp_shift_spacevec(str_copy); @@ -223,7 +223,6 @@ XIAXIDRouteTable::set_handler4(const String &conf, Element *e, void *thunk, Erro String nxthop = args[2]; // If nexthop is less than 40 chars, it is an IP:port if(nxthop.length() < CLICK_XIA_XID_ID_LEN*2) { - printf("XIAXIDRouteTable: Calling udpnext nts %lld\n", (unsigned long)&table->_nts); return set_udpnext(conf, e, thunk, errh); } nexthop = new XID; @@ -267,7 +266,6 @@ XIAXIDRouteTable::set_handler4(const String &conf, Element *e, void *thunk, Erro int XIAXIDRouteTable::add_ip_handler(const String &conf, Element *e, void *thunk, ErrorHandler *errh) { - printf("In add ip handler\n"); XIAXIDRouteTable* table = static_cast(e); Vector args; @@ -304,16 +302,16 @@ XIAXIDRouteTable::add_ip_handler(const String &conf, Element *e, void *thunk, Er if(xid_str.starts_with("AD")) { n->AD = s; - printf("Added AD for %s : %s\n", ipstr.c_str(), table->_nts[ipstr]->AD->c_str()); + printf("XIAXIDRouteTable: Added AD for %s : %s\n", ipstr.c_str(), table->_nts[ipstr]->AD->c_str()); } else if(xid_str.starts_with("HID")) { n->HID = s; - printf("Added HID for %s : %s\n", ipstr.c_str(), table->_nts[ipstr]->HID->c_str()); + printf("XIAXIDRouteTable: Added HID for %s : %s\n", ipstr.c_str(), table->_nts[ipstr]->HID->c_str()); } else if(xid_str.starts_with("SID")) { n->SID = s; - printf("Added SID for %s : %s\n", ipstr.c_str(), table->_nts[ipstr]->SID->c_str()); + printf("XIAXIDRouteTable: Added SID for %s : %s\n", ipstr.c_str(), table->_nts[ipstr]->SID->c_str()); } return 0; @@ -324,7 +322,6 @@ XIAXIDRouteTable::set_udpnext(const String &conf, Element *e, void *thunk, Error { XIAXIDRouteTable* table = static_cast(e); - // printf("******called %s table : %lld\n", __FUNCTION__, (unsigned long)table); bool add_mode = !thunk; Vector args; int port = 0; @@ -391,17 +388,14 @@ XIAXIDRouteTable::set_udpnext(const String &conf, Element *e, void *thunk, Error std::string rstr(result.c_str (), result.length()); std::string::size_type beg = 0; - printf("Returned %s\n", rstr.c_str()); String ad, sid; for (auto end = 0; (end = rstr.find(';', end)) != std::string::npos; end++) { std::string n(rstr.substr(beg, end - beg)); - printf("N : %s\n", n.c_str()); Vectorargs; String c(n.c_str()); cp_argvec(c, args); if(args.size() != 3) { - printf("List IP did not return all args %d\n", args.size()); return errh->error("Not all args"); } if(args[0].equals(ipaddrstr)) { @@ -416,16 +410,13 @@ XIAXIDRouteTable::set_udpnext(const String &conf, Element *e, void *thunk, Error if(re) { String nentry(ipaddrstr + "," + ad + "," + sid + "," + std::to_string(port).c_str()); if(HandlerCall::call_write(re, "neighbor", nentry)) { - printf("Failed to write to xrouted\n"); + return errh->error("Failed to write to xrouted"); } - else { - printf("Written %s\n", nentry.c_str()); - } } } else { - printf("Element %s not found \n", ename.c_str()); + return errh->error("Element not found : ", ename.c_str()); } } } @@ -481,7 +472,6 @@ XIAXIDRouteTable::set_udpnext(const String &conf, Element *e, void *thunk, Error int XIAXIDRouteTable::remove_handler(const String &xid_str, Element *e, void *, ErrorHandler *errh) { - // printf("******called %s \n", __FUNCTION__); XIAXIDRouteTable* table = static_cast(e); if (xid_str.length() == 0) @@ -522,7 +512,6 @@ XIAXIDRouteTable::remove_handler(const String &xid_str, Element *e, void *, Erro int XIAXIDRouteTable::load_routes_handler(const String &conf, Element *e, void *, ErrorHandler *errh) { - // printf("******called %s \n", __FUNCTION__); #if CLICK_USERLEVEL std::ifstream in_f(conf.c_str()); if (!in_f.is_open()) @@ -590,7 +579,6 @@ XIAXIDRouteTable::load_routes_handler(const String &conf, Element *e, void *, Er int XIAXIDRouteTable::generate_routes_handler(const String &conf, Element *e, void *, ErrorHandler *errh) { - // printf("******called %s \n", __FUNCTION__); #if CLICK_USERLEVEL XIAXIDRouteTable* table = dynamic_cast(e); #else @@ -688,7 +676,6 @@ XIAXIDRouteTable::generate_routes_handler(const String &conf, Element *e, void * void XIAXIDRouteTable::push(int /*in_ether_port*/, Packet *p) { - // printf("******called %s \n", __FUNCTION__); int port; //in_ether_port = XIA_PAINT_ANNO(p); @@ -763,7 +750,6 @@ XIAXIDRouteTable::push(int /*in_ether_port*/, Packet *p) int XIAXIDRouteTable::lookup_route(Packet *p) { - // printf("******called %s \n", __FUNCTION__); const struct click_xia* hdr = p->xia_header(); int last = hdr->last; if (last == LAST_NODE_DEFAULT) diff --git a/daemons/common/XIARouter.cc b/daemons/common/XIARouter.cc index 42b408536..d6b82c69b 100644 --- a/daemons/common/XIARouter.cc +++ b/daemons/common/XIARouter.cc @@ -69,29 +69,6 @@ int XIARouter::listRouters(std::vector &rlist) return 0; } -int XIARouter::getNeighbors(std::string xidtype, std::vector &neighbors) -{ - if (!connected()) - return XR_NOT_CONNECTED; - - std::string table = _router + "/xrc/n/proc/rt_" + xidtype; - - std::string neighborStr; - if ((_cserr = _cs.read(table, "neighbor", neighborStr)) != 0) - return XR_CLICK_ERROR; - - std::string::size_type beg = 0; - for (auto end = 0; (end = neighborStr.find(',', end)) != std::string::npos; ++end) - { - neighbors.push_back(neighborStr.substr(beg, end - beg)); - beg = end + 1; - } - - printf("Retuning neighbors\n"); - return 0; -} - - // get the current set of route entries, return value is number of entries returned or < 0 on err int XIARouter::getRoutes(std::string xidtype, std::vector &xrt) { diff --git a/daemons/common/XIARouter.hh b/daemons/common/XIARouter.hh index 3161b5e03..3a92b4b3e 100644 --- a/daemons/common/XIARouter.hh +++ b/daemons/common/XIARouter.hh @@ -89,7 +89,6 @@ public: int addRoute(const std::string &xid, int port, const std::string &next, unsigned long flags); int setRoute(const std::string &xid, int port, const std::string &next, unsigned long flags); int delRoute(const std::string &xid); - int getNeighbors(std::string xidtype, std::vector &neighbors); const char *cserror(); diff --git a/daemons/xrouted/xrouted.cc b/daemons/xrouted/xrouted.cc index ced98d9d0..3e21c63cb 100644 --- a/daemons/xrouted/xrouted.cc +++ b/daemons/xrouted/xrouted.cc @@ -80,9 +80,6 @@ int sendHello() sid->set_id(n_sid.id(), XID_SIZE); -// printf("sending %s\n", msg.DebugString().c_str()); - // printf("**** sending lsa with and num_neighbors %d \n", route_state.num_neighbors); - msg.SerializeToString(&message); buflen = message.length(); diff --git a/experiments/io_engine/driver/kcompat_ethtool.c b/experiments/io_engine/driver/kcompat_ethtool.c index a8fd8883f..388fb21e6 100644 --- a/experiments/io_engine/driver/kcompat_ethtool.c +++ b/experiments/io_engine/driver/kcompat_ethtool.c @@ -1,4 +1,4 @@ -leme/******************************************************************************* +/******************************************************************************* Intel 10 Gigabit PCI Express Linux driver Copyright(c) 1999 - 2009 Intel Corporation. diff --git a/tools/overlay/xiaconfighelper.py b/tools/overlay/xiaconfighelper.py index 591dca988..510fc98a3 100644 --- a/tools/overlay/xiaconfighelper.py +++ b/tools/overlay/xiaconfighelper.py @@ -29,23 +29,17 @@ class Helper(Int32StringReceiver): def __init__(self, common_data, addr): - print inspect.stack()[0][3] self.common_data = common_data self.addr = addr def connectionMade(self): - print inspect.stack()[0][3] self.sendString(xiaconfigdefs.HELPER_GREETING); - def connectionLost(self, reason): - print inspect.stack()[0][3] + def connectionLost(self, reason): # Clean up any state created in common_data for this connection print "Connection to client lost" def handleInterfaceRequest(self, request): - print inspect.stack()[0][3] - print "Got interface request" - # Fill in interface information for if_info in request.ifrequest.interfaces: if_info.ipaddr = interfaces.get_ip_addr(if_info.name) @@ -55,7 +49,6 @@ def handleInterfaceRequest(self, request): self.sendString(request.SerializeToString()) def handleRouterConfRequest(self, request): - print inspect.stack()[0][3] conf_file = os.path.join(xiapyutils.xia_srcdir(), ROUTER_CLICK) with open(conf_file, 'w') as config: config.write(request.routerconf.configfile) @@ -67,7 +60,6 @@ def handleRouterConfRequest(self, request): self.sendString(response.SerializeToString()) def handleRoutesRequest(self, request): - print inspect.stack()[0][3] print "Got IP routes to configure" for route_cmd in request.routes.route_cmds: print route_cmd @@ -76,7 +68,6 @@ def handleRoutesRequest(self, request): self.sendString(request.SerializeToString()) def getXcacheAID(self): - print inspect.stack()[0][3] with open("xcache.local.conf", 'r') as localconf: for line in localconf: if not line.startswith('XCACHE_AID'): @@ -89,13 +80,11 @@ def getXcacheAID(self): return '' def registerXcache(self, hostname, aid): - print inspect.stack()[0][3] print "Confighelper: registering Xcache" with ClickControl() as click: return click.assignXcacheAID(hostname, aid) def handleStartXcacheRequest(self, request): - print inspect.stack()[0][3] print "Got request to start Xcache", request.startxcache.command cwd = os.getcwd() os.chdir(picoquic_directory) @@ -112,7 +101,6 @@ def handleStartXcacheRequest(self, request): # Otherwise, this is a regular router that will be started with the # given resolv.conf file. Response will not have a resolv.conf def handleStartXIARequest(self, request): - print inspect.stack()[0][3] resolvconfreceived = False # If a resolv.conf was sent, write it to storage for router to use if len(request.startxia.resolvconf) > 0: @@ -147,7 +135,6 @@ def handleStartXIARequest(self, request): self.sendString(request.SerializeToString()) def handleGatherXIDsRequest(self, request): - print inspect.stack()[0][3] xdag_cmd = os.path.join(xiapyutils.xia_srcdir(), 'bin/xdag') xdag_out = subprocess.check_output(xdag_cmd, shell=True) router, re, ad, hid = xdag_out.split() @@ -156,7 +143,6 @@ def handleGatherXIDsRequest(self, request): self.sendString(request.SerializeToString()) def handleConfigRequest(self, request): - print inspect.stack()[0][3] if request.type == configrequest_pb2.Request.IFACE_INFO: self.handleInterfaceRequest(request) elif request.type == configrequest_pb2.Request.ROUTER_CONF: @@ -173,7 +159,6 @@ def handleConfigRequest(self, request): print "ERROR: Unknown config request" def stringReceived(self, request): - print inspect.stack()[0][3] #try: # Convert request into protobuf and handle the request conf_request = configrequest_pb2.Request() @@ -184,7 +169,6 @@ def stringReceived(self, request): #self.transport.loseConnection(); class HelperFactory(Factory): - def __init__(self): self.common_data = {}