diff --git a/CHANGELOG.md b/CHANGELOG.md index ce95c5fd..7a85ee34 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,17 @@ +## 2022-03-21 CORE 8.2.0 + +* core-gui + * improved failed starts to trigger runtime to allow node investigation +* core-daemon + * improved default service loading to use a full import path + * updated session instantiation to always set to a runtime state +* core-cli + * \#672 - fixed xml loading + * \#578 - restored json flag and added geo output to session overview +* Documentation + * updated emane example and documentation + * improved table markdown + ## 2022-02-18 CORE 8.1.0 * Installation diff --git a/Makefile.am b/Makefile.am index bd15cf09..83645c1b 100644 --- a/Makefile.am +++ b/Makefile.am @@ -6,10 +6,6 @@ if WANT_DOCS DOCS = docs man endif -if WANT_GUI - GUI = gui -endif - if WANT_DAEMON DAEMON = daemon endif @@ -19,7 +15,7 @@ if WANT_NETNS endif # keep docs last due to dependencies on binaries -SUBDIRS = $(GUI) $(DAEMON) $(NETNS) $(DOCS) +SUBDIRS = $(DAEMON) $(NETNS) $(DOCS) ACLOCAL_AMFLAGS = -I config @@ -115,7 +111,6 @@ $(info creating file $1 from $1.in) -e 's,[@]CORE_STATE_DIR[@],$(CORE_STATE_DIR),g' \ -e 's,[@]CORE_DATA_DIR[@],$(CORE_DATA_DIR),g' \ -e 's,[@]CORE_CONF_DIR[@],$(CORE_CONF_DIR),g' \ - -e 's,[@]CORE_GUI_CONF_DIR[@],$(CORE_GUI_CONF_DIR),g' \ < $1.in > $1 endef @@ -123,7 +118,6 @@ all: change-files .PHONY: change-files change-files: - $(call change-files,gui/core-gui-legacy) $(call change-files,daemon/core/constants.py) $(call change-files,netns/setup.py) diff --git a/bootstrap.sh b/bootstrap.sh index ab3d741c..25fdecfd 100755 --- a/bootstrap.sh +++ b/bootstrap.sh @@ -1,9 +1,5 @@ #!/bin/sh # -# (c)2010-2012 the Boeing Company -# -# author: Jeff Ahrenholz -# # Bootstrap the autoconf system. # diff --git a/configure.ac b/configure.ac index a3d61abc..ae652051 100644 --- a/configure.ac +++ b/configure.ac @@ -2,7 +2,7 @@ # Process this file with autoconf to produce a configure script. # this defines the CORE version number, must be static for AC_INIT -AC_INIT(core, 8.1.0) +AC_INIT(core, 8.2.0) # autoconf and automake initialization AC_CONFIG_SRCDIR([netns/version.h.in]) @@ -30,25 +30,14 @@ AC_SUBST(CORE_CONF_DIR) AC_SUBST(CORE_DATA_DIR) AC_SUBST(CORE_STATE_DIR) -# CORE GUI configuration files and preferences in CORE_GUI_CONF_DIR -# scenario files in ~/.core/configs/ -AC_ARG_WITH([guiconfdir], - [AS_HELP_STRING([--with-guiconfdir=dir], - [specify GUI configuration directory])], - [CORE_GUI_CONF_DIR="$with_guiconfdir"], - [CORE_GUI_CONF_DIR="\$\${HOME}/.core"]) -AC_SUBST(CORE_GUI_CONF_DIR) -AC_ARG_ENABLE([gui], - [AS_HELP_STRING([--enable-gui[=ARG]], - [build and install the GUI (default is yes)])], - [], [enable_gui=yes]) -AC_SUBST(enable_gui) +# documentation option AC_ARG_ENABLE([docs], [AS_HELP_STRING([--enable-docs[=ARG]], [build python documentation (default is no)])], [], [enable_docs=no]) AC_SUBST(enable_docs) +# python option AC_ARG_ENABLE([python], [AS_HELP_STRING([--enable-python[=ARG]], [build and install the python bindings (default is yes)])], @@ -94,27 +83,6 @@ if test "x$enable_daemon" = "xyes"; then want_python=yes want_linux_netns=yes - # Checks for libraries. - AC_CHECK_LIB([netgraph], [NgMkSockNode]) - - # Checks for header files. - AC_CHECK_HEADERS([arpa/inet.h fcntl.h limits.h stdint.h stdlib.h string.h sys/ioctl.h sys/mount.h sys/socket.h sys/time.h termios.h unistd.h]) - - # Checks for typedefs, structures, and compiler characteristics. - AC_C_INLINE - AC_TYPE_INT32_T - AC_TYPE_PID_T - AC_TYPE_SIZE_T - AC_TYPE_SSIZE_T - AC_TYPE_UINT32_T - AC_TYPE_UINT8_T - - # Checks for library functions. - AC_FUNC_FORK - AC_FUNC_MALLOC - AC_FUNC_REALLOC - AC_CHECK_FUNCS([atexit dup2 gettimeofday memset socket strerror uname]) - AM_PATH_PYTHON(3.6) AS_IF([$PYTHON -m grpc_tools.protoc -h &> /dev/null], [], [AC_MSG_ERROR([please install python grpcio-tools])]) @@ -171,6 +139,25 @@ fi if [ test "x$enable_daemon" = "xyes" || test "x$enable_vnodedonly" = "xyes" ] ; then want_linux_netns=yes + + # Checks for header files. + AC_CHECK_HEADERS([arpa/inet.h fcntl.h limits.h stdint.h stdlib.h string.h sys/ioctl.h sys/mount.h sys/socket.h sys/time.h termios.h unistd.h]) + + # Checks for typedefs, structures, and compiler characteristics. + AC_C_INLINE + AC_TYPE_INT32_T + AC_TYPE_PID_T + AC_TYPE_SIZE_T + AC_TYPE_SSIZE_T + AC_TYPE_UINT32_T + AC_TYPE_UINT8_T + + # Checks for library functions. + AC_FUNC_FORK + AC_FUNC_MALLOC + AC_FUNC_REALLOC + AC_CHECK_FUNCS([atexit dup2 gettimeofday memset socket strerror uname]) + PKG_CHECK_MODULES(libev, libev, AC_MSG_RESULT([found libev using pkgconfig OK]) AC_SUBST(libev_CFLAGS) @@ -209,7 +196,6 @@ if [test "x$want_python" = "xyes" && test "x$enable_docs" = "xyes"] ; then fi # Variable substitutions -AM_CONDITIONAL(WANT_GUI, test x$enable_gui = xyes) AM_CONDITIONAL(WANT_DAEMON, test x$enable_daemon = xyes) AM_CONDITIONAL(WANT_DOCS, test x$want_docs = xyes) AM_CONDITIONAL(WANT_PYTHON, test x$want_python = xyes) @@ -224,9 +210,6 @@ fi # Output files AC_CONFIG_FILES([Makefile - gui/version.tcl - gui/Makefile - gui/icons/Makefile man/Makefile docs/Makefile daemon/Makefile @@ -248,17 +231,12 @@ Build: Prefix: ${prefix} Exec Prefix: ${exec_prefix} -GUI: - GUI path: ${CORE_LIB_DIR} - GUI config: ${CORE_GUI_CONF_DIR} - Daemon: Daemon path: ${bindir} Daemon config: ${CORE_CONF_DIR} Python: ${PYTHON} Features to build: - Build GUI: ${enable_gui} Build Daemon: ${enable_daemon} Documentation: ${want_docs} diff --git a/daemon/Makefile.am b/daemon/Makefile.am index 7528dc01..79459b80 100644 --- a/daemon/Makefile.am +++ b/daemon/Makefile.am @@ -1,8 +1,4 @@ # CORE -# (c)2010-2012 the Boeing Company. -# See the LICENSE file included in this distribution. -# -# author: Jeff Ahrenholz # # Makefile for building netns components. # diff --git a/daemon/core/api/grpc/client.py b/daemon/core/api/grpc/client.py index e2e1e729..45af5728 100644 --- a/daemon/core/api/grpc/client.py +++ b/daemon/core/api/grpc/client.py @@ -16,7 +16,13 @@ from core.api.grpc.configservices_pb2 import ( GetConfigServiceDefaultsRequest, GetNodeConfigServiceRequest, ) -from core.api.grpc.core_pb2 import ExecuteScriptRequest, GetConfigRequest +from core.api.grpc.core_pb2 import ( + ExecuteScriptRequest, + GetConfigRequest, + LinkedRequest, + WirelessConfigRequest, + WirelessLinkedRequest, +) from core.api.grpc.emane_pb2 import ( EmaneLinkRequest, GetEmaneEventChannelRequest, @@ -43,6 +49,7 @@ from core.api.grpc.wlan_pb2 import ( WlanConfig, WlanLinkRequest, ) +from core.api.grpc.wrappers import LinkOptions from core.emulator.data import IpPrefixes from core.errors import CoreError @@ -1049,6 +1056,72 @@ class CoreGrpcClient: """ self.stub.EmanePathlosses(streamer.iter()) + def linked( + self, + session_id: int, + node1_id: int, + node2_id: int, + iface1_id: int, + iface2_id: int, + linked: bool, + ) -> None: + """ + Link or unlink an existing core wired link. + + :param session_id: session containing the link + :param node1_id: first node in link + :param node2_id: second node in link + :param iface1_id: node1 interface + :param iface2_id: node2 interface + :param linked: True to connect link, False to disconnect + :return: nothing + """ + request = LinkedRequest( + session_id=session_id, + node1_id=node1_id, + node2_id=node2_id, + iface1_id=iface1_id, + iface2_id=iface2_id, + linked=linked, + ) + self.stub.Linked(request) + + def wireless_linked( + self, + session_id: int, + wireless_id: int, + node1_id: int, + node2_id: int, + linked: bool, + ) -> None: + request = WirelessLinkedRequest( + session_id=session_id, + wireless_id=wireless_id, + node1_id=node1_id, + node2_id=node2_id, + linked=linked, + ) + self.stub.WirelessLinked(request) + + def wireless_config( + self, + session_id: int, + wireless_id: int, + node1_id: int, + node2_id: int, + options1: LinkOptions, + options2: LinkOptions = None, + ) -> None: + request = WirelessConfigRequest( + session_id=session_id, + wireless_id=wireless_id, + node1_id=node1_id, + node2_id=node2_id, + options1=options1.to_proto(), + options2=options2.to_proto(), + ) + self.stub.WirelessConfig(request) + def connect(self) -> None: """ Open connection to server, must be closed manually. diff --git a/daemon/core/api/grpc/events.py b/daemon/core/api/grpc/events.py index b319a978..b15862ac 100644 --- a/daemon/core/api/grpc/events.py +++ b/daemon/core/api/grpc/events.py @@ -3,7 +3,7 @@ from queue import Empty, Queue from typing import Iterable, Optional from core.api.grpc import core_pb2 -from core.api.grpc.grpcutils import convert_link +from core.api.grpc.grpcutils import convert_link_data from core.emulator.data import ( ConfigData, EventData, @@ -51,7 +51,7 @@ def handle_link_event(link_data: LinkData) -> core_pb2.Event: :param link_data: link data :return: link event that has message type and link information """ - link = convert_link(link_data) + link = convert_link_data(link_data) message_type = link_data.message_type.value link_event = core_pb2.LinkEvent(message_type=message_type, link=link) return core_pb2.Event(link_event=link_event, source=link_data.source) diff --git a/daemon/core/api/grpc/grpcutils.py b/daemon/core/api/grpc/grpcutils.py index c585a135..e2cba7e9 100644 --- a/daemon/core/api/grpc/grpcutils.py +++ b/daemon/core/api/grpc/grpcutils.py @@ -1,7 +1,7 @@ import logging import time from pathlib import Path -from typing import Any, Dict, List, Tuple, Type, Union +from typing import Any, Dict, List, Optional, Tuple, Type, Union import grpc from grpc import ServicerContext @@ -20,6 +20,7 @@ from core.config import ConfigurableOptions from core.emane.nodes import EmaneNet from core.emulator.data import InterfaceData, LinkData, LinkOptions, NodeOptions from core.emulator.enumerations import LinkTypes, NodeTypes +from core.emulator.links import CoreLink from core.emulator.session import Session from core.errors import CoreError from core.location.mobility import BasicRangeModel, Ns2ScriptedMobility @@ -27,7 +28,7 @@ from core.nodes.base import CoreNode, CoreNodeBase, NodeBase from core.nodes.docker import DockerNode from core.nodes.interface import CoreInterface from core.nodes.lxd import LxcNode -from core.nodes.network import CtrlNet, PtpNet, WlanNode +from core.nodes.network import CoreNetwork, CtrlNet, PtpNet, WlanNode from core.services.coreservices import CoreService logger = logging.getLogger(__name__) @@ -110,7 +111,7 @@ def link_iface(iface_proto: core_pb2.Interface) -> InterfaceData: def add_link_data( link_proto: core_pb2.Link -) -> Tuple[InterfaceData, InterfaceData, LinkOptions, LinkTypes]: +) -> Tuple[InterfaceData, InterfaceData, LinkOptions]: """ Convert link proto to link interfaces and options data. @@ -119,7 +120,6 @@ def add_link_data( """ iface1_data = link_iface(link_proto.iface1) iface2_data = link_iface(link_proto.iface2) - link_type = LinkTypes(link_proto.type) options = LinkOptions() options_proto = link_proto.options if options_proto: @@ -134,7 +134,7 @@ def add_link_data( options.buffer = options_proto.buffer options.unidirectional = options_proto.unidirectional options.key = options_proto.key - return iface1_data, iface2_data, options, link_type + return iface1_data, iface2_data, options def create_nodes( @@ -174,8 +174,8 @@ def create_links( for link_proto in link_protos: node1_id = link_proto.node1_id node2_id = link_proto.node2_id - iface1, iface2, options, link_type = add_link_data(link_proto) - args = (node1_id, node2_id, iface1, iface2, options, link_type) + iface1, iface2, options = add_link_data(link_proto) + args = (node1_id, node2_id, iface1, iface2, options) funcs.append((session.add_link, args, {})) start = time.monotonic() results, exceptions = utils.threadpool(funcs) @@ -198,8 +198,8 @@ def edit_links( for link_proto in link_protos: node1_id = link_proto.node1_id node2_id = link_proto.node2_id - iface1, iface2, options, link_type = add_link_data(link_proto) - args = (node1_id, node2_id, iface1.id, iface2.id, options, link_type) + iface1, iface2, options = add_link_data(link_proto) + args = (node1_id, node2_id, iface1.id, iface2.id, options) funcs.append((session.update_link, args, {})) start = time.monotonic() results, exceptions = utils.threadpool(funcs) @@ -344,61 +344,84 @@ def get_node_proto( ) -def get_links(node: NodeBase): +def get_links(session: Session, node: NodeBase) -> List[core_pb2.Link]: """ Retrieve a list of links for grpc to use. + :param session: session to get links for node :param node: node to get links from :return: protobuf links """ + link_protos = [] + for core_link in session.link_manager.node_links(node): + link_protos.extend(convert_core_link(core_link)) + if isinstance(node, (WlanNode, EmaneNet)): + for link_data in node.links(): + link_protos.append(convert_link_data(link_data)) + return link_protos + + +def convert_iface(iface: CoreInterface) -> core_pb2.Interface: + """ + Convert interface to protobuf. + + :param iface: interface to convert + :return: protobuf interface + """ + if isinstance(iface.node, CoreNetwork): + return core_pb2.Interface(id=iface.id) + else: + ip4 = iface.get_ip4() + ip4_mask = ip4.prefixlen if ip4 else None + ip4 = str(ip4.ip) if ip4 else None + ip6 = iface.get_ip6() + ip6_mask = ip6.prefixlen if ip6 else None + ip6 = str(ip6.ip) if ip6 else None + mac = str(iface.mac) if iface.mac else None + return core_pb2.Interface( + id=iface.id, + name=iface.name, + mac=mac, + ip4=ip4, + ip4_mask=ip4_mask, + ip6=ip6, + ip6_mask=ip6_mask, + ) + + +def convert_core_link(core_link: CoreLink) -> List[core_pb2.Link]: + """ + Convert core link to protobuf data. + + :param core_link: core link to convert + :return: protobuf link data + """ links = [] - for link in node.links(): - link_proto = convert_link(link) - links.append(link_proto) + node1, iface1 = core_link.node1, core_link.iface1 + node2, iface2 = core_link.node2, core_link.iface2 + unidirectional = core_link.is_unidirectional() + link = convert_link(node1, iface1, node2, iface2, iface1.options, unidirectional) + links.append(link) + if unidirectional: + link = convert_link( + node2, iface2, node1, iface1, iface2.options, unidirectional + ) + links.append(link) return links -def convert_iface(iface_data: InterfaceData) -> core_pb2.Interface: - return core_pb2.Interface( - id=iface_data.id, - name=iface_data.name, - mac=iface_data.mac, - ip4=iface_data.ip4, - ip4_mask=iface_data.ip4_mask, - ip6=iface_data.ip6, - ip6_mask=iface_data.ip6_mask, - ) - - -def convert_link_options(options_data: LinkOptions) -> core_pb2.LinkOptions: - return core_pb2.LinkOptions( - jitter=options_data.jitter, - key=options_data.key, - mburst=options_data.mburst, - mer=options_data.mer, - loss=options_data.loss, - bandwidth=options_data.bandwidth, - burst=options_data.burst, - delay=options_data.delay, - dup=options_data.dup, - buffer=options_data.buffer, - unidirectional=options_data.unidirectional, - ) - - -def convert_link(link_data: LinkData) -> core_pb2.Link: +def convert_link_data(link_data: LinkData) -> core_pb2.Link: """ Convert link_data into core protobuf link. - :param link_data: link to convert :return: core protobuf Link """ iface1 = None if link_data.iface1 is not None: - iface1 = convert_iface(link_data.iface1) + iface1 = convert_iface_data(link_data.iface1) iface2 = None if link_data.iface2 is not None: - iface2 = convert_iface(link_data.iface2) + iface2 = convert_iface_data(link_data.iface2) options = convert_link_options(link_data.options) return core_pb2.Link( type=link_data.type.value, @@ -413,6 +436,89 @@ def convert_link(link_data: LinkData) -> core_pb2.Link: ) +def convert_iface_data(iface_data: InterfaceData) -> core_pb2.Interface: + """ + Convert interface data to protobuf. + + :param iface_data: interface data to convert + :return: interface protobuf + """ + return core_pb2.Interface( + id=iface_data.id, + name=iface_data.name, + mac=iface_data.mac, + ip4=iface_data.ip4, + ip4_mask=iface_data.ip4_mask, + ip6=iface_data.ip6, + ip6_mask=iface_data.ip6_mask, + ) + + +def convert_link_options(options: LinkOptions) -> core_pb2.LinkOptions: + """ + Convert link options to protobuf. + + :param options: link options to convert + :return: link options protobuf + """ + return core_pb2.LinkOptions( + jitter=options.jitter, + key=options.key, + mburst=options.mburst, + mer=options.mer, + loss=options.loss, + bandwidth=options.bandwidth, + burst=options.burst, + delay=options.delay, + dup=options.dup, + buffer=options.buffer, + unidirectional=options.unidirectional, + ) + + +def convert_link( + node1: NodeBase, + iface1: Optional[CoreInterface], + node2: NodeBase, + iface2: Optional[CoreInterface], + options: LinkOptions, + unidirectional: bool, +) -> core_pb2.Link: + """ + Convert link objects to link protobuf. + + :param node1: first node in link + :param iface1: node1 interface + :param node2: second node in link + :param iface2: node2 interface + :param options: link options + :param unidirectional: if this link is considered unidirectional + :return: protobuf link + """ + if iface1 is not None: + iface1 = convert_iface(iface1) + if iface2 is not None: + iface2 = convert_iface(iface2) + is_node1_wireless = isinstance(node1, (WlanNode, EmaneNet)) + is_node2_wireless = isinstance(node2, (WlanNode, EmaneNet)) + if not (is_node1_wireless or is_node2_wireless): + options = convert_link_options(options) + options.unidirectional = unidirectional + else: + options = None + return core_pb2.Link( + type=LinkTypes.WIRED.value, + node1_id=node1.id, + node2_id=node2.id, + iface1=iface1, + iface2=iface2, + options=options, + network_id=None, + label=None, + color=None, + ) + + def get_net_stats() -> Dict[str, Dict]: """ Retrieve status about the current interfaces in the system @@ -490,39 +596,13 @@ def get_service_configuration(service: CoreService) -> NodeServiceData: ) -def iface_to_data(iface: CoreInterface) -> InterfaceData: - ip4 = iface.get_ip4() - ip4_addr = str(ip4.ip) if ip4 else None - ip4_mask = ip4.prefixlen if ip4 else None - ip6 = iface.get_ip6() - ip6_addr = str(ip6.ip) if ip6 else None - ip6_mask = ip6.prefixlen if ip6 else None - return InterfaceData( - id=iface.node_id, - name=iface.name, - mac=str(iface.mac), - ip4=ip4_addr, - ip4_mask=ip4_mask, - ip6=ip6_addr, - ip6_mask=ip6_mask, - ) - - -def iface_to_proto(node_id: int, iface: CoreInterface) -> core_pb2.Interface: +def iface_to_proto(iface: CoreInterface) -> core_pb2.Interface: """ Convenience for converting a core interface to the protobuf representation. - :param node_id: id of node to convert interface for :param iface: interface to convert :return: interface proto """ - if iface.node and iface.node.id == node_id: - _id = iface.node_id - else: - _id = iface.net_id - net_id = iface.net.id if iface.net else None - node_id = iface.node.id if iface.node else None - net2_id = iface.othernet.id if iface.othernet else None ip4_net = iface.get_ip4() ip4 = str(ip4_net.ip) if ip4_net else None ip4_mask = ip4_net.prefixlen if ip4_net else None @@ -531,10 +611,7 @@ def iface_to_proto(node_id: int, iface: CoreInterface) -> core_pb2.Interface: ip6_mask = ip6_net.prefixlen if ip6_net else None mac = str(iface.mac) if iface.mac else None return core_pb2.Interface( - id=_id, - net_id=net_id, - net2_id=net2_id, - node_id=node_id, + id=iface.id, name=iface.name, mac=mac, mtu=iface.mtu, @@ -574,6 +651,12 @@ def get_nem_id( def get_emane_model_configs_dict(session: Session) -> Dict[int, List[NodeEmaneConfig]]: + """ + Get emane model configuration protobuf data. + + :param session: session to get emane model configuration for + :return: dict of emane model protobuf configurations + """ configs = {} for _id, model_configs in session.emane.node_configs.items(): for model_name in model_configs: @@ -591,6 +674,12 @@ def get_emane_model_configs_dict(session: Session) -> Dict[int, List[NodeEmaneCo def get_hooks(session: Session) -> List[core_pb2.Hook]: + """ + Retrieve hook protobuf data for a session. + + :param session: session to get hooks for + :return: list of hook protobufs + """ hooks = [] for state in session.hooks: state_hooks = session.hooks[state] @@ -601,6 +690,12 @@ def get_hooks(session: Session) -> List[core_pb2.Hook]: def get_default_services(session: Session) -> List[ServiceDefaults]: + """ + Retrieve the default service sets for a given session. + + :param session: session to get default service sets for + :return: list of default service sets + """ default_services = [] for name, services in session.services.default_services.items(): default_service = ServiceDefaults(node_type=name, services=services) @@ -611,6 +706,14 @@ def get_default_services(session: Session) -> List[ServiceDefaults]: def get_mobility_node( session: Session, node_id: int, context: ServicerContext ) -> Union[WlanNode, EmaneNet]: + """ + Get mobility node. + + :param session: session to get node from + :param node_id: id of node to get + :param context: grpc context + :return: wlan or emane node + """ try: return session.get_node(node_id, WlanNode) except CoreError: @@ -621,17 +724,26 @@ def get_mobility_node( def convert_session(session: Session) -> wrappers.Session: - links = [] - nodes = [] + """ + Convert session to its wrapped version. + + :param session: session to convert + :return: wrapped session data + """ emane_configs = get_emane_model_configs_dict(session) + nodes = [] + links = [] for _id in session.nodes: node = session.nodes[_id] if not isinstance(node, (PtpNet, CtrlNet)): node_emane_configs = emane_configs.get(node.id, []) node_proto = get_node_proto(session, node, node_emane_configs) nodes.append(node_proto) - node_links = get_links(node) - links.extend(node_links) + if isinstance(node, (WlanNode, EmaneNet)): + for link_data in node.links(): + links.append(convert_link_data(link_data)) + for core_link in session.link_manager.links(): + links.extend(convert_core_link(core_link)) default_services = get_default_services(session) x, y, z = session.location.refxyz lat, lon, alt = session.location.refgeo @@ -665,6 +777,15 @@ def convert_session(session: Session) -> wrappers.Session: def configure_node( session: Session, node: core_pb2.Node, core_node: NodeBase, context: ServicerContext ) -> None: + """ + Configure a node using all provided protobuf data. + + :param session: session for node + :param node: node protobuf data + :param core_node: session node + :param context: grpc context + :return: nothing + """ for emane_config in node.emane_configs: _id = utils.iface_config_id(node.id, emane_config.iface_id) config = {k: v.value for k, v in emane_config.config.items()} diff --git a/daemon/core/api/grpc/server.py b/daemon/core/api/grpc/server.py index 060bc4b6..18a97992 100644 --- a/daemon/core/api/grpc/server.py +++ b/daemon/core/api/grpc/server.py @@ -26,7 +26,15 @@ from core.api.grpc.configservices_pb2 import ( GetNodeConfigServiceRequest, GetNodeConfigServiceResponse, ) -from core.api.grpc.core_pb2 import ExecuteScriptResponse +from core.api.grpc.core_pb2 import ( + ExecuteScriptResponse, + LinkedRequest, + LinkedResponse, + WirelessConfigRequest, + WirelessConfigResponse, + WirelessLinkedRequest, + WirelessLinkedResponse, +) from core.api.grpc.emane_pb2 import ( EmaneLinkRequest, EmaneLinkResponse, @@ -76,17 +84,13 @@ from core.configservice.base import ConfigServiceBootError from core.emane.modelmanager import EmaneModelManager from core.emulator.coreemu import CoreEmu from core.emulator.data import InterfaceData, LinkData, LinkOptions -from core.emulator.enumerations import ( - EventTypes, - ExceptionLevels, - LinkTypes, - MessageFlags, -) +from core.emulator.enumerations import EventTypes, ExceptionLevels, MessageFlags from core.emulator.session import NT, Session from core.errors import CoreCommandError, CoreError from core.location.mobility import BasicRangeModel, Ns2ScriptedMobility from core.nodes.base import CoreNode, NodeBase -from core.nodes.network import WlanNode +from core.nodes.network import CoreNetwork, WlanNode +from core.nodes.wireless import WirelessNode from core.services.coreservices import ServiceManager logger = logging.getLogger(__name__) @@ -248,13 +252,14 @@ class CoreGrpcServer(core_pb2_grpc.CoreApiServicer): # clear previous state and setup for creation session.clear() + session.directory.mkdir(exist_ok=True) if request.definition: state = EventTypes.DEFINITION_STATE else: state = EventTypes.CONFIGURATION_STATE - session.directory.mkdir(exist_ok=True) session.set_state(state) - session.user = request.session.user + if request.session.user: + session.set_user(request.session.user) # session options session.options.config_reset() @@ -564,12 +569,12 @@ class CoreGrpcServer(core_pb2_grpc.CoreApiServicer): ifaces = [] for iface_id in node.ifaces: iface = node.ifaces[iface_id] - iface_proto = grpcutils.iface_to_proto(request.node_id, iface) + iface_proto = grpcutils.iface_to_proto(iface) ifaces.append(iface_proto) emane_configs = grpcutils.get_emane_model_configs_dict(session) node_emane_configs = emane_configs.get(node.id, []) node_proto = grpcutils.get_node_proto(session, node, node_emane_configs) - links = get_links(node) + links = get_links(session, node) return core_pb2.GetNodeResponse(node=node_proto, ifaces=ifaces, links=links) def MoveNode( @@ -705,18 +710,22 @@ class CoreGrpcServer(core_pb2_grpc.CoreApiServicer): node2_id = request.link.node2_id self.get_node(session, node1_id, context, NodeBase) self.get_node(session, node2_id, context, NodeBase) - iface1_data, iface2_data, options, link_type = grpcutils.add_link_data( - request.link - ) + iface1_data, iface2_data, options = grpcutils.add_link_data(request.link) node1_iface, node2_iface = session.add_link( - node1_id, node2_id, iface1_data, iface2_data, options, link_type + node1_id, node2_id, iface1_data, iface2_data, options ) iface1_data = None if node1_iface: - iface1_data = grpcutils.iface_to_data(node1_iface) + if isinstance(node1_iface.node, CoreNetwork): + iface1_data = InterfaceData(id=node1_iface.id) + else: + iface1_data = node1_iface.get_data() iface2_data = None if node2_iface: - iface2_data = grpcutils.iface_to_data(node2_iface) + if isinstance(node2_iface.node, CoreNetwork): + iface2_data = InterfaceData(id=node2_iface.id) + else: + iface2_data = node2_iface.get_data() source = request.source if request.source else None link_data = LinkData( message_type=MessageFlags.ADD, @@ -731,9 +740,9 @@ class CoreGrpcServer(core_pb2_grpc.CoreApiServicer): iface1_proto = None iface2_proto = None if node1_iface: - iface1_proto = grpcutils.iface_to_proto(node1_id, node1_iface) + iface1_proto = grpcutils.iface_to_proto(node1_iface) if node2_iface: - iface2_proto = grpcutils.iface_to_proto(node2_id, node2_iface) + iface2_proto = grpcutils.iface_to_proto(node2_iface) return core_pb2.AddLinkResponse( result=True, iface1=iface1_proto, iface2=iface2_proto ) @@ -1163,7 +1172,8 @@ class CoreGrpcServer(core_pb2_grpc.CoreApiServicer): self, request: core_pb2.GetInterfacesRequest, context: ServicerContext ) -> core_pb2.GetInterfacesResponse: """ - Retrieve all the interfaces of the system including bridges, virtual ethernet, and loopback + Retrieve all the interfaces of the system including bridges, virtual ethernet, + and loopback. :param request: get-interfaces request :param context: context object @@ -1188,32 +1198,9 @@ class CoreGrpcServer(core_pb2_grpc.CoreApiServicer): """ logger.debug("emane link: %s", request) session = self.get_session(request.session_id, context) - nem1 = request.nem1 - iface1 = session.emane.get_iface(nem1) - if not iface1: - context.abort(grpc.StatusCode.NOT_FOUND, f"nem one {nem1} not found") - node1 = iface1.node - - nem2 = request.nem2 - iface2 = session.emane.get_iface(nem2) - if not iface2: - context.abort(grpc.StatusCode.NOT_FOUND, f"nem two {nem2} not found") - node2 = iface2.node - - if iface1.net == iface2.net: - if request.linked: - flag = MessageFlags.ADD - else: - flag = MessageFlags.DELETE - color = session.get_link_color(iface1.net.id) - link = LinkData( - message_type=flag, - type=LinkTypes.WIRELESS, - node1_id=node1.id, - node2_id=node2.id, - network_id=iface1.net.id, - color=color, - ) + flag = MessageFlags.ADD if request.linked else MessageFlags.DELETE + link = session.emane.get_nem_link(request.nem1, request.nem2, flag) + if link: session.broadcast_link(link) return EmaneLinkResponse(result=True) else: @@ -1302,15 +1289,18 @@ class CoreGrpcServer(core_pb2_grpc.CoreApiServicer): if not isinstance(wlan.model, BasicRangeModel): context.abort( grpc.StatusCode.NOT_FOUND, - f"wlan node {request.wlan} does not using BasicRangeModel", + f"wlan node {request.wlan} is not using BasicRangeModel", ) node1 = self.get_node(session, request.node1_id, context, CoreNode) node2 = self.get_node(session, request.node2_id, context, CoreNode) node1_iface, node2_iface = None, None - for net, iface1, iface2 in node1.commonnets(node2): - if net == wlan: - node1_iface = iface1 - node2_iface = iface2 + for iface in node1.get_ifaces(control=False): + if iface.net == wlan: + node1_iface = iface + break + for iface in node2.get_ifaces(control=False): + if iface.net == wlan: + node2_iface = iface break result = False if node1_iface and node2_iface: @@ -1335,3 +1325,36 @@ class CoreGrpcServer(core_pb2_grpc.CoreApiServicer): nem2 = grpcutils.get_nem_id(session, node2, request.iface2_id, context) session.emane.publish_pathloss(nem1, nem2, request.rx1, request.rx2) return EmanePathlossesResponse() + + def Linked( + self, request: LinkedRequest, context: ServicerContext + ) -> LinkedResponse: + session = self.get_session(request.session_id, context) + session.linked( + request.node1_id, + request.node2_id, + request.iface1_id, + request.iface2_id, + request.linked, + ) + return LinkedResponse() + + def WirelessLinked( + self, request: WirelessLinkedRequest, context: ServicerContext + ) -> WirelessLinkedResponse: + session = self.get_session(request.session_id, context) + wireless = self.get_node(session, request.wireless_id, context, WirelessNode) + wireless.link_control(request.node1_id, request.node2_id, request.linked) + return WirelessLinkedResponse() + + def WirelessConfig( + self, request: WirelessConfigRequest, context: ServicerContext + ) -> WirelessConfigResponse: + session = self.get_session(request.session_id, context) + wireless = self.get_node(session, request.wireless_id, context, WirelessNode) + options1 = request.options1 + options2 = options1 + if request.HasField("options2"): + options2 = request.options2 + wireless.link_config(request.node1_id, request.node2_id, options1, options2) + return WirelessConfigResponse() diff --git a/daemon/core/api/grpc/wrappers.py b/daemon/core/api/grpc/wrappers.py index ffeb6793..7bbfdd7b 100644 --- a/daemon/core/api/grpc/wrappers.py +++ b/daemon/core/api/grpc/wrappers.py @@ -67,6 +67,7 @@ class NodeType(Enum): CONTROL_NET = 13 DOCKER = 15 LXC = 16 + WIRELESS = 17 class LinkType(Enum): @@ -637,6 +638,15 @@ class SessionSummary: dir=proto.dir, ) + def to_proto(self) -> core_pb2.SessionSummary: + return core_pb2.SessionSummary( + id=self.id, + state=self.state.value, + nodes=self.nodes, + file=self.file, + dir=self.dir, + ) + @dataclass class Hook: @@ -1093,7 +1103,6 @@ class ConfigEvent: data_types=list(proto.data_types), data_values=proto.data_values, captions=proto.captions, - bitmap=proto.bitmap, possible_values=proto.possible_values, groups=proto.groups, iface_id=proto.iface_id, diff --git a/daemon/core/api/tlv/__init__.py b/daemon/core/api/tlv/__init__.py deleted file mode 100644 index e69de29b..00000000 diff --git a/daemon/core/api/tlv/coreapi.py b/daemon/core/api/tlv/coreapi.py deleted file mode 100644 index 756b623c..00000000 --- a/daemon/core/api/tlv/coreapi.py +++ /dev/null @@ -1,1016 +0,0 @@ -""" -Uses coreapi_data for message and TLV types, and defines TLV data -types and objects used for parsing and building CORE API messages. - -CORE API messaging is leveraged for communication with the GUI. -""" - -import binascii -import socket -import struct -from enum import Enum - -import netaddr - -from core.api.tlv import structutils -from core.api.tlv.enumerations import ( - ConfigTlvs, - EventTlvs, - ExceptionTlvs, - ExecuteTlvs, - FileTlvs, - InterfaceTlvs, - LinkTlvs, - MessageTypes, - NodeTlvs, - SessionTlvs, -) -from core.emulator.enumerations import MessageFlags, RegisterTlvs - - -class CoreTlvData: - """ - Helper base class used for packing and unpacking values using struct. - """ - - # format string for packing data - data_format = None - # python data type for the data - data_type = None - # pad length for data after packing - pad_len = None - - @classmethod - def pack(cls, value): - """ - Convenience method for packing data using the struct module. - - :param value: value to pack - :return: length of data and the packed data itself - :rtype: tuple - """ - data = struct.pack(cls.data_format, value) - length = len(data) - cls.pad_len - return length, data - - @classmethod - def unpack(cls, data): - """ - Convenience method for unpacking data using the struct module. - - :param data: data to unpack - :return: the value of the unpacked data - """ - return struct.unpack(cls.data_format, data)[0] - - @classmethod - def pack_string(cls, value): - """ - Convenience method for packing data from a string representation. - - :param str value: value to pack - :return: length of data and the packed data itself - :rtype: tuple - """ - return cls.pack(cls.from_string(value)) - - @classmethod - def from_string(cls, value): - """ - Retrieve the value type from a string representation. - - :param str value: value to get a data type from - :return: value parse from string representation - """ - return cls.data_type(value) - - -class CoreTlvDataObj(CoreTlvData): - """ - Helper class for packing custom object data. - """ - - @classmethod - def pack(cls, value): - """ - Convenience method for packing custom object data. - - :param value: custom object to pack - :return: length of data and the packed data itself - :rtype: tuple - """ - value = cls.get_value(value) - return super().pack(value) - - @classmethod - def unpack(cls, data): - """ - Convenience method for unpacking custom object data. - - :param data: data to unpack custom object from - :return: unpacked custom object - """ - data = super().unpack(data) - return cls.new_obj(data) - - @staticmethod - def get_value(obj): - """ - Method that will be used to retrieve the data to pack from a custom object. - - :param obj: custom object to get data to pack - :return: data value to pack - """ - raise NotImplementedError - - @staticmethod - def new_obj(obj): - """ - Method for retrieving data to unpack from an object. - - :param obj: object to get unpack data from - :return: value of unpacked data - """ - raise NotImplementedError - - -class CoreTlvDataUint16(CoreTlvData): - """ - Helper class for packing uint16 data. - """ - - data_format = "!H" - data_type = int - pad_len = 0 - - -class CoreTlvDataUint32(CoreTlvData): - """ - Helper class for packing uint32 data. - """ - - data_format = "!2xI" - data_type = int - pad_len = 2 - - -class CoreTlvDataUint64(CoreTlvData): - """ - Helper class for packing uint64 data. - """ - - data_format = "!2xQ" - data_type = int - pad_len = 2 - - -class CoreTlvDataString(CoreTlvData): - """ - Helper class for packing string data. - """ - - data_type = str - - @classmethod - def pack(cls, value): - """ - Convenience method for packing string data. - - :param str value: string to pack - :return: length of data packed and the packed data - :rtype: tuple - """ - if not isinstance(value, str): - raise ValueError(f"value not a string: {type(value)}") - value = value.encode("utf-8") - - if len(value) < 256: - header_len = CoreTlv.header_len - else: - header_len = CoreTlv.long_header_len - - pad_len = -(header_len + len(value)) % 4 - return len(value), value + b"\0" * pad_len - - @classmethod - def unpack(cls, data): - """ - Convenience method for unpacking string data. - - :param str data: unpack string data - :return: unpacked string data - """ - return data.rstrip(b"\0").decode("utf-8") - - -class CoreTlvDataUint16List(CoreTlvData): - """ - List of unsigned 16-bit values. - """ - - data_type = tuple - data_format = "!H" - - @classmethod - def pack(cls, values): - """ - Convenience method for packing a uint 16 list. - - :param list values: unint 16 list to pack - :return: length of data packed and the packed data - :rtype: tuple - """ - if not isinstance(values, tuple): - raise ValueError(f"value not a tuple: {values}") - - data = b"" - for value in values: - data += struct.pack(cls.data_format, value) - - pad_len = -(CoreTlv.header_len + len(data)) % 4 - return len(data), data + b"\0" * pad_len - - @classmethod - def unpack(cls, data): - """ - Convenience method for unpacking a uint 16 list. - - :param data: data to unpack - :return: unpacked data - """ - size = int(len(data) / 2) - data_format = f"!{size}H" - return struct.unpack(data_format, data) - - @classmethod - def from_string(cls, value): - """ - Retrieves a unint 16 list from a string - - :param str value: string representation of a uint 16 list - :return: uint 16 list - :rtype: list - """ - return tuple(int(x) for x in value.split()) - - -class CoreTlvDataIpv4Addr(CoreTlvDataObj): - """ - Utility class for packing/unpacking Ipv4 addresses. - """ - - data_type = str - data_format = "!2x4s" - pad_len = 2 - - @staticmethod - def get_value(obj): - """ - Retrieve Ipv4 address value from object. - - :param str obj: ip address to get value from - :return: packed address - :rtype: bytes - """ - return socket.inet_pton(socket.AF_INET, obj) - - @staticmethod - def new_obj(value): - """ - Retrieve Ipv4 address from a string representation. - - :param bytes value: value to get Ipv4 address from - :return: Ipv4 address - :rtype: str - """ - return socket.inet_ntop(socket.AF_INET, value) - - -class CoreTlvDataIPv6Addr(CoreTlvDataObj): - """ - Utility class for packing/unpacking Ipv6 addresses. - """ - - data_format = "!16s2x" - data_type = str - pad_len = 2 - - @staticmethod - def get_value(obj): - """ - Retrieve Ipv6 address value from object. - - :param str obj: ip address to get value from - :return: packed address - :rtype: bytes - """ - return socket.inet_pton(socket.AF_INET6, obj) - - @staticmethod - def new_obj(value): - """ - Retrieve Ipv6 address from a string representation. - - :param bytes value: value to get Ipv4 address from - :return: Ipv4 address - :rtype: str - """ - return socket.inet_ntop(socket.AF_INET6, value) - - -class CoreTlvDataMacAddr(CoreTlvDataObj): - """ - Utility class for packing/unpacking mac addresses. - """ - - data_format = "!2x8s" - data_type = str - pad_len = 2 - - @staticmethod - def get_value(obj): - """ - Retrieve Ipv6 address value from object. - - :param str obj: mac address to get value from - :return: packed mac address - :rtype: bytes - """ - # extend to 64 bits - return b"\0\0" + netaddr.EUI(obj).packed - - @staticmethod - def new_obj(value): - """ - Retrieve mac address from a string representation. - - :param bytes value: value to get Ipv4 address from - :return: mac address - :rtype: str - """ - # only use 48 bits - value = binascii.hexlify(value[2:]).decode() - mac = netaddr.EUI(value, dialect=netaddr.mac_unix_expanded) - return str(mac) - - -class CoreTlv: - """ - Base class for representing CORE TLVs. - """ - - header_format = "!BB" - header_len = struct.calcsize(header_format) - - long_header_format = "!BBH" - long_header_len = struct.calcsize(long_header_format) - - tlv_type_map = Enum - tlv_data_class_map = {} - - def __init__(self, tlv_type, tlv_data): - """ - Create a CoreTlv instance. - - :param int tlv_type: tlv type - :param tlv_data: data to unpack - :return: unpacked data - """ - self.tlv_type = tlv_type - if tlv_data: - try: - self.value = self.tlv_data_class_map[self.tlv_type].unpack(tlv_data) - except KeyError: - self.value = tlv_data - else: - self.value = None - - @classmethod - def unpack(cls, data): - """ - Parse data and return unpacked class. - - :param data: data to unpack - :return: unpacked data class - """ - tlv_type, tlv_len = struct.unpack(cls.header_format, data[: cls.header_len]) - header_len = cls.header_len - if tlv_len == 0: - tlv_type, _zero, tlv_len = struct.unpack( - cls.long_header_format, data[: cls.long_header_len] - ) - header_len = cls.long_header_len - tlv_size = header_len + tlv_len - # for 32-bit alignment - tlv_size += -tlv_size % 4 - return cls(tlv_type, data[header_len:tlv_size]), data[tlv_size:] - - @classmethod - def pack(cls, tlv_type, value): - """ - Pack a TLV value, based on type. - - :param int tlv_type: type of data to pack - :param value: data to pack - :return: header and packed data - """ - tlv_len, tlv_data = cls.tlv_data_class_map[tlv_type].pack(value) - if tlv_len < 256: - hdr = struct.pack(cls.header_format, tlv_type, tlv_len) - else: - hdr = struct.pack(cls.long_header_format, tlv_type, 0, tlv_len) - return hdr + tlv_data - - @classmethod - def pack_string(cls, tlv_type, value): - """ - Pack data type from a string representation - - :param int tlv_type: type of data to pack - :param str value: string representation of data - :return: header and packed data - """ - return cls.pack(tlv_type, cls.tlv_data_class_map[tlv_type].from_string(value)) - - def type_str(self): - """ - Retrieve type string for this data type. - - :return: data type name - :rtype: str - """ - try: - return self.tlv_type_map(self.tlv_type).name - except ValueError: - return f"unknown tlv type: {self.tlv_type}" - - def __str__(self): - """ - String representation of this data type. - - :return: string representation - :rtype: str - """ - return f"{self.__class__.__name__} " - - -class CoreNodeTlv(CoreTlv): - """ - Class for representing CORE Node TLVs. - """ - - tlv_type_map = NodeTlvs - tlv_data_class_map = { - NodeTlvs.NUMBER.value: CoreTlvDataUint32, - NodeTlvs.TYPE.value: CoreTlvDataUint32, - NodeTlvs.NAME.value: CoreTlvDataString, - NodeTlvs.IP_ADDRESS.value: CoreTlvDataIpv4Addr, - NodeTlvs.MAC_ADDRESS.value: CoreTlvDataMacAddr, - NodeTlvs.IP6_ADDRESS.value: CoreTlvDataIPv6Addr, - NodeTlvs.MODEL.value: CoreTlvDataString, - NodeTlvs.EMULATION_SERVER.value: CoreTlvDataString, - NodeTlvs.SESSION.value: CoreTlvDataString, - NodeTlvs.X_POSITION.value: CoreTlvDataUint16, - NodeTlvs.Y_POSITION.value: CoreTlvDataUint16, - NodeTlvs.CANVAS.value: CoreTlvDataUint16, - NodeTlvs.EMULATION_ID.value: CoreTlvDataUint32, - NodeTlvs.NETWORK_ID.value: CoreTlvDataUint32, - NodeTlvs.SERVICES.value: CoreTlvDataString, - NodeTlvs.LATITUDE.value: CoreTlvDataString, - NodeTlvs.LONGITUDE.value: CoreTlvDataString, - NodeTlvs.ALTITUDE.value: CoreTlvDataString, - NodeTlvs.ICON.value: CoreTlvDataString, - NodeTlvs.OPAQUE.value: CoreTlvDataString, - } - - -class CoreLinkTlv(CoreTlv): - """ - Class for representing CORE link TLVs. - """ - - tlv_type_map = LinkTlvs - tlv_data_class_map = { - LinkTlvs.N1_NUMBER.value: CoreTlvDataUint32, - LinkTlvs.N2_NUMBER.value: CoreTlvDataUint32, - LinkTlvs.DELAY.value: CoreTlvDataUint64, - LinkTlvs.BANDWIDTH.value: CoreTlvDataUint64, - LinkTlvs.LOSS.value: CoreTlvDataString, - LinkTlvs.DUP.value: CoreTlvDataString, - LinkTlvs.JITTER.value: CoreTlvDataUint64, - LinkTlvs.MER.value: CoreTlvDataUint16, - LinkTlvs.BURST.value: CoreTlvDataUint16, - LinkTlvs.SESSION.value: CoreTlvDataString, - LinkTlvs.MBURST.value: CoreTlvDataUint16, - LinkTlvs.TYPE.value: CoreTlvDataUint32, - LinkTlvs.GUI_ATTRIBUTES.value: CoreTlvDataString, - LinkTlvs.UNIDIRECTIONAL.value: CoreTlvDataUint16, - LinkTlvs.EMULATION_ID.value: CoreTlvDataUint32, - LinkTlvs.NETWORK_ID.value: CoreTlvDataUint32, - LinkTlvs.KEY.value: CoreTlvDataUint32, - LinkTlvs.IFACE1_NUMBER.value: CoreTlvDataUint16, - LinkTlvs.IFACE1_IP4.value: CoreTlvDataIpv4Addr, - LinkTlvs.IFACE1_IP4_MASK.value: CoreTlvDataUint16, - LinkTlvs.IFACE1_MAC.value: CoreTlvDataMacAddr, - LinkTlvs.IFACE1_IP6.value: CoreTlvDataIPv6Addr, - LinkTlvs.IFACE1_IP6_MASK.value: CoreTlvDataUint16, - LinkTlvs.IFACE2_NUMBER.value: CoreTlvDataUint16, - LinkTlvs.IFACE2_IP4.value: CoreTlvDataIpv4Addr, - LinkTlvs.IFACE2_IP4_MASK.value: CoreTlvDataUint16, - LinkTlvs.IFACE2_MAC.value: CoreTlvDataMacAddr, - LinkTlvs.IFACE2_IP6.value: CoreTlvDataIPv6Addr, - LinkTlvs.IFACE2_IP6_MASK.value: CoreTlvDataUint16, - LinkTlvs.IFACE1_NAME.value: CoreTlvDataString, - LinkTlvs.IFACE2_NAME.value: CoreTlvDataString, - LinkTlvs.OPAQUE.value: CoreTlvDataString, - } - - -class CoreExecuteTlv(CoreTlv): - """ - Class for representing CORE execute TLVs. - """ - - tlv_type_map = ExecuteTlvs - tlv_data_class_map = { - ExecuteTlvs.NODE.value: CoreTlvDataUint32, - ExecuteTlvs.NUMBER.value: CoreTlvDataUint32, - ExecuteTlvs.TIME.value: CoreTlvDataUint32, - ExecuteTlvs.COMMAND.value: CoreTlvDataString, - ExecuteTlvs.RESULT.value: CoreTlvDataString, - ExecuteTlvs.STATUS.value: CoreTlvDataUint32, - ExecuteTlvs.SESSION.value: CoreTlvDataString, - } - - -class CoreRegisterTlv(CoreTlv): - """ - Class for representing CORE register TLVs. - """ - - tlv_type_map = RegisterTlvs - tlv_data_class_map = { - RegisterTlvs.WIRELESS.value: CoreTlvDataString, - RegisterTlvs.MOBILITY.value: CoreTlvDataString, - RegisterTlvs.UTILITY.value: CoreTlvDataString, - RegisterTlvs.EXECUTE_SERVER.value: CoreTlvDataString, - RegisterTlvs.GUI.value: CoreTlvDataString, - RegisterTlvs.EMULATION_SERVER.value: CoreTlvDataString, - RegisterTlvs.SESSION.value: CoreTlvDataString, - } - - -class CoreConfigTlv(CoreTlv): - """ - Class for representing CORE configuration TLVs. - """ - - tlv_type_map = ConfigTlvs - tlv_data_class_map = { - ConfigTlvs.NODE.value: CoreTlvDataUint32, - ConfigTlvs.OBJECT.value: CoreTlvDataString, - ConfigTlvs.TYPE.value: CoreTlvDataUint16, - ConfigTlvs.DATA_TYPES.value: CoreTlvDataUint16List, - ConfigTlvs.VALUES.value: CoreTlvDataString, - ConfigTlvs.CAPTIONS.value: CoreTlvDataString, - ConfigTlvs.BITMAP.value: CoreTlvDataString, - ConfigTlvs.POSSIBLE_VALUES.value: CoreTlvDataString, - ConfigTlvs.GROUPS.value: CoreTlvDataString, - ConfigTlvs.SESSION.value: CoreTlvDataString, - ConfigTlvs.IFACE_ID.value: CoreTlvDataUint16, - ConfigTlvs.NETWORK_ID.value: CoreTlvDataUint32, - ConfigTlvs.OPAQUE.value: CoreTlvDataString, - } - - -class CoreFileTlv(CoreTlv): - """ - Class for representing CORE file TLVs. - """ - - tlv_type_map = FileTlvs - tlv_data_class_map = { - FileTlvs.NODE.value: CoreTlvDataUint32, - FileTlvs.NAME.value: CoreTlvDataString, - FileTlvs.MODE.value: CoreTlvDataString, - FileTlvs.NUMBER.value: CoreTlvDataUint16, - FileTlvs.TYPE.value: CoreTlvDataString, - FileTlvs.SOURCE_NAME.value: CoreTlvDataString, - FileTlvs.SESSION.value: CoreTlvDataString, - FileTlvs.DATA.value: CoreTlvDataString, - FileTlvs.COMPRESSED_DATA.value: CoreTlvDataString, - } - - -class CoreInterfaceTlv(CoreTlv): - """ - Class for representing CORE interface TLVs. - """ - - tlv_type_map = InterfaceTlvs - tlv_data_class_map = { - InterfaceTlvs.NODE.value: CoreTlvDataUint32, - InterfaceTlvs.NUMBER.value: CoreTlvDataUint16, - InterfaceTlvs.NAME.value: CoreTlvDataString, - InterfaceTlvs.IP_ADDRESS.value: CoreTlvDataIpv4Addr, - InterfaceTlvs.MASK.value: CoreTlvDataUint16, - InterfaceTlvs.MAC_ADDRESS.value: CoreTlvDataMacAddr, - InterfaceTlvs.IP6_ADDRESS.value: CoreTlvDataIPv6Addr, - InterfaceTlvs.IP6_MASK.value: CoreTlvDataUint16, - InterfaceTlvs.TYPE.value: CoreTlvDataUint16, - InterfaceTlvs.SESSION.value: CoreTlvDataString, - InterfaceTlvs.STATE.value: CoreTlvDataUint16, - InterfaceTlvs.EMULATION_ID.value: CoreTlvDataUint32, - InterfaceTlvs.NETWORK_ID.value: CoreTlvDataUint32, - } - - -class CoreEventTlv(CoreTlv): - """ - Class for representing CORE event TLVs. - """ - - tlv_type_map = EventTlvs - tlv_data_class_map = { - EventTlvs.NODE.value: CoreTlvDataUint32, - EventTlvs.TYPE.value: CoreTlvDataUint32, - EventTlvs.NAME.value: CoreTlvDataString, - EventTlvs.DATA.value: CoreTlvDataString, - EventTlvs.TIME.value: CoreTlvDataString, - EventTlvs.SESSION.value: CoreTlvDataString, - } - - -class CoreSessionTlv(CoreTlv): - """ - Class for representing CORE session TLVs. - """ - - tlv_type_map = SessionTlvs - tlv_data_class_map = { - SessionTlvs.NUMBER.value: CoreTlvDataString, - SessionTlvs.NAME.value: CoreTlvDataString, - SessionTlvs.FILE.value: CoreTlvDataString, - SessionTlvs.NODE_COUNT.value: CoreTlvDataString, - SessionTlvs.DATE.value: CoreTlvDataString, - SessionTlvs.THUMB.value: CoreTlvDataString, - SessionTlvs.USER.value: CoreTlvDataString, - SessionTlvs.OPAQUE.value: CoreTlvDataString, - } - - -class CoreExceptionTlv(CoreTlv): - """ - Class for representing CORE exception TLVs. - """ - - tlv_type_map = ExceptionTlvs - tlv_data_class_map = { - ExceptionTlvs.NODE.value: CoreTlvDataUint32, - ExceptionTlvs.SESSION.value: CoreTlvDataString, - ExceptionTlvs.LEVEL.value: CoreTlvDataUint16, - ExceptionTlvs.SOURCE.value: CoreTlvDataString, - ExceptionTlvs.DATE.value: CoreTlvDataString, - ExceptionTlvs.TEXT.value: CoreTlvDataString, - ExceptionTlvs.OPAQUE.value: CoreTlvDataString, - } - - -class CoreMessage: - """ - Base class for representing CORE messages. - """ - - header_format = "!BBH" - header_len = struct.calcsize(header_format) - message_type = None - flag_map = MessageFlags - tlv_class = CoreTlv - - def __init__(self, flags, hdr, data): - self.raw_message = hdr + data - self.flags = flags - self.tlv_data = {} - self.parse_data(data) - - @classmethod - def unpack_header(cls, data): - """ - parse data and return (message_type, message_flags, message_len). - - :param str data: data to parse - :return: unpacked tuple - :rtype: tuple - """ - message_type, message_flags, message_len = struct.unpack( - cls.header_format, data[: cls.header_len] - ) - return message_type, message_flags, message_len - - @classmethod - def create(cls, flags, values): - tlv_data = structutils.pack_values(cls.tlv_class, values) - packed = cls.pack(flags, tlv_data) - header_data = packed[: cls.header_len] - return cls(flags, header_data, tlv_data) - - @classmethod - def pack(cls, message_flags, tlv_data): - """ - Pack CORE message data. - - :param message_flags: message flags to pack with data - :param tlv_data: data to get length from for packing - :return: combined header and tlv data - """ - header = struct.pack( - cls.header_format, cls.message_type, message_flags, len(tlv_data) - ) - return header + tlv_data - - def add_tlv_data(self, key, value): - """ - Add TLV data into the data map. - - :param int key: key to store TLV data - :param value: data to associate with key - :return: nothing - """ - if key in self.tlv_data: - raise KeyError(f"key already exists: {key} (val={value})") - - self.tlv_data[key] = value - - def get_tlv(self, tlv_type): - """ - Retrieve TLV data from data map. - - :param int tlv_type: type of data to retrieve - :return: TLV type data - """ - return self.tlv_data.get(tlv_type) - - def parse_data(self, data): - """ - Parse data while possible and adding TLV data to the data map. - - :param data: data to parse for TLV data - :return: nothing - """ - while data: - tlv, data = self.tlv_class.unpack(data) - self.add_tlv_data(tlv.tlv_type, tlv.value) - - def pack_tlv_data(self): - """ - Opposite of parse_data(). Return packed TLV data using self.tlv_data dict. Used by repack(). - - :return: packed data - :rtype: str - """ - keys = sorted(self.tlv_data.keys()) - tlv_data = b"" - for key in keys: - value = self.tlv_data[key] - tlv_data += self.tlv_class.pack(key, value) - return tlv_data - - def repack(self): - """ - Invoke after updating self.tlv_data[] to rebuild self.raw_message. - Useful for modifying a message that has been parsed, before - sending the raw data again. - - :return: nothing - """ - tlv_data = self.pack_tlv_data() - self.raw_message = self.pack(self.flags, tlv_data) - - def type_str(self): - """ - Retrieve data of the message type. - - :return: name of message type - :rtype: str - """ - try: - return MessageTypes(self.message_type).name - except ValueError: - return f"unknown message type: {self.message_type}" - - def flag_str(self): - """ - Retrieve message flag string. - - :return: message flag string - :rtype: str - """ - message_flags = [] - flag = 1 - - while True: - if self.flags & flag: - try: - message_flags.append(self.flag_map(flag).name) - except ValueError: - message_flags.append(f"0x{flag:x}") - flag <<= 1 - if not (self.flags & ~(flag - 1)): - break - - message_flags = " | ".join(message_flags) - return f"0x{self.flags:x} <{message_flags}>" - - def __str__(self): - """ - Retrieve string representation of the message. - - :return: string representation - :rtype: str - """ - result = f"{self.__class__.__name__} " - - for key in self.tlv_data: - value = self.tlv_data[key] - try: - tlv_type = self.tlv_class.tlv_type_map(key).name - except ValueError: - tlv_type = f"tlv type {key}" - - result += f"\n {tlv_type}: {value}" - - return result - - def node_numbers(self): - """ - Return a list of node numbers included in this message. - """ - number1 = None - number2 = None - - # not all messages have node numbers - if self.message_type == MessageTypes.NODE.value: - number1 = self.get_tlv(NodeTlvs.NUMBER.value) - elif self.message_type == MessageTypes.LINK.value: - number1 = self.get_tlv(LinkTlvs.N1_NUMBER.value) - number2 = self.get_tlv(LinkTlvs.N2_NUMBER.value) - elif self.message_type == MessageTypes.EXECUTE.value: - number1 = self.get_tlv(ExecuteTlvs.NODE.value) - elif self.message_type == MessageTypes.CONFIG.value: - number1 = self.get_tlv(ConfigTlvs.NODE.value) - elif self.message_type == MessageTypes.FILE.value: - number1 = self.get_tlv(FileTlvs.NODE.value) - elif self.message_type == MessageTypes.INTERFACE.value: - number1 = self.get_tlv(InterfaceTlvs.NODE.value) - elif self.message_type == MessageTypes.EVENT.value: - number1 = self.get_tlv(EventTlvs.NODE.value) - - result = [] - - if number1: - result.append(number1) - - if number2: - result.append(number2) - - return result - - def session_numbers(self): - """ - Return a list of session numbers included in this message. - """ - result = [] - - if self.message_type == MessageTypes.SESSION.value: - sessions = self.get_tlv(SessionTlvs.NUMBER.value) - elif self.message_type == MessageTypes.EXCEPTION.value: - sessions = self.get_tlv(ExceptionTlvs.SESSION.value) - else: - # All other messages share TLV number 0xA for the session number(s). - sessions = self.get_tlv(NodeTlvs.SESSION.value) - - if sessions: - for session_id in sessions.split("|"): - result.append(int(session_id)) - - return result - - -class CoreNodeMessage(CoreMessage): - """ - CORE node message class. - """ - - message_type = MessageTypes.NODE.value - tlv_class = CoreNodeTlv - - -class CoreLinkMessage(CoreMessage): - """ - CORE link message class. - """ - - message_type = MessageTypes.LINK.value - tlv_class = CoreLinkTlv - - -class CoreExecMessage(CoreMessage): - """ - CORE execute message class. - """ - - message_type = MessageTypes.EXECUTE.value - tlv_class = CoreExecuteTlv - - -class CoreRegMessage(CoreMessage): - """ - CORE register message class. - """ - - message_type = MessageTypes.REGISTER.value - tlv_class = CoreRegisterTlv - - -class CoreConfMessage(CoreMessage): - """ - CORE configuration message class. - """ - - message_type = MessageTypes.CONFIG.value - tlv_class = CoreConfigTlv - - -class CoreFileMessage(CoreMessage): - """ - CORE file message class. - """ - - message_type = MessageTypes.FILE.value - tlv_class = CoreFileTlv - - -class CoreIfaceMessage(CoreMessage): - """ - CORE interface message class. - """ - - message_type = MessageTypes.INTERFACE.value - tlv_class = CoreInterfaceTlv - - -class CoreEventMessage(CoreMessage): - """ - CORE event message class. - """ - - message_type = MessageTypes.EVENT.value - tlv_class = CoreEventTlv - - -class CoreSessionMessage(CoreMessage): - """ - CORE session message class. - """ - - message_type = MessageTypes.SESSION.value - tlv_class = CoreSessionTlv - - -class CoreExceptionMessage(CoreMessage): - """ - CORE exception message class. - """ - - message_type = MessageTypes.EXCEPTION.value - tlv_class = CoreExceptionTlv - - -# map used to translate enumerated message type values to message class objects -CLASS_MAP = { - MessageTypes.NODE.value: CoreNodeMessage, - MessageTypes.LINK.value: CoreLinkMessage, - MessageTypes.EXECUTE.value: CoreExecMessage, - MessageTypes.REGISTER.value: CoreRegMessage, - MessageTypes.CONFIG.value: CoreConfMessage, - MessageTypes.FILE.value: CoreFileMessage, - MessageTypes.INTERFACE.value: CoreIfaceMessage, - MessageTypes.EVENT.value: CoreEventMessage, - MessageTypes.SESSION.value: CoreSessionMessage, - MessageTypes.EXCEPTION.value: CoreExceptionMessage, -} - - -def str_to_list(value): - """ - Helper to convert pipe-delimited string ("a|b|c") into a list (a, b, c). - - :param str value: string to convert - :return: converted list - :rtype: list - """ - - if value is None: - return None - - return value.split("|") diff --git a/daemon/core/api/tlv/corehandlers.py b/daemon/core/api/tlv/corehandlers.py deleted file mode 100644 index 1937aea8..00000000 --- a/daemon/core/api/tlv/corehandlers.py +++ /dev/null @@ -1,2051 +0,0 @@ -""" -socket server request handlers leveraged by core servers. -""" - -import logging -import shlex -import shutil -import socketserver -import sys -import threading -import time -from itertools import repeat -from pathlib import Path -from queue import Empty, Queue -from typing import Optional - -from core import utils -from core.api.tlv import coreapi, dataconversion, structutils -from core.api.tlv.dataconversion import ConfigShim -from core.api.tlv.enumerations import ( - ConfigFlags, - ConfigTlvs, - EventTlvs, - ExceptionTlvs, - ExecuteTlvs, - FileTlvs, - LinkTlvs, - MessageTypes, - NodeTlvs, - SessionTlvs, -) -from core.emane.modelmanager import EmaneModelManager -from core.emulator.data import ( - ConfigData, - EventData, - ExceptionData, - FileData, - InterfaceData, - LinkOptions, - NodeOptions, -) -from core.emulator.enumerations import ( - ConfigDataTypes, - EventTypes, - ExceptionLevels, - LinkTypes, - MessageFlags, - NodeTypes, - RegisterTlvs, -) -from core.emulator.session import Session -from core.errors import CoreCommandError, CoreError -from core.location.mobility import BasicRangeModel -from core.nodes.base import CoreNode, CoreNodeBase, NodeBase -from core.nodes.network import WlanNode -from core.nodes.physical import Rj45Node -from core.services.coreservices import ServiceManager, ServiceShim - -logger = logging.getLogger(__name__) - - -class CoreHandler(socketserver.BaseRequestHandler): - """ - The CoreHandler class uses the RequestHandler class for servicing requests. - """ - - session_clients = {} - - def __init__(self, request, client_address, server): - """ - Create a CoreRequestHandler instance. - - :param request: request object - :param str client_address: client address - :param CoreServer server: core server instance - """ - self.done = False - self.message_handlers = { - MessageTypes.NODE.value: self.handle_node_message, - MessageTypes.LINK.value: self.handle_link_message, - MessageTypes.EXECUTE.value: self.handle_execute_message, - MessageTypes.REGISTER.value: self.handle_register_message, - MessageTypes.CONFIG.value: self.handle_config_message, - MessageTypes.FILE.value: self.handle_file_message, - MessageTypes.INTERFACE.value: self.handle_iface_message, - MessageTypes.EVENT.value: self.handle_event_message, - MessageTypes.SESSION.value: self.handle_session_message, - } - self.message_queue = Queue() - self.node_status_request = {} - self._shutdown_lock = threading.Lock() - self._sessions_lock = threading.Lock() - - self.handler_threads = [] - thread = threading.Thread(target=self.handler_thread, daemon=True) - thread.start() - self.handler_threads.append(thread) - - self.session: Optional[Session] = None - self.coreemu = server.coreemu - utils.close_onexec(request.fileno()) - socketserver.BaseRequestHandler.__init__(self, request, client_address, server) - - def setup(self): - """ - Client has connected, set up a new connection. - - :return: nothing - """ - logger.debug("new TCP connection: %s", self.client_address) - - def finish(self): - """ - Client has disconnected, end this request handler and disconnect - from the session. Shutdown sessions that are not running. - - :return: nothing - """ - logger.debug("finishing request handler") - logger.debug("remaining message queue size: %s", self.message_queue.qsize()) - - # give some time for message queue to deplete - timeout = 10 - wait = 0 - while not self.message_queue.empty(): - logger.debug("waiting for message queue to empty: %s seconds", wait) - time.sleep(1) - wait += 1 - if wait == timeout: - logger.warning("queue failed to be empty, finishing request handler") - break - - logger.info("client disconnected: notifying threads") - self.done = True - for thread in self.handler_threads: - logger.info("waiting for thread: %s", thread.getName()) - thread.join(timeout) - if thread.is_alive(): - logger.warning( - "joining %s failed: still alive after %s sec", - thread.getName(), - timeout, - ) - - logger.info("connection closed: %s", self.client_address) - if self.session: - # remove client from session broker and shutdown if there are no clients - self.remove_session_handlers() - clients = self.session_clients[self.session.id] - clients.remove(self) - if not clients and not self.session.is_active(): - logger.info( - "no session clients left and not active, initiating shutdown" - ) - self.coreemu.delete_session(self.session.id) - - return socketserver.BaseRequestHandler.finish(self) - - def session_message(self, flags=0): - """ - Build CORE API Sessions message based on current session info. - - :param int flags: message flags - :return: session message - """ - id_list = [] - name_list = [] - file_list = [] - node_count_list = [] - date_list = [] - thumb_list = [] - num_sessions = 0 - with self._sessions_lock: - for _id in self.coreemu.sessions: - session = self.coreemu.sessions[_id] - num_sessions += 1 - id_list.append(str(_id)) - name = session.name - if not name: - name = "" - name_list.append(name) - file_name = str(session.file_path) if session.file_path else "" - file_list.append(str(file_name)) - node_count_list.append(str(session.get_node_count())) - date_list.append(time.ctime(session.state_time)) - thumb = str(session.thumbnail) if session.thumbnail else "" - thumb_list.append(thumb) - session_ids = "|".join(id_list) - names = "|".join(name_list) - files = "|".join(file_list) - node_counts = "|".join(node_count_list) - dates = "|".join(date_list) - thumbs = "|".join(thumb_list) - if num_sessions > 0: - tlv_data = b"" - if len(session_ids) > 0: - tlv_data += coreapi.CoreSessionTlv.pack( - SessionTlvs.NUMBER.value, session_ids - ) - if len(names) > 0: - tlv_data += coreapi.CoreSessionTlv.pack(SessionTlvs.NAME.value, names) - if len(files) > 0: - tlv_data += coreapi.CoreSessionTlv.pack(SessionTlvs.FILE.value, files) - if len(node_counts) > 0: - tlv_data += coreapi.CoreSessionTlv.pack( - SessionTlvs.NODE_COUNT.value, node_counts - ) - if len(dates) > 0: - tlv_data += coreapi.CoreSessionTlv.pack(SessionTlvs.DATE.value, dates) - if len(thumbs) > 0: - tlv_data += coreapi.CoreSessionTlv.pack(SessionTlvs.THUMB.value, thumbs) - message = coreapi.CoreSessionMessage.pack(flags, tlv_data) - else: - message = None - return message - - def handle_broadcast_event(self, event_data): - """ - Callback to handle an event broadcast out from a session. - - :param core.emulator.data.EventData event_data: event data to handle - :return: nothing - """ - logger.debug("handling broadcast event: %s", event_data) - - tlv_data = structutils.pack_values( - coreapi.CoreEventTlv, - [ - (EventTlvs.NODE, event_data.node), - (EventTlvs.TYPE, event_data.event_type.value), - (EventTlvs.NAME, event_data.name), - (EventTlvs.DATA, event_data.data), - (EventTlvs.TIME, event_data.time), - (EventTlvs.SESSION, event_data.session), - ], - ) - message = coreapi.CoreEventMessage.pack(0, tlv_data) - - try: - self.sendall(message) - except IOError: - logger.exception("error sending event message") - - def handle_broadcast_file(self, file_data): - """ - Callback to handle a file broadcast out from a session. - - :param core.emulator.data.FileData file_data: file data to handle - :return: nothing - """ - logger.debug("handling broadcast file: %s", file_data) - - tlv_data = structutils.pack_values( - coreapi.CoreFileTlv, - [ - (FileTlvs.NODE, file_data.node), - (FileTlvs.NAME, file_data.name), - (FileTlvs.MODE, file_data.mode), - (FileTlvs.NUMBER, file_data.number), - (FileTlvs.TYPE, file_data.type), - (FileTlvs.SOURCE_NAME, file_data.source), - (FileTlvs.SESSION, file_data.session), - (FileTlvs.DATA, file_data.data), - (FileTlvs.COMPRESSED_DATA, file_data.compressed_data), - ], - ) - message = coreapi.CoreFileMessage.pack(file_data.message_type.value, tlv_data) - - try: - self.sendall(message) - except IOError: - logger.exception("error sending file message") - - def handle_broadcast_config(self, config_data): - """ - Callback to handle a config broadcast out from a session. - - :param core.emulator.data.ConfigData config_data: config data to handle - :return: nothing - """ - logger.debug("handling broadcast config: %s", config_data) - message = dataconversion.convert_config(config_data) - try: - self.sendall(message) - except IOError: - logger.exception("error sending config message") - - def handle_broadcast_exception(self, exception_data): - """ - Callback to handle an exception broadcast out from a session. - - :param core.emulator.data.ExceptionData exception_data: exception data to handle - :return: nothing - """ - logger.debug("handling broadcast exception: %s", exception_data) - tlv_data = structutils.pack_values( - coreapi.CoreExceptionTlv, - [ - (ExceptionTlvs.NODE, exception_data.node), - (ExceptionTlvs.SESSION, str(exception_data.session)), - (ExceptionTlvs.LEVEL, exception_data.level.value), - (ExceptionTlvs.SOURCE, exception_data.source), - (ExceptionTlvs.DATE, exception_data.date), - (ExceptionTlvs.TEXT, exception_data.text), - ], - ) - message = coreapi.CoreExceptionMessage.pack(0, tlv_data) - - try: - self.sendall(message) - except IOError: - logger.exception("error sending exception message") - - def handle_broadcast_node(self, node_data): - """ - Callback to handle an node broadcast out from a session. - - :param core.emulator.data.NodeData node_data: node data to handle - :return: nothing - """ - logger.debug("handling broadcast node: %s", node_data) - message = dataconversion.convert_node(node_data) - try: - self.sendall(message) - except IOError: - logger.exception("error sending node message") - - def handle_broadcast_link(self, link_data): - """ - Callback to handle an link broadcast out from a session. - - :param core.emulator.data.LinkData link_data: link data to handle - :return: nothing - """ - logger.debug("handling broadcast link: %s", link_data) - options_data = link_data.options - loss = "" - if options_data.loss is not None: - loss = str(options_data.loss) - dup = "" - if options_data.dup is not None: - dup = str(options_data.dup) - iface1 = link_data.iface1 - if iface1 is None: - iface1 = InterfaceData() - iface2 = link_data.iface2 - if iface2 is None: - iface2 = InterfaceData() - - tlv_data = structutils.pack_values( - coreapi.CoreLinkTlv, - [ - (LinkTlvs.N1_NUMBER, link_data.node1_id), - (LinkTlvs.N2_NUMBER, link_data.node2_id), - (LinkTlvs.DELAY, options_data.delay), - (LinkTlvs.BANDWIDTH, options_data.bandwidth), - (LinkTlvs.LOSS, loss), - (LinkTlvs.DUP, dup), - (LinkTlvs.JITTER, options_data.jitter), - (LinkTlvs.MER, options_data.mer), - (LinkTlvs.BURST, options_data.burst), - (LinkTlvs.MBURST, options_data.mburst), - (LinkTlvs.TYPE, link_data.type.value), - (LinkTlvs.UNIDIRECTIONAL, options_data.unidirectional), - (LinkTlvs.NETWORK_ID, link_data.network_id), - (LinkTlvs.KEY, options_data.key), - (LinkTlvs.IFACE1_NUMBER, iface1.id), - (LinkTlvs.IFACE1_IP4, iface1.ip4), - (LinkTlvs.IFACE1_IP4_MASK, iface1.ip4_mask), - (LinkTlvs.IFACE1_MAC, iface1.mac), - (LinkTlvs.IFACE1_IP6, iface1.ip6), - (LinkTlvs.IFACE1_IP6_MASK, iface1.ip6_mask), - (LinkTlvs.IFACE2_NUMBER, iface2.id), - (LinkTlvs.IFACE2_IP4, iface2.ip4), - (LinkTlvs.IFACE2_IP4_MASK, iface2.ip4_mask), - (LinkTlvs.IFACE2_MAC, iface2.mac), - (LinkTlvs.IFACE2_IP6, iface2.ip6), - (LinkTlvs.IFACE2_IP6_MASK, iface2.ip6_mask), - ], - ) - - message = coreapi.CoreLinkMessage.pack(link_data.message_type.value, tlv_data) - - try: - self.sendall(message) - except IOError: - logger.exception("error sending Event Message") - - def register(self): - """ - Return a Register Message - - :return: register message data - """ - logger.info( - "GUI has connected to session %d at %s", self.session.id, time.ctime() - ) - tlv_data = b"" - tlv_data += coreapi.CoreRegisterTlv.pack( - RegisterTlvs.EXECUTE_SERVER.value, "core-daemon" - ) - tlv_data += coreapi.CoreRegisterTlv.pack( - RegisterTlvs.EMULATION_SERVER.value, "core-daemon" - ) - tlv_data += coreapi.CoreRegisterTlv.pack(RegisterTlvs.UTILITY.value, "broker") - tlv_data += coreapi.CoreRegisterTlv.pack( - self.session.location.config_type.value, self.session.location.name - ) - tlv_data += coreapi.CoreRegisterTlv.pack( - self.session.mobility.config_type.value, self.session.mobility.name - ) - for model_name in self.session.mobility.models: - model_class = self.session.mobility.models[model_name] - tlv_data += coreapi.CoreRegisterTlv.pack( - model_class.config_type.value, model_class.name - ) - tlv_data += coreapi.CoreRegisterTlv.pack( - self.session.services.config_type.value, self.session.services.name - ) - tlv_data += coreapi.CoreRegisterTlv.pack( - self.session.emane.config_type.value, self.session.emane.name - ) - for model_name, model_class in EmaneModelManager.models.items(): - tlv_data += coreapi.CoreRegisterTlv.pack( - model_class.config_type.value, model_class.name - ) - tlv_data += coreapi.CoreRegisterTlv.pack( - self.session.options.config_type.value, self.session.options.name - ) - tlv_data += coreapi.CoreRegisterTlv.pack(RegisterTlvs.UTILITY.value, "metadata") - - return coreapi.CoreRegMessage.pack(MessageFlags.ADD.value, tlv_data) - - def sendall(self, data): - """ - Send raw data to the other end of this TCP connection - using socket"s sendall(). - - :param data: data to send over request socket - :return: data sent - """ - return self.request.sendall(data) - - def receive_message(self): - """ - Receive data and return a CORE API message object. - - :return: received message - :rtype: core.api.tlv.coreapi.CoreMessage - """ - try: - header = self.request.recv(coreapi.CoreMessage.header_len) - except IOError as e: - raise IOError(f"error receiving header ({e})") - - if len(header) != coreapi.CoreMessage.header_len: - if len(header) == 0: - raise EOFError("client disconnected") - else: - raise IOError("invalid message header size") - - message_type, message_flags, message_len = coreapi.CoreMessage.unpack_header( - header - ) - if message_len == 0: - logger.warning("received message with no data") - - data = b"" - while len(data) < message_len: - data += self.request.recv(message_len - len(data)) - if len(data) > message_len: - error_message = f"received message length does not match received data ({len(data)} != {message_len})" - logger.error(error_message) - raise IOError(error_message) - - try: - message_class = coreapi.CLASS_MAP[message_type] - message = message_class(message_flags, header, data) - except KeyError: - message = coreapi.CoreMessage(message_flags, header, data) - message.message_type = message_type - logger.exception("unimplemented core message type: %s", message.type_str()) - - return message - - def queue_message(self, message): - """ - Queue an API message for later processing. - - :param message: message to queue - :return: nothing - """ - logger.debug( - "queueing msg (queuedtimes = %s): type %s", - message.queuedtimes, - MessageTypes(message.message_type), - ) - self.message_queue.put(message) - - def handler_thread(self): - """ - CORE API message handling loop that is spawned for each server - thread; get CORE API messages from the incoming message queue, - and call handlemsg() for processing. - - :return: nothing - """ - while not self.done: - try: - message = self.message_queue.get(timeout=1) - self.handle_message(message) - except Empty: - pass - - def handle_message(self, message): - """ - Handle an incoming message; dispatch based on message type, - optionally sending replies. - - :param message: message to handle - :return: nothing - """ - logger.debug( - "%s handling message:\n%s", threading.currentThread().getName(), message - ) - if message.message_type not in self.message_handlers: - logger.error("no handler for message type: %s", message.type_str()) - return - - message_handler = self.message_handlers[message.message_type] - try: - # TODO: this needs to be removed, make use of the broadcast message methods - replies = message_handler(message) - self.dispatch_replies(replies, message) - except Exception as e: - self.send_exception(ExceptionLevels.ERROR, "corehandler", str(e)) - logger.exception( - "%s: exception while handling message: %s", - threading.currentThread().getName(), - message, - ) - - def dispatch_replies(self, replies, message): - """ - Dispatch replies by CORE to message msg previously received from the client. - - :param list replies: reply messages to dispatch - :param message: message for replies - :return: nothing - """ - for reply in replies: - message_type, message_flags, message_length = coreapi.CoreMessage.unpack_header( - reply - ) - try: - reply_message = coreapi.CLASS_MAP[message_type]( - message_flags, - reply[: coreapi.CoreMessage.header_len], - reply[coreapi.CoreMessage.header_len :], - ) - except KeyError: - # multiple TLVs of same type cause KeyError exception - reply_message = f"CoreMessage (type {message_type} flags {message_flags} length {message_length})" - - logger.debug("sending reply:\n%s", reply_message) - - try: - self.sendall(reply) - except IOError: - logger.exception("error dispatching reply") - - def handle(self): - """ - Handle a new connection request from a client. Dispatch to the - recvmsg() method for receiving data into CORE API messages, and - add them to an incoming message queue. - - :return: nothing - """ - # use port as session id - port = self.request.getpeername()[1] - - # TODO: add shutdown handler for session - self.session = self.coreemu.create_session(port) - logger.debug("created new session for client: %s", self.session.id) - clients = self.session_clients.setdefault(self.session.id, []) - clients.append(self) - - # add handlers for various data - self.add_session_handlers() - - # set initial session state - self.session.set_state(EventTypes.DEFINITION_STATE) - - while True: - try: - message = self.receive_message() - except EOFError: - logger.info("client disconnected") - break - except IOError: - logger.exception("error receiving message") - break - - message.queuedtimes = 0 - self.queue_message(message) - - # delay is required for brief connections, allow session joining - if message.message_type == MessageTypes.SESSION.value: - time.sleep(0.125) - - # broadcast node/link messages to other connected clients - if message.message_type not in [ - MessageTypes.NODE.value, - MessageTypes.LINK.value, - ]: - continue - - clients = self.session_clients[self.session.id] - for client in clients: - if client == self: - continue - - logger.debug("BROADCAST TO OTHER CLIENT: %s", client) - client.sendall(message.raw_message) - - def send_exception(self, level, source, text, node=None): - """ - Sends an exception for display within the GUI. - - :param core.emulator.enumerations.ExceptionLevel level: level for exception - :param str source: source where exception came from - :param str text: details about exception - :param int node: node id, if related to a specific node - :return: nothing - """ - exception_data = ExceptionData( - session=self.session.id, - node=node, - date=time.ctime(), - level=level, - source=source, - text=text, - ) - self.handle_broadcast_exception(exception_data) - - def add_session_handlers(self): - logger.debug("adding session broadcast handlers") - self.session.event_handlers.append(self.handle_broadcast_event) - self.session.exception_handlers.append(self.handle_broadcast_exception) - self.session.node_handlers.append(self.handle_broadcast_node) - self.session.link_handlers.append(self.handle_broadcast_link) - self.session.file_handlers.append(self.handle_broadcast_file) - self.session.config_handlers.append(self.handle_broadcast_config) - - def remove_session_handlers(self): - logger.debug("removing session broadcast handlers") - self.session.event_handlers.remove(self.handle_broadcast_event) - self.session.exception_handlers.remove(self.handle_broadcast_exception) - self.session.node_handlers.remove(self.handle_broadcast_node) - self.session.link_handlers.remove(self.handle_broadcast_link) - self.session.file_handlers.remove(self.handle_broadcast_file) - self.session.config_handlers.remove(self.handle_broadcast_config) - - def handle_node_message(self, message): - """ - Node Message handler - - :param core.api.tlv.coreapi.CoreNodeMessage message: node message - :return: replies to node message - """ - replies = [] - if ( - message.flags & MessageFlags.ADD.value - and message.flags & MessageFlags.DELETE.value - ): - logger.warning("ignoring invalid message: add and delete flag both set") - return () - - _class = CoreNode - node_type_value = message.get_tlv(NodeTlvs.TYPE.value) - if node_type_value is not None: - node_type = NodeTypes(node_type_value) - _class = self.session.get_node_class(node_type) - - node_id = message.get_tlv(NodeTlvs.NUMBER.value) - - options = NodeOptions( - name=message.get_tlv(NodeTlvs.NAME.value), - model=message.get_tlv(NodeTlvs.MODEL.value), - legacy=True, - ) - options.set_position( - x=message.get_tlv(NodeTlvs.X_POSITION.value), - y=message.get_tlv(NodeTlvs.Y_POSITION.value), - ) - - lat = message.get_tlv(NodeTlvs.LATITUDE.value) - if lat is not None: - lat = float(lat) - lon = message.get_tlv(NodeTlvs.LONGITUDE.value) - if lon is not None: - lon = float(lon) - alt = message.get_tlv(NodeTlvs.ALTITUDE.value) - if alt is not None: - alt = float(alt) - options.set_location(lat=lat, lon=lon, alt=alt) - - options.icon = message.get_tlv(NodeTlvs.ICON.value) - options.canvas = message.get_tlv(NodeTlvs.CANVAS.value) - options.server = message.get_tlv(NodeTlvs.EMULATION_SERVER.value) - - services = message.get_tlv(NodeTlvs.SERVICES.value) - if services: - options.services = services.split("|") - - if message.flags & MessageFlags.ADD.value: - node = self.session.add_node(_class, node_id, options) - has_geo = all( - i is not None for i in [options.lon, options.lat, options.alt] - ) - if has_geo: - self.session.broadcast_node(node) - if message.flags & MessageFlags.STRING.value: - self.node_status_request[node.id] = True - if self.session.state == EventTypes.RUNTIME_STATE: - self.send_node_emulation_id(node.id) - elif message.flags & MessageFlags.DELETE.value: - with self._shutdown_lock: - result = self.session.delete_node(node_id) - if result and self.session.get_node_count() == 0: - self.session.set_state(EventTypes.SHUTDOWN_STATE) - self.session.delete_nodes() - self.session.distributed.shutdown() - self.session.sdt.shutdown() - - # if we deleted a node broadcast out its removal - if result and message.flags & MessageFlags.STRING.value: - tlvdata = b"" - tlvdata += coreapi.CoreNodeTlv.pack(NodeTlvs.NUMBER.value, node_id) - flags = MessageFlags.DELETE.value | MessageFlags.LOCAL.value - replies.append(coreapi.CoreNodeMessage.pack(flags, tlvdata)) - # node update - else: - node = self.session.get_node(node_id, NodeBase) - node.icon = options.icon - has_geo = all( - i is not None for i in [options.lon, options.lat, options.alt] - ) - if has_geo: - self.session.set_node_geo(node, options.lon, options.lat, options.alt) - self.session.broadcast_node(node) - else: - self.session.set_node_pos(node, options.x, options.y) - - return replies - - def handle_link_message(self, message): - """ - Link Message handler - - :param core.api.tlv.coreapi.CoreLinkMessage message: link message to handle - :return: link message replies - """ - node1_id = message.get_tlv(LinkTlvs.N1_NUMBER.value) - node2_id = message.get_tlv(LinkTlvs.N2_NUMBER.value) - iface1_data = InterfaceData( - id=message.get_tlv(LinkTlvs.IFACE1_NUMBER.value), - name=message.get_tlv(LinkTlvs.IFACE1_NAME.value), - mac=message.get_tlv(LinkTlvs.IFACE1_MAC.value), - ip4=message.get_tlv(LinkTlvs.IFACE1_IP4.value), - ip4_mask=message.get_tlv(LinkTlvs.IFACE1_IP4_MASK.value), - ip6=message.get_tlv(LinkTlvs.IFACE1_IP6.value), - ip6_mask=message.get_tlv(LinkTlvs.IFACE1_IP6_MASK.value), - ) - iface2_data = InterfaceData( - id=message.get_tlv(LinkTlvs.IFACE2_NUMBER.value), - name=message.get_tlv(LinkTlvs.IFACE2_NAME.value), - mac=message.get_tlv(LinkTlvs.IFACE2_MAC.value), - ip4=message.get_tlv(LinkTlvs.IFACE2_IP4.value), - ip4_mask=message.get_tlv(LinkTlvs.IFACE2_IP4_MASK.value), - ip6=message.get_tlv(LinkTlvs.IFACE2_IP6.value), - ip6_mask=message.get_tlv(LinkTlvs.IFACE2_IP6_MASK.value), - ) - link_type = LinkTypes.WIRED - link_type_value = message.get_tlv(LinkTlvs.TYPE.value) - if link_type_value is not None: - link_type = LinkTypes(link_type_value) - options = LinkOptions() - options.delay = message.get_tlv(LinkTlvs.DELAY.value) - options.bandwidth = message.get_tlv(LinkTlvs.BANDWIDTH.value) - options.jitter = message.get_tlv(LinkTlvs.JITTER.value) - options.mer = message.get_tlv(LinkTlvs.MER.value) - options.burst = message.get_tlv(LinkTlvs.BURST.value) - options.mburst = message.get_tlv(LinkTlvs.MBURST.value) - options.unidirectional = message.get_tlv(LinkTlvs.UNIDIRECTIONAL.value) - options.key = message.get_tlv(LinkTlvs.KEY.value) - loss = message.get_tlv(LinkTlvs.LOSS.value) - dup = message.get_tlv(LinkTlvs.DUP.value) - if loss is not None: - options.loss = float(loss) - if dup is not None: - options.dup = int(dup) - - # fix for rj45 nodes missing iface id - node1 = self.session.get_node(node1_id, NodeBase) - node2 = self.session.get_node(node2_id, NodeBase) - if isinstance(node1, Rj45Node) and iface1_data.id is None: - iface1_data.id = 0 - if isinstance(node2, Rj45Node) and iface2_data.id is None: - iface2_data.id = 0 - - if message.flags & MessageFlags.ADD.value: - self.session.add_link( - node1_id, node2_id, iface1_data, iface2_data, options, link_type - ) - elif message.flags & MessageFlags.DELETE.value: - if isinstance(node1, Rj45Node): - iface1_data.id = node1.iface_id - if isinstance(node2, Rj45Node): - iface2_data.id = node2.iface_id - self.session.delete_link( - node1_id, node2_id, iface1_data.id, iface2_data.id, link_type - ) - else: - self.session.update_link( - node1_id, node2_id, iface1_data.id, iface2_data.id, options, link_type - ) - return () - - def handle_execute_message(self, message): - """ - Execute Message handler - - :param core.api.tlv.coreapi.CoreExecMessage message: execute message to handle - :return: reply messages - """ - node_id = message.get_tlv(ExecuteTlvs.NODE.value) - execute_num = message.get_tlv(ExecuteTlvs.NUMBER.value) - execute_time = message.get_tlv(ExecuteTlvs.TIME.value) - command = message.get_tlv(ExecuteTlvs.COMMAND.value) - - # local flag indicates command executed locally, not on a node - if node_id is None and not message.flags & MessageFlags.LOCAL.value: - raise ValueError("Execute Message is missing node number.") - - if execute_num is None: - raise ValueError("Execute Message is missing execution number.") - - if execute_time is not None: - self.session.add_event( - float(execute_time), node_id=node_id, name=None, data=command - ) - return () - - try: - node = self.session.get_node(node_id, CoreNodeBase) - - # build common TLV items for reply - tlv_data = b"" - if node_id is not None: - tlv_data += coreapi.CoreExecuteTlv.pack(ExecuteTlvs.NODE.value, node_id) - tlv_data += coreapi.CoreExecuteTlv.pack( - ExecuteTlvs.NUMBER.value, execute_num - ) - tlv_data += coreapi.CoreExecuteTlv.pack(ExecuteTlvs.COMMAND.value, command) - - if message.flags & MessageFlags.TTY.value: - if node_id is None: - raise NotImplementedError - # echo back exec message with cmd for spawning interactive terminal - if command == "bash": - command = "/bin/bash" - res = node.termcmdstring(command) - tlv_data += coreapi.CoreExecuteTlv.pack(ExecuteTlvs.RESULT.value, res) - reply = coreapi.CoreExecMessage.pack(MessageFlags.TTY.value, tlv_data) - return (reply,) - else: - # execute command and send a response - if ( - message.flags & MessageFlags.STRING.value - or message.flags & MessageFlags.TEXT.value - ): - if message.flags & MessageFlags.LOCAL.value: - try: - res = utils.cmd(command) - status = 0 - except CoreCommandError as e: - res = e.stderr - status = e.returncode - else: - try: - res = node.cmd(command) - status = 0 - except CoreCommandError as e: - res = e.stderr - status = e.returncode - if message.flags & MessageFlags.TEXT.value: - tlv_data += coreapi.CoreExecuteTlv.pack( - ExecuteTlvs.RESULT.value, res - ) - if message.flags & MessageFlags.STRING.value: - tlv_data += coreapi.CoreExecuteTlv.pack( - ExecuteTlvs.STATUS.value, status - ) - reply = coreapi.CoreExecMessage.pack(0, tlv_data) - return (reply,) - # execute the command with no response - else: - if message.flags & MessageFlags.LOCAL.value: - utils.mute_detach(command) - else: - node.cmd(command, wait=False) - except CoreError: - logger.exception("error getting object: %s", node_id) - # XXX wait and queue this message to try again later - # XXX maybe this should be done differently - if not message.flags & MessageFlags.LOCAL.value: - time.sleep(0.125) - self.queue_message(message) - - return () - - def handle_register_message(self, message): - """ - Register Message Handler - - :param core.api.tlv.coreapi.CoreRegMessage message: register message to handle - :return: reply messages - """ - replies = [] - - # execute a Python script or XML file - execute_server = message.get_tlv(RegisterTlvs.EXECUTE_SERVER.value) - if execute_server: - try: - logger.info("executing: %s", execute_server) - old_session_ids = set() - if message.flags & MessageFlags.STRING.value: - old_session_ids = set(self.coreemu.sessions.keys()) - sys.argv = shlex.split(execute_server) - file_path = Path(sys.argv[0]) - if file_path.suffix == ".xml": - session = self.coreemu.create_session() - try: - session.open_xml(file_path) - except Exception: - self.coreemu.delete_session(session.id) - raise - else: - utils.execute_script(self.coreemu, file_path, execute_server) - - if message.flags & MessageFlags.STRING.value: - new_session_ids = set(self.coreemu.sessions.keys()) - new_sid = new_session_ids.difference(old_session_ids) - try: - sid = new_sid.pop() - logger.info("executed: %s as session %d", execute_server, sid) - except KeyError: - logger.info( - "executed %s with unknown session ID", execute_server - ) - return replies - - logger.debug("checking session %d for RUNTIME state", sid) - session = self.coreemu.sessions.get(sid) - retries = 10 - # wait for session to enter RUNTIME state, to prevent GUI from - # connecting while nodes are still being instantiated - while session.state != EventTypes.RUNTIME_STATE: - logger.debug( - "waiting for session %d to enter RUNTIME state", sid - ) - time.sleep(1) - retries -= 1 - if retries <= 0: - logger.debug("session %d did not enter RUNTIME state", sid) - return replies - - tlv_data = coreapi.CoreRegisterTlv.pack( - RegisterTlvs.EXECUTE_SERVER.value, execute_server - ) - tlv_data += coreapi.CoreRegisterTlv.pack( - RegisterTlvs.SESSION.value, str(sid) - ) - message = coreapi.CoreRegMessage.pack(0, tlv_data) - replies.append(message) - except Exception as e: - logger.exception("error executing: %s", execute_server) - tlv_data = coreapi.CoreExceptionTlv.pack(ExceptionTlvs.LEVEL.value, 2) - tlv_data += coreapi.CoreExceptionTlv.pack( - ExceptionTlvs.TEXT.value, str(e) - ) - message = coreapi.CoreExceptionMessage.pack(0, tlv_data) - replies.append(message) - - return replies - - gui = message.get_tlv(RegisterTlvs.GUI.value) - if gui is None: - logger.debug("ignoring Register message") - else: - # register capabilities with the GUI - replies.append(self.register()) - replies.append(self.session_message()) - - return replies - - def handle_config_message(self, message): - """ - Configuration Message handler - - :param core.api.tlv.coreapi.CoreConfMessage message: configuration message to handle - :return: reply messages - """ - # convert config message to standard config data object - config_data = ConfigData( - node=message.get_tlv(ConfigTlvs.NODE.value), - object=message.get_tlv(ConfigTlvs.OBJECT.value), - type=message.get_tlv(ConfigTlvs.TYPE.value), - data_types=message.get_tlv(ConfigTlvs.DATA_TYPES.value), - data_values=message.get_tlv(ConfigTlvs.VALUES.value), - captions=message.get_tlv(ConfigTlvs.CAPTIONS.value), - bitmap=message.get_tlv(ConfigTlvs.BITMAP.value), - possible_values=message.get_tlv(ConfigTlvs.POSSIBLE_VALUES.value), - groups=message.get_tlv(ConfigTlvs.GROUPS.value), - session=message.get_tlv(ConfigTlvs.SESSION.value), - iface_id=message.get_tlv(ConfigTlvs.IFACE_ID.value), - network_id=message.get_tlv(ConfigTlvs.NETWORK_ID.value), - opaque=message.get_tlv(ConfigTlvs.OPAQUE.value), - ) - logger.debug( - "configuration message for %s node %s", config_data.object, config_data.node - ) - message_type = ConfigFlags(config_data.type) - - replies = [] - - # handle session configuration - if config_data.object == "all": - replies = self.handle_config_all(message_type, config_data) - elif config_data.object == self.session.options.name: - replies = self.handle_config_session(message_type, config_data) - elif config_data.object == self.session.location.name: - self.handle_config_location(message_type, config_data) - elif config_data.object == "metadata": - replies = self.handle_config_metadata(message_type, config_data) - elif config_data.object == "broker": - self.handle_config_broker(message_type, config_data) - elif config_data.object == self.session.services.name: - replies = self.handle_config_services(message_type, config_data) - elif config_data.object == self.session.mobility.name: - self.handle_config_mobility(message_type, config_data) - elif config_data.object in self.session.mobility.models: - replies = self.handle_config_mobility_models(message_type, config_data) - elif config_data.object in EmaneModelManager.models: - replies = self.handle_config_emane_models(message_type, config_data) - else: - raise Exception("no handler for configuration: %s", config_data.object) - - for reply in replies: - self.handle_broadcast_config(reply) - - return [] - - def handle_config_all(self, message_type, config_data): - replies = [] - - if message_type == ConfigFlags.RESET: - node_id = config_data.node - if node_id is not None: - self.session.mobility.config_reset(node_id) - self.session.emane.config_reset(node_id) - else: - self.session.location.reset() - self.session.services.reset() - self.session.mobility.config_reset() - self.session.emane.config_reset() - else: - raise Exception(f"cant handle config all: {message_type}") - - return replies - - def handle_config_session(self, message_type, config_data): - replies = [] - if message_type == ConfigFlags.REQUEST: - type_flags = ConfigFlags.NONE.value - config = self.session.options.get_configs() - config_response = ConfigShim.config_data( - 0, None, type_flags, self.session.options, config - ) - replies.append(config_response) - elif message_type != ConfigFlags.RESET and config_data.data_values: - values = ConfigShim.str_to_dict(config_data.data_values) - for key in values: - value = values[key] - self.session.options.set_config(key, value) - return replies - - def handle_config_location(self, message_type, config_data): - if message_type == ConfigFlags.RESET: - self.session.location.reset() - else: - if not config_data.data_values: - logger.warning("location data missing") - else: - values = [float(x) for x in config_data.data_values.split("|")] - - # Cartesian coordinate reference point - refx, refy = values[0], values[1] - refz = 0.0 - lat, lon, alt = values[2], values[3], values[4] - # xyz point - self.session.location.refxyz = (refx, refy, refz) - # geographic reference point - self.session.location.setrefgeo(lat, lon, alt) - self.session.location.refscale = values[5] - logger.info( - "location configured: %s = %s scale=%s", - self.session.location.refxyz, - self.session.location.refgeo, - self.session.location.refscale, - ) - - def handle_config_metadata(self, message_type, config_data): - replies = [] - if message_type == ConfigFlags.REQUEST: - node_id = config_data.node - metadata_configs = self.session.metadata - if metadata_configs is None: - metadata_configs = {} - data_values = "|".join( - [f"{x}={metadata_configs[x]}" for x in metadata_configs] - ) - data_types = tuple(ConfigDataTypes.STRING.value for _ in metadata_configs) - config_response = ConfigData( - message_type=0, - node=node_id, - object="metadata", - type=ConfigFlags.NONE.value, - data_types=data_types, - data_values=data_values, - ) - replies.append(config_response) - elif message_type != ConfigFlags.RESET and config_data.data_values: - values = ConfigShim.str_to_dict(config_data.data_values) - for key in values: - value = values[key] - self.session.metadata[key] = value - return replies - - def handle_config_broker(self, message_type, config_data): - if message_type not in [ConfigFlags.REQUEST, ConfigFlags.RESET]: - if not config_data.data_values: - logger.info("emulation server data missing") - else: - values = config_data.data_values.split("|") - - # string of "server:ip:port,server:ip:port,..." - server_strings = values[0] - server_list = server_strings.split(",") - - for server in server_list: - server_items = server.split(":") - name, host, _ = server_items[:3] - self.session.distributed.add_server(name, host) - elif message_type == ConfigFlags.RESET: - self.session.distributed.shutdown() - - def handle_config_services(self, message_type, config_data): - replies = [] - node_id = config_data.node - opaque = config_data.opaque - - if message_type == ConfigFlags.REQUEST: - session_id = config_data.session - opaque = config_data.opaque - - logger.debug( - "configuration request: node(%s) session(%s) opaque(%s)", - node_id, - session_id, - opaque, - ) - - # send back a list of available services - if opaque is None: - type_flag = ConfigFlags.NONE.value - data_types = tuple( - repeat(ConfigDataTypes.BOOL.value, len(ServiceManager.services)) - ) - - # sort groups by name and map services to groups - groups = set() - group_map = {} - for name in ServiceManager.services: - service_name = ServiceManager.services[name] - group = service_name.group - groups.add(group) - group_map.setdefault(group, []).append(service_name) - groups = sorted(groups, key=lambda x: x.lower()) - - # define tlv values in proper order - captions = [] - possible_values = [] - values = [] - group_strings = [] - start_index = 1 - logger.debug("sorted groups: %s", groups) - for group in groups: - services = sorted(group_map[group], key=lambda x: x.name.lower()) - logger.debug("sorted services for group(%s): %s", group, services) - end_index = start_index + len(services) - 1 - group_strings.append(f"{group}:{start_index}-{end_index}") - start_index += len(services) - for service_name in services: - captions.append(service_name.name) - values.append("0") - if service_name.custom_needed: - possible_values.append("1") - else: - possible_values.append("") - - # format for tlv - captions = "|".join(captions) - possible_values = "|".join(possible_values) - values = "|".join(values) - groups = "|".join(group_strings) - # send back the properties for this service - else: - if not node_id: - return replies - - node = self.session.get_node(node_id, CoreNodeBase) - if node is None: - logger.warning( - "request to configure service for unknown node %s", node_id - ) - return replies - - services = ServiceShim.servicesfromopaque(opaque) - if not services: - return replies - - servicesstring = opaque.split(":") - if len(servicesstring) == 3: - # a file request: e.g. "service:zebra:quagga.conf" - file_name = servicesstring[2] - service_name = services[0] - file_data = self.session.services.get_service_file( - node, service_name, file_name - ) - self.session.broadcast_file(file_data) - # short circuit this request early to avoid returning response below - return replies - - # the first service in the list is the one being configured - service_name = services[0] - # send back: - # dirs, configs, startindex, startup, shutdown, metadata, config - type_flag = ConfigFlags.UPDATE.value - data_types = tuple( - repeat(ConfigDataTypes.STRING.value, len(ServiceShim.keys)) - ) - service = self.session.services.get_service( - node_id, service_name, default_service=True - ) - values = ServiceShim.tovaluelist(node, service) - captions = None - possible_values = None - groups = None - - config_response = ConfigData( - message_type=0, - node=node_id, - object=self.session.services.name, - type=type_flag, - data_types=data_types, - data_values=values, - captions=captions, - possible_values=possible_values, - groups=groups, - session=session_id, - opaque=opaque, - ) - replies.append(config_response) - elif message_type == ConfigFlags.RESET: - self.session.services.reset() - else: - data_types = config_data.data_types - values = config_data.data_values - - error_message = "services config message that I don't know how to handle" - if values is None: - logger.error(error_message) - else: - if opaque is None: - values = values.split("|") - # store default services for a node type in self.defaultservices[] - if ( - data_types is None - or data_types[0] != ConfigDataTypes.STRING.value - ): - logger.info(error_message) - return None - key = values.pop(0) - self.session.services.default_services[key] = values - logger.debug("default services for type %s set to %s", key, values) - elif node_id: - services = ServiceShim.servicesfromopaque(opaque) - if services: - service_name = services[0] - - # set custom service for node - self.session.services.set_service(node_id, service_name) - - # set custom values for custom service - service = self.session.services.get_service( - node_id, service_name - ) - if not service: - raise ValueError( - "custom service(%s) for node(%s) does not exist", - service_name, - node_id, - ) - - values = ConfigShim.str_to_dict(values) - for name in values: - value = values[name] - ServiceShim.setvalue(service, name, value) - - return replies - - def handle_config_mobility(self, message_type, _): - if message_type == ConfigFlags.RESET: - self.session.mobility.reset() - - def handle_config_mobility_models(self, message_type, config_data): - replies = [] - node_id = config_data.node - object_name = config_data.object - iface_id = config_data.iface_id - values_str = config_data.data_values - - node_id = utils.iface_config_id(node_id, iface_id) - logger.debug( - "received configure message for %s nodenum: %s", object_name, node_id - ) - if message_type == ConfigFlags.REQUEST: - logger.info("replying to configure request for model: %s", object_name) - typeflags = ConfigFlags.NONE.value - - model_class = self.session.mobility.models.get(object_name) - if not model_class: - logger.warning("model class does not exist: %s", object_name) - return [] - - config = self.session.mobility.get_model_config(node_id, object_name) - config_response = ConfigShim.config_data( - 0, node_id, typeflags, model_class, config - ) - replies.append(config_response) - elif message_type != ConfigFlags.RESET: - # store the configuration values for later use, when the node - if not object_name: - logger.warning("no configuration object for node: %s", node_id) - return [] - - parsed_config = {} - if values_str: - parsed_config = ConfigShim.str_to_dict(values_str) - - self.session.mobility.set_model_config(node_id, object_name, parsed_config) - if self.session.state == EventTypes.RUNTIME_STATE and parsed_config: - try: - node = self.session.get_node(node_id, WlanNode) - if object_name == BasicRangeModel.name: - node.updatemodel(parsed_config) - except CoreError: - logger.error( - "skipping mobility configuration for unknown node: %s", node_id - ) - - return replies - - def handle_config_emane_models(self, message_type, config_data): - replies = [] - node_id = config_data.node - object_name = config_data.object - iface_id = config_data.iface_id - values_str = config_data.data_values - - node_id = utils.iface_config_id(node_id, iface_id) - logger.debug( - "received configure message for %s nodenum: %s", object_name, node_id - ) - if message_type == ConfigFlags.REQUEST: - logger.info("replying to configure request for model: %s", object_name) - typeflags = ConfigFlags.NONE.value - - model_class = self.session.emane.get_model(object_name) - if not model_class: - logger.warning("model class does not exist: %s", object_name) - return [] - - config = self.session.emane.get_config(node_id, object_name) - config_response = ConfigShim.config_data( - 0, node_id, typeflags, model_class, config - ) - replies.append(config_response) - elif message_type != ConfigFlags.RESET: - # store the configuration values for later use, when the node - if not object_name: - logger.warning("no configuration object for node: %s", node_id) - return [] - parsed_config = {} - if values_str: - parsed_config = ConfigShim.str_to_dict(values_str) - self.session.emane.node_models[node_id] = object_name - self.session.emane.set_config(node_id, object_name, parsed_config) - - return replies - - def handle_file_message(self, message): - """ - File Message handler - - :param core.api.tlv.coreapi.CoreFileMessage message: file message to handle - :return: reply messages - """ - if message.flags & MessageFlags.ADD.value: - node_id = message.get_tlv(FileTlvs.NODE.value) - file_name = message.get_tlv(FileTlvs.NAME.value) - file_type = message.get_tlv(FileTlvs.TYPE.value) - src_path = message.get_tlv(FileTlvs.SOURCE_NAME.value) - if src_path: - src_path = Path(src_path) - data = message.get_tlv(FileTlvs.DATA.value) - compressed_data = message.get_tlv(FileTlvs.COMPRESSED_DATA.value) - - if compressed_data: - logger.warning("Compressed file data not implemented for File message.") - return () - - if src_path and data: - logger.warning( - "ignoring invalid File message: source and data TLVs are both present" - ) - return () - - # some File Messages store custom files in services, - # prior to node creation - if file_type is not None: - if file_type.startswith("service:"): - _, service_name = file_type.split(":")[:2] - self.session.services.set_service_file( - node_id, service_name, file_name, data - ) - return () - elif file_type.startswith("hook:"): - _, state = file_type.split(":")[:2] - if not state.isdigit(): - logger.error("error setting hook having state '%s'", state) - return () - state = int(state) - state = EventTypes(state) - self.session.add_hook(state, file_name, data, src_path) - return () - - # writing a file to the host - if node_id is None: - if src_path is not None: - shutil.copy2(src_path, file_name) - else: - with file_name.open("w") as f: - f.write(data) - return () - - file_path = Path(file_name) - self.session.add_node_file(node_id, src_path, file_path, data) - else: - raise NotImplementedError - - return () - - def handle_iface_message(self, message): - """ - Interface Message handler. - - :param message: interface message to handle - :return: reply messages - """ - logger.info("ignoring Interface message") - return () - - def handle_event_message(self, message): - """ - Event Message handler - - :param core.api.tlv.coreapi.CoreEventMessage message: event message to handle - :return: reply messages - :raises core.CoreError: when event type <= SHUTDOWN_STATE and not a known node id - """ - event_type_value = message.get_tlv(EventTlvs.TYPE.value) - event_type = EventTypes(event_type_value) - event_data = EventData( - node=message.get_tlv(EventTlvs.NODE.value), - event_type=event_type, - name=message.get_tlv(EventTlvs.NAME.value), - data=message.get_tlv(EventTlvs.DATA.value), - time=message.get_tlv(EventTlvs.TIME.value), - session=message.get_tlv(EventTlvs.SESSION.value), - ) - - if event_data.event_type is None: - raise NotImplementedError("Event message missing event type") - node_id = event_data.node - - logger.debug("handling event %s at %s", event_type.name, time.ctime()) - if event_type.value <= EventTypes.SHUTDOWN_STATE.value: - if node_id is not None: - node = self.session.get_node(node_id, NodeBase) - - # configure mobility models for WLAN added during runtime - if event_type == EventTypes.INSTANTIATION_STATE and isinstance( - node, WlanNode - ): - self.session.start_mobility(node_ids=[node.id]) - return () - - logger.warning( - "dropping unhandled event message for node: %s", node.name - ) - return () - - if event_type == EventTypes.DEFINITION_STATE: - self.session.set_state(event_type) - # clear all session objects in order to receive new definitions - self.session.clear() - elif event_type == EventTypes.CONFIGURATION_STATE: - self.session.set_state(event_type) - elif event_type == EventTypes.INSTANTIATION_STATE: - self.session.set_state(event_type) - if len(self.handler_threads) > 1: - # TODO: sync handler threads here before continuing - time.sleep(2.0) # XXX - # done receiving node/link configuration, ready to instantiate - self.session.instantiate() - - # after booting nodes attempt to send emulation id for nodes - # waiting on status - for _id in self.session.nodes: - self.send_node_emulation_id(_id) - elif event_type == EventTypes.RUNTIME_STATE: - self.session.set_state(event_type) - logger.warning("Unexpected event message: RUNTIME state received") - elif event_type == EventTypes.DATACOLLECT_STATE: - self.session.data_collect() - elif event_type == EventTypes.SHUTDOWN_STATE: - self.session.set_state(event_type) - logger.warning("Unexpected event message: SHUTDOWN state received") - elif event_type in { - EventTypes.START, - EventTypes.STOP, - EventTypes.RESTART, - EventTypes.PAUSE, - EventTypes.RECONFIGURE, - }: - handled = False - name = event_data.name - if name: - # TODO: register system for event message handlers, - # like confobjs - if name.startswith("service:"): - self.handle_service_event(event_data) - handled = True - elif name.startswith("mobility:"): - self.session.mobility_event(event_data) - handled = True - if not handled: - logger.warning( - "unhandled event message: event type %s, name %s ", - event_type.name, - name, - ) - elif event_type == EventTypes.FILE_OPEN: - file_path = Path(event_data.name) - self.session.open_xml(file_path, start=False) - self.send_objects() - return () - elif event_type == EventTypes.FILE_SAVE: - file_path = Path(event_data.name) - self.session.save_xml(file_path) - elif event_type == EventTypes.SCHEDULED: - etime = event_data.time - node_id = event_data.node - name = event_data.name - data = event_data.data - if etime is None: - logger.warning("Event message scheduled event missing start time") - return () - if message.flags & MessageFlags.ADD.value: - self.session.add_event( - float(etime), node_id=node_id, name=name, data=data - ) - else: - raise NotImplementedError - - return () - - def handle_service_event(self, event_data): - """ - Handle an Event Message used to start, stop, restart, or validate - a service on a given node. - - :param core.emulator.enumerations.EventData event_data: event data to handle - :return: nothing - """ - event_type = event_data.event_type - node_id = event_data.node - name = event_data.name - - try: - node = self.session.get_node(node_id, CoreNodeBase) - except CoreError: - logger.warning( - "ignoring event for service '%s', unknown node '%s'", name, node_id - ) - return - - fail = "" - unknown = [] - services = ServiceShim.servicesfromopaque(name) - for service_name in services: - service = self.session.services.get_service( - node_id, service_name, default_service=True - ) - if not service: - unknown.append(service_name) - continue - - if event_type in [EventTypes.STOP, EventTypes.RESTART]: - status = self.session.services.stop_service(node, service) - if status: - fail += f"Stop {service.name}," - if event_type in [EventTypes.START, EventTypes.RESTART]: - status = self.session.services.startup_service(node, service) - if status: - fail += f"Start ({service.name})," - if event_type == EventTypes.PAUSE: - status = self.session.services.validate_service(node, service) - if status: - fail += f"{service.name}," - if event_type == EventTypes.RECONFIGURE: - self.session.services.service_reconfigure(node, service) - - fail_data = "" - if len(fail) > 0: - fail_data += f"Fail:{fail}" - unknown_data = "" - num = len(unknown) - if num > 0: - for u in unknown: - unknown_data += u - if num > 1: - unknown_data += ", " - num -= 1 - logger.warning("Event requested for unknown service(s): %s", unknown_data) - unknown_data = f"Unknown:{unknown_data}" - - event_data = EventData( - node=node_id, - event_type=event_type, - name=name, - data=fail_data + ";" + unknown_data, - time=str(time.monotonic()), - ) - - self.session.broadcast_event(event_data) - - def handle_session_message(self, message): - """ - Session Message handler - - :param core.api.tlv.coreapi.CoreSessionMessage message: session message to handle - :return: reply messages - """ - session_id_str = message.get_tlv(SessionTlvs.NUMBER.value) - session_ids = coreapi.str_to_list(session_id_str) - name_str = message.get_tlv(SessionTlvs.NAME.value) - names = coreapi.str_to_list(name_str) - file_str = message.get_tlv(SessionTlvs.FILE.value) - files = coreapi.str_to_list(file_str) - thumb = message.get_tlv(SessionTlvs.THUMB.value) - user = message.get_tlv(SessionTlvs.USER.value) - logger.debug( - "SESSION message flags=0x%x sessions=%s", message.flags, session_id_str - ) - - if message.flags == 0: - for index, session_id in enumerate(session_ids): - session_id = int(session_id) - if session_id == 0: - session = self.session - else: - session = self.coreemu.sessions.get(session_id) - if session is None: - logger.warning("session %s not found", session_id) - continue - if names is not None: - session.name = names[index] - if files is not None: - session.file_path = Path(files[index]) - if thumb: - thumb = Path(thumb) - session.set_thumbnail(thumb) - if user: - session.set_user(user) - elif ( - message.flags & MessageFlags.STRING.value - and not message.flags & MessageFlags.ADD.value - ): - # status request flag: send list of sessions - return (self.session_message(),) - else: - # handle ADD or DEL flags - for session_id in session_ids: - session_id = int(session_id) - session = self.coreemu.sessions.get(session_id) - - if session is None: - logger.info( - "session %s not found (flags=0x%x)", session_id, message.flags - ) - continue - - if message.flags & MessageFlags.ADD.value: - # connect to the first session that exists - logger.info("request to connect to session %s", session_id) - - # remove client from session broker and shutdown if needed - self.remove_session_handlers() - clients = self.session_clients[self.session.id] - clients.remove(self) - if not clients and not self.session.is_active(): - self.coreemu.delete_session(self.session.id) - - # set session to join - self.session = session - - # add client to session broker - clients = self.session_clients.setdefault(self.session.id, []) - clients.append(self) - - # add broadcast handlers - logger.info("adding session broadcast handlers") - self.add_session_handlers() - - if user: - self.session.set_user(user) - - if message.flags & MessageFlags.STRING.value: - self.send_objects() - elif message.flags & MessageFlags.DELETE.value: - # shut down the specified session(s) - logger.info("request to terminate session %s", session_id) - self.coreemu.delete_session(session_id) - else: - logger.warning("unhandled session flags for session %s", session_id) - - return () - - def send_node_emulation_id(self, node_id): - """ - Node emulation id to send. - - :param int node_id: node id to send - :return: nothing - """ - if node_id in self.node_status_request: - tlv_data = b"" - tlv_data += coreapi.CoreNodeTlv.pack(NodeTlvs.NUMBER.value, node_id) - tlv_data += coreapi.CoreNodeTlv.pack(NodeTlvs.EMULATION_ID.value, node_id) - reply = coreapi.CoreNodeMessage.pack( - MessageFlags.ADD.value | MessageFlags.LOCAL.value, tlv_data - ) - - try: - self.sendall(reply) - except IOError: - logger.exception("error sending node emulation id message: %s", node_id) - - del self.node_status_request[node_id] - - def send_objects(self): - """ - Return API messages that describe the current session. - """ - # find all nodes and links - all_links = [] - with self.session.nodes_lock: - for node_id in self.session.nodes: - node = self.session.nodes[node_id] - self.session.broadcast_node(node, MessageFlags.ADD) - links = node.links(flags=MessageFlags.ADD) - all_links.extend(links) - - for link in all_links: - self.session.broadcast_link(link) - - # send mobility model info - for node_id in self.session.mobility.nodes(): - mobility_configs = self.session.mobility.get_all_configs(node_id) - for model_name in mobility_configs: - config = mobility_configs[model_name] - model_class = self.session.mobility.models[model_name] - logger.debug( - "mobility config: node(%s) class(%s) values(%s)", - node_id, - model_class, - config, - ) - config_data = ConfigShim.config_data( - 0, node_id, ConfigFlags.UPDATE.value, model_class, config - ) - self.session.broadcast_config(config_data) - - # send emane model configs - for node_id, model_configs in self.session.emane.node_configs.items(): - for model_name, config in model_configs.items(): - model_class = self.session.emane.get_model(model_name) - logger.debug( - "emane config: node(%s) class(%s) values(%s)", - node_id, - model_class, - config, - ) - config_data = ConfigShim.config_data( - 0, node_id, ConfigFlags.UPDATE.value, model_class, config - ) - self.session.broadcast_config(config_data) - - # service customizations - service_configs = self.session.services.all_configs() - for node_id, service in service_configs: - opaque = f"service:{service.name}" - data_types = tuple( - repeat(ConfigDataTypes.STRING.value, len(ServiceShim.keys)) - ) - node = self.session.get_node(node_id, CoreNodeBase) - values = ServiceShim.tovaluelist(node, service) - config_data = ConfigData( - message_type=0, - node=node_id, - object=self.session.services.name, - type=ConfigFlags.UPDATE.value, - data_types=data_types, - data_values=values, - session=self.session.id, - opaque=opaque, - ) - self.session.broadcast_config(config_data) - - for file_name, config_data in self.session.services.all_files(service): - file_data = FileData( - message_type=MessageFlags.ADD, - node=node_id, - name=str(file_name), - type=opaque, - data=str(config_data), - ) - self.session.broadcast_file(file_data) - - # TODO: send location info - - # send hook scripts - for state in sorted(self.session.hooks): - for file_name, config_data in self.session.hooks[state]: - file_data = FileData( - message_type=MessageFlags.ADD, - name=str(file_name), - type=f"hook:{state.value}", - data=str(config_data), - ) - self.session.broadcast_file(file_data) - - # send session configuration - session_config = self.session.options.get_configs() - config_data = ConfigShim.config_data( - 0, None, ConfigFlags.UPDATE.value, self.session.options, session_config - ) - self.session.broadcast_config(config_data) - - # send session metadata - metadata_configs = self.session.metadata - if metadata_configs: - data_values = "|".join( - [f"{x}={metadata_configs[x]}" for x in metadata_configs] - ) - data_types = tuple( - ConfigDataTypes.STRING.value for _ in self.session.metadata - ) - config_data = ConfigData( - message_type=0, - object="metadata", - type=ConfigFlags.NONE.value, - data_types=data_types, - data_values=data_values, - ) - self.session.broadcast_config(config_data) - - node_count = self.session.get_node_count() - logger.info( - "informed GUI about %d nodes and %d links", node_count, len(all_links) - ) - - -class CoreUdpHandler(CoreHandler): - def __init__(self, request, client_address, server): - self.message_handlers = { - MessageTypes.NODE.value: self.handle_node_message, - MessageTypes.LINK.value: self.handle_link_message, - MessageTypes.EXECUTE.value: self.handle_execute_message, - MessageTypes.REGISTER.value: self.handle_register_message, - MessageTypes.CONFIG.value: self.handle_config_message, - MessageTypes.FILE.value: self.handle_file_message, - MessageTypes.INTERFACE.value: self.handle_iface_message, - MessageTypes.EVENT.value: self.handle_event_message, - MessageTypes.SESSION.value: self.handle_session_message, - } - self.session = None - self.coreemu = server.mainserver.coreemu - self.tcp_handler = server.RequestHandlerClass - socketserver.BaseRequestHandler.__init__(self, request, client_address, server) - - def setup(self): - """ - Client has connected, set up a new connection. - :return: nothing - """ - pass - - def receive_message(self): - data = self.request[0] - header = data[: coreapi.CoreMessage.header_len] - if len(header) < coreapi.CoreMessage.header_len: - raise IOError(f"error receiving header (received {len(header)} bytes)") - - message_type, message_flags, message_len = coreapi.CoreMessage.unpack_header( - header - ) - if message_len == 0: - logger.warning("received message with no data") - return - - if len(data) != coreapi.CoreMessage.header_len + message_len: - logger.error( - "received message length does not match received data (%s != %s)", - len(data), - coreapi.CoreMessage.header_len + message_len, - ) - raise IOError - - try: - message_class = coreapi.CLASS_MAP[message_type] - message = message_class( - message_flags, header, data[coreapi.CoreMessage.header_len :] - ) - return message - except KeyError: - message = coreapi.CoreMessage( - message_flags, header, data[coreapi.CoreMessage.header_len :] - ) - message.msgtype = message_type - logger.exception("unimplemented core message type: %s", message.type_str()) - - def handle(self): - message = self.receive_message() - sessions = message.session_numbers() - message.queuedtimes = 0 - if sessions: - for session_id in sessions: - session = self.server.mainserver.coreemu.sessions.get(session_id) - if session: - logger.debug("session handling message: %s", session.id) - self.session = session - self.handle_message(message) - self.broadcast(message) - else: - logger.error( - "session %d in %s message not found.", - session_id, - message.type_str(), - ) - else: - # no session specified, find an existing one - session = None - node_count = 0 - for session_id in self.server.mainserver.coreemu.sessions: - current_session = self.server.mainserver.coreemu.sessions[session_id] - current_node_count = current_session.get_node_count() - if ( - current_session.state == EventTypes.RUNTIME_STATE - and current_node_count > node_count - ): - node_count = current_node_count - session = current_session - - if session or message.message_type == MessageTypes.REGISTER.value: - self.session = session - self.handle_message(message) - self.broadcast(message) - else: - logger.error( - "no active session, dropping %s message.", message.type_str() - ) - - def broadcast(self, message): - if not isinstance(message, (coreapi.CoreNodeMessage, coreapi.CoreLinkMessage)): - return - - clients = self.tcp_handler.session_clients.get(self.session.id, []) - for client in clients: - try: - client.sendall(message.raw_message) - except IOError: - logger.error("error broadcasting") - - def finish(self): - return socketserver.BaseRequestHandler.finish(self) - - def queuemsg(self, msg): - """ - UDP handlers are short-lived and do not have message queues. - - :param bytes msg: message to queue - :return: - """ - raise Exception( - f"Unable to queue {msg} message for later processing using UDP!" - ) - - def sendall(self, data): - """ - Use sendto() on the connectionless UDP socket. - - :param data: - :return: - """ - self.request[1].sendto(data, self.client_address) diff --git a/daemon/core/api/tlv/coreserver.py b/daemon/core/api/tlv/coreserver.py deleted file mode 100644 index c51e8023..00000000 --- a/daemon/core/api/tlv/coreserver.py +++ /dev/null @@ -1,60 +0,0 @@ -""" -Defines core server for handling TCP connections. -""" - -import socketserver - -from core.emulator.coreemu import CoreEmu - - -class CoreServer(socketserver.ThreadingMixIn, socketserver.TCPServer): - """ - TCP server class, manages sessions and spawns request handlers for - incoming connections. - """ - - daemon_threads = True - allow_reuse_address = True - - def __init__(self, server_address, handler_class, config=None): - """ - Server class initialization takes configuration data and calls - the socketserver constructor. - - :param tuple[str, int] server_address: server host and port to use - :param class handler_class: request handler - :param dict config: configuration setting - """ - self.coreemu = CoreEmu(config) - self.config = config - socketserver.TCPServer.__init__(self, server_address, handler_class) - - -class CoreUdpServer(socketserver.ThreadingMixIn, socketserver.UDPServer): - """ - UDP server class, manages sessions and spawns request handlers for - incoming connections. - """ - - daemon_threads = True - allow_reuse_address = True - - def __init__(self, server_address, handler_class, mainserver): - """ - Server class initialization takes configuration data and calls - the SocketServer constructor - - :param server_address: - :param class handler_class: request handler - :param mainserver: - """ - self.mainserver = mainserver - socketserver.UDPServer.__init__(self, server_address, handler_class) - - def start(self): - """ - Thread target to run concurrently with the TCP server. - - :return: nothing - """ - self.serve_forever() diff --git a/daemon/core/api/tlv/dataconversion.py b/daemon/core/api/tlv/dataconversion.py deleted file mode 100644 index d625a615..00000000 --- a/daemon/core/api/tlv/dataconversion.py +++ /dev/null @@ -1,178 +0,0 @@ -""" -Converts CORE data objects into legacy API messages. -""" -import logging -from collections import OrderedDict -from typing import Dict, List - -from core.api.tlv import coreapi, structutils -from core.api.tlv.enumerations import ConfigTlvs, NodeTlvs -from core.config import ConfigGroup, ConfigurableOptions -from core.emulator.data import ConfigData, NodeData - -logger = logging.getLogger(__name__) - - -def convert_node(node_data: NodeData): - """ - Convenience method for converting NodeData to a packed TLV message. - - :param core.emulator.data.NodeData node_data: node data to convert - :return: packed node message - """ - node = node_data.node - services = None - if node.services is not None: - services = "|".join([x.name for x in node.services]) - server = None - if node.server is not None: - server = node.server.name - tlv_data = structutils.pack_values( - coreapi.CoreNodeTlv, - [ - (NodeTlvs.NUMBER, node.id), - (NodeTlvs.TYPE, node.apitype.value), - (NodeTlvs.NAME, node.name), - (NodeTlvs.MODEL, node.type), - (NodeTlvs.EMULATION_SERVER, server), - (NodeTlvs.X_POSITION, int(node.position.x)), - (NodeTlvs.Y_POSITION, int(node.position.y)), - (NodeTlvs.CANVAS, node.canvas), - (NodeTlvs.SERVICES, services), - (NodeTlvs.LATITUDE, str(node.position.lat)), - (NodeTlvs.LONGITUDE, str(node.position.lon)), - (NodeTlvs.ALTITUDE, str(node.position.alt)), - (NodeTlvs.ICON, node.icon), - ], - ) - return coreapi.CoreNodeMessage.pack(node_data.message_type.value, tlv_data) - - -def convert_config(config_data): - """ - Convenience method for converting ConfigData to a packed TLV message. - - :param core.emulator.data.ConfigData config_data: config data to convert - :return: packed message - """ - session = None - if config_data.session is not None: - session = str(config_data.session) - tlv_data = structutils.pack_values( - coreapi.CoreConfigTlv, - [ - (ConfigTlvs.NODE, config_data.node), - (ConfigTlvs.OBJECT, config_data.object), - (ConfigTlvs.TYPE, config_data.type), - (ConfigTlvs.DATA_TYPES, config_data.data_types), - (ConfigTlvs.VALUES, config_data.data_values), - (ConfigTlvs.CAPTIONS, config_data.captions), - (ConfigTlvs.BITMAP, config_data.bitmap), - (ConfigTlvs.POSSIBLE_VALUES, config_data.possible_values), - (ConfigTlvs.GROUPS, config_data.groups), - (ConfigTlvs.SESSION, session), - (ConfigTlvs.IFACE_ID, config_data.iface_id), - (ConfigTlvs.NETWORK_ID, config_data.network_id), - (ConfigTlvs.OPAQUE, config_data.opaque), - ], - ) - return coreapi.CoreConfMessage.pack(config_data.message_type, tlv_data) - - -class ConfigShim: - """ - Provides helper methods for converting newer configuration values into TLV - compatible formats. - """ - - @classmethod - def str_to_dict(cls, key_values: str) -> Dict[str, str]: - """ - Converts a TLV key/value string into an ordered mapping. - - :param key_values: - :return: ordered mapping of key/value pairs - """ - key_values = key_values.split("|") - values = OrderedDict() - for key_value in key_values: - key, value = key_value.split("=", 1) - values[key] = value - return values - - @classmethod - def groups_to_str(cls, config_groups: List[ConfigGroup]) -> str: - """ - Converts configuration groups to a TLV formatted string. - - :param config_groups: configuration groups to format - :return: TLV configuration group string - """ - group_strings = [] - for config_group in config_groups: - group_string = ( - f"{config_group.name}:{config_group.start}-{config_group.stop}" - ) - group_strings.append(group_string) - return "|".join(group_strings) - - @classmethod - def config_data( - cls, - flags: int, - node_id: int, - type_flags: int, - configurable_options: ConfigurableOptions, - config: Dict[str, str], - ) -> ConfigData: - """ - Convert this class to a Config API message. Some TLVs are defined - by the class, but node number, conf type flags, and values must - be passed in. - - :param flags: message flags - :param node_id: node id - :param type_flags: type flags - :param configurable_options: options to create config data for - :param config: configuration values for options - :return: configuration data object - """ - key_values = None - captions = None - data_types = [] - possible_values = [] - logger.debug("configurable: %s", configurable_options) - logger.debug("configuration options: %s", configurable_options.configurations) - logger.debug("configuration data: %s", config) - for configuration in configurable_options.configurations(): - if not captions: - captions = configuration.label - else: - captions += f"|{configuration.label}" - - data_types.append(configuration.type.value) - - options = ",".join(configuration.options) - possible_values.append(options) - - _id = configuration.id - config_value = config.get(_id, configuration.default) - key_value = f"{_id}={config_value}" - if not key_values: - key_values = key_value - else: - key_values += f"|{key_value}" - - groups_str = cls.groups_to_str(configurable_options.config_groups()) - return ConfigData( - message_type=flags, - node=node_id, - object=configurable_options.name, - type=type_flags, - data_types=tuple(data_types), - data_values=key_values, - captions=captions, - possible_values="|".join(possible_values), - bitmap=configurable_options.bitmap, - groups=groups_str, - ) diff --git a/daemon/core/api/tlv/enumerations.py b/daemon/core/api/tlv/enumerations.py deleted file mode 100644 index f2b35703..00000000 --- a/daemon/core/api/tlv/enumerations.py +++ /dev/null @@ -1,212 +0,0 @@ -""" -Enumerations specific to the CORE TLV API. -""" -from enum import Enum - -CORE_API_PORT = 4038 - - -class MessageTypes(Enum): - """ - CORE message types. - """ - - NODE = 0x01 - LINK = 0x02 - EXECUTE = 0x03 - REGISTER = 0x04 - CONFIG = 0x05 - FILE = 0x06 - INTERFACE = 0x07 - EVENT = 0x08 - SESSION = 0x09 - EXCEPTION = 0x0A - - -class NodeTlvs(Enum): - """ - Node type, length, value enumerations. - """ - - NUMBER = 0x01 - TYPE = 0x02 - NAME = 0x03 - IP_ADDRESS = 0x04 - MAC_ADDRESS = 0x05 - IP6_ADDRESS = 0x06 - MODEL = 0x07 - EMULATION_SERVER = 0x08 - SESSION = 0x0A - X_POSITION = 0x20 - Y_POSITION = 0x21 - CANVAS = 0x22 - EMULATION_ID = 0x23 - NETWORK_ID = 0x24 - SERVICES = 0x25 - LATITUDE = 0x30 - LONGITUDE = 0x31 - ALTITUDE = 0x32 - ICON = 0x42 - OPAQUE = 0x50 - - -class LinkTlvs(Enum): - """ - Link type, length, value enumerations. - """ - - N1_NUMBER = 0x01 - N2_NUMBER = 0x02 - DELAY = 0x03 - BANDWIDTH = 0x04 - LOSS = 0x05 - DUP = 0x06 - JITTER = 0x07 - MER = 0x08 - BURST = 0x09 - SESSION = 0x0A - MBURST = 0x10 - TYPE = 0x20 - GUI_ATTRIBUTES = 0x21 - UNIDIRECTIONAL = 0x22 - EMULATION_ID = 0x23 - NETWORK_ID = 0x24 - KEY = 0x25 - IFACE1_NUMBER = 0x30 - IFACE1_IP4 = 0x31 - IFACE1_IP4_MASK = 0x32 - IFACE1_MAC = 0x33 - IFACE1_IP6 = 0x34 - IFACE1_IP6_MASK = 0x35 - IFACE2_NUMBER = 0x36 - IFACE2_IP4 = 0x37 - IFACE2_IP4_MASK = 0x38 - IFACE2_MAC = 0x39 - IFACE2_IP6 = 0x40 - IFACE2_IP6_MASK = 0x41 - IFACE1_NAME = 0x42 - IFACE2_NAME = 0x43 - OPAQUE = 0x50 - - -class ExecuteTlvs(Enum): - """ - Execute type, length, value enumerations. - """ - - NODE = 0x01 - NUMBER = 0x02 - TIME = 0x03 - COMMAND = 0x04 - RESULT = 0x05 - STATUS = 0x06 - SESSION = 0x0A - - -class ConfigTlvs(Enum): - """ - Configuration type, length, value enumerations. - """ - - NODE = 0x01 - OBJECT = 0x02 - TYPE = 0x03 - DATA_TYPES = 0x04 - VALUES = 0x05 - CAPTIONS = 0x06 - BITMAP = 0x07 - POSSIBLE_VALUES = 0x08 - GROUPS = 0x09 - SESSION = 0x0A - IFACE_ID = 0x0B - NETWORK_ID = 0x24 - OPAQUE = 0x50 - - -class ConfigFlags(Enum): - """ - Configuration flags. - """ - - NONE = 0x00 - REQUEST = 0x01 - UPDATE = 0x02 - RESET = 0x03 - - -class FileTlvs(Enum): - """ - File type, length, value enumerations. - """ - - NODE = 0x01 - NAME = 0x02 - MODE = 0x03 - NUMBER = 0x04 - TYPE = 0x05 - SOURCE_NAME = 0x06 - SESSION = 0x0A - DATA = 0x10 - COMPRESSED_DATA = 0x11 - - -class InterfaceTlvs(Enum): - """ - Interface type, length, value enumerations. - """ - - NODE = 0x01 - NUMBER = 0x02 - NAME = 0x03 - IP_ADDRESS = 0x04 - MASK = 0x05 - MAC_ADDRESS = 0x06 - IP6_ADDRESS = 0x07 - IP6_MASK = 0x08 - TYPE = 0x09 - SESSION = 0x0A - STATE = 0x0B - EMULATION_ID = 0x23 - NETWORK_ID = 0x24 - - -class EventTlvs(Enum): - """ - Event type, length, value enumerations. - """ - - NODE = 0x01 - TYPE = 0x02 - NAME = 0x03 - DATA = 0x04 - TIME = 0x05 - SESSION = 0x0A - - -class SessionTlvs(Enum): - """ - Session type, length, value enumerations. - """ - - NUMBER = 0x01 - NAME = 0x02 - FILE = 0x03 - NODE_COUNT = 0x04 - DATE = 0x05 - THUMB = 0x06 - USER = 0x07 - OPAQUE = 0x0A - - -class ExceptionTlvs(Enum): - """ - Exception type, length, value enumerations. - """ - - NODE = 0x01 - SESSION = 0x02 - LEVEL = 0x03 - SOURCE = 0x04 - DATE = 0x05 - TEXT = 0x06 - OPAQUE = 0x0A diff --git a/daemon/core/api/tlv/structutils.py b/daemon/core/api/tlv/structutils.py deleted file mode 100644 index d67f388e..00000000 --- a/daemon/core/api/tlv/structutils.py +++ /dev/null @@ -1,45 +0,0 @@ -""" -Utilities for working with python struct data. -""" - -import logging - -logger = logging.getLogger(__name__) - - -def pack_values(clazz, packers): - """ - Pack values for a given legacy class. - - :param class clazz: class that will provide a pack method - :param list packers: a list of tuples that are used to pack values and transform them - :return: packed data string of all values - """ - - # iterate through tuples of values to pack - logger.debug("packing: %s", packers) - data = b"" - for packer in packers: - # check if a transformer was provided for valid values - transformer = None - if len(packer) == 2: - tlv_type, value = packer - elif len(packer) == 3: - tlv_type, value, transformer = packer - else: - raise RuntimeError("packer had more than 3 arguments") - - # only pack actual values and avoid packing empty strings - # protobuf defaults to empty strings and does no imply a value to set - if value is None or (isinstance(value, str) and not value): - continue - - # transform values as needed - if transformer: - value = transformer(value) - - # pack and add to existing data - logger.debug("packing: %s - %s type(%s)", tlv_type, value, type(value)) - data += clazz.pack(tlv_type.value, value) - - return data diff --git a/daemon/core/config.py b/daemon/core/config.py index b705e8b6..de08649a 100644 --- a/daemon/core/config.py +++ b/daemon/core/config.py @@ -113,7 +113,6 @@ class ConfigurableOptions: """ name: Optional[str] = None - bitmap: Optional[str] = None options: List[Configuration] = [] @classmethod diff --git a/daemon/core/configservices/frrservices/services.py b/daemon/core/configservices/frrservices/services.py index f09428ca..e08481c2 100644 --- a/daemon/core/configservices/frrservices/services.py +++ b/daemon/core/configservices/frrservices/services.py @@ -4,14 +4,25 @@ from typing import Any, Dict, List from core.config import Configuration from core.configservice.base import ConfigService, ConfigServiceMode from core.emane.nodes import EmaneNet -from core.nodes.base import CoreNodeBase +from core.nodes.base import CoreNodeBase, NodeBase from core.nodes.interface import DEFAULT_MTU, CoreInterface from core.nodes.network import WlanNode +from core.nodes.wireless import WirelessNode GROUP: str = "FRR" FRR_STATE_DIR: str = "/var/run/frr" +def is_wireless(node: NodeBase) -> bool: + """ + Check if the node is a wireless type node. + + :param node: node to check type for + :return: True if wireless type, False otherwise + """ + return isinstance(node, (WlanNode, EmaneNet, WirelessNode)) + + def has_mtu_mismatch(iface: CoreInterface) -> bool: """ Helper to detect MTU mismatch and add the appropriate FRR @@ -324,7 +335,7 @@ class FRRBabel(FrrService, ConfigService): return self.render_text(text, data) def frr_iface_config(self, iface: CoreInterface) -> str: - if isinstance(iface.net, (WlanNode, EmaneNet)): + if is_wireless(iface.net): text = """ babel wireless no babel split-horizon diff --git a/daemon/core/configservices/quaggaservices/services.py b/daemon/core/configservices/quaggaservices/services.py index a4ee157d..2bafeff6 100644 --- a/daemon/core/configservices/quaggaservices/services.py +++ b/daemon/core/configservices/quaggaservices/services.py @@ -5,16 +5,27 @@ from typing import Any, Dict, List from core.config import Configuration from core.configservice.base import ConfigService, ConfigServiceMode from core.emane.nodes import EmaneNet -from core.nodes.base import CoreNodeBase +from core.nodes.base import CoreNodeBase, NodeBase from core.nodes.interface import DEFAULT_MTU, CoreInterface from core.nodes.network import PtpNet, WlanNode from core.nodes.physical import Rj45Node +from core.nodes.wireless import WirelessNode logger = logging.getLogger(__name__) GROUP: str = "Quagga" QUAGGA_STATE_DIR: str = "/var/run/quagga" +def is_wireless(node: NodeBase) -> bool: + """ + Check if the node is a wireless type node. + + :param node: node to check type for + :return: True if wireless type, False otherwise + """ + return isinstance(node, (WlanNode, EmaneNet, WirelessNode)) + + def has_mtu_mismatch(iface: CoreInterface) -> bool: """ Helper to detect MTU mismatch and add the appropriate OSPF @@ -265,7 +276,7 @@ class Ospfv3mdr(Ospfv3): def quagga_iface_config(self, iface: CoreInterface) -> str: config = super().quagga_iface_config(iface) - if isinstance(iface.net, (WlanNode, EmaneNet)): + if is_wireless(iface.net): config = self.clean_text( f""" {config} @@ -390,7 +401,7 @@ class Babel(QuaggaService, ConfigService): return self.render_text(text, data) def quagga_iface_config(self, iface: CoreInterface) -> str: - if isinstance(iface.net, (WlanNode, EmaneNet)): + if is_wireless(iface.net): text = """ babel wireless no babel split-horizon diff --git a/daemon/core/emane/emanemanager.py b/daemon/core/emane/emanemanager.py index 4ffed725..95ebf90e 100644 --- a/daemon/core/emane/emanemanager.py +++ b/daemon/core/emane/emanemanager.py @@ -12,12 +12,12 @@ from core import utils from core.emane.emanemodel import EmaneModel from core.emane.linkmonitor import EmaneLinkMonitor from core.emane.modelmanager import EmaneModelManager -from core.emane.nodes import EmaneNet +from core.emane.nodes import EmaneNet, TunTap from core.emulator.data import LinkData from core.emulator.enumerations import LinkTypes, MessageFlags, RegisterTlvs from core.errors import CoreCommandError, CoreError -from core.nodes.base import CoreNetworkBase, CoreNode, NodeBase -from core.nodes.interface import CoreInterface, TunTap +from core.nodes.base import CoreNode, NodeBase +from core.nodes.interface import CoreInterface from core.xml import emanexml logger = logging.getLogger(__name__) @@ -224,11 +224,9 @@ class EmaneManager: :return: net, node, or interface model configuration """ model_name = emane_net.model.name - config = None # try to retrieve interface specific configuration - if iface.node_id is not None: - key = utils.iface_config_id(iface.node.id, iface.node_id) - config = self.get_config(key, model_name, default=False) + key = utils.iface_config_id(iface.node.id, iface.id) + config = self.get_config(key, model_name, default=False) # attempt to retrieve node specific config, when iface config is not present if not config: config = self.get_config(iface.node.id, model_name, default=False) @@ -272,7 +270,8 @@ class EmaneManager: nodes = set() for emane_net in self._emane_nets.values(): for iface in emane_net.get_ifaces(): - nodes.add(iface.node) + if isinstance(iface.node, CoreNode): + nodes.add(iface.node) return nodes def setup(self) -> EmaneState: @@ -323,7 +322,7 @@ class EmaneManager: for emane_net, iface in self.get_ifaces(): self.start_iface(emane_net, iface) - def start_iface(self, emane_net: EmaneNet, iface: CoreInterface) -> None: + def start_iface(self, emane_net: EmaneNet, iface: TunTap) -> None: nem_id = self.next_nem_id(iface) nem_port = self.get_nem_port(iface) logger.info( @@ -338,7 +337,7 @@ class EmaneManager: self.start_daemon(iface) self.install_iface(iface, config) - def get_ifaces(self) -> List[Tuple[EmaneNet, CoreInterface]]: + def get_ifaces(self) -> List[Tuple[EmaneNet, TunTap]]: ifaces = [] for emane_net in self._emane_nets.values(): if not emane_net.model: @@ -352,8 +351,9 @@ class EmaneManager: iface.name, ) continue - ifaces.append((emane_net, iface)) - return sorted(ifaces, key=lambda x: (x[1].node.id, x[1].node_id)) + if isinstance(iface, TunTap): + ifaces.append((emane_net, iface)) + return sorted(ifaces, key=lambda x: (x[1].node.id, x[1].id)) def setup_control_channels( self, nem_id: int, iface: CoreInterface, config: Dict[str, str] @@ -622,9 +622,9 @@ class EmaneManager: args = f"{emanecmd} -f {log_file} {platform_xml}" node.host_cmd(args, cwd=self.session.directory) - def install_iface(self, iface: CoreInterface, config: Dict[str, str]) -> None: + def install_iface(self, iface: TunTap, config: Dict[str, str]) -> None: external = config.get("external", "0") - if isinstance(iface, TunTap) and external == "0": + if external == "0": iface.set_ips() # at this point we register location handlers for generating # EMANE location events @@ -732,9 +732,6 @@ class EmaneManager: self.session.broadcast_node(node) return True - def is_emane_net(self, net: Optional[CoreNetworkBase]) -> bool: - return isinstance(net, EmaneNet) - def emanerunning(self, node: CoreNode) -> bool: """ Return True if an EMANE process associated with the given node is running, diff --git a/daemon/core/emane/nodes.py b/daemon/core/emane/nodes.py index 76a93767..a32814e1 100644 --- a/daemon/core/emane/nodes.py +++ b/daemon/core/emane/nodes.py @@ -4,7 +4,8 @@ share the same MAC+PHY model. """ import logging -from typing import TYPE_CHECKING, Dict, List, Optional, Type +import time +from typing import TYPE_CHECKING, Callable, Dict, List, Optional, Type from core.emulator.data import InterfaceData, LinkData, LinkOptions from core.emulator.distributed import DistributedServer @@ -15,7 +16,7 @@ from core.emulator.enumerations import ( NodeTypes, RegisterTlvs, ) -from core.errors import CoreError +from core.errors import CoreCommandError, CoreError from core.nodes.base import CoreNetworkBase, CoreNode from core.nodes.interface import CoreInterface @@ -39,6 +40,114 @@ except ImportError: logger.debug("compatible emane python bindings not installed") +class TunTap(CoreInterface): + """ + TUN/TAP virtual device in TAP mode + """ + + def __init__( + self, + _id: int, + name: str, + localname: str, + use_ovs: bool, + node: CoreNode = None, + server: "DistributedServer" = None, + ) -> None: + super().__init__(_id, name, localname, use_ovs, node=node, server=server) + self.node: CoreNode = node + + def startup(self) -> None: + """ + Startup logic for a tunnel tap. + + :return: nothing + """ + self.up = True + + def shutdown(self) -> None: + """ + Shutdown functionality for a tunnel tap. + + :return: nothing + """ + if not self.up: + return + self.up = False + + def waitfor( + self, func: Callable[[], int], attempts: int = 10, maxretrydelay: float = 0.25 + ) -> bool: + """ + Wait for func() to return zero with exponential backoff. + + :param func: function to wait for a result of zero + :param attempts: number of attempts to wait for a zero result + :param maxretrydelay: maximum retry delay + :return: True if wait succeeded, False otherwise + """ + delay = 0.01 + result = False + for i in range(1, attempts + 1): + r = func() + if r == 0: + result = True + break + msg = f"attempt {i} failed with nonzero exit status {r}" + if i < attempts + 1: + msg += ", retrying..." + logger.info(msg) + time.sleep(delay) + delay += delay + if delay > maxretrydelay: + delay = maxretrydelay + else: + msg += ", giving up" + logger.info(msg) + return result + + def nodedevexists(self) -> int: + """ + Checks if device exists. + + :return: 0 if device exists, 1 otherwise + """ + try: + self.node.node_net_client.device_show(self.name) + return 0 + except CoreCommandError: + return 1 + + def waitfordevicenode(self) -> None: + """ + Check for presence of a node device - tap device may not appear right away waits. + + :return: nothing + """ + logger.debug("waiting for device node: %s", self.name) + count = 0 + while True: + result = self.waitfor(self.nodedevexists) + if result: + break + should_retry = count < 5 + is_emane_running = self.node.session.emane.emanerunning(self.node) + if all([should_retry, is_emane_running]): + count += 1 + else: + raise RuntimeError("node device failed to exist") + + def set_ips(self) -> None: + """ + Set interface ip addresses. + + :return: nothing + """ + self.waitfordevicenode() + for ip in self.ips(): + self.node.node_net_client.create_address(self.name, str(ip)) + + class EmaneNet(CoreNetworkBase): """ EMANE node contains NEM configuration and causes connected nodes @@ -49,7 +158,6 @@ class EmaneNet(CoreNetworkBase): apitype: NodeTypes = NodeTypes.EMANE linktype: LinkTypes = LinkTypes.WIRED type: str = "wlan" - has_custom_iface: bool = True def __init__( self, @@ -73,14 +181,11 @@ class EmaneNet(CoreNetworkBase): return self.model.linkconfig(iface, options, iface2) - def config(self, conf: str) -> None: - self.conf = conf - def startup(self) -> None: - pass + self.up = True def shutdown(self) -> None: - pass + self.up = False def link(self, iface1: CoreInterface, iface2: CoreInterface) -> None: pass @@ -88,10 +193,13 @@ class EmaneNet(CoreNetworkBase): def unlink(self, iface1: CoreInterface, iface2: CoreInterface) -> None: pass - def linknet(self, net: "CoreNetworkBase") -> CoreInterface: - raise CoreError("emane networks cannot be linked to other networks") - def updatemodel(self, config: Dict[str, str]) -> None: + """ + Update configuration for the current model. + + :param config: configuration to update model with + :return: nothing + """ if not self.model: raise CoreError(f"no model set to update for node({self.name})") logger.info("node(%s) updating model(%s): %s", self.id, self.model.name, config) @@ -111,7 +219,7 @@ class EmaneNet(CoreNetworkBase): self.mobility.update_config(config) def links(self, flags: MessageFlags = MessageFlags.NONE) -> List[LinkData]: - links = super().links(flags) + links = [] emane_manager = self.session.emane # gather current emane links nem_ids = set() @@ -132,22 +240,44 @@ class EmaneNet(CoreNetworkBase): # ignore incomplete links if (nem2, nem1) not in emane_links: continue - link = emane_manager.get_nem_link(nem1, nem2) + link = emane_manager.get_nem_link(nem1, nem2, flags) if link: links.append(link) return links - def custom_iface(self, node: CoreNode, iface_data: InterfaceData) -> CoreInterface: - # TUN/TAP is not ready for addressing yet; the device may - # take some time to appear, and installing it into a - # namespace after it has been bound removes addressing; - # save addresses with the interface now - iface_id = node.newtuntap(iface_data.id, iface_data.name) - node.attachnet(iface_id, self) - iface = node.get_iface(iface_id) - iface.set_mac(iface_data.mac) - for ip in iface_data.get_ips(): - iface.add_ip(ip) + def create_tuntap(self, node: CoreNode, iface_data: InterfaceData) -> CoreInterface: + """ + Create a tuntap interface for the provided node. + + :param node: node to create tuntap interface for + :param iface_data: interface data to create interface with + :return: created tuntap interface + """ + with node.lock: + if iface_data.id is not None and iface_data.id in node.ifaces: + raise CoreError( + f"node({self.id}) interface({iface_data.id}) already exists" + ) + iface_id = ( + iface_data.id if iface_data.id is not None else node.next_iface_id() + ) + name = iface_data.name if iface_data.name is not None else f"eth{iface_id}" + session_id = self.session.short_session_id() + localname = f"tap{node.id}.{iface_id}.{session_id}" + iface = TunTap(iface_id, name, localname, self.session.use_ovs(), node=node) + if iface_data.mac: + iface.set_mac(iface_data.mac) + for ip in iface_data.get_ips(): + iface.add_ip(ip) + node.ifaces[iface_id] = iface + self.attach(iface) + if self.up: + iface.startup() if self.session.state == EventTypes.RUNTIME_STATE: self.session.emane.start_iface(self, iface) return iface + + def adopt_iface(self, iface: CoreInterface, name: str) -> None: + raise CoreError( + f"emane network({self.name}) do not support adopting interfaces" + ) diff --git a/daemon/core/emulator/distributed.py b/daemon/core/emulator/distributed.py index 2b4830ad..6faa852a 100644 --- a/daemon/core/emulator/distributed.py +++ b/daemon/core/emulator/distributed.py @@ -15,6 +15,7 @@ from fabric import Connection from invoke import UnexpectedExit from core import utils +from core.emulator.links import CoreLink from core.errors import CoreCommandError, CoreError from core.executables import get_requirements from core.nodes.interface import GreTap @@ -183,21 +184,36 @@ class DistributedController: def start(self) -> None: """ - Start distributed network tunnels. + Start distributed network tunnels for control networks. :return: nothing """ mtu = self.session.options.get_config_int("mtu") for node_id in self.session.nodes: node = self.session.nodes[node_id] - if not isinstance(node, CoreNetwork): - continue - if isinstance(node, CtrlNet) and node.serverintf is not None: + if not isinstance(node, CtrlNet) or node.serverintf is not None: continue for name in self.servers: server = self.servers[name] self.create_gre_tunnel(node, server, mtu, True) + def create_gre_tunnels(self, core_link: CoreLink) -> None: + """ + Creates gre tunnels for a core link with a ptp network connection. + + :param core_link: core link to create gre tunnel for + :return: nothing + """ + if not self.servers: + return + if not core_link.ptp: + raise CoreError( + "attempted to create gre tunnel for core link without a ptp network" + ) + mtu = self.session.options.get_config_int("mtu") + for server in self.servers.values(): + self.create_gre_tunnel(core_link.ptp, server, mtu, True) + def create_gre_tunnel( self, node: CoreNetwork, server: DistributedServer, mtu: int, start: bool ) -> Tuple[GreTap, GreTap]: diff --git a/daemon/core/emulator/enumerations.py b/daemon/core/emulator/enumerations.py index 83e7bffd..e04d382b 100644 --- a/daemon/core/emulator/enumerations.py +++ b/daemon/core/emulator/enumerations.py @@ -20,6 +20,17 @@ class MessageFlags(Enum): TTY = 0x40 +class ConfigFlags(Enum): + """ + Configuration flags. + """ + + NONE = 0x00 + REQUEST = 0x01 + UPDATE = 0x02 + RESET = 0x03 + + class NodeTypes(Enum): """ Node types. @@ -38,6 +49,7 @@ class NodeTypes(Enum): CONTROL_NET = 13 DOCKER = 15 LXC = 16 + WIRELESS = 17 class LinkTypes(Enum): diff --git a/daemon/core/emulator/links.py b/daemon/core/emulator/links.py new file mode 100644 index 00000000..22f75b98 --- /dev/null +++ b/daemon/core/emulator/links.py @@ -0,0 +1,256 @@ +""" +Provides functionality for maintaining information about known links +for a session. +""" + +import logging +from dataclasses import dataclass +from typing import Dict, Optional, Tuple, ValuesView + +from core.emulator.data import LinkData, LinkOptions +from core.emulator.enumerations import LinkTypes, MessageFlags +from core.errors import CoreError +from core.nodes.base import NodeBase +from core.nodes.interface import CoreInterface +from core.nodes.network import PtpNet + +logger = logging.getLogger(__name__) +LinkKeyType = Tuple[int, Optional[int], int, Optional[int]] + + +def create_key( + node1: NodeBase, + iface1: Optional[CoreInterface], + node2: NodeBase, + iface2: Optional[CoreInterface], +) -> LinkKeyType: + """ + Creates a unique key for tracking links. + + :param node1: first node in link + :param iface1: node1 interface + :param node2: second node in link + :param iface2: node2 interface + :return: link key + """ + iface1_id = iface1.id if iface1 else None + iface2_id = iface2.id if iface2 else None + if node1.id < node2.id: + return node1.id, iface1_id, node2.id, iface2_id + else: + return node2.id, iface2_id, node1.id, iface1_id + + +@dataclass +class CoreLink: + """ + Provides a core link data structure. + """ + + node1: NodeBase + iface1: Optional[CoreInterface] + node2: NodeBase + iface2: Optional[CoreInterface] + ptp: PtpNet = None + label: str = None + color: str = None + + def key(self) -> LinkKeyType: + """ + Retrieve the key for this link. + + :return: link key + """ + return create_key(self.node1, self.iface1, self.node2, self.iface2) + + def is_unidirectional(self) -> bool: + """ + Checks if this link is considered unidirectional, due to current + iface configurations. + + :return: True if unidirectional, False otherwise + """ + unidirectional = False + if self.iface1 and self.iface2: + unidirectional = self.iface1.options != self.iface2.options + return unidirectional + + def options(self) -> LinkOptions: + """ + Retrieve the options for this link. + + :return: options for this link + """ + if self.is_unidirectional(): + options = self.iface1.options + else: + if self.iface1: + options = self.iface1.options + else: + options = self.iface2.options + return options + + def get_data(self, message_type: MessageFlags, source: str = None) -> LinkData: + """ + Create link data for this link. + + :param message_type: link data message type + :param source: source for this data + :return: link data + """ + iface1_data = self.iface1.get_data() if self.iface1 else None + iface2_data = self.iface2.get_data() if self.iface2 else None + return LinkData( + message_type=message_type, + type=LinkTypes.WIRED, + node1_id=self.node1.id, + node2_id=self.node2.id, + iface1=iface1_data, + iface2=iface2_data, + options=self.options(), + label=self.label, + color=self.color, + source=source, + ) + + def get_data_unidirectional(self, source: str = None) -> LinkData: + """ + Create other unidirectional link data. + + :param source: source for this data + :return: unidirectional link data + """ + iface1_data = self.iface1.get_data() if self.iface1 else None + iface2_data = self.iface2.get_data() if self.iface2 else None + return LinkData( + message_type=MessageFlags.NONE, + type=LinkTypes.WIRED, + node1_id=self.node2.id, + node2_id=self.node1.id, + iface1=iface2_data, + iface2=iface1_data, + options=self.iface2.options, + label=self.label, + color=self.color, + source=source, + ) + + +class LinkManager: + """ + Provides core link management. + """ + + def __init__(self) -> None: + """ + Create a LinkManager instance. + """ + self._links: Dict[LinkKeyType, CoreLink] = {} + self._node_links: Dict[int, Dict[LinkKeyType, CoreLink]] = {} + + def add(self, core_link: CoreLink) -> None: + """ + Add a core link to be tracked. + + :param core_link: link to track + :return: nothing + """ + node1, iface1 = core_link.node1, core_link.iface1 + node2, iface2 = core_link.node2, core_link.iface2 + if core_link.key() in self._links: + raise CoreError( + f"node1({node1.name}) iface1({iface1.id}) " + f"node2({node2.name}) iface2({iface2.id}) link already exists" + ) + logger.info( + "adding link from node(%s:%s) to node(%s:%s)", + node1.name, + iface1.name if iface1 else None, + node2.name, + iface2.name if iface2 else None, + ) + self._links[core_link.key()] = core_link + node1_links = self._node_links.setdefault(node1.id, {}) + node1_links[core_link.key()] = core_link + node2_links = self._node_links.setdefault(node2.id, {}) + node2_links[core_link.key()] = core_link + + def delete( + self, + node1: NodeBase, + iface1: Optional[CoreInterface], + node2: NodeBase, + iface2: Optional[CoreInterface], + ) -> CoreLink: + """ + Remove a link from being tracked. + + :param node1: first node in link + :param iface1: node1 interface + :param node2: second node in link + :param iface2: node2 interface + :return: removed core link + """ + key = create_key(node1, iface1, node2, iface2) + if key not in self._links: + raise CoreError( + f"node1({node1.name}) iface1({iface1.id}) " + f"node2({node2.name}) iface2({iface2.id}) is not linked" + ) + logger.info( + "deleting link from node(%s:%s) to node(%s:%s)", + node1.name, + iface1.name if iface1 else None, + node2.name, + iface2.name if iface2 else None, + ) + node1_links = self._node_links[node1.id] + node1_links.pop(key) + node2_links = self._node_links[node2.id] + node2_links.pop(key) + return self._links.pop(key) + + def reset(self) -> None: + """ + Resets and clears all tracking information. + + :return: nothing + """ + self._links.clear() + self._node_links.clear() + + def get_link( + self, + node1: NodeBase, + iface1: Optional[CoreInterface], + node2: NodeBase, + iface2: Optional[CoreInterface], + ) -> Optional[CoreLink]: + """ + Retrieve a link for provided values. + + :param node1: first node in link + :param iface1: interface for node1 + :param node2: second node in link + :param iface2: interface for node2 + :return: core link if present, None otherwise + """ + key = create_key(node1, iface1, node2, iface2) + return self._links.get(key) + + def links(self) -> ValuesView[CoreLink]: + """ + Retrieve all known links + + :return: iterator for all known links + """ + return self._links.values() + + def node_links(self, node: NodeBase) -> ValuesView[CoreLink]: + """ + Retrieve all links for a given node. + + :param node: node to get links for + :return: node links + """ + return self._node_links.get(node.id, {}).values() diff --git a/daemon/core/emulator/session.py b/daemon/core/emulator/session.py index 219555d5..4cae8a77 100644 --- a/daemon/core/emulator/session.py +++ b/daemon/core/emulator/session.py @@ -35,10 +35,10 @@ from core.emulator.distributed import DistributedController from core.emulator.enumerations import ( EventTypes, ExceptionLevels, - LinkTypes, MessageFlags, NodeTypes, ) +from core.emulator.links import CoreLink, LinkManager from core.emulator.sessionconfig import SessionConfig from core.errors import CoreError from core.location.event import EventLoop @@ -58,6 +58,7 @@ from core.nodes.network import ( WlanNode, ) from core.nodes.physical import PhysicalNode, Rj45Node +from core.nodes.wireless import WirelessNode from core.plugins.sdt import Sdt from core.services.coreservices import CoreServices from core.xml import corexml, corexmldeployment @@ -80,12 +81,18 @@ NODES: Dict[NodeTypes, Type[NodeBase]] = { NodeTypes.CONTROL_NET: CtrlNet, NodeTypes.DOCKER: DockerNode, NodeTypes.LXC: LxcNode, + NodeTypes.WIRELESS: WirelessNode, } NODES_TYPE: Dict[Type[NodeBase], NodeTypes] = {NODES[x]: x for x in NODES} CONTAINER_NODES: Set[Type[NodeBase]] = {DockerNode, LxcNode} CTRL_NET_ID: int = 9001 LINK_COLORS: List[str] = ["green", "blue", "orange", "purple", "turquoise"] NT: TypeVar = TypeVar("NT", bound=NodeBase) +WIRELESS_TYPE: Tuple[Type[WlanNode], Type[EmaneNet], Type[WirelessNode]] = ( + WlanNode, + EmaneNet, + WirelessNode, +) class Session: @@ -119,7 +126,8 @@ class Session: # dict of nodes: all nodes and nets self.nodes: Dict[int, NodeBase] = {} - self.nodes_lock = threading.Lock() + self.nodes_lock: threading.Lock = threading.Lock() + self.link_manager: LinkManager = LinkManager() # states and hooks handlers self.state: EventTypes = EventTypes.DEFINITION_STATE @@ -187,43 +195,48 @@ class Session: raise CoreError(f"invalid node class: {_class}") return node_type - def _link_wireless( - self, node1: CoreNodeBase, node2: CoreNodeBase, connect: bool - ) -> None: - """ - Objects to deal with when connecting/disconnecting wireless links. - - :param node1: node one for wireless link - :param node2: node two for wireless link - :param connect: link interfaces if True, unlink otherwise - :return: nothing - :raises core.CoreError: when objects to link is less than 2, or no common - networks are found - """ - logger.info( - "handling wireless linking node1(%s) node2(%s): %s", - node1.name, - node2.name, - connect, - ) - common_networks = node1.commonnets(node1) - if not common_networks: - raise CoreError("no common network found for wireless link/unlink") - for common_network, iface1, iface2 in common_networks: - if not isinstance(common_network, (WlanNode, EmaneNet)): - logger.info( - "skipping common network that is not wireless/emane: %s", - common_network, - ) - continue - if connect: - common_network.link(iface1, iface2) - else: - common_network.unlink(iface1, iface2) - def use_ovs(self) -> bool: return self.options.get_config("ovs") == "1" + def linked( + self, node1_id: int, node2_id: int, iface1_id: int, iface2_id: int, linked: bool + ) -> None: + """ + Links or unlinks wired core link interfaces from being connected to the same + bridge. + + :param node1_id: first node in link + :param node2_id: second node in link + :param iface1_id: node1 interface + :param iface2_id: node2 interface + :param linked: True if interfaces should be connected, False for disconnected + :return: nothing + """ + node1 = self.get_node(node1_id, NodeBase) + node2 = self.get_node(node2_id, NodeBase) + logger.info( + "link node(%s):interface(%s) node(%s):interface(%s) linked(%s)", + node1.name, + iface1_id, + node2.name, + iface2_id, + linked, + ) + iface1 = node1.get_iface(iface1_id) + iface2 = node2.get_iface(iface2_id) + core_link = self.link_manager.get_link(node1, iface1, node2, iface2) + if not core_link: + raise CoreError( + f"there is no link for node({node1.name}):interface({iface1_id}) " + f"node({node2.name}):interface({iface2_id})" + ) + if linked: + core_link.ptp.attach(iface1) + core_link.ptp.attach(iface2) + else: + core_link.ptp.detach(iface1) + core_link.ptp.detach(iface2) + def add_link( self, node1_id: int, @@ -231,8 +244,7 @@ class Session: iface1_data: InterfaceData = None, iface2_data: InterfaceData = None, options: LinkOptions = None, - link_type: LinkTypes = LinkTypes.WIRED, - ) -> Tuple[CoreInterface, CoreInterface]: + ) -> Tuple[Optional[CoreInterface], Optional[CoreInterface]]: """ Add a link between nodes. @@ -244,89 +256,129 @@ class Session: data, defaults to none :param options: data for creating link, defaults to no options - :param link_type: type of link to add :return: tuple of created core interfaces, depending on link """ - if not options: - options = LinkOptions() - node1 = self.get_node(node1_id, NodeBase) - node2 = self.get_node(node2_id, NodeBase) - iface1 = None - iface2 = None + options = options if options else LinkOptions() # set mtu mtu = self.options.get_config_int("mtu") or DEFAULT_MTU if iface1_data: iface1_data.mtu = mtu if iface2_data: iface2_data.mtu = mtu - # wireless link - if link_type == LinkTypes.WIRELESS: - if isinstance(node1, CoreNodeBase) and isinstance(node2, CoreNodeBase): - self._link_wireless(node1, node2, connect=True) - else: - raise CoreError( - f"cannot wireless link node1({type(node1)}) node2({type(node2)})" - ) - # wired link + node1 = self.get_node(node1_id, NodeBase) + node2 = self.get_node(node2_id, NodeBase) + # check for invalid linking + if ( + isinstance(node1, WIRELESS_TYPE) + and isinstance(node2, WIRELESS_TYPE) + or isinstance(node1, WIRELESS_TYPE) + and not isinstance(node2, CoreNodeBase) + or not isinstance(node1, CoreNodeBase) + and isinstance(node2, WIRELESS_TYPE) + ): + raise CoreError(f"cannot link node({type(node1)}) node({type(node2)})") + # custom links + iface1 = None + iface2 = None + if isinstance(node1, (WlanNode, WirelessNode)): + iface2 = self._add_wlan_link(node2, iface2_data, node1) + elif isinstance(node2, (WlanNode, WirelessNode)): + iface1 = self._add_wlan_link(node1, iface1_data, node2) + elif isinstance(node1, EmaneNet) and isinstance(node2, CoreNode): + iface2 = self._add_emane_link(node2, iface2_data, node1) + elif isinstance(node2, EmaneNet) and isinstance(node1, CoreNode): + iface1 = self._add_emane_link(node1, iface1_data, node2) else: - # peer to peer link - if isinstance(node1, CoreNodeBase) and isinstance(node2, CoreNodeBase): - logger.info("linking ptp: %s - %s", node1.name, node2.name) - start = self.state.should_start() - ptp = self.create_node(PtpNet, start) - iface1 = node1.new_iface(ptp, iface1_data) - iface2 = node2.new_iface(ptp, iface2_data) - iface1.config(options) - if not options.unidirectional: - iface2.config(options) - # link node to net - elif isinstance(node1, CoreNodeBase) and isinstance(node2, CoreNetworkBase): - logger.info("linking node to net: %s - %s", node1.name, node2.name) - iface1 = node1.new_iface(node2, iface1_data) - if not isinstance(node2, (EmaneNet, WlanNode)): - iface1.config(options) - # link net to node - elif isinstance(node2, CoreNodeBase) and isinstance(node1, CoreNetworkBase): - logger.info("linking net to node: %s - %s", node1.name, node2.name) - iface2 = node2.new_iface(node1, iface2_data) - wireless_net = isinstance(node1, (EmaneNet, WlanNode)) - if not options.unidirectional and not wireless_net: - iface2.config(options) - # network to network - elif isinstance(node1, CoreNetworkBase) and isinstance( - node2, CoreNetworkBase - ): - logger.info( - "linking network to network: %s - %s", node1.name, node2.name - ) - iface1 = node1.linknet(node2) - use_local = iface1.net == node1 - iface1.config(options, use_local=use_local) - if not options.unidirectional: - iface1.config(options, use_local=not use_local) - else: - raise CoreError( - f"cannot link node1({type(node1)}) node2({type(node2)})" - ) - - # configure tunnel nodes - key = options.key - if isinstance(node1, TunnelNode): - logger.info("setting tunnel key for: %s", node1.name) - node1.setkey(key, iface1_data) - if isinstance(node2, TunnelNode): - logger.info("setting tunnel key for: %s", node2.name) - node2.setkey(key, iface2_data) + iface1, iface2 = self._add_wired_link( + node1, node2, iface1_data, iface2_data, options + ) + # configure tunnel nodes + key = options.key + if isinstance(node1, TunnelNode): + logger.info("setting tunnel key for: %s", node1.name) + node1.setkey(key, iface1_data) + if isinstance(node2, TunnelNode): + logger.info("setting tunnel key for: %s", node2.name) + node2.setkey(key, iface2_data) self.sdt.add_link(node1_id, node2_id) return iface1, iface2 - def delete_link( + def _add_wlan_link( self, - node1_id: int, - node2_id: int, - iface1_id: int = None, - iface2_id: int = None, - link_type: LinkTypes = LinkTypes.WIRED, + node: NodeBase, + iface_data: InterfaceData, + net: Union[WlanNode, WirelessNode], + ) -> CoreInterface: + """ + Create a wlan link. + + :param node: node to link to wlan network + :param iface_data: data to create interface with + :param net: wlan network to link to + :return: interface created for node + """ + # create interface + iface = node.create_iface(iface_data) + # attach to wlan + net.attach(iface) + # track link + core_link = CoreLink(node, iface, net, None) + self.link_manager.add(core_link) + return iface + + def _add_emane_link( + self, node: CoreNode, iface_data: InterfaceData, net: EmaneNet + ) -> CoreInterface: + """ + Create am emane link. + + :param node: node to link to emane network + :param iface_data: data to create interface with + :param net: emane network to link to + :return: interface created for node + """ + # create iface tuntap + iface = net.create_tuntap(node, iface_data) + # track link + core_link = CoreLink(node, iface, net, None) + self.link_manager.add(core_link) + return iface + + def _add_wired_link( + self, + node1: NodeBase, + node2: NodeBase, + iface1_data: InterfaceData = None, + iface2_data: InterfaceData = None, + options: LinkOptions = None, + ) -> Tuple[CoreInterface, CoreInterface]: + """ + Create a wired link between two nodes. + + :param node1: first node to be linked + :param node2: second node to be linked + :param iface1_data: data to create interface for node1 + :param iface2_data: data to create interface for node2 + :param options: options to configure interfaces with + :return: interfaces created for both nodes + """ + # create interfaces + iface1 = node1.create_iface(iface1_data, options) + iface2 = node2.create_iface(iface2_data, options) + # join and attach to ptp bridge + ptp = self.create_node(PtpNet, self.state.should_start()) + ptp.attach(iface1) + ptp.attach(iface2) + # track link + core_link = CoreLink(node1, iface1, node2, iface2, ptp) + self.link_manager.add(core_link) + # setup link for gre tunnels if needed + if ptp.up: + self.distributed.create_gre_tunnels(core_link) + return iface1, iface2 + + def delete_link( + self, node1_id: int, node2_id: int, iface1_id: int = None, iface2_id: int = None ) -> None: """ Delete a link between nodes. @@ -335,63 +387,38 @@ class Session: :param node2_id: node two id :param iface1_id: interface id for node one :param iface2_id: interface id for node two - :param link_type: link type to delete :return: nothing :raises core.CoreError: when no common network is found for link being deleted """ node1 = self.get_node(node1_id, NodeBase) node2 = self.get_node(node2_id, NodeBase) logger.info( - "deleting link(%s) node(%s):interface(%s) node(%s):interface(%s)", - link_type.name, + "deleting link node(%s):interface(%s) node(%s):interface(%s)", node1.name, iface1_id, node2.name, iface2_id, ) - - # wireless link - if link_type == LinkTypes.WIRELESS: - if isinstance(node1, CoreNodeBase) and isinstance(node2, CoreNodeBase): - self._link_wireless(node1, node2, connect=False) - else: - raise CoreError( - "cannot delete wireless link " - f"node1({type(node1)}) node2({type(node2)})" - ) - # wired link + iface1 = None + iface2 = None + if isinstance(node1, (WlanNode, WirelessNode)): + iface2 = node2.delete_iface(iface2_id) + node1.detach(iface2) + elif isinstance(node2, (WlanNode, WirelessNode)): + iface1 = node1.delete_iface(iface1_id) + node2.detach(iface1) + elif isinstance(node1, EmaneNet): + iface2 = node2.delete_iface(iface2_id) + node1.detach(iface2) + elif isinstance(node2, EmaneNet): + iface1 = node1.delete_iface(iface1_id) + node2.detach(iface1) else: - if isinstance(node1, CoreNodeBase) and isinstance(node2, CoreNodeBase): - iface1 = node1.get_iface(iface1_id) - iface2 = node2.get_iface(iface2_id) - if iface1.net != iface2.net: - raise CoreError( - f"node1({node1.name}) node2({node2.name}) " - "not connected to same net" - ) - ptp = iface1.net - node1.delete_iface(iface1_id) - node2.delete_iface(iface2_id) - self.delete_node(ptp.id) - elif isinstance(node1, CoreNodeBase) and isinstance(node2, CoreNetworkBase): - node1.delete_iface(iface1_id) - elif isinstance(node2, CoreNodeBase) and isinstance(node1, CoreNetworkBase): - node2.delete_iface(iface2_id) - elif isinstance(node1, CoreNetworkBase) and isinstance( - node2, CoreNetworkBase - ): - iface1 = node1.get_linked_iface(node2) - if iface1: - node1.detach(iface1) - iface1.shutdown() - iface2 = node2.get_linked_iface(node1) - if iface2: - node2.detach(iface2) - iface2.shutdown() - if not iface1 and not iface2: - raise CoreError( - f"node1({node1.name}) and node2({node2.name}) are not connected" - ) + iface1 = node1.delete_iface(iface1_id) + iface2 = node2.delete_iface(iface2_id) + core_link = self.link_manager.delete(node1, iface1, node2, iface2) + if core_link.ptp: + self.delete_node(core_link.ptp.id) self.sdt.delete_link(node1_id, node2_id) def update_link( @@ -401,7 +428,6 @@ class Session: iface1_id: int = None, iface2_id: int = None, options: LinkOptions = None, - link_type: LinkTypes = LinkTypes.WIRED, ) -> None: """ Update link information between nodes. @@ -411,7 +437,6 @@ class Session: :param iface1_id: interface id for node one :param iface2_id: interface id for node two :param options: data to update link with - :param link_type: type of link to update :return: nothing :raises core.CoreError: when updating a wireless type link, when there is a unknown link between networks @@ -421,72 +446,26 @@ class Session: node1 = self.get_node(node1_id, NodeBase) node2 = self.get_node(node2_id, NodeBase) logger.info( - "update link(%s) node(%s):interface(%s) node(%s):interface(%s)", - link_type.name, + "update link node(%s):interface(%s) node(%s):interface(%s)", node1.name, iface1_id, node2.name, iface2_id, ) - - # wireless link - if link_type == LinkTypes.WIRELESS: - raise CoreError("cannot update wireless link") - else: - if isinstance(node1, CoreNodeBase) and isinstance(node2, CoreNodeBase): - iface1 = node1.ifaces.get(iface1_id) - if not iface1: - raise CoreError( - f"node({node1.name}) missing interface({iface1_id})" - ) - iface2 = node2.ifaces.get(iface2_id) - if not iface2: - raise CoreError( - f"node({node2.name}) missing interface({iface2_id})" - ) - if iface1.net != iface2.net: - raise CoreError( - f"node1({node1.name}) node2({node2.name}) " - "not connected to same net" - ) - iface1.config(options) - if not options.unidirectional: - iface2.config(options) - elif isinstance(node1, CoreNodeBase) and isinstance(node2, CoreNetworkBase): - iface = node1.get_iface(iface1_id) - if iface.net != node2: - raise CoreError( - f"node1({node1.name}) iface1({iface1_id})" - f" is not linked to node1({node2.name})" - ) - iface.config(options) - elif isinstance(node2, CoreNodeBase) and isinstance(node1, CoreNetworkBase): - iface = node2.get_iface(iface2_id) - if iface.net != node1: - raise CoreError( - f"node2({node2.name}) iface2({iface2_id})" - f" is not linked to node1({node1.name})" - ) - iface.config(options) - elif isinstance(node1, CoreNetworkBase) and isinstance( - node2, CoreNetworkBase - ): - iface = node1.get_linked_iface(node2) - if not iface: - iface = node2.get_linked_iface(node1) - if iface: - use_local = iface.net == node1 - iface.config(options, use_local=use_local) - if not options.unidirectional: - iface.config(options, use_local=not use_local) - else: - raise CoreError( - f"node1({node1.name}) and node2({node2.name}) are not linked" - ) - else: - raise CoreError( - f"cannot update link node1({type(node1)}) node2({type(node2)})" - ) + iface1 = node1.get_iface(iface1_id) if iface1_id is not None else None + iface2 = node2.get_iface(iface2_id) if iface2_id is not None else None + core_link = self.link_manager.get_link(node1, iface1, node2, iface2) + if not core_link: + raise CoreError( + f"there is no link for node({node1.name}):interface({iface1_id}) " + f"node({node2.name}):interface({iface2_id})" + ) + if iface1: + iface1.options.update(options) + iface1.set_config() + if iface2 and not options.unidirectional: + iface2.options.update(options) + iface2.set_config() def next_node_id(self) -> int: """ @@ -618,26 +597,6 @@ class Session: node.position.set_geo(lon, lat, alt) self.sdt.edit_node(node, lon, lat, alt) - def start_mobility(self, node_ids: List[int] = None) -> None: - """ - Start mobility for the provided node ids. - - :param node_ids: nodes to start mobility for - :return: nothing - """ - self.mobility.startup(node_ids) - - def is_active(self) -> bool: - """ - Determine if this session is considered to be active. - (Runtime or Data collect states) - - :return: True if active, False otherwise - """ - result = self.state in {EventTypes.RUNTIME_STATE, EventTypes.DATACOLLECT_STATE} - logger.info("session(%s) checking if active: %s", self.id, result) - return result - def open_xml(self, file_path: Path, start: bool = False) -> None: """ Import a session from the EmulationScript XML format. @@ -723,6 +682,7 @@ class Session: """ self.emane.shutdown() self.delete_nodes() + self.link_manager.reset() self.distributed.shutdown() self.hooks.clear() self.emane.reset() @@ -732,23 +692,6 @@ class Session: self.mobility.config_reset() self.link_colors.clear() - def start_events(self) -> None: - """ - Start event loop. - - :return: nothing - """ - self.event_loop.run() - - def mobility_event(self, event_data: EventData) -> None: - """ - Handle a mobility event. - - :param event_data: event data to handle - :return: nothing - """ - self.mobility.handleevent(event_data) - def set_location(self, lat: float, lon: float, alt: float, scale: float) -> None: """ Set session geospatial location. @@ -1007,15 +950,14 @@ class Session: env["SESSION_STATE"] = str(self.state) # try reading and merging optional environments from: # /etc/core/environment - # /home/user/.core/environment + # /home/user/.coregui/environment # /tmp/pycore./environment core_env_path = constants.CORE_CONF_DIR / "environment" session_env_path = self.directory / "environment" if self.user: user_home_path = Path(f"~{self.user}").expanduser() - user_env1 = user_home_path / ".core" / "environment" - user_env2 = user_home_path / ".coregui" / "environment" - paths = [core_env_path, user_env1, user_env2, session_env_path] + user_env = user_home_path / ".coregui" / "environment" + paths = [core_env_path, user_env, session_env_path] else: paths = [core_env_path, session_env_path] for path in paths: @@ -1026,21 +968,6 @@ class Session: logger.exception("error reading environment file: %s", path) return env - def set_thumbnail(self, thumb_file: Path) -> None: - """ - Set the thumbnail filename. Move files from /tmp to session dir. - - :param thumb_file: tumbnail file to set for session - :return: nothing - """ - if not thumb_file.is_file(): - logger.error("thumbnail file to set does not exist: %s", thumb_file) - self.thumbnail = None - return - dst_path = self.directory / thumb_file.name - shutil.copy(thumb_file, dst_path) - self.thumbnail = dst_path - def set_user(self, user: str) -> None: """ Set the username for this session. Update the permissions of the @@ -1049,14 +976,13 @@ class Session: :param user: user to give write permissions to for the session directory :return: nothing """ - if user: - try: - uid = pwd.getpwnam(user).pw_uid - gid = self.directory.stat().st_gid - os.chown(self.directory, uid, gid) - except IOError: - logger.exception("failed to set permission on %s", self.directory) self.user = user + try: + uid = pwd.getpwnam(user).pw_uid + gid = self.directory.stat().st_gid + os.chown(self.directory, uid, gid) + except IOError: + logger.exception("failed to set permission on %s", self.directory) def create_node( self, _class: Type[NT], start: bool, *args: Any, **kwargs: Any @@ -1194,6 +1120,10 @@ class Session: # boot node services and then start mobility exceptions = self.boot_nodes() if not exceptions: + # complete wireless node + for node in self.nodes.values(): + if isinstance(node, WirelessNode): + node.post_startup() self.mobility.startup() # notify listeners that instantiation is complete event = EventData(event_type=EventTypes.INSTANTIATION_COMPLETE) @@ -1480,7 +1410,8 @@ class Session: ip4_mask=ip4_mask, mtu=DEFAULT_MTU, ) - iface = node.new_iface(control_net, iface_data) + iface = node.create_iface(iface_data) + control_net.attach(iface) iface.control = True except ValueError: msg = f"Control interface not added to node {node.id}. " diff --git a/daemon/core/gui/coreclient.py b/daemon/core/gui/coreclient.py index 4905ac8a..b92dee79 100644 --- a/daemon/core/gui/coreclient.py +++ b/daemon/core/gui/coreclient.py @@ -404,9 +404,11 @@ class CoreClient: for edge in self.links.values(): link = edge.link if not definition: - if link.iface1 and not link.iface1.mac: + node1 = self.session.nodes[link.node1_id] + node2 = self.session.nodes[link.node2_id] + if nutils.is_container(node1) and link.iface1 and not link.iface1.mac: link.iface1.mac = self.ifaces_manager.next_mac() - if link.iface2 and not link.iface2.mac: + if nutils.is_container(node2) and link.iface2 and not link.iface2.mac: link.iface2.mac = self.ifaces_manager.next_mac() links.append(link) if edge.asymmetric_link: diff --git a/daemon/core/gui/data/icons/wireless.png b/daemon/core/gui/data/icons/wireless.png new file mode 100644 index 00000000..2b42b8dd Binary files /dev/null and b/daemon/core/gui/data/icons/wireless.png differ diff --git a/daemon/core/gui/dialogs/nodeconfig.py b/daemon/core/gui/dialogs/nodeconfig.py index ee0d7b81..c9ca67f5 100644 --- a/daemon/core/gui/dialogs/nodeconfig.py +++ b/daemon/core/gui/dialogs/nodeconfig.py @@ -230,13 +230,8 @@ class NodeConfigDialog(Dialog): if nutils.is_model(self.node): label = ttk.Label(frame, text="Type") label.grid(row=row, column=0, sticky=tk.EW, padx=PADX, pady=PADY) - combobox = ttk.Combobox( - frame, - textvariable=self.type, - values=list(nutils.NODE_MODELS), - state=combo_state, - ) - combobox.grid(row=row, column=1, sticky=tk.EW) + entry = ttk.Entry(frame, textvariable=self.type, state=tk.DISABLED) + entry.grid(row=row, column=1, sticky=tk.EW) row += 1 # container image field @@ -275,7 +270,7 @@ class NodeConfigDialog(Dialog): ifaces_scroll.listbox.bind("<>", self.iface_select) # interfaces - if self.canvas_node.ifaces: + if nutils.is_container(self.node): self.draw_ifaces() self.draw_spacer() diff --git a/daemon/core/gui/graph/node.py b/daemon/core/gui/graph/node.py index 1de7319f..7f445f91 100644 --- a/daemon/core/gui/graph/node.py +++ b/daemon/core/gui/graph/node.py @@ -298,7 +298,10 @@ class CanvasNode: other_iface = edge.other_iface(self) label = other_node.core_node.name if other_iface: - label = f"{label}:{other_iface.name}" + iface_label = other_iface.id + if other_iface.name: + iface_label = other_iface.name + label = f"{label}:{iface_label}" func_unlink = functools.partial(self.click_unlink, edge) unlink_menu.add_command(label=label, command=func_unlink) themes.style_menu(unlink_menu) diff --git a/daemon/core/gui/images.py b/daemon/core/gui/images.py index 7c5897e5..53620e72 100644 --- a/daemon/core/gui/images.py +++ b/daemon/core/gui/images.py @@ -53,6 +53,7 @@ class ImageEnum(Enum): LINK = "link" HUB = "hub" WLAN = "wlan" + WIRELESS = "wireless" EMANE = "emane" RJ45 = "rj45" TUNNEL = "tunnel" diff --git a/daemon/core/gui/interface.py b/daemon/core/gui/interface.py index d4d09443..83fba104 100644 --- a/daemon/core/gui/interface.py +++ b/daemon/core/gui/interface.py @@ -241,10 +241,10 @@ class InterfaceManager: dst_node = edge.dst.core_node self.determine_subnets(edge.src, edge.dst) src_iface = None - if nutils.is_container(src_node): + if nutils.is_iface_node(src_node): src_iface = self.create_iface(edge.src, edge.linked_wireless) dst_iface = None - if nutils.is_container(dst_node): + if nutils.is_iface_node(dst_node): dst_iface = self.create_iface(edge.dst, edge.linked_wireless) link = Link( type=LinkType.WIRED, @@ -258,22 +258,26 @@ class InterfaceManager: def create_iface(self, canvas_node: CanvasNode, wireless_link: bool) -> Interface: node = canvas_node.core_node - ip4, ip6 = self.get_ips(node) - if wireless_link: - ip4_mask = WIRELESS_IP4_MASK - ip6_mask = WIRELESS_IP6_MASK + if nutils.is_bridge(node): + iface_id = canvas_node.next_iface_id() + iface = Interface(id=iface_id) else: - ip4_mask = IP4_MASK - ip6_mask = IP6_MASK - iface_id = canvas_node.next_iface_id() - name = f"eth{iface_id}" - iface = Interface( - id=iface_id, - name=name, - ip4=ip4, - ip4_mask=ip4_mask, - ip6=ip6, - ip6_mask=ip6_mask, - ) + ip4, ip6 = self.get_ips(node) + if wireless_link: + ip4_mask = WIRELESS_IP4_MASK + ip6_mask = WIRELESS_IP6_MASK + else: + ip4_mask = IP4_MASK + ip6_mask = IP6_MASK + iface_id = canvas_node.next_iface_id() + name = f"eth{iface_id}" + iface = Interface( + id=iface_id, + name=name, + ip4=ip4, + ip4_mask=ip4_mask, + ip6=ip6, + ip6_mask=ip6_mask, + ) logger.info("create node(%s) interface(%s)", node.name, iface) return iface diff --git a/daemon/core/gui/nodeutils.py b/daemon/core/gui/nodeutils.py index 537cedf2..0175797d 100644 --- a/daemon/core/gui/nodeutils.py +++ b/daemon/core/gui/nodeutils.py @@ -18,12 +18,16 @@ NETWORK_NODES: List["NodeDraw"] = [] NODE_ICONS = {} CONTAINER_NODES: Set[NodeType] = {NodeType.DEFAULT, NodeType.DOCKER, NodeType.LXC} IMAGE_NODES: Set[NodeType] = {NodeType.DOCKER, NodeType.LXC} -WIRELESS_NODES: Set[NodeType] = {NodeType.WIRELESS_LAN, NodeType.EMANE} +WIRELESS_NODES: Set[NodeType] = { + NodeType.WIRELESS_LAN, + NodeType.EMANE, + NodeType.WIRELESS, +} RJ45_NODES: Set[NodeType] = {NodeType.RJ45} BRIDGE_NODES: Set[NodeType] = {NodeType.HUB, NodeType.SWITCH} IGNORE_NODES: Set[NodeType] = {NodeType.CONTROL_NET} MOBILITY_NODES: Set[NodeType] = {NodeType.WIRELESS_LAN, NodeType.EMANE} -NODE_MODELS: Set[str] = {"router", "host", "PC", "mdr", "prouter"} +NODE_MODELS: Set[str] = {"router", "PC", "mdr", "prouter"} ROUTER_NODES: Set[str] = {"router", "mdr"} ANTENNA_ICON: Optional[PhotoImage] = None @@ -46,6 +50,7 @@ def setup() -> None: (ImageEnum.HUB, NodeType.HUB, "Hub"), (ImageEnum.SWITCH, NodeType.SWITCH, "Switch"), (ImageEnum.WLAN, NodeType.WIRELESS_LAN, "WLAN"), + (ImageEnum.WIRELESS, NodeType.WIRELESS, "Wireless"), (ImageEnum.EMANE, NodeType.EMANE, "EMANE"), (ImageEnum.RJ45, NodeType.RJ45, "RJ45"), (ImageEnum.TUNNEL, NodeType.TUNNEL, "Tunnel"), @@ -97,6 +102,10 @@ def is_custom(node: Node) -> bool: return is_model(node) and node.model not in NODE_MODELS +def is_iface_node(node: Node) -> bool: + return is_container(node) or is_bridge(node) + + def get_custom_services(gui_config: GuiConfig, name: str) -> List[str]: for custom_node in gui_config.nodes: if custom_node.name == name: diff --git a/daemon/core/location/mobility.py b/daemon/core/location/mobility.py index ebcb8fe4..bae9985d 100644 --- a/daemon/core/location/mobility.py +++ b/daemon/core/location/mobility.py @@ -225,7 +225,6 @@ class WirelessModel(ConfigurableOptions): """ config_type: RegisterTlvs = RegisterTlvs.WIRELESS - bitmap: str = None position_callback: Callable[[CoreInterface], None] = None def __init__(self, session: "Session", _id: int) -> None: @@ -321,7 +320,8 @@ class BasicRangeModel(WirelessModel): loss=self.loss, jitter=self.jitter, ) - iface.config(options) + iface.options.update(options) + iface.set_config() def get_position(self, iface: CoreInterface) -> Tuple[float, float, float]: """ diff --git a/daemon/core/nodes/base.py b/daemon/core/nodes/base.py index 34bf6601..41d6efb3 100644 --- a/daemon/core/nodes/base.py +++ b/daemon/core/nodes/base.py @@ -13,11 +13,11 @@ import netaddr from core import utils from core.configservice.dependencies import ConfigServiceDependencies -from core.emulator.data import InterfaceData, LinkData -from core.emulator.enumerations import LinkTypes, MessageFlags, NodeTypes +from core.emulator.data import InterfaceData, LinkOptions +from core.emulator.enumerations import LinkTypes, NodeTypes from core.errors import CoreCommandError, CoreError from core.executables import BASH, MOUNT, TEST, VCMD, VNODED -from core.nodes.interface import DEFAULT_MTU, CoreInterface, TunTap, Veth +from core.nodes.interface import DEFAULT_MTU, CoreInterface from core.nodes.netclient import LinuxNetClient, get_net_client logger = logging.getLogger(__name__) @@ -74,6 +74,7 @@ class NodeBase(abc.ABC): self.icon: Optional[str] = None self.position: Position = Position() self.up: bool = False + self.lock: RLock = RLock() self.net_client: LinuxNetClient = get_net_client( self.session.use_ovs(), self.host_cmd ) @@ -96,6 +97,18 @@ class NodeBase(abc.ABC): """ raise NotImplementedError + @abc.abstractmethod + def adopt_iface(self, iface: CoreInterface, name: str) -> None: + """ + Adopt an interface, placing within network namespacing for containers + and setting to bridge masters for network like nodes. + + :param iface: interface to adopt + :param name: proper name to use for interface + :return: nothing + """ + raise NotImplementedError + def host_cmd( self, args: str, @@ -120,6 +133,19 @@ class NodeBase(abc.ABC): else: return self.server.remote_cmd(args, env, cwd, wait) + def cmd(self, args: str, wait: bool = True, shell: bool = False) -> str: + """ + Runs a command that is in the context of a node, default is to run a standard + host command. + + :param args: command to run + :param wait: True to wait for status, False otherwise + :param shell: True to use shell, False otherwise + :return: combined stdout and stderr + :raises CoreCommandError: when a non-zero exit status occurs + """ + return self.host_cmd(args, wait=wait, shell=shell) + def setposition(self, x: float = None, y: float = None, z: float = None) -> bool: """ Set the (x,y,z) position of the object. @@ -139,6 +165,70 @@ class NodeBase(abc.ABC): """ return self.position.get() + def create_iface( + self, iface_data: InterfaceData = None, options: LinkOptions = None + ) -> CoreInterface: + """ + Creates an interface and adopts it to a node. + + :param iface_data: data to create interface with + :param options: options to create interface with + :return: created interface + """ + with self.lock: + if iface_data and iface_data.id is not None: + if iface_data.id in self.ifaces: + raise CoreError( + f"node({self.id}) interface({iface_data.id}) already exists" + ) + iface_id = iface_data.id + else: + iface_id = self.next_iface_id() + mtu = DEFAULT_MTU + if iface_data and iface_data.mtu is not None: + mtu = iface_data.mtu + name = f"veth{self.id}.{iface_id}.{self.session.short_session_id()}" + localname = f"{name}p" + iface = CoreInterface( + iface_id, + name, + localname, + self.session.use_ovs(), + mtu, + self, + self.server, + ) + if iface_data: + if iface_data.mac: + iface.set_mac(iface_data.mac) + for ip in iface_data.get_ips(): + iface.add_ip(ip) + if iface_data.name: + name = iface_data.name + if options: + iface.options.update(options) + self.ifaces[iface_id] = iface + if self.up: + iface.startup() + self.adopt_iface(iface, name) + else: + iface.name = name + return iface + + def delete_iface(self, iface_id: int) -> CoreInterface: + """ + Delete an interface. + + :param iface_id: interface id to delete + :return: the removed interface + """ + if iface_id not in self.ifaces: + raise CoreError(f"node({self.name}) interface({iface_id}) does not exist") + iface = self.ifaces.pop(iface_id) + logger.info("node(%s) removing interface(%s)", self.name, iface.name) + iface.shutdown() + return iface + def get_iface(self, iface_id: int) -> CoreInterface: """ Retrieve interface based on id. @@ -191,15 +281,6 @@ class NodeBase(abc.ABC): self.iface_id += 1 return iface_id - def links(self, flags: MessageFlags = MessageFlags.NONE) -> List[LinkData]: - """ - Build link data for this node. - - :param flags: message flags - :return: list of link data - """ - return [] - class CoreNodeBase(NodeBase): """ @@ -227,14 +308,6 @@ class CoreNodeBase(NodeBase): self.directory: Optional[Path] = None self.tmpnodedir: bool = False - @abc.abstractmethod - def startup(self) -> None: - raise NotImplementedError - - @abc.abstractmethod - def shutdown(self) -> None: - raise NotImplementedError - @abc.abstractmethod def create_dir(self, dir_path: Path) -> None: """ @@ -270,19 +343,6 @@ class CoreNodeBase(NodeBase): """ raise NotImplementedError - @abc.abstractmethod - def cmd(self, args: str, wait: bool = True, shell: bool = False) -> str: - """ - Runs a command within a node container. - - :param args: command to run - :param wait: True to wait for status, False otherwise - :param shell: True to use shell, False otherwise - :return: combined stdout and stderr - :raises CoreCommandError: when a non-zero exit status occurs - """ - raise NotImplementedError - @abc.abstractmethod def termcmdstring(self, sh: str) -> str: """ @@ -293,19 +353,6 @@ class CoreNodeBase(NodeBase): """ raise NotImplementedError - @abc.abstractmethod - def new_iface( - self, net: "CoreNetworkBase", iface_data: InterfaceData - ) -> CoreInterface: - """ - Create a new interface. - - :param net: network to associate with - :param iface_data: interface data for new interface - :return: interface index - """ - raise NotImplementedError - @abc.abstractmethod def path_exists(self, path: str) -> bool: """ @@ -318,7 +365,7 @@ class CoreNodeBase(NodeBase): def host_path(self, path: Path, is_dir: bool = False) -> Path: """ - Return the name of a node"s file on the host filesystem. + Return the name of a node's file on the host filesystem. :param path: path to translate to host path :param is_dir: True if path is a directory path, False otherwise @@ -393,54 +440,6 @@ class CoreNodeBase(NodeBase): if self.tmpnodedir: self.host_cmd(f"rm -rf {self.directory}") - def add_iface(self, iface: CoreInterface, iface_id: int) -> None: - """ - Add network interface to node and set the network interface index if successful. - - :param iface: network interface to add - :param iface_id: interface id - :return: nothing - """ - if iface_id in self.ifaces: - raise CoreError(f"interface({iface_id}) already exists") - self.ifaces[iface_id] = iface - iface.node_id = iface_id - - def delete_iface(self, iface_id: int) -> None: - """ - Delete a network interface - - :param iface_id: interface index to delete - :return: nothing - """ - if iface_id not in self.ifaces: - raise CoreError(f"node({self.name}) interface({iface_id}) does not exist") - iface = self.ifaces.pop(iface_id) - logger.info("node(%s) removing interface(%s)", self.name, iface.name) - iface.detachnet() - iface.shutdown() - - def attachnet(self, iface_id: int, net: "CoreNetworkBase") -> None: - """ - Attach a network. - - :param iface_id: interface of index to attach - :param net: network to attach - :return: nothing - """ - iface = self.get_iface(iface_id) - iface.attachnet(net) - - def detachnet(self, iface_id: int) -> None: - """ - Detach network interface. - - :param iface_id: interface id to detach - :return: nothing - """ - iface = self.get_iface(iface_id) - iface.detachnet() - def setposition(self, x: float = None, y: float = None, z: float = None) -> None: """ Set position. @@ -455,25 +454,6 @@ class CoreNodeBase(NodeBase): for iface in self.get_ifaces(): iface.setposition() - def commonnets( - self, node: "CoreNodeBase", want_ctrl: bool = False - ) -> List[Tuple["CoreNetworkBase", CoreInterface, CoreInterface]]: - """ - Given another node or net object, return common networks between - this node and that object. A list of tuples is returned, with each tuple - consisting of (network, interface1, interface2). - - :param node: node to get common network with - :param want_ctrl: flag set to determine if control network are wanted - :return: tuples of common networks - """ - common = [] - for iface1 in self.get_ifaces(control=want_ctrl): - for iface2 in node.get_ifaces(): - if iface1.net == iface2.net: - common.append((iface1.net, iface1, iface2)) - return common - class CoreNode(CoreNodeBase): """ @@ -504,7 +484,6 @@ class CoreNode(CoreNodeBase): self.directory: Optional[Path] = directory self.ctrlchnlname: Path = self.session.directory / self.name self.pid: Optional[int] = None - self.lock: RLock = RLock() self._mounts: List[Tuple[Path, Path]] = [] self.node_net_client: LinuxNetClient = self.create_node_net_client( self.session.use_ovs() @@ -585,6 +564,10 @@ class CoreNode(CoreNodeBase): self._mounts = [] # shutdown all interfaces for iface in self.get_ifaces(): + try: + self.node_net_client.device_flush(iface.name) + except CoreCommandError: + pass iface.shutdown() # kill node process if present try: @@ -691,150 +674,6 @@ class CoreNode(CoreNodeBase): self.cmd(f"{MOUNT} -n --bind {src_path} {target_path}") self._mounts.append((src_path, target_path)) - def next_iface_id(self) -> int: - """ - Retrieve a new interface index. - - :return: new interface index - """ - with self.lock: - return super().next_iface_id() - - def newveth(self, iface_id: int = None, ifname: str = None, mtu: int = None) -> int: - """ - Create a new interface. - - :param iface_id: id for the new interface - :param ifname: name for the new interface - :param mtu: mtu for interface - :return: nothing - """ - with self.lock: - mtu = mtu if mtu is not None else DEFAULT_MTU - iface_id = iface_id if iface_id is not None else self.next_iface_id() - ifname = ifname if ifname is not None else f"eth{iface_id}" - sessionid = self.session.short_session_id() - try: - suffix = f"{self.id:x}.{iface_id}.{sessionid}" - except TypeError: - suffix = f"{self.id}.{iface_id}.{sessionid}" - localname = f"veth{suffix}" - name = f"{localname}p" - veth = Veth(self.session, name, localname, mtu, self.server, self) - veth.adopt_node(iface_id, ifname, self.up) - return iface_id - - def newtuntap(self, iface_id: int = None, ifname: str = None) -> int: - """ - Create a new tunnel tap. - - :param iface_id: interface id - :param ifname: interface name - :return: interface index - """ - with self.lock: - iface_id = iface_id if iface_id is not None else self.next_iface_id() - ifname = ifname if ifname is not None else f"eth{iface_id}" - sessionid = self.session.short_session_id() - localname = f"tap{self.id}.{iface_id}.{sessionid}" - name = ifname - tuntap = TunTap(self.session, name, localname, node=self) - if self.up: - tuntap.startup() - try: - self.add_iface(tuntap, iface_id) - except CoreError as e: - tuntap.shutdown() - raise e - return iface_id - - def set_mac(self, iface_id: int, mac: str) -> None: - """ - Set hardware address for an interface. - - :param iface_id: id of interface to set hardware address for - :param mac: mac address to set - :return: nothing - :raises CoreCommandError: when a non-zero exit status occurs - """ - iface = self.get_iface(iface_id) - iface.set_mac(mac) - if self.up: - self.node_net_client.device_mac(iface.name, str(iface.mac)) - - def add_ip(self, iface_id: int, ip: str) -> None: - """ - Add an ip address to an interface in the format "10.0.0.1/24". - - :param iface_id: id of interface to add address to - :param ip: address to add to interface - :return: nothing - :raises CoreError: when ip address provided is invalid - :raises CoreCommandError: when a non-zero exit status occurs - """ - iface = self.get_iface(iface_id) - iface.add_ip(ip) - if self.up: - # ipv4 check - broadcast = None - if netaddr.valid_ipv4(ip): - broadcast = "+" - self.node_net_client.create_address(iface.name, ip, broadcast) - - def remove_ip(self, iface_id: int, ip: str) -> None: - """ - Remove an ip address from an interface in the format "10.0.0.1/24". - - :param iface_id: id of interface to delete address from - :param ip: ip address to remove from interface - :return: nothing - :raises CoreError: when ip address provided is invalid - :raises CoreCommandError: when a non-zero exit status occurs - """ - iface = self.get_iface(iface_id) - iface.remove_ip(ip) - if self.up: - self.node_net_client.delete_address(iface.name, ip) - - def ifup(self, iface_id: int) -> None: - """ - Bring an interface up. - - :param iface_id: index of interface to bring up - :return: nothing - """ - if self.up: - iface = self.get_iface(iface_id) - self.node_net_client.device_up(iface.name) - - def new_iface( - self, net: "CoreNetworkBase", iface_data: InterfaceData - ) -> CoreInterface: - """ - Create a new network interface. - - :param net: network to associate with - :param iface_data: interface data for new interface - :return: interface index - """ - with self.lock: - if net.has_custom_iface: - return net.custom_iface(self, iface_data) - else: - iface_id = iface_data.id - if iface_id is not None and iface_id in self.ifaces: - raise CoreError( - f"node({self.name}) already has interface({iface_id})" - ) - iface_id = self.newveth(iface_id, iface_data.name, iface_data.mtu) - self.attachnet(iface_id, net) - if iface_data.mac: - self.set_mac(iface_id, iface_data.mac) - for ip in iface_data.get_ips(): - self.add_ip(iface_id, ip) - self.ifup(iface_id) - return self.get_iface(iface_id) - def _find_parent_path(self, path: Path) -> Optional[Path]: """ Check if there is a mounted parent directory created for this node. @@ -910,6 +749,49 @@ class CoreNode(CoreNodeBase): if mode is not None: self.host_cmd(f"chmod {mode:o} {host_path}") + def adopt_iface(self, iface: CoreInterface, name: str) -> None: + """ + Adopt interface to the network namespace of the node and setting + the proper name provided. + + :param iface: interface to adopt + :param name: proper name for interface + :return: nothing + """ + # TODO: container, checksums off (container only?) + # TODO: container, get flow id (container only?) + # validate iface belongs to node and get id + iface_id = self.get_iface_id(iface) + if iface_id == -1: + raise CoreError(f"adopting unknown iface({iface.name})") + # add iface to container namespace + self.net_client.device_ns(iface.name, str(self.pid)) + # use default iface name for container, if a unique name was not provided + if iface.name == name: + name = f"eth{iface_id}" + self.node_net_client.device_name(iface.name, name) + iface.name = name + # turn checksums off + self.node_net_client.checksums_off(iface.name) + # retrieve flow id for container + iface.flow_id = self.node_net_client.get_ifindex(iface.name) + logger.debug("interface flow index: %s - %s", iface.name, iface.flow_id) + # set mac address + if iface.mac: + self.node_net_client.device_mac(iface.name, str(iface.mac)) + logger.debug("interface mac: %s - %s", iface.name, iface.mac) + # set all addresses + for ip in iface.ips(): + # ipv4 check + broadcast = None + if netaddr.valid_ipv4(ip): + broadcast = "+" + self.node_net_client.create_address(iface.name, str(ip), broadcast) + # configure iface options + iface.set_config() + # set iface up + self.node_net_client.device_up(iface.name) + class CoreNetworkBase(NodeBase): """ @@ -917,7 +799,6 @@ class CoreNetworkBase(NodeBase): """ linktype: LinkTypes = LinkTypes.WIRED - has_custom_iface: bool = False def __init__( self, @@ -941,57 +822,6 @@ class CoreNetworkBase(NodeBase): self.linked: Dict[CoreInterface, Dict[CoreInterface, bool]] = {} self.linked_lock: threading.Lock = threading.Lock() - @abc.abstractmethod - def startup(self) -> None: - """ - Each object implements its own startup method. - - :return: nothing - """ - raise NotImplementedError - - @abc.abstractmethod - def shutdown(self) -> None: - """ - Each object implements its own shutdown method. - - :return: nothing - """ - raise NotImplementedError - - @abc.abstractmethod - def linknet(self, net: "CoreNetworkBase") -> CoreInterface: - """ - Link network to another. - - :param net: network to link with - :return: created interface - """ - raise NotImplementedError - - @abc.abstractmethod - def custom_iface(self, node: CoreNode, iface_data: InterfaceData) -> CoreInterface: - """ - Defines custom logic for creating an interface, if required. - - :param node: node to create interface for - :param iface_data: data for creating interface - :return: created interface - """ - raise NotImplementedError - - def get_linked_iface(self, net: "CoreNetworkBase") -> Optional[CoreInterface]: - """ - Return the interface that links this net with another net. - - :param net: interface to get link for - :return: interface the provided network is linked to - """ - for iface in self.get_ifaces(): - if iface.othernet == net: - return iface - return None - def attach(self, iface: CoreInterface) -> None: """ Attach network interface. @@ -999,9 +829,10 @@ class CoreNetworkBase(NodeBase): :param iface: network interface to attach :return: nothing """ - i = self.next_iface_id() - self.ifaces[i] = iface - iface.net_id = i + iface_id = self.next_iface_id() + self.ifaces[iface_id] = iface + iface.net = self + iface.net_id = iface_id with self.linked_lock: self.linked[iface] = {} @@ -1013,56 +844,11 @@ class CoreNetworkBase(NodeBase): :return: nothing """ del self.ifaces[iface.net_id] + iface.net = None iface.net_id = None with self.linked_lock: del self.linked[iface] - def links(self, flags: MessageFlags = MessageFlags.NONE) -> List[LinkData]: - """ - Build link data objects for this network. Each link object describes a link - between this network and a node. - - :param flags: message type - :return: list of link data - """ - all_links = [] - # build a link message from this network node to each node having a - # connected interface - for iface in self.get_ifaces(): - unidirectional = 0 - linked_node = iface.node - if linked_node is None: - # two layer-2 switches/hubs linked together - if not iface.othernet: - continue - linked_node = iface.othernet - if linked_node.id == self.id: - continue - if iface.local_options != iface.options: - unidirectional = 1 - iface_data = iface.get_data() - link_data = LinkData( - message_type=flags, - type=self.linktype, - node1_id=self.id, - node2_id=linked_node.id, - iface2=iface_data, - options=iface.local_options, - ) - link_data.options.unidirectional = unidirectional - all_links.append(link_data) - if unidirectional: - link_data = LinkData( - message_type=MessageFlags.NONE, - type=self.linktype, - node1_id=linked_node.id, - node2_id=self.id, - options=iface.options, - ) - link_data.options.unidirectional = unidirectional - all_links.append(link_data) - return all_links - class Position: """ diff --git a/daemon/core/nodes/docker.py b/daemon/core/nodes/docker.py index d5e928de..0a0690b1 100644 --- a/daemon/core/nodes/docker.py +++ b/daemon/core/nodes/docker.py @@ -93,10 +93,9 @@ class DockerNode(CoreNode): will run on, default is None for localhost :param image: image to start container with """ - if image is None: - image = "ubuntu" - self.image: str = image super().__init__(session, _id, name, directory, server) + self.image = image if image is not None else "ubuntu" + self.client: Optional[DockerClient] = None def create_node_net_client(self, use_ovs: bool) -> LinuxNetClient: """ @@ -141,7 +140,6 @@ class DockerNode(CoreNode): # nothing to do if node is not up if not self.up: return - with self.lock: self.ifaces.clear() self.client.stop_container() diff --git a/daemon/core/nodes/interface.py b/daemon/core/nodes/interface.py index 70eb679f..bb90653f 100644 --- a/daemon/core/nodes/interface.py +++ b/daemon/core/nodes/interface.py @@ -4,7 +4,6 @@ virtual ethernet classes that implement the interfaces available under Linux. import logging import math -import time from pathlib import Path from typing import TYPE_CHECKING, Callable, Dict, List, Optional @@ -20,11 +19,12 @@ from core.nodes.netclient import LinuxNetClient, get_net_client logger = logging.getLogger(__name__) if TYPE_CHECKING: - from core.emulator.distributed import DistributedServer from core.emulator.session import Session - from core.nodes.base import CoreNetworkBase, CoreNode + from core.emulator.distributed import DistributedServer + from core.nodes.base import CoreNetworkBase, CoreNode, NodeBase DEFAULT_MTU: int = 1500 +IFACE_NAME_LENGTH: int = 15 def tc_clear_cmd(name: str) -> str: @@ -78,35 +78,42 @@ class CoreInterface: def __init__( self, - session: "Session", + _id: int, name: str, localname: str, + use_ovs: bool, mtu: int = DEFAULT_MTU, + node: "NodeBase" = None, server: "DistributedServer" = None, - node: "CoreNode" = None, ) -> None: """ Creates a CoreInterface instance. - :param session: core session instance + :param _id: interface id for associated node :param name: interface name :param localname: interface local name + :param use_ovs: True to use ovs, False otherwise :param mtu: mtu value + :param node: node associated with this interface :param server: remote server node will run on, default is None for localhost - :param node: node for interface """ - if len(name) >= 16: - raise CoreError(f"interface name ({name}) too long, max 16") - if len(localname) >= 16: - raise CoreError(f"interface local name ({localname}) too long, max 16") - self.session: "Session" = session - self.node: Optional["CoreNode"] = node + if len(name) >= IFACE_NAME_LENGTH: + raise CoreError( + f"interface name ({name}) too long, max {IFACE_NAME_LENGTH}" + ) + if len(localname) >= IFACE_NAME_LENGTH: + raise CoreError( + f"interface local name ({localname}) too long, max {IFACE_NAME_LENGTH}" + ) + self.id: int = _id + self.node: Optional["NodeBase"] = node + # id of interface for network, used by wlan/emane + self.net_id: Optional[int] = None self.name: str = name self.localname: str = localname self.up: bool = False self.mtu: int = mtu self.net: Optional[CoreNetworkBase] = None - self.othernet: Optional[CoreNetworkBase] = None self.ip4s: List[netaddr.IPNetwork] = [] self.ip6s: List[netaddr.IPNetwork] = [] self.mac: Optional[netaddr.EUI] = None @@ -114,20 +121,12 @@ class CoreInterface: self.poshook: Callable[[CoreInterface], None] = lambda x: None # used with EMANE self.transport_type: TransportType = TransportType.VIRTUAL - # id of interface for node - self.node_id: Optional[int] = None - # id of interface for network - self.net_id: Optional[int] = None # id used to find flow data self.flow_id: Optional[int] = None self.server: Optional["DistributedServer"] = server - self.net_client: LinuxNetClient = get_net_client( - self.session.use_ovs(), self.host_cmd - ) + self.net_client: LinuxNetClient = get_net_client(use_ovs, self.host_cmd) self.control: bool = False # configuration data - self.has_local_netem: bool = False - self.local_options: LinkOptions = LinkOptions() self.has_netem: bool = False self.options: LinkOptions = LinkOptions() @@ -161,7 +160,13 @@ class CoreInterface: :return: nothing """ - pass + self.net_client.create_veth(self.localname, self.name) + if self.mtu > 0: + self.net_client.set_mtu(self.name, self.mtu) + self.net_client.set_mtu(self.localname, self.mtu) + self.net_client.device_up(self.name) + self.net_client.device_up(self.localname) + self.up = True def shutdown(self) -> None: """ @@ -169,29 +174,14 @@ class CoreInterface: :return: nothing """ - pass - - def attachnet(self, net: "CoreNetworkBase") -> None: - """ - Attach network. - - :param net: network to attach - :return: nothing - """ - if self.net: - self.detachnet() - self.net = None - net.attach(self) - self.net = net - - def detachnet(self) -> None: - """ - Detach from a network. - - :return: nothing - """ - if self.net is not None: - self.net.detach(self) + if not self.up: + return + if self.localname: + try: + self.net_client.delete_device(self.localname) + except CoreCommandError: + pass + self.up = False def add_ip(self, ip: str) -> None: """ @@ -303,41 +293,24 @@ class CoreInterface: """ return self.transport_type == TransportType.VIRTUAL - def config(self, options: LinkOptions, use_local: bool = True) -> None: - """ - Configure interface using tc based on existing state and provided - link options. - - :param options: options to configure with - :param use_local: True to use localname for device, False for name - :return: nothing - """ - # determine name, options, and if anything has changed - name = self.localname if use_local else self.name - current_options = self.local_options if use_local else self.options - changed = current_options.update(options) - # nothing more to do when nothing has changed or not up - if not changed or not self.up: - return + def set_config(self) -> None: # clear current settings - if current_options.is_clear(): - clear_local_netem = use_local and self.has_local_netem - clear_netem = not use_local and self.has_netem - if clear_local_netem or clear_netem: - cmd = tc_clear_cmd(name) - self.host_cmd(cmd) - if use_local: - self.has_local_netem = False + if self.options.is_clear(): + if self.has_netem: + cmd = tc_clear_cmd(self.name) + if self.node: + self.node.cmd(cmd) else: - self.has_netem = False + self.host_cmd(cmd) + self.has_netem = False # set updated settings else: - cmd = tc_cmd(name, current_options, self.mtu) - self.host_cmd(cmd) - if use_local: - self.has_local_netem = True + cmd = tc_cmd(self.name, self.options, self.mtu) + if self.node: + self.node.cmd(cmd) else: - self.has_netem = True + self.host_cmd(cmd) + self.has_netem = True def get_data(self) -> InterfaceData: """ @@ -345,231 +318,22 @@ class CoreInterface: :return: interface data """ - if self.node: - iface_id = self.node.get_iface_id(self) - else: - iface_id = self.othernet.get_iface_id(self) - data = InterfaceData( - id=iface_id, name=self.name, mac=str(self.mac) if self.mac else None - ) ip4 = self.get_ip4() - if ip4: - data.ip4 = str(ip4.ip) - data.ip4_mask = ip4.prefixlen + ip4_addr = str(ip4.ip) if ip4 else None + ip4_mask = ip4.prefixlen if ip4 else None ip6 = self.get_ip6() - if ip6: - data.ip6 = str(ip6.ip) - data.ip6_mask = ip6.prefixlen - return data - - -class Veth(CoreInterface): - """ - Provides virtual ethernet functionality for core nodes. - """ - - def adopt_node(self, iface_id: int, name: str, start: bool) -> None: - """ - Adopt this interface to the provided node, configuring and associating - with the node as needed. - - :param iface_id: interface id for node - :param name: name of interface fo rnode - :param start: True to start interface, False otherwise - :return: nothing - """ - if start: - self.startup() - self.net_client.device_ns(self.name, str(self.node.pid)) - self.node.node_net_client.checksums_off(self.name) - self.flow_id = self.node.node_net_client.get_ifindex(self.name) - logger.debug("interface flow index: %s - %s", self.name, self.flow_id) - mac = self.node.node_net_client.get_mac(self.name) - logger.debug("interface mac: %s - %s", self.name, mac) - self.set_mac(mac) - self.node.node_net_client.device_name(self.name, name) - self.name = name - try: - self.node.add_iface(self, iface_id) - except CoreError as e: - self.shutdown() - raise e - - def startup(self) -> None: - """ - Interface startup logic. - - :return: nothing - :raises CoreCommandError: when there is a command exception - """ - self.net_client.create_veth(self.localname, self.name) - if self.mtu > 0: - self.net_client.set_mtu(self.name, self.mtu) - self.net_client.set_mtu(self.localname, self.mtu) - self.net_client.device_up(self.localname) - self.up = True - - def shutdown(self) -> None: - """ - Interface shutdown logic. - - :return: nothing - """ - if not self.up: - return - if self.node: - try: - self.node.node_net_client.device_flush(self.name) - except CoreCommandError: - pass - if self.localname: - try: - self.net_client.delete_device(self.localname) - except CoreCommandError: - pass - self.up = False - - -class TunTap(CoreInterface): - """ - TUN/TAP virtual device in TAP mode - """ - - def startup(self) -> None: - """ - Startup logic for a tunnel tap. - - :return: nothing - """ - # TODO: more sophisticated TAP creation here - # Debian does not support -p (tap) option, RedHat does. - # For now, this is disabled to allow the TAP to be created by another - # system (e.g. EMANE"s emanetransportd) - # check_call(["tunctl", "-t", self.name]) - # self.install() - self.up = True - - def shutdown(self) -> None: - """ - Shutdown functionality for a tunnel tap. - - :return: nothing - """ - if not self.up: - return - try: - self.node.node_net_client.device_flush(self.name) - except CoreCommandError: - logger.exception("error shutting down tunnel tap") - self.up = False - - def waitfor( - self, func: Callable[[], int], attempts: int = 10, maxretrydelay: float = 0.25 - ) -> bool: - """ - Wait for func() to return zero with exponential backoff. - - :param func: function to wait for a result of zero - :param attempts: number of attempts to wait for a zero result - :param maxretrydelay: maximum retry delay - :return: True if wait succeeded, False otherwise - """ - delay = 0.01 - result = False - for i in range(1, attempts + 1): - r = func() - if r == 0: - result = True - break - msg = f"attempt {i} failed with nonzero exit status {r}" - if i < attempts + 1: - msg += ", retrying..." - logger.info(msg) - time.sleep(delay) - delay += delay - if delay > maxretrydelay: - delay = maxretrydelay - else: - msg += ", giving up" - logger.info(msg) - - return result - - def waitfordevicelocal(self) -> None: - """ - Check for presence of a local device - tap device may not - appear right away waits - - :return: wait for device local response - """ - logger.debug("waiting for device local: %s", self.localname) - - def localdevexists(): - try: - self.net_client.device_show(self.localname) - return 0 - except CoreCommandError: - return 1 - - self.waitfor(localdevexists) - - def waitfordevicenode(self) -> None: - """ - Check for presence of a node device - tap device may not appear right away waits. - - :return: nothing - """ - logger.debug("waiting for device node: %s", self.name) - - def nodedevexists(): - try: - self.node.node_net_client.device_show(self.name) - return 0 - except CoreCommandError: - return 1 - - count = 0 - while True: - result = self.waitfor(nodedevexists) - if result: - break - - # TODO: emane specific code - # check if this is an EMANE interface; if so, continue - # waiting if EMANE is still running - should_retry = count < 5 - is_emane = self.session.emane.is_emane_net(self.net) - is_emane_running = self.session.emane.emanerunning(self.node) - if all([should_retry, is_emane, is_emane_running]): - count += 1 - else: - raise RuntimeError("node device failed to exist") - - def install(self) -> None: - """ - Install this TAP into its namespace. This is not done from the - startup() method but called at a later time when a userspace - program (running on the host) has had a chance to open the socket - end of the TAP. - - :return: nothing - :raises CoreCommandError: when there is a command exception - """ - self.waitfordevicelocal() - netns = str(self.node.pid) - self.net_client.device_ns(self.localname, netns) - self.node.node_net_client.device_name(self.localname, self.name) - self.node.node_net_client.device_up(self.name) - - def set_ips(self) -> None: - """ - Set interface ip addresses. - - :return: nothing - """ - self.waitfordevicenode() - for ip in self.ips(): - self.node.node_net_client.create_address(self.name, str(ip)) + ip6_addr = str(ip6.ip) if ip6 else None + ip6_mask = ip6.prefixlen if ip6 else None + mac = str(self.mac) if self.mac else None + return InterfaceData( + id=self.id, + name=self.name, + mac=mac, + ip4=ip4_addr, + ip4_mask=ip4_mask, + ip6=ip6_addr, + ip6_mask=ip6_mask, + ) class GreTap(CoreInterface): @@ -594,7 +358,7 @@ class GreTap(CoreInterface): """ Creates a GreTap instance. - :param session: core session instance + :param session: session for this gre tap :param remoteip: remote address :param key: gre tap key :param node: related core node @@ -612,7 +376,7 @@ class GreTap(CoreInterface): sessionid = session.short_session_id() localname = f"gt.{self.id}.{sessionid}" name = f"{localname}p" - super().__init__(session, name, localname, mtu, server, node) + super().__init__(0, name, localname, session.use_ovs(), mtu, node, server) self.transport_type: TransportType = TransportType.RAW self.remote_ip: str = remoteip self.ttl: int = ttl diff --git a/daemon/core/nodes/lxd.py b/daemon/core/nodes/lxd.py index 54fc8341..e755e9c9 100644 --- a/daemon/core/nodes/lxd.py +++ b/daemon/core/nodes/lxd.py @@ -6,6 +6,7 @@ from tempfile import NamedTemporaryFile from typing import TYPE_CHECKING, Callable, Dict, Optional from core import utils +from core.emulator.data import InterfaceData, LinkOptions from core.emulator.distributed import DistributedServer from core.emulator.enumerations import NodeTypes from core.errors import CoreCommandError @@ -89,10 +90,9 @@ class LxcNode(CoreNode): will run on, default is None for localhost :param image: image to start container with """ - if image is None: - image = "ubuntu" - self.image: str = image super().__init__(session, _id, name, directory, server) + self.image: str = image if image is not None else "ubuntu" + self.client: Optional[LxdClient] = None def alive(self) -> bool: """ @@ -125,7 +125,6 @@ class LxcNode(CoreNode): # nothing to do if node is not up if not self.up: return - with self.lock: self.ifaces.clear() self.client.stop_container() @@ -212,7 +211,10 @@ class LxcNode(CoreNode): if mode is not None: self.cmd(f"chmod {mode:o} {dst_path}") - def add_iface(self, iface: CoreInterface, iface_id: int) -> None: - super().add_iface(iface, iface_id) + def create_iface( + self, iface_data: InterfaceData = None, options: LinkOptions = None + ) -> CoreInterface: + iface = super().create_iface(iface_data, options) # adding small delay to allow time for adding addresses to work correctly time.sleep(0.5) + return iface diff --git a/daemon/core/nodes/network.py b/daemon/core/nodes/network.py index 262d422c..decfdbc0 100644 --- a/daemon/core/nodes/network.py +++ b/daemon/core/nodes/network.py @@ -22,8 +22,8 @@ from core.emulator.enumerations import ( ) from core.errors import CoreCommandError, CoreError from core.executables import NFTABLES -from core.nodes.base import CoreNetworkBase, CoreNode -from core.nodes.interface import CoreInterface, GreTap, Veth +from core.nodes.base import CoreNetworkBase +from core.nodes.interface import CoreInterface, GreTap from core.nodes.netclient import get_net_client logger = logging.getLogger(__name__) @@ -222,7 +222,7 @@ class CoreNetwork(CoreNetworkBase): policy: NetworkPolicy = None, ) -> None: """ - Creates a LxBrNet instance. + Creates a CoreNetwork instance. :param session: core session instance :param _id: object id @@ -280,6 +280,17 @@ class CoreNetwork(CoreNetworkBase): self.up = True nft_queue.start() + def adopt_iface(self, iface: CoreInterface, name: str) -> None: + """ + Adopt interface and set it to use this bridge as master. + + :param iface: interface to adpopt + :param name: formal name for interface + :return: nothing + """ + iface.net_client.set_iface_master(self.brname, iface.name) + iface.set_config() + def shutdown(self) -> None: """ Linux bridge shutdown logic. @@ -309,9 +320,9 @@ class CoreNetwork(CoreNetworkBase): :param iface: network interface to attach :return: nothing """ + super().attach(iface) if self.up: iface.net_client.set_iface_master(self.brname, iface.localname) - super().attach(iface) def detach(self, iface: CoreInterface) -> None: """ @@ -320,9 +331,9 @@ class CoreNetwork(CoreNetworkBase): :param iface: network interface to detach :return: nothing """ + super().detach(iface) if self.up: iface.net_client.delete_iface(self.brname, iface.localname) - super().detach(iface) def is_linked(self, iface1: CoreInterface, iface2: CoreInterface) -> bool: """ @@ -378,67 +389,6 @@ class CoreNetwork(CoreNetworkBase): self.linked[iface1][iface2] = True nft_queue.update(self) - def linknet(self, net: CoreNetworkBase) -> CoreInterface: - """ - Link this bridge with another by creating a veth pair and installing - each device into each bridge. - - :param net: network to link with - :return: created interface - """ - sessionid = self.session.short_session_id() - try: - _id = f"{self.id:x}" - except TypeError: - _id = str(self.id) - try: - net_id = f"{net.id:x}" - except TypeError: - net_id = str(net.id) - localname = f"veth{_id}.{net_id}.{sessionid}" - name = f"veth{net_id}.{_id}.{sessionid}" - iface = Veth(self.session, name, localname) - if self.up: - iface.startup() - self.attach(iface) - if net.up and net.brname: - iface.net_client.set_iface_master(net.brname, iface.name) - i = net.next_iface_id() - net.ifaces[i] = iface - with net.linked_lock: - net.linked[iface] = {} - iface.net = self - iface.othernet = net - return iface - - def get_linked_iface(self, net: CoreNetworkBase) -> Optional[CoreInterface]: - """ - Return the interface of that links this net with another net - (that were linked using linknet()). - - :param net: interface to get link for - :return: interface the provided network is linked to - """ - for iface in self.get_ifaces(): - if iface.othernet == net: - return iface - return None - - def add_ips(self, ips: List[str]) -> None: - """ - Add ip addresses on the bridge in the format "10.0.0.1/24". - - :param ips: ip address to add - :return: nothing - """ - if not self.up: - return - for ip in ips: - self.net_client.create_address(self.brname, ip) - - def custom_iface(self, node: CoreNode, iface_data: InterfaceData) -> CoreInterface: - raise CoreError(f"{type(self).__name__} does not support, custom interfaces") - class GreTapBridge(CoreNetwork): """ @@ -686,15 +636,6 @@ class CtrlNet(CoreNetwork): super().shutdown() - def links(self, flags: MessageFlags = MessageFlags.NONE) -> List[LinkData]: - """ - Do not include CtrlNet in link messages describing this session. - - :param flags: message flags - :return: list of link data - """ - return [] - class PtpNet(CoreNetwork): """ @@ -714,50 +655,6 @@ class PtpNet(CoreNetwork): raise CoreError("ptp links support at most 2 network interfaces") super().attach(iface) - def links(self, flags: MessageFlags = MessageFlags.NONE) -> List[LinkData]: - """ - Build CORE API TLVs for a point-to-point link. One Link message - describes this network. - - :param flags: message flags - :return: list of link data - """ - all_links = [] - if len(self.ifaces) != 2: - return all_links - ifaces = self.get_ifaces() - iface1 = ifaces[0] - iface2 = ifaces[1] - unidirectional = 0 if iface1.local_options == iface2.local_options else 1 - iface1_data = iface1.get_data() - iface2_data = iface2.get_data() - link_data = LinkData( - message_type=flags, - type=self.linktype, - node1_id=iface1.node.id, - node2_id=iface2.node.id, - iface1=iface1_data, - iface2=iface2_data, - options=iface1.local_options, - ) - link_data.options.unidirectional = unidirectional - all_links.append(link_data) - # build a 2nd link message for the upstream link parameters - # (swap if1 and if2) - if unidirectional: - link_data = LinkData( - message_type=MessageFlags.NONE, - type=self.linktype, - node1_id=iface2.node.id, - node2_id=iface1.node.id, - iface1=InterfaceData(id=iface2_data.id), - iface2=InterfaceData(id=iface1_data.id), - options=iface2.local_options, - ) - link_data.options.unidirectional = unidirectional - all_links.append(link_data) - return all_links - class SwitchNode(CoreNetwork): """ @@ -884,10 +781,10 @@ class WlanNode(CoreNetwork): :param flags: message flags :return: list of link data """ - links = super().links(flags) if self.model: - links.extend(self.model.links(flags)) - return links + return self.model.links(flags) + else: + return [] class TunnelNode(GreTapBridge): diff --git a/daemon/core/nodes/physical.py b/daemon/core/nodes/physical.py index 0a686da8..ae1b07af 100644 --- a/daemon/core/nodes/physical.py +++ b/daemon/core/nodes/physical.py @@ -3,17 +3,18 @@ PhysicalNode class for including real systems in the emulated network. """ import logging -import threading from pathlib import Path from typing import TYPE_CHECKING, List, Optional, Tuple -from core.emulator.data import InterfaceData +import netaddr + +from core.emulator.data import InterfaceData, LinkOptions from core.emulator.distributed import DistributedServer from core.emulator.enumerations import NodeTypes, TransportType from core.errors import CoreCommandError, CoreError -from core.executables import MOUNT, TEST, UMOUNT -from core.nodes.base import CoreNetworkBase, CoreNodeBase -from core.nodes.interface import DEFAULT_MTU, CoreInterface +from core.executables import BASH, TEST, UMOUNT +from core.nodes.base import CoreNode, CoreNodeBase +from core.nodes.interface import CoreInterface logger = logging.getLogger(__name__) @@ -21,185 +22,6 @@ if TYPE_CHECKING: from core.emulator.session import Session -class PhysicalNode(CoreNodeBase): - def __init__( - self, - session: "Session", - _id: int = None, - name: str = None, - directory: Path = None, - server: DistributedServer = None, - ) -> None: - super().__init__(session, _id, name, server) - if not self.server: - raise CoreError("physical nodes must be assigned to a remote server") - self.directory: Optional[Path] = directory - self.lock: threading.RLock = threading.RLock() - self._mounts: List[Tuple[Path, Path]] = [] - - def startup(self) -> None: - with self.lock: - self.makenodedir() - self.up = True - - def shutdown(self) -> None: - if not self.up: - return - with self.lock: - while self._mounts: - _, target_path = self._mounts.pop(-1) - self.umount(target_path) - for iface in self.get_ifaces(): - iface.shutdown() - self.rmnodedir() - - def path_exists(self, path: str) -> bool: - """ - Determines if a file or directory path exists. - - :param path: path to file or directory - :return: True if path exists, False otherwise - """ - try: - self.host_cmd(f"{TEST} -e {path}") - return True - except CoreCommandError: - return False - - def termcmdstring(self, sh: str = "/bin/sh") -> str: - """ - Create a terminal command string. - - :param sh: shell to execute command in - :return: str - """ - return sh - - def set_mac(self, iface_id: int, mac: str) -> None: - """ - Set mac address for an interface. - - :param iface_id: index of interface to set hardware address for - :param mac: mac address to set - :return: nothing - :raises CoreCommandError: when a non-zero exit status occurs - """ - iface = self.get_iface(iface_id) - iface.set_mac(mac) - if self.up: - self.net_client.device_mac(iface.name, str(iface.mac)) - - def add_ip(self, iface_id: int, ip: str) -> None: - """ - Add an ip address to an interface in the format "10.0.0.1/24". - - :param iface_id: id of interface to add address to - :param ip: address to add to interface - :return: nothing - :raises CoreError: when ip address provided is invalid - :raises CoreCommandError: when a non-zero exit status occurs - """ - iface = self.get_iface(iface_id) - iface.add_ip(ip) - if self.up: - self.net_client.create_address(iface.name, ip) - - def remove_ip(self, iface_id: int, ip: str) -> None: - """ - Remove an ip address from an interface in the format "10.0.0.1/24". - - :param iface_id: id of interface to delete address from - :param ip: ip address to remove from interface - :return: nothing - :raises CoreError: when ip address provided is invalid - :raises CoreCommandError: when a non-zero exit status occurs - """ - iface = self.get_iface(iface_id) - iface.remove_ip(ip) - if self.up: - self.net_client.delete_address(iface.name, ip) - - def adopt_iface( - self, iface: CoreInterface, iface_id: int, mac: str, ips: List[str] - ) -> None: - """ - When a link message is received linking this node to another part of - the emulation, no new interface is created; instead, adopt the - GreTap interface as the node interface. - """ - iface.name = f"gt{iface_id}" - iface.node = self - self.add_iface(iface, iface_id) - # use a more reasonable name, e.g. "gt0" instead of "gt.56286.150" - if self.up: - self.net_client.device_down(iface.localname) - self.net_client.device_name(iface.localname, iface.name) - iface.localname = iface.name - if mac: - self.set_mac(iface_id, mac) - for ip in ips: - self.add_ip(iface_id, ip) - if self.up: - self.net_client.device_up(iface.localname) - - def next_iface_id(self) -> int: - with self.lock: - while self.iface_id in self.ifaces: - self.iface_id += 1 - iface_id = self.iface_id - self.iface_id += 1 - return iface_id - - def new_iface( - self, net: CoreNetworkBase, iface_data: InterfaceData - ) -> CoreInterface: - logger.info("creating interface") - ips = iface_data.get_ips() - iface_id = iface_data.id - if iface_id is None: - iface_id = self.next_iface_id() - name = iface_data.name - if name is None: - name = f"gt{iface_id}" - _, remote_tap = self.session.distributed.create_gre_tunnel( - net, self.server, iface_data.mtu, self.up - ) - self.adopt_iface(remote_tap, iface_id, iface_data.mac, ips) - return remote_tap - - def privatedir(self, dir_path: Path) -> None: - if not str(dir_path).startswith("/"): - raise CoreError(f"private directory path not fully qualified: {dir_path}") - host_path = self.host_path(dir_path, is_dir=True) - self.host_cmd(f"mkdir -p {host_path}") - self.mount(host_path, dir_path) - - def mount(self, src_path: Path, target_path: Path) -> None: - logger.debug("node(%s) mounting: %s at %s", self.name, src_path, target_path) - self.cmd(f"mkdir -p {target_path}") - self.host_cmd(f"{MOUNT} --bind {src_path} {target_path}", cwd=self.directory) - self._mounts.append((src_path, target_path)) - - def umount(self, target_path: Path) -> None: - logger.info("unmounting '%s'", target_path) - try: - self.host_cmd(f"{UMOUNT} -l {target_path}", cwd=self.directory) - except CoreCommandError: - logger.exception("unmounting failed for %s", target_path) - - def cmd(self, args: str, wait: bool = True, shell: bool = False) -> str: - return self.host_cmd(args, wait=wait) - - def create_dir(self, dir_path: Path) -> None: - raise CoreError("physical node does not support creating directories") - - def create_file(self, file_path: Path, contents: str, mode: int = 0o644) -> None: - raise CoreError("physical node does not support creating files") - - def copy_file(self, src_path: Path, dst_path: Path, mode: int = None) -> None: - raise CoreError("physical node does not support copying files") - - class Rj45Node(CoreNodeBase): """ RJ45Node is a physical interface on the host linked to the emulated @@ -214,7 +36,6 @@ class Rj45Node(CoreNodeBase): session: "Session", _id: int = None, name: str = None, - mtu: int = DEFAULT_MTU, server: DistributedServer = None, ) -> None: """ @@ -223,17 +44,14 @@ class Rj45Node(CoreNodeBase): :param session: core session instance :param _id: node id :param name: node name - :param mtu: rj45 mtu :param server: remote server node will run on, default is None for localhost """ super().__init__(session, _id, name, server) self.iface: CoreInterface = CoreInterface( - session, name, name, mtu, server, self + self.iface_id, name, name, session.use_ovs(), node=self, server=server ) self.iface.transport_type = TransportType.RAW - self.lock: threading.RLock = threading.RLock() - self.iface_id: Optional[int] = None self.old_up: bool = False self.old_addrs: List[Tuple[str, Optional[str]]] = [] @@ -245,7 +63,7 @@ class Rj45Node(CoreNodeBase): :raises CoreCommandError: when there is a command exception """ # interface will also be marked up during net.attach() - self.savestate() + self.save_state() self.net_client.device_up(self.iface.localname) self.up = True @@ -266,7 +84,7 @@ class Rj45Node(CoreNodeBase): except CoreCommandError: pass self.up = False - self.restorestate() + self.restore_state() def path_exists(self, path: str) -> bool: """ @@ -281,33 +99,28 @@ class Rj45Node(CoreNodeBase): except CoreCommandError: return False - def new_iface( - self, net: CoreNetworkBase, iface_data: InterfaceData + def create_iface( + self, iface_data: InterfaceData = None, options: LinkOptions = None ) -> CoreInterface: - """ - This is called when linking with another node. Since this node - represents an interface, we do not create another object here, - but attach ourselves to the given network. - - :param net: new network instance - :param iface_data: interface data for new interface - :return: interface index - :raises ValueError: when an interface has already been created, one max - """ with self.lock: - iface_id = iface_data.id - if iface_id is None: - iface_id = 0 - if self.iface.net is not None: + if self.iface.id in self.ifaces: raise CoreError( - f"RJ45({self.name}) nodes support at most 1 network interface" + f"rj45({self.name}) nodes support at most 1 network interface" ) - self.ifaces[iface_id] = self.iface - self.iface_id = iface_id - self.iface.attachnet(net) + if iface_data and iface_data.mtu is not None: + self.iface.mtu = iface_data.mtu + self.iface.ip4s.clear() + self.iface.ip6s.clear() for ip in iface_data.get_ips(): - self.add_ip(ip) - return self.iface + self.iface.add_ip(ip) + self.ifaces[self.iface.id] = self.iface + if self.up: + for ip in self.iface.ips(): + self.net_client.create_address(self.iface.name, str(ip)) + return self.iface + + def adopt_iface(self, iface: CoreInterface, name: str) -> None: + raise CoreError(f"rj45({self.name}) does not support adopt interface") def delete_iface(self, iface_id: int) -> None: """ @@ -318,16 +131,10 @@ class Rj45Node(CoreNodeBase): """ self.get_iface(iface_id) self.ifaces.pop(iface_id) - if self.iface.net is None: - raise CoreError( - f"RJ45({self.name}) is not currently connected to a network" - ) - self.iface.detachnet() - self.iface.net = None self.shutdown() def get_iface(self, iface_id: int) -> CoreInterface: - if iface_id != self.iface_id or iface_id not in self.ifaces: + if iface_id not in self.ifaces: raise CoreError(f"node({self.name}) interface({iface_id}) does not exist") return self.iface @@ -341,42 +148,17 @@ class Rj45Node(CoreNodeBase): """ if iface is not self.iface: raise CoreError(f"node({self.name}) does not have interface({iface.name})") - return self.iface_id + return self.iface.id - def add_ip(self, ip: str) -> None: - """ - Add an ip address to an interface in the format "10.0.0.1/24". - - :param ip: address to add to interface - :return: nothing - :raises CoreError: when ip address provided is invalid - :raises CoreCommandError: when a non-zero exit status occurs - """ - self.iface.add_ip(ip) - if self.up: - self.net_client.create_address(self.name, ip) - - def remove_ip(self, ip: str) -> None: - """ - Remove an ip address from an interface in the format "10.0.0.1/24". - - :param ip: ip address to remove from interface - :return: nothing - :raises CoreError: when ip address provided is invalid - :raises CoreCommandError: when a non-zero exit status occurs - """ - self.iface.remove_ip(ip) - if self.up: - self.net_client.delete_address(self.name, ip) - - def savestate(self) -> None: + def save_state(self) -> None: """ Save the addresses and other interface state before using the - interface for emulation purposes. TODO: save/restore the PROMISC flag + interface for emulation purposes. :return: nothing :raises CoreCommandError: when there is a command exception """ + # TODO: save/restore the PROMISC flag self.old_up = False self.old_addrs: List[Tuple[str, Optional[str]]] = [] localname = self.iface.localname @@ -397,7 +179,7 @@ class Rj45Node(CoreNodeBase): self.old_addrs.append((items[1], None)) logger.info("saved rj45 state: addrs(%s) up(%s)", self.old_addrs, self.old_up) - def restorestate(self) -> None: + def restore_state(self) -> None: """ Restore the addresses and other interface state after using it. @@ -437,3 +219,69 @@ class Rj45Node(CoreNodeBase): def copy_file(self, src_path: Path, dst_path: Path, mode: int = None) -> None: raise CoreError("rj45 does not support copying files") + + +class PhysicalNode(CoreNode): + def __init__( + self, + session: "Session", + _id: int = None, + name: str = None, + directory: Path = None, + server: DistributedServer = None, + ) -> None: + if not self.server: + raise CoreError("physical nodes must be assigned to a remote server") + super().__init__(session, _id, name, directory, server) + + def startup(self) -> None: + with self.lock: + self.makenodedir() + self.up = True + + def shutdown(self) -> None: + if not self.up: + return + with self.lock: + while self._mounts: + _, target_path = self._mounts.pop(-1) + self.umount(target_path) + for iface in self.get_ifaces(): + iface.shutdown() + self.rmnodedir() + + def _create_cmd(self, args: str, shell: bool = False) -> str: + if shell: + args = f'{BASH} -c "{args}"' + return args + + def adopt_iface(self, iface: CoreInterface, name: str) -> None: + # validate iface belongs to node and get id + iface_id = self.get_iface_id(iface) + if iface_id == -1: + raise CoreError(f"adopting unknown iface({iface.name})") + # turn checksums off + self.node_net_client.checksums_off(iface.name) + # retrieve flow id for container + iface.flow_id = self.node_net_client.get_ifindex(iface.name) + logger.debug("interface flow index: %s - %s", iface.name, iface.flow_id) + if iface.mac: + self.net_client.device_mac(iface.name, str(iface.mac)) + # set all addresses + for ip in iface.ips(): + # ipv4 check + broadcast = None + if netaddr.valid_ipv4(ip): + broadcast = "+" + self.node_net_client.create_address(iface.name, str(ip), broadcast) + # configure iface options + iface.set_config() + # set iface up + self.net_client.device_up(iface.name) + + def umount(self, target_path: Path) -> None: + logger.info("unmounting '%s'", target_path) + try: + self.host_cmd(f"{UMOUNT} -l {target_path}", cwd=self.directory) + except CoreCommandError: + logger.exception("unmounting failed for %s", target_path) diff --git a/daemon/core/nodes/wireless.py b/daemon/core/nodes/wireless.py new file mode 100644 index 00000000..69e64639 --- /dev/null +++ b/daemon/core/nodes/wireless.py @@ -0,0 +1,240 @@ +""" +Defines a wireless node that allows programmatic link connectivity and +configuration between pairs of nodes. +""" + +import logging +import math +from dataclasses import dataclass +from typing import TYPE_CHECKING, Dict, Tuple + +from core.emulator.data import LinkData, LinkOptions +from core.emulator.enumerations import LinkTypes, MessageFlags +from core.errors import CoreError +from core.executables import NFTABLES +from core.nodes.base import CoreNetworkBase +from core.nodes.interface import CoreInterface + +if TYPE_CHECKING: + from core.emulator.session import Session + from core.emulator.distributed import DistributedServer + +logger = logging.getLogger(__name__) + + +def calc_distance( + point1: Tuple[float, float, float], point2: Tuple[float, float, float] +) -> float: + a = point1[0] - point2[0] + b = point1[1] - point2[1] + c = 0 + if point1[2] is not None and point2[2] is not None: + c = point1[2] - point2[2] + return math.hypot(math.hypot(a, b), c) + + +@dataclass +class WirelessLink: + bridge1: str + bridge2: str + iface: CoreInterface + + +class WirelessNode(CoreNetworkBase): + def __init__( + self, + session: "Session", + _id: int, + name: str, + server: "DistributedServer" = None, + ): + super().__init__(session, _id, name, server) + self.bridges: Dict[int, Tuple[CoreInterface, str]] = {} + self.links: Dict[Tuple[int, int], WirelessLink] = {} + self.labels: Dict[Tuple[int, int], str] = {} + + def startup(self) -> None: + if self.up: + return + self.up = True + + def shutdown(self) -> None: + while self.bridges: + _, (_, bridge_name) = self.bridges.popitem() + self.net_client.delete_bridge(bridge_name) + self.host_cmd(f"{NFTABLES} delete table bridge {bridge_name}") + while self.links: + _, link = self.links.popitem() + link.iface.shutdown() + self.up = False + + def attach(self, iface: CoreInterface) -> None: + super().attach(iface) + logging.info("attaching node(%s) iface(%s)", iface.node.name, iface.name) + if self.up: + # create node unique bridge + bridge_name = f"wb{iface.node.id}.{self.id}.{self.session.id}" + self.net_client.create_bridge(bridge_name) + # setup initial bridge rules + self.host_cmd(f'{NFTABLES} "add table bridge {bridge_name}"') + self.host_cmd( + f"{NFTABLES} " + f"'add chain bridge {bridge_name} forward {{type filter hook " + f"forward priority -1; policy drop;}}'" + ) + self.host_cmd( + f"{NFTABLES} " + f"'add rule bridge {bridge_name} forward " + f"ibriport != {bridge_name} accept'" + ) + # associate node iface with bridge + iface.net_client.set_iface_master(bridge_name, iface.localname) + # assign position callback + iface.poshook = self.position_callback + # save created bridge + self.bridges[iface.node.id] = (iface, bridge_name) + + def post_startup(self) -> None: + routes = {} + for node_id, (iface, bridge_name) in self.bridges.items(): + for onode_id, (oiface, obridge_name) in self.bridges.items(): + if node_id == onode_id: + continue + if node_id < onode_id: + node1, node2 = iface.node, oiface.node + bridge1, bridge2 = bridge_name, obridge_name + else: + node1, node2 = oiface.node, iface.node + bridge1, bridge2 = obridge_name, bridge_name + key = (node1.id, node2.id) + if key in self.links: + continue + # create node to node link + session_id = self.session.short_session_id() + name1 = f"we{self.id}.{node1.id}.{node2.id}.{session_id}" + name2 = f"we{self.id}.{node2.id}.{node1.id}.{session_id}" + link_iface = CoreInterface(0, name1, name2, self.session.use_ovs()) + link_iface.startup() + link = WirelessLink(bridge1, bridge2, link_iface) + self.links[key] = link + # assign ifaces to respective bridges + self.net_client.set_iface_master(bridge1, link_iface.name) + self.net_client.set_iface_master(bridge2, link_iface.localname) + # track bridge routes + node1_routes = routes.setdefault(node1.id, set()) + node1_routes.add(name1) + node2_routes = routes.setdefault(node2.id, set()) + node2_routes.add(name2) + # send link + self.send_link(node1.id, node2.id, MessageFlags.ADD) + for node_id, ifaces in routes.items(): + iface, bridge_name = self.bridges[node_id] + ifaces = ",".join(ifaces) + # out routes + self.host_cmd( + f"{NFTABLES} " + f'"add rule bridge {bridge_name} forward ' + f"iif {iface.localname} oif {{{ifaces}}} " + f'accept"' + ) + # in routes + self.host_cmd( + f"{NFTABLES} " + f'"add rule bridge {bridge_name} forward ' + f"iif {{{ifaces}}} oif {iface.localname} " + f'accept"' + ) + + def link_control(self, node1_id: int, node2_id: int, linked: bool) -> None: + key = (node1_id, node2_id) if node1_id < node2_id else (node2_id, node1_id) + link = self.links.get(key) + if not link: + raise CoreError(f"invalid node links node1({node1_id}) node2({node2_id})") + bridge1, bridge2 = link.bridge1, link.bridge2 + iface = link.iface + if linked: + self.net_client.set_iface_master(bridge1, iface.name) + self.net_client.set_iface_master(bridge2, iface.localname) + message_type = MessageFlags.ADD + else: + self.net_client.delete_iface(bridge1, iface.name) + self.net_client.delete_iface(bridge2, iface.localname) + message_type = MessageFlags.DELETE + label = self.labels.get(key) + self.send_link(key[0], key[1], message_type, label) + + def link_config( + self, node1_id: int, node2_id: int, options1: LinkOptions, options2: LinkOptions + ) -> None: + key = (node1_id, node2_id) if node1_id < node2_id else (node2_id, node1_id) + link = self.links.get(key) + if not link: + raise CoreError(f"invalid node links node1({node1_id}) node2({node2_id})") + iface = link.iface + iface.options.update(options1) + iface.set_config() + name, localname = iface.name, iface.localname + iface.name, iface.localname = localname, name + iface.options.update(options2) + iface.set_config() + iface.name, iface.localname = name, localname + if options1 == options2: + if options1.is_clear(): + label = "" + else: + label = f"{options1.loss:.2f}%/{options1.delay}us" + else: + label = ( + f"({options1.loss:.2f}%/{options1.delay}us) " + f"({options2.loss:.2f}%/{options2.delay}us)" + ) + self.labels[key] = label + self.send_link(key[0], key[1], MessageFlags.NONE, label) + + def send_link( + self, + node1_id: int, + node2_id: int, + message_type: MessageFlags, + label: str = None, + ) -> None: + """ + Broadcasts out a wireless link/unlink message. + + :param node1_id: first node in link + :param node2_id: second node in link + :param message_type: type of link message to send + :param label: label to display for link + :return: nothing + """ + color = self.session.get_link_color(self.id) + link_data = LinkData( + message_type=message_type, + type=LinkTypes.WIRELESS, + node1_id=node1_id, + node2_id=node2_id, + network_id=self.id, + color=color, + label=label, + ) + self.session.broadcast_link(link_data) + + def position_callback(self, iface: CoreInterface) -> None: + for oiface, bridge_name in self.bridges.values(): + if iface == oiface: + continue + point1 = iface.node.position.get() + point2 = oiface.node.position.get() + distance = calc_distance(point1, point2) - 250 + distance = max(distance, 0.0) + logger.info( + "n1(%s) n2(%s) d(%s)", iface.node.name, oiface.node.name, distance + ) + loss = min((distance / 500) * 100.0, 100.0) + node1_id = iface.node.id + node2_id = oiface.node.id + options = LinkOptions(loss=loss, delay=0) + self.link_config(node1_id, node2_id, options, options) + + def adopt_iface(self, iface: CoreInterface, name: str) -> None: + raise CoreError(f"{type(self)} does not support adopt interface") diff --git a/daemon/core/plugins/sdt.py b/daemon/core/plugins/sdt.py index 575f9257..0300a3b0 100644 --- a/daemon/core/plugins/sdt.py +++ b/daemon/core/plugins/sdt.py @@ -4,7 +4,7 @@ sdt.py: Scripted Display Tool (SDT3D) helper import logging import socket -from typing import IO, TYPE_CHECKING, Dict, List, Optional, Set, Tuple +from typing import TYPE_CHECKING, Dict, List, Optional, Set, Tuple from urllib.parse import urlparse from core.constants import CORE_CONF_DIR, CORE_DATA_DIR @@ -12,22 +12,15 @@ from core.emane.nodes import EmaneNet from core.emulator.data import LinkData, NodeData from core.emulator.enumerations import EventTypes, MessageFlags from core.errors import CoreError -from core.nodes.base import CoreNetworkBase, NodeBase +from core.nodes.base import NodeBase from core.nodes.network import WlanNode +from core.nodes.wireless import WirelessNode logger = logging.getLogger(__name__) if TYPE_CHECKING: from core.emulator.session import Session - -def get_link_id(node1_id: int, node2_id: int, network_id: int) -> str: - link_id = f"{node1_id}-{node2_id}" - if network_id is not None: - link_id = f"{link_id}-{network_id}" - return link_id - - CORE_LAYER: str = "CORE" NODE_LAYER: str = "CORE::Nodes" LINK_LAYER: str = "CORE::Links" @@ -36,6 +29,17 @@ CORE_LAYERS: List[str] = [CORE_LAYER, LINK_LAYER, NODE_LAYER, WIRED_LINK_LAYER] DEFAULT_LINK_COLOR: str = "red" +def is_wireless(node: NodeBase) -> bool: + return isinstance(node, (WlanNode, EmaneNet, WirelessNode)) + + +def get_link_id(node1_id: int, node2_id: int, network_id: int) -> str: + link_id = f"{node1_id}-{node2_id}" + if network_id is not None: + link_id = f"{link_id}-{network_id}" + return link_id + + class Sdt: """ Helper class for exporting session objects to NRL"s SDT3D. @@ -67,7 +71,7 @@ class Sdt: :param session: session this manager is tied to """ self.session: "Session" = session - self.sock: Optional[IO] = None + self.sock: Optional[socket.socket] = None self.connected: bool = False self.url: str = self.DEFAULT_SDT_URL self.address: Optional[Tuple[Optional[str], Optional[int]]] = None @@ -210,26 +214,23 @@ class Sdt: :return: nothing """ - nets = [] - # create layers for layer in CORE_LAYERS: self.cmd(f"layer {layer}") - with self.session.nodes_lock: - for node_id in self.session.nodes: - node = self.session.nodes[node_id] - if isinstance(node, CoreNetworkBase): + nets = [] + for node in self.session.nodes.values(): + if isinstance(node, (EmaneNet, WlanNode)): nets.append(node) if not isinstance(node, NodeBase): continue self.add_node(node) - + for link in self.session.link_manager.links(): + if is_wireless(link.node1) or is_wireless(link.node2): + continue + link_data = link.get_data(MessageFlags.ADD) + self.handle_link_update(link_data) for net in nets: - all_links = net.links(flags=MessageFlags.ADD) - for link_data in all_links: - is_wireless = isinstance(net, (WlanNode, EmaneNet)) - if is_wireless and link_data.node1_id == net.id: - continue + for link_data in net.links(MessageFlags.ADD): self.handle_link_update(link_data) def get_node_position(self, node: NodeBase) -> Optional[str]: @@ -341,7 +342,7 @@ class Sdt: result = False try: node = self.session.get_node(node_id, NodeBase) - result = isinstance(node, (WlanNode, EmaneNet)) + result = isinstance(node, (WlanNode, EmaneNet, WirelessNode)) except CoreError: pass return result diff --git a/daemon/core/services/coreservices.py b/daemon/core/services/coreservices.py index 8d611d4b..f77a2136 100644 --- a/daemon/core/services/coreservices.py +++ b/daemon/core/services/coreservices.py @@ -109,114 +109,6 @@ class ServiceDependencies: return self.boot_paths -class ServiceShim: - keys: List[str] = [ - "dirs", - "files", - "startidx", - "cmdup", - "cmddown", - "cmdval", - "meta", - "starttime", - ] - - @classmethod - def tovaluelist(cls, node: CoreNode, service: "CoreService") -> str: - """ - Convert service properties into a string list of key=value pairs, - separated by "|". - - :param node: node to get value list for - :param service: service to get value list for - :return: value list string - """ - start_time = 0 - start_index = 0 - valmap = [ - service.dirs, - service.configs, - start_index, - service.startup, - service.shutdown, - service.validate, - service.meta, - start_time, - ] - if not service.custom: - valmap[1] = service.get_configs(node) - valmap[3] = service.get_startup(node) - vals = ["%s=%s" % (x, y) for x, y in zip(cls.keys, valmap)] - return "|".join(vals) - - @classmethod - def fromvaluelist(cls, service: "CoreService", values: List[str]) -> None: - """ - Convert list of values into properties for this instantiated - (customized) service. - - :param service: service to get value list for - :param values: value list to set properties from - :return: nothing - """ - # TODO: support empty value? e.g. override default meta with '' - for key in cls.keys: - try: - cls.setvalue(service, key, values[cls.keys.index(key)]) - except IndexError: - # old config does not need to have new keys - logger.exception("error indexing into key") - - @classmethod - def setvalue(cls, service: "CoreService", key: str, value: str) -> None: - """ - Set values for this service. - - :param service: service to get value list for - :param key: key to set value for - :param value: value of key to set - :return: nothing - """ - if key not in cls.keys: - raise ValueError("key `%s` not in `%s`" % (key, cls.keys)) - # this handles data conversion to int, string, and tuples - if value: - if key == "startidx": - value = int(value) - elif key == "starttime": - value = float(value) - elif key == "meta": - value = str(value) - else: - value = utils.make_tuple_fromstr(value, str) - - if key == "dirs": - service.dirs = value - elif key == "files": - service.configs = value - elif key == "cmdup": - service.startup = value - elif key == "cmddown": - service.shutdown = value - elif key == "cmdval": - service.validate = value - elif key == "meta": - service.meta = value - - @classmethod - def servicesfromopaque(cls, opaque: str) -> List[str]: - """ - Build a list of services from an opaque data string. - - :param opaque: opaque data string - :return: services - """ - servicesstring = opaque.split(":") - if servicesstring[0] != "service": - return [] - return servicesstring[1].split(",") - - class ServiceManager: """ Manages services available for CORE nodes to use. diff --git a/daemon/core/services/frr.py b/daemon/core/services/frr.py index 9029daec..07b1cfa5 100644 --- a/daemon/core/services/frr.py +++ b/daemon/core/services/frr.py @@ -7,15 +7,26 @@ from typing import Optional, Tuple import netaddr from core.emane.nodes import EmaneNet -from core.nodes.base import CoreNode +from core.nodes.base import CoreNode, NodeBase from core.nodes.interface import DEFAULT_MTU, CoreInterface from core.nodes.network import PtpNet, WlanNode from core.nodes.physical import Rj45Node +from core.nodes.wireless import WirelessNode from core.services.coreservices import CoreService FRR_STATE_DIR: str = "/var/run/frr" +def is_wireless(node: NodeBase) -> bool: + """ + Check if the node is a wireless type node. + + :param node: node to check type for + :return: True if wireless type, False otherwise + """ + return isinstance(node, (WlanNode, EmaneNet, WirelessNode)) + + class FRRZebra(CoreService): name: str = "FRRzebra" group: str = "FRR" @@ -593,7 +604,7 @@ class FRRBabel(FrrService): @classmethod def generate_frr_iface_config(cls, node: CoreNode, iface: CoreInterface) -> str: - if iface.net and isinstance(iface.net, (EmaneNet, WlanNode)): + if is_wireless(iface.net): return " babel wireless\n no babel split-horizon\n" else: return " babel wired\n babel split-horizon\n" diff --git a/daemon/core/services/quagga.py b/daemon/core/services/quagga.py index fa71feee..51668bc9 100644 --- a/daemon/core/services/quagga.py +++ b/daemon/core/services/quagga.py @@ -7,15 +7,26 @@ import netaddr from core.emane.nodes import EmaneNet from core.emulator.enumerations import LinkTypes -from core.nodes.base import CoreNode +from core.nodes.base import CoreNode, NodeBase from core.nodes.interface import DEFAULT_MTU, CoreInterface from core.nodes.network import PtpNet, WlanNode from core.nodes.physical import Rj45Node +from core.nodes.wireless import WirelessNode from core.services.coreservices import CoreService QUAGGA_STATE_DIR: str = "/var/run/quagga" +def is_wireless(node: NodeBase) -> bool: + """ + Check if the node is a wireless type node. + + :param node: node to check type for + :return: True if wireless type, False otherwise + """ + return isinstance(node, (WlanNode, EmaneNet, WirelessNode)) + + class Zebra(CoreService): name: str = "zebra" group: str = "Quagga" @@ -431,7 +442,7 @@ class Ospfv3mdr(Ospfv3): @classmethod def generate_quagga_iface_config(cls, node: CoreNode, iface: CoreInterface) -> str: cfg = cls.mtu_check(iface) - if iface.net is not None and isinstance(iface.net, (WlanNode, EmaneNet)): + if is_wireless(iface.net): return ( cfg + """\ diff --git a/daemon/core/xml/corexml.py b/daemon/core/xml/corexml.py index 647300fc..57d42187 100644 --- a/daemon/core/xml/corexml.py +++ b/daemon/core/xml/corexml.py @@ -1,6 +1,6 @@ import logging from pathlib import Path -from typing import TYPE_CHECKING, Any, Dict, Generic, List, Optional, Type, TypeVar +from typing import TYPE_CHECKING, Any, Dict, Generic, Optional, Type, TypeVar from lxml import etree @@ -8,13 +8,15 @@ import core.nodes.base import core.nodes.physical from core import utils from core.emane.nodes import EmaneNet -from core.emulator.data import InterfaceData, LinkData, LinkOptions, NodeOptions +from core.emulator.data import InterfaceData, LinkOptions, NodeOptions from core.emulator.enumerations import EventTypes, NodeTypes from core.errors import CoreXmlError from core.nodes.base import CoreNodeBase, NodeBase from core.nodes.docker import DockerNode +from core.nodes.interface import CoreInterface from core.nodes.lxd import LxcNode from core.nodes.network import CtrlNet, GreTapBridge, WlanNode +from core.nodes.wireless import WirelessNode from core.services.coreservices import CoreService logger = logging.getLogger(__name__) @@ -269,8 +271,8 @@ class CoreXmlWriter: def write_session(self) -> None: # generate xml content - links = self.write_nodes() - self.write_links(links) + self.write_nodes() + self.write_links() self.write_mobility_configs() self.write_emane_configs() self.write_service_configs() @@ -449,8 +451,7 @@ class CoreXmlWriter: if node_types.getchildren(): self.scenario.append(node_types) - def write_nodes(self) -> List[LinkData]: - links = [] + def write_nodes(self) -> None: for node_id in self.session.nodes: node = self.session.nodes[node_id] # network node @@ -464,10 +465,6 @@ class CoreXmlWriter: elif isinstance(node, core.nodes.base.CoreNodeBase): self.write_device(node) - # add known links - links.extend(node.links()) - return links - def write_network(self, node: NodeBase) -> None: # ignore p2p and other nodes that are not part of the api if not node.apitype: @@ -476,15 +473,21 @@ class CoreXmlWriter: network = NetworkElement(self.session, node) self.networks.append(network.element) - def write_links(self, links: List[LinkData]) -> None: + def write_links(self) -> None: link_elements = etree.Element("links") - # add link data - for link_data in links: - # skip basic range links - if link_data.iface1 is None and link_data.iface2 is None: - continue - link_element = self.create_link_element(link_data) + for core_link in self.session.link_manager.links(): + node1, iface1 = core_link.node1, core_link.iface1 + node2, iface2 = core_link.node2, core_link.iface2 + unidirectional = core_link.is_unidirectional() + link_element = self.create_link_element( + node1, iface1, node2, iface2, core_link.options(), unidirectional + ) link_elements.append(link_element) + if unidirectional: + link_element = self.create_link_element( + node2, iface2, node1, iface1, iface2.options, unidirectional + ) + link_elements.append(link_element) if link_elements.getchildren(): self.scenario.append(link_elements) @@ -493,67 +496,71 @@ class CoreXmlWriter: self.devices.append(device.element) def create_iface_element( - self, element_name: str, node_id: int, iface_data: InterfaceData + self, element_name: str, iface: CoreInterface ) -> etree.Element: iface_element = etree.Element(element_name) - node = self.session.get_node(node_id, NodeBase) - if isinstance(node, CoreNodeBase): - iface = node.get_iface(iface_data.id) - # check if emane interface - if isinstance(iface.net, EmaneNet): - nem_id = self.session.emane.get_nem_id(iface) - add_attribute(iface_element, "nem", nem_id) - add_attribute(iface_element, "id", iface_data.id) - add_attribute(iface_element, "name", iface_data.name) - add_attribute(iface_element, "mac", iface_data.mac) - add_attribute(iface_element, "ip4", iface_data.ip4) - add_attribute(iface_element, "ip4_mask", iface_data.ip4_mask) - add_attribute(iface_element, "ip6", iface_data.ip6) - add_attribute(iface_element, "ip6_mask", iface_data.ip6_mask) + # check if interface if connected to emane + if isinstance(iface.node, CoreNodeBase) and isinstance(iface.net, EmaneNet): + nem_id = self.session.emane.get_nem_id(iface) + add_attribute(iface_element, "nem", nem_id) + ip4 = iface.get_ip4() + ip4_mask = None + if ip4: + ip4_mask = ip4.prefixlen + ip4 = str(ip4.ip) + ip6 = iface.get_ip6() + ip6_mask = None + if ip6: + ip6_mask = ip6.prefixlen + ip6 = str(ip6.ip) + add_attribute(iface_element, "id", iface.id) + add_attribute(iface_element, "name", iface.name) + add_attribute(iface_element, "mac", iface.mac) + add_attribute(iface_element, "ip4", ip4) + add_attribute(iface_element, "ip4_mask", ip4_mask) + add_attribute(iface_element, "ip6", ip6) + add_attribute(iface_element, "ip6_mask", ip6_mask) return iface_element - def create_link_element(self, link_data: LinkData) -> etree.Element: + def create_link_element( + self, + node1: NodeBase, + iface1: Optional[CoreInterface], + node2: NodeBase, + iface2: Optional[CoreInterface], + options: LinkOptions, + unidirectional: bool, + ) -> etree.Element: link_element = etree.Element("link") - add_attribute(link_element, "node1", link_data.node1_id) - add_attribute(link_element, "node2", link_data.node2_id) - + add_attribute(link_element, "node1", node1.id) + add_attribute(link_element, "node2", node2.id) # check for interface one - if link_data.iface1 is not None: - iface1 = self.create_iface_element( - "iface1", link_data.node1_id, link_data.iface1 - ) + if iface1 is not None: + iface1 = self.create_iface_element("iface1", iface1) link_element.append(iface1) - # check for interface two - if link_data.iface2 is not None: - iface2 = self.create_iface_element( - "iface2", link_data.node2_id, link_data.iface2 - ) + if iface2 is not None: + iface2 = self.create_iface_element("iface2", iface2) link_element.append(iface2) - # check for options, don't write for emane/wlan links - node1 = self.session.get_node(link_data.node1_id, NodeBase) - node2 = self.session.get_node(link_data.node2_id, NodeBase) - is_node1_wireless = isinstance(node1, (WlanNode, EmaneNet)) - is_node2_wireless = isinstance(node2, (WlanNode, EmaneNet)) - if not any([is_node1_wireless, is_node2_wireless]): - options_data = link_data.options - options = etree.Element("options") - add_attribute(options, "delay", options_data.delay) - add_attribute(options, "bandwidth", options_data.bandwidth) - add_attribute(options, "loss", options_data.loss) - add_attribute(options, "dup", options_data.dup) - add_attribute(options, "jitter", options_data.jitter) - add_attribute(options, "mer", options_data.mer) - add_attribute(options, "burst", options_data.burst) - add_attribute(options, "mburst", options_data.mburst) - add_attribute(options, "unidirectional", options_data.unidirectional) - add_attribute(options, "network_id", link_data.network_id) - add_attribute(options, "key", options_data.key) - add_attribute(options, "buffer", options_data.buffer) - if options.items(): - link_element.append(options) - + is_node1_wireless = isinstance(node1, (WlanNode, EmaneNet, WirelessNode)) + is_node2_wireless = isinstance(node2, (WlanNode, EmaneNet, WirelessNode)) + if not (is_node1_wireless or is_node2_wireless): + unidirectional = 1 if unidirectional else 0 + options_element = etree.Element("options") + add_attribute(options_element, "delay", options.delay) + add_attribute(options_element, "bandwidth", options.bandwidth) + add_attribute(options_element, "loss", options.loss) + add_attribute(options_element, "dup", options.dup) + add_attribute(options_element, "jitter", options.jitter) + add_attribute(options_element, "mer", options.mer) + add_attribute(options_element, "burst", options.burst) + add_attribute(options_element, "mburst", options.mburst) + add_attribute(options_element, "unidirectional", unidirectional) + add_attribute(options_element, "key", options.key) + add_attribute(options_element, "buffer", options.buffer) + if options_element.items(): + link_element.append(options_element) return link_element diff --git a/daemon/data/core.conf b/daemon/data/core.conf index 20ee5d1f..874ba567 100644 --- a/daemon/data/core.conf +++ b/daemon/data/core.conf @@ -1,7 +1,5 @@ [core-daemon] #distributed_address = 127.0.0.1 -listenaddr = localhost -port = 4038 grpcaddress = localhost grpcport = 50051 quagga_bin_search = "/usr/local/bin /usr/bin /usr/lib/quagga" @@ -12,8 +10,8 @@ frr_sbin_search = "/usr/local/sbin /usr/sbin /usr/lib/frr" # uncomment the following line to load custom services from the specified dir # this may be a comma-separated list, and directory names should be unique # and not named 'services' -#custom_services_dir = /home/username/.core/myservices -#custom_config_services_dir = /home/username/.coregui/custom_services +#custom_services_dir = /home//.coregui/custom_services +#custom_config_services_dir = /home//.coregui/custom_services # uncomment to establish a standalone control backchannel for accessing nodes # (overriden by the session option of the same name) @@ -48,7 +46,7 @@ emane_platform_port = 8101 emane_transform_port = 8201 emane_event_generate = True emane_event_monitor = False -#emane_models_dir = /home/username/.core/myemane +#emane_models_dir = /home//.coregui/custom_emane # EMANE log level range [0,4] default: 2 #emane_log_level = 2 emane_realtime = True diff --git a/daemon/doc/Makefile.am b/daemon/doc/Makefile.am index e46f7d32..9ce90bfa 100644 --- a/daemon/doc/Makefile.am +++ b/daemon/doc/Makefile.am @@ -1,8 +1,4 @@ # CORE -# (c)2012 the Boeing Company. -# See the LICENSE file included in this distribution. -# -# author: Jeff Ahrenholz # # Builds html and pdf documentation using Sphinx. # diff --git a/daemon/examples/grpc/wireless.py b/daemon/examples/grpc/wireless.py new file mode 100644 index 00000000..b196d748 --- /dev/null +++ b/daemon/examples/grpc/wireless.py @@ -0,0 +1,29 @@ +from core.api.grpc import client +from core.api.grpc.wrappers import NodeType, Position + +# interface helper +iface_helper = client.InterfaceHelper(ip4_prefix="10.0.0.0/24", ip6_prefix="2001::/64") + +# create grpc client and connect +core = client.CoreGrpcClient() +core.connect() + +# add session +session = core.create_session() + +# create nodes +position = Position(x=200, y=200) +wlan = session.add_node(1, _type=NodeType.WIRELESS, position=position) +position = Position(x=100, y=100) +node1 = session.add_node(2, model="mdr", position=position) +position = Position(x=300, y=100) +node2 = session.add_node(3, model="mdr", position=position) + +# create links +iface1 = iface_helper.create_iface(node1.id, 0) +session.add_link(node1=node1, node2=wlan, iface1=iface1) +iface1 = iface_helper.create_iface(node2.id, 0) +session.add_link(node1=node2, node2=wlan, iface1=iface1) + +# start session +core.start_session(session) diff --git a/daemon/examples/python/wireless.py b/daemon/examples/python/wireless.py new file mode 100644 index 00000000..559cf2f8 --- /dev/null +++ b/daemon/examples/python/wireless.py @@ -0,0 +1,46 @@ +# required imports +import logging + +from core.emulator.coreemu import CoreEmu +from core.emulator.data import IpPrefixes, NodeOptions +from core.emulator.enumerations import EventTypes +from core.nodes.base import CoreNode +from core.nodes.network import WlanNode + +# enable info logging +logging.basicConfig(level=logging.INFO) + +# ip nerator for example +ip_prefixes = IpPrefixes(ip4_prefix="10.0.0.0/24") + +# create emulator instance for creating sessions and utility methods +coreemu = CoreEmu() +session = coreemu.create_session() + +# must be in configuration state for nodes to start +session.set_state(EventTypes.CONFIGURATION_STATE) + +# create wireless +options = NodeOptions(x=200, y=200) +wireless = session.add_node(WlanNode, options=options) + +# create nodes +options = NodeOptions(model="mdr", x=100, y=100) +n1 = session.add_node(CoreNode, options=options) +options = NodeOptions(model="mdr", x=300, y=100) +n2 = session.add_node(CoreNode, options=options) + +# link nodes to wireless +iface1 = ip_prefixes.create_iface(n1) +session.add_link(n1.id, wireless.id, iface1) +iface1 = ip_prefixes.create_iface(n2) +session.add_link(n2.id, wireless.id, iface1) + +# start session +session.instantiate() + +# do whatever you like here +input("press enter to shutdown") + +# stop session +session.shutdown() diff --git a/daemon/proto/core/api/grpc/core.proto b/daemon/proto/core/api/grpc/core.proto index f0cb242d..f17b61fe 100644 --- a/daemon/proto/core/api/grpc/core.proto +++ b/daemon/proto/core/api/grpc/core.proto @@ -61,6 +61,8 @@ service CoreApi { } rpc DeleteLink (DeleteLinkRequest) returns (DeleteLinkResponse) { } + rpc Linked (LinkedRequest) returns (LinkedResponse) { + } // mobility rpc rpc GetMobilityConfig (mobility.GetMobilityConfigRequest) returns (mobility.GetMobilityConfigResponse) { @@ -98,6 +100,12 @@ service CoreApi { rpc WlanLink (wlan.WlanLinkRequest) returns (wlan.WlanLinkResponse) { } + // wireless rpc + rpc WirelessLinked (WirelessLinkedRequest) returns (WirelessLinkedResponse) { + } + rpc WirelessConfig (WirelessConfigRequest) returns (WirelessConfigResponse) { + } + // emane rpc rpc GetEmaneModelConfig (emane.GetEmaneModelConfigRequest) returns (emane.GetEmaneModelConfigResponse) { } @@ -280,12 +288,11 @@ message ConfigEvent { repeated int32 data_types = 5; string data_values = 6; string captions = 7; - string bitmap = 8; - string possible_values = 9; - string groups = 10; - int32 iface_id = 11; - int32 network_id = 12; - string opaque = 13; + string possible_values = 8; + string groups = 9; + int32 iface_id = 10; + int32 network_id = 11; + string opaque = 12; } message ExceptionEvent { @@ -684,3 +691,38 @@ message Server { string name = 1; string host = 2; } + +message LinkedRequest { + int32 session_id = 1; + int32 node1_id = 2; + int32 node2_id = 3; + int32 iface1_id = 4; + int32 iface2_id = 5; + bool linked = 6; +} + +message LinkedResponse { +} + +message WirelessLinkedRequest { + int32 session_id = 1; + int32 wireless_id = 2; + int32 node1_id = 3; + int32 node2_id = 4; + bool linked = 5; +} + +message WirelessLinkedResponse { +} + +message WirelessConfigRequest { + int32 session_id = 1; + int32 wireless_id = 2; + int32 node1_id = 3; + int32 node2_id = 4; + LinkOptions options1 = 5; + LinkOptions options2 = 6; +} + +message WirelessConfigResponse { +} diff --git a/daemon/pyproject.toml b/daemon/pyproject.toml index a92cc994..9e11d3f6 100644 --- a/daemon/pyproject.toml +++ b/daemon/pyproject.toml @@ -1,6 +1,6 @@ [tool.poetry] name = "core" -version = "8.1.0" +version = "8.2.0" description = "CORE Common Open Research Emulator" authors = ["Boeing Research and Technology"] license = "BSD-2-Clause" diff --git a/daemon/scripts/core-cli b/daemon/scripts/core-cli index fbbe6ede..6f2c1f5b 100755 --- a/daemon/scripts/core-cli +++ b/daemon/scripts/core-cli @@ -1,22 +1,24 @@ #!/usr/bin/env python3 +import json import sys from argparse import ( ArgumentDefaultsHelpFormatter, ArgumentParser, ArgumentTypeError, Namespace, - _SubParsersAction, ) from functools import wraps from pathlib import Path -from typing import Optional, Tuple +from typing import Any, Dict, Optional, Tuple import grpc import netaddr +from google.protobuf.json_format import MessageToDict from netaddr import EUI, AddrFormatError, IPNetwork from core.api.grpc.client import CoreGrpcClient from core.api.grpc.wrappers import ( + ConfigOption, Geo, Interface, Link, @@ -29,6 +31,15 @@ from core.api.grpc.wrappers import ( NODE_TYPES = [x for x in NodeType if x != NodeType.PEER_TO_PEER] +def protobuf_to_json(message: Any) -> Dict[str, Any]: + return MessageToDict(message, including_default_value_fields=True, preserving_proto_field_name=True) + + +def print_json(data: Any) -> None: + data = json.dumps(data, indent=2) + print(data) + + def coreclient(func): @wraps(func) def wrapper(*args, **kwargs): @@ -94,11 +105,11 @@ def geo_type(value: str) -> Tuple[float, float, float]: return lon, lat, alt -def file_type(value: str) -> str: +def file_type(value: str) -> Path: path = Path(value) if not path.is_file(): raise ArgumentTypeError(f"invalid file: {value}") - return str(path.absolute()) + return path def get_current_session(core: CoreGrpcClient, session_id: Optional[int]) -> int: @@ -140,12 +151,15 @@ def print_iface(iface: Interface) -> None: def get_wlan_config(core: CoreGrpcClient, args: Namespace) -> None: session_id = get_current_session(core, args.session) config = core.get_wlan_config(session_id, args.node) - size = 0 - for option in config.values(): - size = max(size, len(option.name)) - print(f"{'Name':<{size}.{size}} | Value") - for option in config.values(): - print(f"{option.name:<{size}.{size}} | {option.value}") + if args.json: + print_json(ConfigOption.to_dict(config)) + else: + size = 0 + for option in config.values(): + size = max(size, len(option.name)) + print(f"{'Name':<{size}.{size}} | Value") + for option in config.values(): + print(f"{option.name:<{size}.{size}} | {option.value}") @coreclient @@ -163,80 +177,102 @@ def set_wlan_config(core: CoreGrpcClient, args: Namespace) -> None: if args.range: config["range"] = str(args.range) result = core.set_wlan_config(session_id, args.node, config) - print(f"set wlan config: {result}") + if args.json: + print_json(dict(result=result)) + else: + print(f"set wlan config: {result}") @coreclient def open_xml(core: CoreGrpcClient, args: Namespace) -> None: result, session_id = core.open_xml(args.file, args.start) - print(f"opened xml: {result},{session_id}") + if args.json: + print_json(dict(result=result, session_id=session_id)) + else: + print(f"opened xml: {result},{session_id}") @coreclient def query_sessions(core: CoreGrpcClient, args: Namespace) -> None: sessions = core.get_sessions() - print("Session ID | Session State | Nodes") - for session in sessions: - print(f"{session.id:<10} | {session.state.name:<13} | {session.nodes}") + if args.json: + sessions = [protobuf_to_json(x.to_proto()) for x in sessions] + print_json(sessions) + else: + print("Session ID | Session State | Nodes") + for session in sessions: + print(f"{session.id:<10} | {session.state.name:<13} | {session.nodes}") @coreclient def query_session(core: CoreGrpcClient, args: Namespace) -> None: session = core.get_session(args.id) - print("Nodes") - print("Node ID | Node Name | Node Type") - for node in session.nodes.values(): - print(f"{node.id:<7} | {node.name:<9} | {node.type.name}") - print("\nLinks") - for link in session.links: - n1 = session.nodes[link.node1_id].name - n2 = session.nodes[link.node2_id].name - print(f"Node | ", end="") - print_iface_header() - print(f"{n1:<6} | ", end="") - if link.iface1: - print_iface(link.iface1) - else: + if args.json: + session = protobuf_to_json(session.to_proto()) + print_json(session) + else: + print("Nodes") + print("ID | Name | Type | XY | Geo") + for node in session.nodes.values(): + xy_pos = f"{int(node.position.x)},{int(node.position.y)}" + geo_pos = f"{node.geo.lon:.7f},{node.geo.lat:.7f},{node.geo.alt:f}" + print(f"{node.id:<7} | {node.name[:7]:<7} | {node.type.name[:7]:<7} | {xy_pos:<9} | {geo_pos}") + print("\nLinks") + for link in session.links: + n1 = session.nodes[link.node1_id].name + n2 = session.nodes[link.node2_id].name + print(f"Node | ", end="") + print_iface_header() + print(f"{n1:<6} | ", end="") + if link.iface1: + print_iface(link.iface1) + else: + print() + print(f"{n2:<6} | ", end="") + if link.iface2: + print_iface(link.iface2) + else: + print() print() - print(f"{n2:<6} | ", end="") - if link.iface2: - print_iface(link.iface2) - else: - print() - print() @coreclient def query_node(core: CoreGrpcClient, args: Namespace) -> None: session = core.get_session(args.id) node, ifaces, _ = core.get_node(args.id, args.node) - print("ID | Name | Type | XY") - xy_pos = f"{int(node.position.x)},{int(node.position.y)}" - print(f"{node.id:<4} | {node.name[:7]:<7} | {node.type.name[:7]:<7} | {xy_pos}") - if node.geo: - print("Geo") - print(f"{node.geo.lon:.7f},{node.geo.lat:.7f},{node.geo.alt:f}") - if ifaces: - print("Interfaces") - print("Connected To | ", end="") - print_iface_header() - for iface in ifaces: - if iface.net_id == node.id: - if iface.node_id: - name = session.nodes[iface.node_id].name + if args.json: + node = protobuf_to_json(node.to_proto()) + ifaces = [protobuf_to_json(x.to_proto()) for x in ifaces] + print_json(dict(node=node, ifaces=ifaces)) + else: + print("ID | Name | Type | XY | Geo") + xy_pos = f"{int(node.position.x)},{int(node.position.y)}" + geo_pos = f"{node.geo.lon:.7f},{node.geo.lat:.7f},{node.geo.alt:f}" + print(f"{node.id:<7} | {node.name[:7]:<7} | {node.type.name[:7]:<7} | {xy_pos:<9} | {geo_pos}") + if ifaces: + print("Interfaces") + print("Connected To | ", end="") + print_iface_header() + for iface in ifaces: + if iface.net_id == node.id: + if iface.node_id: + name = session.nodes[iface.node_id].name + else: + name = session.nodes[iface.net2_id].name else: - name = session.nodes[iface.net2_id].name - else: - net_node = session.nodes.get(iface.net_id) - name = net_node.name if net_node else "" - print(f"{name:<12} | ", end="") - print_iface(iface) + net_node = session.nodes.get(iface.net_id) + name = net_node.name if net_node else "" + print(f"{name:<12} | ", end="") + print_iface(iface) @coreclient def delete_session(core: CoreGrpcClient, args: Namespace) -> None: result = core.delete_session(args.id) - print(f"delete session({args.id}): {result}") + if args.json: + print_json(dict(result=result)) + else: + print(f"delete session({args.id}): {result}") @coreclient @@ -263,14 +299,20 @@ def add_node(core: CoreGrpcClient, args: Namespace) -> None: geo=geo, ) node_id = core.add_node(session_id, node) - print(f"created node: {node_id}") + if args.json: + print_json(dict(node_id=node_id)) + else: + print(f"created node: {node_id}") @coreclient def edit_node(core: CoreGrpcClient, args: Namespace) -> None: session_id = get_current_session(core, args.session) result = core.edit_node(session_id, args.id, args.icon) - print(f"edit node: {result}") + if args.json: + print_json(dict(result=result)) + else: + print(f"edit node: {result}") @coreclient @@ -285,14 +327,20 @@ def move_node(core: CoreGrpcClient, args: Namespace) -> None: lon, lat, alt = args.geo geo = Geo(lon=lon, lat=lat, alt=alt) result = core.move_node(session_id, args.id, pos, geo) - print(f"move node: {result}") + if args.json: + print_json(dict(result=result)) + else: + print(f"move node: {result}") @coreclient def delete_node(core: CoreGrpcClient, args: Namespace) -> None: session_id = get_current_session(core, args.session) result = core.delete_node(session_id, args.id) - print(f"deleted node: {result}") + if args.json: + print_json(dict(result=result)) + else: + print(f"deleted node: {result}") @coreclient @@ -313,8 +361,13 @@ def add_link(core: CoreGrpcClient, args: Namespace) -> None: unidirectional=args.uni, ) link = Link(args.node1, args.node2, iface1=iface1, iface2=iface2, options=options) - result, _, _ = core.add_link(session_id, link) - print(f"add link: {result}") + result, iface1, iface2 = core.add_link(session_id, link) + if args.json: + iface1 = protobuf_to_json(iface1.to_proto()) + iface2 = protobuf_to_json(iface2.to_proto()) + print_json(dict(result=result, iface1=iface1, iface2=iface2)) + else: + print(f"add link: {result}") @coreclient @@ -332,7 +385,10 @@ def edit_link(core: CoreGrpcClient, args: Namespace) -> None: iface2 = Interface(args.iface2) link = Link(args.node1, args.node2, iface1=iface1, iface2=iface2, options=options) result = core.edit_link(session_id, link) - print(f"edit link: {result}") + if args.json: + print_json(dict(result=result)) + else: + print(f"edit link: {result}") @coreclient @@ -342,10 +398,13 @@ def delete_link(core: CoreGrpcClient, args: Namespace) -> None: iface2 = Interface(args.iface2) link = Link(args.node1, args.node2, iface1=iface1, iface2=iface2) result = core.delete_link(session_id, link) - print(f"delete link: {result}") + if args.json: + print_json(dict(result=result)) + else: + print(f"delete link: {result}") -def setup_sessions_parser(parent: _SubParsersAction) -> None: +def setup_sessions_parser(parent) -> None: parser = parent.add_parser("session", help="session interactions") parser.formatter_class = ArgumentDefaultsHelpFormatter parser.add_argument("-i", "--id", type=int, help="session id to use", required=True) @@ -358,7 +417,7 @@ def setup_sessions_parser(parent: _SubParsersAction) -> None: delete_parser.set_defaults(func=delete_session) -def setup_node_parser(parent: _SubParsersAction) -> None: +def setup_node_parser(parent) -> None: parser = parent.add_parser("node", help="node interactions") parser.formatter_class = ArgumentDefaultsHelpFormatter parser.add_argument("-s", "--session", type=int, help="session to interact with") @@ -402,7 +461,7 @@ def setup_node_parser(parent: _SubParsersAction) -> None: delete_parser.set_defaults(func=delete_node) -def setup_link_parser(parent: _SubParsersAction) -> None: +def setup_link_parser(parent) -> None: parser = parent.add_parser("link", help="link interactions") parser.formatter_class = ArgumentDefaultsHelpFormatter parser.add_argument("-s", "--session", type=int, help="session to interact with") @@ -455,7 +514,7 @@ def setup_link_parser(parent: _SubParsersAction) -> None: delete_parser.set_defaults(func=delete_link) -def setup_query_parser(parent: _SubParsersAction) -> None: +def setup_query_parser(parent) -> None: parser = parent.add_parser("query", help="query interactions") subparsers = parser.add_subparsers(help="query commands") subparsers.required = True @@ -477,7 +536,7 @@ def setup_query_parser(parent: _SubParsersAction) -> None: node_parser.set_defaults(func=query_node) -def setup_xml_parser(parent: _SubParsersAction) -> None: +def setup_xml_parser(parent) -> None: parser = parent.add_parser("xml", help="open session xml") parser.formatter_class = ArgumentDefaultsHelpFormatter parser.add_argument("-f", "--file", type=file_type, help="xml file to open", required=True) @@ -485,7 +544,7 @@ def setup_xml_parser(parent: _SubParsersAction) -> None: parser.set_defaults(func=open_xml) -def setup_wlan_parser(parent: _SubParsersAction) -> None: +def setup_wlan_parser(parent) -> None: parser = parent.add_parser("wlan", help="wlan specific interactions") parser.formatter_class = ArgumentDefaultsHelpFormatter parser.add_argument("-s", "--session", type=int, help="session to interact with") @@ -511,6 +570,9 @@ def setup_wlan_parser(parent: _SubParsersAction) -> None: def main() -> None: parser = ArgumentParser(formatter_class=ArgumentDefaultsHelpFormatter) + parser.add_argument( + "-js", "--json", action="store_true", help="print responses to terminal as json" + ) subparsers = parser.add_subparsers(help="supported commands") subparsers.required = True subparsers.dest = "command" diff --git a/daemon/scripts/core-daemon b/daemon/scripts/core-daemon index 0ff4ca77..a2ae3343 100755 --- a/daemon/scripts/core-daemon +++ b/daemon/scripts/core-daemon @@ -8,19 +8,15 @@ message handlers are defined and some support for sending messages. import argparse import logging import os -import sys -import threading import time from configparser import ConfigParser from pathlib import Path from core import constants from core.api.grpc.server import CoreGrpcServer -from core.api.tlv.corehandlers import CoreHandler, CoreUdpHandler -from core.api.tlv.coreserver import CoreServer, CoreUdpServer -from core.api.tlv.enumerations import CORE_API_PORT from core.constants import CORE_CONF_DIR, COREDPY_VERSION -from core.utils import close_onexec, load_logging_config +from core.emulator.coreemu import CoreEmu +from core.utils import load_logging_config logger = logging.getLogger(__name__) @@ -34,20 +30,6 @@ def banner(): logger.info("CORE daemon v.%s started %s", constants.COREDPY_VERSION, time.ctime()) -def start_udp(mainserver, server_address): - """ - Start a thread running a UDP server on the same host,port for - connectionless requests. - - :param CoreServer mainserver: main core tcp server to piggy back off of - :param server_address: - :return: CoreUdpServer - """ - mainserver.udpserver = CoreUdpServer(server_address, CoreUdpHandler, mainserver) - mainserver.udpthread = threading.Thread(target=mainserver.udpserver.start, daemon=True) - mainserver.udpthread.start() - - def cored(cfg): """ Start the CoreServer object and enter the server loop. @@ -55,34 +37,13 @@ def cored(cfg): :param dict cfg: core configuration :return: nothing """ - host = cfg["listenaddr"] - port = int(cfg["port"]) - if host == "" or host is None: - host = "localhost" - - try: - address = (host, port) - server = CoreServer(address, CoreHandler, cfg) - except: - logger.exception("error starting main server on: %s:%s", host, port) - sys.exit(1) - # initialize grpc api - grpc_server = CoreGrpcServer(server.coreemu) + coreemu = CoreEmu(cfg) + grpc_server = CoreGrpcServer(coreemu) address_config = cfg["grpcaddress"] port_config = cfg["grpcport"] grpc_address = f"{address_config}:{port_config}" - grpc_thread = threading.Thread(target=grpc_server.listen, args=(grpc_address,), daemon=True) - grpc_thread.start() - - # start udp server - start_udp(server, address) - - # close handlers - close_onexec(server.fileno()) - - logger.info("CORE TLV API TCP/UDP listening on: %s:%s", host, port) - server.serve_forever() + grpc_server.listen(grpc_address) def get_merged_config(filename): @@ -98,49 +59,38 @@ def get_merged_config(filename): default_grpc_port = "50051" default_address = "localhost" defaults = { - "port": str(CORE_API_PORT), - "listenaddr": default_address, "grpcport": default_grpc_port, "grpcaddress": default_address, "logfile": default_log } - parser = argparse.ArgumentParser( description=f"CORE daemon v.{COREDPY_VERSION} instantiates Linux network namespace nodes.") parser.add_argument("-f", "--configfile", dest="configfile", help=f"read config from specified file; default = {filename}") - parser.add_argument("-p", "--port", dest="port", type=int, - help=f"port number to listen on; default = {CORE_API_PORT}") parser.add_argument("--ovs", action="store_true", help="enable experimental ovs mode, default is false") parser.add_argument("--grpc-port", dest="grpcport", help=f"grpc port to listen on; default {default_grpc_port}") parser.add_argument("--grpc-address", dest="grpcaddress", help=f"grpc address to listen on; default {default_address}") parser.add_argument("-l", "--logfile", help=f"core logging configuration; default {default_log}") - # parse command line options args = parser.parse_args() - # convert ovs to internal format args.ovs = "1" if args.ovs else "0" - # read the config file if args.configfile is not None: filename = args.configfile del args.configfile cfg = ConfigParser(defaults) cfg.read(filename) - section = "core-daemon" if not cfg.has_section(section): cfg.add_section(section) - # merge argparse with configparser for opt in vars(args): val = getattr(args, opt) if val is not None: cfg.set(section, opt, str(val)) - return dict(cfg.items(section)) diff --git a/daemon/scripts/core-imn-to-xml b/daemon/scripts/core-imn-to-xml deleted file mode 100755 index c11533a4..00000000 --- a/daemon/scripts/core-imn-to-xml +++ /dev/null @@ -1,70 +0,0 @@ -#!/usr/bin/env python3 -import argparse -import re -import sys -from pathlib import Path - -from core import utils -from core.api.grpc.client import CoreGrpcClient -from core.errors import CoreCommandError - -if __name__ == "__main__": - # parse flags - parser = argparse.ArgumentParser(description="Converts CORE imn files to xml") - parser.add_argument("-f", "--file", dest="file", help="imn file to convert") - parser.add_argument( - "-d", "--dest", dest="dest", default=None, help="destination for xml file, defaults to same location as imn" - ) - args = parser.parse_args() - - # validate provided file exists - imn_file = Path(args.file) - if not imn_file.exists(): - print(f"{args.file} does not exist") - sys.exit(1) - - # validate destination - if args.dest is not None: - dest = Path(args.dest) - if not dest.exists() or not dest.is_dir(): - print(f"{dest.resolve()} does not exist or is not a directory") - sys.exit(1) - xml_file = Path(dest, imn_file.with_suffix(".xml").name) - else: - xml_file = Path(imn_file.with_suffix(".xml").name) - - # validate xml file - if xml_file.exists(): - print(f"{xml_file.resolve()} already exists") - sys.exit(1) - - # run provided imn using core-gui batch mode - try: - print(f"running {imn_file.resolve()} in batch mode") - output = utils.cmd(f"core-gui --batch {imn_file.resolve()}") - last_line = output.split("\n")[-1].strip() - - # check for active session - if last_line == "Another session is active.": - print("need to restart core-daemon or shutdown previous batch session") - sys.exit(1) - - # parse session id - m = re.search(r"Session id is (\d+)\.", last_line) - if not m: - print(f"failed to find session id: {output}") - sys.exit(1) - session_id = int(m.group(1)) - print(f"created session {session_id}") - - # save xml and delete session - client = CoreGrpcClient() - with client.context_connect(): - print(f"saving xml {xml_file.resolve()}") - client.save_xml(session_id, str(xml_file)) - - print(f"deleting session {session_id}") - client.delete_session(session_id) - except CoreCommandError as e: - print(f"core-gui batch failed for {imn_file.resolve()}: {e}") - sys.exit(1) diff --git a/daemon/scripts/core-manage b/daemon/scripts/core-manage deleted file mode 100755 index 5587c9ae..00000000 --- a/daemon/scripts/core-manage +++ /dev/null @@ -1,247 +0,0 @@ -#!/usr/bin/env python3 -""" -core-manage: Helper tool to add, remove, or check for services, models, and -node types in a CORE installation. -""" - -import ast -import optparse -import os -import re -import sys - -from core import services -from core.constants import CORE_CONF_DIR - - -class FileUpdater: - """ - Helper class for changing configuration files. - """ - actions = ("add", "remove", "check") - targets = ("service", "model", "nodetype") - - def __init__(self, action, target, data, options): - """ - """ - self.action = action - self.target = target - self.data = data - self.options = options - self.verbose = options.verbose - self.search, self.filename = self.get_filename(target) - - def process(self): - """ Invoke update_file() using a helper method depending on target. - """ - if self.verbose: - txt = "Updating" - if self.action == "check": - txt = "Checking" - sys.stdout.write(f"{txt} file: {self.filename}\n") - - if self.target == "service": - r = self.update_file(fn=self.update_services) - elif self.target == "model": - r = self.update_file(fn=self.update_emane_models) - elif self.target == "nodetype": - r = self.update_nodes_conf() - - if self.verbose: - txt = "" - if not r: - txt = "NOT " - if self.action == "check": - sys.stdout.write(f"String {txt} found.\n") - else: - sys.stdout.write(f"File {txt} updated.\n") - - return r - - def update_services(self, line): - """ Modify the __init__.py file having this format: - __all__ = ["quagga", "nrl", "xorp", "bird", ] - Returns True or False when "check" is the action, a modified line - otherwise. - """ - line = line.strip("\n") - key, valstr = line.split("= ") - vals = ast.literal_eval(valstr) - r = self.update_keyvals(key, vals) - if self.action == "check": - return r - valstr = str(r) - return "= ".join([key, valstr]) + "\n" - - def update_emane_models(self, line): - """ Modify the core.conf file having this format: - emane_models = RfPipe, Ieee80211abg, CommEffect, Bypass - Returns True or False when "check" is the action, a modified line - otherwise. - """ - line = line.strip("\n") - key, valstr = line.split("= ") - vals = valstr.split(", ") - r = self.update_keyvals(key, vals) - if self.action == "check": - return r - valstr = ", ".join(r) - return "= ".join([key, valstr]) + "\n" - - def update_keyvals(self, key, vals): - """ Perform self.action on (key, vals). - Returns True or False when "check" is the action, a modified line - otherwise. - """ - if self.action == "check": - if self.data in vals: - return True - else: - return False - elif self.action == "add": - if self.data not in vals: - vals.append(self.data) - elif self.action == "remove": - try: - vals.remove(self.data) - except ValueError: - pass - return vals - - def get_filename(self, target): - """ Return search string and filename based on target. - """ - if target == "service": - filename = os.path.abspath(services.__file__) - search = "__all__ =" - elif target == "model": - filename = os.path.join(CORE_CONF_DIR, "core.conf") - search = "emane_models =" - elif target == "nodetype": - if self.options.userpath is None: - raise ValueError("missing user path") - filename = os.path.join(self.options.userpath, "nodes.conf") - search = self.data - else: - raise ValueError("unknown target") - if not os.path.exists(filename): - raise ValueError(f"file {filename} does not exist") - return search, filename - - def update_file(self, fn=None): - """ Open a file and search for self.search, invoking the supplied - function on the matching line. Write file changes if necessary. - Returns True if the file has changed (or action is "check" and the - search string is found), False otherwise. - """ - changed = False - output = "" # this accumulates output, assumes input is small - with open(self.filename, "r") as f: - for line in f: - if line[:len(self.search)] == self.search: - r = fn(line) # line may be modified by fn() here - if self.action == "check": - return r - else: - if line != r: - changed = True - line = r - output += line - if changed: - with open(self.filename, "w") as f: - f.write(output) - - return changed - - def update_nodes_conf(self): - """ Add/remove/check entries from nodes.conf. This file - contains a Tcl-formatted array of node types. The array index must be - properly set for new entries. Uses self.{action, filename, search, - data} variables as input and returns the same value as update_file(). - """ - changed = False - output = "" # this accumulates output, assumes input is small - with open(self.filename, "r") as f: - for line in f: - # make sure data is not added twice - if line.find(self.search) >= 0: - if self.action == "check": - return True - elif self.action == "add": - return False - elif self.action == "remove": - changed = True - continue - else: - output += line - - if self.action == "add": - index = int(re.match("^\d+", line).group(0)) - output += str(index + 1) + " " + self.data + "\n" - changed = True - if changed: - with open(self.filename, "w") as f: - f.write(output) - - return changed - - -def main(): - actions = ", ".join(FileUpdater.actions) - targets = ", ".join(FileUpdater.targets) - usagestr = "usage: %prog [-h] [options] \n" - usagestr += "\nHelper tool to add, remove, or check for " - usagestr += "services, models, and node types\nin a CORE installation.\n" - usagestr += "\nExamples:\n %prog add service newrouting" - usagestr += "\n %prog -v check model RfPipe" - usagestr += "\n %prog --userpath=\"$HOME/.core\" add nodetype \"{ftp ftp.gif ftp.gif {DefaultRoute FTP} netns {FTP server} }\" \n" - usagestr += f"\nArguments:\n should be one of: {actions}" - usagestr += f"\n should be one of: {targets}" - usagestr += f"\n is the text to {actions}" - parser = optparse.OptionParser(usage=usagestr) - parser.set_defaults(userpath=None, verbose=False, ) - - parser.add_option("--userpath", dest="userpath", type="string", - help="use the specified user path (e.g. \"$HOME/.core" \ - "\") to access nodes.conf") - parser.add_option("-v", "--verbose", dest="verbose", action="store_true", - help="be verbose when performing action") - - def usage(msg=None, err=0): - sys.stdout.write("\n") - if msg: - sys.stdout.write(msg + "\n\n") - parser.print_help() - sys.exit(err) - - (options, args) = parser.parse_args() - - if len(args) != 3: - usage("Missing required arguments!", 1) - - action = args[0] - if action not in FileUpdater.actions: - usage(f"invalid action {action}", 1) - - target = args[1] - if target not in FileUpdater.targets: - usage(f"invalid target {target}", 1) - - if target == "nodetype" and not options.userpath: - usage(f"user path option required for this target ({target})") - - data = args[2] - - try: - up = FileUpdater(action, target, data, options) - r = up.process() - except Exception as e: - sys.stderr.write(f"Exception: {e}\n") - sys.exit(1) - if not r: - sys.exit(1) - sys.exit(0) - - -if __name__ == "__main__": - main() diff --git a/daemon/scripts/coresendmsg b/daemon/scripts/coresendmsg deleted file mode 100755 index 13e20b5c..00000000 --- a/daemon/scripts/coresendmsg +++ /dev/null @@ -1,279 +0,0 @@ -#!/usr/bin/env python3 -""" -coresendmsg: utility for generating CORE messages -""" - -import optparse -import os -import socket -import sys - -from core.api.tlv import coreapi -from core.api.tlv.enumerations import CORE_API_PORT, MessageTypes, SessionTlvs -from core.emulator.enumerations import MessageFlags - - -def print_available_tlvs(t, tlv_class): - """ - Print a TLV list. - """ - print(f"TLVs available for {t} message:") - for tlv in sorted([tlv for tlv in tlv_class.tlv_type_map], key=lambda x: x.name): - print(tlv.name.lower()) - - -def print_examples(name): - """ - Print example usage of this script. - """ - examples = [ - ("node number=3 x_position=125 y_position=525", - "move node number 3 to x,y=(125,525)"), - ("node number=4 icon=/usr/local/share/core/icons/normal/router_red.gif", - "change node number 4\"s icon to red"), - ("node flags=add number=5 type=0 name=\"n5\" x_position=500 y_position=500", - "add a new router node n5"), - ("link n1_number=2 n2_number=3 delay=15000", - "set a 15ms delay on the link between n2 and n3"), - ("link n1_number=2 n2_number=3 gui_attributes=\"color=blue\"", - "change the color of the link between n2 and n3"), - ("link flags=add n1_number=4 n2_number=5 interface1_ip4=\"10.0.3.2\" " - "interface1_ip4_mask=24 interface2_ip4=\"10.0.3.1\" interface2_ip4_mask=24", - "link node n5 with n4 using the given interface addresses"), - ("execute flags=string,text node=1 number=1000 command=\"uname -a\" -l", - "run a command on node 1 and wait for the result"), - ("execute node=2 number=1001 command=\"killall ospfd\"", - "run a command on node 2 and ignore the result"), - ("file flags=add node=1 name=\"/var/log/test.log\" data=\"hello world.\"", - "write a test.log file on node 1 with the given contents"), - ("file flags=add node=2 name=\"test.log\" source_name=\"./test.log\"", - "move a test.log file from host to node 2"), - ] - print(f"Example {name} invocations:") - for cmd, descr in examples: - print(f" {name} {cmd}\n\t\t{descr}") - - -def receive_message(sock): - """ - Retrieve a message from a socket and return the CoreMessage object or - None upon disconnect. Socket data beyond the first message is dropped. - """ - try: - # large receive buffer used for UDP sockets, instead of just receiving - # the 4-byte header - data = sock.recv(4096) - msghdr = data[:coreapi.CoreMessage.header_len] - except KeyboardInterrupt: - print("CTRL+C pressed") - sys.exit(1) - - if len(msghdr) == 0: - return None - - msgdata = None - msgtype, msgflags, msglen = coreapi.CoreMessage.unpack_header(msghdr) - - if msglen: - msgdata = data[coreapi.CoreMessage.header_len:] - try: - msgcls = coreapi.CLASS_MAP[msgtype] - except KeyError: - msg = coreapi.CoreMessage(msgflags, msghdr, msgdata) - msg.message_type = msgtype - print(f"unimplemented CORE message type: {msg.type_str()}") - return msg - if len(data) > msglen + coreapi.CoreMessage.header_len: - data_size = len(data) - (msglen + coreapi.CoreMessage.header_len) - print(f"received a message of type {msgtype}, dropping {data_size} bytes of extra data") - return msgcls(msgflags, msghdr, msgdata) - - -def connect_to_session(sock, requested): - """ - Use Session Messages to retrieve the current list of sessions and - connect to the first one. - """ - # request the session list - tlvdata = coreapi.CoreSessionTlv.pack(SessionTlvs.NUMBER.value, "") - flags = MessageFlags.STRING.value - smsg = coreapi.CoreSessionMessage.pack(flags, tlvdata) - sock.sendall(smsg) - - print("waiting for session list...") - smsgreply = receive_message(sock) - if smsgreply is None: - print("disconnected") - return False - - sessstr = smsgreply.get_tlv(SessionTlvs.NUMBER.value) - if sessstr is None: - print("missing session numbers") - return False - - # join the first session (that is not our own connection) - tmp, localport = sock.getsockname() - sessions = sessstr.split("|") - sessions.remove(str(localport)) - if len(sessions) == 0: - print("no sessions to join") - return False - - if not requested: - session = sessions[0] - elif requested in sessions: - session = requested - else: - print("requested session not found!") - return False - - print(f"joining session: {session}") - tlvdata = coreapi.CoreSessionTlv.pack(SessionTlvs.NUMBER.value, session) - flags = MessageFlags.ADD.value - smsg = coreapi.CoreSessionMessage.pack(flags, tlvdata) - sock.sendall(smsg) - return True - - -def receive_response(sock, opt): - """ - Receive and print a CORE message from the given socket. - """ - print("waiting for response...") - msg = receive_message(sock) - if msg is None: - print(f"disconnected from {opt.address}:{opt.port}") - sys.exit(0) - print(f"received message: {msg}") - - -def main(): - """ - Parse command-line arguments to build and send a CORE message. - """ - types = [message_type.name.lower() for message_type in MessageTypes] - flags = [flag.name.lower() for flag in MessageFlags] - types_usage = " ".join(types) - flags_usage = " ".join(flags) - usagestr = ( - "usage: %prog [-h|-H] [options] [message-type] [flags=flags] " - "[message-TLVs]\n\n" - f"Supported message types:\n {types_usage}\n" - f"Supported message flags (flags=f1,f2,...):\n {flags_usage}" - ) - parser = optparse.OptionParser(usage=usagestr) - default_address = "localhost" - default_session = None - default_tcp = False - parser.set_defaults( - port=CORE_API_PORT, - address=default_address, - session=default_session, - listen=False, - examples=False, - tlvs=False, - tcp=default_tcp - ) - parser.add_option("-H", dest="examples", action="store_true", - help="show example usage help message and exit") - parser.add_option("-p", "--port", dest="port", type=int, - help=f"TCP port to connect to, default: {CORE_API_PORT}") - parser.add_option("-a", "--address", dest="address", type=str, - help=f"Address to connect to, default: {default_address}") - parser.add_option("-s", "--session", dest="session", type=str, - help=f"Session to join, default: {default_session}") - parser.add_option("-l", "--listen", dest="listen", action="store_true", - help="Listen for a response message and print it.") - parser.add_option("-t", "--list-tlvs", dest="tlvs", action="store_true", - help="List TLVs for the specified message type.") - parser.add_option("--tcp", dest="tcp", action="store_true", - help=f"Use TCP instead of UDP and connect to a session default: {default_tcp}") - - def usage(msg=None, err=0): - print() - if msg: - print(f"{msg}\n") - parser.print_help() - sys.exit(err) - - # parse command line opt - opt, args = parser.parse_args() - if opt.examples: - print_examples(os.path.basename(sys.argv[0])) - sys.exit(0) - if len(args) == 0: - usage("Please specify a message type to send.") - - # given a message type t, determine the message and TLV classes - t = args.pop(0) - t = t.lower() - if t not in types: - usage(f"Unknown message type requested: {t}") - message_type = MessageTypes[t.upper()] - msg_cls = coreapi.CLASS_MAP[message_type.value] - tlv_cls = msg_cls.tlv_class - - # list TLV types for this message type - if opt.tlvs: - print_available_tlvs(t, tlv_cls) - sys.exit(0) - - # build a message consisting of TLVs from "type=value" arguments - flagstr = "" - tlvdata = b"" - for a in args: - typevalue = a.split("=") - if len(typevalue) < 2: - usage(f"Use \"type=value\" syntax instead of \"{a}\".") - tlv_typestr = typevalue[0].lower() - tlv_valstr = "=".join(typevalue[1:]) - if tlv_typestr == "flags": - flagstr = tlv_valstr - continue - try: - tlv_type = tlv_cls.tlv_type_map[tlv_typestr.upper()] - tlvdata += tlv_cls.pack_string(tlv_type.value, tlv_valstr) - except KeyError: - usage(f"Unknown TLV: \"{tlv_typestr}\"") - - flags = 0 - for f in flagstr.split(","): - if f == "": - continue - try: - flag_enum = MessageFlags[f.upper()] - n = flag_enum.value - flags |= n - except KeyError: - usage(f"Invalid flag \"{f}\".") - - msg = msg_cls.pack(flags, tlvdata) - - if opt.tcp: - protocol = socket.SOCK_STREAM - else: - protocol = socket.SOCK_DGRAM - - sock = socket.socket(socket.AF_INET, protocol) - sock.setblocking(True) - - try: - sock.connect((opt.address, opt.port)) - except Exception as e: - print(f"Error connecting to {opt.address}:{opt.port}:\n\t{e}") - sys.exit(1) - - if opt.tcp and not connect_to_session(sock, opt.session): - print("warning: continuing without joining a session!") - - sock.sendall(msg) - if opt.listen: - receive_response(sock, opt) - if opt.tcp: - sock.shutdown(socket.SHUT_RDWR) - sock.close() - sys.exit(0) - - -if __name__ == "__main__": - main() diff --git a/daemon/tests/conftest.py b/daemon/tests/conftest.py index 98552540..4827ed86 100644 --- a/daemon/tests/conftest.py +++ b/daemon/tests/conftest.py @@ -7,11 +7,9 @@ import time import mock import pytest -from mock.mock import MagicMock from core.api.grpc.client import InterfaceHelper from core.api.grpc.server import CoreGrpcServer -from core.api.tlv.corehandlers import CoreHandler from core.emulator.coreemu import CoreEmu from core.emulator.data import IpPrefixes from core.emulator.distributed import DistributedServer @@ -104,17 +102,6 @@ def module_grpc(global_coreemu): grpc_server.server.stop(None) -@pytest.fixture(scope="module") -def module_coretlv(patcher, global_coreemu, global_session): - request_mock = MagicMock() - request_mock.fileno = MagicMock(return_value=1) - server = MockServer(global_coreemu) - request_handler = CoreHandler(request_mock, "", server) - request_handler.session = global_session - request_handler.add_session_handlers() - yield request_handler - - @pytest.fixture def grpc_server(module_grpc): yield module_grpc @@ -130,16 +117,6 @@ def session(global_session): global_session.clear() -@pytest.fixture -def coretlv(module_coretlv): - session = module_coretlv.session - session.set_state(EventTypes.CONFIGURATION_STATE) - coreemu = module_coretlv.coreemu - coreemu.sessions[session.id] = session - yield module_coretlv - coreemu.shutdown() - - def pytest_addoption(parser): parser.addoption("--distributed", help="distributed server address") parser.addoption("--mock", action="store_true", help="run without mocking") diff --git a/daemon/tests/test_core.py b/daemon/tests/test_core.py index 3fbd91cb..71a3d972 100644 --- a/daemon/tests/test_core.py +++ b/daemon/tests/test_core.py @@ -9,7 +9,6 @@ from typing import List, Type import pytest from core.emulator.data import IpPrefixes, NodeOptions -from core.emulator.enumerations import MessageFlags from core.emulator.session import Session from core.errors import CoreCommandError from core.location.mobility import BasicRangeModel, Ns2ScriptedMobility @@ -63,44 +62,6 @@ class TestCore: status = ping(node1, node2, ip_prefixes) assert not status - def test_iface(self, session: Session, ip_prefixes: IpPrefixes): - """ - Test interface methods. - - :param session: session for test - :param ip_prefixes: generates ip addresses for nodes - """ - - # create ptp - ptp_node = session.add_node(PtpNet) - - # create nodes - node1 = session.add_node(CoreNode) - node2 = session.add_node(CoreNode) - - # link nodes to ptp net - for node in [node1, node2]: - iface = ip_prefixes.create_iface(node) - session.add_link(node.id, ptp_node.id, iface1_data=iface) - - # instantiate session - session.instantiate() - - # check link data gets generated - assert ptp_node.links(MessageFlags.ADD) - - # check common nets exist between linked nodes - assert node1.commonnets(node2) - assert node2.commonnets(node1) - - # check we can retrieve interface id - assert 0 in node1.ifaces - assert 0 in node2.ifaces - - # delete interface and test that if no longer exists - node1.delete_iface(0) - assert 0 not in node1.ifaces - def test_wlan_ping(self, session: Session, ip_prefixes: IpPrefixes): """ Test basic wlan network. diff --git a/daemon/tests/test_distributed.py b/daemon/tests/test_distributed.py index 01362cae..35b7af4e 100644 --- a/daemon/tests/test_distributed.py +++ b/daemon/tests/test_distributed.py @@ -29,12 +29,14 @@ class TestDistributed: # when session.distributed.add_server(server_name, host) + node1 = session.add_node(HubNode) options = NodeOptions(server=server_name) - node = session.add_node(HubNode, options=options) + node2 = session.add_node(HubNode, options=options) + session.add_link(node1.id, node2.id) session.instantiate() # then - assert node.server is not None - assert node.server.name == server_name - assert node.server.host == host - assert len(session.distributed.tunnels) > 0 + assert node2.server is not None + assert node2.server.name == server_name + assert node2.server.host == host + assert len(session.distributed.tunnels) == 1 diff --git a/daemon/tests/test_grpc.py b/daemon/tests/test_grpc.py index e56322ad..7e4e8be2 100644 --- a/daemon/tests/test_grpc.py +++ b/daemon/tests/test_grpc.py @@ -31,12 +31,10 @@ from core.api.grpc.wrappers import ( SessionLocation, SessionState, ) -from core.api.tlv.dataconversion import ConfigShim -from core.api.tlv.enumerations import ConfigFlags from core.emane.models.ieee80211abg import EmaneIeee80211abgModel from core.emane.nodes import EmaneNet from core.emulator.data import EventData, IpPrefixes, NodeData, NodeOptions -from core.emulator.enumerations import EventTypes, ExceptionLevels +from core.emulator.enumerations import EventTypes, ExceptionLevels, MessageFlags from core.errors import CoreError from core.location.mobility import BasicRangeModel, Ns2ScriptedMobility from core.nodes.base import CoreNode @@ -415,7 +413,7 @@ class TestGrpc: session = grpc_server.coreemu.create_session() switch = session.add_node(SwitchNode) node = session.add_node(CoreNode) - assert len(switch.links()) == 0 + assert len(session.link_manager.links()) == 0 iface = InterfaceHelper("10.0.0.0/24").create_iface(node.id, 0) link = Link(node.id, switch.id, iface1=iface) @@ -425,7 +423,7 @@ class TestGrpc: # then assert result is True - assert len(switch.links()) == 1 + assert len(session.link_manager.links()) == 1 assert iface1.id == iface.id assert iface1.ip4 == iface.ip4 @@ -447,11 +445,10 @@ class TestGrpc: session = grpc_server.coreemu.create_session() switch = session.add_node(SwitchNode) node = session.add_node(CoreNode) - iface = ip_prefixes.create_iface(node) - session.add_link(node.id, switch.id, iface) + iface_data = ip_prefixes.create_iface(node) + iface, _ = session.add_link(node.id, switch.id, iface_data) options = LinkOptions(bandwidth=30000) - link = switch.links()[0] - assert options.bandwidth != link.options.bandwidth + assert iface.options.bandwidth != options.bandwidth link = Link(node.id, switch.id, iface1=Interface(id=iface.id), options=options) # then @@ -460,8 +457,7 @@ class TestGrpc: # then assert result is True - link = switch.links()[0] - assert options.bandwidth == link.options.bandwidth + assert options.bandwidth == iface.options.bandwidth def test_delete_link(self, grpc_server: CoreGrpcServer, ip_prefixes: IpPrefixes): # given @@ -472,13 +468,7 @@ class TestGrpc: node2 = session.add_node(CoreNode) iface2 = ip_prefixes.create_iface(node2) session.add_link(node1.id, node2.id, iface1, iface2) - link_node = None - for node_id in session.nodes: - node = session.nodes[node_id] - if node.id not in {node1.id, node2.id}: - link_node = node - break - assert len(link_node.links()) == 1 + assert len(session.link_manager.links()) == 1 link = Link( node1.id, node2.id, @@ -492,7 +482,7 @@ class TestGrpc: # then assert result is True - assert len(link_node.links()) == 0 + assert len(session.link_manager.links()) == 0 def test_get_wlan_config(self, grpc_server: CoreGrpcServer): # given @@ -757,9 +747,11 @@ class TestGrpc: session = grpc_server.coreemu.create_session() wlan = session.add_node(WlanNode) node = session.add_node(CoreNode) - iface = ip_prefixes.create_iface(node) - session.add_link(node.id, wlan.id, iface) - link_data = wlan.links()[0] + iface_data = ip_prefixes.create_iface(node) + session.add_link(node.id, wlan.id, iface_data) + core_link = list(session.link_manager.links())[0] + link_data = core_link.get_data(MessageFlags.ADD) + queue = Queue() def handle_event(event: Event) -> None: @@ -820,30 +812,6 @@ class TestGrpc: # then queue.get(timeout=5) - def test_config_events(self, grpc_server: CoreGrpcServer): - # given - client = CoreGrpcClient() - session = grpc_server.coreemu.create_session() - queue = Queue() - - def handle_event(event: Event) -> None: - assert event.session_id == session.id - assert event.config_event is not None - queue.put(event) - - # then - with client.context_connect(): - client.events(session.id, handle_event) - time.sleep(0.1) - session_config = session.options.get_configs() - config_data = ConfigShim.config_data( - 0, None, ConfigFlags.UPDATE.value, session.options, session_config - ) - session.broadcast_config(config_data) - - # then - queue.get(timeout=5) - def test_exception_events(self, grpc_server: CoreGrpcServer): # given client = CoreGrpcClient() @@ -958,3 +926,26 @@ class TestGrpc: with pytest.raises(grpc.RpcError): with client.context_connect(): client.move_nodes(streamer) + + def test_wlan_link(self, grpc_server: CoreGrpcServer, ip_prefixes: IpPrefixes): + # given + client = CoreGrpcClient() + session = grpc_server.coreemu.create_session() + wlan = session.add_node(WlanNode) + node1 = session.add_node(CoreNode) + node2 = session.add_node(CoreNode) + iface1_data = ip_prefixes.create_iface(node1) + iface2_data = ip_prefixes.create_iface(node2) + session.add_link(node1.id, wlan.id, iface1_data) + session.add_link(node2.id, wlan.id, iface2_data) + session.instantiate() + assert len(session.link_manager.links()) == 2 + + # when + with client.context_connect(): + result1 = client.wlan_link(session.id, wlan.id, node1.id, node2.id, True) + result2 = client.wlan_link(session.id, wlan.id, node1.id, node2.id, False) + + # then + assert result1 is True + assert result2 is True diff --git a/daemon/tests/test_gui.py b/daemon/tests/test_gui.py deleted file mode 100644 index b14f1fb1..00000000 --- a/daemon/tests/test_gui.py +++ /dev/null @@ -1,941 +0,0 @@ -""" -Tests for testing tlv message handling. -""" -import time -from pathlib import Path -from typing import Optional - -import mock -import netaddr -import pytest -from mock import MagicMock - -from core.api.tlv import coreapi -from core.api.tlv.corehandlers import CoreHandler -from core.api.tlv.enumerations import ( - ConfigFlags, - ConfigTlvs, - EventTlvs, - ExecuteTlvs, - FileTlvs, - LinkTlvs, - NodeTlvs, - SessionTlvs, -) -from core.emane.models.ieee80211abg import EmaneIeee80211abgModel -from core.emulator.enumerations import EventTypes, MessageFlags, NodeTypes, RegisterTlvs -from core.errors import CoreError -from core.location.mobility import BasicRangeModel -from core.nodes.base import CoreNode, NodeBase -from core.nodes.network import SwitchNode, WlanNode - - -def dict_to_str(values) -> str: - return "|".join(f"{x}={values[x]}" for x in values) - - -class TestGui: - @pytest.mark.parametrize( - "node_type, model", - [ - (NodeTypes.DEFAULT, "PC"), - (NodeTypes.EMANE, None), - (NodeTypes.HUB, None), - (NodeTypes.SWITCH, None), - (NodeTypes.WIRELESS_LAN, None), - (NodeTypes.TUNNEL, None), - ], - ) - def test_node_add( - self, coretlv: CoreHandler, node_type: NodeTypes, model: Optional[str] - ): - node_id = 1 - name = "node1" - message = coreapi.CoreNodeMessage.create( - MessageFlags.ADD.value, - [ - (NodeTlvs.NUMBER, node_id), - (NodeTlvs.TYPE, node_type.value), - (NodeTlvs.NAME, name), - (NodeTlvs.X_POSITION, 0), - (NodeTlvs.Y_POSITION, 0), - (NodeTlvs.MODEL, model), - ], - ) - - coretlv.handle_message(message) - node = coretlv.session.get_node(node_id, NodeBase) - assert node - assert node.name == name - - def test_node_update(self, coretlv: CoreHandler): - node_id = 1 - coretlv.session.add_node(CoreNode, _id=node_id) - x = 50 - y = 100 - message = coreapi.CoreNodeMessage.create( - 0, - [ - (NodeTlvs.NUMBER, node_id), - (NodeTlvs.X_POSITION, x), - (NodeTlvs.Y_POSITION, y), - ], - ) - - coretlv.handle_message(message) - - node = coretlv.session.get_node(node_id, NodeBase) - assert node is not None - assert node.position.x == x - assert node.position.y == y - - def test_node_delete(self, coretlv: CoreHandler): - node_id = 1 - coretlv.session.add_node(CoreNode, _id=node_id) - message = coreapi.CoreNodeMessage.create( - MessageFlags.DELETE.value, [(NodeTlvs.NUMBER, node_id)] - ) - - coretlv.handle_message(message) - - with pytest.raises(CoreError): - coretlv.session.get_node(node_id, NodeBase) - - def test_link_add_node_to_net(self, coretlv: CoreHandler): - node1_id = 1 - coretlv.session.add_node(CoreNode, _id=node1_id) - switch_id = 2 - coretlv.session.add_node(SwitchNode, _id=switch_id) - ip_prefix = netaddr.IPNetwork("10.0.0.0/24") - iface1_ip4 = str(ip_prefix[node1_id]) - message = coreapi.CoreLinkMessage.create( - MessageFlags.ADD.value, - [ - (LinkTlvs.N1_NUMBER, node1_id), - (LinkTlvs.N2_NUMBER, switch_id), - (LinkTlvs.IFACE1_NUMBER, 0), - (LinkTlvs.IFACE1_IP4, iface1_ip4), - (LinkTlvs.IFACE1_IP4_MASK, 24), - ], - ) - - coretlv.handle_message(message) - - switch_node = coretlv.session.get_node(switch_id, SwitchNode) - all_links = switch_node.links() - assert len(all_links) == 1 - - def test_link_add_net_to_node(self, coretlv: CoreHandler): - node1_id = 1 - coretlv.session.add_node(CoreNode, _id=node1_id) - switch_id = 2 - coretlv.session.add_node(SwitchNode, _id=switch_id) - ip_prefix = netaddr.IPNetwork("10.0.0.0/24") - iface2_ip4 = str(ip_prefix[node1_id]) - message = coreapi.CoreLinkMessage.create( - MessageFlags.ADD.value, - [ - (LinkTlvs.N1_NUMBER, switch_id), - (LinkTlvs.N2_NUMBER, node1_id), - (LinkTlvs.IFACE2_NUMBER, 0), - (LinkTlvs.IFACE2_IP4, iface2_ip4), - (LinkTlvs.IFACE2_IP4_MASK, 24), - ], - ) - - coretlv.handle_message(message) - - switch_node = coretlv.session.get_node(switch_id, SwitchNode) - all_links = switch_node.links() - assert len(all_links) == 1 - - def test_link_add_node_to_node(self, coretlv: CoreHandler): - node1_id = 1 - coretlv.session.add_node(CoreNode, _id=node1_id) - node2_id = 2 - coretlv.session.add_node(CoreNode, _id=node2_id) - ip_prefix = netaddr.IPNetwork("10.0.0.0/24") - iface1_ip4 = str(ip_prefix[node1_id]) - iface2_ip4 = str(ip_prefix[node2_id]) - message = coreapi.CoreLinkMessage.create( - MessageFlags.ADD.value, - [ - (LinkTlvs.N1_NUMBER, node1_id), - (LinkTlvs.N2_NUMBER, node2_id), - (LinkTlvs.IFACE1_NUMBER, 0), - (LinkTlvs.IFACE1_IP4, iface1_ip4), - (LinkTlvs.IFACE1_IP4_MASK, 24), - (LinkTlvs.IFACE2_NUMBER, 0), - (LinkTlvs.IFACE2_IP4, iface2_ip4), - (LinkTlvs.IFACE2_IP4_MASK, 24), - ], - ) - - coretlv.handle_message(message) - - all_links = [] - for node_id in coretlv.session.nodes: - node = coretlv.session.nodes[node_id] - all_links += node.links() - assert len(all_links) == 1 - - def test_link_update(self, coretlv: CoreHandler): - node1_id = 1 - coretlv.session.add_node(CoreNode, _id=node1_id) - switch_id = 2 - coretlv.session.add_node(SwitchNode, _id=switch_id) - ip_prefix = netaddr.IPNetwork("10.0.0.0/24") - iface1_ip4 = str(ip_prefix[node1_id]) - message = coreapi.CoreLinkMessage.create( - MessageFlags.ADD.value, - [ - (LinkTlvs.N1_NUMBER, node1_id), - (LinkTlvs.N2_NUMBER, switch_id), - (LinkTlvs.IFACE1_NUMBER, 0), - (LinkTlvs.IFACE1_IP4, iface1_ip4), - (LinkTlvs.IFACE1_IP4_MASK, 24), - ], - ) - coretlv.handle_message(message) - switch_node = coretlv.session.get_node(switch_id, SwitchNode) - all_links = switch_node.links() - assert len(all_links) == 1 - link = all_links[0] - assert link.options.bandwidth is None - - bandwidth = 50000 - message = coreapi.CoreLinkMessage.create( - 0, - [ - (LinkTlvs.N1_NUMBER, node1_id), - (LinkTlvs.N2_NUMBER, switch_id), - (LinkTlvs.IFACE1_NUMBER, 0), - (LinkTlvs.BANDWIDTH, bandwidth), - ], - ) - coretlv.handle_message(message) - - switch_node = coretlv.session.get_node(switch_id, SwitchNode) - all_links = switch_node.links() - assert len(all_links) == 1 - link = all_links[0] - assert link.options.bandwidth == bandwidth - - def test_link_delete_node_to_node(self, coretlv: CoreHandler): - node1_id = 1 - coretlv.session.add_node(CoreNode, _id=node1_id) - node2_id = 2 - coretlv.session.add_node(CoreNode, _id=node2_id) - ip_prefix = netaddr.IPNetwork("10.0.0.0/24") - iface1_ip4 = str(ip_prefix[node1_id]) - iface2_ip4 = str(ip_prefix[node2_id]) - message = coreapi.CoreLinkMessage.create( - MessageFlags.ADD.value, - [ - (LinkTlvs.N1_NUMBER, node1_id), - (LinkTlvs.N2_NUMBER, node2_id), - (LinkTlvs.IFACE1_NUMBER, 0), - (LinkTlvs.IFACE1_IP4, iface1_ip4), - (LinkTlvs.IFACE1_IP4_MASK, 24), - (LinkTlvs.IFACE2_IP4, iface2_ip4), - (LinkTlvs.IFACE2_IP4_MASK, 24), - ], - ) - coretlv.handle_message(message) - all_links = [] - for node_id in coretlv.session.nodes: - node = coretlv.session.nodes[node_id] - all_links += node.links() - assert len(all_links) == 1 - - message = coreapi.CoreLinkMessage.create( - MessageFlags.DELETE.value, - [ - (LinkTlvs.N1_NUMBER, node1_id), - (LinkTlvs.N2_NUMBER, node2_id), - (LinkTlvs.IFACE1_NUMBER, 0), - (LinkTlvs.IFACE2_NUMBER, 0), - ], - ) - coretlv.handle_message(message) - - all_links = [] - for node_id in coretlv.session.nodes: - node = coretlv.session.nodes[node_id] - all_links += node.links() - assert len(all_links) == 0 - - def test_link_delete_node_to_net(self, coretlv: CoreHandler): - node1_id = 1 - coretlv.session.add_node(CoreNode, _id=node1_id) - switch_id = 2 - coretlv.session.add_node(SwitchNode, _id=switch_id) - ip_prefix = netaddr.IPNetwork("10.0.0.0/24") - iface1_ip4 = str(ip_prefix[node1_id]) - message = coreapi.CoreLinkMessage.create( - MessageFlags.ADD.value, - [ - (LinkTlvs.N1_NUMBER, node1_id), - (LinkTlvs.N2_NUMBER, switch_id), - (LinkTlvs.IFACE1_NUMBER, 0), - (LinkTlvs.IFACE1_IP4, iface1_ip4), - (LinkTlvs.IFACE1_IP4_MASK, 24), - ], - ) - coretlv.handle_message(message) - switch_node = coretlv.session.get_node(switch_id, SwitchNode) - all_links = switch_node.links() - assert len(all_links) == 1 - - message = coreapi.CoreLinkMessage.create( - MessageFlags.DELETE.value, - [ - (LinkTlvs.N1_NUMBER, node1_id), - (LinkTlvs.N2_NUMBER, switch_id), - (LinkTlvs.IFACE1_NUMBER, 0), - ], - ) - coretlv.handle_message(message) - - switch_node = coretlv.session.get_node(switch_id, SwitchNode) - all_links = switch_node.links() - assert len(all_links) == 0 - - def test_link_delete_net_to_node(self, coretlv: CoreHandler): - node1_id = 1 - coretlv.session.add_node(CoreNode, _id=node1_id) - switch_id = 2 - coretlv.session.add_node(SwitchNode, _id=switch_id) - ip_prefix = netaddr.IPNetwork("10.0.0.0/24") - iface1_ip4 = str(ip_prefix[node1_id]) - message = coreapi.CoreLinkMessage.create( - MessageFlags.ADD.value, - [ - (LinkTlvs.N1_NUMBER, node1_id), - (LinkTlvs.N2_NUMBER, switch_id), - (LinkTlvs.IFACE1_NUMBER, 0), - (LinkTlvs.IFACE1_IP4, iface1_ip4), - (LinkTlvs.IFACE1_IP4_MASK, 24), - ], - ) - coretlv.handle_message(message) - switch_node = coretlv.session.get_node(switch_id, SwitchNode) - all_links = switch_node.links() - assert len(all_links) == 1 - - message = coreapi.CoreLinkMessage.create( - MessageFlags.DELETE.value, - [ - (LinkTlvs.N1_NUMBER, switch_id), - (LinkTlvs.N2_NUMBER, node1_id), - (LinkTlvs.IFACE2_NUMBER, 0), - ], - ) - coretlv.handle_message(message) - - switch_node = coretlv.session.get_node(switch_id, SwitchNode) - all_links = switch_node.links() - assert len(all_links) == 0 - - def test_session_update(self, coretlv: CoreHandler): - session_id = coretlv.session.id - name = "test" - message = coreapi.CoreSessionMessage.create( - 0, [(SessionTlvs.NUMBER, str(session_id)), (SessionTlvs.NAME, name)] - ) - - coretlv.handle_message(message) - - assert coretlv.session.name == name - - def test_session_query(self, coretlv: CoreHandler): - coretlv.dispatch_replies = mock.MagicMock() - message = coreapi.CoreSessionMessage.create(MessageFlags.STRING.value, []) - - coretlv.handle_message(message) - - args, _ = coretlv.dispatch_replies.call_args - replies = args[0] - assert len(replies) == 1 - - def test_session_join(self, coretlv: CoreHandler): - coretlv.dispatch_replies = mock.MagicMock() - session_id = coretlv.session.id - message = coreapi.CoreSessionMessage.create( - MessageFlags.ADD.value, [(SessionTlvs.NUMBER, str(session_id))] - ) - - coretlv.handle_message(message) - - assert coretlv.session.id == session_id - - def test_session_delete(self, coretlv: CoreHandler): - assert len(coretlv.coreemu.sessions) == 1 - session_id = coretlv.session.id - message = coreapi.CoreSessionMessage.create( - MessageFlags.DELETE.value, [(SessionTlvs.NUMBER, str(session_id))] - ) - - coretlv.handle_message(message) - - assert len(coretlv.coreemu.sessions) == 0 - - def test_file_hook_add(self, coretlv: CoreHandler): - state = EventTypes.DATACOLLECT_STATE - assert coretlv.session.hooks.get(state) is None - file_name = "test.sh" - file_data = "echo hello" - message = coreapi.CoreFileMessage.create( - MessageFlags.ADD.value, - [ - (FileTlvs.TYPE, f"hook:{state.value}"), - (FileTlvs.NAME, file_name), - (FileTlvs.DATA, file_data), - ], - ) - - coretlv.handle_message(message) - - hooks = coretlv.session.hooks.get(state) - assert len(hooks) == 1 - name, data = hooks[0] - assert file_name == name - assert file_data == data - - def test_file_service_file_set(self, coretlv: CoreHandler): - node = coretlv.session.add_node(CoreNode) - service = "DefaultRoute" - file_name = "defaultroute.sh" - file_data = "echo hello" - message = coreapi.CoreFileMessage.create( - MessageFlags.ADD.value, - [ - (FileTlvs.NODE, node.id), - (FileTlvs.TYPE, f"service:{service}"), - (FileTlvs.NAME, file_name), - (FileTlvs.DATA, file_data), - ], - ) - - coretlv.handle_message(message) - - service_file = coretlv.session.services.get_service_file( - node, service, file_name - ) - assert file_data == service_file.data - - def test_file_node_file_copy(self, request, coretlv: CoreHandler): - file_path = Path("/var/log/test/node.log") - node = coretlv.session.add_node(CoreNode) - node.makenodedir() - file_data = "echo hello" - message = coreapi.CoreFileMessage.create( - MessageFlags.ADD.value, - [ - (FileTlvs.NODE, node.id), - (FileTlvs.NAME, str(file_path)), - (FileTlvs.DATA, file_data), - ], - ) - - coretlv.handle_message(message) - - if not request.config.getoption("mock"): - expected_path = node.directory / "var.log/test" / file_path.name - assert expected_path.exists() - - def test_exec_node_tty(self, coretlv: CoreHandler): - coretlv.dispatch_replies = mock.MagicMock() - node = coretlv.session.add_node(CoreNode) - message = coreapi.CoreExecMessage.create( - MessageFlags.TTY.value, - [ - (ExecuteTlvs.NODE, node.id), - (ExecuteTlvs.NUMBER, 1), - (ExecuteTlvs.COMMAND, "bash"), - ], - ) - - coretlv.handle_message(message) - - args, _ = coretlv.dispatch_replies.call_args - replies = args[0] - assert len(replies) == 1 - - def test_exec_local_command(self, request, coretlv: CoreHandler): - if request.config.getoption("mock"): - pytest.skip("mocking calls") - - coretlv.dispatch_replies = mock.MagicMock() - node = coretlv.session.add_node(CoreNode) - cmd = "echo hello" - message = coreapi.CoreExecMessage.create( - MessageFlags.TEXT.value | MessageFlags.LOCAL.value, - [ - (ExecuteTlvs.NODE, node.id), - (ExecuteTlvs.NUMBER, 1), - (ExecuteTlvs.COMMAND, cmd), - ], - ) - - coretlv.handle_message(message) - - args, _ = coretlv.dispatch_replies.call_args - replies = args[0] - assert len(replies) == 1 - - def test_exec_node_command(self, coretlv: CoreHandler): - coretlv.dispatch_replies = mock.MagicMock() - node = coretlv.session.add_node(CoreNode) - cmd = "echo hello" - message = coreapi.CoreExecMessage.create( - MessageFlags.TEXT.value, - [ - (ExecuteTlvs.NODE, node.id), - (ExecuteTlvs.NUMBER, 1), - (ExecuteTlvs.COMMAND, cmd), - ], - ) - node.cmd = MagicMock(return_value="hello") - - coretlv.handle_message(message) - - node.cmd.assert_called_with(cmd) - - @pytest.mark.parametrize( - "state", - [ - EventTypes.SHUTDOWN_STATE, - EventTypes.RUNTIME_STATE, - EventTypes.DATACOLLECT_STATE, - EventTypes.CONFIGURATION_STATE, - EventTypes.DEFINITION_STATE, - ], - ) - def test_event_state(self, coretlv: CoreHandler, state: EventTypes): - message = coreapi.CoreEventMessage.create(0, [(EventTlvs.TYPE, state.value)]) - - coretlv.handle_message(message) - - assert coretlv.session.state == state - - def test_event_schedule(self, coretlv: CoreHandler): - coretlv.session.add_event = mock.MagicMock() - node = coretlv.session.add_node(CoreNode) - message = coreapi.CoreEventMessage.create( - MessageFlags.ADD.value, - [ - (EventTlvs.TYPE, EventTypes.SCHEDULED.value), - (EventTlvs.TIME, str(time.monotonic() + 100)), - (EventTlvs.NODE, node.id), - (EventTlvs.NAME, "event"), - (EventTlvs.DATA, "data"), - ], - ) - - coretlv.handle_message(message) - - coretlv.session.add_event.assert_called_once() - - def test_event_save_xml(self, coretlv: CoreHandler, tmpdir): - xml_file = tmpdir.join("coretlv.session.xml") - file_path = xml_file.strpath - coretlv.session.add_node(CoreNode) - message = coreapi.CoreEventMessage.create( - 0, - [(EventTlvs.TYPE, EventTypes.FILE_SAVE.value), (EventTlvs.NAME, file_path)], - ) - coretlv.handle_message(message) - assert Path(file_path).exists() - - def test_event_open_xml(self, coretlv: CoreHandler, tmpdir): - xml_file = tmpdir.join("coretlv.session.xml") - file_path = Path(xml_file.strpath) - node = coretlv.session.add_node(CoreNode) - coretlv.session.save_xml(file_path) - coretlv.session.delete_node(node.id) - message = coreapi.CoreEventMessage.create( - 0, - [ - (EventTlvs.TYPE, EventTypes.FILE_OPEN.value), - (EventTlvs.NAME, str(file_path)), - ], - ) - - coretlv.handle_message(message) - assert coretlv.session.get_node(node.id, NodeBase) - - @pytest.mark.parametrize( - "state", - [ - EventTypes.START, - EventTypes.STOP, - EventTypes.RESTART, - EventTypes.PAUSE, - EventTypes.RECONFIGURE, - ], - ) - def test_event_service(self, coretlv: CoreHandler, state: EventTypes): - coretlv.session.broadcast_event = mock.MagicMock() - node = coretlv.session.add_node(CoreNode) - message = coreapi.CoreEventMessage.create( - 0, - [ - (EventTlvs.TYPE, state.value), - (EventTlvs.NODE, node.id), - (EventTlvs.NAME, "service:DefaultRoute"), - ], - ) - - coretlv.handle_message(message) - - coretlv.session.broadcast_event.assert_called_once() - - @pytest.mark.parametrize( - "state", - [ - EventTypes.START, - EventTypes.STOP, - EventTypes.RESTART, - EventTypes.PAUSE, - EventTypes.RECONFIGURE, - ], - ) - def test_event_mobility(self, coretlv: CoreHandler, state: EventTypes): - message = coreapi.CoreEventMessage.create( - 0, [(EventTlvs.TYPE, state.value), (EventTlvs.NAME, "mobility:ns2script")] - ) - - coretlv.handle_message(message) - - def test_register_gui(self, coretlv: CoreHandler): - message = coreapi.CoreRegMessage.create(0, [(RegisterTlvs.GUI, "gui")]) - coretlv.handle_message(message) - - def test_register_xml(self, coretlv: CoreHandler, tmpdir): - xml_file = tmpdir.join("coretlv.session.xml") - file_path = xml_file.strpath - node = coretlv.session.add_node(CoreNode) - coretlv.session.save_xml(file_path) - coretlv.session.delete_node(node.id) - message = coreapi.CoreRegMessage.create( - 0, [(RegisterTlvs.EXECUTE_SERVER, file_path)] - ) - coretlv.session.instantiate() - - coretlv.handle_message(message) - - assert coretlv.coreemu.sessions[1].get_node(node.id, CoreNode) - - def test_register_python(self, coretlv: CoreHandler, tmpdir): - xml_file = tmpdir.join("test.py") - file_path = xml_file.strpath - with open(file_path, "w") as f: - f.write("from core.nodes.base import CoreNode\n") - f.write("coreemu = globals()['coreemu']\n") - f.write(f"session = coreemu.sessions[{coretlv.session.id}]\n") - f.write("session.add_node(CoreNode)\n") - message = coreapi.CoreRegMessage.create( - 0, [(RegisterTlvs.EXECUTE_SERVER, file_path)] - ) - coretlv.session.instantiate() - - coretlv.handle_message(message) - - assert len(coretlv.session.nodes) == 1 - - def test_config_all(self, coretlv: CoreHandler): - message = coreapi.CoreConfMessage.create( - MessageFlags.ADD.value, - [(ConfigTlvs.OBJECT, "all"), (ConfigTlvs.TYPE, ConfigFlags.RESET.value)], - ) - coretlv.session.location.refxyz = (10, 10, 10) - - coretlv.handle_message(message) - - assert coretlv.session.location.refxyz == (0, 0, 0) - - def test_config_options_request(self, coretlv: CoreHandler): - message = coreapi.CoreConfMessage.create( - 0, - [ - (ConfigTlvs.OBJECT, "session"), - (ConfigTlvs.TYPE, ConfigFlags.REQUEST.value), - ], - ) - coretlv.handle_broadcast_config = mock.MagicMock() - - coretlv.handle_message(message) - - coretlv.handle_broadcast_config.assert_called_once() - - def test_config_options_update(self, coretlv: CoreHandler): - test_key = "test" - test_value = "test" - values = {test_key: test_value} - message = coreapi.CoreConfMessage.create( - 0, - [ - (ConfigTlvs.OBJECT, "session"), - (ConfigTlvs.TYPE, ConfigFlags.UPDATE.value), - (ConfigTlvs.VALUES, dict_to_str(values)), - ], - ) - - coretlv.handle_message(message) - - assert coretlv.session.options.get_config(test_key) == test_value - - def test_config_location_reset(self, coretlv: CoreHandler): - message = coreapi.CoreConfMessage.create( - 0, - [ - (ConfigTlvs.OBJECT, "location"), - (ConfigTlvs.TYPE, ConfigFlags.RESET.value), - ], - ) - coretlv.session.location.refxyz = (10, 10, 10) - - coretlv.handle_message(message) - - assert coretlv.session.location.refxyz == (0, 0, 0) - - def test_config_location_update(self, coretlv: CoreHandler): - message = coreapi.CoreConfMessage.create( - 0, - [ - (ConfigTlvs.OBJECT, "location"), - (ConfigTlvs.TYPE, ConfigFlags.UPDATE.value), - (ConfigTlvs.VALUES, "10|10|70|50|0|0.5"), - ], - ) - - coretlv.handle_message(message) - - assert coretlv.session.location.refxyz == (10, 10, 0.0) - assert coretlv.session.location.refgeo == (70, 50, 0) - assert coretlv.session.location.refscale == 0.5 - - def test_config_metadata_request(self, coretlv: CoreHandler): - message = coreapi.CoreConfMessage.create( - 0, - [ - (ConfigTlvs.OBJECT, "metadata"), - (ConfigTlvs.TYPE, ConfigFlags.REQUEST.value), - ], - ) - coretlv.handle_broadcast_config = mock.MagicMock() - - coretlv.handle_message(message) - - coretlv.handle_broadcast_config.assert_called_once() - - def test_config_metadata_update(self, coretlv: CoreHandler): - test_key = "test" - test_value = "test" - values = {test_key: test_value} - message = coreapi.CoreConfMessage.create( - 0, - [ - (ConfigTlvs.OBJECT, "metadata"), - (ConfigTlvs.TYPE, ConfigFlags.UPDATE.value), - (ConfigTlvs.VALUES, dict_to_str(values)), - ], - ) - - coretlv.handle_message(message) - - assert coretlv.session.metadata[test_key] == test_value - - def test_config_broker_request(self, coretlv: CoreHandler): - server = "test" - host = "10.0.0.1" - port = 50000 - message = coreapi.CoreConfMessage.create( - 0, - [ - (ConfigTlvs.OBJECT, "broker"), - (ConfigTlvs.TYPE, ConfigFlags.UPDATE.value), - (ConfigTlvs.VALUES, f"{server}:{host}:{port}"), - ], - ) - coretlv.session.distributed.add_server = mock.MagicMock() - - coretlv.handle_message(message) - - coretlv.session.distributed.add_server.assert_called_once_with(server, host) - - def test_config_services_request_all(self, coretlv: CoreHandler): - message = coreapi.CoreConfMessage.create( - 0, - [ - (ConfigTlvs.OBJECT, "services"), - (ConfigTlvs.TYPE, ConfigFlags.REQUEST.value), - ], - ) - coretlv.handle_broadcast_config = mock.MagicMock() - - coretlv.handle_message(message) - - coretlv.handle_broadcast_config.assert_called_once() - - def test_config_services_request_specific(self, coretlv: CoreHandler): - node = coretlv.session.add_node(CoreNode) - message = coreapi.CoreConfMessage.create( - 0, - [ - (ConfigTlvs.NODE, node.id), - (ConfigTlvs.OBJECT, "services"), - (ConfigTlvs.TYPE, ConfigFlags.REQUEST.value), - (ConfigTlvs.OPAQUE, "service:DefaultRoute"), - ], - ) - coretlv.handle_broadcast_config = mock.MagicMock() - - coretlv.handle_message(message) - - coretlv.handle_broadcast_config.assert_called_once() - - def test_config_services_request_specific_file(self, coretlv: CoreHandler): - node = coretlv.session.add_node(CoreNode) - message = coreapi.CoreConfMessage.create( - 0, - [ - (ConfigTlvs.NODE, node.id), - (ConfigTlvs.OBJECT, "services"), - (ConfigTlvs.TYPE, ConfigFlags.REQUEST.value), - (ConfigTlvs.OPAQUE, "service:DefaultRoute:defaultroute.sh"), - ], - ) - coretlv.session.broadcast_file = mock.MagicMock() - - coretlv.handle_message(message) - - coretlv.session.broadcast_file.assert_called_once() - - def test_config_services_reset(self, coretlv: CoreHandler): - node = coretlv.session.add_node(CoreNode) - service = "DefaultRoute" - coretlv.session.services.set_service(node.id, service) - message = coreapi.CoreConfMessage.create( - 0, - [ - (ConfigTlvs.OBJECT, "services"), - (ConfigTlvs.TYPE, ConfigFlags.RESET.value), - ], - ) - assert coretlv.session.services.get_service(node.id, service) is not None - - coretlv.handle_message(message) - - assert coretlv.session.services.get_service(node.id, service) is None - - def test_config_services_set(self, coretlv: CoreHandler): - node = coretlv.session.add_node(CoreNode) - service = "DefaultRoute" - values = {"meta": "metadata"} - message = coreapi.CoreConfMessage.create( - 0, - [ - (ConfigTlvs.NODE, node.id), - (ConfigTlvs.OBJECT, "services"), - (ConfigTlvs.TYPE, ConfigFlags.UPDATE.value), - (ConfigTlvs.OPAQUE, f"service:{service}"), - (ConfigTlvs.VALUES, dict_to_str(values)), - ], - ) - assert coretlv.session.services.get_service(node.id, service) is None - - coretlv.handle_message(message) - - assert coretlv.session.services.get_service(node.id, service) is not None - - def test_config_mobility_reset(self, coretlv: CoreHandler): - wlan = coretlv.session.add_node(WlanNode) - message = coreapi.CoreConfMessage.create( - 0, - [ - (ConfigTlvs.OBJECT, "MobilityManager"), - (ConfigTlvs.TYPE, ConfigFlags.RESET.value), - ], - ) - coretlv.session.mobility.set_model_config(wlan.id, BasicRangeModel.name, {}) - assert len(coretlv.session.mobility.node_configurations) == 1 - - coretlv.handle_message(message) - - assert len(coretlv.session.mobility.node_configurations) == 0 - - def test_config_mobility_model_request(self, coretlv: CoreHandler): - wlan = coretlv.session.add_node(WlanNode) - message = coreapi.CoreConfMessage.create( - 0, - [ - (ConfigTlvs.NODE, wlan.id), - (ConfigTlvs.OBJECT, BasicRangeModel.name), - (ConfigTlvs.TYPE, ConfigFlags.REQUEST.value), - ], - ) - coretlv.handle_broadcast_config = mock.MagicMock() - - coretlv.handle_message(message) - - coretlv.handle_broadcast_config.assert_called_once() - - def test_config_mobility_model_update(self, coretlv: CoreHandler): - wlan = coretlv.session.add_node(WlanNode) - config_key = "range" - config_value = "1000" - values = {config_key: config_value} - message = coreapi.CoreConfMessage.create( - 0, - [ - (ConfigTlvs.NODE, wlan.id), - (ConfigTlvs.OBJECT, BasicRangeModel.name), - (ConfigTlvs.TYPE, ConfigFlags.UPDATE.value), - (ConfigTlvs.VALUES, dict_to_str(values)), - ], - ) - - coretlv.handle_message(message) - - config = coretlv.session.mobility.get_model_config( - wlan.id, BasicRangeModel.name - ) - assert config[config_key] == config_value - - def test_config_emane_model_request(self, coretlv: CoreHandler): - wlan = coretlv.session.add_node(WlanNode) - message = coreapi.CoreConfMessage.create( - 0, - [ - (ConfigTlvs.NODE, wlan.id), - (ConfigTlvs.OBJECT, EmaneIeee80211abgModel.name), - (ConfigTlvs.TYPE, ConfigFlags.REQUEST.value), - ], - ) - coretlv.handle_broadcast_config = mock.MagicMock() - - coretlv.handle_message(message) - - coretlv.handle_broadcast_config.assert_called_once() - - def test_config_emane_model_update(self, coretlv: CoreHandler): - wlan = coretlv.session.add_node(WlanNode) - config_key = "distance" - config_value = "50051" - values = {config_key: config_value} - message = coreapi.CoreConfMessage.create( - 0, - [ - (ConfigTlvs.NODE, wlan.id), - (ConfigTlvs.OBJECT, EmaneIeee80211abgModel.name), - (ConfigTlvs.TYPE, ConfigFlags.UPDATE.value), - (ConfigTlvs.VALUES, dict_to_str(values)), - ], - ) - - coretlv.handle_message(message) - - config = coretlv.session.emane.get_config(wlan.id, EmaneIeee80211abgModel.name) - assert config[config_key] == config_value diff --git a/daemon/tests/test_links.py b/daemon/tests/test_links.py index 791eb77a..eea88fb3 100644 --- a/daemon/tests/test_links.py +++ b/daemon/tests/test_links.py @@ -46,14 +46,17 @@ class TestLinks: ) # then + assert len(session.link_manager.links()) == 1 assert node1.get_iface(iface1_data.id) assert node2.get_iface(iface2_data.id) assert iface1 is not None + assert iface1.options == LINK_OPTIONS + assert iface1.has_netem + assert node1.get_iface(iface1_data.id) assert iface2 is not None - assert iface1.local_options == LINK_OPTIONS - assert iface1.has_local_netem - assert iface2.local_options == LINK_OPTIONS - assert iface2.has_local_netem + assert iface2.options == LINK_OPTIONS + assert iface2.has_netem + assert node1.get_iface(iface1_data.id) def test_add_node_to_net(self, session: Session, ip_prefixes: IpPrefixes): # given @@ -62,16 +65,20 @@ class TestLinks: iface1_data = ip_prefixes.create_iface(node1) # when - iface, _ = session.add_link( + iface1, iface2 = session.add_link( node1.id, node2.id, iface1_data=iface1_data, options=LINK_OPTIONS ) # then - assert node2.links() + assert len(session.link_manager.links()) == 1 + assert iface1 is not None + assert iface1.options == LINK_OPTIONS + assert iface1.has_netem assert node1.get_iface(iface1_data.id) - assert iface is not None - assert iface.local_options == LINK_OPTIONS - assert iface.has_local_netem + assert iface2 is not None + assert iface2.options == LINK_OPTIONS + assert iface2.has_netem + assert node2.get_iface(iface1_data.id) def test_add_net_to_node(self, session: Session, ip_prefixes: IpPrefixes): # given @@ -80,32 +87,37 @@ class TestLinks: iface2_data = ip_prefixes.create_iface(node2) # when - _, iface = session.add_link( + iface1, iface2 = session.add_link( node1.id, node2.id, iface2_data=iface2_data, options=LINK_OPTIONS ) # then - assert node1.links() - assert node2.get_iface(iface2_data.id) - assert iface is not None - assert iface.local_options == LINK_OPTIONS - assert iface.has_local_netem + assert len(session.link_manager.links()) == 1 + assert iface1 is not None + assert iface1.options == LINK_OPTIONS + assert iface1.has_netem + assert node1.get_iface(iface1.id) + assert iface2 is not None + assert iface2.options == LINK_OPTIONS + assert iface2.has_netem + assert node2.get_iface(iface2.id) - def test_add_net_to_net(self, session): + def test_add_net_to_net(self, session: Session): # given node1 = session.add_node(SwitchNode) node2 = session.add_node(SwitchNode) # when - iface, _ = session.add_link(node1.id, node2.id, options=LINK_OPTIONS) + iface1, iface2 = session.add_link(node1.id, node2.id, options=LINK_OPTIONS) # then - assert node1.links() - assert iface is not None - assert iface.local_options == LINK_OPTIONS - assert iface.options == LINK_OPTIONS - assert iface.has_local_netem - assert iface.has_netem + assert len(session.link_manager.links()) == 1 + assert iface1 is not None + assert iface1.options == LINK_OPTIONS + assert iface1.has_netem + assert iface2 is not None + assert iface2.options == LINK_OPTIONS + assert iface2.has_netem def test_add_node_to_node_uni(self, session: Session, ip_prefixes: IpPrefixes): # given @@ -141,48 +153,52 @@ class TestLinks: ) # then + assert len(session.link_manager.links()) == 1 assert node1.get_iface(iface1_data.id) assert node2.get_iface(iface2_data.id) assert iface1 is not None + assert iface1.options == link_options1 + assert iface1.has_netem assert iface2 is not None - assert iface1.local_options == link_options1 - assert iface1.has_local_netem - assert iface2.local_options == link_options2 - assert iface2.has_local_netem + assert iface2.options == link_options2 + assert iface2.has_netem def test_update_node_to_net(self, session: Session, ip_prefixes: IpPrefixes): # given node1 = session.add_node(CoreNode) node2 = session.add_node(SwitchNode) iface1_data = ip_prefixes.create_iface(node1) - iface1, _ = session.add_link(node1.id, node2.id, iface1_data) - assert iface1.local_options != LINK_OPTIONS + iface1, iface2 = session.add_link(node1.id, node2.id, iface1_data) + assert len(session.link_manager.links()) == 1 + assert iface1.options != LINK_OPTIONS + assert iface2.options != LINK_OPTIONS # when - session.update_link( - node1.id, node2.id, iface1_id=iface1_data.id, options=LINK_OPTIONS - ) + session.update_link(node1.id, node2.id, iface1.id, iface2.id, LINK_OPTIONS) # then - assert iface1.local_options == LINK_OPTIONS - assert iface1.has_local_netem + assert iface1.options == LINK_OPTIONS + assert iface1.has_netem + assert iface2.options == LINK_OPTIONS + assert iface2.has_netem def test_update_net_to_node(self, session: Session, ip_prefixes: IpPrefixes): # given node1 = session.add_node(SwitchNode) node2 = session.add_node(CoreNode) iface2_data = ip_prefixes.create_iface(node2) - _, iface2 = session.add_link(node1.id, node2.id, iface2_data=iface2_data) - assert iface2.local_options != LINK_OPTIONS + iface1, iface2 = session.add_link(node1.id, node2.id, iface2_data=iface2_data) + assert iface1.options != LINK_OPTIONS + assert iface2.options != LINK_OPTIONS # when - session.update_link( - node1.id, node2.id, iface2_id=iface2_data.id, options=LINK_OPTIONS - ) + session.update_link(node1.id, node2.id, iface1.id, iface2.id, LINK_OPTIONS) # then - assert iface2.local_options == LINK_OPTIONS - assert iface2.has_local_netem + assert iface1.options == LINK_OPTIONS + assert iface1.has_netem + assert iface2.options == LINK_OPTIONS + assert iface2.has_netem def test_update_ptp(self, session: Session, ip_prefixes: IpPrefixes): # given @@ -191,55 +207,68 @@ class TestLinks: iface1_data = ip_prefixes.create_iface(node1) iface2_data = ip_prefixes.create_iface(node2) iface1, iface2 = session.add_link(node1.id, node2.id, iface1_data, iface2_data) - assert iface1.local_options != LINK_OPTIONS - assert iface2.local_options != LINK_OPTIONS + assert iface1.options != LINK_OPTIONS + assert iface2.options != LINK_OPTIONS # when - session.update_link( - node1.id, node2.id, iface1_data.id, iface2_data.id, LINK_OPTIONS - ) + session.update_link(node1.id, node2.id, iface1.id, iface2.id, LINK_OPTIONS) # then - assert iface1.local_options == LINK_OPTIONS - assert iface1.has_local_netem - assert iface2.local_options == LINK_OPTIONS - assert iface2.has_local_netem + assert iface1.options == LINK_OPTIONS + assert iface1.has_netem + assert iface2.options == LINK_OPTIONS + assert iface2.has_netem def test_update_net_to_net(self, session: Session, ip_prefixes: IpPrefixes): # given node1 = session.add_node(SwitchNode) node2 = session.add_node(SwitchNode) - iface1, _ = session.add_link(node1.id, node2.id) - assert iface1.local_options != LINK_OPTIONS + iface1, iface2 = session.add_link(node1.id, node2.id) + assert iface1.options != LINK_OPTIONS + assert iface2.options != LINK_OPTIONS # when - session.update_link(node1.id, node2.id, options=LINK_OPTIONS) + session.update_link(node1.id, node2.id, iface1.id, iface2.id, LINK_OPTIONS) # then - assert iface1.local_options == LINK_OPTIONS - assert iface1.has_local_netem assert iface1.options == LINK_OPTIONS assert iface1.has_netem + assert iface2.options == LINK_OPTIONS + assert iface2.has_netem + + def test_update_error(self, session: Session, ip_prefixes: IpPrefixes): + # given + node1 = session.add_node(CoreNode) + node2 = session.add_node(CoreNode) + iface1_data = ip_prefixes.create_iface(node1) + iface2_data = ip_prefixes.create_iface(node2) + iface1, iface2 = session.add_link(node1.id, node2.id, iface1_data, iface2_data) + assert iface1.options != LINK_OPTIONS + assert iface2.options != LINK_OPTIONS + + # when + with pytest.raises(CoreError): + session.delete_link(node1.id, INVALID_ID, iface1.id, iface2.id) def test_clear_net_to_net(self, session: Session, ip_prefixes: IpPrefixes): # given node1 = session.add_node(SwitchNode) node2 = session.add_node(SwitchNode) - iface1, _ = session.add_link(node1.id, node2.id, options=LINK_OPTIONS) - assert iface1.local_options == LINK_OPTIONS - assert iface1.has_local_netem + iface1, iface2 = session.add_link(node1.id, node2.id, options=LINK_OPTIONS) assert iface1.options == LINK_OPTIONS assert iface1.has_netem + assert iface2.options == LINK_OPTIONS + assert iface2.has_netem # when options = LinkOptions(delay=0, bandwidth=0, loss=0.0, dup=0, jitter=0, buffer=0) - session.update_link(node1.id, node2.id, options=options) + session.update_link(node1.id, node2.id, iface1.id, iface2.id, options) # then - assert iface1.local_options.is_clear() - assert not iface1.has_local_netem assert iface1.options.is_clear() assert not iface1.has_netem + assert iface2.options.is_clear() + assert not iface2.has_netem def test_delete_node_to_node(self, session: Session, ip_prefixes: IpPrefixes): # given @@ -247,82 +276,100 @@ class TestLinks: node2 = session.add_node(CoreNode) iface1_data = ip_prefixes.create_iface(node1) iface2_data = ip_prefixes.create_iface(node2) - session.add_link(node1.id, node2.id, iface1_data, iface2_data) - assert node1.get_iface(iface1_data.id) - assert node2.get_iface(iface2_data.id) + iface1, iface2 = session.add_link(node1.id, node2.id, iface1_data, iface2_data) + assert len(session.link_manager.links()) == 1 + assert node1.get_iface(iface1.id) + assert node2.get_iface(iface2.id) # when - session.delete_link(node1.id, node2.id, iface1_data.id, iface2_data.id) + session.delete_link(node1.id, node2.id, iface1.id, iface2.id) # then - assert iface1_data.id not in node1.ifaces - assert iface2_data.id not in node2.ifaces + assert len(session.link_manager.links()) == 0 + assert iface1.id not in node1.ifaces + assert iface2.id not in node2.ifaces def test_delete_node_to_net(self, session: Session, ip_prefixes: IpPrefixes): # given node1 = session.add_node(CoreNode) node2 = session.add_node(SwitchNode) iface1_data = ip_prefixes.create_iface(node1) - session.add_link(node1.id, node2.id, iface1_data) - assert node1.get_iface(iface1_data.id) + iface1, iface2 = session.add_link(node1.id, node2.id, iface1_data) + assert len(session.link_manager.links()) == 1 + assert node1.get_iface(iface1.id) + assert node2.get_iface(iface2.id) # when - session.delete_link(node1.id, node2.id, iface1_id=iface1_data.id) + session.delete_link(node1.id, node2.id, iface1.id, iface2.id) # then - assert iface1_data.id not in node1.ifaces + assert len(session.link_manager.links()) == 0 + assert iface1.id not in node1.ifaces + assert iface2.id not in node2.ifaces def test_delete_net_to_node(self, session: Session, ip_prefixes: IpPrefixes): # given node1 = session.add_node(SwitchNode) node2 = session.add_node(CoreNode) iface2_data = ip_prefixes.create_iface(node2) - session.add_link(node1.id, node2.id, iface2_data=iface2_data) - assert node2.get_iface(iface2_data.id) + iface1, iface2 = session.add_link(node1.id, node2.id, iface2_data=iface2_data) + assert len(session.link_manager.links()) == 1 + assert node1.get_iface(iface1.id) + assert node2.get_iface(iface2.id) # when - session.delete_link(node1.id, node2.id, iface2_id=iface2_data.id) + session.delete_link(node1.id, node2.id, iface1.id, iface2.id) # then - assert iface2_data.id not in node2.ifaces + assert len(session.link_manager.links()) == 0 + assert iface1.id not in node1.ifaces + assert iface2.id not in node2.ifaces def test_delete_net_to_net(self, session: Session, ip_prefixes: IpPrefixes): # given node1 = session.add_node(SwitchNode) node2 = session.add_node(SwitchNode) - session.add_link(node1.id, node2.id) - assert node1.get_linked_iface(node2) + iface1, iface2 = session.add_link(node1.id, node2.id) + assert len(session.link_manager.links()) == 1 + assert node1.get_iface(iface1.id) + assert node2.get_iface(iface2.id) # when - session.delete_link(node1.id, node2.id) + session.delete_link(node1.id, node2.id, iface1.id, iface2.id) # then - assert not node1.get_linked_iface(node2) + assert len(session.link_manager.links()) == 0 + assert iface1.id not in node1.ifaces + assert iface2.id not in node2.ifaces def test_delete_node_error(self, session: Session, ip_prefixes: IpPrefixes): # given node1 = session.add_node(SwitchNode) node2 = session.add_node(SwitchNode) - session.add_link(node1.id, node2.id) - assert node1.get_linked_iface(node2) + iface1, iface2 = session.add_link(node1.id, node2.id) + assert len(session.link_manager.links()) == 1 + assert node1.get_iface(iface1.id) + assert node2.get_iface(iface2.id) # when with pytest.raises(CoreError): - session.delete_link(node1.id, INVALID_ID) + session.delete_link(node1.id, INVALID_ID, iface1.id, iface2.id) with pytest.raises(CoreError): - session.delete_link(INVALID_ID, node2.id) + session.delete_link(INVALID_ID, node2.id, iface1.id, iface2.id) def test_delete_net_to_net_error(self, session: Session, ip_prefixes: IpPrefixes): # given node1 = session.add_node(SwitchNode) node2 = session.add_node(SwitchNode) node3 = session.add_node(SwitchNode) - session.add_link(node1.id, node2.id) - assert node1.get_linked_iface(node2) + iface1, iface2 = session.add_link(node1.id, node2.id) + assert len(session.link_manager.links()) == 1 + assert node1.get_iface(iface1.id) + assert node2.get_iface(iface2.id) # when with pytest.raises(CoreError): - session.delete_link(node1.id, node3.id) + session.delete_link(node1.id, node3.id, iface1.id, iface2.id) def test_delete_node_to_net_error(self, session: Session, ip_prefixes: IpPrefixes): # given @@ -330,12 +377,14 @@ class TestLinks: node2 = session.add_node(SwitchNode) node3 = session.add_node(SwitchNode) iface1_data = ip_prefixes.create_iface(node1) - iface1, _ = session.add_link(node1.id, node2.id, iface1_data) - assert iface1 + iface1, iface2 = session.add_link(node1.id, node2.id, iface1_data) + assert len(session.link_manager.links()) == 1 + assert node1.get_iface(iface1.id) + assert node2.get_iface(iface2.id) # when with pytest.raises(CoreError): - session.delete_link(node1.id, node3.id) + session.delete_link(node1.id, node3.id, iface1.id, iface2.id) def test_delete_net_to_node_error(self, session: Session, ip_prefixes: IpPrefixes): # given @@ -343,12 +392,14 @@ class TestLinks: node2 = session.add_node(CoreNode) node3 = session.add_node(SwitchNode) iface2_data = ip_prefixes.create_iface(node2) - _, iface2 = session.add_link(node1.id, node2.id, iface2_data=iface2_data) - assert iface2 + iface1, iface2 = session.add_link(node1.id, node2.id, iface2_data=iface2_data) + assert len(session.link_manager.links()) == 1 + assert node1.get_iface(iface1.id) + assert node2.get_iface(iface2.id) # when with pytest.raises(CoreError): - session.delete_link(node1.id, node3.id) + session.delete_link(node1.id, node3.id, iface1.id, iface2.id) def test_delete_node_to_node_error(self, session: Session, ip_prefixes: IpPrefixes): # given @@ -358,9 +409,10 @@ class TestLinks: iface1_data = ip_prefixes.create_iface(node1) iface2_data = ip_prefixes.create_iface(node2) iface1, iface2 = session.add_link(node1.id, node2.id, iface1_data, iface2_data) - assert iface1 - assert iface2 + assert len(session.link_manager.links()) == 1 + assert node1.get_iface(iface1.id) + assert node2.get_iface(iface2.id) # when with pytest.raises(CoreError): - session.delete_link(node1.id, node3.id) + session.delete_link(node1.id, node3.id, iface1.id, iface2.id) diff --git a/daemon/tests/test_nodes.py b/daemon/tests/test_nodes.py index 3f0fbab1..112045fa 100644 --- a/daemon/tests/test_nodes.py +++ b/daemon/tests/test_nodes.py @@ -60,6 +60,40 @@ class TestNodes: with pytest.raises(CoreError): session.get_node(node.id, CoreNode) + def test_node_add_iface(self, session: Session): + # given + node = session.add_node(CoreNode) + + # when + iface = node.create_iface() + + # then + assert iface.id in node.ifaces + + def test_node_get_iface(self, session: Session): + # given + node = session.add_node(CoreNode) + iface = node.create_iface() + assert iface.id in node.ifaces + + # when + iface2 = node.get_iface(iface.id) + + # then + assert iface == iface2 + + def test_node_delete_iface(self, session: Session): + # given + node = session.add_node(CoreNode) + iface = node.create_iface() + assert iface.id in node.ifaces + + # when + node.delete_iface(iface.id) + + # then + assert iface.id not in node.ifaces + @pytest.mark.parametrize( "mac,expected", [ @@ -70,12 +104,11 @@ class TestNodes: def test_node_set_mac(self, session: Session, mac: str, expected: str): # given node = session.add_node(CoreNode) - switch = session.add_node(SwitchNode) iface_data = InterfaceData() - iface = node.new_iface(switch, iface_data) + iface = node.create_iface(iface_data) # when - node.set_mac(iface.node_id, mac) + iface.set_mac(mac) # then assert str(iface.mac) == expected @@ -86,13 +119,12 @@ class TestNodes: def test_node_set_mac_exception(self, session: Session, mac: str): # given node = session.add_node(CoreNode) - switch = session.add_node(SwitchNode) iface_data = InterfaceData() - iface = node.new_iface(switch, iface_data) + iface = node.create_iface(iface_data) # when with pytest.raises(CoreError): - node.set_mac(iface.node_id, mac) + iface.set_mac(mac) @pytest.mark.parametrize( "ip,expected,is_ip6", @@ -106,12 +138,11 @@ class TestNodes: def test_node_add_ip(self, session: Session, ip: str, expected: str, is_ip6: bool): # given node = session.add_node(CoreNode) - switch = session.add_node(SwitchNode) iface_data = InterfaceData() - iface = node.new_iface(switch, iface_data) + iface = node.create_iface(iface_data) # when - node.add_ip(iface.node_id, ip) + iface.add_ip(ip) # then if is_ip6: @@ -122,14 +153,13 @@ class TestNodes: def test_node_add_ip_exception(self, session): # given node = session.add_node(CoreNode) - switch = session.add_node(SwitchNode) iface_data = InterfaceData() - iface = node.new_iface(switch, iface_data) + iface = node.create_iface(iface_data) ip = "256.168.0.1/24" # when with pytest.raises(CoreError): - node.add_ip(iface.node_id, ip) + iface.add_ip(ip) @pytest.mark.parametrize("net_type", NET_TYPES) def test_net(self, session, net_type): diff --git a/daemon/tests/test_xml.py b/daemon/tests/test_xml.py index 653e77f6..b3e57bef 100644 --- a/daemon/tests/test_xml.py +++ b/daemon/tests/test_xml.py @@ -10,7 +10,7 @@ from core.emulator.session import Session from core.errors import CoreError from core.location.mobility import BasicRangeModel from core.nodes.base import CoreNode -from core.nodes.network import PtpNet, SwitchNode, WlanNode +from core.nodes.network import SwitchNode, WlanNode from core.services.utility import SshService @@ -65,25 +65,18 @@ class TestXml: :param tmpdir: tmpdir to create data in :param ip_prefixes: generates ip addresses for nodes """ - # create ptp - ptp_node = session.add_node(PtpNet) - # create nodes node1 = session.add_node(CoreNode) node2 = session.add_node(CoreNode) - # link nodes to ptp net - for node in [node1, node2]: - iface_data = ip_prefixes.create_iface(node) - session.add_link(node.id, ptp_node.id, iface1_data=iface_data) + # link nodes + iface1_data = ip_prefixes.create_iface(node1) + iface2_data = ip_prefixes.create_iface(node2) + session.add_link(node1.id, node2.id, iface1_data, iface2_data) # instantiate session session.instantiate() - # get ids for nodes - node1_id = node1.id - node2_id = node2.id - # save xml xml_file = tmpdir.join("session.xml") file_path = Path(xml_file.strpath) @@ -98,16 +91,19 @@ class TestXml: # verify nodes have been removed from session with pytest.raises(CoreError): - assert not session.get_node(node1_id, CoreNode) + assert not session.get_node(node1.id, CoreNode) with pytest.raises(CoreError): - assert not session.get_node(node2_id, CoreNode) + assert not session.get_node(node2.id, CoreNode) + # verify no links are known + assert len(session.link_manager.links()) == 0 # load saved xml session.open_xml(file_path, start=True) # verify nodes have been recreated - assert session.get_node(node1_id, CoreNode) - assert session.get_node(node2_id, CoreNode) + assert session.get_node(node1.id, CoreNode) + assert session.get_node(node2.id, CoreNode) + assert len(session.link_manager.links()) == 1 def test_xml_ptp_services( self, session: Session, tmpdir: TemporaryFile, ip_prefixes: IpPrefixes @@ -119,18 +115,15 @@ class TestXml: :param tmpdir: tmpdir to create data in :param ip_prefixes: generates ip addresses for nodes """ - # create ptp - ptp_node = session.add_node(PtpNet) - # create nodes options = NodeOptions(model="host") node1 = session.add_node(CoreNode, options=options) node2 = session.add_node(CoreNode) # link nodes to ptp net - for node in [node1, node2]: - iface_data = ip_prefixes.create_iface(node) - session.add_link(node.id, ptp_node.id, iface1_data=iface_data) + iface1_data = ip_prefixes.create_iface(node1) + iface2_data = ip_prefixes.create_iface(node2) + session.add_link(node1.id, node2.id, iface1_data, iface2_data) # set custom values for node service session.services.set_service(node1.id, SshService.name) @@ -143,10 +136,6 @@ class TestXml: # instantiate session session.instantiate() - # get ids for nodes - node1_id = node1.id - node2_id = node2.id - # save xml xml_file = tmpdir.join("session.xml") file_path = Path(xml_file.strpath) @@ -161,9 +150,9 @@ class TestXml: # verify nodes have been removed from session with pytest.raises(CoreError): - assert not session.get_node(node1_id, CoreNode) + assert not session.get_node(node1.id, CoreNode) with pytest.raises(CoreError): - assert not session.get_node(node2_id, CoreNode) + assert not session.get_node(node2.id, CoreNode) # load saved xml session.open_xml(file_path, start=True) @@ -172,8 +161,8 @@ class TestXml: service = session.services.get_service(node1.id, SshService.name) # verify nodes have been recreated - assert session.get_node(node1_id, CoreNode) - assert session.get_node(node2_id, CoreNode) + assert session.get_node(node1.id, CoreNode) + assert session.get_node(node2.id, CoreNode) assert service.config_data.get(service_file) == file_data def test_xml_mobility( @@ -187,8 +176,8 @@ class TestXml: :param ip_prefixes: generates ip addresses for nodes """ # create wlan - wlan_node = session.add_node(WlanNode) - session.mobility.set_model(wlan_node, BasicRangeModel, {"test": "1"}) + wlan = session.add_node(WlanNode) + session.mobility.set_model(wlan, BasicRangeModel, {"test": "1"}) # create nodes options = NodeOptions(model="mdr") @@ -199,16 +188,11 @@ class TestXml: # link nodes for node in [node1, node2]: iface_data = ip_prefixes.create_iface(node) - session.add_link(node.id, wlan_node.id, iface1_data=iface_data) + session.add_link(node.id, wlan.id, iface1_data=iface_data) # instantiate session session.instantiate() - # get ids for nodes - wlan_id = wlan_node.id - node1_id = node1.id - node2_id = node2.id - # save xml xml_file = tmpdir.join("session.xml") file_path = Path(xml_file.strpath) @@ -223,20 +207,20 @@ class TestXml: # verify nodes have been removed from session with pytest.raises(CoreError): - assert not session.get_node(node1_id, CoreNode) + assert not session.get_node(node1.id, CoreNode) with pytest.raises(CoreError): - assert not session.get_node(node2_id, CoreNode) + assert not session.get_node(node2.id, CoreNode) # load saved xml session.open_xml(file_path, start=True) # retrieve configuration we set originally - value = str(session.mobility.get_config("test", wlan_id, BasicRangeModel.name)) + value = str(session.mobility.get_config("test", wlan.id, BasicRangeModel.name)) # verify nodes and configuration were restored - assert session.get_node(node1_id, CoreNode) - assert session.get_node(node2_id, CoreNode) - assert session.get_node(wlan_id, WlanNode) + assert session.get_node(node1.id, CoreNode) + assert session.get_node(node2.id, CoreNode) + assert session.get_node(wlan.id, WlanNode) assert value == "1" def test_network_to_network(self, session: Session, tmpdir: TemporaryFile): @@ -256,10 +240,6 @@ class TestXml: # instantiate session session.instantiate() - # get ids for nodes - node1_id = switch1.id - node2_id = switch2.id - # save xml xml_file = tmpdir.join("session.xml") file_path = Path(xml_file.strpath) @@ -274,19 +254,19 @@ class TestXml: # verify nodes have been removed from session with pytest.raises(CoreError): - assert not session.get_node(node1_id, SwitchNode) + assert not session.get_node(switch1.id, SwitchNode) with pytest.raises(CoreError): - assert not session.get_node(node2_id, SwitchNode) + assert not session.get_node(switch2.id, SwitchNode) # load saved xml session.open_xml(file_path, start=True) # verify nodes have been recreated - switch1 = session.get_node(node1_id, SwitchNode) - switch2 = session.get_node(node2_id, SwitchNode) + switch1 = session.get_node(switch1.id, SwitchNode) + switch2 = session.get_node(switch2.id, SwitchNode) assert switch1 assert switch2 - assert len(switch1.links() + switch2.links()) == 1 + assert len(session.link_manager.links()) == 1 def test_link_options( self, session: Session, tmpdir: TemporaryFile, ip_prefixes: IpPrefixes @@ -316,10 +296,6 @@ class TestXml: # instantiate session session.instantiate() - # get ids for nodes - node1_id = node1.id - node2_id = switch.id - # save xml xml_file = tmpdir.join("session.xml") file_path = Path(xml_file.strpath) @@ -334,27 +310,25 @@ class TestXml: # verify nodes have been removed from session with pytest.raises(CoreError): - assert not session.get_node(node1_id, CoreNode) + assert not session.get_node(node1.id, CoreNode) with pytest.raises(CoreError): - assert not session.get_node(node2_id, SwitchNode) + assert not session.get_node(switch.id, SwitchNode) # load saved xml session.open_xml(file_path, start=True) # verify nodes have been recreated - assert session.get_node(node1_id, CoreNode) - assert session.get_node(node2_id, SwitchNode) - links = [] - for node_id in session.nodes: - node = session.nodes[node_id] - links += node.links() - link = links[0] - assert options.loss == link.options.loss - assert options.bandwidth == link.options.bandwidth - assert options.jitter == link.options.jitter - assert options.delay == link.options.delay - assert options.dup == link.options.dup - assert options.buffer == link.options.buffer + assert session.get_node(node1.id, CoreNode) + assert session.get_node(switch.id, SwitchNode) + assert len(session.link_manager.links()) == 1 + link = list(session.link_manager.links())[0] + link_options = link.options() + assert options.loss == link_options.loss + assert options.bandwidth == link_options.bandwidth + assert options.jitter == link_options.jitter + assert options.delay == link_options.delay + assert options.dup == link_options.dup + assert options.buffer == link_options.buffer def test_link_options_ptp( self, session: Session, tmpdir: TemporaryFile, ip_prefixes: IpPrefixes @@ -385,10 +359,6 @@ class TestXml: # instantiate session session.instantiate() - # get ids for nodes - node1_id = node1.id - node2_id = node2.id - # save xml xml_file = tmpdir.join("session.xml") file_path = Path(xml_file.strpath) @@ -403,27 +373,25 @@ class TestXml: # verify nodes have been removed from session with pytest.raises(CoreError): - assert not session.get_node(node1_id, CoreNode) + assert not session.get_node(node1.id, CoreNode) with pytest.raises(CoreError): - assert not session.get_node(node2_id, CoreNode) + assert not session.get_node(node2.id, CoreNode) # load saved xml session.open_xml(file_path, start=True) # verify nodes have been recreated - assert session.get_node(node1_id, CoreNode) - assert session.get_node(node2_id, CoreNode) - links = [] - for node_id in session.nodes: - node = session.nodes[node_id] - links += node.links() - link = links[0] - assert options.loss == link.options.loss - assert options.bandwidth == link.options.bandwidth - assert options.jitter == link.options.jitter - assert options.delay == link.options.delay - assert options.dup == link.options.dup - assert options.buffer == link.options.buffer + assert session.get_node(node1.id, CoreNode) + assert session.get_node(node2.id, CoreNode) + assert len(session.link_manager.links()) == 1 + link = list(session.link_manager.links())[0] + link_options = link.options() + assert options.loss == link_options.loss + assert options.bandwidth == link_options.bandwidth + assert options.jitter == link_options.jitter + assert options.delay == link_options.delay + assert options.dup == link_options.dup + assert options.buffer == link_options.buffer def test_link_options_bidirectional( self, session: Session, tmpdir: TemporaryFile, ip_prefixes: IpPrefixes @@ -450,7 +418,9 @@ class TestXml: options1.dup = 5 options1.jitter = 5 options1.buffer = 50 - session.add_link(node1.id, node2.id, iface1_data, iface2_data, options1) + iface1, iface2 = session.add_link( + node1.id, node2.id, iface1_data, iface2_data, options1 + ) options2 = LinkOptions() options2.unidirectional = 1 options2.bandwidth = 10000 @@ -459,17 +429,11 @@ class TestXml: options2.dup = 10 options2.jitter = 10 options2.buffer = 100 - session.update_link( - node2.id, node1.id, iface2_data.id, iface1_data.id, options2 - ) + session.update_link(node2.id, node1.id, iface2.id, iface1.id, options2) # instantiate session session.instantiate() - # get ids for nodes - node1_id = node1.id - node2_id = node2.id - # save xml xml_file = tmpdir.join("session.xml") file_path = Path(xml_file.strpath) @@ -484,32 +448,26 @@ class TestXml: # verify nodes have been removed from session with pytest.raises(CoreError): - assert not session.get_node(node1_id, CoreNode) + assert not session.get_node(node1.id, CoreNode) with pytest.raises(CoreError): - assert not session.get_node(node2_id, CoreNode) + assert not session.get_node(node2.id, CoreNode) # load saved xml session.open_xml(file_path, start=True) # verify nodes have been recreated - assert session.get_node(node1_id, CoreNode) - assert session.get_node(node2_id, CoreNode) - links = [] - for node_id in session.nodes: - node = session.nodes[node_id] - links += node.links() - assert len(links) == 2 - link1 = links[0] - link2 = links[1] - assert options1.bandwidth == link1.options.bandwidth - assert options1.delay == link1.options.delay - assert options1.loss == link1.options.loss - assert options1.dup == link1.options.dup - assert options1.jitter == link1.options.jitter - assert options1.buffer == link1.options.buffer - assert options2.bandwidth == link2.options.bandwidth - assert options2.delay == link2.options.delay - assert options2.loss == link2.options.loss - assert options2.dup == link2.options.dup - assert options2.jitter == link2.options.jitter - assert options2.buffer == link2.options.buffer + assert session.get_node(node1.id, CoreNode) + assert session.get_node(node2.id, CoreNode) + assert len(session.link_manager.links()) == 1 + assert options1.bandwidth == iface1.options.bandwidth + assert options1.delay == iface1.options.delay + assert options1.loss == iface1.options.loss + assert options1.dup == iface1.options.dup + assert options1.jitter == iface1.options.jitter + assert options1.buffer == iface1.options.buffer + assert options2.bandwidth == iface2.options.bandwidth + assert options2.delay == iface2.options.delay + assert options2.loss == iface2.options.loss + assert options2.dup == iface2.options.dup + assert options2.jitter == iface2.options.jitter + assert options2.buffer == iface2.options.buffer diff --git a/docs/architecture.md b/docs/architecture.md index ceaf7cc2..410b37ac 100644 --- a/docs/architecture.md +++ b/docs/architecture.md @@ -10,17 +10,14 @@ * Nodes are created using Linux namespaces * Links are created using Linux bridges and virtual ethernet peers * Packets sent over links are manipulated using traffic control - * Controlled via the CORE GUI - * Provides both a custom TLV API and gRPC API - * Python program that leverages a small C binary for node creation + * Provides gRPC API * core-gui - * GUI and daemon communicate over the custom TLV API + * GUI and daemon communicate over gRPC API * Drag and drop creation for nodes and links * Can launch terminals for emulated nodes in running sessions * Can save/open scenario files to recreate previous sessions - * TCL/TK program -* coresendmsg - * Command line utility for sending TLV API messages to the core-daemon +* vnoded + * Command line utility for creating CORE node namespaces * vcmd * Command line utility for sending shell commands to nodes @@ -55,21 +52,10 @@ Nftables provides Ethernet frame filtering on Linux bridges. Wireless networks a emulated by controlling which interfaces can send and receive with nftables rules. -## Prior Work - -The Tcl/Tk CORE GUI was originally derived from the open source -[IMUNES](http://imunes.net) project from the University of Zagreb as a custom -project within Boeing Research and Technology's Network Technology research -group in 2004. Since then they have developed the CORE framework to use Linux -namespacing, have developed a Python framework, and made numerous user and -kernel-space developments, such as support for wireless networks, IPsec, -distribute emulation, simulation integration, and more. The IMUNES project -also consists of userspace and kernel components. - ## Open Source Project and Resources CORE has been released by Boeing to the open source community under the BSD license. If you find CORE useful for your work, please contribute back to the project. Contributions can be as simple as reporting a bug, dropping a line of -encouragement or technical suggestions to the mailing lists, or can also -include submitting patches or maintaining aspects of the tool. +encouragement, or can also include submitting patches or maintaining aspects +of the tool. diff --git a/docs/devguide.md b/docs/devguide.md index f8524da4..fe25e306 100644 --- a/docs/devguide.md +++ b/docs/devguide.md @@ -5,7 +5,7 @@ ## Repository Overview -The CORE source consists of several different programming languages for +The CORE source consists of several programming languages for historical reasons. Current development focuses on the Python modules and daemon. Here is a brief description of the source directories. @@ -13,7 +13,6 @@ daemon. Here is a brief description of the source directories. |-----------|--------------------------------------------------------------------------------------| | daemon | Python CORE daemon/gui code that handles receiving API calls and creating containers | | docs | Markdown Documentation currently hosted on GitHub | -| gui | Tcl/Tk GUI | | man | Template files for creating man pages for various CORE command line utilities | | netns | C program for creating CORE containers | @@ -58,7 +57,7 @@ sudo core-daemon # run python gui core-pygui -# run tcl gui +# run gui core-gui # run mocked unit tests diff --git a/docs/diagrams/architecture.plantuml b/docs/diagrams/architecture.plantuml index a43494d5..403886d9 100644 --- a/docs/diagrams/architecture.plantuml +++ b/docs/diagrams/architecture.plantuml @@ -1,5 +1,5 @@ @startuml -skinparam { +skinparam { RoundCorner 8 ComponentStyle uml2 ComponentBorderColor #Black @@ -9,7 +9,6 @@ skinparam { package User { component "core-gui" as gui #DeepSkyBlue - component "coresendmsg" #DeepSkyBlue component "python scripts" as scripts #DeepSkyBlue component vcmd #DeepSkyBlue } @@ -19,11 +18,11 @@ package Server { package Python { component core #LightSteelBlue } -package "Linux System" { +package "Linux System" { component nodes #SpringGreen [ nodes (linux namespaces) - ] + ] component links #SpringGreen [ links (bridging and traffic manipulation) @@ -31,19 +30,15 @@ package "Linux System" { } package API { - interface TLV as tlv interface gRPC as grpc } -gui <..> tlv -coresendmsg <..> tlv -scripts <..> tlv +gui <..> grpc scripts <..> grpc -tlv -- daemon grpc -- daemon scripts -- core daemon - core core <..> nodes core <..> links vcmd <..> nodes -@enduml \ No newline at end of file +@enduml diff --git a/docs/diagrams/workflow.plantuml b/docs/diagrams/workflow.plantuml index 9aa1c04f..cff943ad 100644 --- a/docs/diagrams/workflow.plantuml +++ b/docs/diagrams/workflow.plantuml @@ -1,11 +1,11 @@ @startuml -skinparam { +skinparam { RoundCorner 8 StateBorderColor #Black StateBackgroundColor #LightSteelBlue } -Definition: Session XML/IMN +Definition: Session XML Definition: GUI Drawing Definition: Scripts @@ -37,4 +37,4 @@ Configuration -> Instantiation Instantiation -> Runtime Runtime -> Datacollect Datacollect -> Shutdown -@enduml \ No newline at end of file +@enduml diff --git a/docs/distributed.md b/docs/distributed.md index 2d46ac96..65429f03 100644 --- a/docs/distributed.md +++ b/docs/distributed.md @@ -124,7 +124,7 @@ connect_kwargs: {"key_filename": "/home/user/.ssh/core"} Within the core-gui navigate to menu option: -**Session -> Emulation servers...** +**Session -> Servers...** Within the dialog box presented, add or modify an existing server if present to use the name, address, and port for the a server you plan to use. @@ -132,12 +132,6 @@ to use the name, address, and port for the a server you plan to use. Server configurations are loaded and written to in a configuration file for the GUI. -**~/.core/servers.conf** -```conf -# name address port -server2 192.168.0.2 4038 -``` - ## Assigning Nodes The user needs to assign nodes to emulation servers in the scenario. Making no diff --git a/docs/emane.md b/docs/emane.md index d4f4e42c..dfa30897 100644 --- a/docs/emane.md +++ b/docs/emane.md @@ -80,7 +80,7 @@ EMANE. An example emane section from the **core.conf** file is shown below: emane_platform_port = 8101 emane_transform_port = 8201 emane_event_monitor = False -#emane_models_dir = /home/username/.core/myemane +#emane_models_dir = /home//.coregui/custom_emane # EMANE log level range [0,4] default: 2 emane_log_level = 2 emane_realtime = True @@ -242,7 +242,7 @@ directory to find the generated EMANE xml files. One easy way to view this information is by double-clicking one of the virtual nodes and listing the files in the shell. -![](static/single-pc-emane.png) +![](static/emane-single-pc.png) ## Distributed EMANE @@ -277,7 +277,7 @@ it will be emulated locally. Using the EMANE node configuration dialog. You can change the EMANE model being used, along with changing any configuration setting from their defaults. -![](static/distributed-emane-configuration.png) +![](static/emane-configuration.png) > **NOTE:** Here is a quick checklist for distributed emulation with EMANE. @@ -304,5 +304,3 @@ Double-clicking on a node during runtime will cause the GUI to attempt to SSH to the emulation server for that node and run an interactive shell. The public key SSH configuration should be tested with all emulation servers prior to starting the emulation. - -![](static/distributed-emane-network.png) diff --git a/docs/emane/antenna.md b/docs/emane/antenna.md index 20c98304..c8a86eaa 100644 --- a/docs/emane/antenna.md +++ b/docs/emane/antenna.md @@ -335,7 +335,7 @@ Create `/tmp/emane/blockageaft.xml` with the following contents. ## Run Demo 1. Select `Open...` within the GUI 1. Load `emane-demo-antenna.xml` -1. Click ![Start Button](../static/gui/start.gif) +1. Click ![Start Button](../static/gui/start.png) 1. After startup completes, double click n1 to bring up the nodes terminal ## Example Demo diff --git a/docs/emane/eel.md b/docs/emane/eel.md index 0f41c357..ca094542 100644 --- a/docs/emane/eel.md +++ b/docs/emane/eel.md @@ -11,7 +11,7 @@ for more specifics. ## Run Demo 1. Select `Open...` within the GUI 1. Load `emane-demo-eel.xml` -1. Click ![Start Button](../static/gui/start.gif) +1. Click ![Start Button](../static/gui/start.png) 1. After startup completes, double click n1 to bring up the nodes terminal ## Example Demo diff --git a/docs/emane/files.md b/docs/emane/files.md index 62729ac8..c9bc35e8 100644 --- a/docs/emane/files.md +++ b/docs/emane/files.md @@ -12,7 +12,7 @@ may provide more helpful details. ## Run Demo 1. Select `Open...` within the GUI 1. Load `emane-demo-files.xml` -1. Click ![Start Button](../static/gui/start.gif) +1. Click ![Start Button](../static/gui/start.png) 1. After startup completes, double click n1 to bring up the nodes terminal ## Example Demo @@ -21,14 +21,14 @@ case we are running the RF Pipe model. ### Generated Files -|Name|Description| -|---|---| -|\-platform.xml|configuration file for the emulator instances| -|\-nem.xml|configuration for creating a NEM| -|\-mac.xml|configuration for defining a NEMs MAC layer| -|\-phy.xml|configuration for defining a NEMs PHY layer| -|\-trans-virtual.xml|configuration when a virtual transport is being used| -|\-trans.xml|configuration when a raw transport is being used| +| Name | Description | +|-------------------------------------|------------------------------------------------------| +| \-platform.xml | configuration file for the emulator instances | +| \-nem.xml | configuration for creating a NEM | +| \-mac.xml | configuration for defining a NEMs MAC layer | +| \-phy.xml | configuration for defining a NEMs PHY layer | +| \-trans-virtual.xml | configuration when a virtual transport is being used | +| \-trans.xml | configuration when a raw transport is being used | ### Listing File Below are the files within n1 after starting the demo session. diff --git a/docs/emane/gpsd.md b/docs/emane/gpsd.md index 06c44198..f20cc8fe 100644 --- a/docs/emane/gpsd.md +++ b/docs/emane/gpsd.md @@ -13,7 +13,7 @@ may provide more helpful details. ## Run Demo 1. Select `Open...` within the GUI 1. Load `emane-demo-gpsd.xml` -1. Click ![Start Button](../static/gui/start.gif) +1. Click ![Start Button](../static/gui/start.png) 1. After startup completes, double click n1 to bring up the nodes terminal ## Example Demo diff --git a/docs/emane/precomputed.md b/docs/emane/precomputed.md index f8064c97..53da75eb 100644 --- a/docs/emane/precomputed.md +++ b/docs/emane/precomputed.md @@ -11,7 +11,7 @@ for more specifics. ## Run Demo 1. Select `Open...` within the GUI 1. Load `emane-demo-precomputed.xml` -1. Click ![Start Button](../static/gui/start.gif) +1. Click ![Start Button](../static/gui/start.png) 1. After startup completes, double click n1 to bring up the nodes terminal ## Example Demo diff --git a/docs/gui.md b/docs/gui.md index d59f30c5..633cf829 100644 --- a/docs/gui.md +++ b/docs/gui.md @@ -1,12 +1,10 @@ -# Using the CORE GUI +# CORE GUI * Table of Contents {:toc} -The following image shows the CORE GUI: -![](static/core_screenshot.png) - +![](static/core-gui.png) ## Overview @@ -28,45 +26,54 @@ Beyond installing CORE, you must have the CORE daemon running. This is done on the command line with either systemd or sysv. ```shell -# systemd +# systemd service sudo systemctl daemon-reload sudo systemctl start core-daemon -# sysv -sudo service core-daemon start -``` - -You can also invoke the daemon directly from the command line, which can be -useful if you'd like to see the logging output directly. - -```shell # direct invocation sudo core-daemon ``` +## GUI Files + +The GUI will create a directory in your home directory on first run called +~/.coregui. This directory will help layout various files that the GUI may use. + +* .coregui/ + * backgrounds/ + * place backgrounds used for display in the GUI + * custom_emane/ + * place to keep custom emane models to use with the core-daemon + * custom_services/ + * place to keep custom services to use with the core-daemon + * icons/ + * icons the GUI uses along with customs icons desired + * mobility/ + * place to keep custom mobility files + * scripts/ + * place to keep core related scripts + * xmls/ + * place to keep saved session xml files + * gui.log + * log file when running the gui, look here when issues occur for exceptions etc + * config.yaml + * configuration file used to save/load various gui related settings (custom nodes, layouts, addresses, etc) + ## Modes of Operation The CORE GUI has two primary modes of operation, **Edit** and **Execute** -modes. Running the GUI, by typing **core-gui** with no options, starts in -Edit mode. Nodes are drawn on a blank canvas using the toolbar on the left +modes. Running the GUI, by typing **core-pygui** with no options, starts in +Edit mode. Nodes are drawn on a blank canvas using the toolbar on the left and configured from right-click menus or by double-clicking them. The GUI does not need to be run as root. -Once editing is complete, pressing the green **Start** button (or choosing -**Execute** from the **Session** menu) instantiates the topology within the -Linux kernel and enters Execute mode. In execute mode, the user can interact -with the running emulated machines by double-clicking or right-clicking on -them. The editing toolbar disappears and is replaced by an execute toolbar, -which provides tools while running the emulation. Pressing the red **Stop** -button (or choosing **Terminate** from the **Session** menu) will destroy -the running emulation and return CORE to Edit mode. - -CORE can be started directly in Execute mode by specifying **--start** and a -topology file on the command line: - -```shell -core-gui --start ~/.core/configs/myfile.imn -``` +Once editing is complete, pressing the green **Start** button instantiates +the topology and enters Execute mode. In execute mode, +the user can interact with the running emulated machines by double-clicking or +right-clicking on them. The editing toolbar disappears and is replaced by an +execute toolbar, which provides tools while running the emulation. Pressing +the red **Stop** button will destroy the running emulation and return CORE +to Edit mode. Once the emulation is running, the GUI can be closed, and a prompt will appear asking if the emulation should be terminated. The emulation may be left @@ -74,11 +81,22 @@ running and the GUI can reconnect to an existing session at a later time. The GUI can be run as a normal user on Linux. -The GUI can be connected to a different address or TCP port using the -**--address** and/or **--port** options. The defaults are shown below. +The GUI currently provides the following options on startup. ```shell -core-gui --address 127.0.0.1 --port 4038 +usage: core-gui [-h] [-l {DEBUG,INFO,WARNING,ERROR,CRITICAL}] [-p] + [-s SESSION] [--create-dir] + +CORE Python GUI + +optional arguments: + -h, --help show this help message and exit + -l {DEBUG,INFO,WARNING,ERROR,CRITICAL}, --level {DEBUG,INFO,WARNING,ERROR,CRITICAL} + logging level + -p, --proxy enable proxy + -s SESSION, --session SESSION + session id to join + --create-dir create gui directory and exit ``` ## Toolbar @@ -95,22 +113,21 @@ sub-menus, which appear when you click on their group icon. | Icon | Name | Description | |----------------------------|----------------|----------------------------------------------------------------------------------------| -| ![](static/gui/select.gif) | Selection Tool | Tool for selecting, moving, configuring nodes. | -| ![](static/gui/start.gif) | Start Button | Starts Execute mode, instantiates the emulation. | -| ![](static/gui/link.gif) | Link | Allows network links to be drawn between two nodes by clicking and dragging the mouse. | +| ![](static/gui/select.png) | Selection Tool | Tool for selecting, moving, configuring nodes. | +| ![](static/gui/start.png) | Start Button | Starts Execute mode, instantiates the emulation. | +| ![](static/gui/link.png) | Link | Allows network links to be drawn between two nodes by clicking and dragging the mouse. | ### CORE Nodes These nodes will create a new node container and run associated services. -| Icon | Name | Description | -|-----------------------------------------|---------|------------------------------------------------------------------------------| -| ![](static/gui/router.gif) | Router | Runs Quagga OSPFv2 and OSPFv3 routing to forward packets. | -| ![](static/gui/host.gif) | Host | Emulated server machine having a default route, runs SSH server. | -| ![](static/gui/pc.gif) | PC | Basic emulated machine having a default route, runs no processes by default. | -| ![](static/gui/mdr.gif) | MDR | Runs Quagga OSPFv3 MDR routing for MANET-optimized routing. | -| ![](static/gui/router_green.gif) | PRouter | Physical router represents a real testbed machine. | -| ![](static/gui/document-properties.gif) | Edit | Bring up the custom node dialog. | +| Icon | Name | Description | +|----------------------------|---------|------------------------------------------------------------------------------| +| ![](static/gui/router.png) | Router | Runs Quagga OSPFv2 and OSPFv3 routing to forward packets. | +| ![](static/gui/host.png) | Host | Emulated server machine having a default route, runs SSH server. | +| ![](static/gui/pc.png) | PC | Basic emulated machine having a default route, runs no processes by default. | +| ![](static/gui/mdr.png) | MDR | Runs Quagga OSPFv3 MDR routing for MANET-optimized routing. | +| ![](static/gui/router.png) | PRouter | Physical router represents a real testbed machine. | ### Network Nodes @@ -119,20 +136,20 @@ purpose described below. | Icon | Name | Description | |-------------------------------|--------------|----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| -| ![](static/gui/hub.gif) | Hub | Ethernet hub forwards incoming packets to every connected node. | -| ![](static/gui/lanswitch.gif) | Switch | Ethernet switch intelligently forwards incoming packets to attached hosts using an Ethernet address hash table. | -| ![](static/gui/wlan.gif) | Wireless LAN | When routers are connected to this WLAN node, they join a wireless network and an antenna is drawn instead of a connecting line; the WLAN node typically controls connectivity between attached wireless nodes based on the distance between them. | -| ![](static/gui/rj45.gif) | RJ45 | RJ45 Physical Interface Tool, emulated nodes can be linked to real physical interfaces; using this tool, real networks and devices can be physically connected to the live-running emulation. | -| ![](static/gui/tunnel.gif) | Tunnel | Tool allows connecting together more than one CORE emulation using GRE tunnels. | +| ![](static/gui/hub.png) | Hub | Ethernet hub forwards incoming packets to every connected node. | +| ![](static/gui/lanswitch.png) | Switch | Ethernet switch intelligently forwards incoming packets to attached hosts using an Ethernet address hash table. | +| ![](static/gui/wlan.png) | Wireless LAN | When routers are connected to this WLAN node, they join a wireless network and an antenna is drawn instead of a connecting line; the WLAN node typically controls connectivity between attached wireless nodes based on the distance between them. | +| ![](static/gui/rj45.png) | RJ45 | RJ45 Physical Interface Tool, emulated nodes can be linked to real physical interfaces; using this tool, real networks and devices can be physically connected to the live-running emulation. | +| ![](static/gui/tunnel.png) | Tunnel | Tool allows connecting together more than one CORE emulation using GRE tunnels. | ### Annotation Tools | Icon | Name | Description | |-------------------------------|-----------|---------------------------------------------------------------------| -| ![](static/gui/marker.gif) | Marker | For drawing marks on the canvas. | -| ![](static/gui/oval.gif) | Oval | For drawing circles on the canvas that appear in the background. | -| ![](static/gui/rectangle.gif) | Rectangle | For drawing rectangles on the canvas that appear in the background. | -| ![](static/gui/text.gif) | Text | For placing text captions on the canvas. | +| ![](static/gui/marker.png) | Marker | For drawing marks on the canvas. | +| ![](static/gui/oval.png) | Oval | For drawing circles on the canvas that appear in the background. | +| ![](static/gui/rectangle.png) | Rectangle | For drawing rectangles on the canvas that appear in the background. | +| ![](static/gui/text.png) | Text | For placing text captions on the canvas. | ### Execution Toolbar @@ -140,14 +157,12 @@ When the Start button is pressed, CORE switches to Execute mode, and the Edit toolbar on the left of the CORE window is replaced with the Execution toolbar Below are the items on this toolbar, starting from the top. -| Icon | Name | Description | -|-----------------------------|-----------------------|-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| -| ![](static/gui/select.gif) | Selection Tool | In Execute mode, the Selection Tool can be used for moving nodes around the canvas, and double-clicking on a node will open a shell window for that node; right-clicking on a node invokes a pop-up menu of run-time options for that node. | -| ![](static/gui/stop.gif) | Stop Button | Stops Execute mode, terminates the emulation, returns CORE to edit mode. | -| ![](static/gui/observe.gif) | Observer Widgets Tool | Clicking on this magnifying glass icon invokes a menu for easily selecting an Observer Widget. The icon has a darker gray background when an Observer Widget is active, during which time moving the mouse over a node will pop up an information display for that node. | -| ![](static/gui/marker.gif) | Marker | For drawing freehand lines on the canvas, useful during demonstrations; markings are not saved. | -| ![](static/gui/twonode.gif) | Two-node Tool | Click to choose a starting and ending node, and run a one-time *traceroute* between those nodes or a continuous *ping -R* between nodes. The output is displayed in real time in a results box, while the IP addresses are parsed and the complete network path is highlighted on the CORE display. | -| ![](static/gui/run.gif) | Run Tool | This tool allows easily running a command on all or a subset of all nodes. A list box allows selecting any of the nodes. A text entry box allows entering any command. The command should return immediately, otherwise the display will block awaiting response. The *ping* command, for example, with no parameters, is not a good idea. The result of each command is displayed in a results box. The first occurrence of the special text "NODE" will be replaced with the node name. The command will not be attempted to run on nodes that are not routers, PCs, or hosts, even if they are selected. | +| Icon | Name | Description | +|----------------------------|----------------|-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| +| ![](static/gui/stop.png) | Stop Button | Stops Execute mode, terminates the emulation, returns CORE to edit mode. | +| ![](static/gui/select.png) | Selection Tool | In Execute mode, the Selection Tool can be used for moving nodes around the canvas, and double-clicking on a node will open a shell window for that node; right-clicking on a node invokes a pop-up menu of run-time options for that node. | +| ![](static/gui/marker.png) | Marker | For drawing freehand lines on the canvas, useful during demonstrations; markings are not saved. | +| ![](static/gui/run.png) | Run Tool | This tool allows easily running a command on all or a subset of all nodes. A list box allows selecting any of the nodes. A text entry box allows entering any command. The command should return immediately, otherwise the display will block awaiting response. The *ping* command, for example, with no parameters, is not a good idea. The result of each command is displayed in a results box. The first occurrence of the special text "NODE" will be replaced with the node name. The command will not be attempted to run on nodes that are not routers, PCs, or hosts, even if they are selected. | ## Menu @@ -157,98 +172,61 @@ menu, by clicking the dashed line at the top. ### File Menu -The File menu contains options for manipulating the **.imn** Configuration -Files. Generally, these menu items should not be used in Execute mode. +The File menu contains options for saving and opening saved sessions. -| Option | Description | -|------------------------------------|-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| -| New | This starts a new file with an empty canvas. | -| Open | Invokes the File Open dialog box for selecting a new **.imn** or XML file to open. You can change the default path used for this dialog in the Preferences Dialog. | -| Save | Saves the current topology. If you have not yet specified a file name, the Save As dialog box is invoked. | -| Save As XML | Invokes the Save As dialog box for selecting a new **.xml** file for saving the current configuration in the XML file. | -| Save As imn | Invokes the Save As dialog box for selecting a new **.imn** topology file for saving the current configuration. Files are saved in the *IMUNES network configuration* file. | -| Export Python script | Prints Python snippets to the console, for inclusion in a CORE Python script. | -| Execute XML or Python script | Invokes a File Open dialog box for selecting an XML file to run or a Python script to run and automatically connect to. If a Python script, the script must create a new CORE Session and add this session to the daemon's list of sessions in order for this to work. | -| Execute Python script with options | Invokes a File Open dialog box for selecting a Python script to run and automatically connect to. After a selection is made, a Python Script Options dialog box is invoked to allow for command-line options to be added. The Python script must create a new CORE Session and add this session to the daemon's list of sessions in order for this to work. | -| Open current file in editor | This opens the current topology file in the **vim** text editor. First you need to save the file. Once the file has been edited with a text editor, you will need to reload the file to see your changes. The text editor can be changed from the Preferences Dialog. | -| Print | This uses the Tcl/Tk postscript command to print the current canvas to a printer. A dialog is invoked where you can specify a printing command, the default being **lpr**. The postscript output is piped to the print command. | -| Save screenshot | Saves the current canvas as a postscript graphic file. | -| Recently used files | Above the Quit menu command is a list of recently use files, if any have been opened. You can clear this list in the Preferences dialog box. You can specify the number of files to keep in this list from the Preferences dialog. Click on one of the file names listed to open that configuration file. | -| Quit | The Quit command should be used to exit the CORE GUI. CORE may prompt for termination if you are currently in Execute mode. Preferences and the recently-used files list are saved. | +| Option | Description | +|-----------------------|-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| +| New Session | This starts a new session with an empty canvas. | +| Save | Saves the current topology. If you have not yet specified a file name, the Save As dialog box is invoked. | +| Save As | Invokes the Save As dialog box for selecting a new **.xml** file for saving the current configuration in the XML file. | +| Open | Invokes the File Open dialog box for selecting a new XML file to open. | +| Recently used files | Above the Quit menu command is a list of recently use files, if any have been opened. You can clear this list in the Preferences dialog box. You can specify the number of files to keep in this list from the Preferences dialog. Click on one of the file names listed to open that configuration file. | +| Execute Python Script | Invokes a File Open dialog box for selecting a Python script to run and automatically connect to. After a selection is made, a Python Script Options dialog box is invoked to allow for command-line options to be added. The Python script must create a new CORE Session and add this session to the daemon's list of sessions in order for this to work. | +| Quit | The Quit command should be used to exit the CORE GUI. CORE may prompt for termination if you are currently in Execute mode. Preferences and the recently-used files list are saved. | ### Edit Menu -| Option | Description | -|------------------|-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| -| Undo | Attempts to undo the last edit in edit mode. | -| Redo | Attempts to redo an edit that has been undone. | -| Cut, Copy, Paste | Used to cut, copy, and paste a selection. When nodes are pasted, their node numbers are automatically incremented, and existing links are preserved with new IP addresses assigned. Services and their customizations are copied to the new node, but care should be taken as node IP addresses have changed with possibly old addresses remaining in any custom service configurations. Annotations may also be copied and pasted. | -| Select All | Selects all items on the canvas. Selected items can be moved as a group. | -| Select Adjacent | Select all nodes that are linked to the already selected node(s). For wireless nodes this simply selects the WLAN node(s) that the wireless node belongs to. You can use this by clicking on a node and pressing CTRL+N to select the adjacent nodes. | -| Find... | Invokes the *Find* dialog box. The Find dialog can be used to search for nodes by name or number. Results are listed in a table that includes the node or link location and details such as IP addresses or link parameters. Clicking on a result will focus the canvas on that node or link, switching canvases if necessary. | -| Clear marker | Clears any annotations drawn with the marker tool. Also clears any markings used to indicate a node's status. | -| Preferences... | Invokes the Preferences dialog box. | +| Option | Description | +|--------------------------|---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| +| Preferences | Invokes the Preferences dialog box. | +| Custom Nodes | Custom node creation dialog box. | +| Undo | (Disabled) Attempts to undo the last edit in edit mode. | +| Redo | (Disabled) Attempts to redo an edit that has been undone. | +| Cut, Copy, Paste, Delete | Used to cut, copy, paste, and delete a selection. When nodes are pasted, their node numbers are automatically incremented, and existing links are preserved with new IP addresses assigned. Services and their customizations are copied to the new node, but care should be taken as node IP addresses have changed with possibly old addresses remaining in any custom service configurations. Annotations may also be copied and pasted. | ### Canvas Menu -The canvas menu provides commands for adding, removing, changing, and switching -to different editing canvases. +The canvas menu provides commands related to the editing canvas. -| Option | Description | -|-----------------------------|-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| -| New | Creates a new empty canvas at the right of all existing canvases. | -| Manage... | Invokes the *Manage Canvases* dialog box, where canvases may be renamed and reordered, and you can easily switch to one of the canvases by selecting it. | -| Delete | Deletes the current canvas and all items that it contains. | -| Size/scale... | Invokes a Canvas Size and Scale dialog that allows configuring the canvas size, scale, and geographic reference point. The size controls allow changing the width and height of the current canvas, in pixels or meters. The scale allows specifying how many meters are equivalent to 100 pixels. The reference point controls specify the latitude, longitude, and altitude reference point used to convert between geographic and Cartesian coordinate systems. By clicking the *Save as default* option, all new canvases will be created with these properties. The default canvas size can also be changed in the Preferences dialog box. | -| Wallpaper... | Used for setting the canvas background image. | -| Previous, Next, First, Last | Used for switching the active canvas to the first, last, or adjacent canvas. | +| Option | Description | +|------------|-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| +| Size/scale | Invokes a Canvas Size and Scale dialog that allows configuring the canvas size, scale, and geographic reference point. The size controls allow changing the width and height of the current canvas, in pixels or meters. The scale allows specifying how many meters are equivalent to 100 pixels. The reference point controls specify the latitude, longitude, and altitude reference point used to convert between geographic and Cartesian coordinate systems. By clicking the *Save as default* option, all new canvases will be created with these properties. The default canvas size can also be changed in the Preferences dialog box. | +| Wallpaper | Used for setting the canvas background image. | ### View Menu -The View menu features items for controlling what is displayed on the drawing -canvas. +The View menu features items for toggling on and off their display on the canvas. -| Option | Description | -|-------------------|--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| -| Show | Opens a submenu of items that can be displayed or hidden, such as interface names, addresses, and labels. Use these options to help declutter the display. These options are generally saved in the topology files, so scenarios have a more consistent look when copied from one computer to another. | -| Show hidden nodes | Reveal nodes that have been hidden. Nodes are hidden by selecting one or more nodes, right-clicking one and choosing *hide*. | -| Locked | Toggles locked view; when the view is locked, nodes cannot be moved around on the canvas with the mouse. This could be useful when sharing the topology with someone and you do not expect them to change things. | -| 3D GUI... | Launches a 3D GUI by running the command defined under Preferences, *3D GUI command*. This is typically a script that runs the SDT3D display. SDT is the Scripted Display Tool from NRL that is based on NASA's Java-based WorldWind virtual globe software. | -| Zoom In | Magnifies the display. You can also zoom in by clicking *zoom 100%* label in the status bar, or by pressing the **+** (plus) key. | -| Zoom Out | Reduces the size of the display. You can also zoom out by right-clicking *zoom 100%* label in the status bar or by pressing the **-** (minus) key. | +| Option | Description | +|-----------------|-----------------------------------| +| Interface Names | Display interface names on links. | +| IPv4 Addresses | Display IPv4 addresses on links. | +| IPv6 Addresses | Display IPv6 addresses on links. | +| Node Labels | Display node names. | +| Link Labels | Display link labels. | +| Annotations | Display annotations. | +| Canvas Grid | Display the canvas grid. | ### Tools Menu The tools menu lists different utility functions. -| Option | Description | -|------------------------|--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| -| Autorearrange all | Automatically arranges all nodes on the canvas. Nodes having a greater number of links are moved to the center. This mode can continue to run while placing nodes. To turn off this autorearrange mode, click on a blank area of the canvas with the select tool, or choose this menu option again. | -| Autorearrange selected | Automatically arranges the selected nodes on the canvas. | -| Align to grid | Moves nodes into a grid formation, starting with the smallest-numbered node in the upper-left corner of the canvas, arranging nodes in vertical columns. | -| Traffic... | Invokes the CORE Traffic Flows dialog box, which allows configuring, starting, and stopping MGEN traffic flows for the emulation. | -| IP addresses... | Invokes the IP Addresses dialog box for configuring which IPv4/IPv6 prefixes are used when automatically addressing new interfaces. | -| MAC addresses... | Invokes the MAC Addresses dialog box for configuring the starting number used as the lowest byte when generating each interface MAC address. This value should be changed when tunneling between CORE emulations to prevent MAC address conflicts. | -| Build hosts file... | Invokes the Build hosts File dialog box for generating **/etc/hosts** file entries based on IP addresses used in the emulation. | -| Renumber nodes... | Invokes the Renumber Nodes dialog box, which allows swapping one node number with another in a few clicks. | -| Experimental... | Menu of experimental options, such as a tool to convert ns-2 scripts to IMUNES imn topologies, supporting only basic ns-2 functionality, and a tool for automatically dividing up a topology into partitions. | -| Topology generator | Opens a submenu of topologies to generate. You can first select the type of node that the topology should consist of, or routers will be chosen by default. Nodes may be randomly placed, aligned in grids, or various other topology patterns. All of the supported patterns are listed in the table below. | -| Debugger... | Opens the CORE Debugger window for executing arbitrary Tcl/Tk commands. | - -#### Topology Generator - -| Pattern | Description | -|----------------|-----------------------------------------------------------------------------------------------------------------------------------------------------------------| -| Random | Nodes are randomly placed about the canvas, but are not linked together. This can be used in conjunction with a WLAN node to quickly create a wireless network. | -| Grid | Nodes are placed in horizontal rows starting in the upper-left corner, evenly spaced to the right; nodes are not linked to each other. | -| Connected Grid | Nodes are placed in an N x M (width and height) rectangular grid, and each node is linked to the node above, below, left and right of itself. | -| Chain | Nodes are linked together one after the other in a chain. | -| Star | One node is placed in the center with N nodes surrounding it in a circular pattern, with each node linked to the center node. | -| Cycle | Nodes are arranged in a circular pattern with every node connected to its neighbor to form a closed circular path. | -| Wheel | The wheel pattern links nodes in a combination of both Star and Cycle patterns. | -| Cube | Generate a cube graph of nodes. | -| Clique | Creates a clique graph of nodes, where every node is connected to every other node. | -| Bipartite | Creates a bipartite graph of nodes, having two disjoint sets of vertices. | +| Option | Description | +|---------------|----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| +| Find | Display find dialog used for highlighting a node on the canvas. | +| Auto Grid | Automatically layout nodes in a grid. | +| IP addresses | Invokes the IP Addresses dialog box for configuring which IPv4/IPv6 prefixes are used when automatically addressing new interfaces. | +| MAC addresses | Invokes the MAC Addresses dialog box for configuring the starting number used as the lowest byte when generating each interface MAC address. This value should be changed when tunneling between CORE emulations to prevent MAC address conflicts. | ### Widgets Menu @@ -275,30 +253,29 @@ Here are some standard widgets: Only half of the line is drawn because each router may be in a different adjacency state with respect to the other. * **Throughput** - displays the kilobits-per-second throughput above each link, - using statistics gathered from the ng_pipe Netgraph node that implements each - link. If the throughput exceeds a certain threshold, the link will become - highlighted. For wireless nodes which broadcast data to all nodes in range, - the throughput rate is displayed next to the node and the node will become - circled if the threshold is exceeded. + using statistics gathered from each link. If the throughput exceeds a certain + threshold, the link will become highlighted. For wireless nodes which broadcast + data to all nodes in range, the throughput rate is displayed next to the node and + the node will become circled if the threshold is exceeded. #### Observer Widgets -These Widgets are available from the *Observer Widgets* submenu of the -*Widgets* menu, and from the Widgets Tool on the toolbar. Only one Observer Widget may +These Widgets are available from the **Observer Widgets** submenu of the +**Widgets** menu, and from the Widgets Tool on the toolbar. Only one Observer Widget may be used at a time. Mouse over a node while the session is running to pop up an informational display about that node. Available Observer Widgets include IPv4 and IPv6 routing tables, socket information, list of running processes, and OSPFv2/v3 neighbor information. -Observer Widgets may be edited by the user and rearranged. Choosing *Edit...* -from the Observer Widget menu will invoke the Observer Widgets dialog. A list -of Observer Widgets is displayed along with up and down arrows for rearranging -the list. Controls are available for renaming each widget, for changing the -command that is run during mouse over, and for adding and deleting items from -the list. Note that specified commands should return immediately to avoid -delays in the GUI display. Changes are saved to a **widgets.conf** file in -the CORE configuration directory. +Observer Widgets may be edited by the user and rearranged. Choosing +**Widgets->Observer Widgets->Edit Observers** from the Observer Widget menu will +invoke the Observer Widgets dialog. A list of Observer Widgets is displayed along +with up and down arrows for rearranging the list. Controls are available for +renaming each widget, for changing the command that is run during mouse over, and +for adding and deleting items from the list. Note that specified commands should +return immediately to avoid delays in the GUI display. Changes are saved to a +**config.yaml** file in the CORE configuration directory. ### Session Menu @@ -306,28 +283,23 @@ The Session Menu has entries for starting, stopping, and managing sessions, in addition to global options such as node types, comments, hooks, servers, and options. -| Option | Description | -|----------------------|---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| -| Start or Stop | This starts or stops the emulation, performing the same function as the green Start or red Stop button. | -| Change sessions... | Invokes the CORE Sessions dialog box containing a list of active CORE sessions in the daemon. Basic session information such as name, node count, start time, and a thumbnail are displayed. This dialog allows connecting to different sessions, shutting them down, or starting a new session. | -| Node types... | Invokes the CORE Node Types dialog, performing the same function as the Edit button on the Network-Layer Nodes toolbar. | -| Comments... | Invokes the CORE Session Comments window where optional text comments may be specified. These comments are saved at the top of the configuration file, and can be useful for describing the topology or how to use the network. | -| Hooks... | Invokes the CORE Session Hooks window where scripts may be configured for a particular session state. The session states are defined in the [table](#session-states) below. The top of the window has a list of configured hooks, and buttons on the bottom left allow adding, editing, and removing hook scripts. The new or edit button will open a hook script editing window. A hook script is a shell script invoked on the host (not within a virtual node). | -| Reset node positions | If you have moved nodes around using the mouse or by using a mobility module, choosing this item will reset all nodes to their original position on the canvas. The node locations are remembered when you first press the Start button. | -| Emulation servers... | Invokes the CORE emulation servers dialog for configuring. | -| Change Sessions... | Invokes the Sessions dialog for switching between different running sessions. This dialog is presented during startup when one or more sessions are already running. | -| Options... | Presents per-session options, such as the IPv4 prefix to be used, if any, for a control network the ability to preserve the session directory; and an on/off switch for SDT3D support. | +| Option | Description | +|----------|---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| +| Sessions | Invokes the CORE Sessions dialog box containing a list of active CORE sessions in the daemon. Basic session information such as name, node count, start time, and a thumbnail are displayed. This dialog allows connecting to different sessions, shutting them down, or starting a new session. | +| Servers | Invokes the CORE emulation servers dialog for configuring. | +| Options | Presents per-session options, such as the IPv4 prefix to be used, if any, for a control network the ability to preserve the session directory; and an on/off switch for SDT3D support. | +| Hooks | Invokes the CORE Session Hooks window where scripts may be configured for a particular session state. The session states are defined in the [table](#session-states) below. The top of the window has a list of configured hooks, and buttons on the bottom left allow adding, editing, and removing hook scripts. The new or edit button will open a hook script editing window. A hook script is a shell script invoked on the host (not within a virtual node). | #### Session States | State | Description | |---------------|--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| -| definition | Used by the GUI to tell the backend to clear any state. | -| configuration | When the user presses the *Start* button, node, link, and other configuration data is sent to the backend. This state is also reached when the user customizes a service. | -| instantiation | After configuration data has been sent, just before the nodes are created. | -| runtime | All nodes and networks have been built and are running. (This is the same state at which the previously-named *global experiment script* was run.) | -| datacollect | The user has pressed the *Stop* button, but before services have been stopped and nodes have been shut down. This is a good time to collect log files and other data from the nodes. | -| shutdown | All nodes and networks have been shut down and destroyed. | +| Definition | Used by the GUI to tell the backend to clear any state. | +| Configuration | When the user presses the *Start* button, node, link, and other configuration data is sent to the backend. This state is also reached when the user customizes a service. | +| Instantiation | After configuration data has been sent, just before the nodes are created. | +| Runtime | All nodes and networks have been built and are running. (This is the same state at which the previously-named *global experiment script* was run.) | +| Datacollect | The user has pressed the *Stop* button, but before services have been stopped and nodes have been shut down. This is a good time to collect log files and other data from the nodes. | +| Shutdown | All nodes and networks have been shut down and destroyed. | ### Help Menu @@ -341,13 +313,13 @@ and options. CORE's emulated networks run in real time, so they can be connected to live physical networks. The RJ45 tool and the Tunnel tool help with connecting to -the real world. These tools are available from the *Link-layer nodes* menu. +the real world. These tools are available from the **Link-layer nodes** menu. When connecting two or more CORE emulations together, MAC address collisions should be avoided. CORE automatically assigns MAC addresses to interfaces when the emulation is started, starting with **00:00:00:aa:00:00** and incrementing the bottom byte. The starting byte should be changed on the second CORE machine -using the *MAC addresses...* option from the *Tools* menu. +using the **Tools->MAC Addresses** option the menu. ### RJ45 Tool @@ -360,8 +332,8 @@ connection. When the physical interface is assigned to CORE, it may not be used for anything else. Another consideration is that the computer or network that you are connecting to must be co-located with the CORE machine. -To place an RJ45 connection, click on the *Link-layer nodes* toolbar and select -the *RJ45 Tool* from the submenu. Click on the canvas near the node you want to +To place an RJ45 connection, click on the **Link-layer nodes** toolbar and select +the **RJ45 Tool** from the submenu. Click on the canvas near the node you want to connect to. This could be a router, hub, switch, or WLAN, for example. Now click on the *Link Tool* and draw a link between the RJ45 and the other node. The RJ45 node will display "UNASSIGNED". Double-click the RJ45 node to assign a @@ -459,7 +431,7 @@ firewall is not blocking the GRE traffic. The host machine that runs the CORE GUI and/or daemon is not necessarily accessible from a node. Running an X11 application on a node, for example, requires some channel of communication for the application to connect with -the X server for graphical display. There are several different ways to +the X server for graphical display. There are different ways to connect from the node to the host and vice versa. #### Control Network @@ -476,12 +448,6 @@ the node, and SSH with X11 forwarding can be used from the host to the node. ssh -X 172.16.0.5 xclock ``` -Note that the **coresendmsg** utility can be used for a node to send -messages to the CORE daemon running on the host (if the **listenaddr = 0.0.0.0** -is set in the **/etc/core/core.conf** file) to interact with the running -emulation. For example, a node may move itself or other nodes, or change -its icon based on some node state. - #### Other Methods There are still other ways to connect a host with a node. The RJ45 Tool @@ -509,11 +475,11 @@ the node linked to the RJ45 may have the address **10.0.1.1**. ### Wired Networks -Wired networks are created using the *Link Tool* to draw a link between two +Wired networks are created using the **Link Tool** to draw a link between two nodes. This automatically draws a red line representing an Ethernet link and creates new interfaces on network-layer nodes. -Double-click on the link to invoke the *link configuration* dialog box. Here +Double-click on the link to invoke the **link configuration** dialog box. Here you can change the Bandwidth, Delay, Loss, and Duplicate rate parameters for that link. You can also modify the color and width of the link, affecting its display. @@ -550,11 +516,10 @@ on platform. See the table below for a brief overview of wireless model types. To quickly build a wireless network, you can first place several router nodes onto the canvas. If you have the Quagga MDR software installed, it is -recommended that you use the *mdr* node type for reduced routing overhead. Next -choose the *wireless LAN* from the *Link-layer nodes* submenu. First set the +recommended that you use the **mdr** node type for reduced routing overhead. Next +choose the **WLAN** from the **Link-layer nodes** submenu. First set the desired WLAN parameters by double-clicking the cloud icon. Then you can link -all of the routers by right-clicking on the WLAN and choosing *Link to all -routers*. +all selected right-clicking on the WLAN and choosing **Link to Selected**. Linking a router to the WLAN causes a small antenna to appear, but no red link line is drawn. Routers can have multiple wireless links and both wireless and @@ -564,28 +529,27 @@ enables OSPFv3 with MANET extensions. This is a Boeing-developed extension to Quagga's OSPFv3 that reduces flooding overhead and optimizes the flooding procedure for mobile ad-hoc (MANET) networks. -The default configuration of the WLAN is set to use the basic range model, -using the *Basic* tab in the WLAN configuration dialog. Having this model +The default configuration of the WLAN is set to use the basic range model. Having this model selected causes **core-daemon** to calculate the distance between nodes based on screen pixels. A numeric range in screen pixels is set for the wireless -network using the *Range* slider. When two wireless nodes are within range of +network using the **Range** slider. When two wireless nodes are within range of each other, a green line is drawn between them and they are linked. Two wireless nodes that are farther than the range pixels apart are not linked. During Execute mode, users may move wireless nodes around by clicking and dragging them, and wireless links will be dynamically made or broken. -The *EMANE* tab lists available EMANE models to use for wireless networking. +The **EMANE Nodes** leverage available EMANE models to use for wireless networking. See the [EMANE](emane.md) chapter for details on using EMANE. ### Mobility Scripting CORE has a few ways to script mobility. -| Option | Description | -|--------------|---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| -| ns-2 script | The script specifies either absolute positions or waypoints with a velocity. Locations are given with Cartesian coordinates. | -| CORE API | An external entity can move nodes by sending CORE API Node messages with updated X,Y coordinates; the **coresendmsg** utility allows a shell script to generate these messages. | -| EMANE events | See [EMANE](emane.md) for details on using EMANE scripts to move nodes around. Location information is typically given as latitude, longitude, and altitude. | +| Option | Description | +|--------------|--------------------------------------------------------------------------------------------------------------------------------------------------------------| +| ns-2 script | The script specifies either absolute positions or waypoints with a velocity. Locations are given with Cartesian coordinates. | +| gRPC API | An external entity can move nodes by leveraging the gRPC API | +| EMANE events | See [EMANE](emane.md) for details on using EMANE scripts to move nodes around. Location information is typically given as latitude, longitude, and altitude. | For the first method, you can create a mobility script using a text editor, or using a tool such as [BonnMotion](http://net.cs.uni-bonn.de/wg/cs/applications/bonnmotion/), and associate the script with one of the wireless @@ -604,7 +568,7 @@ bm NSFile -f sample When the Execute mode is started and one of the WLAN nodes has a mobility script, a mobility script window will appear. This window contains controls for starting, stopping, and resetting the running time for the mobility script. The -*loop* checkbox causes the script to play continuously. The *resolution* text +**loop** checkbox causes the script to play continuously. The **resolution** text box contains the number of milliseconds between each timer event; lower values cause the mobility to appear smoother but consumes greater CPU time. @@ -628,79 +592,28 @@ accurate. Examples mobility scripts (and their associated topology files) can be found in the **configs/** directory. -## Multiple Canvases +## Alerts -CORE supports multiple canvases for organizing emulated nodes. Nodes running on -different canvases may be linked together. +The alerts button is located in the bottom right-hand corner +of the status bar in the CORE GUI. This will change colors to indicate one or +more problems with the running emulation. Clicking on the alerts button will invoke the +alerts dialog. -To create a new canvas, choose *New* from the *Canvas* menu. A new canvas tab -appears in the bottom left corner. Clicking on a canvas tab switches to that -canvas. Double-click on one of the tabs to invoke the *Manage Canvases* dialog -box. Here, canvases may be renamed and reordered, and you can easily switch to -one of the canvases by selecting it. - -Each canvas maintains its own set of nodes and annotations. To link between -canvases, select a node and right-click on it, choose *Create link to*, choose -the target canvas from the list, and from that submenu the desired node. A -pseudo-link will be drawn, representing the link between the two nodes on -different canvases. Double-clicking on the label at the end of the arrow will -jump to the canvas that it links. - -## Check Emulation Light (CEL) - -The |cel| Check Emulation Light, or CEL, is located in the bottom right-hand corner -of the status bar in the CORE GUI. This is a yellow icon that indicates one or -more problems with the running emulation. Clicking on the CEL will invoke the -CEL dialog. - -The Check Emulation Light dialog contains a list of exceptions received from -the CORE daemon. An exception has a time, severity level, optional node number, -and source. When the CEL is blinking, this indicates one or more fatal -exceptions. An exception with a fatal severity level indicates that one or more +The alerts dialog contains a list of alerts received from +the CORE daemon. An alert has a time, severity level, optional node number, +and source. When the alerts button is red, this indicates one or more fatal +exceptions. An alert with a fatal severity level indicates that one or more of the basic pieces of emulation could not be created, such as failure to create a bridge or namespace, or the failure to launch EMANE processes for an EMANE-based network. -Clicking on an exception displays details for that -exception. If a node number is specified, that node is highlighted on the -canvas when the exception is selected. The exception source is a text string +Clicking on an alert displays details for that +exceptio. The exception source is a text string to help trace where the exception occurred; "service:UserDefined" for example, would appear for a failed validation command with the UserDefined service. -Buttons are available at the bottom of the dialog for clearing the exception -list and for viewing the CORE daemon and node log files. - -> **NOTE:** In batch mode, exceptions received from the CORE daemon are displayed on - the console. - -## Configuration Files - -Configurations are saved to **xml** or **.imn** topology files using -the *File* menu. You -can easily edit these files with a text editor. -Any time you edit the topology -file, you will need to stop the emulation if it were running and reload the -file. - -The **.imn** file format comes from IMUNES, and is -basically Tcl lists of nodes, links, etc. -Tabs and spacing in the topology files are important. The file starts by -listing every node, then links, annotations, canvases, and options. Each entity -has a block contained in braces. The first block is indented by four spaces. -Within the **network-config** block (and any *custom-*-config* block), the -indentation is one tab character. - -> **NOTE:** There are several topology examples included with CORE in - the **configs/** directory. - This directory can be found in **~/.core/configs**, or - installed to the filesystem - under **/usr[/local]/share/examples/configs**. - -> **NOTE:** When using the **.imn** file format, file paths for things like custom - icons may contain the special variables **$CORE_DATA_DIR** or **$CONFDIR** which - will be substituted with **/usr/share/core** or **~/.core/configs**. - -> **NOTE:** Feel free to edit the files directly using your favorite text editor. +A button is available at the bottom of the dialog for clearing the exception +list. ## Customizing your Topology's Look @@ -723,12 +636,3 @@ A background image for the canvas may be set using the *Wallpaper...* option from the *Canvas* menu. The image may be centered, tiled, or scaled to fit the canvas size. An existing terrain, map, or network diagram could be used as a background, for example, with CORE nodes drawn on top. - -## Preferences - -The *Preferences* Dialog can be accessed from the **Edit_Menu**. There are -numerous defaults that can be set with this dialog, which are stored in the -**~/.core/prefs.conf** preferences file. - - - diff --git a/docs/index.md b/docs/index.md index 2321fa54..e17a2e3b 100644 --- a/docs/index.md +++ b/docs/index.md @@ -23,8 +23,7 @@ networking scenarios, security studies, and increasing the size of physical test | [Installation](install.md) | How to install CORE and its requirements | | [Architecture](architecture.md) | Overview of the architecture | | [Node Types](nodetypes.md) | Overview of node types supported within CORE | -| [Python GUI](pygui.md) | How to use the default python based GUI | -| [Legacy GUI (deprecated)](gui.md) | How to use the deprecated Tcl based GUI | +| [GUI](gui.md) | How to use the GUI | | [Python API](python.md) | Covers how to control core directly using python | | [gRPC API](grpc.md) | Covers how control core using gRPC | | [Distributed](distributed.md) | Details for running CORE across multiple servers | @@ -34,17 +33,3 @@ networking scenarios, security studies, and increasing the size of physical test | [EMANE](emane.md) | Overview of EMANE integration and integrating custom EMANE models | | [Performance](performance.md) | Notes on performance when using CORE | | [Developers Guide](devguide.md) | Overview on how to contribute to CORE | - -## Credits - -The CORE project was derived from the open source IMUNES project from the University of Zagreb in 2004. In 2006, -changes for CORE were released back to that project, some items of which were adopted. Marko Zec is the -primary developer from the University of Zagreb responsible for the IMUNES (GUI) and VirtNet (kernel) projects. Ana -Kukec and Miljenko Mikuc are known contributors. - -Jeff Ahrenholz has been the primary Boeing developer of CORE, and has written this manual. Tom Goff designed the -Python framework and has made significant contributions. Claudiu Danilov, Rod Santiago, Kevin Larson, Gary Pei, -Phil Spagnolo, and Ian Chakeres have contributed code to CORE. Dan Mackley helped develop the CORE API, originally to -interface with a simulator. Jae Kim and Tom Henderson have supervised the project and provided direction. - -Copyright (c) 2005-2020, the Boeing Company. diff --git a/docs/install.md b/docs/install.md index 2f6dbce3..7af62ee3 100644 --- a/docs/install.md +++ b/docs/install.md @@ -51,11 +51,6 @@ The following is a list of files that would be installed after running the autom * executable files * `/bin/{core-daemon, core-gui, vcmd, vnoded, etc}` -* tcl/tk gui files - * `/lib/core` - * `/share/core/icons` -* example imn files - * `/share/core/examples` * python files * poetry virtual env * `cd /daemon && poetry env info` @@ -77,15 +72,11 @@ After the installation complete it will have installed the following scripts. |---------------------|------------------------------------------------------------------------------| | core-cleanup | tool to help removed lingering core created containers, bridges, directories | | core-cli | tool to query, open xml files, and send commands using gRPC | -| core-daemon | runs the backed core server providing TLV and gRPC APIs | -| core-gui | runs the legacy tcl/tk based GUI | -| core-imn-to-xml | tool to help automate converting a .imn file to .xml format | -| core-manage | tool to add, remove, or check for services, models, and node types | -| core-pygui | runs the new python/tk based GUI | +| core-daemon | runs the backed core server providing a gRPC API | +| core-gui | starts GUI | | core-python | provides a convenience for running the core python virtual environment | | core-route-monitor | tool to help monitor traffic across nodes and feed that to SDT | | core-service-update | tool to update automate modifying a legacy service to match current naming | -| coresendmsg | tool to send TLV API commands from command line | ## Upgrading from Older Release Please make sure to uninstall any previous installations of CORE cleanly @@ -237,7 +228,7 @@ sudo docker exec -it core core-gui ``` ## Running User Scripts -If you create your own python scripts to run CORE directly or using the gRPC/TLV +If you create your own python scripts to run CORE directly or using the gRPC APIs you will need to make sure you are running them within context of the installed virtual environment. To help support this CORE provides the `core-python` executable. This executable will allow you to enter CORE's python virtual diff --git a/docs/pygui.md b/docs/pygui.md deleted file mode 100644 index 1d495834..00000000 --- a/docs/pygui.md +++ /dev/null @@ -1,649 +0,0 @@ - -# (BETA) Python GUI - -* Table of Contents -{:toc} - -![](static/core-pygui.png) - -## Overview - -The GUI is used to draw nodes and network devices on a canvas, linking them -together to create an emulated network session. - -After pressing the start button, CORE will proceed through these phases, -staying in the **runtime** phase. After the session is stopped, CORE will -proceed to the **data collection** phase before tearing down the emulated -state. - -CORE can be customized to perform any action at each state. See the -**Hooks...** entry on the [Session Menu](#session-menu) for details about -when these session states are reached. - -## Prerequisites - -Beyond installing CORE, you must have the CORE daemon running. This is done -on the command line with either systemd or sysv. - -```shell -# systemd service -sudo systemctl daemon-reload -sudo systemctl start core-daemon - -# sysv service -sudo service core-daemon start - -# direct invocation -sudo core-daemon -``` - -## GUI Files - -> **NOTE:** Previously the BETA GUI placed files under ~/.coretk, this has been -> updated to be ~/.coregui. The prior config file named ~/.coretk/gui.yaml is -> also now known as ~/.coregui/config.yaml and has a slightly different format - -The GUI will create a directory in your home directory on first run called -~/.coregui. This directory will help layout various files that the GUI may use. - -* .coregui/ - * backgrounds/ - * place backgrounds used for display in the GUI - * custom_emane/ - * place to keep custom emane models to use with the core-daemon - * custom_services/ - * place to keep custom services to use with the core-daemon - * icons/ - * icons the GUI uses along with customs icons desired - * mobility/ - * place to keep custom mobility files - * scripts/ - * place to keep core related scripts - * xmls/ - * place to keep saved session xml files - * gui.log - * log file when running the gui, look here when issues occur for exceptions etc - * config.yaml - * configuration file used to save/load various gui related settings (custom nodes, layouts, addresses, etc) - -## Modes of Operation - -The CORE GUI has two primary modes of operation, **Edit** and **Execute** -modes. Running the GUI, by typing **core-pygui** with no options, starts in -Edit mode. Nodes are drawn on a blank canvas using the toolbar on the left -and configured from right-click menus or by double-clicking them. The GUI -does not need to be run as root. - -Once editing is complete, pressing the green **Start** button instantiates -the topology and enters Execute mode. In execute mode, -the user can interact with the running emulated machines by double-clicking or -right-clicking on them. The editing toolbar disappears and is replaced by an -execute toolbar, which provides tools while running the emulation. Pressing -the red **Stop** button will destroy the running emulation and return CORE -to Edit mode. - -Once the emulation is running, the GUI can be closed, and a prompt will appear -asking if the emulation should be terminated. The emulation may be left -running and the GUI can reconnect to an existing session at a later time. - -The GUI can be run as a normal user on Linux. - -The python GUI currently provides the following options on startup. - -```shell -usage: core-pygui [-h] [-l {DEBUG,INFO,WARNING,ERROR,CRITICAL}] [-p] - -CORE Python GUI - -optional arguments: - -h, --help show this help message and exit - -l {DEBUG,INFO,WARNING,ERROR,CRITICAL}, --level {DEBUG,INFO,WARNING,ERROR,CRITICAL} - logging level - -p, --proxy enable proxy -``` - -## Toolbar - -The toolbar is a row of buttons that runs vertically along the left side of the -CORE GUI window. The toolbar changes depending on the mode of operation. - -### Editing Toolbar - -When CORE is in Edit mode (the default), the vertical Editing Toolbar exists on -the left side of the CORE window. Below are brief descriptions for each toolbar -item, starting from the top. Most of the tools are grouped into related -sub-menus, which appear when you click on their group icon. - -| Icon | Name | Description | -|------------------------------|----------------|----------------------------------------------------------------------------------------| -| ![](static/pygui/select.png) | Selection Tool | Tool for selecting, moving, configuring nodes. | -| ![](static/pygui/start.png) | Start Button | Starts Execute mode, instantiates the emulation. | -| ![](static/pygui/link.png) | Link | Allows network links to be drawn between two nodes by clicking and dragging the mouse. | - -### CORE Nodes - -These nodes will create a new node container and run associated services. - -| Icon | Name | Description | -|------------------------------|---------|------------------------------------------------------------------------------| -| ![](static/pygui/router.png) | Router | Runs Quagga OSPFv2 and OSPFv3 routing to forward packets. | -| ![](static/pygui/host.png) | Host | Emulated server machine having a default route, runs SSH server. | -| ![](static/pygui/pc.png) | PC | Basic emulated machine having a default route, runs no processes by default. | -| ![](static/pygui/mdr.png) | MDR | Runs Quagga OSPFv3 MDR routing for MANET-optimized routing. | -| ![](static/pygui/router.png) | PRouter | Physical router represents a real testbed machine. | - -### Network Nodes - -These nodes are mostly used to create a Linux bridge that serves the -purpose described below. - -| Icon | Name | Description | -|---------------------------------|--------------|----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| -| ![](static/pygui/hub.png) | Hub | Ethernet hub forwards incoming packets to every connected node. | -| ![](static/pygui/lanswitch.png) | Switch | Ethernet switch intelligently forwards incoming packets to attached hosts using an Ethernet address hash table. | -| ![](static/pygui/wlan.png) | Wireless LAN | When routers are connected to this WLAN node, they join a wireless network and an antenna is drawn instead of a connecting line; the WLAN node typically controls connectivity between attached wireless nodes based on the distance between them. | -| ![](static/pygui/rj45.png) | RJ45 | RJ45 Physical Interface Tool, emulated nodes can be linked to real physical interfaces; using this tool, real networks and devices can be physically connected to the live-running emulation. | -| ![](static/pygui/tunnel.png) | Tunnel | Tool allows connecting together more than one CORE emulation using GRE tunnels. | - -### Annotation Tools - -| Icon | Name | Description | -|---------------------------------|-----------|---------------------------------------------------------------------| -| ![](static/pygui/marker.png) | Marker | For drawing marks on the canvas. | -| ![](static/pygui/oval.png) | Oval | For drawing circles on the canvas that appear in the background. | -| ![](static/pygui/rectangle.png) | Rectangle | For drawing rectangles on the canvas that appear in the background. | -| ![](static/pygui/text.png) | Text | For placing text captions on the canvas. | - -### Execution Toolbar - -When the Start button is pressed, CORE switches to Execute mode, and the Edit -toolbar on the left of the CORE window is replaced with the Execution toolbar -Below are the items on this toolbar, starting from the top. - -| Icon | Name | Description | -|------------------------------|----------------|-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| -| ![](static/pygui/stop.png) | Stop Button | Stops Execute mode, terminates the emulation, returns CORE to edit mode. | -| ![](static/pygui/select.png) | Selection Tool | In Execute mode, the Selection Tool can be used for moving nodes around the canvas, and double-clicking on a node will open a shell window for that node; right-clicking on a node invokes a pop-up menu of run-time options for that node. | -| ![](static/pygui/marker.png) | Marker | For drawing freehand lines on the canvas, useful during demonstrations; markings are not saved. | -| ![](static/pygui/run.png) | Run Tool | This tool allows easily running a command on all or a subset of all nodes. A list box allows selecting any of the nodes. A text entry box allows entering any command. The command should return immediately, otherwise the display will block awaiting response. The *ping* command, for example, with no parameters, is not a good idea. The result of each command is displayed in a results box. The first occurrence of the special text "NODE" will be replaced with the node name. The command will not be attempted to run on nodes that are not routers, PCs, or hosts, even if they are selected. | - -## Menu - -The menubar runs along the top of the CORE GUI window and provides access to a -variety of features. Some of the menus are detachable, such as the *Widgets* -menu, by clicking the dashed line at the top. - -### File Menu - -The File menu contains options for manipulating the **.imn** Configuration -Files. Generally, these menu items should not be used in Execute mode. - -| Option | Description | -|-----------------------|-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| -| New Session | This starts a new session with an empty canvas. | -| Save | Saves the current topology. If you have not yet specified a file name, the Save As dialog box is invoked. | -| Save As | Invokes the Save As dialog box for selecting a new **.xml** file for saving the current configuration in the XML file. | -| Open | Invokes the File Open dialog box for selecting a new XML file to open. | -| Recently used files | Above the Quit menu command is a list of recently use files, if any have been opened. You can clear this list in the Preferences dialog box. You can specify the number of files to keep in this list from the Preferences dialog. Click on one of the file names listed to open that configuration file. | -| Execute Python Script | Invokes a File Open dialog box for selecting a Python script to run and automatically connect to. After a selection is made, a Python Script Options dialog box is invoked to allow for command-line options to be added. The Python script must create a new CORE Session and add this session to the daemon's list of sessions in order for this to work. | -| Quit | The Quit command should be used to exit the CORE GUI. CORE may prompt for termination if you are currently in Execute mode. Preferences and the recently-used files list are saved. | - -### Edit Menu - -| Option | Description | -|--------------------------|---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| -| Preferences | Invokes the Preferences dialog box. | -| Custom Nodes | Custom node creation dialog box. | -| Undo | (Disabled) Attempts to undo the last edit in edit mode. | -| Redo | (Disabled) Attempts to redo an edit that has been undone. | -| Cut, Copy, Paste, Delete | Used to cut, copy, paste, and delete a selection. When nodes are pasted, their node numbers are automatically incremented, and existing links are preserved with new IP addresses assigned. Services and their customizations are copied to the new node, but care should be taken as node IP addresses have changed with possibly old addresses remaining in any custom service configurations. Annotations may also be copied and pasted. | - -### Canvas Menu - -The canvas menu provides commands related to the editing canvas. - -| Option | Description | -|------------|-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| -| Size/scale | Invokes a Canvas Size and Scale dialog that allows configuring the canvas size, scale, and geographic reference point. The size controls allow changing the width and height of the current canvas, in pixels or meters. The scale allows specifying how many meters are equivalent to 100 pixels. The reference point controls specify the latitude, longitude, and altitude reference point used to convert between geographic and Cartesian coordinate systems. By clicking the *Save as default* option, all new canvases will be created with these properties. The default canvas size can also be changed in the Preferences dialog box. | -| Wallpaper | Used for setting the canvas background image. | - -### View Menu - -The View menu features items for toggling on and off their display on the canvas. - -| Option | Description | -|-----------------|-----------------------------------| -| Interface Names | Display interface names on links. | -| IPv4 Addresses | Display IPv4 addresses on links. | -| IPv6 Addresses | Display IPv6 addresses on links. | -| Node Labels | Display node names. | -| Link Labels | Display link labels. | -| Annotations | Display annotations. | -| Canvas Grid | Display the canvas grid. | - -### Tools Menu - -The tools menu lists different utility functions. - -| Option | Description | -|---------------|----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| -| Find | Display find dialog used for highlighting a node on the canvas. | -| Auto Grid | Automatically layout nodes in a grid. | -| IP addresses | Invokes the IP Addresses dialog box for configuring which IPv4/IPv6 prefixes are used when automatically addressing new interfaces. | -| MAC addresses | Invokes the MAC Addresses dialog box for configuring the starting number used as the lowest byte when generating each interface MAC address. This value should be changed when tunneling between CORE emulations to prevent MAC address conflicts. | - -### Widgets Menu - -Widgets are GUI elements that allow interaction with a running emulation. -Widgets typically automate the running of commands on emulated nodes to report -status information of some type and display this on screen. - -#### Periodic Widgets - -These Widgets are those available from the main *Widgets* menu. More than one -of these Widgets may be run concurrently. An event loop fires once every second -that the emulation is running. If one of these Widgets is enabled, its periodic -routine will be invoked at this time. Each Widget may have a configuration -dialog box which is also accessible from the *Widgets* menu. - -Here are some standard widgets: - -* **Adjacency** - displays router adjacency states for Quagga's OSPFv2 and OSPFv3 - routing protocols. A line is drawn from each router halfway to the router ID - of an adjacent router. The color of the line is based on the OSPF adjacency - state such as Two-way or Full. To learn about the different colors, see the - *Configure Adjacency...* menu item. The **vtysh** command is used to - dump OSPF neighbor information. - Only half of the line is drawn because each - router may be in a different adjacency state with respect to the other. -* **Throughput** - displays the kilobits-per-second throughput above each link, - using statistics gathered from the ng_pipe Netgraph node that implements each - link. If the throughput exceeds a certain threshold, the link will become - highlighted. For wireless nodes which broadcast data to all nodes in range, - the throughput rate is displayed next to the node and the node will become - circled if the threshold is exceeded. - -#### Observer Widgets - -These Widgets are available from the **Observer Widgets** submenu of the -**Widgets** menu, and from the Widgets Tool on the toolbar. Only one Observer Widget may -be used at a time. Mouse over a node while the session is running to pop up -an informational display about that node. - -Available Observer Widgets include IPv4 and IPv6 routing tables, socket -information, list of running processes, and OSPFv2/v3 neighbor information. - -Observer Widgets may be edited by the user and rearranged. Choosing -**Widgets->Observer Widgets->Edit Observers** from the Observer Widget menu will -invoke the Observer Widgets dialog. A list of Observer Widgets is displayed along -with up and down arrows for rearranging the list. Controls are available for -renaming each widget, for changing the command that is run during mouse over, and -for adding and deleting items from the list. Note that specified commands should -return immediately to avoid delays in the GUI display. Changes are saved to a -**config.yaml** file in the CORE configuration directory. - -### Session Menu - -The Session Menu has entries for starting, stopping, and managing sessions, -in addition to global options such as node types, comments, hooks, servers, -and options. - -| Option | Description | -|----------|---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| -| Sessions | Invokes the CORE Sessions dialog box containing a list of active CORE sessions in the daemon. Basic session information such as name, node count, start time, and a thumbnail are displayed. This dialog allows connecting to different sessions, shutting them down, or starting a new session. | -| Servers | Invokes the CORE emulation servers dialog for configuring. | -| Options | Presents per-session options, such as the IPv4 prefix to be used, if any, for a control network the ability to preserve the session directory; and an on/off switch for SDT3D support. | -| Hooks | Invokes the CORE Session Hooks window where scripts may be configured for a particular session state. The session states are defined in the [table](#session-states) below. The top of the window has a list of configured hooks, and buttons on the bottom left allow adding, editing, and removing hook scripts. The new or edit button will open a hook script editing window. A hook script is a shell script invoked on the host (not within a virtual node). | - -#### Session States - -| State | Description | -|---------------|--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| -| Definition | Used by the GUI to tell the backend to clear any state. | -| Configuration | When the user presses the *Start* button, node, link, and other configuration data is sent to the backend. This state is also reached when the user customizes a service. | -| Instantiation | After configuration data has been sent, just before the nodes are created. | -| Runtime | All nodes and networks have been built and are running. (This is the same state at which the previously-named *global experiment script* was run.) | -| Datacollect | The user has pressed the *Stop* button, but before services have been stopped and nodes have been shut down. This is a good time to collect log files and other data from the nodes. | -| Shutdown | All nodes and networks have been shut down and destroyed. | - -### Help Menu - -| Option | Description | -|--------------------------|---------------------------------------------------------------| -| CORE Github (www) | Link to the CORE GitHub page. | -| CORE Documentation (www) | Lnk to the CORE Documentation page. | -| About | Invokes the About dialog box for viewing version information. | - -## Connecting with Physical Networks - -CORE's emulated networks run in real time, so they can be connected to live -physical networks. The RJ45 tool and the Tunnel tool help with connecting to -the real world. These tools are available from the **Link-layer nodes** menu. - -When connecting two or more CORE emulations together, MAC address collisions -should be avoided. CORE automatically assigns MAC addresses to interfaces when -the emulation is started, starting with **00:00:00:aa:00:00** and incrementing -the bottom byte. The starting byte should be changed on the second CORE machine -using the **Tools->MAC Addresses** option the menu. - -### RJ45 Tool - -The RJ45 node in CORE represents a physical interface on the real CORE machine. -Any real-world network device can be connected to the interface and communicate -with the CORE nodes in real time. - -The main drawback is that one physical interface is required for each -connection. When the physical interface is assigned to CORE, it may not be used -for anything else. Another consideration is that the computer or network that -you are connecting to must be co-located with the CORE machine. - -To place an RJ45 connection, click on the **Link-layer nodes** toolbar and select -the **RJ45 Tool** from the submenu. Click on the canvas near the node you want to -connect to. This could be a router, hub, switch, or WLAN, for example. Now -click on the *Link Tool* and draw a link between the RJ45 and the other node. -The RJ45 node will display "UNASSIGNED". Double-click the RJ45 node to assign a -physical interface. A list of available interfaces will be shown, and one may -be selected by double-clicking its name in the list, or an interface name may -be entered into the text box. - -> **NOTE:** When you press the Start button to instantiate your topology, the - interface assigned to the RJ45 will be connected to the CORE topology. The - interface can no longer be used by the system. - -Multiple RJ45 nodes can be used within CORE and assigned to the same physical -interface if 802.1x VLANs are used. This allows for more RJ45 nodes than -physical ports are available, but the (e.g. switching) hardware connected to -the physical port must support the VLAN tagging, and the available bandwidth -will be shared. - -You need to create separate VLAN virtual devices on the Linux host, -and then assign these devices to RJ45 nodes inside of CORE. The VLANning is -actually performed outside of CORE, so when the CORE emulated node receives a -packet, the VLAN tag will already be removed. - -Here are example commands for creating VLAN devices under Linux: - -```shell -ip link add link eth0 name eth0.1 type vlan id 1 -ip link add link eth0 name eth0.2 type vlan id 2 -ip link add link eth0 name eth0.3 type vlan id 3 -``` - -### Tunnel Tool - -The tunnel tool builds GRE tunnels between CORE emulations or other hosts. -Tunneling can be helpful when the number of physical interfaces is limited or -when the peer is located on a different network. Also a physical interface does -not need to be dedicated to CORE as with the RJ45 tool. - -The peer GRE tunnel endpoint may be another CORE machine or another -host that supports GRE tunneling. When placing a Tunnel node, initially -the node will display "UNASSIGNED". This text should be replaced with the IP -address of the tunnel peer. This is the IP address of the other CORE machine or -physical machine, not an IP address of another virtual node. - -> **NOTE:** Be aware of possible MTU (Maximum Transmission Unit) issues with GRE devices. The *gretap* device - has an interface MTU of 1,458 bytes; when joined to a Linux bridge, the - bridge's MTU - becomes 1,458 bytes. The Linux bridge will not perform fragmentation for - large packets if other bridge ports have a higher MTU such as 1,500 bytes. - -The GRE key is used to identify flows with GRE tunneling. This allows multiple -GRE tunnels to exist between that same pair of tunnel peers. A unique number -should be used when multiple tunnels are used with the same peer. When -configuring the peer side of the tunnel, ensure that the matching keys are -used. - -Here are example commands for building the other end of a tunnel on a Linux -machine. In this example, a router in CORE has the virtual address -**10.0.0.1/24** and the CORE host machine has the (real) address -**198.51.100.34/24**. The Linux box -that will connect with the CORE machine is reachable over the (real) network -at **198.51.100.76/24**. -The emulated router is linked with the Tunnel Node. In the -Tunnel Node configuration dialog, the address **198.51.100.76** is entered, with -the key set to **1**. The gretap interface on the Linux box will be assigned -an address from the subnet of the virtual router node, -**10.0.0.2/24**. - -```shell -# these commands are run on the tunnel peer -sudo ip link add gt0 type gretap remote 198.51.100.34 local 198.51.100.76 key 1 -sudo ip addr add 10.0.0.2/24 dev gt0 -sudo ip link set dev gt0 up -``` - -Now the virtual router should be able to ping the Linux machine: - -```shell -# from the CORE router node -ping 10.0.0.2 -``` - -And the Linux machine should be able to ping inside the CORE emulation: - -```shell -# from the tunnel peer -ping 10.0.0.1 -``` - -To debug this configuration, **tcpdump** can be run on the gretap devices, or -on the physical interfaces on the CORE or Linux machines. Make sure that a -firewall is not blocking the GRE traffic. - -### Communicating with the Host Machine - -The host machine that runs the CORE GUI and/or daemon is not necessarily -accessible from a node. Running an X11 application on a node, for example, -requires some channel of communication for the application to connect with -the X server for graphical display. There are several different ways to -connect from the node to the host and vice versa. - -#### Control Network - -The quickest way to connect with the host machine through the primary control -network. - -With a control network, the host can launch an X11 application on a node. -To run an X11 application on the node, the **SSH** service can be enabled on -the node, and SSH with X11 forwarding can be used from the host to the node. - -```shell -# SSH from host to node n5 to run an X11 app -ssh -X 172.16.0.5 xclock -``` - -Note that the **coresendmsg** utility can be used for a node to send -messages to the CORE daemon running on the host (if the **listenaddr = 0.0.0.0** -is set in the **/etc/core/core.conf** file) to interact with the running -emulation. For example, a node may move itself or other nodes, or change -its icon based on some node state. - -#### Other Methods - -There are still other ways to connect a host with a node. The RJ45 Tool -can be used in conjunction with a dummy interface to access a node: - -```shell -sudo modprobe dummy numdummies=1 -``` - -A **dummy0** interface should appear on the host. Use the RJ45 tool assigned -to **dummy0**, and link this to a node in your scenario. After starting the -session, configure an address on the host. - -```shell -sudo ip link show type bridge -# determine bridge name from the above command -# assign an IP address on the same network as the linked node -sudo ip addr add 10.0.1.2/24 dev b.48304.34658 -``` - -In the example shown above, the host will have the address **10.0.1.2** and -the node linked to the RJ45 may have the address **10.0.1.1**. - -## Building Sample Networks - -### Wired Networks - -Wired networks are created using the **Link Tool** to draw a link between two -nodes. This automatically draws a red line representing an Ethernet link and -creates new interfaces on network-layer nodes. - -Double-click on the link to invoke the **link configuration** dialog box. Here -you can change the Bandwidth, Delay, Loss, and Duplicate -rate parameters for that link. You can also modify the color and width of the -link, affecting its display. - -Link-layer nodes are provided for modeling wired networks. These do not create -a separate network stack when instantiated, but are implemented using Linux bridging. -These are the hub, switch, and wireless LAN nodes. The hub copies each packet from -the incoming link to every connected link, while the switch behaves more like an -Ethernet switch and keeps track of the Ethernet address of the connected peer, -forwarding unicast traffic only to the appropriate ports. - -The wireless LAN (WLAN) is covered in the next section. - -### Wireless Networks - -The wireless LAN node allows you to build wireless networks where moving nodes -around affects the connectivity between them. Connection between a pair of nodes is stronger -when the nodes are closer while connection is weaker when the nodes are further away. -The wireless LAN, or WLAN, node appears as a small cloud. The WLAN offers -several levels of wireless emulation fidelity, depending on your modeling needs. - -The WLAN tool can be extended with plug-ins for different levels of wireless -fidelity. The basic on/off range is the default setting available on all -platforms. Other plug-ins offer higher fidelity at the expense of greater -complexity and CPU usage. The availability of certain plug-ins varies depending -on platform. See the table below for a brief overview of wireless model types. - - -| Model | Type | Supported Platform(s) | Fidelity | Description | -|-------|---------|-----------------------|----------|-------------------------------------------------------------------------------| -| Basic | on/off | Linux | Low | Ethernet bridging with nftables | -| EMANE | Plug-in | Linux | High | TAP device connected to EMANE emulator with pluggable MAC and PHY radio types | - -To quickly build a wireless network, you can first place several router nodes -onto the canvas. If you have the -Quagga MDR software installed, it is -recommended that you use the **mdr** node type for reduced routing overhead. Next -choose the **WLAN** from the **Link-layer nodes** submenu. First set the -desired WLAN parameters by double-clicking the cloud icon. Then you can link -all selected right-clicking on the WLAN and choosing **Link to Selected**. - -Linking a router to the WLAN causes a small antenna to appear, but no red link -line is drawn. Routers can have multiple wireless links and both wireless and -wired links (however, you will need to manually configure route -redistribution.) The mdr node type will generate a routing configuration that -enables OSPFv3 with MANET extensions. This is a Boeing-developed extension to -Quagga's OSPFv3 that reduces flooding overhead and optimizes the flooding -procedure for mobile ad-hoc (MANET) networks. - -The default configuration of the WLAN is set to use the basic range model. Having this model -selected causes **core-daemon** to calculate the distance between nodes based -on screen pixels. A numeric range in screen pixels is set for the wireless -network using the **Range** slider. When two wireless nodes are within range of -each other, a green line is drawn between them and they are linked. Two -wireless nodes that are farther than the range pixels apart are not linked. -During Execute mode, users may move wireless nodes around by clicking and -dragging them, and wireless links will be dynamically made or broken. - -The **EMANE Nodes** leverage available EMANE models to use for wireless networking. -See the [EMANE](emane.md) chapter for details on using EMANE. - -### Mobility Scripting - -CORE has a few ways to script mobility. - -| Option | Description | -|--------------|---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| -| ns-2 script | The script specifies either absolute positions or waypoints with a velocity. Locations are given with Cartesian coordinates. | -| CORE API | An external entity can move nodes by sending CORE API Node messages with updated X,Y coordinates; the **coresendmsg** utility allows a shell script to generate these messages. | -| EMANE events | See [EMANE](emane.md) for details on using EMANE scripts to move nodes around. Location information is typically given as latitude, longitude, and altitude. | - -For the first method, you can create a mobility script using a text -editor, or using a tool such as [BonnMotion](http://net.cs.uni-bonn.de/wg/cs/applications/bonnmotion/), and associate the script with one of the wireless -using the WLAN configuration dialog box. Click the *ns-2 mobility script...* -button, and set the *mobility script file* field in the resulting *ns2script* -configuration dialog. - -Here is an example for creating a BonnMotion script for 10 nodes: - -```shell -bm -f sample RandomWaypoint -n 10 -d 60 -x 1000 -y 750 -bm NSFile -f sample -# use the resulting 'sample.ns_movements' file in CORE -``` - -When the Execute mode is started and one of the WLAN nodes has a mobility -script, a mobility script window will appear. This window contains controls for -starting, stopping, and resetting the running time for the mobility script. The -**loop** checkbox causes the script to play continuously. The **resolution** text -box contains the number of milliseconds between each timer event; lower values -cause the mobility to appear smoother but consumes greater CPU time. - -The format of an ns-2 mobility script looks like: - -```shell -# nodes: 3, max time: 35.000000, max x: 600.00, max y: 600.00 -$node_(2) set X_ 144.0 -$node_(2) set Y_ 240.0 -$node_(2) set Z_ 0.00 -$ns_ at 1.00 "$node_(2) setdest 130.0 280.0 15.0" -``` - -The first three lines set an initial position for node 2. The last line in the -above example causes node 2 to move towards the destination **(130, 280)** at -speed **15**. All units are screen coordinates, with speed in units per second. -The total script time is learned after all nodes have reached their waypoints. -Initially, the time slider in the mobility script dialog will not be -accurate. - -Examples mobility scripts (and their associated topology files) can be found -in the **configs/** directory. - -## Alerts - -The alerts button is located in the bottom right-hand corner -of the status bar in the CORE GUI. This will change colors to indicate one or -more problems with the running emulation. Clicking on the alerts button will invoke the -alerts dialog. - -The alerts dialog contains a list of alerts received from -the CORE daemon. An alert has a time, severity level, optional node number, -and source. When the alerts button is red, this indicates one or more fatal -exceptions. An alert with a fatal severity level indicates that one or more -of the basic pieces of emulation could not be created, such as failure to -create a bridge or namespace, or the failure to launch EMANE processes for an -EMANE-based network. - -Clicking on an alert displays details for that -exceptio. The exception source is a text string -to help trace where the exception occurred; "service:UserDefined" for example, -would appear for a failed validation command with the UserDefined service. - -A button is available at the bottom of the dialog for clearing the exception -list. - -## Customizing your Topology's Look - -Several annotation tools are provided for changing the way your topology is -presented. Captions may be added with the Text tool. Ovals and rectangles may -be drawn in the background, helpful for visually grouping nodes together. - -During live demonstrations the marker tool may be helpful for drawing temporary -annotations on the canvas that may be quickly erased. A size and color palette -appears at the bottom of the toolbar when the marker tool is selected. Markings -are only temporary and are not saved in the topology file. - -The basic node icons can be replaced with a custom image of your choice. Icons -appear best when they use the GIF or PNG format with a transparent background. -To change a node's icon, double-click the node to invoke its configuration -dialog and click on the button to the right of the node name that shows the -node's current icon. - -A background image for the canvas may be set using the *Wallpaper...* option -from the *Canvas* menu. The image may be centered, tiled, or scaled to fit the -canvas size. An existing terrain, map, or network diagram could be used as a -background, for example, with CORE nodes drawn on top. diff --git a/docs/services.md b/docs/services.md index f92e5df1..7ff50c0e 100644 --- a/docs/services.md +++ b/docs/services.md @@ -63,13 +63,6 @@ toolbar, or choose *Node types...* from the *Session* menu. Note that any new services selected are not applied to existing nodes if the nodes have been customized. -The node types are saved in a **~/.core/nodes.conf** file, not with the -**.imn** file. Keep this in mind when changing the default services for -existing node types; it may be better to simply create a new node type. It is -recommended that you do not change the default built-in node types. The -**nodes.conf** file can be copied between CORE machines to save your custom -types. - ## Customizing a Service A service can be fully customized for a particular node. From the node's @@ -151,11 +144,11 @@ ideas for a service before adding a new service type. defines one or more classes to be imported. You can create multiple Python files that will be imported. -2. Put these files in a directory such as /home/username/.core/myservices - Note that the last component of this directory name **myservices** should not - be named something like **services** which conflicts with an existing module. +2. Put these files in a directory such as `/home//.coregui/custom_services` + Note that the last component of this directory name **custom_services** should not + be named the same as any python module, due to naming conflicts. -3. Add a **custom_services_dir = /home/username/.core/myservices** entry to the +3. Add a **custom_services_dir = `/home//.coregui/custom_services`** entry to the /etc/core/core.conf file. **NOTE:** @@ -165,7 +158,7 @@ ideas for a service before adding a new service type. or **services**. 4. Restart the CORE daemon (core-daemon). Any import errors (Python syntax) - should be displayed in the /var/log/core-daemon.log log file (or on screen). + should be displayed in the daemon output. 5. Start using your custom service on your nodes. You can create a new node type that uses your service, or change the default services for an existing diff --git a/docs/static/architecture.png b/docs/static/architecture.png index e07542a4..f4ce3388 100644 Binary files a/docs/static/architecture.png and b/docs/static/architecture.png differ diff --git a/docs/static/core-pygui.png b/docs/static/core-gui.png similarity index 100% rename from docs/static/core-pygui.png rename to docs/static/core-gui.png diff --git a/docs/static/core_screenshot.png b/docs/static/core_screenshot.png deleted file mode 100644 index 410754e9..00000000 Binary files a/docs/static/core_screenshot.png and /dev/null differ diff --git a/docs/static/distributed-controlnetwork.png b/docs/static/distributed-controlnetwork.png deleted file mode 100644 index ed9b0354..00000000 Binary files a/docs/static/distributed-controlnetwork.png and /dev/null differ diff --git a/docs/static/distributed-emane-network.png b/docs/static/distributed-emane-network.png deleted file mode 100644 index ebc5577f..00000000 Binary files a/docs/static/distributed-emane-network.png and /dev/null differ diff --git a/docs/static/distributed-emane-configuration.png b/docs/static/emane-configuration.png similarity index 100% rename from docs/static/distributed-emane-configuration.png rename to docs/static/emane-configuration.png diff --git a/docs/static/single-pc-emane.png b/docs/static/emane-single-pc.png similarity index 100% rename from docs/static/single-pc-emane.png rename to docs/static/emane-single-pc.png diff --git a/docs/static/gui/document-properties.gif b/docs/static/gui/document-properties.gif deleted file mode 100644 index 732d8436..00000000 Binary files a/docs/static/gui/document-properties.gif and /dev/null differ diff --git a/docs/static/gui/host.gif b/docs/static/gui/host.gif deleted file mode 100644 index 5bd60ae3..00000000 Binary files a/docs/static/gui/host.gif and /dev/null differ diff --git a/docs/static/pygui/host.png b/docs/static/gui/host.png similarity index 100% rename from docs/static/pygui/host.png rename to docs/static/gui/host.png diff --git a/docs/static/gui/hub.gif b/docs/static/gui/hub.gif deleted file mode 100644 index 17f7c4d3..00000000 Binary files a/docs/static/gui/hub.gif and /dev/null differ diff --git a/docs/static/pygui/hub.png b/docs/static/gui/hub.png similarity index 100% rename from docs/static/pygui/hub.png rename to docs/static/gui/hub.png diff --git a/docs/static/gui/lanswitch.gif b/docs/static/gui/lanswitch.gif deleted file mode 100644 index 38fcbb2e..00000000 Binary files a/docs/static/gui/lanswitch.gif and /dev/null differ diff --git a/docs/static/pygui/lanswitch.png b/docs/static/gui/lanswitch.png similarity index 100% rename from docs/static/pygui/lanswitch.png rename to docs/static/gui/lanswitch.png diff --git a/docs/static/gui/link.gif b/docs/static/gui/link.gif deleted file mode 100644 index 55532ecf..00000000 Binary files a/docs/static/gui/link.gif and /dev/null differ diff --git a/docs/static/pygui/link.png b/docs/static/gui/link.png similarity index 100% rename from docs/static/pygui/link.png rename to docs/static/gui/link.png diff --git a/docs/static/gui/marker.gif b/docs/static/gui/marker.gif deleted file mode 100644 index d7ed153c..00000000 Binary files a/docs/static/gui/marker.gif and /dev/null differ diff --git a/docs/static/pygui/marker.png b/docs/static/gui/marker.png similarity index 100% rename from docs/static/pygui/marker.png rename to docs/static/gui/marker.png diff --git a/docs/static/gui/mdr.gif b/docs/static/gui/mdr.gif deleted file mode 100644 index d6762f65..00000000 Binary files a/docs/static/gui/mdr.gif and /dev/null differ diff --git a/docs/static/pygui/mdr.png b/docs/static/gui/mdr.png similarity index 100% rename from docs/static/pygui/mdr.png rename to docs/static/gui/mdr.png diff --git a/docs/static/gui/observe.gif b/docs/static/gui/observe.gif deleted file mode 100644 index 6b66e730..00000000 Binary files a/docs/static/gui/observe.gif and /dev/null differ diff --git a/docs/static/gui/oval.gif b/docs/static/gui/oval.gif deleted file mode 100644 index 4b3124d4..00000000 Binary files a/docs/static/gui/oval.gif and /dev/null differ diff --git a/docs/static/pygui/oval.png b/docs/static/gui/oval.png similarity index 100% rename from docs/static/pygui/oval.png rename to docs/static/gui/oval.png diff --git a/docs/static/gui/pc.gif b/docs/static/gui/pc.gif deleted file mode 100644 index 743fb500..00000000 Binary files a/docs/static/gui/pc.gif and /dev/null differ diff --git a/docs/static/pygui/pc.png b/docs/static/gui/pc.png similarity index 100% rename from docs/static/pygui/pc.png rename to docs/static/gui/pc.png diff --git a/docs/static/gui/rectangle.gif b/docs/static/gui/rectangle.gif deleted file mode 100644 index ed271f57..00000000 Binary files a/docs/static/gui/rectangle.gif and /dev/null differ diff --git a/docs/static/pygui/rectangle.png b/docs/static/gui/rectangle.png similarity index 100% rename from docs/static/pygui/rectangle.png rename to docs/static/gui/rectangle.png diff --git a/docs/static/gui/rj45.gif b/docs/static/gui/rj45.gif deleted file mode 100644 index 9ab7ac56..00000000 Binary files a/docs/static/gui/rj45.gif and /dev/null differ diff --git a/docs/static/pygui/rj45.png b/docs/static/gui/rj45.png similarity index 100% rename from docs/static/pygui/rj45.png rename to docs/static/gui/rj45.png diff --git a/docs/static/gui/router.gif b/docs/static/gui/router.gif deleted file mode 100644 index eaf145eb..00000000 Binary files a/docs/static/gui/router.gif and /dev/null differ diff --git a/docs/static/pygui/router.png b/docs/static/gui/router.png similarity index 100% rename from docs/static/pygui/router.png rename to docs/static/gui/router.png diff --git a/docs/static/gui/router_green.gif b/docs/static/gui/router_green.gif deleted file mode 100644 index 76e3ecd5..00000000 Binary files a/docs/static/gui/router_green.gif and /dev/null differ diff --git a/docs/static/gui/run.gif b/docs/static/gui/run.gif deleted file mode 100644 index 71dcc67e..00000000 Binary files a/docs/static/gui/run.gif and /dev/null differ diff --git a/docs/static/pygui/run.png b/docs/static/gui/run.png similarity index 100% rename from docs/static/pygui/run.png rename to docs/static/gui/run.png diff --git a/docs/static/gui/select.gif b/docs/static/gui/select.gif deleted file mode 100644 index bb7e128c..00000000 Binary files a/docs/static/gui/select.gif and /dev/null differ diff --git a/docs/static/pygui/select.png b/docs/static/gui/select.png similarity index 100% rename from docs/static/pygui/select.png rename to docs/static/gui/select.png diff --git a/docs/static/gui/start.gif b/docs/static/gui/start.gif deleted file mode 100644 index a73c36fb..00000000 Binary files a/docs/static/gui/start.gif and /dev/null differ diff --git a/docs/static/pygui/start.png b/docs/static/gui/start.png similarity index 100% rename from docs/static/pygui/start.png rename to docs/static/gui/start.png diff --git a/docs/static/gui/stop.gif b/docs/static/gui/stop.gif deleted file mode 100644 index 02c28668..00000000 Binary files a/docs/static/gui/stop.gif and /dev/null differ diff --git a/docs/static/pygui/stop.png b/docs/static/gui/stop.png similarity index 100% rename from docs/static/pygui/stop.png rename to docs/static/gui/stop.png diff --git a/docs/static/gui/text.gif b/docs/static/gui/text.gif deleted file mode 100644 index 65508214..00000000 Binary files a/docs/static/gui/text.gif and /dev/null differ diff --git a/docs/static/pygui/text.png b/docs/static/gui/text.png similarity index 100% rename from docs/static/pygui/text.png rename to docs/static/gui/text.png diff --git a/docs/static/gui/tunnel.gif b/docs/static/gui/tunnel.gif deleted file mode 100644 index d574147f..00000000 Binary files a/docs/static/gui/tunnel.gif and /dev/null differ diff --git a/docs/static/pygui/tunnel.png b/docs/static/gui/tunnel.png similarity index 100% rename from docs/static/pygui/tunnel.png rename to docs/static/gui/tunnel.png diff --git a/docs/static/gui/twonode.gif b/docs/static/gui/twonode.gif deleted file mode 100644 index 28e75fac..00000000 Binary files a/docs/static/gui/twonode.gif and /dev/null differ diff --git a/docs/static/gui/wlan.gif b/docs/static/gui/wlan.gif deleted file mode 100644 index d72fe9c3..00000000 Binary files a/docs/static/gui/wlan.gif and /dev/null differ diff --git a/docs/static/pygui/wlan.png b/docs/static/gui/wlan.png similarity index 100% rename from docs/static/pygui/wlan.png rename to docs/static/gui/wlan.png diff --git a/docs/static/pygui/OVS.gif b/docs/static/pygui/OVS.gif deleted file mode 100755 index 38fcbb2e..00000000 Binary files a/docs/static/pygui/OVS.gif and /dev/null differ diff --git a/docs/static/pygui/alert.png b/docs/static/pygui/alert.png deleted file mode 100644 index 718fa9f1..00000000 Binary files a/docs/static/pygui/alert.png and /dev/null differ diff --git a/docs/static/pygui/antenna.gif b/docs/static/pygui/antenna.gif deleted file mode 100644 index 55814324..00000000 Binary files a/docs/static/pygui/antenna.gif and /dev/null differ diff --git a/docs/static/pygui/cancel.png b/docs/static/pygui/cancel.png deleted file mode 100644 index 1d95ba0c..00000000 Binary files a/docs/static/pygui/cancel.png and /dev/null differ diff --git a/docs/static/pygui/core-icon.png b/docs/static/pygui/core-icon.png deleted file mode 100644 index 0b0ff5aa..00000000 Binary files a/docs/static/pygui/core-icon.png and /dev/null differ diff --git a/docs/static/pygui/delete.png b/docs/static/pygui/delete.png deleted file mode 100644 index 01b498d4..00000000 Binary files a/docs/static/pygui/delete.png and /dev/null differ diff --git a/docs/static/pygui/docker.png b/docs/static/pygui/docker.png deleted file mode 100644 index 6021c640..00000000 Binary files a/docs/static/pygui/docker.png and /dev/null differ diff --git a/docs/static/pygui/document-new.gif b/docs/static/pygui/document-new.gif deleted file mode 100644 index 570b45e6..00000000 Binary files a/docs/static/pygui/document-new.gif and /dev/null differ diff --git a/docs/static/pygui/document-properties.gif b/docs/static/pygui/document-properties.gif deleted file mode 100644 index 732d8436..00000000 Binary files a/docs/static/pygui/document-properties.gif and /dev/null differ diff --git a/docs/static/pygui/document-save.gif b/docs/static/pygui/document-save.gif deleted file mode 100644 index 165bcb90..00000000 Binary files a/docs/static/pygui/document-save.gif and /dev/null differ diff --git a/docs/static/pygui/edit-delete.gif b/docs/static/pygui/edit-delete.gif deleted file mode 100644 index d23f758c..00000000 Binary files a/docs/static/pygui/edit-delete.gif and /dev/null differ diff --git a/docs/static/pygui/edit-node.png b/docs/static/pygui/edit-node.png deleted file mode 100644 index 28490eff..00000000 Binary files a/docs/static/pygui/edit-node.png and /dev/null differ diff --git a/docs/static/pygui/emane.png b/docs/static/pygui/emane.png deleted file mode 100644 index 1baa933d..00000000 Binary files a/docs/static/pygui/emane.png and /dev/null differ diff --git a/docs/static/pygui/error.png b/docs/static/pygui/error.png deleted file mode 100644 index d73d1dd4..00000000 Binary files a/docs/static/pygui/error.png and /dev/null differ diff --git a/docs/static/pygui/fileopen.gif b/docs/static/pygui/fileopen.gif deleted file mode 100644 index fb744207..00000000 Binary files a/docs/static/pygui/fileopen.gif and /dev/null differ diff --git a/docs/static/pygui/lxc.png b/docs/static/pygui/lxc.png deleted file mode 100644 index b944b231..00000000 Binary files a/docs/static/pygui/lxc.png and /dev/null differ diff --git a/docs/static/pygui/markerclear.png b/docs/static/pygui/markerclear.png deleted file mode 100644 index 6f58c005..00000000 Binary files a/docs/static/pygui/markerclear.png and /dev/null differ diff --git a/docs/static/pygui/observe.gif b/docs/static/pygui/observe.gif deleted file mode 100644 index 6b66e730..00000000 Binary files a/docs/static/pygui/observe.gif and /dev/null differ diff --git a/docs/static/pygui/pause.png b/docs/static/pygui/pause.png deleted file mode 100644 index 9ac4e6ea..00000000 Binary files a/docs/static/pygui/pause.png and /dev/null differ diff --git a/docs/static/pygui/plot.gif b/docs/static/pygui/plot.gif deleted file mode 100644 index 3924adbf..00000000 Binary files a/docs/static/pygui/plot.gif and /dev/null differ diff --git a/docs/static/pygui/prouter.png b/docs/static/pygui/prouter.png deleted file mode 100644 index b0ccf664..00000000 Binary files a/docs/static/pygui/prouter.png and /dev/null differ diff --git a/docs/static/pygui/shutdown.png b/docs/static/pygui/shutdown.png deleted file mode 100644 index 532f2cb9..00000000 Binary files a/docs/static/pygui/shutdown.png and /dev/null differ diff --git a/docs/static/pygui/twonode.png b/docs/static/pygui/twonode.png deleted file mode 100644 index 6828db8e..00000000 Binary files a/docs/static/pygui/twonode.png and /dev/null differ diff --git a/docs/static/workflow.png b/docs/static/workflow.png index cff86d07..35613983 100644 Binary files a/docs/static/workflow.png and b/docs/static/workflow.png differ diff --git a/gui/.gitignore b/gui/.gitignore deleted file mode 100644 index dea55215..00000000 --- a/gui/.gitignore +++ /dev/null @@ -1,2 +0,0 @@ -core-gui-legacy -version.tcl diff --git a/gui/Makefile.am b/gui/Makefile.am deleted file mode 100644 index 938769a2..00000000 --- a/gui/Makefile.am +++ /dev/null @@ -1,41 +0,0 @@ -# CORE -# (c)2010-2013 the Boeing Company. -# See the LICENSE file included in this distribution. -# -# author: Jeff Ahrenholz -# -# Makefile for installing the CORE GUI. Since it is a Tcl/Tk script, we do not -# build anything here. -# - -SUBDIRS = icons - -TCL_FILES := $(wildcard *.tcl) -ADDONS_FILES := $(wildcard addons/*) -CONFIG_FILES := $(wildcard configs/*) - -# CORE GUI script (/usr/local/bin/core-gui-legacy) -dist_bin_SCRIPTS = core-gui-legacy - -# Tcl/Tk scripts (/usr/local/lib/core) -coredir = $(CORE_LIB_DIR) -dist_core_DATA = $(TCL_FILES) -dist_core_SCRIPTS = $(OTHER_FILES) - -# Addon files -coreaddonsdir = $(coredir)/addons -dist_coreaddons_DATA = $(ADDONS_FILES) - -# Sample configs (/usr/local/share/core/examples/configs) -coreconfigsdir = $(datadir)/core/examples/configs -dist_coreconfigs_DATA = $(CONFIG_FILES) - -# remove generated file from dist -dist-hook: - -rm -f $(distdir)/version.tcl - -# extra cruft to remove -DISTCLEANFILES = Makefile.in - -# files to include in source tarball not included elsewhere -EXTRA_DIST = core-gui-legacy.in diff --git a/gui/addons/ipsecservice.tcl b/gui/addons/ipsecservice.tcl deleted file mode 100644 index c859852a..00000000 --- a/gui/addons/ipsecservice.tcl +++ /dev/null @@ -1,329 +0,0 @@ -# -# This is a separate "addons" file because it is closely tied to Python -# service definition for the IPsec service. -# - -# -# Helper dialog for configuring the IPsec service -# -proc popupServiceConfig_IPsec { parent w node service btn } { - global plugin_img_add plugin_img_del plugin_img_edit - - set f $w.note.ipsec - ttk::frame $f - set h "This IPsec service helper will assist with building an ipsec.sh file" - set h "$h (located on the Files tab).\nThe IPsec service builds ESP" - set h "$h tunnels between the specified peers using the racoon IKEv2" - set h "$h\nkeying daemon. You need to provide keys and the addresses of" - set h "$h peers, along with the\nsubnets to tunnel." - ttk::label $f.help -text $h - pack $f.help -side top -anchor w -padx 4 -pady 4 - $w.note add $f -text "IPsec" -underline 0 - - global g_ipsec_key_dir g_ipsec_key_name - set g_ipsec_key_dir "/etc/core/keys" - set g_ipsec_key_name "ipsec1" - ttk::labelframe $f.keys -text "Keys" - - ttk::frame $f.keys.dir - ttk::label $f.keys.dir.lab -text "Key directory:" - ttk::entry $f.keys.dir.ent -width 40 -textvariable g_ipsec_key_dir - ttk::button $f.keys.dir.btn -width 5 -text "..." -command { - set f .popupServicesCustomize.note.ipsec - set d [$f.keys.dir.ent get] - set d [tk_chooseDirectory -initialdir $d -title "Key directory"] - if { $d != "" } { - $f.keys.dir.ent delete 0 end - $f.keys.dir.ent insert 0 $d - } - } - pack $f.keys.dir.lab $f.keys.dir.ent $f.keys.dir.btn \ - -side left -padx 4 -pady 4 - pack $f.keys.dir -side top -anchor w - - ttk::frame $f.keys.name - ttk::label $f.keys.name.lab -text "Key base name:" - ttk::entry $f.keys.name.ent -width 10 -textvariable g_ipsec_key_name - pack $f.keys.name.lab $f.keys.name.ent -side left -padx 4 -pady 4 - pack $f.keys.name -side top -anchor w - - set h "The (name).pem x509 certificate and (name).key RSA private key need" - set h "$h to exist in the\nspecified directory. These can be generated" - set h "$h using the openssl tool. Also, a ca-cert.pem\nfile should exist" - set h "$h in the key directory for the CA that issued the certs." - ttk::label $f.keys.help -text $h - pack $f.keys.help -side top -anchor w -padx 4 -pady 4 - - pack $f.keys -side top -pady 4 -pady 4 -expand true -fill x - - ttk::labelframe $f.t -text "IPsec Tunnel Endpoints" - set h "(1) Define tunnel endpoints (select peer node using the button" - set h "$h, then select address from the list)" - ttk::label $f.t.lab1 -text $h - pack $f.t.lab1 -side top -anchor w -padx 4 -pady 4 - ttk::frame $f.t.ep - ttk::label $f.t.ep.lab1 -text "Local:" - ttk::combobox $f.t.ep.combo1 -width 12 - pack $f.t.ep.lab1 $f.t.ep.combo1 -side left -padx 4 -pady 4 - populateComboWithIPs $f.t.ep.combo1 $node - - global g_twoNodeSelect g_twoNodeSelectCallback - set g_twoNodeSelect "" - set g_twoNodeSelectCallback selectTwoNodeIPsecCallback - - set h "Choose a node by clicking it on the canvas" - set h "$h or\nby selecting it from the list below." - ttk::label $f.t.ep.lab2 -text "Peer node:" - ttk::checkbutton $f.t.ep.node -text " (none) " -variable g_twoNodeSelect \ - -onvalue "$f.t.ep.node" -style Toolbutton \ - -command "popupSelectNodes {$h} {} selectNodesIPsecCallback" - - ttk::label $f.t.ep.lab3 -text "Peer:" - ttk::combobox $f.t.ep.combo2 -width 12 - ttk::button $f.t.ep.add -text "Add Endpoint" -image $plugin_img_add \ - -compound left -command "ipsecTreeHelper $f ep" - pack $f.t.ep.lab2 $f.t.ep.node $f.t.ep.lab3 $f.t.ep.combo2 \ - $f.t.ep.add -side left -padx 4 -pady 4 - pack $f.t.ep -side top -anchor w - - set h "(2) Select endpoints below and add the subnets to be encrypted" - ttk::label $f.t.lab2 -text $h - pack $f.t.lab2 -side top -anchor w -padx 4 -pady 4 - - ttk::frame $f.t.sub - ttk::label $f.t.sub.lab1 -text "Local subnet:" - ttk::combobox $f.t.sub.combo1 -width 12 - ttk::label $f.t.sub.lab2 -text "Remote subnet:" - ttk::combobox $f.t.sub.combo2 -width 12 - ttk::button $f.t.sub.add -text "Add Subnet" -image $plugin_img_add \ - -compound left -command "ipsecTreeHelper $f sub" - pack $f.t.sub.lab1 $f.t.sub.combo1 $f.t.sub.lab2 $f.t.sub.combo2 \ - $f.t.sub.add -side left -padx 5 -pady 4 - pack $f.t.sub -side top -anchor w - - global node_list - set net_list [ipv4SubnetList $node_list] - $f.t.sub.combo1 configure -values $net_list - $f.t.sub.combo2 configure -values $net_list - - ttk::treeview $f.t.tree -height 5 -selectmode browse -show tree - - pack $f.t.tree -side top -padx 4 -pady 4 -fill both - pack $f.t -side top -expand true -fill both - - ttk::frame $f.bottom - ttk::button $f.bottom.del -image $plugin_img_del \ - -command "ipsecTreeHelper $f del" - ttk::button $f.bottom.gen -text "Generate ipsec.sh" \ - -image $plugin_img_edit -compound left -command "generateIPsecScript $w" - pack $f.bottom.del $f.bottom.gen -side left -padx 4 -pady 4 - pack $f.bottom -side top -} - -# -# Callback invoked when receiving configuration values -# from a Configuration Message; this service helper depends on the ipsec.sh -# file, not the other configuration values. -# -#proc popupServiceConfig_IPsec_vals { node values services w } { -#} - -# -# Callback invoked when receiving service file data from a File Message -proc popupServiceConfig_IPsec_file { node name data w } { - if { $name == "ipsec.sh" } { - readIPsecScript $w - } -} - -# helper to insert all of a node's IP addresses into a combo -proc populateComboWithIPs { combo node } { - set ip_list [ipv4List $node 0] - $combo configure -values $ip_list - $combo delete 0 end - $combo insert 0 [lindex $ip_list 0] -} - -# called from editor.tcl:button1 when user clicks on a node -# search for IP address and populate -proc selectTwoNodeIPsecCallback {} { - set w .popupServicesCustomize - set f $w.note.ipsec - - if { ![winfo exists $w] } { return }; # user has closed window - catch {destroy .nodeselect} - - set node [string trim [$f.t.ep.node cget -text]] - if { [set node] == "(none)" } { set node "" } - - # populate peer interface combo with list of IPs - populateComboWithIPs $f.t.ep.combo2 $node -} - -# called from popupSelectNodes dialog when a node selection has been made -proc selectNodesIPsecCallback { nodes } { - global g_twoNodeSelect - set w .popupServicesCustomize - set f $w.note.ipsec - - set g_twoNodeSelect "" - set node [lindex $nodes 0] - if { $node == "" } { - $f.t.ep.node configure -text "(none)" - return - } - $f.t.ep.node configure -text " $node " - - # populate peer interface combo with list of IPs - populateComboWithIPs $f.t.ep.combo2 $node -} - -# helper to manipulate tree; cmd is "del", "ep" or "sub" -proc ipsecTreeHelper { f cmd } { - - if { $cmd == "del" } { - set sel [$f.t.tree selection] - $f.t.tree delete $sel - return - } - - # add endpoint (ep) or subnet (sub) - set l [string trim [$f.t.$cmd.combo1 get]] - set p [string trim [$f.t.$cmd.combo2 get]] - if { $l == "" || $p == "" } { - if { $cmd == "ep" } { - set h "tunnel interface addresses" - } else { - set h "subnet addresses" - } - tk_messageBox -type ok -icon warning -message \ - "You need to select local and peer $h." - return - } - - if { $cmd == "ep" } { - set item [$f.t.tree insert {} end -text "$l <--> $p" -open true] - $f.t.tree selection set $item - } elseif { $cmd == "sub" } { - set parent [$f.t.tree selection] - if { $parent == "" } { - tk_messageBox -type ok -icon warning -message \ - "You need to first select endpoints, then configure their subnets." - return - } - if { [$f.t.tree parent $parent] != {} } { - set parent [$f.t.tree parent $parent] - } - $f.t.tree insert $parent end -text "$l <===> $p" - } -} - -# update an ipsec.sh file that was generated by the IPsec service -proc generateIPsecScript { w } { - #puts "generateIPsecScript $w..." - set cfg [$w.note.files.txt get 0.0 end-1c] - set newcfg "" - - # - # Gather data for a new config - # - set f $w.note.ipsec - set keydir [$f.keys.dir.ent get] - set keyname [$f.keys.name.ent get] - - set tunnelhosts "" - set subnet_list "" - set ti 0 - set th_items [$f.t.tree children {}] - foreach th $th_items { - set ep [$f.t.tree item $th -text] - set i [string first " " $ep] - # replace " <--> " with "AND" - set ep [string replace $ep $i $i+5 "AND"] - # build a list e.g.: - # tunnelhosts="172.16.0.1AND172.16.0.2 172.16.0.1AND172.16.2.1" - lappend tunnelhosts $ep - - set subnets "" - foreach subnet_item [$f.t.tree children $th] { - set sn [$f.t.tree item $subnet_item -text] - set i [string first " " $sn] - # replace " <===> " with "AND" - set sn [string replace $sn $i $i+6 "AND"] - lappend subnets $sn - } - incr ti - set subnetstxt [join $subnets " "] - # build a list e.g.: - # T2="172.16.4.0/24AND172.16.5.0/24 172.16.4.0/24AND172.16.6.0/24" - set subnets "T$ti=\"$subnetstxt\"" - lappend subnet_list $subnets - } - - # - # Perform replacements in existing ipsec.sh file. - # - set have_subnets 0 - foreach line [split $cfg "\n"] { - if { [string range $line 0 6] == "keydir=" } { - set line "keydir=$keydir" - } elseif { [string range $line 0 8] == "certname=" } { - set line "certname=$keyname" - } elseif { [string range $line 0 11] == "tunnelhosts=" } { - set tunnelhosts [join $tunnelhosts " "] - set line "tunnelhosts=\"$tunnelhosts\"" - } elseif { [string range $line 0 0] == "T" && \ - [string is digit [string range $line 1 1]] } { - if { $have_subnets } { - continue ;# skip this line - } else { - set line [join $subnet_list "\n"] - set have_subnets 1 - } - } - lappend newcfg $line - } - $w.note.files.txt delete 0.0 end - $w.note.files.txt insert 0.0 [join $newcfg "\n"] - $w.note select $w.note.files - $w.btn.apply configure -state normal -} - -proc readIPsecScript { w } { - set cfg [$w.note.files.txt get 0.0 end-1c] - - set f $w.note.ipsec - $f.keys.dir.ent delete 0 end - $f.keys.name.ent delete 0 end - $f.t.tree delete [$f.t.tree children {}] - - set ti 1 - foreach line [split $cfg "\n"] { - if { [string range $line 0 6] == "keydir=" } { - $f.keys.dir.ent insert 0 [string range $line 7 end] - } elseif { [string range $line 0 8] == "certname=" } { - $f.keys.name.ent insert 0 [string range $line 9 end] - } elseif { [string range $line 0 11] == "tunnelhosts=" } { - set tunnelhosts [string range $line 13 end-1] - set ti 0 - foreach ep [split $tunnelhosts " "] { - incr ti - set i [string first "AND" $ep] - set ep [string replace $ep $i $i+2 " <--> "] - $f.t.tree insert {} end -id "T$ti" -text "$ep" -open true - } - } elseif { [string range $line 0 0] == "T" && \ - [string is digit [string range $line 1 1]] } { - set i [string first "=" $line] - set ti [string range $line 0 $i-1] - set subnets [split [string range $line $i+2 end-1] " "] - foreach sn $subnets { - set i [string first "AND" $sn] - set sn [string replace $sn $i $i+2 " <===> "] - if { [catch {$f.t.tree insert $ti end -text "$sn"} e] } { - puts "IPsec service ignoring line '$ti='" - } - } - } - } -} diff --git a/gui/annotations.tcl b/gui/annotations.tcl deleted file mode 100644 index 8a2184d3..00000000 --- a/gui/annotations.tcl +++ /dev/null @@ -1,837 +0,0 @@ -# -# Copyright 2007-2008 University of Zagreb, Croatia. -# -# Redistribution and use in source and binary forms, with or without -# modification, are permitted provided that the following conditions -# are met: -# 1. Redistributions of source code must retain the above copyright -# notice, this list of conditions and the following disclaimer. -# 2. Redistributions in binary form must reproduce the above copyright -# notice, this list of conditions and the following disclaimer in the -# documentation and/or other materials provided with the distribution. -# -# THIS SOFTWARE IS PROVIDED BY AUTHOR AND CONTRIBUTORS ``AS IS'' AND -# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE -# ARE DISCLAIMED. IN NO EVENT SHALL AUTHOR OR CONTRIBUTORS BE LIABLE -# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS -# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) -# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY -# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF -# SUCH DAMAGE. -# - -#****h* imunes/annotations.tcl -# NAME -# annotations.tcl -- oval, rectangle, text, background, ... -# FUNCTION -# This module is used for configuration/image annotations, such as oval, -# rectangle, text, background or some other. -#**** - -#****f* annotations.tcl/annotationConfig -# NAME -# annotationConfig -- -# SYNOPSIS -# annotationConfig $canvas $target -# FUNCTION -# . . . -# INPUTS -# * canvas -- -# * target -- oval or rectangle object -#**** - -proc annotationConfig { c target } { - switch -exact -- [nodeType $target] { - oval { - popupAnnotationDialog $c $target "true" - } - rectangle { - popupAnnotationDialog $c $target "true" - } - text { - popupAnnotationDialog $c $target "true" - } - default { - puts "Unknown type [nodeType $target] for target $target" - } - } - redrawAll -} - - -#****f* annotations.tcl/popupOvalDialog -# NAME -# popupOvalDialog -- creates a new oval or modifies existing oval -# SYNOPSIS -# popupOvalDialog $canvas $modify $color $label $lcolor -# FUNCTION -# Called from: -# - editor.tcl/button1-release when new oval is drawn -# - annotationConfig which is called from popupConfigDialog bound to -# Double-1 on various objects -# - configureOval called from button3annotation procedure which creates -# a menu for configuration and deletion (bound to 3 on oval, -# rectangle and text) -# INPUTS -# * canvas -- -# * modify -- create new oval "newoval" if modify=false or -# modify an existing oval "newoval" if modify=true -# * color -- oval color -# * label -- label text -# * lcolor -- label (text) color -#**** - - -#****f* annotations.tcl/destroyNewoval -# NAME -# destroyNewoval -- helper for popupOvalDialog and popupOvalApply -# SYNOPSIS -# destroyNewoval $canvas -# FUNCTION -# . . . -# INPUTS -# * canvas -- -#**** - -proc destroyNewoval { c } { - global newoval - $c delete -withtags newoval - set newoval "" -} - - -# oval/rectangle/text right-click menu - -proc button3annotation { type c x y } { - - if { $type == "oval" } { - set procname "Oval" - set item [lindex [$c gettags {oval && current}] 1] - } elseif { $type == "rectangle" } { - set procname "Rectangle" - set item [lindex [$c gettags {rectangle && current}] 1] - } elseif { $type == "label" } { - set procname "Label" - set item [lindex [$c gettags {label && current}] 1] - } elseif { $type == "text" } { - set procname "Text" - set item [lindex [$c gettags {text && current}] 1] - } elseif { $type == "marker" } { - # erase markings - $c delete -withtags {marker && current} - return - } else { - # ??? - return - } - if { $item == "" } { - return - } - set menutext "$type $item" - - .button3menu delete 0 end - - .button3menu add command -label "Configure $menutext" \ - -command "annotationConfig $c $item" - .button3menu add command -label "Delete $menutext" \ - -command "deleteAnnotation $c $type $item" - - set x [winfo pointerx .] - set y [winfo pointery .] - tk_popup .button3menu $x $y -} - - -proc deleteAnnotation { c type target } { - global changed annotation_list - - $c delete -withtags "$type && $target" - $c delete -withtags "new$type" - set i [lsearch -exact $annotation_list $target] - set annotation_list [lreplace $annotation_list $i $i] - set changed 1 - updateUndoLog -} - - -proc drawOval {oval} { - global $oval defOvalColor zoom curcanvas - global defTextFontFamily defTextFontSize - - set coords [getNodeCoords $oval] - if { [llength $coords] < 4 } { - puts "Bad coordinates for oval $oval" - return - } - set x1 [expr {[lindex $coords 0] * $zoom}] - set y1 [expr {[lindex $coords 1] * $zoom}] - set x2 [expr {[lindex $coords 2] * $zoom}] - set y2 [expr {[lindex $coords 3] * $zoom}] - set color [lindex [lsearch -inline [set $oval] "color *"] 1] - set label [lindex [lsearch -inline [set $oval] "label *"] 1] - set lcolor [lindex [lsearch -inline [set $oval] "labelcolor *"] 1] - set bordercolor [lindex [lsearch -inline [set $oval] "border *"] 1] - set width [lindex [lsearch -inline [set $oval] "width *"] 1] - set lx [expr $x1 + (($x2 - $x1) / 2)] - set ly [expr ($y1 + 20)] - - if { $color == "" } { set color $defOvalColor } - if { $lcolor == "" } { set lcolor black } - if { $width == "" } { set width 0 } - if { $bordercolor == "" } { set bordercolor black } - - # -outline red -stipple gray50 - set newoval [.c create oval $x1 $y1 $x2 $y2 \ - -fill $color -width $width -outline $bordercolor \ - -tags "oval $oval annotation"] - .c raise $newoval background - - set fontfamily [lindex [lsearch -inline [set $oval] "fontfamily *"] 1] - set fontsize [lindex [lsearch -inline [set $oval] "fontsize *"] 1] - if { $fontfamily == "" } { - set fontfamily $defTextFontFamily - } - if { $fontsize == "" } { - set fontsize $defTextFontSize - } - set newfontsize $fontsize - set font [list "$fontfamily" $fontsize] - set effects [lindex [lsearch -inline [set $oval] "effects *"] 1] - - .c create text $lx $ly -tags "oval $oval annotation" -text $label \ - -justify center -font "$font $effects" -fill $lcolor - - setNodeCanvas $oval $curcanvas - setType $oval "oval" -} - - -# Color helper for popupOvalDialog and popupLabelDialog -proc popupColor { type l settext } { - # popup color selection dialog with current color - if { $type == "fg" } { - set initcolor [$l cget -fg] - } else { - set initcolor [$l cget -bg] - } - set newcolor [tk_chooseColor -initialcolor $initcolor] - - # set fg or bg of the "l" label control - if { $newcolor == "" } { - return - } - if { $settext == "true" } { - $l configure -text $newcolor -$type $newcolor - } else { - $l configure -$type $newcolor - } -} - - -#****f* annotations.tcl/roundRect -# NAME -# roundRect -- Draw a rounded rectangle in the canvas. -# Called from drawRect procedure -# SYNOPSIS -# roundRect $w $x0 $y0 $x3 $y3 $radius $args -# FUNCTION -# Creates a rounded rectangle as a smooth polygon in the canvas -# and returns the canvas item number of the rounded rectangle. -# INPUTS -# * w -- Path name of the canvas -# * x0, y0 -- Coordinates of the upper left corner, in pixels -# * x3, y3 -- Coordinates of the lower right corner, in pixels -# * radius -- Radius of the bend at the corners, in any form -# acceptable to Tk_GetPixels -# * args -- Other args suitable to a 'polygon' item on the canvas -# Example: -# roundRect .c 100 50 500 250 $rad -fill white -outline black -tags rectangle -#**** - -proc roundRect { w x0 y0 x3 y3 radius args } { - - set r [winfo pixels $w $radius] - set d [expr { 2 * $r }] - - # Make sure that the radius of the curve is less than 3/8 size of the box - - set maxr 0.75 - - if { $d > $maxr * ( $x3 - $x0 ) } { - set d [expr { $maxr * ( $x3 - $x0 ) }] - } - if { $d > $maxr * ( $y3 - $y0 ) } { - set d [expr { $maxr * ( $y3 - $y0 ) }] - } - - set x1 [expr { $x0 + $d }] - set x2 [expr { $x3 - $d }] - set y1 [expr { $y0 + $d }] - set y2 [expr { $y3 - $d }] - - set cmd [list $w create polygon] - lappend cmd $x0 $y0 $x1 $y0 $x2 $y0 $x3 $y0 $x3 $y1 $x3 $y2 - lappend cmd $x3 $y3 $x2 $y3 $x1 $y3 $x0 $y3 $x0 $y2 $x0 $y1 - lappend cmd -smooth 1 - return [eval $cmd $args] - } - -proc drawRect {rectangle} { - global $rectangle defRectColor zoom curcanvas - global defTextFontFamily defTextFontSize - - set coords [getNodeCoords $rectangle] - if {$coords == "" || [llength $coords] != 4 } { - puts "Bad coordinates for rectangle $rectangle" - return - } - - set x1 [expr {[lindex $coords 0] * $zoom}] - set y1 [expr {[lindex $coords 1] * $zoom}] - set x2 [expr {[lindex $coords 2] * $zoom}] - set y2 [expr {[lindex $coords 3] * $zoom}] - set color [lindex [lsearch -inline [set $rectangle] "color *"] 1] - set label [lindex [lsearch -inline [set $rectangle] "label *"] 1] - set lcolor [lindex [lsearch -inline [set $rectangle] "labelcolor *"] 1] - set bordercolor [lindex [lsearch -inline [set $rectangle] "border *"] 1] - set width [lindex [lsearch -inline [set $rectangle] "width *"] 1] - set rad [lindex [lsearch -inline [set $rectangle] "rad *"] 1] - set lx [expr $x1 + (($x2 - $x1) / 2)] - set ly [expr ($y1 + 20)] - - if { $color == "" } { set color $defRectColor } - if { $lcolor == "" } { set lcolor black } - if { $bordercolor == "" } { set bordercolor black } - if { $width == "" } { set width 0 } - # rounded-rectangle radius - if { $rad == "" } { set rad 25 } - - # Boeing: allow borderless rectangles - if { $width == 0 } { - set newrect [roundRect .c $x1 $y1 $x2 $y2 $rad \ - -fill $color -tags "rectangle $rectangle annotation"] - } else { - # end Boeing - set newrect [roundRect .c $x1 $y1 $x2 $y2 $rad \ - -fill $color -outline $bordercolor -width $width \ - -tags "rectangle $rectangle annotation"] - .c raise $newrect background - # Boeing - } - # end Boeing - - set fontfamily [lindex [lsearch -inline [set $rectangle] "fontfamily *"] 1] - set fontsize [lindex [lsearch -inline [set $rectangle] "fontsize *"] 1] - if { $fontfamily == "" } { - set fontfamily $defTextFontFamily - } - if { $fontsize == "" } { - set fontsize $defTextFontSize - } - set newfontsize $fontsize - set font [list "$fontfamily" $fontsize] - set effects [lindex [lsearch -inline [set $rectangle] "effects *"] 1] - - .c create text $lx $ly -tags "rectangle $rectangle annotation" \ - -text $label -justify center -font "$font $effects" -fill $lcolor - - setNodeCanvas $rectangle $curcanvas - setType $rectangle "rectangle" -} - - -proc popupAnnotationDialog { c target modify } { - global $target newrect newoval - global width rad fontfamily fontsize - global defFillColor defTextColor defTextFontFamily defTextFontSize - - # do nothing, return, if coords are empty - if { $target == 0 \ - && [$c coords "$newrect"] == "" \ - && [$c coords "$newoval"] == "" } { - return - } - if { $target == 0 } { - set width 0 - set rad 25 - set coords [$c bbox "$newrect"] - if { [$c coords "$newrect"] == "" } { - set coords [$c bbox "$newoval"] - set annotationType "oval" - } else { - set annotationType "rectangle" - } - set fontfamily "" - set fontsize "" - set effects "" - set color "" - set label "" - set lcolor "" - set bordercolor "" - } else { - set width [lindex [lsearch -inline [set $target] "width *"] 1] - set rad [lindex [lsearch -inline [set $target] "rad *"] 1] - set coords [$c bbox "$target"] - set color [lindex [lsearch -inline [set $target] "color *"] 1] - set fontfamily [lindex [lsearch -inline [set $target] "fontfamily *"] 1] - set fontsize [lindex [lsearch -inline [set $target] "fontsize *"] 1] - set effects [lindex [lsearch -inline [set $target] "effects *"] 1] - - set label [lindex [lsearch -inline [set $target] "label *"] 1] - set lcolor [lindex [lsearch -inline [set $target] "labelcolor *"] 1] - set bordercolor [lindex [lsearch -inline [set $target] "border *"] 1] - set annotationType [nodeType $target] - } - - if { $color == "" } { - # Boeing: use default shape colors - if { $annotationType == "oval" } { - global defOvalColor - set color $defOvalColor - } elseif { $annotationType == "rectangle" } { - global defRectColor - set color $defRectColor - } else { - set color $defFillColor - } - } - if { $lcolor == "" } { set lcolor black } - if { $bordercolor == "" } { set bordercolor black } - if { $width == "" } { set width 0 } - if { $rad == "" } { set rad 25 } - if { $fontfamily == "" } { set fontfamily $defTextFontFamily } - if { $fontsize == "" } { set fontsize $defTextFontSize } - - set textBold 0 - set textItalic 0 - set textUnderline 0 - if { [lsearch $effects bold ] != -1} {set textBold 1} - if { [lsearch $effects italic ] != -1} {set textItalic 1} - if { [lsearch $effects underline ] != -1} {set textUnderline 1} - - set x1 [lindex $coords 0] - set y1 [lindex $coords 1] - set x2 [lindex $coords 2] - set y2 [lindex $coords 3] - set xx [expr {abs($x2 - $x1)}] - set yy [expr {abs($y2 - $y1)}] - if { $xx > $yy } { - set maxrad [expr $yy * 3.0 / 8.0] - } else { - set maxrad [expr $xx * 3.0 / 8.0] - } - - set wi .popup - catch {destroy $wi} - toplevel $wi - - wm transient $wi . - wm resizable $wi 0 0 - - if { $modify == "true" } { - set windowtitle "Configure $annotationType $target" - } else { - set windowtitle "Add a new $annotationType" - } - wm title $wi $windowtitle - - frame $wi.text -relief groove -bd 2 - frame $wi.text.lab - label $wi.text.lab.name_label -text "Text for top of $annotationType:" - entry $wi.text.lab.name -bg white -fg $lcolor -width 32 \ - -validate focus -invcmd "focusAndFlash %W" - $wi.text.lab.name insert 0 $label - pack $wi.text.lab.name_label $wi.text.lab.name -side left -anchor w \ - -padx 2 -pady 2 -fill x - pack $wi.text.lab -side top -fill x - - frame $wi.text.format - - set fontmenu [tk_optionMenu $wi.text.format.fontmenu fontfamily "$fontfamily"] - set sizemenu [tk_optionMenu $wi.text.format.fontsize fontsize "$fontsize"] - - - # color selection - if { $color == "" } { - set color $defTextColor - } - button $wi.text.format.fg -text "Text color" -command \ - "popupColor fg $wi.text.lab.name false" - checkbutton $wi.text.format.bold -text "Bold" -variable textBold \ - -command [list fontupdate $wi.text.lab.name bold] - checkbutton $wi.text.format.italic -text "Italic" -variable textItalic \ - -command [list fontupdate $wi.text.lab.name italic] - checkbutton $wi.text.format.underline -text "Underline" \ - -variable textUnderline \ - -command [list fontupdate $wi.text.lab.name underline] - - if {$textBold == 1} { $wi.text.format.bold select - } else { $wi.text.format.bold deselect } - if {$textItalic == 1} { $wi.text.format.italic select - } else { $wi.text.format.italic deselect } - if {$textUnderline == 1} { $wi.text.format.underline select - } else { $wi.text.format.underline deselect } - - pack $wi.text.format.fontmenu \ - $wi.text.format.fontsize \ - $wi.text.format.fg \ - $wi.text.format.bold \ - $wi.text.format.italic \ - $wi.text.format.underline \ - -side left -pady 2 - - pack $wi.text.format -side top -fill x - - pack $wi.text -side top -fill x - - fontupdate $wi.text.lab.name fontfamily $fontfamily - fontupdate $wi.text.lab.name fontsize $fontsize - - $fontmenu delete 0 - foreach f [lsort -dictionary [font families]] { - $fontmenu add radiobutton -value "$f" -label $f \ - -variable fontfamily \ - -command [list fontupdate $wi.text.lab.name fontfamily $f] - } - - $sizemenu delete 0 - foreach f {8 9 10 11 12 14 16 18 20 22 24 26 28 36 48 72} { - $sizemenu add radiobutton -value "$f" -label $f \ - -variable fontsize \ - -command [list fontupdate $wi.text.lab.name fontsize $f] - } - -if { "$annotationType" == "rectangle" || "$annotationType" == "oval" } { - - # fill color, border color - frame $wi.colors -relief groove -bd 2 - # color selection controls - label $wi.colors.label -text "Fill color:" - - label $wi.colors.color -text $color -width 8 \ - -bg $color -fg $lcolor - button $wi.colors.bg -text "Color" -command \ - "popupColor bg $wi.colors.color true" - pack $wi.colors.label $wi.colors.color $wi.colors.bg \ - -side left -padx 2 -pady 2 -anchor w -fill x - pack $wi.colors -side top -fill x - - # border selection controls - frame $wi.border -relief groove -bd 2 - label $wi.border.label -text "Border color:" - label $wi.border.color -text $bordercolor -width 8 \ - -bg $color -fg $bordercolor - label $wi.border.width_label -text "Border width:" - set widthMenu [tk_optionMenu $wi.border.width width "$width"] - $widthMenu delete 0 - foreach f {0 1 2 3 4 5 6 7 8 9 10} { - $widthMenu add radiobutton -value $f -label $f \ - -variable width - } - button $wi.border.fg -text "Color" -command \ - "popupColor fg $wi.border.color true" - pack $wi.border.label $wi.border.color $wi.border.fg \ - $wi.border.width_label $wi.border.width \ - $wi.border.fg $wi.border.color $wi.border.label \ - -side left -padx 2 -pady 2 -anchor w -fill x - pack $wi.border -side top -fill x - -} - -if { $annotationType == "rectangle" } { - frame $wi.radius -relief groove -bd 2 - scale $wi.radius.rad -from 0 -to [expr int($maxrad)] \ - -length 400 -variable rad \ - -orient horizontal -label "Radius of the bend at the corners: " \ - -tickinterval [expr int($maxrad / 15) + 1] -showvalue true - pack $wi.radius.rad -side left -padx 2 -pady 2 -anchor w -fill x - pack $wi.radius -side top -fill x -} - - # Add new oval or modify old one? - if { $modify == "true" } { - set cancelcmd "destroy $wi" - set applytext "Modify $annotationType" - } else { - set cancelcmd "destroy $wi; destroyNewRect $c" - set applytext "Add $annotationType" - } - - frame $wi.butt -borderwidth 6 - button $wi.butt.apply -text $applytext -command "popupAnnotationApply $c $wi $target $annotationType" - - button $wi.butt.cancel -text "Cancel" -command $cancelcmd - bind $wi "$cancelcmd" - bind $wi "popupAnnotationApply $c $wi $target $annotationType" - pack $wi.butt.cancel $wi.butt.apply -side right - pack $wi.butt -side bottom - - after 100 { - grab .popup - } - return -} - -# helper for popupOvalDialog and popupOvalApply -proc destroyNewRect { c } { - global newrect - $c delete -withtags newrect - set newrect "" -} - - -proc popupAnnotationApply { c wi target type } { - global newrect newoval annotation_list - global $target - global changed - global width rad - global fontfamily fontsize textBold textItalic textUnderline - - # attributes - set caption [string trim [$wi.text.lab.name get]] - set labelcolor [$wi.text.lab.name cget -fg] - set coords [$c coords "$target"] - set iconcoords "iconcoords" - - if {"$type" == "rectangle" || "$type" == "oval" } { - set color [$wi.colors.color cget -text] - set bordercolor [$wi.border.color cget -text] - } - - if { $target == 0 } { - # Create a new annotation object - set target [newObjectId annotation] - global $target - lappend annotation_list $target - if {"$type" == "rectangle" } { - set coords [$c coords $newrect] - } elseif { "$type" == "oval" } { - set coords [$c coords $newoval] - } - } else { - set coords [getNodeCoords $target] - } - set $target {} - lappend $iconcoords $coords - lappend $target $iconcoords "label {$caption}" "labelcolor $labelcolor" \ - "fontfamily {$fontfamily}" "fontsize $fontsize" - if {"$type" == "rectangle" || "$type" == "oval" } { - lappend $target "color $color" "width $width" "border $bordercolor" - } - if {"$type" == "rectangle" } { - lappend $target "rad $rad" - } - - set ef {} - if {"$textBold" == 1} { lappend ef bold} - if {"$textItalic" == 1} { lappend ef italic} - if {"$textUnderline" == 1} { lappend ef underline} - if {"$ef" != ""} { lappend $target "effects {$ef}"} - - # draw it - if { $type == "rectangle" } { - drawRect $target - destroyNewRect $c - } elseif { $type == "oval" } { - drawOval $target - destroyNewoval $c - } elseif { $type == "text" } { - drawText $target - } - - set changed 1 - updateUndoLog - redrawAll - destroy $wi -} - -proc selectmarkEnter {c x y} { - set isThruplot false - - if {$c == ".c"} { - set obj [lindex [$c gettags current] 1] - set type [nodeType $obj] - if {$type != "oval" && $type != "rectangle"} { return } - } else { - set obj $c - set c .c - set isThruplot true - } - set bbox [$c bbox $obj] - - set x1 [lindex $bbox 0] - set y1 [lindex $bbox 1] - set x2 [lindex $bbox 2] - set y2 [lindex $bbox 3] - - if {$isThruplot == true} { - set x [expr $x+$x1] - set y [expr $y+$y1] - - } - set l 0 ;# left - set r 0 ;# right - set u 0 ;# up - set d 0 ;# down - - set x [$c canvasx $x] - set y [$c canvasy $y] - - if { $x < [expr $x1+($x2-$x1)/8.0]} { set l 1 } - if { $x > [expr $x2-($x2-$x1)/8.0]} { set r 1 } - if { $y < [expr $y1+($y2-$y1)/8.0]} { set u 1 } - if { $y > [expr $y2-($y2-$y1)/8.0]} { set d 1 } - - if {$l==1} { - if {$u==1} { - $c config -cursor top_left_corner - } elseif {$d==1} { - $c config -cursor bottom_left_corner - } else { - $c config -cursor left_side - } - } elseif {$r==1} { - if {$u==1} { - $c config -cursor top_right_corner - } elseif {$d==1} { - $c config -cursor bottom_right_corner - } else { - $c config -cursor right_side - } - } elseif {$u==1} { - $c config -cursor top_side - } elseif {$d==1} { - $c config -cursor bottom_side - } else { - $c config -cursor left_ptr - } -} - -proc selectmarkLeave {c x y} { - global thruplotResize - .bottom.textbox config -text {} - - # cursor options for thruplot resize - if {$thruplotResize == true} { - - } else { - # no resize update cursor - $c config -cursor left_ptr - } -} - - -proc textEnter { c x y } { - global annotation_list - global curcanvas - - set object [newObjectId annotation] - set newtext [$c create text $x $y -text "" \ - -anchor w -justify left -tags "text $object annotation"] - - set coords [$c coords "text && $object"] - set iconcoords "iconcoords" - - global $object - set $object {} - setType $object "text" - lappend $iconcoords $coords - lappend $object $iconcoords - lappend $object "label {}" - setNodeCanvas $object $curcanvas - - lappend annotation_list $object - popupAnnotationDialog $c $object "false" -} - - -proc drawText {text} { - global $text defTextColor defTextFont defTextFontFamily defTextFontSize - global zoom curcanvas newfontsize - - set coords [getNodeCoords $text] - if { [llength $coords] < 2 } { - puts "Bad coordinates for text $text" - return - } - set x [expr {[lindex $coords 0] * $zoom}] - set y [expr {[lindex $coords 1] * $zoom}] - set color [lindex [lsearch -inline [set $text] "labelcolor *"] 1] - if { $color == "" } { - set color $defTextColor - } - set label [lindex [lsearch -inline [set $text] "label *"] 1] - set fontfamily [lindex [lsearch -inline [set $text] "fontfamily *"] 1] - set fontsize [lindex [lsearch -inline [set $text] "fontsize *"] 1] - if { $fontfamily == "" } { - set fontfamily $defTextFontFamily - } - if { $fontsize == "" } { - set fontsize $defTextFontSize - } - set newfontsize $fontsize - set font [list "$fontfamily" $fontsize] - set effects [lindex [lsearch -inline [set $text] "effects *"] 1] - set newtext [.c create text $x $y -text $label -anchor w \ - -font "$font $effects" -justify left -fill $color \ - -tags "text $text annotation"] - - .c addtag text withtag $newtext - .c raise $text background - setNodeCanvas $text $curcanvas - setType $text "text" -} - - -proc fontupdate { label type args} { - global fontfamily fontsize - global textBold textItalic textUnderline - - if {"$textBold" == 1} {set bold "bold"} else {set bold {} } - if {"$textItalic"} {set italic "italic"} else {set italic {} } - if {"$textUnderline"} {set underline "underline"} else {set underline {} } - switch $type { - fontsize { - set fontsize $args - } - fontfamily { - set fontfamily "$args" - } - } - set f [list "$fontfamily" $fontsize] - lappend f "$bold $italic $underline" - $label configure -font "$f" -} - - -proc drawAnnotation { obj } { - switch -exact -- [nodeType $obj] { - oval { - drawOval $obj - } - rectangle { - drawRect $obj - } - text { - drawText $obj - } - } -} - -# shift annotation coordinates by dx, dy; does not redraw the annotation -proc moveAnnotation { obj dx dy } { - set coords [getNodeCoords $obj] - lassign $coords x1 y1 x2 y2 - set pt1 "[expr {$x1 + $dx}] [expr {$y1 + $dy}]" - if { [nodeType $obj] == "text" } { - # shift one point - setNodeCoords $obj $pt1 - } else { ;# oval/rectangle - # shift two points - set pt2 "[expr {$x2 + $dx}] [expr {$y2 + $dy}]" - setNodeCoords $obj "$pt1 $pt2" - } -} diff --git a/gui/api.tcl b/gui/api.tcl deleted file mode 100644 index 1801f82c..00000000 --- a/gui/api.tcl +++ /dev/null @@ -1,3296 +0,0 @@ -# version of the API document that is used -set CORE_API_VERSION 1.23 - -set DEFAULT_API_PORT 4038 -set g_api_exec_num 100; # starting execution number - -# set scale for X/Y coordinate translation -set XSCALE 1.0 -set YSCALE 1.0 -set XOFFSET 0 -set YOFFSET 0 - -# current session; 0 is a new session -set g_current_session 0 -set g_session_dialog_hint 1 - -# this is an array of lists, with one array entry for each widget or callback, -# and the entry is a list of execution numbers (for matching replies with -# requests) -array set g_execRequests { shell "" observer "" } - -# for a simulator, uncomment this line or cut/paste into debugger: -# set XSCALE 4.0; set YSCALE 4.0; set XOFFSET 1800; set YOFFSET 300 - -array set nodetypes { 0 def 1 phys 2 tbd 3 tbd 4 lanswitch 5 hub \ - 6 wlan 7 rj45 8 tunnel 9 ktunnel 10 emane } - -array set regtypes { wl 1 mob 2 util 3 exec 4 gui 5 emul 6 } -array set regntypes { 1 wl 2 mob 3 util 4 exec 5 gui 6 emul 7 relay 10 session } -array set regtxttypes { wl "Wireless Module" mob "Mobility Module" \ - util "Utility Module" exec "Execution Server" \ - gui "Graphical User Interface" emul "Emulation Server" \ - relay "Relay" } -set DEFAULT_GUI_REG "gui core_2d_gui" -array set eventtypes { definition_state 1 configuration_state 2 \ - instantiation_state 3 runtime_state 4 \ - datacollect_state 5 shutdown_state 6 \ - event_start 7 event_stop 8 event_pause 9 \ - event_restart 10 file_open 11 file_save 12 \ - event_scheduled 31 } - -set CORE_STATES \ - "NONE DEFINITION CONFIGURATION INSTANTIATION RUNTIME DATACOLLECT SHUTDOWN" - -set EXCEPTION_LEVELS \ - "NONE FATAL ERROR WARNING NOTICE" - -# Event handler invoked for each message received by peer -proc receiveMessage { channel } { - global curcanvas showAPI - set prmsg $showAPI - set type 0 - set flags 0 - set len 0 - set seq 0 - - #puts "API receive data." - # disable the fileevent here, then reinstall the handler at the end - fileevent $channel readable "" - # channel closed - if { [eof $channel] } { - resetChannel channel 1 - return - } - - # - # read first four bytes of message header - set more_data 1 - while { $more_data == 1 } { - if { [catch { set bytes [read $channel 4] } e] } { - # in tcl8.6 this occurs during shutdown - #puts "channel closed: $e" - break; - } - if { [fblocked $channel] == 1} { - # 4 bytes not available yet - break; - } elseif { [eof $channel] } { - resetChannel channel 1 - break; - } elseif { [string bytelength $bytes] == 0 } { - # zero bytes read - parseMessageHeader would fail - break; - } - # parse type/flags/length - if { [parseMessageHeader $bytes type flags len] < 0 } { - # Message header error - break; - } - # read message data of specified length - set bytes [read $channel $len] - #if { $prmsg== 1} { - # puts "read $len bytes (type=$type, flags=$flags, len=$len)..." - #} - # handle each message type - switch -exact -- "$type" { - 1 { parseNodeMessage $bytes $len $flags } - 2 { parseLinkMessage $bytes $len $flags } - 3 { parseExecMessage $bytes $len $flags $channel } - 4 { parseRegMessage $bytes $len $flags $channel } - 5 { parseConfMessage $bytes $len $flags $channel } - 6 { parseFileMessage $bytes $len $flags $channel } - 8 { parseEventMessage $bytes $len $flags $channel } - 9 { parseSessionMessage $bytes $len $flags $channel } - 10 { parseExceptionMessage $bytes $len $flags $channel; - #7 { parseIfaceMessage $bytes $len $flags $channel } - # - } - default { puts "Unknown Message = $type" } - } - # end switch - } - # end while - - # update the canvas - catch { - # this messes up widgets - #raiseAll .c - .c config -cursor left_ptr ;# otherwise we have hourglass/pirate - update - } - - if {$channel != -1 } { - resetChannel channel 0 - } -} - -# -# Open an API socket to the specified server:port, prompt user for retry -# if specified; set the readable file event and parameters; -# returns the channel name or -1 on error. -# -proc openAPIChannel { server port retry } { - # use default values (localhost:4038) when none specified - if { $server == "" || $server == 0 } { - set server "localhost" - } - if { $port == 0 } { - global DEFAULT_API_PORT - set port $DEFAULT_API_PORT - } - - # loop when retry is true - set s -1 - while { $s < 0 } { - # TODO: fix this to remove lengthy timeout periods... - # (need to convert all channel I/O to use async channel) - # vwait doesn't work here, blocks on socket call - #puts "Connecting to $server:$port..."; # verbose - set svcstart [getServiceStartString] - set e "This feature requires a connection to the CORE daemon.\n" - set e "$e\nFailed to connect to $server:$port!\n" - set e "$e\nHave you started the CORE daemon with" - set e "$e '$svcstart'?" - if { [catch {set s [socket $server $port]} ex] } { - puts "\n$e\n (Error: $ex)" - set s -1 - if { ! $retry } { return $s; }; # error, don't retry - } - if { $s > 0 } { puts "connected." }; # verbose - if { $retry } {; # prompt user with retry dialog - if { $s < 0 } { - set choice [tk_dialog .connect "Error" $e \ - error 0 Retry "Start daemon..." Cancel] - if { $choice == 2 } { return $s } ;# cancel - if { $choice == 1 } { - set sudocmd "gksudo" - set cmd "core-daemon -d" - if { [catch {exec $sudocmd $cmd & } e] } { - puts "Error running '$sudocmd $cmd'!" - } - after 300 ;# allow time for daemon to start - } - # fall through for retry... - } - } - }; # end while - - # now we have a valid socket, set up encoding and receive event - fconfigure $s -blocking 0 -encoding binary -translation { binary binary } \ - -buffering full -buffersize 4096 - fileevent $s readable [list receiveMessage $s] - return $s -} - -# -# Reinstall the receiveMessage event handler -# -proc resetChannel { channel_ptr close } { - upvar 1 $channel_ptr channel - if {$close == 1} { - close $channel - pluginChannelClosed $channel - set $channel -1 - } - if { [catch { fileevent $channel readable \ - [list receiveMessage $channel] } ] } { - # may print error here - } -} - -# -# Catch errors when flushing sockets -# -proc flushChannel { channel_ptr msg } { - upvar 1 $channel_ptr channel - if { [catch { flush $channel } err] } { - puts "*** $msg: $err" - set channel -1 - return -1 - } - return 0 -} - - -# -# CORE message header -# -proc parseMessageHeader { bytes type flags len } { - # variables are passed by reference - upvar 1 $type mytype - upvar 1 $flags myflags - upvar 1 $len mylen - - # - # read the four-byte message header - # - if { [binary scan $bytes ccS mytype myflags mylen] != 3 } { - puts "*** warning: message header error" - return -1 - } else { - set mytype [expr {$mytype & 0xFF}]; # convert signed to unsigned - set myflags [expr {$myflags & 0xFF}] - if { $mylen == 0 } { - puts "*** warning: zero length message header!" - # empty the channel - #set bytes [read $channel] - return -1 - } - } - return 0 -} - - -# -# CORE API Node message TLVs -# -proc parseNodeMessage { data len flags } { - global node_list curcanvas c router eid showAPI nodetypes CORE_DATA_DIR - global XSCALE YSCALE XOFFSET YOFFSET deployCfgAPI_lock - #puts "Parsing node message of length=$len, flags=$flags" - set prmsg $showAPI - set current 0 - - array set typenames { 1 num 2 type 3 name 4 ipv4_addr 5 mac_addr \ - 6 ipv6_addr 7 model 8 emulsrv 10 session \ - 32 xpos 33 ypos 34 canv \ - 35 emuid 36 netid 37 services \ - 48 lat 49 long 50 alt \ - 66 icon 80 opaque } - array set typesizes { num 4 type 4 name -1 ipv4_addr 4 ipv6_addr 16 \ - mac_addr 8 model -1 emulsrv -1 session -1 \ - xpos 2 ypos 2 canv 2 emuid 4 \ - netid 4 services -1 lat 4 long 4 alt 4 \ - icon -1 opaque -1 } - array set vals { num 0 type 0 name "" ipv4_addr -1 ipv6_addr -1 \ - mac_addr -1 model "" emulsrv "" session "" \ - xpos 0 ypos 0 canv "" \ - emuid -1 netid -1 services "" \ - lat 0 long 0 alt 0 \ - icon "" opaque "" } - - if { $prmsg==1 } { puts -nonewline "NODE(flags=$flags," } - - # - # TLV parsing - # - while { $current < $len } { - # TLV header - if { [binary scan $data @${current}cc type length] != 2 } { - puts "TLV header error" - break - } - set length [expr {$length & 0xFF}]; # convert signed to unsigned - if { $length == 0 } {; # prevent endless looping - if { $type == 0 } { puts -nonewline "(extra padding)"; break - } else { puts "Found zero-length TLV for type=$type, dropping."; - break } - } - set pad [pad_32bit $length] - # verbose debugging - #puts "tlv type=$type length=$length pad=$pad current=$current" - incr current 2 - - if {![info exists typenames($type)] } { ;# unknown TLV type - if { $prmsg } { puts -nonewline "unknown=$type," } - incr current $length - continue - } - set typename $typenames($type) - set size $typesizes($typename) - # 32-bit and 64-bit vals pre-padded - if { $size == 4 || $size == 8 } { incr current $pad } - # read TLV data depending on size - switch -exact -- "$size" { - 2 { binary scan $data @${current}S vals($typename) } - 4 { binary scan $data @${current}I vals($typename) } - 8 { binary scan $data @${current}W vals($typename) } - 16 { binary scan $data @${current}c16 vals($typename) } - -1 { binary scan $data @${current}a${length} vals($typename) } - } - if { $size == -1 } { incr current $pad } ;# string vals post-padded - if { $type == 6 } { incr current $pad } ;# 128-bit vals post-padded - incr current $length - # special handling of data here - switch -exact -- "$typename" { - ipv4_addr { array set vals [list $typename \ - [ipv4ToString $vals($typename)] ] } - mac_addr { array set vals [list $typename \ - [macToString $vals($typename)] ] } - ipv6_addr { array set vals [list $typename \ - [ipv6ToString $vals($typename)] ] } - xpos { array set vals [list $typename \ - [expr { ($vals($typename) * $XSCALE) - $XOFFSET }] ] } - ypos { array set vals [list $typename \ - [expr { ($vals($typename) * $YSCALE) - $YOFFSET }] ] } - } - if { $prmsg } { puts -nonewline "$typename=$vals($typename)," } - } - - if { $prmsg } { puts ") "} - - # - # Execution - # - # TODO: enforce message parameters here - if { ![info exists nodetypes($vals(type))] } { - puts "NODE: invalid node type ($vals(type)), dropping"; return - } - set node "n$vals(num)" - set node_id "$eid\_$node" - if { [lsearch $node_list $node] == -1 } {; # check for node existance - set exists false - } else { - set exists true - } - - if { $vals(name) == "" } {; # make sure there is a node name - set name $node - if { $exists } { set name [getNodeName $node] } - array set vals [list name $name] - } - if { $exists } { - if { $flags == 1 } { - puts "Node add msg but node ($node) already exists, dropping." - return - } - } elseif { $flags != 1 } { - puts -nonewline "Node modify/delete message but node ($node) does " - puts "not exist dropping." - return - } - if { $vals(icon) != "" } { - set icon $vals(icon) - if { [file pathtype $icon] == "relative" } { - set icon "$CORE_DATA_DIR/icons/normal/$icon" - } - if { ![file exists $icon ] } { - puts "Node icon '$vals(icon)' does not exist." - array set vals [list icon ""] - } else { - array set vals [list icon $icon] - } - } - global $node - - set wlans_needing_update { } - if { $vals(emuid) != -1 } { - # For Linux populate ngnodeidmap for later use with wireless; it is treated as - # a hex value string (without the leading "0x") - global ngnodeidmap - foreach wlan [findWlanNodes $node] { - if { ![info exists ngnodeidmap($eid\_$wlan)] } { - set netid [string range $wlan 1 end] - set emulation_type [lindex [getEmulPlugin $node] 1] - # TODO: verify that this incr 1000 is for OpenVZ - if { $emulation_type == "openvz" } { incr netid 1000 } - set ngnodeidmap($eid\_$wlan) [format "%x" $netid] - } - if { ![info exists ngnodeidmap($eid\_$wlan-$node)] } { - set ngnodeidmap($eid\_$wlan-$node) [format "%x" $vals(emuid)] - lappend wlans_needing_update $wlan - } - } ;# end foreach wlan - } - - # local flags: informational message that node was added or deleted - if {[expr {$flags & 0x8}]} { - if { ![info exists c] } { return } - if {[expr {$flags & 0x1}] } { ;# add flag - nodeHighlights $c $node on green - after 3000 "nodeHighlights .c $node off green" - } elseif {[expr {$flags & 0x2}] } { ;# delete flag - nodeHighlights $c $node on black - after 3000 "nodeHighlights .c $node off black" - } - # note: we may want to save other data passed in this message here - # rather than just returning... - return - } - # now we have all the information about this node - switch -exact -- "$flags" { - 0 { apiNodeModify $node vals } - 1 { apiNodeCreate $node vals } - 2 { apiNodeDelete $node } - default { puts "NODE: unsupported flags ($flags)"; return } - } -} - -# -# modify a node -# -proc apiNodeModify { node vals_ref } { - global c eid zoom curcanvas - upvar $vals_ref vals - if { ![info exists c] } { return } ;# batch mode - set draw 0 - if { $vals(icon) != "" } { - setCustomImage $node $vals(icon) - set draw 1 - } - # move the node and its links - if {$vals(xpos) != 0 && $vals(ypos) != 0} { - moveNodeAbs $c $node [expr {$zoom * $vals(xpos)}] \ - [expr {$zoom * $vals(ypos)}] - } - if { $vals(name) != "" } { - setNodeName $node $vals(name) - set draw 1 - } - if { $vals(services) != "" } { - set services [split $vals(services) |] - setNodeServices $node $services - } - # TODO: handle other optional on-screen data - # lat, long, alt, heading, platform type, platform id - if { $draw && [getNodeCanvas $node] == $curcanvas } { - .c delete withtag "node && $node" - .c delete withtag "nodelabel && $node" - drawNode .c $node - } -} - -# -# add a node -# -proc apiNodeCreate { node vals_ref } { - global $node nodetypes node_list canvas_list curcanvas eid - upvar $vals_ref vals - - # create GUI object - set nodetype $nodetypes($vals(type)) - set nodename $vals(name) - if { $nodetype == "emane" } { set nodetype "wlan" } ;# special case - EMANE - if { $nodetype == "def" } { set nodetype "router" } - newNode [list $nodetype $node] ;# use node number supplied from API message - setNodeName $node $nodename - if { $vals(canv) == "" } { - setNodeCanvas $node $curcanvas - } else { - set canv $vals(canv) - if { ![string is integer $canv] || $canv < 0 || $canv > 100} { - puts "warning: invalid canvas '$canv' in Node message!" - return - } - set canv "c$canv" - if { [lsearch $canvas_list $canv] < 0 && $canv == "c0" } { - # special case -- support old imn files with Canvas0 - global $canv - lappend canvas_list $canv - set $canv {} - setCanvasName $canv "Canvas0" - set curcanvas $canv - switchCanvas none - } else { - while { [lsearch $canvas_list $canv] < 0 } { - set canvnew [newCanvas ""] - switchCanvas none ;# redraw canvas tabs - } - } - setNodeCanvas $node $canv - } - setNodeCoords $node "$vals(xpos) $vals(ypos)" - lassign [getDefaultLabelOffsets [nodeType $node]] dx dy - setNodeLabelCoords $node "[expr $vals(xpos) + $dx] [expr $vals(ypos) + $dy]" - setNodeLocation $node $vals(emulsrv) - if { $vals(icon) != "" } { - setCustomImage $node $vals(icon) - } - drawNode .c $node - - set model $vals(model) - if { $model != "" && $vals(type) < 4} { - # set model only for (0 def 1 phys 2 tbd 3 tbd) 4 lanswitch - setNodeModel $node $model - if { [lsearch -exact [getNodeTypeNames] $model] == -1 } { - puts "warning: unknown node type '$model' in Node message!" - } - } - if { $vals(services) != "" } { - set services [split $vals(services) |] - setNodeServices $node $services - } - - if { $vals(type) == 7 } { ;# RJ45 node - used later to control linking - netconfInsertSection $node [list model $vals(model)] - } elseif { $vals(type) == 10 } { ;# EMANE node - set section [list mobmodel coreapi ""] - netconfInsertSection $node $section - #set sock [lindex [getEmulPlugin $node] 2] - #sendConfRequestMessage $sock $node "all" 0x1 -1 "" - } elseif { $vals(type) == 6 } { ;# WLAN node - if { $vals(opaque) != "" } { - # treat opaque as a list to accomodate other data - set i [lsearch $vals(opaque) "range=*"] - if { $i != -1 } { - set range [lindex $vals(opaque) $i] - setNodeRange $node [lindex [split $range =] 1] - } - } - } -} - -# -# delete a node -# -proc apiNodeDelete { node } { - removeGUINode $node -} - -# -# CORE API Link message TLVs -# -proc parseLinkMessage { data len flags } { - global router def_router_model eid - global link_list node_list ngnodeidmap ngnodeidrmap showAPI execMode - set prmsg $showAPI - set current 0 - set c .c - #puts "Parsing link message of length=$len, flags=$flags" - - array set typenames { 1 node1num 2 node2num 3 delay 4 bw 5 per \ - 6 dup 7 jitter 8 mer 9 burst 10 session \ - 16 mburst 32 ltype 33 guiattr 34 uni \ - 35 emuid1 36 netid 37 key \ - 48 if1num 49 if1ipv4 50 if1ipv4mask 51 if1mac \ - 52 if1ipv6 53 if1ipv6mask \ - 54 if2num 55 if2ipv4 56 if2ipv4mask 57 if2mac \ - 64 if2ipv6 65 if2ipv6mask } - array set typesizes { node1num 4 node2num 4 delay 8 bw 8 per -1 \ - dup -1 jitter 8 mer 2 burst 2 session -1 \ - mburst 2 ltype 4 guiattr -1 uni 2 \ - emuid1 4 netid 4 key 4 \ - if1num 2 if1ipv4 4 if1ipv4mask 2 if1mac 8 \ - if1ipv6 16 if1ipv6mask 2 \ - if2num 2 if2ipv4 4 if2ipv4mask 2 if2mac 8 \ - if2ipv6 16 if2ipv6mask 2 } - array set vals { node1num -1 node2num -1 delay 0 bw 0 per "" \ - dup "" jitter 0 mer 0 burst 0 session "" \ - mburst 0 ltype 0 guiattr "" uni 0 \ - emuid1 -1 netid -1 key -1 \ - if1num -1 if1ipv4 -1 if1ipv4mask 24 if1mac -1 \ - if1ipv6 -1 if1ipv6mask 64 \ - if2num -1 if2ipv4 -1 if2ipv4mask 24 if2mac -1 \ - if2ipv6 -1 if2ipv6mask 64 } - set emuid1 -1 - - if { $prmsg==1 } { puts -nonewline "LINK(flags=$flags," } - - # - # TLV parsing - # - while { $current < $len } { - # TLV header - if { [binary scan $data @${current}cc type length] != 2 } { - puts "TLV header error" - break - } - set length [expr {$length & 0xFF}]; # convert signed to unsigned - if { $length == 0 } {; # prevent endless looping - if { $type == 0 } { puts -nonewline "(extra padding)"; break - } else { puts "Found zero-length TLV for type=$type, dropping."; - break } - } - set pad [pad_32bit $length] - # verbose debugging - #puts "tlv type=$type length=$length pad=$pad current=$current" - incr current 2 - - if {![info exists typenames($type)] } { ;# unknown TLV type - if { $prmsg } { puts -nonewline "unknown=$type," } - incr current $length - continue - } - set typename $typenames($type) - set size $typesizes($typename) - # 32-bit and 64-bit vals pre-padded - if { $size == 4 || $size == 8} { incr current $pad } - # read TLV data depending on size - switch -exact -- "$size" { - 2 { binary scan $data @${current}S vals($typename) } - 4 { binary scan $data @${current}I vals($typename) } - 8 { binary scan $data @${current}W vals($typename) } - 16 { binary scan $data @${current}c16 vals($typename) } - -1 { binary scan $data @${current}a${length} vals($typename) } - } - incr current $length - # special handling of data here - switch -exact -- "$typename" { - delay - - jitter { if { $vals($typename) > 2000000 } { - array set vals [list $typename 2000000] } } - bw { if { $vals($typename) > 1000000000 } { - array set vals [list $typename 0] } } - per { if { $vals($typename) > 100 } { - array set vals [list $typename 100] } } - dup { if { $vals($typename) > 50 } { - array set vals [list $typename 50] } } - emuid1 { if { $emuid1 == -1 } { - set emuid $vals($typename) - } else { ;# this sets emuid2 if we already have emuid1 - array set vals [list emuid2 $vals($typename) ] - array set vals [list emuid1 $emuid1 ] - } - } - if1ipv4 - - if2ipv4 { array set vals [list $typename \ - [ipv4ToString $vals($typename)] ] } - if1mac - - if2mac { array set vals [list $typename \ - [macToString $vals($typename)] ] } - if1ipv6 - - if2ipv6 { array set vals [list $typename \ - [ipv6ToString $vals($typename)] ] } - } - if { $prmsg } { puts -nonewline "$typename=$vals($typename)," } - if { $size == 16 } { incr current $pad } ;# 128-bit vals post-padded - if { $size == -1 } { incr current $pad } ;# string vals post-padded - } - - if { $prmsg == 1 } { puts ") " } - - # perform some sanity checking of the link message - if { $vals(node1num) == $vals(node2num) || \ - $vals(node1num) < 0 || $vals(node2num) < 0 } { - puts -nonewline "link message error - node1=$vals(node1num), " - puts "node2=$vals(node2num)" - return - } - - # convert node number to node and check for node existance - set node1 "n$vals(node1num)" - set node2 "n$vals(node2num)" - if { [lsearch $node_list $node1] == -1 || \ - [lsearch $node_list $node2] == -1 } { - puts "Node ($node1/$node2) in link message not found, dropping" - return - } - - # set IPv4 and IPv6 address if specified, otherwise may be automatic - set prefix1 [chooseIfName $node1 $node2] - set prefix2 [chooseIfName $node2 $node1] - foreach i "1 2" { - # set interface name/number - if { $vals(if${i}num) == -1 } { - set ifname [newIfc [set prefix${i}] [set node${i}]] - set prefixlen [string length [set prefix${i}]] - set if${i}num [string range $ifname $prefixlen end] - array set vals [list if${i}num [set if${i}num]] - } - set ifname [set prefix${i}]$vals(if${i}num) - array set vals [list if${i}name $ifname] - # record IPv4/IPv6 addresses for newGUILink - foreach j "4 6" { - if { $vals(if${i}ipv${j}) != -1 } { - setIfcIPv${j}addr [set node${i}] $ifname \ - $vals(if${i}ipv${j})/$vals(if${i}ipv${j}mask) - } - } - if { $vals(if${i}mac) != -1 } { - setIfcMacaddr [set node${i}] $ifname $vals(if${i}mac) - } - } - # adopt network address for WLAN (WLAN must be node 1) - if { [nodeType $node1] == "wlan" } { - set v4addr $vals(if2ipv4) - if { $v4addr != -1 } { - set v4net [ipv4ToNet $v4addr $vals(if2ipv4mask)] - setIfcIPv4addr $node1 wireless "$v4net/$vals(if2ipv4mask)" - } - set v6addr $vals(if2ipv6) - if { $v6addr != -1 } { - set v6net [ipv6ToNet $v6addr $vals(if2ipv6mask)] - setIfcIPv6addr $node1 wireless "${v6net}::0/$vals(if2ipv6mask)" - } - } - - if { $execMode == "batch" } { - return ;# no GUI to update in batch mode - } - # treat 100% loss as link delete - if { $flags == 0 && $vals(per) == 100 } { - apiLinkDelete $node1 $node2 vals - return - } - - # now we have all the information about this node - switch -exact -- "$flags" { - 0 { apiLinkAddModify $node1 $node2 vals 0 } - 1 { apiLinkAddModify $node1 $node2 vals 1 } - 2 { apiLinkDelete $node1 $node2 vals } - default { puts "LINK: unsupported flags ($flags)"; return } - } -} - -# -# add or modify a link -# if add flag is set, check if two nodes are part of same wlan, and do wlan -# linkage, or add a wired link; otherwise modify wired/wireless link with -# supplied parameters -proc apiLinkAddModify { node1 node2 vals_ref add } { - global eid defLinkWidth - set c .c - upvar $vals_ref vals - - if {$vals(key) > -1} { - if { [nodeType $node1] == "tunnel" } { - netconfInsertSection $node1 [list "tunnel-key" $vals(key)] - } - if { [nodeType $node2] == "tunnel" } { - netconfInsertSection $node2 [list "tunnel-key" $vals(key)] - } - } - - # look for a wired link in the link list - set wired_link [linkByPeers $node1 $node2] - if { $wired_link != "" && $add == 0 } { ;# wired link exists, modify it - #puts "modify wired link" - if { $vals(uni) == 1 } { ;# unidirectional link effects message - set peers [linkPeers $wired_link] - if { $node1 == [lindex $peers 0] } { ;# downstream n1 <-- n2 - set bw [list $vals(bw) [getLinkBandwidth $wired_link up]] - set delay [list $vals(delay) [getLinkDelay $wired_link up]] - set per [list $vals(per) [getLinkBER $wired_link up]] - set dup [list $vals(dup) [getLinkBER $wired_link up]] - set jitter [list $vals(jitter) [getLinkJitter $wired_link up]] - } else { ;# upstream n1 --> n2 - set bw [list [getLinkBandwidth $wired_link] $vals(bw)] - set delay [list [getLinkDelay $wired_link] $vals(delay)] - set per [list [getLinkBER $wired_link] $vals(per)] - set dup [list [getLinkBER $wired_link] $vals(dup)] - set jitter [list $vals(jitter) [getLinkJitter $wired_link]] - } - setLinkBandwidth $wired_link $bw - setLinkDelay $wired_link $delay - setLinkBER $wired_link $per - setLinkDup $wired_link $dup - setLinkJitter $wired_link $jitter - } else { - setLinkBandwidth $wired_link $vals(bw) - setLinkDelay $wired_link $vals(delay) - setLinkBER $wired_link $vals(per) - setLinkDup $wired_link $vals(dup) - setLinkJitter $wired_link $vals(jitter) - } - updateLinkLabel $wired_link - updateLinkGuiAttr $wired_link $vals(guiattr) - return - # if add flag is set and a wired link already exists, assume wlan linkage - # special case: rj45 model=1 means link via wireless - } elseif {[nodeType $node1] == "rj45" || [nodeType $node2] == "rj45"} { - if { [nodeType $node1] == "rj45" } { - set rj45node $node1; set othernode $node2; - } else { set rj45node $node2; set othernode $node1; } - if { [netconfFetchSection $rj45node model] == 1 } { - set wlan [findWlanNodes $othernode] - if {$wlan != ""} {newGUILink $wlan $rj45node};# link rj4node to wlan - } - } - - # no wired link; determine if both nodes belong to the same wlan, and - # link them; otherwise add a wired link if add flag is set - set wlan $vals(netid) - if { $wlan < 0 } { - # WLAN not specified with netid, search for common WLAN - set wlans1 [findWlanNodes $node1] - set wlans2 [findWlanNodes $node2] - foreach w $wlans1 { - if { [lsearch -exact $wlans2 $w] < 0 } { continue } - set wlan $w - break - } - } - - if { $wlan < 0 } { ;# no common wlan - if {$add == 1} { ;# add flag was set - add a wired link - global g_newLink_ifhints - set g_newLink_ifhints [list $vals(if1name) $vals(if2name)] - newGUILink $node1 $node2 - if { [getNodeCanvas $node1] != [getNodeCanvas $node2] } { - set wired_link [linkByPeersMirror $node1 $node2] - } else { - set wired_link [linkByPeers $node1 $node2] - } - setLinkBandwidth $wired_link $vals(bw) - setLinkDelay $wired_link $vals(delay) - setLinkBER $wired_link $vals(per) - setLinkDup $wired_link $vals(dup) - setLinkJitter $wired_link $vals(jitter) - updateLinkLabel $wired_link - updateLinkGuiAttr $wired_link $vals(guiattr) - # adopt link effects for WLAN (WLAN must be node 1) - if { [nodeType $node1] == "wlan" } { - setLinkBandwidth $node1 $vals(bw) - setLinkDelay $node1 $vals(delay) - setLinkBER $node1 $vals(per) - } - return - } else { ;# modify link, but no wired link or common wlan! - puts -nonewline "link modify message received, but no wired link" - puts " or wlan for nodes $node1-$node2, dropping" - return - } - } - - set wlan "n$wlan" - drawWlanLink $node1 $node2 $wlan -} - -# -# delete a link -# -proc apiLinkDelete { node1 node2 vals_ref } { - global eid - upvar $vals_ref vals - set c .c - - # look for a wired link in the link list - set wired_link [linkByPeers $node1 $node2] - if { $wired_link != "" } { - removeGUILink $wired_link non-atomic - return - } - - set wlan $vals(netid) - if { $wlan < 0 } { - # WLAN not specified with netid, search for common WLAN - set wlans1 [findWlanNodes $node1] - set wlans2 [findWlanNodes $node2] - foreach w $wlans1 { - if { [lsearch -exact $wlans2 $w] < 0 } { continue } - set wlan $w - break - } - } - if { $wlan < 0 } { - puts "apiLinkDelete: no common WLAN!" - return - } - set wlan "n$wlan" - - # look for wireless link on the canvas, remove GUI object - $c delete -withtags "wlanlink && $node2 && $node1 && $wlan" - $c delete -withtags "linklabel && $node2 && $node1 && $wlan" -} - -# -# CORE API Execute message TLVs -# -proc parseExecMessage { data len flags channel } { - global node_list curcanvas c router eid showAPI - global XSCALE YSCALE XOFFSET YOFFSET - set prmsg $showAPI - set current 0 - - # set default values - set nodenum 0 - set execnum 0 - set exectime 0 - set execcmd "" - set execres "" - set execstatus 0 - set session "" - - if { $prmsg==1 } { puts -nonewline "EXEC(flags=$flags," } - - # parse each TLV - while { $current < $len } { - # TLV header - set typelength [parseTLVHeader $data current] - set type [lindex $typelength 0] - set length [lindex $typelength 1] - if { $length == 0 || $length == "" } { break } - set pad [pad_32bit $length] - # verbose debugging - #puts "exec tlv type=$type length=$length pad=$pad current=$current" - if { [expr {$current + $length + $pad}] > $len } { - puts "error with EXEC message length (len=$len, TLV length=$length)" - break - } - # TLV data - switch -exact -- "$type" { - 1 { - incr current $pad - binary scan $data @${current}I nodenum - if { $prmsg==1 } { puts -nonewline "node=$nodenum/" } - } - 2 { - incr current $pad - binary scan $data @${current}I execnum - if { $prmsg == 1} { puts -nonewline "exec=$execnum," } - } - 3 { - incr current $pad - binary scan $data @${current}I exectime - if { $prmsg == 1} { puts -nonewline "time=$exectime," } - } - 4 { - binary scan $data @${current}a${length} execcmd - if { $prmsg == 1} { puts -nonewline "cmd=$execcmd," } - incr current $pad - } - 5 { - binary scan $data @${current}a${length} execres - if { $prmsg == 1} { puts -nonewline "res=($length bytes)," } - incr current $pad - } - 6 { - incr current $pad - binary scan $data @${current}I execstatus - if { $prmsg == 1} { puts -nonewline "status=$execstatus," } - } - 10 { - binary scan $data @${current}a${length} session - if { $prmsg == 1} { puts -nonewline "session=$session," } - incr current $pad - } - default { - if { $prmsg == 1} { puts -nonewline "unknown=" } - if { $prmsg == 1} { puts -nonewline "$type," } - } - } - # end switch - - # advance current pointer - incr current $length - } - if { $prmsg == 1 } { puts ") "} - - set node "n$nodenum" - set node_id "$eid\_$node" - # check for node existance - if { [lsearch $node_list $node] == -1 } { - puts "Execute message but node ($node) does not exist, dropping." - return - } - global $node - - # Callback support - match execnum from response with original request, and - # invoke type-specific callback - global g_execRequests - foreach type [array names g_execRequests] { - set idx [lsearch $g_execRequests($type) $execnum] - if { $idx > -1 } { - set g_execRequests($type) \ - [lreplace $g_execRequests($type) $idx $idx] - exec_${type}_callback $node $execnum $execcmd $execres $execstatus - return - } - } -} - -# spawn interactive terminal -proc exec_shell_callback { node execnum execcmd execres execstatus } { - #puts "opening terminal for $node by running '$execres'" - set title "CORE: [getNodeName $node] (console)" - set term [get_term_prog false] - set xi [string first "xterm -e" $execres] - - # shell callback already has xterm command, launch it using user-defined - # term program (e.g. remote nodes 'ssh -X -f a.b.c.d xterm -e ...' - if { $xi > -1 } { - set execres [string replace $execres $xi [expr $xi+7] $term] - if { [catch {exec sh -c "$execres" & } ] } { - puts "Warning: failed to open terminal for $node" - } - return - # no xterm command; execute shell callback in a terminal (e.g. local nodes) - } elseif { \ - [catch {eval exec $term "$execres" & } ] } { - puts "Warning: failed to open terminal for $node: ($term $execres)" - } -} - - -# -# CORE API Register message TLVs -# parse register message into plugin capabilities -# -proc parseRegMessage { data len flags channel } { - global regntypes showAPI - set prmsg $showAPI - set current 0 - set str 0 - set session "" - set fnhint "" - - set plugin_cap_list {} ;# plugin capabilities list - - if { $prmsg==1 } { puts -nonewline "REG(flags=$flags," } - - # parse each TLV - while { $current < $len } { - # TLV header - if { [binary scan $data @${current}cc type length] != 2 } { - puts "TLV header error" - break - } - set length [expr {$length & 0xFF}]; # convert signed to unsigned - if { $length == 0 } { - # prevent endless looping - if { $type == 0 } { - puts -nonewline "(extra padding)" - break - } else { - puts "Found zero-length TLV for type=$type, dropping." - break - } - } - set pad [pad_32bit $length] - # verbose debugging - #puts "tlv type=$type length=$length pad=$pad current=$current" - incr current 2 - # TLV data - if { [info exists regntypes($type)] } { - set plugin_type $regntypes($type) - binary scan $data @${current}a${length} str - if { $prmsg == 1} { puts -nonewline "$plugin_type=$str," } - if { $type == 10 } { ;# session number - set session $str - } else { - lappend plugin_cap_list "$plugin_type=$str" - if { $plugin_type == "exec" } { set fnhint $str } - } - } else { - if { $prmsg == 1} { puts -nonewline "unknown($type)," } - } - incr current $pad - # end switch - - # advance current pointer - incr current $length - } - if { $prmsg == 1 } { puts ") "} - - # reg message with session number indicates the sid of a session that - # was just started from XML or Python script (via reg exec=scriptfile.py) - if { $session != "" } { - # The channel passed to here is soon after discarded for - # sessions that are started from XML or Python scripts. This causes - # an exception in the GUI when responding back to daemon if the - # response is sent after the channel has been destroyed. Setting - # the channel to -1 basically disables the GUI response to the daemon, - # but it turns out the daemon does not need the response anyway. - set channel -1 - # assume session string only contains one session number - connectShutdownSession connect $channel $session $fnhint - return - } - - set plugin [pluginByChannel $channel] - if { [setPluginCapList $plugin $plugin_cap_list] < 0 } { - return - } - - # callback to refresh any open dialogs this message may refresh - pluginsConfigRefreshCallback -} - -proc parseConfMessage { data len flags channel } { - global showAPI node_list MACHINE_TYPES - set prmsg $showAPI - set current 0 - set str 0 - set nodenum -1 - set obj "" - set tflags 0 - set types {} - set values {} - set captions {} - set bitmap {} - set possible_values {} - set groups {} - set opaque {} - set session "" - set netid -1 - - if { $prmsg==1 } { puts -nonewline "CONF(flags=$flags," } - - # parse each TLV - while { $current < $len } { - set typelength [parseTLVHeader $data current] - set type [lindex $typelength 0] - set length [lindex $typelength 1] - set pad [pad_32bit $length] - if { $length == 0 || $length == "" } { - # allow some zero-length string TLVs - if { $type < 5 || $type > 9 } { break } - } - # verbose debugging - #puts "tlv type=$type length=$length pad=$pad current=$current" - # TLV data - switch -exact -- "$type" { - 1 { - incr current $pad - binary scan $data @${current}I nodenum - if { $prmsg == 1} { puts -nonewline "node=$nodenum/" } - } - 2 { - binary scan $data @${current}a${length} obj - if { $prmsg == 1} { puts -nonewline "obj=$obj," } - incr current $pad - } - 3 { - binary scan $data @${current}S tflags - if { $prmsg == 1} { puts -nonewline "cflags=$tflags," } - } - 4 { - set type 0 - set types {} - if { $prmsg == 1} { puts -nonewline "types=" } - # number of 16-bit values - set types_len $length - # get each 16-bit type value, add to list - while {$types_len > 0} { - binary scan $data @${current}S type - if {$type > 0 && $type < 12} { - lappend types $type - if { $prmsg == 1} { puts -nonewline "$type/" } - } - incr current 2 - incr types_len -2 - } - if { $prmsg == 1} { puts -nonewline "," } - incr current -$length; # length incremented below - incr current $pad - } - 5 { - set values {} - binary scan $data @${current}a${length} vals - if { $prmsg == 1} { puts -nonewline "vals=$vals," } - set values [split $vals |] - incr current $pad - } - 6 { - set captions {} - binary scan $data @${current}a${length} capt - if { $prmsg == 1} { puts -nonewline "capt=$capt," } - set captions [split $capt |] - incr current $pad - } - 7 { - set bitmap {} - binary scan $data @${current}a${length} bitmap - if { $prmsg == 1} { puts -nonewline "bitmap," } - incr current $pad - } - 8 { - set possible_values {} - binary scan $data @${current}a${length} pvals - if { $prmsg == 1} { puts -nonewline "pvals=$pvals," } - set possible_values [split $pvals |] - incr current $pad - } - 9 { - set groups {} - binary scan $data @${current}a${length} groupsstr - if { $prmsg == 1} { puts -nonewline "groups=$groupsstr," } - set groups [split $groupsstr |] - incr current $pad - } - 10 { - binary scan $data @${current}a${length} session - if { $prmsg == 1} { puts -nonewline "session=$session," } - incr current $pad - } - 35 { - incr current $pad - binary scan $data @${current}I netid - if { $prmsg == 1} { puts -nonewline "netid=$netid/" } - } - 80 { - set opaque {} - binary scan $data @${current}a${length} opaquestr - if { $prmsg == 1} { puts -nonewline "opaque=$opaquestr," } - set opaque [split $opaquestr |] - incr current $pad - } - default { - if { $prmsg == 1} { puts -nonewline "unknown=" } - if { $prmsg == 1} { puts -nonewline "$type," } - } - } - # end switch - - # advance current pointer - incr current $length - } - - if { $prmsg == 1 } { puts ") "} - - set objs_ok [concat "services session metadata emane" $MACHINE_TYPES] - if { $nodenum > -1 } { - set node "n$nodenum" - } else { - set node "" - } - # check for node existance - if { [lsearch $node_list $node] == -1 } { - if { [lsearch $objs_ok $obj] < 0 } { - set msg "Configure message for $obj but node ($node) does" - set msg "$msg not exist, dropping." - puts $msg - return - } - } else { - global $node - } - - # for handling node services - # this could be improved, instead of checking for the hard-coded object - # "services" and opaque data for service customization - if { $obj == "services" } { - if { $tflags & 0x2 } { ;# update flag - if { $opaque != "" } { - set services [lindex [split $opaque ":"] 1] - set services [split $services ","] - customizeServiceValues n$nodenum $values $services - } - # TODO: save services config with the node - } elseif { $tflags & 0x1 } { ;# request flag - # TODO: something else - } else { - popupServicesConfig $channel n$nodenum $types $values $captions \ - $possible_values $groups $session - } - return - # metadata received upon XML file load - } elseif { $obj == "metadata" } { - parseMetaData $values - return - # session options received upon XML file load - } elseif { $obj == "session" && $tflags & 0x2 } { - setSessionOptions $types $values - return - } - # handle node machine-type profile - if { [lsearch $MACHINE_TYPES $obj] != -1 } { - if { $tflags == 0 } { - popupNodeProfileConfig $channel n$nodenum $obj $types $values \ - $captions $bitmap $possible_values $groups $session \ - $opaque - } else { - puts -nonewline "warning: received Configure message for profile " - puts "with unexpected flags!" - } - return - } - - # update the configuration for a node without displaying dialog box - if { $tflags & 0x2 } { - if { $obj == "emane" && $node == "" } { - set node [lindex [findWlanNodes ""] 0] - } - if { $node == "" } { - puts "ignoring Configure message for $obj with no node" - return - } - # this is similar to popupCapabilityConfigApply - setCustomConfig $node $obj $types $values 0 - if { $obj != "emane" && [nodeType $node] == "wlan"} { - set section [list mobmodel coreapi $obj] - netconfInsertSection $node $section - } - # configuration request - unhandled - } elseif { $tflags & 0x1 } { - # configuration response data from our request (from GUI plugin configure) - } else { - popupCapabilityConfig $channel n$nodenum $obj $types $values \ - $captions $bitmap $possible_values $groups - } -} - -# process metadata received from Conf Message when loading XML -proc parseMetaData { values } { - global canvas_list annotation_list execMode g_comments - - foreach value $values { - # data looks like this: "annotation a1={iconcoords {514.0 132.0...}}" - lassign [splitKeyValue $value] key object_config - lassign $key class object - # metadata with no object name e.g. comments="Comment text" - if { "$class" == "comments" } { - set g_comments $object_config - continue - } elseif { "$class" == "global_options" } { - foreach opt $object_config { - lassign [split $opt =] key value - setGlobalOption $key $value - } - continue - } - # metadata having class and object name - if {"$class" == "" || $object == ""} { - puts "warning: invalid metadata value '$value'" - } - if { "$class" == "canvas" } { - if { [lsearch $canvas_list $object] < 0 } { - lappend canvas_list $object - } - } elseif { "$class" == "annotation" } { - if { [lsearch $annotation_list $object] < 0 } { - lappend annotation_list $object - } - } else { - puts "metadata parsing error: unknown object class $class" - } - global $object - set $object $object_config - } - - if { $execMode == "batch" } { return } - switchCanvas none - redrawAll -} - -proc parseFileMessage { data len flags channel } { - global showAPI node_list - set prmsg $showAPI - - array set tlvnames { 1 num 2 name 3 mode 4 fno 5 type 6 sname \ - 10 session 16 data 17 cdata } - array set tlvsizes { num 4 name -1 mode -3 fno 2 type -1 sname -1 \ - session -1 data -1 cdata -1 } - array set defvals { num -1 name "" mode -1 fno -1 type "" sname "" \ - session "" data "" cdata "" } - - if { $prmsg==1 } { puts -nonewline "FILE(flags=$flags," } - array set vals [parseMessage $data $len $flags [array get tlvnames] \ - [array get tlvsizes] [array get defvals]] - if { $prmsg } { puts ") "} - - # hook scripts received in File Message - if { [string range $vals(type) 0 4] == "hook:" } { - global g_hook_scripts - set state [string range $vals(type) 5 end] - lappend g_hook_scripts [list $vals(name) $state $vals(data)] - return - } - - # required fields - foreach t "num name data" { - if { $vals($t) == $defvals($t) } { - puts "Received File Message without $t, dropping."; return; - } - } - - # check for node existance - set node "n$vals(num)" - if { [lsearch $node_list $node] == -1 } { - puts "File message but node ($node) does not exist, dropping." - return - } else { - global $node - } - - # service customization received in File Message - if { [string range $vals(type) 0 7] == "service:" } { - customizeServiceFile $node $vals(name) $vals(type) $vals(data) true - } -} - -proc parseEventMessage { data len flags channel } { - global showAPI eventtypes g_traffic_start_opt execMode node_list - set prmsg $showAPI - set current 0 - set nodenum -1 - set eventtype -1 - set eventname "" - set eventdata "" - set eventtime "" - set session "" - - if { $prmsg==1 } { puts -nonewline "EVENT(flags=$flags," } - - # parse each TLV - while { $current < $len } { - set typelength [parseTLVHeader $data current] - set type [lindex $typelength 0] - set length [lindex $typelength 1] - if { $length == 0 || $length == "" } { break } - set pad [pad_32bit $length] - # verbose debugging - #puts "tlv type=$type length=$length pad=$pad current=$current" - # TLV data - switch -exact -- "$type" { - 1 { - incr current $pad - binary scan $data @${current}I nodenum - if { $prmsg == 1} { puts -nonewline "node=$nodenum," } - } - 2 { - incr current $pad - binary scan $data @${current}I eventtype - if { $prmsg == 1} { - set typestr "" - foreach t [array names eventtypes] { - if { $eventtypes($t) == $eventtype } { - set typestr "-$t" - break - } - } - puts -nonewline "type=$eventtype$typestr," - } - } - 3 { - binary scan $data @${current}a${length} eventname - if { $prmsg == 1} { puts -nonewline "name=$eventname," } - incr current $pad - } - 4 { - binary scan $data @${current}a${length} eventdata - if { $prmsg == 1} { puts -nonewline "data=$eventdata," } - incr current $pad - } - 5 { - binary scan $data @${current}a${length} eventtime - if { $prmsg == 1} { puts -nonewline "time=$eventtime," } - incr current $pad - } - 10 { - binary scan $data @${current}a${length} session - if { $prmsg == 1} { puts -nonewline "session=$session," } - incr current $pad - } - default { - if { $prmsg == 1} { puts -nonewline "unknown=" } - if { $prmsg == 1} { puts -nonewline "$type," } - } - } - # end switch - - # advance current pointer - incr current $length - } - - if { $prmsg == 1 } { puts ") "} - - # TODO: take other actions here based on Event Message - if { $eventtype == 4 } { ;# entered the runtime state - if { $g_traffic_start_opt == 1 } { startTrafficScripts } - if { $execMode == "batch" } { - global g_current_session g_abort_session - if {$g_abort_session} { - puts "Current session ($g_current_session) aborted. Disconnecting." - shutdownSession - } else { - puts "Session running. Session id is $g_current_session. Disconnecting." - } - exit.real - } - } elseif { $eventtype == 6 } { ;# shutdown state - set name [lindex [getEmulPlugin "*"] 0] - if { [getAssignedRemoteServers] == "" } { - # start a new session if not distributed - # otherwise we need to allow time for node delete messages - # from other servers - pluginConnect $name disconnect 1 - pluginConnect $name connect 1 - } - } elseif { $eventtype >= 7 || $eventtype <= 10 } { - if { [string range $eventname 0 8] == "mobility:" } { - set node "n$nodenum" - if {[lsearch $node_list $node] == -1} { - puts "Event message with unknown node %nodenum." - return - } - handleMobilityScriptEvent $node $eventtype $eventdata $eventtime - } - } -} - -proc parseSessionMessage { data len flags channel } { - global showAPI g_current_session g_session_dialog_hint execMode - set prmsg $showAPI - set current 0 - set sessionids {} - set sessionnames {} - set sessionfiles {} - set nodecounts {} - set sessiondates {} - set thumbs {} - set sessionopaque {} - - if { $prmsg==1 } { puts -nonewline "SESSION(flags=$flags," } - - # parse each TLV - while { $current < $len } { - set typelength [parseTLVHeader $data current] - set type [lindex $typelength 0] - set length [lindex $typelength 1] - if { $length == 0 || $length == "" } { - puts "warning: zero-length TLV, discarding remainder of message!" - break - } - set pad [pad_32bit $length] - # verbose debugging - #puts "tlv type=$type length=$length pad=$pad current=$current" - # TLV data - switch -exact -- "$type" { - 1 { - set sessionids {} - binary scan $data @${current}a${length} sids - if { $prmsg == 1} { puts -nonewline "sids=$sids," } - set sessionids [split $sids |] - incr current $pad - } - 2 { - set sessionnames {} - binary scan $data @${current}a${length} snames - if { $prmsg == 1} { puts -nonewline "names=$snames," } - set sessionnames [split $snames |] - incr current $pad - } - 3 { - set sessionfiles {} - binary scan $data @${current}a${length} sfiles - if { $prmsg == 1} { puts -nonewline "files=$sfiles," } - set sessionfiles [split $sfiles |] - incr current $pad - } - 4 { - set nodecounts {} - binary scan $data @${current}a${length} ncs - if { $prmsg == 1} { puts -nonewline "ncs=$ncs," } - set nodecounts [split $ncs |] - incr current $pad - } - 5 { - set sessiondates {} - binary scan $data @${current}a${length} sdates - if { $prmsg == 1} { puts -nonewline "dates=$sdates," } - set sessiondates [split $sdates |] - incr current $pad - } - 6 { - set thumbs {} - binary scan $data @${current}a${length} th - if { $prmsg == 1} { puts -nonewline "thumbs=$th," } - set thumbs [split $th |] - incr current $pad - } - 10 { - set sessionopaque {} - binary scan $data @${current}a${length} sessionopaque - if { $prmsg == 1} { puts -nonewline "$sessionopaque," } - incr current $pad - } - default { - if { $prmsg == 1} { puts -nonewline "unknown=" } - if { $prmsg == 1} { puts -nonewline "$type," } - } - } - # end switch - - # advance current pointer - incr current $length - } - - if { $prmsg == 1 } { puts ") "} - - if {$g_current_session == 0} { - # set the current session to the channel port number - set current_session [lindex [fconfigure $channel -sockname] 2] - } else { - set current_session $g_current_session - } - - if {[lsearch $sessionids $current_session] == -1} { - puts -nonewline "*** warning: current session ($g_current_session) " - puts "not found in session list: $sessionids" - } - - set orig_session_choice $g_current_session - set g_current_session $current_session - setGuiTitle "" - - if {$execMode == "closebatch"} { - # we're going to close some session, so this is expected - global g_session_choice - - if {[lsearch $sessionids $g_session_choice] == -1} { - puts -nonewline "*** warning: current session ($g_session_choice) " - puts "not found in session list: $sessionids" - } else { - set flags 0x2 ;# delete flag - set sid $g_session_choice - set name "" - set f "" - set nodecount "" - set thumb "" - set user "" - sendSessionMessage $channel $flags $sid $name $f $nodecount $thumb $user - - puts "Session shutdown message sent." - } - exit.real - } - - if {$orig_session_choice == 0 && [llength $sessionids] == 1} { - # we just started up and only the current session exists - set g_session_dialog_hint 0 - return - } - - if {$execMode == "batch"} { - puts "Another session is active." - exit.real - } - - if { $g_session_dialog_hint } { - popupSessionConfig $channel $sessionids $sessionnames $sessionfiles \ - $nodecounts $sessiondates $thumbs $sessionopaque - } - set g_session_dialog_hint 0 -} - -# parse message TLVs given the possible TLV names and sizes -# default values are supplied in defaultvals, parsed values are returned -proc parseMessage { data len flags tlvnamesl tlvsizesl defaultvalsl } { - global showAPI - set prmsg $showAPI - - array set tlvnames $tlvnamesl - array set tlvsizes $tlvsizesl - array set vals $defaultvalsl ;# this array is returned - - set current 0 - - while { $current < $len } { - set typelength [parseTLVHeader $data current] - set type [lindex $typelength 0] - set length [lindex $typelength 1] - if { $length == 0 || $length == "" } { break } - set pad [pad_32bit $length] - - if {![info exists tlvnames($type)] } { ;# unknown TLV type - if { $prmsg } { puts -nonewline "unknown=$type," } - incr current $length - continue - } - set tlvname $tlvnames($type) - set size $tlvsizes($tlvname) - # 32-bit and 64-bit vals pre-padded - if { $size == 4 || $size == 8 } { incr current $pad } - # read TLV data depending on size - switch -exact -- "$size" { - 2 { binary scan $data @${current}S vals($tlvname) } - 4 { binary scan $data @${current}I vals($tlvname) } - 8 { binary scan $data @${current}W vals($tlvname) } - 16 { binary scan $data @${current}c16 vals($tlvname) } - -1 { binary scan $data @${current}a${length} vals($tlvname) } - } - if { $size == -1 } { incr current $pad } ;# string vals post-padded - if { $type == 6 } { incr current $pad } ;# 128-bit vals post-padded - incr current $length - - if { $prmsg } { puts -nonewline "$tlvname=$vals($tlvname)," } - } - return [array get vals] -} - -proc parseExceptionMessage { data len flags channel } { - global showAPI - set prmsg $showAPI - - array set typenames { 1 num 2 sess 3 level 4 src 5 date 6 txt 10 opaque } - array set typesizes { num 4 sess -1 level 2 src -1 date -1 txt -1 \ - opaque -1 } - array set defvals { num -1 sess "" level -1 src "" date "" txt "" opaque ""} - - if { $prmsg==1 } { puts -nonewline "EXCEPTION(flags=$flags," } - array set vals [parseMessage $data $len $flags [array get typenames] \ - [array get typesizes] [array get defvals]] - if { $prmsg == 1 } { puts ") "} - - if { $vals(level) == $defvals(level) } { - puts "Exception Message received without an exception level."; return; - } - - receiveException [array get vals] -} - -proc sendNodePosMessage { channel node nodeid x y wlanid force } { - global showAPI - set prmsg $showAPI - - if { $channel == -1 } { - set channel [lindex [getEmulPlugin $node] 2] - if { $channel == -1 } { return } - } - set node_num [string range $node 1 end] - set x [format "%u" [expr int($x)]] - set y [format "%u" [expr int($y)]] - set len [expr 8+4+4] ;# node number, x, y - if {$nodeid > -1} { incr len 8 } - if {$wlanid > -1} { incr len 8 } - if {$force == 1 } { set crit 0x4 } else { set crit 0x0 } - #puts "sending [expr $len+4] bytes: $nodeid $x $y $wlanid" - if { $prmsg == 1 } { - puts -nonewline ">NODE(flags=$crit,$node,x=$x,y=$y" } - set msg [binary format ccSc2sIc2Sc2S \ - 1 $crit $len \ - {1 4} 0 $node_num \ - {0x20 2} $x \ - {0x21 2} $y - ] - - set msg2 "" - set msg3 "" - if { $nodeid > -1 } { - if { $prmsg == 1 } { puts -nonewline ",emuid=$nodeid" } - set msg2 [binary format c2sI {0x23 4} 0 $nodeid] - } - if { $wlanid > -1 } { - if { $prmsg == 1 } { puts -nonewline ",netid=$wlanid" } - set msg3 [binary format c2sI {0x24 4} 0 $wlanid] - } - - if { $prmsg == 1 } { puts ")" } - puts -nonewline $channel $msg$msg2$msg3 - flushChannel channel "Error sending node position" -} - -# build a new node -proc sendNodeAddMessage { channel node } { - global showAPI CORE_DATA_DIR - set prmsg $showAPI - set len [expr {8+8+4+4}]; # node number, type, x, y - set ipv4 0 - set ipv6 0 - set macstr "" - set wireless 0 - - # type, name - set type [getNodeTypeAPI $node] - set model [getNodeModel $node] - set model_len [string length $model] - set model_pad_len [pad_32bit $model_len] - set model_pad [binary format x$model_pad_len] - set name [getNodeName $node] - set name_len [string length $name] - set name_pad_len [pad_32bit $name_len] - set name_pad [binary format x$name_pad_len] - incr len [expr { 2+$name_len+$name_pad_len}] - if {$model_len > 0} { incr len [expr {2+$model_len+$model_pad_len }] } - set node_num [string range $node 1 end] - - # fixup node type for EMANE-enabled WLAN nodes - set opaque "" - if { [isEmane $node] } { set type 0xA } - - # emulation server (node location) - set emusrv [getNodeLocation $node] - set emusrv_len [string length $emusrv] - set emusrv_pad_len [pad_32bit $emusrv_len] - set emusrv_pad [binary format x$emusrv_pad_len] - if { $emusrv_len > 0 } { incr len [expr {2+$emusrv_len+$emusrv_pad_len } ] } - - # canvas - set canv [getNodeCanvas $node] - if { $canv != "c1" } { - set canv [string range $canv 1 end] ;# convert "c2" to "2" - incr len 4 - } else { - set canv "" - } - - # services - set svc [getNodeServices $node false] - set svc [join $svc "|"] - set svc_len [string length $svc] - set svc_pad_len [pad_32bit $svc_len] - set svc_pad [binary format x$svc_pad_len] - if { $svc_len > 0 } { incr len [expr {2+$svc_len+$svc_pad_len } ] } - - # icon - set icon [getCustomImage $node] - if { [file dirname $icon] == "$CORE_DATA_DIR/icons/normal" } { - set icon [file tail $icon] ;# don't include standard icon path - } - set icon_len [string length $icon] - set icon_pad_len [pad_32bit $icon_len] - set icon_pad [binary format x$icon_pad_len] - if { $icon_len > 0 } { incr len [expr {2+$icon_len+$icon_pad_len} ] } - - # opaque data - set opaque_len [string length $opaque] - set opaque_pad_len [pad_32bit $opaque_len] - set opaque_pad [binary format x$opaque_pad_len] - if { $opaque_len > 0 } { incr len [expr {2+$opaque_len+$opaque_pad_len} ] } - - # length must be calculated before this - if { $prmsg == 1 } { - puts -nonewline ">NODE(flags=add/str,$node,type=$type,$name," - } - set msg [binary format c2Sc2sIc2sIcc \ - {0x1 0x11} $len \ - {0x1 4} 0 $node_num \ - {0x2 4} 0 $type \ - 0x3 $name_len ] - puts -nonewline $channel $msg$name$name_pad - - # IPv4 address - if { $ipv4 > 0 } { - if { $prmsg == 1 } { puts -nonewline "$ipv4str," } - set msg [binary format c2sI {0x4 4} 0 $ipv4] - puts -nonewline $channel $msg - } - - # MAC address - if { $macstr != "" } { - if { $prmsg == 1 } { puts -nonewline "$macstr," } - set mac [join [split $macstr ":"] ""] - puts -nonewline $channel [binary format c2x2W {0x5 8} 0x$mac] - } - - # IPv6 address - if { $ipv6 != 0 } { - if { $prmsg == 1 } { puts -nonewline "$ipv6str," } - set msg [binary format c2 {0x6 16} ] - puts -nonewline $channel $msg - foreach ipv6w [split $ipv6 ":"] { - set msg [binary format S 0x$ipv6w] - puts -nonewline $channel $msg - } - puts -nonewline $channel [binary format x2]; # 2 bytes padding - } - - # model type - if { $model_len > 0 } { - set mh [binary format cc 0x7 $model_len] - puts -nonewline $channel $mh$model$model_pad - if { $prmsg == 1 } { puts -nonewline "m=$model," } - } - - # emulation server - if { $emusrv_len > 0 } { - puts -nonewline $channel [binary format cc 0x8 $emusrv_len] - puts -nonewline $channel $emusrv$emusrv_pad - if { $prmsg == 1 } { puts -nonewline "srv=$emusrv," } - } - - # X,Y coordinates - set coords [getNodeCoords $node] - set x [format "%u" [expr int([lindex $coords 0])]] - set y [format "%u" [expr int([lindex $coords 1])]] - set msg [binary format c2Sc2S {0x20 2} $x {0x21 2} $y] - puts -nonewline $channel $msg - - # canvas - if { $canv != "" } { - if { $prmsg == 1 } { puts -nonewline "canvas=$canv," } - set msg [binary format c2S {0x22 2} $canv] - puts -nonewline $channel $msg - } - - if { $prmsg == 1 } { puts -nonewline "x=$x,y=$y" } - - # services - if { $svc_len > 0 } { - puts -nonewline $channel [binary format cc 0x25 $svc_len] - puts -nonewline $channel $svc$svc_pad - if { $prmsg == 1 } { puts -nonewline ",svc=$svc" } - } - - # icon - if { $icon_len > 0 } { - puts -nonewline $channel [binary format cc 0x42 $icon_len] - puts -nonewline $channel $icon$icon_pad - if { $prmsg == 1 } { puts -nonewline ",icon=$icon" } - } - - # opaque data - if { $opaque_len > 0 } { - puts -nonewline $channel [binary format cc 0x50 $opaque_len] - puts -nonewline $channel $opaque$opaque_pad - if { $prmsg == 1 } { puts -nonewline ",opaque=$opaque" } - } - - if { $prmsg == 1 } { puts ")" } - - flushChannel channel "Error sending node add" -} - -# delete a node -proc sendNodeDelMessage { channel node } { - global showAPI - set prmsg $showAPI - set len 8; # node number - set node_num [string range $node 1 end] - - if { $prmsg == 1 } { puts ">NODE(flags=del/str,$node_num)" } - set msg [binary format c2Sc2sI \ - {0x1 0x12} $len \ - {0x1 4} 0 $node_num ] - puts -nonewline $channel $msg - flushChannel channel "Error sending node delete" -} - -# send a message to build, modify, or delete a link -# type should indicate add/delete/link/unlink -proc sendLinkMessage { channel link type {sendboth true} } { - global showAPI - set prmsg $showAPI - - set node1 [lindex [linkPeers $link] 0] - set node2 [lindex [linkPeers $link] 1] - set if1 [ifcByPeer $node1 $node2]; set if2 [ifcByPeer $node2 $node1] - if { [nodeType $node1] == "pseudo" } { return } ;# never seems to occur - if { [nodeType $node2] == "pseudo" } { - set mirror2 [getLinkMirror $node2] - set node2 [getNodeName $node2] - if { [string range $node1 1 end] > [string range $node2 1 end] } { - return ;# only send one link message (for two pseudo-links) - } - set if2 [ifcByPeer $node2 $mirror2] - } - set node1_num [string range $node1 1 end] - set node2_num [string range $node2 1 end] - - # flag for sending unidirectional link messages - set uni 0 - if { $sendboth && [isLinkUni $link] } { - set uni 1 - } - - # set flags and link message type from supplied type parameter - set flags 0 - set ltype 1 ;# add/delete a link (not wireless link/unlink) - set netid -1 - if { $type == "add" || $type == "link" } { - set flags 1 - } elseif { $type == "delete" || $type == "unlink" } { - set flags 2 - } - if { $type == "link" || $type == "unlink" } { - set ltype 0 ;# a wireless link/unlink event - set tmp [getLinkOpaque $link net] - if { $tmp != "" } { set netid [string range $tmp 1 end] } - } - - set key "" - if { [nodeType $node1] == "tunnel" } { - set key [netconfFetchSection $node1 "tunnel-key"] - if { $key == "" } { set key 1 } - } - if {[nodeType $node2] == "tunnel" } { - set key [netconfFetchSection $node2 "tunnel-key"] - if { $key == "" } { set key 1 } - } - - if { $prmsg == 1 } { - puts -nonewline ">LINK(flags=$flags,$node1_num-$node2_num," - } - - # len = node1num, node2num, type - set len [expr {8+8+8}] - set delay [getLinkDelay $link] - if { $delay == "" } { set delay 0 } - set jitter [getLinkJitter $link] - if { $jitter == "" } { set jitter 0 } - set bw [getLinkBandwidth $link] - if { $bw == "" } { set bw 0 } - set per [getLinkBER $link]; # PER and BER - if { $per == "" } { set per 0 } - set per_len 0 - set per_msg [buildStringTLV 0x5 $per per_len] - set dup [getLinkDup $link] - if { $dup == "" } { set dup 0 } - set dup_len 0 - set dup_msg [buildStringTLV 0x6 $dup dup_len] - if { $type != "delete" } { - incr len [expr {12+12+$per_len+$dup_len+12}] ;# delay,bw,per,dup,jitter - if {$prmsg==1 } { - puts -nonewline "$delay,$bw,$per,$dup,$jitter," - } - } - # TODO: mer, burst, mburst - if { $prmsg == 1 } { puts -nonewline "type=$ltype," } - if { $uni } { - incr len 4 - if { $prmsg == 1 } { puts -nonewline "uni=$uni," } - } - if { $netid > -1 } { - incr len 8 - if { $prmsg == 1 } { puts -nonewline "netid=$netid," } - } - if { $key != "" } { - incr len 8 - if { $prmsg == 1 } { puts -nonewline "key=$key," } - } - - set if1num [ifcNameToNum $if1]; set if2num [ifcNameToNum $if2] - set if1ipv4 0; set if2ipv4 0; set if1ipv6 ""; set if2ipv6 ""; - set if1ipv4mask 0; set if2ipv4mask 0; - set if1ipv6mask ""; set if2ipv6mask ""; set if1mac ""; set if2mac ""; - - if { $if1num >= 0 && ([[typemodel $node1].layer] == "NETWORK" || \ - [nodeType $node1] == "tunnel") } { - incr len 4 - if { $prmsg == 1 } { puts -nonewline "if1n=$if1num," } - if { $type != "delete" } { - getIfcAddrs $node1 $if1 if1ipv4 if1ipv6 if1mac if1ipv4mask \ - if1ipv6mask len - } - } - if { $if2num >= 0 && ([[typemodel $node2].layer] == "NETWORK" || \ - [nodeType $node2] == "tunnel") } { - incr len 4 - if { $prmsg == 1 } { puts -nonewline "if2n=$if2num," } - if { $type != "delete" } { - getIfcAddrs $node2 $if2 if2ipv4 if2ipv6 if2mac if2ipv4mask \ - if2ipv6mask len - } - } - - # start building the binary message on channel - # length must be calculated before this - set msg [binary format ccSc2sIc2sI \ - {0x2} $flags $len \ - {0x1 4} 0 $node1_num \ - {0x2 4} 0 $node2_num ] - puts -nonewline $channel $msg - - if { $type != "delete" } { - puts -nonewline $channel [binary format c2sW {0x3 8} 0 $delay] - puts -nonewline $channel [binary format c2sW {0x4 8} 0 $bw] - puts -nonewline $channel $per_msg - puts -nonewline $channel $dup_msg - puts -nonewline $channel [binary format c2sW {0x7 8} 0 $jitter] - } - # TODO: mer, burst, mburst - - # link type - puts -nonewline $channel [binary format c2sI {0x20 4} 0 $ltype] - - # unidirectional flag - if { $uni } { - puts -nonewline $channel [binary format c2S {0x22 2} $uni] - } - - # network ID - if { $netid > -1 } { - puts -nonewline $channel [binary format c2sI {0x24 4} 0 $netid] - } - - if { $key != "" } { - puts -nonewline $channel [binary format c2sI {0x25 4} 0 $key] - } - - # interface 1 info - if { $if1num >= 0 && ([[typemodel $node1].layer] == "NETWORK" || \ - [nodeType $node1] == "tunnel") } { - puts -nonewline $channel [ binary format c2S {0x30 2} $if1num ] - } - if { $if1ipv4 > 0 } { puts -nonewline $channel [binary format c2sIc2S \ - {0x31 4} 0 $if1ipv4 {0x32 2} $if1ipv4mask ] } - if { $if1mac != "" } { - set if1mac [join [split $if1mac ":"] ""] - puts -nonewline $channel [binary format c2x2W {0x33 8} 0x$if1mac] - } - if {$if1ipv6 != ""} { puts -nonewline $channel [binary format c2 {0x34 16}] - foreach ipv6w [split $if1ipv6 ":"] { puts -nonewline $channel \ - [binary format S 0x$ipv6w] } - puts -nonewline $channel [binary format x2c2S {0x35 2} $if1ipv6mask] } - - # interface 2 info - if { $if2num >= 0 && ([[typemodel $node2].layer] == "NETWORK" || \ - [nodeType $node2] == "tunnel") } { - puts -nonewline $channel [ binary format c2S {0x36 2} $if2num ] - } - if { $if2ipv4 > 0 } { puts -nonewline $channel [binary format c2sIc2S \ - {0x37 4} 0 $if2ipv4 {0x38 2} $if2ipv4mask ] } - if { $if2mac != "" } { - set if2mac [join [split $if2mac ":"] ""] - puts -nonewline $channel [binary format c2x2W {0x39 8} 0x$if2mac] - } - if {$if2ipv6 != ""} { puts -nonewline $channel [binary format c2 {0x40 16}] - foreach ipv6w [split $if2ipv6 ":"] { puts -nonewline $channel \ - [binary format S 0x$ipv6w] } - puts -nonewline $channel [binary format x2c2S {0x41 2} $if2ipv6mask] } - - if { $prmsg==1 } { puts ")" } - flushChannel channel "Error sending link message" - - ########################################################## - # send a second Link Message for unidirectional link effects - if { $uni < 1 } { - return - } - # first calculate length and possibly print the message - set flags 0 - if { $prmsg == 1 } { - puts -nonewline ">LINK(flags=$flags,$node2_num-$node1_num," - } - set len [expr {8+8+8}] ;# len = node2num, node1num (swapped), type - set delay [getLinkDelay $link up] - if { $delay == "" } { set delay 0 } - set jitter [getLinkJitter $link up] - if { $jitter == "" } { set jitter 0 } - set bw [getLinkBandwidth $link up] - if { $bw == "" } { set bw 0 } - set per [getLinkBER $link up]; # PER and BER - if { $per == "" } { set per 0 } - set per_len 0 - set per_msg [buildStringTLV 0x5 $per per_len] - set dup [getLinkDup $link up] - if { $dup == "" } { set dup 0 } - set dup_len 0 - set dup_msg [buildStringTLV 0x6 $dup dup_len] - incr len [expr {12+12+$per_len+$dup_len+12}] ;# delay,bw,per,dup,jitter - if {$prmsg==1 } { - puts -nonewline "$delay,$bw,$per,$dup,$jitter," - } - if { $prmsg == 1 } { puts -nonewline "type=$ltype," } - incr len 4 ;# unidirectional flag - if { $prmsg == 1 } { puts -nonewline "uni=$uni," } - # note that if1num / if2num are reversed here due to reversed node nums - if { $if2num >= 0 && ([[typemodel $node2].layer] == "NETWORK" || \ - [nodeType $node2] == "tunnel") } { - incr len 4 - if { $prmsg == 1 } { puts -nonewline "if1n=$if2num," } - } - if { $if1num >= 0 && ([[typemodel $node1].layer] == "NETWORK" || \ - [nodeType $node1] == "tunnel") } { - incr len 4 - if { $prmsg == 1 } { puts -nonewline "if2n=$if1num," } - } - # build and send the link message - set msg [binary format ccSc2sIc2sI \ - {0x2} $flags $len \ - {0x1 4} 0 $node2_num \ - {0x2 4} 0 $node1_num ] - puts -nonewline $channel $msg - puts -nonewline $channel [binary format c2sW {0x3 8} 0 $delay] - puts -nonewline $channel [binary format c2sW {0x4 8} 0 $bw] - puts -nonewline $channel $per_msg - puts -nonewline $channel $dup_msg - puts -nonewline $channel [binary format c2sW {0x7 8} 0 $jitter] - puts -nonewline $channel [binary format c2sI {0x20 4} 0 $ltype] - puts -nonewline $channel [binary format c2S {0x22 2} $uni] - if { $if2num >= 0 && ([[typemodel $node2].layer] == "NETWORK" || \ - [nodeType $node2] == "tunnel") } { - puts -nonewline $channel [ binary format c2S {0x30 2} $if2num ] - } - if { $if1num >= 0 && ([[typemodel $node1].layer] == "NETWORK" || \ - [nodeType $node1] == "tunnel") } { - puts -nonewline $channel [ binary format c2S {0x36 2} $if1num ] - } - if { $prmsg==1 } { puts ")" } - flushChannel channel "Error sending link message" -} - -# helper to get IPv4, IPv6, MAC address and increment length -# also prints TLV-style addresses if showAPI is true -proc getIfcAddrs { node ifc ipv4p ipv6p macp ipv4maskp ipv6maskp lenp } { - global showAPI - upvar $ipv4p ipv4 - upvar $ipv6p ipv6 - upvar $macp mac - upvar $ipv4maskp ipv4mask - upvar $ipv6maskp ipv6mask - upvar $lenp len - - if { $ifc == "" || $node == "" } { return } - - # IPv4 address - set ipv4str [getIfcIPv4addr $node $ifc] - if {$ipv4str != ""} { - set ipv4 [lindex [split $ipv4str /] 0] - if { [info exists ipv4mask ] } { - set ipv4mask [lindex [split $ipv4str / ] 1] - incr len 12; # 8 addr + 4 mask - if { $showAPI == 1 } { puts -nonewline "$ipv4str," } - } else { - incr len 8; # 8 addr - if { $showAPI == 1 } { puts -nonewline "$ipv4," } - } - set ipv4 [stringToIPv4 $ipv4]; # convert to integer - } - - # IPv6 address - set ipv6str [getIfcIPv6addr $node $ifc] - if {$ipv6str != ""} { - set ipv6 [lindex [split $ipv6str /] 0] - if { [info exists ipv6mask ] } { - set ipv6mask [lindex [split $ipv6str / ] 1] - incr len 24; # 20 addr + 4 mask - if { $showAPI == 1 } { puts -nonewline "$ipv6str," } - } else { - incr len 20; # 20 addr - if { $showAPI == 1 } { puts -nonewline "$ipv6," } - } - set ipv6 [expandIPv6 $ipv6]; # convert to long string - } - - # MAC address (from conf if there, otherwise generated) - if { [info exists mac] } { - set mac [lindex [getIfcMacaddr $node $ifc] 0] - if {$mac == ""} { - set mac [getNextMac] - } - if { $showAPI == 1 } { puts -nonewline "$mac," } - incr len 12; - } -} - -# -# Register Message: (registration types) -# This is a simple Register Message, types is an array of -# tuples. -proc sendRegMessage { channel flags types_list } { - global showAPI regtypes - set prmsg $showAPI - - if { $channel == -1 || $channel == "" } { - set plugin [lindex [getEmulPlugin "*"] 0] - set channel [pluginConnect $plugin connect true] - if { $channel == -1 } { return } - } - set len 0 - array set types $types_list - - # array names output is unreliable, sort it - set type_list [lsort -dict [array names types]] - foreach type $type_list { - if { ![info exists regtypes($type)] } { - puts "sendRegMessage: unknown registration type '$type'" - return -1 - } - set str_$type $types($type) - set str_${type}_len [string length [set str_$type]] - set str_${type}_pad_len [pad_32bit [set str_${type}_len]] - set str_${type}_pad [binary format x[set str_${type}_pad_len]] - incr len [expr { 2 + [set str_${type}_len] + [set str_${type}_pad_len]}] - } - - if { $prmsg == 1 } { puts ">REG($type_list)" } - # message header - set msg1 [binary format ccS 4 $flags $len] - puts -nonewline $channel $msg1 - - foreach type $type_list { - set type_num $regtypes($type) - set tlvh [binary format cc $type_num [set str_${type}_len]] - puts -nonewline $channel $tlvh[set str_${type}][set str_${type}_pad] - } - - flushChannel channel "Error: API channel was closed" -} - -# -# Configuration Message: (object, type flags, node) -# This is a simple Configuration Message containing flags -proc sendConfRequestMessage { channel node model flags netid opaque } { - global showAPI - set prmsg $showAPI - - if { $channel == -1 || $channel == "" } { - set pname [lindex [getEmulPlugin $node] 0] - set channel [pluginConnect $pname connect true] - if { $channel == -1 } { return } - } - - set model_len [string length $model] - set model_pad_len [pad_32bit $model_len] - set model_pad [binary format x$model_pad_len ] - set len [expr {4+2+$model_len+$model_pad_len}] - # optional network ID to provide Netgraph mapping - if { $netid != -1 } { incr len 8 } - # convert from node name to number - if { [string is alpha [string range $node 0 0]] } { - set node [string range $node 1 end] - } - - if { $node > 0 } { incr len 8 } - # add a session number when configuring services - set session "" - set session_len 0 - set session_pad_len 0 - set session_pad "" - if { $node <= 0 && $model == "services" } { - global g_current_session - set session [format "0x%x" $g_current_session] - set session_len [string length $session] - set session_pad_len [pad_32bit $session_len] - set session_pad [binary format x$session_pad_len] - incr len [expr {2 + $session_len + $session_pad_len}] - } - # opaque data - used when custom configuring services - set opaque_len 0 - set msgop [buildStringTLV 0x50 $opaque opaque_len] - if { $opaque_len > 0 } { incr len $opaque_len } - - if { $prmsg == 1 } { - puts -nonewline ">CONF(flags=0," - if { $node > 0 } { puts -nonewline "node=$node," } - puts -nonewline "obj=$model,cflags=$flags" - if { $session != "" } { puts -nonewline ",session=$session" } - if { $netid > -1 } { puts -nonewline ",netid=$netid" } - if { $opaque_len > 0 } { puts -nonewline ",opaque=$opaque" } - puts ") request" - } - # header, node node number, node model header - set msg1 [binary format c2S {5 0} $len ] - set msg1b "" - if { $node > 0 } { set msg1b [binary format c2sI {1 4} 0 $node] } - set msg1c [binary format cc 2 $model_len] - # request flag - set msg2 [binary format c2S {3 2} $flags ] - # session number - set msg3 "" - if { $session != "" } { - set msg3 [binary format cc 0x0A $session_len] - set msg3 $msg3$session$session_pad - } - # network ID - set msg4 "" - if { $netid != -1 } { - set msg4 [binary format c2sI {0x23 4} 0 0x$netid ] - } - - #catch {puts -nonewline $channel $msg1$model$model_pad$msg2$msg3$msg4$msg5} - puts -nonewline $channel $msg1$msg1b$msg1c$model$model_pad$msg2$msg3$msg4 - if { $opaque_len > 0 } { puts -nonewline $channel $msgop } - - flushChannel channel "Error: API channel was closed" -} - -# -# Configuration Message: (object, type flags, node, types, values) -# This message is more complicated to build because of the list of -# data types and values. -proc sendConfReplyMessage { channel node model types values opaque } { - global showAPI - set prmsg $showAPI - # convert from node name to number - if { [string is alpha [string range $node 0 0]] } { - set node [string range $node 1 end] - } - # add a session number when configuring services - set session "" - set session_len 0 - set session_pad_len 0 - set session_pad "" - if { $node <= 0 && $model == "services" && $opaque == "" } { - global g_current_session - set session [format "0x%x" $g_current_session] - set session_len [string length $session] - set session_pad_len [pad_32bit $session_len] - set session_pad [binary format x$session_pad_len] - incr len [expr {$session_len + $session_pad_len}] - } - - if { $prmsg == 1 } { - puts -nonewline ">CONF(flags=0," - if {$node > -1 } { puts -nonewline "node=$node," } - puts -nonewline "obj=$model,cflags=0" - if {$session != "" } { puts -nonewline "session=$session," } - if {$opaque != "" } { puts -nonewline "opaque=$opaque," } - puts "types=<$types>,values=<$values>) reply" - } - - # types (16-bit values) and values - set n 0 - set type_len [expr {[llength $types] * 2} ] - set type_data [binary format cc 4 $type_len] - set value_data "" - foreach type $types { - set t [binary format S $type] - set type_data $type_data$t - set val [lindex $values $n] - if { $val == "" } { - #puts "warning: empty value $n (type=$type)" - if { $type != 10 } { set val 0 } - } - incr n - lappend value_data $val - }; # end foreach - set value_len 0 - set value_data [join $value_data |] - set msgval [buildStringTLV 0x5 $value_data value_len] - set type_pad_len [pad_32bit $type_len] - set type_pad [binary format x$type_pad_len ] - set model_len [string length $model] - set model_pad_len [pad_32bit $model_len] - set model_pad [binary format x$model_pad_len ] - # opaque data - used when custom configuring services - set opaque_len 0 - set msgop [buildStringTLV 0x50 $opaque opaque_len] - - # 4 bytes header, model TLV - set len [expr 4+2+$model_len+$model_pad_len] - if { $node > -1 } { incr len 8 } - # session number - set msg3 "" - if { $session != "" } { - incr len [expr {2 + $session_len + $session_pad_len }] - set msg3 [binary format cc 0x0A $session_len] - set msg3 $msg3$session$session_pad - } - if { $opaque_len > 0 } { incr len $opaque_len } - # types TLV, values TLV - incr len [expr {2 + $type_len + $type_pad_len + $value_len}] - - # header, node node number, node model header - set msgh [binary format c2S {5 0} $len ] - set msgwl "" - if { $node > -1 } { set msgwl [binary format c2sI {1 4} 0 $node] } - set model_hdr [binary format cc 2 $model_len] - # no flags - set type_hdr [binary format c2S {3 2} 0 ] - set msg $msgh$msgwl$model_hdr$model$model_pad$type_hdr$type_data$type_pad - set msg $msg$msgval$msg3 - puts -nonewline $channel $msg - if { $opaque_len > 0 } { puts -nonewline $channel $msgop } - flushChannel channel "Error sending conf reply" -} - -# Event Message -proc sendEventMessage { channel type nodenum name data flags } { - global showAPI eventtypes - set prmsg $showAPI - - set len [expr 8] ;# event type - if {$nodenum > -1} { incr len 8 } - set name_len [string length $name] - set name_pad_len [pad_32bit $name_len] - if { $name_len > 0 } { incr len [expr {2 + $name_len + $name_pad_len}] } - set data_len [string length $data] - set data_pad_len [pad_32bit $data_len] - if { $data_len > 0 } { incr len [expr {2 + $data_len + $data_pad_len}] } - - if { $prmsg == 1 } { - puts -nonewline ">EVENT(flags=$flags," } - set msg [binary format ccS 8 $flags $len ] ;# message header - - set msg2 "" - if { $nodenum > -1 } { - if { $prmsg == 1 } { puts -nonewline "node=$nodenum," } - set msg2 [binary format c2sI {0x01 4} 0 $nodenum] - } - if { $prmsg == 1} { - set typestr "" - foreach t [array names eventtypes] { - if { $eventtypes($t) == $type } { set typestr "-$t"; break } - } - puts -nonewline "type=$type$typestr," - } - set msg3 [binary format c2sI {0x02 4} 0 $type] - set msg4 "" - set msg5 "" - if { $name_len > 0 } { - if { $prmsg == 1 } { puts -nonewline "name=$name," } - set msg4 [binary format cc 0x03 $name_len ] - set name_pad [binary format x$name_pad_len ] - set msg5 $name$name_pad - } - set msg6 "" - set msg7 "" - if { $data_len > 0 } { - if { $prmsg == 1 } { puts -nonewline "data=$data" } - set msg6 [binary format cc 0x04 $data_len ] - set data_pad [binary format x$data_pad_len ] - set msg7 $data$data_pad - } - - if { $prmsg == 1 } { puts ")" } - puts -nonewline $channel $msg$msg2$msg3$msg4$msg5$msg6$msg7 - flushChannel channel "Error sending Event type=$type" -} - - -# deploy working configuration using CORE API -# Deploys a current working configuration. It creates all the -# nodes and link as defined in configuration file. -proc deployCfgAPI { sock } { - global eid - global node_list link_list annotation_list canvas_list - global mac_byte4 mac_byte5 - global execMode - global ngnodemap - global mac_addr_start - global deployCfgAPI_lock - global eventtypes - global g_comments - - if { ![info exists deployCfgAPI_lock] } { set deployCfgAPI_lock 0 } - if { $deployCfgAPI_lock } { - puts "***error: deployCfgAPI called while deploying config" - return - } - - set deployCfgAPI_lock 1 ;# lock - - set mac_byte4 0 - set mac_byte5 0 - if { [info exists mac_addr_start] } { set mac_byte5 $mac_addr_start } - set t_start [clock seconds] - - global systype - set systype [lindex [checkOS] 0] - statgraph on [expr (2*[llength $node_list]) + [llength $link_list]] - - - sendSessionProperties $sock - - # this tells the CORE services that we are starting to send - # configuration data - # clear any existing config - sendEventMessage $sock $eventtypes(definition_state) -1 "" "" 0 - # inform CORE services about emulation servers, hook scripts, canvas info, - # and services - sendEventMessage $sock $eventtypes(configuration_state) -1 "" "" 0 - sendEmulationServerInfo $sock 0 - sendSessionOptions $sock - sendHooks $sock - sendCanvasInfo $sock - sendNodeTypeInfo $sock 0 - # send any custom service info before the node messages - sendNodeCustomServices $sock - - # send Node add messages for all emulation nodes - foreach node $node_list { - set node_id "$eid\_$node" - set type [nodeType $node] - set name [getNodeName $node] - if { $type == "pseudo" } { continue } - - statgraph inc 1 - statline "Creating node $name" - if { [[typemodel $node].layer] == "NETWORK" } { - nodeHighlights .c $node on red - } - # inform the CORE daemon of the node - sendNodeAddMessage $sock $node - pluginCapsInitialize $node "mobmodel" - writeNodeCoords $node [getNodeCoords $node] - } - - # send Link add messages for all network links - for { set pending_links $link_list } { $pending_links != "" } {} { - set link [lindex $pending_links 0] - set i [lsearch -exact $pending_links $link] - set pending_links [lreplace $pending_links $i $i] - statgraph inc 1 - - set lnode1 [lindex [linkPeers $link] 0] - set lnode2 [lindex [linkPeers $link] 1] - if { [nodeType $lnode2] == "router" && \ - [getNodeModel $lnode2] == "remote" } { - continue; # remote routers are ctrl. by GUI; TODO: move to daemon - } - sendLinkMessage $sock $link add - } - - # GUI-specific meta-data send via Configure Messages - if { [llength $annotation_list] > 0 } { - sendMetaData $sock $annotation_list "annotation" - } - sendMetaData $sock $canvas_list "canvas" ;# assume >= 1 canvas - # global GUI options - send as meta-data - set obj "metadata" - set values [getGlobalOptionList] - sendConfReplyMessage $sock -1 $obj "10" "{global_options=$values}" "" - if { [info exists g_comments] && $g_comments != "" } { - sendConfReplyMessage $sock -1 $obj "10" "{comments=$g_comments}" "" - } - - # status bar graph - statgraph off 0 - statline "Network topology instantiated in [expr [clock seconds] - $t_start] seconds ([llength $node_list] nodes and [llength $link_list] links)." - - # TODO: turn on tcpdump if enabled; customPostConfigCommands; - # addons 4 deployCfgHook - - # draw lines between wlan nodes - # initialization does not work earlier than this - - foreach node $node_list { - # WLAN handling: draw lines between wireless nodes - if { [nodeType $node] == "wlan" && $execMode == "interactive" } { - wlanRunMobilityScript $node - } - } - - sendTrafficScripts $sock - - # tell the CORE services that we are ready to instantiate - sendEventMessage $sock $eventtypes(instantiation_state) -1 "" "" 0 - - set deployCfgAPI_lock 0 ;# unlock - - statline "Network topology instantiated in [expr [clock seconds] - $t_start] seconds ([llength $node_list] nodes and [llength $link_list] links)." -} - -# -# emulation shutdown procedure when using the CORE API -proc shutdownSession {} { - global link_list node_list eid eventtypes execMode - - set nodecount [getNodeCount] - if { $nodecount == 0 } { - # This allows switching to edit mode without extra API messages, - # such as when file new is selected while running an existing session. - return - } - - # prepare the channel - set plugin [lindex [getEmulPlugin "*"] 0] - set sock [pluginConnect $plugin connect true] - - sendEventMessage $sock $eventtypes(datacollect_state) -1 "" "" 0 - - # shut down all links - foreach link $link_list { - - set lnode2 [lindex [linkPeers $link] 1] - if { [nodeType $lnode2] == "router" && \ - [getNodeModel $lnode2] == "remote" } { - continue; # remote routers are ctrl. by GUI; TODO: move to daemon - } - - sendLinkMessage $sock $link delete false - } - # shut down all nodes - foreach node $node_list { - set type [nodeType $node] - if { [[typemodel $node].layer] == "NETWORK" && $execMode != "batch" } { - nodeHighlights .c $node on red - } - sendNodeDelMessage $sock $node - pluginCapsDeinitialize $node "mobmodel" - deleteNodeCoords $node - } - - sendNodeTypeInfo $sock 1 - sendEmulationServerInfo $sock 1 -} - -# inform the CORE services about the canvas information to support -# conversion between X,Y and lat/long coordinates -proc sendCanvasInfo { sock } { - global curcanvas - - if { ![info exists curcanvas] } { return } ;# batch mode - set obj "location" - - set scale [getCanvasScale $curcanvas] - set refpt [getCanvasRefPoint $curcanvas] - set refx [lindex $refpt 0] - set refy [lindex $refpt 1] - set latitude [lindex $refpt 2] - set longitude [lindex $refpt 3] - set altitude [lindex $refpt 4] - - set types [list 2 2 10 10 10 10] - set values [list $refx $refy $latitude $longitude $altitude $scale] - - sendConfReplyMessage $sock -1 $obj $types $values "" -} - -# inform the CORE services about the default services for a node type, which -# are used when node-specific services have not been configured for a node -proc sendNodeTypeInfo { sock reset } { - global node_list - - set obj "services" - - if { $reset == 1} { - sendConfRequestMessage $sock -1 "all" 0x3 -1 "" - return - } - # build a list of node types in use - set typesinuse "" - foreach node $node_list { - set type [nodeType $node] - if { $type != "router" } { continue } - set model [getNodeModel $node] - if { [lsearch $typesinuse $model] < 0 } { lappend typesinuse $model } - } - - foreach type $typesinuse { - # build a list of type + enabled services, all strings - set values [getNodeTypeServices $type] - set values [linsert $values 0 $type] - set types [string repeat "10 " [llength $values]] - sendConfReplyMessage $sock -1 $obj $types $values "" - # send any custom profiles for a node type; node type passed in opaque - set machine_type [getNodeTypeMachineType $type] - set values [getNodeTypeProfile $type] - if { $values != "" } { - set types [string repeat "10 " [llength $values]] - sendConfReplyMessage $sock -1 $machine_type $types $values \ - "$machine_type:$type" - } - } - -} - -# inform the CORE services about any services that have been customized for -# a particular node -proc sendNodeCustomServices { sock } { - global node_list - foreach node $node_list { - set cfgs [getCustomConfig $node] - set cfgfiles "" - foreach cfg $cfgs { - set ids [split [getConfig $cfg "custom-config-id"] :] - if { [lindex $ids 0] != "service" } { continue } - if { [llength $ids] == 3 } { - # customized service config file -- build a list - lappend cfgfiles $cfg - continue - } - set s [lindex $ids 1] - set values [getConfig $cfg "config"] - set t [string repeat "10 " [llength $values]] - sendConfReplyMessage $sock $node services $t $values "service:$s" - } - # send customized service config files after the service info - foreach cfg $cfgfiles { - set idstr [getConfig $cfg "custom-config-id"] - set ids [split $idstr :] - if { [lindex $ids 0] != "service" } { continue } - set s [lindex $ids 1] - set filename [lindex $ids 2] - set data [join [getConfig $cfg "config"] "\n"] - sendFileMessage $sock $node "service:$s" $filename "" $data \ - [string length $data] - } - } -} - -# publish hooks to the CORE services -proc sendHooks { sock } { - global g_hook_scripts - if { ![info exists g_hook_scripts] } { return } - foreach hook $g_hook_scripts { - set name [lindex $hook 0] - set state [lindex $hook 1] - set data [lindex $hook 2] - # TODO: modify sendFileMessage to make node number optional - sendFileMessage $sock n0 "hook:$state" $name "" $data \ - [string length $data] - } -} - -# inform the CORE services about the emulation servers that will be used -proc sendEmulationServerInfo { sock reset } { - global exec_servers - set node -1 ;# not used - set obj "broker" - - set servernames [getAssignedRemoteServers] - if { $servernames == "" } { return } ;# not using emulation servers - - if { $reset == 1} { - sendConfRequestMessage $sock $node $obj 0x3 -1 "" - return - } - - set servers "" - foreach servername $servernames { - set host [lindex $exec_servers($servername) 0] - set port [lindex $exec_servers($servername) 1] - lappend servers "$servername:$host:$port" - } - - set serversstring [join $servers ,] - - set types [list 10] - set values [list $serversstring] - - sendConfReplyMessage $sock $node $obj $types $values "" -} - -# returns the length of node_list minus any pseudo-nodes (inter-canvas nodes) -proc getNodeCount {} { - global node_list - set nodecount 0 - foreach node $node_list { - if { [nodeType $node] != "pseudo" } { incr nodecount } - } - return $nodecount -} - -# send basic properties of a session -proc sendSessionProperties { sock } { - global currentFile CORE_DATA_DIR CORE_USER - set sessionname [file tail $currentFile] - set nodecount [getNodeCount] - if { $sessionname == "" } { set sessionname "untitled" } - set tf "/tmp/thumb.jpg" - if { ![writeCanvasThumbnail .c $tf] } { - set src "$CORE_DATA_DIR/icons/normal/thumb-unknown.gif" - set tf "/tmp/thumb.gif" - if [catch { file copy $src $tf } e] { - puts -nonewline "warning: failed to copy $src to $tf\n($e)" - set tf "" - } - } - set user $CORE_USER - sendSessionMessage $sock 0 0 $sessionname $currentFile $nodecount $tf $user -} - -# send session options from global array in Config Message -proc sendSessionOptions { sock } { - if { $sock == -1 } { - set sock [lindex [getEmulPlugin "*"] 2] - } - set values [getSessionOptionsList] - set types [string repeat "10 " [llength $values]] - sendConfReplyMessage $sock -1 "session" $types $values "" -} - -# send annotations as key=value metadata in Config Message -proc sendAnnotations { sock } { - global annotation_list - - if { $sock == -1 } { - set sock [lindex [getEmulPlugin "*"] 2] - } - set values "" - foreach a $annotation_list { - global $a - set val [set $a] - lappend values "annotation $a=$val" - } - set types [string repeat "10 " [llength $values]] - sendConfReplyMessage $sock -1 "metadata" $types $values "" -} - -# send items as key=value metadata in Config Message -proc sendMetaData { sock items itemtype } { - - if { $sock == -1 } { - set sock [lindex [getEmulPlugin "*"] 2] - } - set values "" - foreach i $items { - global $i - set val [set $i] - lappend values "$itemtype $i=$val" - } - set types [string repeat "10 " [llength $values]] - sendConfReplyMessage $sock -1 "metadata" $types $values "" -} - -# send an Event message for the definition state (this clears any existing -# state), then send all node and link definitions to the CORE services -proc sendNodeLinkDefinitions { sock } { - global node_list link_list annotation_list canvas_list eventtypes - global g_comments - #sendEventMessage $sock $eventtypes(definition_state) -1 "" "" 0 - foreach node $node_list { - sendNodeAddMessage $sock $node - pluginCapsInitialize $node "mobmodel" - } - foreach link $link_list { sendLinkMessage $sock $link add } - # GUI-specific meta-data send via Configure Messages - sendMetaData $sock $annotation_list "annotation" - sendMetaData $sock $canvas_list "canvas" - set obj "metadata" - set values [getGlobalOptionList] - sendConfReplyMessage $sock -1 $obj "10" "{global_options=$values}" "" - if { [info exists g_comments] && $g_comments != "" } { - sendConfReplyMessage $sock -1 $obj "10" "{comments=$g_comments}" "" - } -} - -proc getNodeTypeAPI { node } { - set type [nodeType $node] - if { $type == "router" } { - set model [getNodeModel $node] - set type [getNodeTypeMachineType $model] - } - switch -exact -- "$type" { - router { return 0x0 } - netns { return 0x0 } - jail { return 0x0 } - physical { return 0x1 } - tbd { return 0x3 } - lanswitch { return 0x4 } - hub { return 0x5 } - wlan { return 0x6 } - rj45 { return 0x7 } - tunnel { return 0x8 } - ktunnel { return 0x9 } - emane { return 0xA } - default { return 0x0 } - } -} - -# send an Execute message -proc sendExecMessage { channel node cmd exec_num flags } { - global showAPI g_api_exec_num - set prmsg $showAPI - - set node_num [string range $node 1 end] - set cmd_len [string length $cmd] - if { $cmd_len > 255 } { puts "sendExecMessage error: cmd too long!"; return} - set cmd_pad_len [pad_32bit $cmd_len] - set cmd_pad [binary format x$cmd_pad_len] - - if { $exec_num == 0 } { - incr g_api_exec_num - set exec_num $g_api_exec_num - } - - # node num + exec num + command string - set len [expr {8 + 8 + 2 + $cmd_len + $cmd_pad_len}] - - if { $prmsg == 1 } {puts ">EXEC(flags=$flags,$node,n=$exec_num,cmd='$cmd')" } - - set msg [binary format ccSc2sIc2sIcc \ - 3 $flags $len \ - {1 4} 0 $node_num \ - {2 4} 0 $exec_num \ - 4 $cmd_len \ - ] - puts -nonewline $channel $msg$cmd$cmd_pad - flushChannel channel "Error sending file message" -} - -# if source file (sf) is specified, then send a message that the file source -# file should be copied to the given file name (f); otherwise, include the file -# data in this message -proc sendFileMessage { channel node type f sf data data_len } { - global showAPI - set prmsg $showAPI - - set node_num [string range $node 1 end] - - set f_len [string length $f] - set f_pad_len [pad_32bit $f_len] - set f_pad [binary format x$f_pad_len] - set type_len [string length $type] - set type_pad_len [pad_32bit $type_len] - set type_pad [binary format x$type_pad_len] - if { $sf != "" } { - set sf_len [string length $sf] - set sf_pad_len [pad_32bit $sf_len] - set sf_pad [binary format x$sf_pad_len] - set data_len 0 - set data_pad_len 0 - } else { - set sf_len 0 - set sf_pad_len 0 - set data_pad_len [pad_32bit $data_len] - set data_pad [binary format x$data_pad_len] - } - # TODO: gzip compression w/tlv type 0x11 - - # node number TLV + file name TLV + ( file src name / data TLV) - set len [expr {8 + 2 + 2 + $f_len + $f_pad_len + $sf_len + $sf_pad_len \ - + $data_len + $data_pad_len}] - # 16-bit data length - if { $data_len > 255 } { - incr len 2 - if { $data_len > 65536 } { - puts -nonewline "*** error: File Message data length too large " - puts "($data_len > 65536)" - return - } - } - if { $type_len > 0 } { incr len [expr {2 + $type_len + $type_pad_len}] } - set flags 1; # add flag - - if { $prmsg == 1 } { - puts -nonewline ">FILE(flags=$flags,$node,f=$f," - if { $type != "" } { puts -nonewline "type=$type," } - if { $sf != "" } { puts "src=$sf)" - } else { puts "data=($data_len))" } - } - - set msg [binary format ccSc2sIcc \ - 6 $flags $len \ - {1 4} 0 $node_num \ - 2 $f_len \ - ] - set msg2 "" - if { $type_len > 0 } { - set msg2 [binary format cc 0x5 $type_len] - set msg2 $msg2$type$type_pad - } - if { $sf != "" } { ;# source file name TLV - set msg3 [binary format cc 0x6 $sf_len] - puts -nonewline $channel $msg$f$f_pad$msg2$msg3$sf$sf_pad - } else { ;# file data TLV - if { $data_len > 255 } { - set msg3 [binary format ccS 0x10 0 $data_len] - } else { - set msg3 [binary format cc 0x10 $data_len] - } - puts -nonewline $channel $msg$f$f_pad$msg2$msg3$data$data_pad - } - flushChannel channel "Error sending file message" -} - -# Session Message -proc sendSessionMessage { channel flags num name sfile nodecount tf user } { - global showAPI - set prmsg $showAPI - - if { $channel == -1 } { - set pname [lindex [getEmulPlugin "*"] 0] - set channel [pluginConnect $pname connect true] - if { $channel == -1 } { return } - } - - set num_len [string length $num] - set num_pad_len [pad_32bit $num_len] - set len [expr {2 + $num_len + $num_pad_len}] - if { $num_len <= 0 } { - puts "error: sendSessionMessage requires at least one session number" - return - } - set name_len [string length $name] - set name_pad_len [pad_32bit $name_len] - if { $name_len > 0 } { incr len [expr { 2 + $name_len + $name_pad_len }] } - set sfile_len [string length $sfile] - set sfile_pad_len [pad_32bit $sfile_len] - if { $sfile_len > 0 } { - incr len [expr { 2 + $sfile_len + $sfile_pad_len }] - } - set nc_len [string length $nodecount] - set nc_pad_len [pad_32bit $nc_len] - if { $nc_len > 0 } { incr len [expr { 2 + $nc_len + $nc_pad_len }] } - set tf_len [string length $tf] - set tf_pad_len [pad_32bit $tf_len] - if { $tf_len > 0 } { incr len [expr { 2 + $tf_len + $tf_pad_len }] } - set user_len [string length $user] - set user_pad_len [pad_32bit $user_len] - if { $user_len > 0 } { incr len [expr { 2 + $user_len + $user_pad_len }] } - - if { $prmsg == 1 } { - puts -nonewline ">SESSION(flags=$flags" } - set msgh [binary format ccS 0x09 $flags $len ] ;# message header - - if { $prmsg == 1 } { puts -nonewline ",sids=$num" } - set num_hdr [binary format cc 0x01 $num_len] - set num_pad [binary format x$num_pad_len ] - set msg1 "$num_hdr$num$num_pad" - - set msg2 "" - if { $name_len > 0 } { - if { $prmsg == 1 } { puts -nonewline ",name=$name" } - # TODO: name_len > 255 - set name_hdr [binary format cc 0x02 $name_len] - set name_pad [binary format x$name_pad_len] - set msg2 "$name_hdr$name$name_pad" - } - set msg3 "" - if { $sfile_len > 0 } { - if { $prmsg == 1 } { puts -nonewline ",file=$sfile" } - # TODO: sfile_len > 255 - set sfile_hdr [binary format cc 0x03 $sfile_len] - set sfile_pad [binary format x$sfile_pad_len] - set msg3 "$sfile_hdr$sfile$sfile_pad" - } - set msg4 "" - if { $nc_len > 0 } { - if { $prmsg == 1 } { puts -nonewline ",nc=$nodecount" } - set nc_hdr [binary format cc 0x04 $nc_len] - set nc_pad [binary format x$nc_pad_len] - set msg4 "$nc_hdr$nodecount$nc_pad" - } - set msg5 "" - if { $tf_len > 0 } { - if { $prmsg == 1 } { puts -nonewline ",thumb=$tf" } - set tf_hdr [binary format cc 0x06 $tf_len] - set tf_pad [binary format x$tf_pad_len] - set msg5 "$tf_hdr$tf$tf_pad" - } - set msg6 "" - if { $user_len > 0 } { - if { $prmsg == 1 } { puts -nonewline ",user=$user" } - set user_hdr [binary format cc 0x07 $user_len] - set user_pad [binary format x$user_pad_len] - set msg6 "$user_hdr$user$user_pad" - } - - if { $prmsg == 1 } { puts ")" } - puts -nonewline $channel $msgh$msg1$msg2$msg3$msg4$msg5$msg6 - flushChannel channel "Error sending Session num=$num" -} - -# return a new execution number and record it in the execution request list -# for the given callback (e.g. widget) type -proc newExecCallbackRequest { type } { - global g_api_exec_num g_execRequests - incr g_api_exec_num - set exec_num $g_api_exec_num - lappend g_execRequests($type) $exec_num - return $exec_num -} - -# ask daemon to load or save an XML file based on the current session -proc xmlFileLoadSave { cmd name } { - global oper_mode eventtypes - - set plugin [lindex [getEmulPlugin "*"] 0] - set sock [pluginConnect $plugin connect true] - if { $sock == -1 || $sock == "" } { return } - - # inform daemon about nodes and links when saving in edit mode - if { $cmd == "save" && $oper_mode != "exec" } { - sendSessionProperties $sock - # this tells the CORE services that we are starting to send - # configuration data - # clear any existing config - sendEventMessage $sock $eventtypes(definition_state) -1 "" "" 0 - sendEventMessage $sock $eventtypes(configuration_state) -1 "" "" 0 - sendEmulationServerInfo $sock 0 - sendSessionOptions $sock - sendHooks $sock - sendCanvasInfo $sock - sendNodeTypeInfo $sock 0 - # send any custom service info before the node messages - sendNodeCustomServices $sock - sendNodeLinkDefinitions $sock - } elseif { $cmd == "open" } { - # reset config objects - sendNodeTypeInfo $sock 1 - } - sendEventMessage $sock $eventtypes(file_$cmd) -1 $name "" 0 -} - -############################################################################ -# -# Helper functions below here -# - -# helper function to get interface number from name -proc ifcNameToNum { ifc } { - # eth0, eth1, etc. - if {[string range $ifc 0 2] == "eth"} { - set ifnum [string range $ifc 3 end] - # l0, l1, etc. - } else { - set ifnum [string range $ifc 1 end] - } - if { $ifnum == "" } { - return -1 - } - if {![string is integer $ifnum]} { - return -1 - } - return $ifnum -} - -# -# parse the type and length from a TLV header -proc parseTLVHeader { data current_ref } { - global showAPI - set prmsg $showAPI - upvar $current_ref current - - if { [binary scan $data @${current}cc type length] != 2 } { - if { $prmsg == 1 } { puts "TLV header error" } - return "" - } - set length [expr {$length & 0xFF}]; # convert signed to unsigned - if { $length == 0 } { - if { $type == 0 } { - # prevent endless looping - if { $prmsg == 1 } { puts -nonewline "(extra padding)" } - return "" - } else { - # support for length > 255 - incr current 2 - if { [binary scan $data @${current}S length] != 1 } { - puts "error reading TLV length (type=$type)" - return "" - } - set length [expr {$length & 0xFFFF}] - if { $length == 0 } { - # zero-length string, not length > 255 - incr current -2 - } - } - } - incr current 2 - return [list $type $length] -} - -# return the binary string, and length by reference -proc buildStringTLV { type data len_ref } { - upvar $len_ref len - set data_len [string length $data] - if { $data_len > 65536 } { - puts "warning: buildStringTLV data truncated" - set data_len 65536 - set data [string range 0 65535] - } - set data_pad_len [pad_32bit $data_len] - set data_pad [binary format x$data_pad_len] - - if { $data_len == 0 } { - set len 0 - return "" - } - - if { $data_len > 255 } { - set hdr [binary format ccS $type 0 $data_len] - set hdr_len 4 - } else { - set hdr [binary format cc $type $data_len] - set hdr_len 2 - } - - set len [expr {$hdr_len + $data_len + $data_pad_len}] - - return $hdr$data$data_pad -} - -# calculate padding to 32-bit word boundary -# 32-bit and 64-bit values are pre-padded, strings and 128-bit values are -# post-padded to word boundary, depending on type -proc pad_32bit { len } { - # total length = 2 + len + pad - if { $len < 256 } { - set hdrsiz 2 - } else { - set hdrsiz 4 - } - # calculate padding to fill 32-bit boundary - return [expr { -($hdrsiz + $len) % 4 }] -} - -proc macToString { mac_num } { - set mac_bytes "" - # convert 64-bit integer into 12-digit hex string - set mac_num 0x[format "%.12lx" $mac_num] - while { $mac_num > 0 } { - # append 8-bit hex number to list - set uchar [format "%02x" [expr $mac_num & 0xFF]] - lappend mac_bytes $uchar - # shift off 8-bits - set mac_num [expr $mac_num >> 8] - } - - # make sure we have six hex digits - set num_zeroes [expr 6 - [llength $mac_bytes]] - while { $num_zeroes > 0 } { - lappend mac_bytes 00 - incr num_zeroes -1 - } - - # this is lreverse in tcl8.5 and later - set r {} - set i [llength $mac_bytes] - while { $i > 0 } { lappend r [lindex $mac_bytes [incr i -1]] } - - return [join $r :] -} - -proc hexdump { data } { - # read data as hex - binary scan $data H* hex - # split into pairs of hex digits - regsub -all -- {..} $hex {& } hex - return $hex -} diff --git a/gui/canvas.tcl b/gui/canvas.tcl deleted file mode 100644 index 11c8217b..00000000 --- a/gui/canvas.tcl +++ /dev/null @@ -1,406 +0,0 @@ -# -# Copyright 2005-2008 University of Zagreb, Croatia. -# -# Redistribution and use in source and binary forms, with or without -# modification, are permitted provided that the following conditions -# are met: -# 1. Redistributions of source code must retain the above copyright -# notice, this list of conditions and the following disclaimer. -# 2. Redistributions in binary form must reproduce the above copyright -# notice, this list of conditions and the following disclaimer in the -# documentation and/or other materials provided with the distribution. -# -# THIS SOFTWARE IS PROVIDED BY AUTHOR AND CONTRIBUTORS ``AS IS'' AND -# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE -# ARE DISCLAIMED. IN NO EVENT SHALL AUTHOR OR CONTRIBUTORS BE LIABLE -# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS -# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) -# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY -# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF -# SUCH DAMAGE. -# -# - -#****h* imunes/canvas.tcl -# NAME -# canvas.tcl -- file used for manipultaion with canvases in IMUNES -# FUNCTION -# This module is used to define all the actions used for configuring -# canvases in IMUNES. On each canvas a part of the simulation is presented -# If there is no additional canvas defined, simulation is presented on the -# defalut canvas. -# -#**** - -#****f* canvas.tcl/removeCanvas -# NAME -# removeCanvas -- remove canvas -# SYNOPSIS -# removeCanvas $canvas_id -# FUNCTION -# Removes the canvas from simulation. This function does not change the -# configuration of the nodes, i.e. nodes attached to the removed canvas -# remain attached to the same non existing canvas. -# INPUTS -# * canvas_id -- canvas id -#**** - -proc removeCanvas { canvas } { - global canvas_list $canvas - - set i [lsearch $canvas_list $canvas] - set canvas_list [lreplace $canvas_list $i $i] - set $canvas {} -} - -#****f* canvas.tcl/newCanvas -# NAME -# newCanvas -- craete new canvas -# SYNOPSIS -# set canvas_id [newCanvas $canvas_name] -# FUNCTION -# Creates new canvas. Returns the canvas_id of the new canvas. -# If the canvas_name parameter is empty, the name of the new canvas -# is set to CanvasN, where N represents the canvas_id of the new canvas. -# INPUTS -# * canvas_name -- canvas name -# RESULT -# * canvas_id -- canvas id -#**** - -proc newCanvas { name } { - global canvas_list - - set canvas [newObjectId canvas] - global $canvas - lappend canvas_list $canvas - set $canvas {} - if { $name != "" } { - setCanvasName $canvas $name - } else { - setCanvasName $canvas Canvas[string range $canvas 1 end] - } - - return $canvas -} - - -proc setCanvasSize { canvas x y } { - global $canvas - - set i [lsearch [set $canvas] "size *"] - if { $i >= 0 } { - set $canvas [lreplace [set $canvas] $i $i "size {$x $y}"] - } else { - set $canvas [linsert [set $canvas] 1 "size {$x $y}"] - } -} - -proc getCanvasSize { canvas } { - global $canvas g_prefs - - set entry [lrange [lsearch -inline [set $canvas] "size *"] 1 end] - set size [string trim $entry \{\}] - if { $size == "" } { - return "$g_prefs(gui_canvas_x) $g_prefs(gui_canvas_y)" - } else { - return $size - } -} - -#****f* canvas.tcl/getCanvasName -# NAME -# getCanvasName -- get canvas name -# SYNOPSIS -# set canvas_name [getCanvasName $canvas_id] -# FUNCTION -# Returns the name of the canvas. -# INPUTS -# * canvas_id -- canvas id -# RESULT -# * canvas_name -- canvas name -#**** - -proc getCanvasName { canvas } { - global $canvas - - set entry [lrange [lsearch -inline [set $canvas] "name *"] 1 end] - return [string trim $entry \{\}] -} - -#****f* canvas.tcl/setCanvasName -# NAME -# setCanvasName -- set canvas name -# SYNOPSIS -# setCanvasName $canvas_id $canvas_name -# FUNCTION -# Sets the name of the canvas. -# INPUTS -# * canvas_id -- canvas id -# * canvas_name -- canvas name -#**** - -proc setCanvasName { canvas name } { - global $canvas - - set i [lsearch [set $canvas] "name *"] - if { $i >= 0 } { - set $canvas [lreplace [set $canvas] $i $i "name {$name}"] - } else { - set $canvas [linsert [set $canvas] 1 "name {$name}"] - } -} - -# Boeing: canvas wallpaper support -proc getCanvasWallpaper { canvas } { - global $canvas - - set entry [lrange [lsearch -inline [set $canvas] "wallpaper *"] 1 end] - set entry2 [lrange [lsearch -inline \ - [set $canvas] "wallpaper-style *"] 1 end] - return [list [string trim $entry \{\}] [string trim $entry2 \{\}]] -} - -proc setCanvasWallpaper { canvas file style} { - global $canvas - - set i [lsearch [set $canvas] "wallpaper *"] - if { $i >= 0 } { - set $canvas [lreplace [set $canvas] $i $i "wallpaper {$file}"] - } else { - set $canvas [linsert [set $canvas] 1 "wallpaper {$file}"] - } - - set i [lsearch [set $canvas] "wallpaper-style *"] - if { $i >= 0 } { - set $canvas [lreplace [set $canvas] $i $i "wallpaper-style {$style}"] - } else { - set $canvas [linsert [set $canvas] 1 "wallpaper-style {$style}"] - } -} - -# Boeing: manage canvases -proc manageCanvasPopup { x y } { - global curcanvas CORE_DATA_DIR - - set w .entry1 - catch {destroy $w} - toplevel $w -takefocus 1 - - if { $x == 0 && $y == 0 } { - set screen [wm maxsize .] - set x [expr {[lindex $screen 0] / 4}] - set y [expr {[lindex $screen 1] / 4}] - } else { - set x [expr {$x + 10}] - set y [expr {$y - 250}] - } - wm geometry $w +$x+$y - wm title $w "Manage Canvases" - wm iconname $w "Manage Canvases" - - - ttk::frame $w.name - ttk::label $w.name.lab -text "Canvas name:" - ttk::entry $w.name.ent - $w.name.ent insert 0 [getCanvasName $curcanvas] - pack $w.name.lab $w.name.ent -side left -fill x - pack $w.name -side top -padx 4 -pady 4 - - global canvas_list - ttk::frame $w.canv - listbox $w.canv.cl -bg white -yscrollcommand "$w.canv.scroll set" - ttk::scrollbar $w.canv.scroll -orient vertical -command "$w.canv.cl yview" - foreach canvas $canvas_list { - $w.canv.cl insert end [getCanvasName $canvas] - if { $canvas == $curcanvas } { - set curindex [expr {[$w.canv.cl size] - 1}] - } - } - pack $w.canv.cl -side left -pady 4 -fill both -expand true - pack $w.canv.scroll -side left -fill y - pack $w.canv -side top -fill both -expand true -padx 4 -pady 4 - $w.canv.cl selection set $curindex - $w.canv.cl see $curindex - bind $w.canv.cl "manageCanvasSwitch $w" - - ttk::frame $w.buttons2 - foreach b {up down} { - set fn "$CORE_DATA_DIR/icons/tiny/arrow.${b}.gif" - set img$b [image create photo -file $fn] - ttk::button $w.buttons2.$b -image [set img${b}] \ - -command "manageCanvasUpDown $w $b" - } - pack $w.buttons2.up $w.buttons2.down -side left -expand 1 - pack $w.buttons2 -side top -fill x -pady 2 - - # hidden list of canvas numbers - ttk::label $w.list -text $canvas_list - - ttk::frame $w.buttons - ttk::button $w.buttons.apply -text "Apply" -command "manageCanvasApply $w" - ttk::button $w.buttons.cancel -text "Cancel" -command "destroy $w" - pack $w.buttons.apply $w.buttons.cancel -side left -expand 1 - pack $w.buttons -side bottom -fill x -pady 2m - - bind $w "destroy $w" - bind $w "manageCanvasApply $w" - -} - -# Boeing: manage canvases helper -# called when a canvas in the list is double-clicked -proc manageCanvasSwitch { w } { - global canvas_list curcanvas - set i [$w.canv.cl curselection] - if {$i == ""} { return} - set i [lindex $i 0] - set item [$w.canv.cl get $i] - - foreach canvas $canvas_list { - if {[getCanvasName $canvas] == $item} { - $w.name.ent delete 0 end - $w.name.ent insert 0 $item - set curcanvas $canvas - switchCanvas none - return - } - } -} - -# manage canvases helper -# handle the move up/down buttons for the canvas selection window -proc manageCanvasUpDown { w dir } { - global canvas_list - # get the currently selected item - set i [$w.canv.cl curselection] - if {$i == ""} { return} - set i [lindex $i 0] - set item [$w.canv.cl get $i] - - if {$dir == "down" } { - set max [expr {[llength $canvas_list] - 1}] - if {$i >= $max } { return } - set newi [expr {$i + 1}] - } else { - if {$i <= 0} { return } - set newi [expr {$i - 1}] - } - - # change the position - $w.canv.cl delete $i - $w.canv.cl insert $newi $item - $w.canv.cl selection set $newi - $w.canv.cl see $newi - - # update hidden list of canvas numbers - set new_canvas_list [$w.list cget -text] - set item [lindex $new_canvas_list $i] - set new_canvas_list [lreplace $new_canvas_list $i $i] - set new_canvas_list [linsert $new_canvas_list $newi $item] - $w.list configure -text $new_canvas_list -} - -# manage canvases helper -# called when apply button is pressed - changes the order of the canvases -proc manageCanvasApply { w } { - global canvas_list curcanvas changed - # we calculated this list earlier, making life easier here - set new_canvas_list [$w.list cget -text] - if {$canvas_list != $new_canvas_list} { - set canvas_list $new_canvas_list - } - set newname [$w.name.ent get] - destroy $w - if { $newname != [getCanvasName $curcanvas] } { - set changed 1 - } - setCanvasName $curcanvas $newname - switchCanvas none - updateUndoLog -} - -proc setCanvasScale { canvas scale } { - global $canvas - - set i [lsearch [set $canvas] "scale *"] - if { $i >= 0 } { - set $canvas [lreplace [set $canvas] $i $i "scale $scale"] - } else { - set $canvas [linsert [set $canvas] 1 "scale $scale"] - } -} - -proc getCanvasScale { canvas } { - global $canvas g_prefs - - set entry [lrange [lsearch -inline [set $canvas] "scale *"] 1 end] - set scale [string trim $entry \{\}] - if { $scale == "" } { - if { ![info exists g_prefs(gui_canvas_scale)] } { return 150.0 } - return "$g_prefs(gui_canvas_scale)" - } else { - return $scale - } -} - -proc setCanvasRefPoint { canvas refpt } { - global $canvas - - set i [lsearch [set $canvas] "refpt *"] - if { $i >= 0 } { - set $canvas [lreplace [set $canvas] $i $i "refpt {$refpt}"] - } else { - set $canvas [linsert [set $canvas] 1 "refpt {$refpt}"] - } -} - -proc getCanvasRefPoint { canvas } { - global $canvas g_prefs DEFAULT_REFPT - - set entry [lrange [lsearch -inline [set $canvas] "refpt *"] 1 end] - set altitude [string trim $entry \{\}] - if { $altitude == "" } { - if { ![info exists g_prefs(gui_canvas_refpt)] } { - return $DEFAULT_REFPT - } - return "$g_prefs(gui_canvas_refpt)" - } else { - return $altitude - } -} - -# from http://wiki.tcl.tk/1415 (MAK) -proc canvasSee { hWnd items } { - set box [eval $hWnd bbox $items] - - if {$box == ""} { return } - - if {[string match {} [$hWnd cget -scrollregion]] } { - # People really should set -scrollregion you know... - foreach {x y x1 y1} $box break - - set x [expr round(2.5 * ($x1+$x) / [winfo width $hWnd])] - set y [expr round(2.5 * ($y1+$y) / [winfo height $hWnd])] - - $hWnd xview moveto 0 - $hWnd yview moveto 0 - $hWnd xview scroll $x units - $hWnd yview scroll $y units - } else { - # If -scrollregion is set properly, use this - foreach { x y x1 y1 } $box break - foreach { top btm } [$hWnd yview] break - foreach { left right } [$hWnd xview] break - foreach { p q xmax ymax } [$hWnd cget -scrollregion] break - - set xpos [expr (($x1+$x) / 2.0) / $xmax - ($right-$left) / 2.0] - set ypos [expr (($y1+$y) / 2.0) / $ymax - ($btm-$top) / 2.0] - - $hWnd xview moveto $xpos - $hWnd yview moveto $ypos - } -} diff --git a/gui/cfgparse.tcl b/gui/cfgparse.tcl deleted file mode 100644 index 41f25594..00000000 --- a/gui/cfgparse.tcl +++ /dev/null @@ -1,1147 +0,0 @@ -# -# Copyright 2005-2008 University of Zagreb, Croatia. -# -# Redistribution and use in source and binary forms, with or without -# modification, are permitted provided that the following conditions -# are met: -# 1. Redistributions of source code must retain the above copyright -# notice, this list of conditions and the following disclaimer. -# 2. Redistributions in binary form must reproduce the above copyright -# notice, this list of conditions and the following disclaimer in the -# documentation and/or other materials provided with the distribution. -# -# THIS SOFTWARE IS PROVIDED BY AUTHOR AND CONTRIBUTORS ``AS IS'' AND -# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE -# ARE DISCLAIMED. IN NO EVENT SHALL AUTHOR OR CONTRIBUTORS BE LIABLE -# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS -# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) -# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY -# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF -# SUCH DAMAGE. -# -# This work was supported in part by the Croatian Ministry of Science -# and Technology through the research contract #IP-2003-143. -# - -#****h* imunes/cfgparse.tcl -# NAME -# cfgparse.tcl -- file used for parsing the configuration -# FUNCTION -# This module is used for parsing the configuration, i.e. reading the -# configuration from a file or a string and writing the configuration -# to a file or a string. This module also contains a function for returning -# a new ID for nodes, links and canvases. -#**** - -#****f* nodecfg.tcl/dumpputs -# NAME -# dumpputs -- puts a string to a file or a string configuration -# SYNOPSIS -# dumpputs $method $destination $string -# FUNCTION -# Puts a sting to the file or appends the string configuration (used for -# undo functions), the choice depends on the value of method parameter. -# INPUTS -# * method -- method used. Possiable values are file (if saving the string -# to the file) and string (if appending the string configuration) -# * dest -- destination used. File_id for files, and string name for string -# configuration -# * string -- the string that is inserted to a file or appended to the string -# configuartion -#**** - -proc dumpputs {method dest string} { - switch -exact -- $method { - file { - puts $dest $string - } - string { - global $dest - append $dest "$string -" - } - } -} - -#****f* nodecfg.tcl/dumpCfg -# NAME -# dumpCfg -- puts the current configuraton to a file or a string -# SYNOPSIS -# dumpCfg $method $destination -# FUNCTION -# Writes the working (current) configuration to a file or a string. -# INPUTS -# * method -- used method. Possiable values are file (saving current congif -# to the file) and string (saving current config in a string) -# * dest -- destination used. File_id for files, and string name for string -# configurations -#**** - -proc dumpCfg {method dest} { - global node_list plot_list link_list canvas_list annotation_list - - global g_comments - if { [info exists g_comments] && $g_comments != "" } { - dumpputs $method $dest "comments \{" - foreach line [split $g_comments "\n"] { dumpputs $method $dest "$line" } - dumpputs $method $dest "\}" - dumpputs $method $dest "" - } - - foreach node $node_list { - global $node - upvar 0 $node lnode - dumpputs $method $dest "node $node \{" - foreach element $lnode { - if { "[lindex $element 0]" == "network-config" } { - dumpputs $method $dest " network-config \{" - foreach line [lindex $element 1] { - dumpputs $method $dest " $line" - } - dumpputs $method $dest " \}" - } elseif { "[lindex $element 0]" == "custom-config" } { - dumpputs $method $dest " custom-config \{" - foreach line [lindex $element 1] { - if { $line != {} } { - if { [catch {set str [lindex $line 0]} err] } { - puts "error loading config: $err" - puts "problem section: [lindex $element 0]" - puts "problem line: $line" - set str "" - } - if { $str == "config" } { - dumpputs $method $dest " config \{" - foreach element [lindex $line 1] { - dumpputs $method $dest " $element" - } - dumpputs $method $dest " \}" - } else { - dumpputs $method $dest " $line" - } - } - } - dumpputs $method $dest " \}" - } elseif { "[lindex $element 0]" == "ipsec-config" } { - dumpputs $method $dest " ipsec-config \{" - foreach line [lindex $element 1] { - if { $line != {} } { - dumpputs $method $dest " $line" - } - } - dumpputs $method $dest " \}" - } elseif { "[lindex $element 0]" == "custom-pre-config-commands" } { - #Boeing custom pre config commands - dumpputs $method $dest " custom-pre-config-commands \{" - foreach line [lindex $element 1] { - dumpputs $method $dest " $line" - } - dumpputs $method $dest " \}" - } elseif { "[lindex $element 0]" == "custom-post-config-commands" } { - #Boeing custom post config commands - dumpputs $method $dest " custom-post-config-commands \{" - foreach line [lindex $element 1] { - dumpputs $method $dest " $line" - } - dumpputs $method $dest " \}" - } elseif { "[lindex $element 0]" == "ine-config" } { - # Boeing: INE config support - dumpputs $method $dest " ine-config \{" - foreach line [lindex $element 1] { - dumpputs $method $dest " $line" - } - dumpputs $method $dest " \}" - # end Boeing - } else { - dumpputs $method $dest " $element" - } - } - dumpputs $method $dest "\}" - dumpputs $method $dest "" - } - - foreach obj "link annotation canvas plot" { - upvar 0 ${obj}_list obj_list - foreach elem $obj_list { - global $elem - upvar 0 $elem lelem - dumpputs $method $dest "$obj $elem \{" - foreach element $lelem { - dumpputs $method $dest " $element" - } - dumpputs $method $dest "\}" - dumpputs $method $dest "" - } - } - - global g_traffic_flows - if { [info exists g_traffic_flows] && [llength $g_traffic_flows] > 0 } { - dumpputs $method $dest "traffic \{" - foreach flow $g_traffic_flows { - dumpputs $method $dest " $flow" - } - dumpputs $method $dest "\}" - dumpputs $method $dest "" - } - - global g_hook_scripts - if { [info exists g_hook_scripts] && [llength $g_hook_scripts] > 0 } { - foreach hook $g_hook_scripts { - set name [lindex $hook 0] - set state [lindex $hook 1] - set script [lindex $hook 2] - dumpputs $method $dest "hook $state:$name \{" - # remove the final newline here because dumpputs adds a - # newline automatically - if {[string index $script end] == "\n"} { - set script [string replace $script end end] - } - dumpputs $method $dest $script - dumpputs $method $dest "\}" - dumpputs $method $dest "" - } - } - - dumpGlobalOptions $method $dest - - # session options - dumpputs $method $dest "option session \{" - foreach kv [getSessionOptionsList] { dumpputs $method $dest " $kv" } - dumpputs $method $dest "\}" - dumpputs $method $dest "" -} - -proc dumpGlobalOptions { method dest } { - global showIfNames showNodeLabels showLinkLabels - global showIfIPaddrs showIfIPv6addrs - global showBkgImage showGrid showAnnotations - global showAPI - global g_view_locked - global g_traffic_start_opt - global mac_addr_start - - dumpputs $method $dest "option global \{" - if {$showIfNames == 0} { - dumpputs $method $dest " interface_names no" - } else { - dumpputs $method $dest " interface_names yes" } - if {$showIfIPaddrs == 0} { - dumpputs $method $dest " ip_addresses no" - } else { - dumpputs $method $dest " ip_addresses yes" } - if {$showIfIPv6addrs == 0} { - dumpputs $method $dest " ipv6_addresses no" - } else { - dumpputs $method $dest " ipv6_addresses yes" } - if {$showNodeLabels == 0} { - dumpputs $method $dest " node_labels no" - } else { - dumpputs $method $dest " node_labels yes" } - if {$showLinkLabels == 0} { - dumpputs $method $dest " link_labels no" - } else { - dumpputs $method $dest " link_labels yes" } - if {$showAPI == 0} { - dumpputs $method $dest " show_api no" - } else { - dumpputs $method $dest " show_api yes" } - if {$showBkgImage == 0} { - dumpputs $method $dest " background_images no" - } else { - dumpputs $method $dest " background_images yes" } - if {$showAnnotations == 0} { - dumpputs $method $dest " annotations no" - } else { - dumpputs $method $dest " annotations yes" } - if {$showGrid == 0} { - dumpputs $method $dest " grid no" - } else { - dumpputs $method $dest " grid yes" } - if {$g_view_locked == 1} { - dumpputs $method $dest " locked yes" } - if { [info exists g_traffic_start_opt] } { - dumpputs $method $dest " traffic_start $g_traffic_start_opt" - } - if { [info exists mac_addr_start] && $mac_addr_start > 0 } { - dumpputs $method $dest " mac_address_start $mac_addr_start" - } - dumpputs $method $dest "\}" - dumpputs $method $dest "" -} - -# get the global options into a list of key=value pairs -proc getGlobalOptionList {} { - global tmp - set tmp "" - dumpGlobalOptions string tmp ;# put "options global {items}" into tmp - set items [lindex $tmp 2] - return [listToKeyValues $items] -} - -proc setGlobalOption { field value } { - global showIfNames showNodeLabels showLinkLabels - global showIfIPaddrs showIfIPv6addrs - global showBkgImage showGrid showAnnotations - global showAPI - global mac_addr_start - global g_traffic_start_opt - global g_view_locked - - switch -exact -- $field { - interface_names { - if { $value == "no" } { - set showIfNames 0 - } elseif { $value == "yes" } { - set showIfNames 1 - } - } - ip_addresses { - if { $value == "no" } { - set showIfIPaddrs 0 - } elseif { $value == "yes" } { - set showIfIPaddrs 1 - } - } - ipv6_addresses { - if { $value == "no" } { - set showIfIPv6addrs 0 - } elseif { $value == "yes" } { - set showIfIPv6addrs 1 - } - } - node_labels { - if { $value == "no" } { - set showNodeLabels 0 - } elseif { $value == "yes" } { - set showNodeLabels 1 - } - } - link_labels { - if { $value == "no" } { - set showLinkLabels 0 - } elseif { $value == "yes" } { - set showLinkLabels 1 - } - } - show_api { - if { $value == "no" } { - set showAPI 0 - } elseif { $value == "yes" } { - set showAPI 1 - } - } - background_images { - if { $value == "no" } { - set showBkgImage 0 - } elseif { $value == "yes" } { - set showBkgImage 1 - } - } - annotations { - if { $value == "no" } { - set showAnnotations 0 - } elseif { $value == "yes" } { - set showAnnotations 1 - } - } - grid { - if { $value == "no" } { - set showGrid 0 - } elseif { $value == "yes" } { - set showGrid 1 - } - } - locked { - if { $value == "yes" } { - set g_view_locked 1 - } else { - set g_view_locked 0 - } - } - mac_address_start { - set mac_addr_start $value - } - traffic_start { - set g_traffic_start_opt $value - } - } -} - -# reset global vars when opening a new file -proc cleanupGUIState {} { - global node_list link_list plot_list canvas_list annotation_list - global mac_addr_start g_comments - global g_traffic_flows g_traffic_start_opt g_hook_scripts - global g_view_locked - - set node_list {} - set link_list {} - set annotation_list {} - set plot_list {} - set canvas_list {} - set g_traffic_flows "" - set g_traffic_start_opt 0 - set g_hook_scripts "" - set g_comments "" - set g_view_locked 0 - resetSessionOptions -} - -#****f* nodecfg.tcl/loadCfg -# NAME -# loadCfg -- loads the current configuration. -# SYNOPSIS -# loadCfg $cfg -# FUNCTION -# Loads the configuration written in the cfg string to a current -# configuration. -# INPUTS -# * cfg -- string containing the new working configuration. -#**** - -proc loadCfg { cfg } { - global node_list plot_list link_list canvas_list annotation_list - global g_traffic_flows g_traffic_start_opt g_hook_scripts - global g_view_locked - global g_comments - - # maximum coordinates - set maxX 0 - set maxY 0 - set do_upgrade [upgradeOldConfig cfg] - if { $do_upgrade == "no"} { return } - - # Cleanup first - cleanupGUIState - set class "" - set object "" - foreach entry $cfg { - if {"$class" == ""} { - set class $entry - continue - } elseif {"$object" == ""} { - set object $entry - if {"$class" == "node"} { - lappend node_list $object - } elseif {"$class" == "link"} { - lappend link_list $object - } elseif {"$class" == "canvas"} { - lappend canvas_list $object - } elseif {"$class" == "plot"} { - lappend plot_list $object - } elseif {"$class" == "option"} { - # do nothing - } elseif {"$class" == "traffic"} { ;# save traffic flows - set g_traffic_flows [split [string trim $object] "\n"] - set class ""; set object ""; continue - } elseif {"$class" == "script"} { - # global_script (old config) becomes a runtime hook - set name "runtime_hook.sh" - set script [string trim $object] - lappend g_hook_scripts [list $name 4 $script] ;# 4=RUNTIME_STATE - set class ""; set object ""; continue - } elseif {"$class" == "hook"} { - continue - } elseif {"$class" == "comments"} { - set g_comments [string trim $object] - set class ""; set object ""; continue - } elseif {"$class" == "annotation"} { - lappend annotation_list $object - } else { - puts "configuration parsing error: unknown object class $class" - #exit 1 - } - # create an empty global variable named object for most objects - global $object - set $object {} - continue - } else { - set line [concat $entry] - # uses 'key=value' instead of 'key value' - if { $object == "session" } { - # 'key=value', values with space needs quoting 'key={space val}' - setSessionOptions "" [split $line "\n"] - set class "" - set object "" - continue - } - # extracts "field { value }" elements from line - if { [catch { set tmp [llength $line] } e] } { - puts "*** Error with line ('$e'):\n$line" - puts "*** Line will be skipped. This is a Tcl limitation, " - puts "*** consider using XML or fixing with whitespace." - continue - } - while {[llength $line] >= 2} { - set field [lindex $line 0] - if {"$field" == ""} { - set line [lreplace $line 0 0] - continue - } - - # consume first two list elements from line - set value [lindex $line 1] - set line [lreplace $line 0 1] - - if {"$class" == "node"} { - switch -exact -- $field { - type { - lappend $object "type $value" - } - mirror { - lappend $object "mirror $value" - } - model { - lappend $object "model $value" - } - cpu { - lappend $object "cpu {$value}" - } - interface-peer { - lappend $object "interface-peer {$value}" - } - network-config { - set cfg "" - foreach zline [split $value { -}] { - if { [string index "$zline" 0] == " " } { - set zline [string replace "$zline" 0 0] - } - lappend cfg $zline - } - set cfg [lrange $cfg 1 [expr {[llength $cfg] - 2}]] - lappend $object "network-config {$cfg}" - } - custom-enabled { - lappend $object "custom-enabled $value" - } - custom-command { - lappend $object "custom-command {$value}" - } - custom-config { - set cfg "" - set have_config 0 - set ccfg {} - foreach zline [split $value "\n"] { - if { [string index "$zline" 0] == \ - " " } { - # remove leading tab character - set zline [string replace "$zline" 0 0] - } - - # flag for config lines - if { $zline == "config \{" } { - set have_config 1 - # collect custom config lines into list - } elseif { $have_config == 1 } { - lappend ccfg $zline - # add non-config lines - } else { - lappend cfg $zline - } - } - # chop off last brace in config { } block and add it - if { $have_config } { - set ccfg [lrange $ccfg 0 \ - [expr {[llength $ccfg] - 3}]] - lappend cfg [list config $ccfg] - } - #set cfg [lrange $cfg 1 [expr {[llength $cfg] - 2}]] - lappend $object "custom-config {$cfg}" - } - ipsec-enabled { - lappend $object "ipsec-enabled $value" - } - ipsec-config { - set cfg "" - - foreach zline [split $value { -}] { - if { [string index "$zline" 0] == " " } { - set zline [string replace "$zline" 0 0] - } - lappend cfg $zline - } - set cfg [lrange $cfg 1 [expr {[llength $cfg] - 2}]] - lappend $object "ipsec-config {$cfg}" - } - iconcoords { - checkMaxCoords $value maxX maxY - lappend $object "iconcoords {$value}" - } - labelcoords { - checkMaxCoords $value maxX maxY - lappend $object "labelcoords {$value}" - } - canvas { - lappend $object "canvas $value" - } - hidden { - lappend $object "hidden $value" - } - /* { - set comment "$field $value" - foreach c $line { - lappend comment $c - # consume one element from line - set line [lreplace $line 0 0] - if { $c == "*/" } { break } - } - lappend $object "$comment" - } - - custom-pre-config-commands { - # Boeing - custom pre config commands - set cfg "" - foreach zline [split $value { -}] { - if { [string index "$zline" 0] == " " } { - set zline [string replace "$zline" 0 0] - } - lappend cfg $zline - } - set cfg [lrange $cfg 1 [expr [llength $cfg] - 2]] - lappend $object "custom-pre-config-commands {$cfg}" - } - custom-post-config-commands { - # Boeing - custom post config commands - set cfg "" - foreach zline [split $value { -}] { - if { [string index "$zline" 0] == " " } { - set zline [string replace "$zline" 0 0] - } - lappend cfg $zline - } - set cfg [lrange $cfg 1 [expr [llength $cfg] - 2]] - lappend $object "custom-post-config-commands {$cfg}" - } - custom-image { - # Boeing - custom-image - lappend $object "custom-image $value" - } - ine-config { - # Boeing - INE - set cfg "" - foreach zline [split $value { -}] { - if { [string index "$zline" 0] == " " } { - set zline [string replace "$zline" 0 0] - } - lappend cfg $zline - } - set cfg [lrange $cfg 1 [expr [llength $cfg] - 2]] - lappend $object "ine-config {$cfg}" - } - tunnel-peer { - # Boeing - Span tunnels - lappend $object "tunnel-peer {$value}" - } - range { - # Boeing - WLAN range - lappend $object "range $value" - } - bandwidth { - # Boeing - WLAN bandwidth - lappend $object "bandwidth $value" - } - cli-enabled { - puts "Warning: cli-enabled setting is deprecated" - } - delay { - # Boeing - WLAN delay - lappend $object "delay $value" - } - ber { - # Boeing - WLAN BER - lappend $object "ber $value" - } - location { - # Boeing - node location - lappend $object "location $value" - } - os { - # Boeing - node OS - # just ignore it, set at runtime - } - services { - lappend $object "services {$value}" - } - - default { - # Boeing - added warning - puts -nonewline "config file warning: unknown confi" - puts "guration item '$field' ignored for $object" - } - } - } elseif {"$class" == "plot"} { - switch -exact -- $field { - name { - lappend $object "name $value" - } - height { - lappend $object "height $value" - } - width { - lappend $object "width $value" - } - x { - lappend $object "x $value" - } - y { - lappend $object "y $value" - } - color { - lappend $object "color $value" - } - } - } elseif {"$class" == "link"} { - switch -exact -- $field { - nodes { - lappend $object "nodes {$value}" - } - mirror { - lappend $object "mirror $value" - } - bandwidth - - delay - - ber - - duplicate - - jitter { - if { [llength $value] > 1 } { ;# down/up-stream - lappend $object "$field {$value}" - } else { - lappend $object "$field $value" - } - } - color { - lappend $object "color $value" - } - width { - lappend $object "width $value" - } - default { - # this enables opaque data to be stored along with - # each link (any key is stored) - lappend $object "$field $value" - # Boeing - added warning - #puts -nonewline "config file warning: unknown conf" - #puts "iguration item '$field' ignored for $object" - } - } - } elseif {"$class" == "canvas"} { - switch -exact -- $field { - name { - lappend $object "name {$value}" - } - size { - lappend $object "size {$value}" - } - bkgImage { - lappend $object "wallpaper {$value}" - } - wallpaper { - lappend $object "wallpaper {$value}" - } - wallpaper-style { - lappend $object "wallpaper-style {$value}" - } - scale { - lappend $object "scale {$value}" - } - refpt { - lappend $object "refpt {$value}" - } - } - } elseif {"$class" == "option"} { - setGlobalOption $field $value - } elseif {"$class" == "annotation"} { - switch -exact -- $field { - type { - lappend $object "type $value" - } - iconcoords { - lappend $object "iconcoords {$value}" - } - color { - lappend $object "color $value" - } - border { - lappend $object "border $value" - } - label { - lappend $object "label {$value}" - } - labelcolor { - lappend $object "labelcolor $value" - } - size { - lappend $object "size $value" - } - canvas { - lappend $object "canvas $value" - } - font { - lappend $object "font {$value}" - } - fontfamily { - lappend $object "fontfamily {$value}" - } - fontsize { - lappend $object "fontsize {$value}" - } - effects { - lappend $object "effects {$value}" - } - width { - lappend $object "width $value" - } - rad { - lappend $object "rad $value" - } - } ;# end switch - } elseif {"$class" == "hook"} { - set state_name [split $object :] - if { [llength $state_name] != 2 } { - puts "invalid hook in config file" - continue - } - set state [lindex $state_name 0] - set name [lindex $state_name 1] - set lines [split $entry "\n"] - set lines [lreplace $lines 0 0] ;# chop extra newline - set lines [join $lines "\n"] - set hook [list $name $state $lines] - lappend g_hook_scripts $hook - set line "" ;# exit this while loop - } ;#endif class - } - } - set class "" - set object "" - } - - # - # Hack for comaptibility with old format files (no canvases) - # - if { $canvas_list == "" } { - set curcanvas [newCanvas ""] - foreach node $node_list { - setNodeCanvas $node $curcanvas - } - } - - - # auto resize canvas - set curcanvas [lindex $canvas_list 0] - set newX 0 - set newY 0 - if { $maxX > [lindex [getCanvasSize $curcanvas] 0] } { - set newX [expr {$maxX + 50}] - } - if { $maxY > [lindex [getCanvasSize $curcanvas] 1] } { - set newY [expr {$maxY + 50}] - } - if { $newX > 0 || $newY > 0 } { - if { $newX == 0 } { set newX [lindex [getCanvasSize $curcanvas] 0] } - if { $newY == 0 } { set newY [lindex [getCanvasSize $curcanvas] 1] } - setCanvasSize $curcanvas $newX $newY - } - - # extra upgrade steps - if { $do_upgrade == "yes" } { - upgradeNetworkConfigToServices - } - upgradeConfigRemoveNode0 - upgradeConfigServices - upgradeWlanConfigs -} - -#****f* nodecfg.tcl/newObjectId -# NAME -# newObjectId -- new object Id -# SYNOPSIS -# set obj_id [newObjectId $type] -# FUNCTION -# Returns the Id for a new object of the defined type. Supported types -# are node, link and canvas. The Id is in the form $mark$number. $mark is the -# first letter of the given type and $number is the first available number to -# that can be used for id. -# INPUTS -# * type -- the type of the new object. Can be node, link or canvas. -# RESULT -# * obj_id -- object Id in the form $mark$number. $mark is the -# first letter of the given type and $number is the first available number to -# that can be used for id. -#**** - -proc newObjectId { type } { - global node_list link_list annotation_list canvas_list - - set mark [string range [set type] 0 0] - set id 1 ;# start numbering at 1, not 0 - while {[lsearch [set [set type]_list] "$mark$id"] != -1} { - incr id - } - return $mark$id -} - - - -# Boeing: pick a new link id for temporary newlinks -proc newlinkId { } { - global link_list - set id [newObjectId link] - set mark "l" - set id 0 - - # alllinks contains a list of all existing and new links - set alllinks $link_list - foreach newlink [.c find withtag "newlink"] { - set newlinkname [lindex [.c gettags $newlink] 1] - lappend alllinks $newlinkname - } - - while {[lsearch $alllinks "$mark$id"] != -1 } { - incr id - } - return $mark$id -} - -# Boeing: helper fn to determine canvas size during load -proc checkMaxCoords { str maxXp maxYp } { - upvar 1 $maxXp maxX - upvar 1 $maxYp maxY - set x [lindex $str 0] - set y [lindex $str 1] - if { $x > $maxX } { - set maxX $x - } - if { $y > $maxY } { - set maxY $y - } - if { [llength $str] == 4 } { - set x [lindex $str 2] - set y [lindex $str 3] - if { $x > $maxX } { - set maxX $x - } - if { $y > $maxY } { - set maxY $y - } - } -} - -# Boeing: pick a router for OSPF -proc newRouterId { type node } { - set mark [string range [set type] 0 0] - for { set id 0 } { $node != "$mark$id" } { incr id } { - } - return "0.0.0.${id}" -} -# end Boeing - -# Boeing: load servers.conf file into exec_servers array -proc loadServersConf { } { - global CONFDIR exec_servers DEFAULT_API_PORT - set confname "$CONFDIR/servers.conf" - if { [catch { set f [open "$confname" r] } ] } { - puts "Creating a default $confname" - if { [catch { set f [open "$confname" w+] } ] } { - puts "***Warning: could not create a default $confname file." - return - } - puts $f "core1 192.168.0.2 $DEFAULT_API_PORT" - puts $f "core2 192.168.0.3 $DEFAULT_API_PORT" - close $f - if { [catch { set f [open "$confname" r] } ] } { - return - } - } - - array unset exec_servers - - while { [ gets $f line ] >= 0 } { - if { [string range $line 0 0] == "#" } { continue } ;# skip comments - set l [split $line] ;# parse fields separated by whitespace - set name [lindex $l 0] - set ip [lindex $l 1] - set port [lindex $l 2] - set sock -1 - if { $name == "" } { continue } ;# blank name - # load array of servers - array set exec_servers [list $name [list $ip $port $sock]] - } - close $f -} -# end Boeing - -# Boeing: write servers.conf file from exec_servers array -proc writeServersConf { } { - global CONFDIR exec_servers - set confname "$CONFDIR/servers.conf" - if { [catch { set f [open "$confname" w] } ] } { - puts "***Warning: could not write servers file: $confname" - return - } - - set header "# servers.conf: list of CORE emulation servers for running" - set header "$header remotely." - puts $f $header - foreach server [lsort -dictionary [array names exec_servers]] { - set ip [lindex $exec_servers($server) 0] - set port [lindex $exec_servers($server) 1] - puts $f "$server $ip $port" - } - close $f -} -# end Boeing - -# display the preferences dialog -proc popupPrefs {} { - global EDITORS TERMS - - set wi .core_prefs - catch { destroy $wi } - toplevel $wi - - wm transient $wi . - wm resizable $wi 0 0 - wm title $wi "Preferences" - - global g_prefs g_prefs_old - array set g_prefs_old [array get g_prefs] - - # - # Paths - # - labelframe $wi.dirs -borderwidth 4 -text "Paths" -relief raised - frame $wi.dirs.conf - label $wi.dirs.conf.label -text "Default configuration file path:" - entry $wi.dirs.conf.entry -bg white -width 40 \ - -textvariable g_prefs(default_conf_path) - pack $wi.dirs.conf.label $wi.dirs.conf.entry -side left - pack $wi.dirs.conf -side top -anchor w -padx 4 -pady 4 - - frame $wi.dirs.mru - label $wi.dirs.mru.label -text "Number of recent files to remember:" - entry $wi.dirs.mru.num -bg white -width 3 \ - -textvariable g_prefs(num_recent) - button $wi.dirs.mru.clear -text "Clear recent files" \ - -command "addFileToMrulist \"\"" - pack $wi.dirs.mru.label $wi.dirs.mru.num $wi.dirs.mru.clear -side left - pack $wi.dirs.mru -side top -anchor w -padx 4 -pady 4 - - pack $wi.dirs -side top -fill x - - # - # Window - # - labelframe $wi.win -borderwidth 4 -text "GUI Window" -relief raised - frame $wi.win.win - checkbutton $wi.win.win.savepos -text "remember window position" \ - -variable g_prefs(gui_save_pos) - checkbutton $wi.win.win.savesiz -text "remember window size" \ - -variable g_prefs(gui_save_size) - pack $wi.win.win.savepos $wi.win.win.savesiz -side left -anchor w -padx 4 - pack $wi.win.win -side top -anchor w -padx 4 -pady 4 - - frame $wi.win.a - checkbutton $wi.win.a.snaptogrid -text "snap to grid" \ - -variable g_prefs(gui_snap_grid) - checkbutton $wi.win.a.showtooltips -text "show tooltips" \ - -variable g_prefs(gui_show_tooltips) - pack $wi.win.a.snaptogrid $wi.win.a.showtooltips \ - -side left -anchor w -padx 4 - pack $wi.win.a -side top -anchor w -padx 4 -pady 4 - - frame $wi.win.canv - label $wi.win.canv.label -text "Default canvas size:" - entry $wi.win.canv.x -bg white -width 5 -textvariable g_prefs(gui_canvas_x) - entry $wi.win.canv.y -bg white -width 5 -textvariable g_prefs(gui_canvas_y) - label $wi.win.canv.label2 -text "Default # of canvases:" - entry $wi.win.canv.num -bg white -width 5 \ - -textvariable g_prefs(gui_num_canvases) - pack $wi.win.canv.label $wi.win.canv.x $wi.win.canv.y \ - $wi.win.canv.label2 $wi.win.canv.num \ - -side left -anchor w -padx 4 - pack $wi.win.canv -side top -anchor w -padx 4 -pady 4 - pack $wi.win -side top -fill x - - # - # Programs - # - labelframe $wi.pr -borderwidth 4 -text "Programs" -relief raised - - frame $wi.pr.editor - label $wi.pr.editor.label -text "Text editor:" - set editors [linsert $EDITORS 0 "EDITOR"] - ttk::combobox $wi.pr.editor.combo -width 10 -exportselection 0 \ - -values $editors -textvariable g_prefs(gui_text_editor) - label $wi.pr.editor.label2 -text "Terminal program:" - set terms [linsert $TERMS 0 "TERM"] - ttk::combobox $wi.pr.editor.combo2 -width 20 -exportselection 0 \ - -values $terms -textvariable g_prefs(gui_term_prog) - pack $wi.pr.editor.label $wi.pr.editor.combo -padx 4 -pady 4 -side left - pack $wi.pr.editor.label2 $wi.pr.editor.combo2 -padx 4 -pady 4 -side left - pack $wi.pr.editor -side top -anchor w -padx 4 -pady 4 - - frame $wi.pr.3d - label $wi.pr.3d.label -text "3D GUI command:" - entry $wi.pr.3d.entry -bg white -width 40 -textvariable g_prefs(gui_3d_path) - pack $wi.pr.3d.label $wi.pr.3d.entry -side left -padx 4 -pady 4 - pack $wi.pr.3d -side top -anchor w -padx 4 -pady 4 - - pack $wi.pr -side top -fill x - - # - # Buttons at the bottom - # - frame $wi.bot -borderwidth 0 - button $wi.bot.apply -text "Save" -command "savePrefsFile; destroy $wi" - button $wi.bot.defaults -text "Load defaults" -command initDefaultPrefs - button $wi.bot.cancel -text "Cancel" -command { - global g_prefs g_prefs_old - array set g_prefs [array get g_prefs_old] - destroy .core_prefs - } - pack $wi.bot.cancel $wi.bot.defaults $wi.bot.apply -side right - pack $wi.bot -side bottom -fill x - after 100 { - catch { grab .core_prefs } - } -} - -# initialize preferences array with default values -proc initDefaultPrefs {} { - global g_prefs CONFDIR SBINDIR DEFAULT_REFPT tcl_platform - - # variable expansions must be done here - array set g_prefs [list default_conf_path "$CONFDIR/configs"] - array set g_prefs [list gui_canvas_refpt "$DEFAULT_REFPT"] - set shell "bash" - array set g_prefs [list shell $shell] - array set g_prefs [list gui_text_editor [get_text_editor true]] - array set g_prefs [list gui_term_prog [get_term_prog true]] - setDefaultAddrs ipv4 - setDefaultAddrs ipv6 - # preferences will be reordered alphabetically - array set g_prefs { - num_recent 4 - log_path "/tmp/core_logs" - gui_save_pos 0 - gui_save_size 0 - gui_snap_grid 0 - gui_show_tooltips 1 - gui_canvas_x 1000 - gui_canvas_y 750 - gui_canvas_scale 150.0 - gui_num_canvases 1 - gui_3d_path "/usr/local/bin/sdt3d.sh" - } - # add new preferences above; keep this at the end of the file -} - - diff --git a/gui/configs/sample1-bg.gif b/gui/configs/sample1-bg.gif deleted file mode 100644 index 98344744..00000000 Binary files a/gui/configs/sample1-bg.gif and /dev/null differ diff --git a/gui/configs/sample1.imn b/gui/configs/sample1.imn deleted file mode 100644 index da646f1d..00000000 --- a/gui/configs/sample1.imn +++ /dev/null @@ -1,462 +0,0 @@ -node n1 { - type router - model router - network-config { - hostname n1 - ! - interface eth1 - ip address 10.0.5.1/24 - ipv6 address a:5::1/64 - ! - interface eth0 - ip address 10.0.3.2/24 - ipv6 address a:3::2/64 - ! - } - canvas c1 - iconcoords {384.0 456.0} - labelcoords {384.0 484.0} - interface-peer {eth0 n2} - interface-peer {eth1 n15} -} - -node n2 { - type router - model router - network-config { - hostname n2 - ! - interface eth2 - ip address 10.0.4.1/24 - ipv6 address a:4::1/64 - ! - interface eth1 - ip address 10.0.3.1/24 - ipv6 address a:3::1/64 - ! - interface eth0 - ip address 10.0.2.2/24 - ipv6 address a:2::2/64 - ! - } - canvas c1 - iconcoords {264.0 432.0} - labelcoords {264.0 460.0} - interface-peer {eth0 n3} - interface-peer {eth1 n1} - interface-peer {eth2 n15} -} - -node n3 { - type router - model router - network-config { - hostname n3 - ! - interface eth1 - ip address 10.0.2.1/24 - ipv6 address a:2::1/64 - ! - interface eth0 - ip address 10.0.1.1/24 - ipv6 address a:1::1/64 - ! - } - canvas c1 - iconcoords {120.0 360.0} - labelcoords {120.0 388.0} - interface-peer {eth0 n4} - interface-peer {eth1 n2} -} - -node n4 { - type lanswitch - network-config { - hostname n4 - ! - } - canvas c1 - iconcoords {192.0 252.0} - labelcoords {192.0 280.0} - interface-peer {e0 n3} - interface-peer {e1 n11} - interface-peer {e2 n12} - interface-peer {e3 n13} - interface-peer {e4 n14} -} - -node n5 { - type router - model mdr - network-config { - hostname n5 - ! - interface eth0 - ipv6 address a:0::3/128 - ip address 10.0.0.5/32 - ! - interface eth1 - ip address 10.0.6.2/24 - ipv6 address a:6::2/64 - ! - } - canvas c1 - iconcoords {540.0 348.0} - labelcoords {540.0 376.0} - interface-peer {eth0 n10} - interface-peer {eth1 n15} - services {zebra OSPFv2 OSPFv3MDR IPForward} -} - -node n6 { - type router - model mdr - network-config { - hostname n6 - ! - interface eth0 - ip address 10.0.0.6/32 - ipv6 address a:0::6/128 - ! - } - canvas c1 - iconcoords {780.0 228.0} - labelcoords {780.0 252.0} - interface-peer {eth0 n10} -} - -node n7 { - type router - model mdr - network-config { - hostname n7 - ! - interface eth0 - ip address 10.0.0.7/32 - ipv6 address a:0::7/128 - ! - } - canvas c1 - iconcoords {816.0 348.0} - labelcoords {816.0 372.0} - interface-peer {eth0 n10} -} - -node n8 { - type router - model mdr - network-config { - hostname n8 - ! - interface eth0 - ip address 10.0.0.8/32 - ipv6 address a:0::8/128 - ! - } - canvas c1 - iconcoords {672.0 420.0} - labelcoords {672.0 444.0} - interface-peer {eth0 n10} -} - -node n9 { - type router - model mdr - network-config { - hostname n9 - ! - interface eth0 - ip address 10.0.0.9/32 - ipv6 address a:0::9/128 - ! - } - canvas c1 - iconcoords {672.0 96.0} - labelcoords {672.0 120.0} - interface-peer {eth0 n10} -} - -node n10 { - type wlan - network-config { - hostname wlan10 - ! - interface wireless - ip address 10.0.0.0/32 - ipv6 address a:0::0/128 - ! - mobmodel - coreapi - basic_range - ns2script - ! - } - canvas c1 - iconcoords {852.0 564.0} - labelcoords {852.0 596.0} - interface-peer {e0 n8} - interface-peer {e1 n7} - interface-peer {e2 n5} - interface-peer {e3 n6} - interface-peer {e4 n9} - custom-config { - custom-config-id basic_range - custom-command {3 3 9 9 9} - config { - range=240 - bandwidth=54000000 - jitter=0 - delay=50000 - error=0 - } - } - custom-config { - custom-config-id ns2script - custom-command {10 3 11 10 10} - config { - file=sample1.scen - refresh_ms=50 - loop=1 - autostart=5 - map= - } - } -} - -node n11 { - type router - model PC - network-config { - hostname n11 - ! - interface eth0 - ip address 10.0.1.20/24 - ipv6 address a:1::20/64 - ! - } - canvas c1 - iconcoords {192.0 156.0} - labelcoords {192.0 188.0} - interface-peer {eth0 n4} -} - -node n12 { - type router - model PC - network-config { - hostname n12 - ! - interface eth0 - ip address 10.0.1.21/24 - ipv6 address a:1::21/64 - ! - } - canvas c1 - iconcoords {264.0 156.0} - labelcoords {264.0 188.0} - interface-peer {eth0 n4} -} - -node n13 { - type router - model PC - network-config { - hostname n13 - ! - interface eth0 - ip address 10.0.1.22/24 - ipv6 address a:1::22/64 - ! - } - canvas c1 - iconcoords {336.0 156.0} - labelcoords {336.0 188.0} - interface-peer {eth0 n4} -} - -node n14 { - type router - model host - network-config { - hostname n14 - ! - interface eth0 - ip address 10.0.1.10/24 - ipv6 address a:1::10/64 - ! - } - canvas c1 - iconcoords {348.0 228.0} - labelcoords {348.0 260.0} - interface-peer {eth0 n4} -} - -node n15 { - type router - model router - network-config { - hostname n15 - ! - interface eth2 - ip address 10.0.6.1/24 - ipv6 address a:6::1/64 - ! - interface eth1 - ip address 10.0.5.2/24 - ipv6 address a:5::2/64 - ! - interface eth0 - ip address 10.0.4.2/24 - ipv6 address a:4::2/64 - ! - } - canvas c1 - iconcoords {384.0 312.0} - labelcoords {384.0 340.0} - interface-peer {eth0 n2} - interface-peer {eth1 n1} - interface-peer {eth2 n5} -} - -link l1 { - nodes {n10 n8} - bandwidth 11000000 - delay 25000 -} - -link l0 { - nodes {n10 n7} - bandwidth 11000000 - delay 25000 -} - -link l2 { - nodes {n10 n5} - bandwidth 11000000 - delay 25000 -} - -link l3 { - nodes {n10 n6} - bandwidth 11000000 - delay 25000 -} - -link l4 { - nodes {n10 n9} - bandwidth 11000000 - delay 25000 -} - -link l5 { - nodes {n3 n4} - bandwidth 100000000 -} - -link l6 { - delay 25000 - nodes {n3 n2} - bandwidth 100000000 -} - -link l7 { - nodes {n2 n1} - bandwidth 100000000 -} - -link l8 { - delay 50000 - nodes {n2 n15} - bandwidth 100000000 -} - -link l9 { - nodes {n1 n15} - bandwidth 100000000 -} - -link l10 { - nodes {n15 n5} - bandwidth 100000000 -} - -link l11 { - nodes {n4 n11} - bandwidth 100000000 -} - -link l12 { - nodes {n4 n12} - bandwidth 100000000 -} - -link l13 { - nodes {n4 n13} - bandwidth 100000000 -} - -link l14 { - nodes {n4 n14} - bandwidth 100000000 -} - -annotation a0 { - iconcoords {612.0 492.0} - type text - label {wireless network} - labelcolor black - fontfamily {Arial} - fontsize {12} - effects {bold} - canvas c1 -} - -annotation a1 { - iconcoords {142.0 112.0 393.0 291.0} - type rectangle - label {} - labelcolor black - fontfamily {Arial} - fontsize {12} - color #ebebde - width 1 - border #ffffff - rad 25 - canvas c1 -} - -annotation a2 { - iconcoords {492.0 384.0} - type text - label {gateway} - labelcolor black - fontfamily {Arial} - fontsize {12} - effects {bold} - canvas c1 -} - -canvas c1 { - name {Canvas1} - wallpaper-style {upperleft} - wallpaper {sample1-bg.gif} -} - -option global { - interface_names no - ip_addresses yes - ipv6_addresses no - node_labels yes - link_labels yes - ipsec_configs yes - exec_errors no - show_api no - background_images no - annotations yes - grid no - traffic_start 0 -} - -option session { -} - diff --git a/gui/configs/sample1.scen b/gui/configs/sample1.scen deleted file mode 100644 index c2fc5a44..00000000 --- a/gui/configs/sample1.scen +++ /dev/null @@ -1,28 +0,0 @@ -# -# nodes: 4, max time: 27.000000, max x: 600.00, max y: 600.00 -# nominal range: 300.00 link bw: 54000000.00 -# pause: 30.00, min speed 1.50 max speed: 4.50 - -$node_(6) set X_ 780.0 -$node_(6) set Y_ 228.0 -$node_(6) set Z_ 0.00 -$node_(7) set X_ 816.0 -$node_(7) set Y_ 348.0 -$node_(7) set Z_ 0.00 -$node_(8) set X_ 672.0 -$node_(8) set Y_ 420.0 -$node_(8) set Z_ 0.00 -$node_(9) set X_ 672.0 -$node_(9) set Y_ 96.0 -$node_(9) set Z_ 0.00 -$ns_ at 1.00 "$node_(6) setdest 500.0 178.0 25.0" -$ns_ at 2.00 "$node_(7) setdest 400.0 288.0 15.0" -$ns_ at 1.00 "$node_(8) setdest 590.0 520.0 17.0" -$ns_ at 3.00 "$node_(9) setdest 720.0 300.0 20.0" -$ns_ at 8.00 "$node_(7) setdest 600.0 350.0 10.0" -$ns_ at 9.00 "$node_(8) setdest 730.0 300.0 15.0" -$ns_ at 10.00 "$node_(6) setdest 600.0 108.0 10.0" -$ns_ at 16.00 "$node_(9) setdest 672.0 96.0 20.0" -$ns_ at 17.00 "$node_(7) setdest 816.0 348.0 20.0" -$ns_ at 18.00 "$node_(6) setdest 780.0 228.0 25.0" -$ns_ at 22.00 "$node_(8) setdest 672.0 420.0 20.0" diff --git a/gui/configs/sample10-kitchen-sink.imn b/gui/configs/sample10-kitchen-sink.imn deleted file mode 100644 index dacee547..00000000 --- a/gui/configs/sample10-kitchen-sink.imn +++ /dev/null @@ -1,848 +0,0 @@ -comments { -Kitchen Sink -============ - -Contains every type of node available in CORE, except for physical (prouter) -machine types, and nodes distributed on other emulation servers. - -To get the RJ45 node to work, a test0 interface should first be created like this: - sudo ip link add name test0 type veth peer name test0.1 - -wlan15 uses the basic range model, while wlan24 uses EMANE 802.11 - -gateway nodes n11 and n20 are customized to redistribute routing between OSPFv2 and -OSPFv3 MDR (the MANET networks) -} - -node n1 { - type router - model router - network-config { - hostname n1 - ! - interface eth2 - ip address 10.0.11.2/24 - ipv6 address 2001:11::2/64 - ! - interface eth1 - ip address 10.0.3.1/24 - ipv6 address 2001:3::1/64 - ! - interface eth0 - ip address 10.0.2.1/24 - ipv6 address 2001:2::1/64 - ! - } - canvas c1 - iconcoords {288.0 264.0} - labelcoords {288.0 292.0} - interface-peer {eth0 n3} - interface-peer {eth1 n2} - interface-peer {eth2 n20} - custom-image $CORE_DATA_DIR/icons/normal/router_red.gif -} - -node n2 { - type router - model router - network-config { - hostname n2 - ! - interface eth2 - ip address 10.0.5.2/24 - ipv6 address 2001:5::2/64 - ! - interface eth1 - ip address 10.0.3.2/24 - ipv6 address 2001:3::2/64 - ! - interface eth0 - ip address 10.0.0.1/24 - ipv6 address 2001:0::1/64 - ! - } - canvas c1 - iconcoords {576.0 264.0} - labelcoords {576.0 292.0} - interface-peer {eth0 n5} - interface-peer {eth1 n1} - interface-peer {eth2 n19} -} - -node n3 { - type router - model router - network-config { - hostname n3 - ! - interface eth3 - ip address 10.0.9.1/24 - ipv6 address 2001:9::1/64 - ! - interface eth2 - ip address 10.0.4.1/24 - ipv6 address 2001:4::1/64 - ! - interface eth1 - ip address 10.0.2.2/24 - ipv6 address 2001:2::2/64 - ! - interface eth0 - ip address 10.0.1.1/24 - ipv6 address 2001:1::1/64 - ! - } - canvas c1 - iconcoords {288.0 408.0} - labelcoords {288.0 436.0} - interface-peer {eth0 n4} - interface-peer {eth1 n1} - interface-peer {eth2 n19} - interface-peer {eth3 n11} - custom-image $CORE_DATA_DIR/icons/normal/router_red.gif -} - -node n4 { - type hub - network-config { - hostname n4 - ! - } - canvas c1 - iconcoords {216.0 528.0} - labelcoords {216.0 552.0} - interface-peer {e0 n3} - interface-peer {e1 n16} - interface-peer {e2 n17} - interface-peer {e3 n18} -} - -node n5 { - type lanswitch - network-config { - hostname n5 - ! - } - canvas c1 - iconcoords {672.0 264.0} - labelcoords {672.0 288.0} - interface-peer {e0 n2} - interface-peer {e1 n6} - interface-peer {e2 n7} - interface-peer {e3 n8} - interface-peer {e4 n25} -} - -node n6 { - type router - model host - network-config { - hostname n6 - ! - interface eth0 - ip address 10.0.0.10/24 - ipv6 address 2001:0::10/64 - ! - } - canvas c1 - iconcoords {792.0 216.0} - labelcoords {792.0 248.0} - interface-peer {eth0 n5} -} - -node n7 { - type router - model host - network-config { - hostname n7 - ! - interface eth0 - ip address 10.0.0.11/24 - ipv6 address 2001:0::11/64 - ! - } - canvas c1 - iconcoords {792.0 288.0} - labelcoords {792.0 320.0} - interface-peer {eth0 n5} -} - -node n8 { - type router - model host - network-config { - hostname n8 - ! - interface eth0 - ip address 10.0.0.12/24 - ipv6 address 2001:0::12/64 - ! - } - canvas c1 - iconcoords {792.0 360.0} - labelcoords {792.0 392.0} - interface-peer {eth0 n5} -} - -node n9 { - type rj45 - network-config { - hostname test0 - ! - } - canvas c1 - iconcoords {576.0 528.0} - labelcoords {576.0 556.0} - interface-peer {0 n19} -} - -node n10 { - type tunnel - network-config { - hostname 10.250.0.91 - ! - interface e0 - ip address 10.250.0.91/24 - ! - tunnel-type - UDP - ! - tunnel-tap - off - ! - tunnel-key - 1 - ! - } - canvas c1 - iconcoords {672.0 504.0} - labelcoords {672.0 536.0} - interface-peer {e0 n19} -} - -node n11 { - type router - model mdr - network-config { - hostname n11 - ! - interface eth1 - ip address 10.0.9.2/24 - ipv6 address 2001:9::2/64 - ! - interface eth0 - ip address 10.0.8.1/32 - ipv6 address 2001:8::1/128 - ! - } - canvas c1 - iconcoords {288.0 624.0} - labelcoords {288.0 656.0} - interface-peer {eth0 n15} - interface-peer {eth1 n3} - custom-config { - custom-config-id service:zebra - custom-command zebra - config { - files=('/usr/local/etc/quagga/Quagga.conf', 'quaggaboot.sh', '/usr/local/etc/quagga/vtysh.conf', ) - } - } - custom-config { - custom-config-id service:zebra:/usr/local/etc/quagga/Quagga.conf - custom-command /usr/local/etc/quagga/Quagga.conf - config { - interface eth0 - ip address 10.0.8.1/32 - ipv6 address 2001:8::1/128 - ipv6 ospf6 instance-id 65 - ipv6 ospf6 hello-interval 2 - ipv6 ospf6 dead-interval 6 - ipv6 ospf6 retransmit-interval 5 - ipv6 ospf6 network manet-designated-router - ipv6 ospf6 diffhellos - ipv6 ospf6 adjacencyconnectivity uniconnected - ipv6 ospf6 lsafullness mincostlsa - ! - interface eth1 - ip address 10.0.9.2/24 - ipv6 address 2001:9::2/64 - ! - router ospf - router-id 10.0.8.1 - network 10.0.8.1/32 area 0 - network 10.0.9.0/24 area 0 - redistribute connected metric-type 1 - redistribute ospf6 metric-type 1 - ! - router ospf6 - router-id 10.0.8.1 - interface eth0 area 0.0.0.0 - redistribute connected - redistribute ospf - ! - - } - } - services {zebra OSPFv2 OSPFv3MDR IPForward} -} - -node n12 { - type router - model mdr - network-config { - hostname n12 - ! - interface eth0 - ip address 10.0.8.2/32 - ipv6 address 2001:8::2/128 - ! - } - canvas c1 - iconcoords {504.0 792.0} - labelcoords {504.0 824.0} - interface-peer {eth0 n15} -} - -node n13 { - type router - model mdr - network-config { - hostname n13 - ! - interface eth0 - ip address 10.0.8.3/32 - ipv6 address 2001:8::3/128 - ! - } - canvas c1 - iconcoords {552.0 672.0} - labelcoords {552.0 704.0} - interface-peer {eth0 n15} -} - -node n14 { - type router - model mdr - network-config { - hostname n14 - ! - interface eth0 - ip address 10.0.8.4/32 - ipv6 address 2001:8::4/128 - ! - } - canvas c1 - iconcoords {720.0 792.0} - labelcoords {720.0 824.0} - interface-peer {eth0 n15} -} - -node n15 { - type wlan - network-config { - hostname wlan15 - ! - interface wireless - ip address 10.0.8.0/32 - ipv6 address 2001:8::0/128 - ! - mobmodel - coreapi - basic_range - ! - } - custom-config { - custom-config-id basic_range - custom-command {3 3 9 9 9} - config { - range=275 - bandwidth=54000000 - jitter=0 - delay=20000 - error=0 - } - } - canvas c1 - iconcoords {120.0 768.0} - labelcoords {120.0 800.0} - interface-peer {e0 n11} - interface-peer {e1 n12} - interface-peer {e2 n13} - interface-peer {e3 n14} -} - -node n16 { - type router - model PC - network-config { - hostname n16 - ! - interface eth0 - ip address 10.0.1.20/24 - ipv6 address 2001:1::20/64 - ! - } - canvas c1 - iconcoords {96.0 456.0} - labelcoords {96.0 488.0} - interface-peer {eth0 n4} -} - -node n17 { - type router - model PC - network-config { - hostname n17 - ! - interface eth0 - ip address 10.0.1.21/24 - ipv6 address 2001:1::21/64 - ! - } - canvas c1 - iconcoords {96.0 600.0} - labelcoords {96.0 632.0} - interface-peer {eth0 n4} -} - -node n18 { - type router - model PC - network-config { - hostname n18 - ! - interface eth0 - ip address 10.0.1.22/24 - ipv6 address 2001:1::22/64 - ! - } - canvas c1 - iconcoords {96.0 528.0} - labelcoords {96.0 560.0} - interface-peer {eth0 n4} -} - -node n19 { - type router - model router - network-config { - hostname n19 - ! - interface eth3 - ip address 10.0.7.1/24 - ipv6 address 2001:7::1/64 - ! - interface eth2 - ip address 10.0.6.1/24 - ipv6 address 2001:6::1/64 - ! - interface eth1 - ip address 10.0.5.1/24 - ipv6 address 2001:5::1/64 - ! - interface eth0 - ip address 10.0.4.2/24 - ipv6 address 2001:4::2/64 - ! - } - canvas c1 - iconcoords {576.0 408.0} - labelcoords {576.0 436.0} - interface-peer {eth0 n3} - interface-peer {eth1 n2} - interface-peer {eth2 n9} - interface-peer {eth3 n10} -} - -node n20 { - type router - model mdr - network-config { - hostname n20 - ! - interface eth1 - ip address 10.0.11.1/24 - ipv6 address 2001:11::1/64 - ! - interface eth0 - ip address 10.0.10.1/32 - ipv6 address 2001:10::1/128 - ! - } - canvas c1 - iconcoords {288.0 168.0} - labelcoords {288.0 200.0} - interface-peer {eth0 n24} - interface-peer {eth1 n1} - custom-config { - custom-config-id service:zebra - custom-command zebra - config { - files=('/usr/local/etc/quagga/Quagga.conf', 'quaggaboot.sh', '/usr/local/etc/quagga/vtysh.conf', ) - } - } - custom-config { - custom-config-id service:zebra:/usr/local/etc/quagga/Quagga.conf - custom-command /usr/local/etc/quagga/Quagga.conf - config { - interface eth0 - ip address 10.0.10.1/32 - ipv6 address 2001:10::1/128 - ipv6 ospf6 instance-id 65 - ipv6 ospf6 hello-interval 2 - ipv6 ospf6 dead-interval 6 - ipv6 ospf6 retransmit-interval 5 - ipv6 ospf6 network manet-designated-router - ipv6 ospf6 diffhellos - ipv6 ospf6 adjacencyconnectivity uniconnected - ipv6 ospf6 lsafullness mincostlsa - ! - interface eth1 - ip address 10.0.11.1/24 - ipv6 address 2001:11::1/64 - ! - router ospf - router-id 10.0.10.1 - network 10.0.10.1/32 area 0 - network 10.0.11.0/24 area 0 - redistribute connected metric-type 1 - redistribute ospf6 metric-type 1 - ! - router ospf6 - router-id 10.0.10.1 - interface eth0 area 0.0.0.0 - redistribute connected - redistribute ospf - ! - - } - } - services {zebra OSPFv2 OSPFv3MDR IPForward} -} - -node n21 { - type router - model mdr - network-config { - hostname n21 - ! - interface eth0 - ip address 10.0.10.2/32 - ipv6 address 2001:10::2/128 - ! - } - canvas c1 - iconcoords {240.0 48.0} - labelcoords {240.0 80.0} - interface-peer {eth0 n24} -} - -node n22 { - type router - model mdr - network-config { - hostname n22 - ! - interface eth0 - ip address 10.0.10.3/32 - ipv6 address 2001:10::3/128 - ! - } - canvas c1 - iconcoords {504.0 48.0} - labelcoords {504.0 80.0} - interface-peer {eth0 n24} -} - -node n23 { - type router - model mdr - network-config { - hostname n23 - ! - interface eth0 - ip address 10.0.10.4/32 - ipv6 address 2001:10::4/128 - ! - } - canvas c1 - iconcoords {144.0 168.0} - labelcoords {144.0 200.0} - interface-peer {eth0 n24} -} - -node n24 { - type wlan - network-config { - hostname wlan24 - ! - interface wireless - ip address 10.0.10.0/32 - ipv6 address 2001:10::0/128 - ! - mobmodel - coreapi - emane_ieee80211abg - ! - } - custom-config { - custom-config-id basic_range - custom-command {3 3 9 9 9} - config { - range=275 - bandwidth=54000000 - jitter=0 - delay=20000 - error=0 - } - } - canvas c1 - iconcoords {48.0 72.0} - labelcoords {48.0 104.0} - interface-peer {e0 n20} - interface-peer {e1 n21} - interface-peer {e2 n22} - interface-peer {e3 n23} -} - -node n25 { - type lanswitch - network-config { - hostname n25 - ! - } - canvas c1 - iconcoords {624.0 192.0} - labelcoords {624.0 216.0} - interface-peer {e0 n5} - interface-peer {e1 n26} -} - -node n26 { - type router - model PC - network-config { - hostname n26 - ! - interface eth0 - ip address 10.0.0.20/24 - ipv6 address 2001:0::20/64 - ! - } - canvas c1 - iconcoords {720.0 144.0} - labelcoords {720.0 176.0} - interface-peer {eth0 n25} -} - -link l1 { - nodes {n2 n5} - bandwidth 0 -} - -link l2 { - delay 8000 - nodes {n3 n4} - bandwidth 1024000 -} - -link l3 { - nodes {n1 n3} - bandwidth 0 -} - -link l4 { - nodes {n1 n2} - bandwidth 0 -} - -link l5 { - nodes {n5 n6} - bandwidth 0 -} - -link l6 { - nodes {n5 n7} - bandwidth 0 -} - -link l7 { - nodes {n5 n8} - bandwidth 0 -} - -link l8 { - nodes {n3 n19} - bandwidth 0 -} - -link l9 { - nodes {n19 n2} - bandwidth 0 -} - -link l10 { - nodes {n4 n16} - bandwidth 0 -} - -link l11 { - nodes {n4 n17} - bandwidth 0 -} - -link l12 { - nodes {n4 n18} - bandwidth 0 -} - -link l13 { - nodes {n19 n9} -} - -link l14 { - nodes {n19 n10} -} - -link l15 { - nodes {n15 n11} -} - -link l16 { - nodes {n15 n12} -} - -link l17 { - nodes {n15 n13} -} - -link l18 { - nodes {n15 n14} -} - -link l19 { - nodes {n3 n11} - bandwidth 0 -} - -link l20 { - nodes {n24 n20} -} - -link l21 { - nodes {n24 n21} -} - -link l22 { - nodes {n24 n22} -} - -link l23 { - nodes {n24 n23} -} - -link l24 { - nodes {n20 n1} - bandwidth 0 -} - -link l25 { - delay 5000 - nodes {n25 n5} - bandwidth 0 -} - -link l26 { - nodes {n25 n26} - bandwidth 0 -} - -annotation a1 { - iconcoords {45.0 431.0 220.0 642.0} - type rectangle - label {} - labelcolor black - fontfamily {Arial} - fontsize {12} - color #e6f4f4 - width 0 - border black - rad 0 - canvas c1 -} - -annotation a2 { - iconcoords {642 189 821 404} - type rectangle - label {} - labelcolor black - fontfamily {Arial} - fontsize {12} - color #e6f4f4 - width 0 - border black - rad 0 - canvas c1 -} - -annotation a3 { - iconcoords {200 218 655 463} - type rectangle - label {} - labelcolor black - fontfamily {Arial} - fontsize {12} - color #f4f1f0 - width 0 - border black - rad 0 - canvas c1 -} - -annotation a4 { - iconcoords {600.0 48.0} - type text - label {Kitchen Sink Scenario} - labelcolor black - fontfamily {FreeSans} - fontsize {16} - effects {bold} - canvas c1 -} - -annotation a5 { - iconcoords {648.0 72.0} - type text - label {see scenario comments} - labelcolor black - fontfamily {FreeSans} - fontsize {12} - canvas c1 -} - -canvas c1 { - name {Canvas1} - refpt {0 0 47.5791667 -122.132322 150} - scale {150.0} - size {1000 1000} -} - -option global { - interface_names no - ip_addresses yes - ipv6_addresses yes - node_labels yes - link_labels yes - ipsec_configs yes - exec_errors yes - show_api no - background_images no - annotations yes - grid yes - traffic_start 0 -} - -option session { - enablesdt=1 -} - diff --git a/gui/configs/sample11-sdn.imn b/gui/configs/sample11-sdn.imn deleted file mode 100644 index a41dbc11..00000000 --- a/gui/configs/sample11-sdn.imn +++ /dev/null @@ -1,291 +0,0 @@ -node n1 { - type router - model host - network-config { - hostname ryu1 - ! - interface eth1 - ip address 10.0.5.10/24 - ipv6 address 2001:5::10/64 - ! - interface eth0 - ip address 10.0.4.10/24 - ipv6 address 2001:4::10/64 - ! - } - canvas c1 - iconcoords {203.0 65.0} - labelcoords {203.0 97.0} - interface-peer {eth0 n2} - interface-peer {eth1 n3} -} - -node n2 { - type router - model OVS - network-config { - hostname ovs1 - ! - interface eth2 - ip address 10.0.4.1/24 - ipv6 address 2001:4::1/64 - ! - interface eth1 - ip address 10.0.1.1/24 - ipv6 address 2001:1::1/64 - ! - interface eth0 - ip address 10.0.0.1/24 - ipv6 address 2001:0::1/64 - ! - } - canvas c1 - iconcoords {124.0 213.0} - labelcoords {124.0 245.0} - interface-peer {eth0 n6} - interface-peer {eth1 n4} - interface-peer {eth2 n1} -} - -node n3 { - type router - model OVS - network-config { - hostname ovs2 - ! - interface eth2 - ip address 10.0.5.1/24 - ipv6 address 2001:5::1/64 - ! - interface eth1 - ip address 10.0.3.1/24 - ipv6 address 2001:3::1/64 - ! - interface eth0 - ip address 10.0.2.1/24 - ipv6 address 2001:2::1/64 - ! - } - canvas c1 - iconcoords {299.0 220.0} - labelcoords {299.0 252.0} - interface-peer {eth0 n7} - interface-peer {eth1 n5} - interface-peer {eth2 n1} -} - -node n4 { - type router - model host - network-config { - hostname n4 - ! - interface eth0 - ip address 10.0.1.10/24 - ipv6 address 2001:1::10/64 - ! - } - canvas c1 - iconcoords {39.0 313.0} - labelcoords {39.0 345.0} - interface-peer {eth0 n2} -} - -node n5 { - type router - model host - network-config { - hostname n5 - ! - interface eth0 - ip address 10.0.3.10/24 - ipv6 address 2001:3::10/64 - ! - } - canvas c1 - iconcoords {286.0 327.0} - labelcoords {286.0 359.0} - interface-peer {eth0 n3} -} - -node n6 { - type router - model host - network-config { - hostname n6 - ! - interface eth0 - ip address 10.0.0.10/24 - ipv6 address 2001:0::10/64 - ! - } - canvas c1 - iconcoords {131.0 322.0} - labelcoords {131.0 354.0} - interface-peer {eth0 n2} -} - -node n7 { - type router - model host - network-config { - hostname n7 - ! - interface eth0 - ip address 10.0.2.10/24 - ipv6 address 2001:2::10/64 - ! - } - canvas c1 - iconcoords {373.0 328.0} - labelcoords {373.0 360.0} - interface-peer {eth0 n3} -} - -node n8 { - type router - model mdr - network-config { - hostname n8 - ! - interface eth0 - ip address 10.0.6.1/32 - ipv6 address 2001:6::1/128 - ! - } - canvas c1 - iconcoords {579.0 102.0} - labelcoords {579.0 134.0} - interface-peer {eth0 n11} -} - -node n9 { - type router - model mdr - network-config { - hostname n9 - ! - interface eth0 - ip address 10.0.6.2/32 - ipv6 address 2001:6::2/128 - ! - } - canvas c1 - iconcoords {493.0 212.0} - labelcoords {493.0 244.0} - interface-peer {eth0 n11} -} - -node n10 { - type router - model mdr - network-config { - hostname n10 - ! - interface eth0 - ip address 10.0.6.3/32 - ipv6 address 2001:6::3/128 - ! - } - canvas c1 - iconcoords {674.0 225.0} - labelcoords {674.0 257.0} - interface-peer {eth0 n11} -} - -node n11 { - type wlan - network-config { - hostname mobile-sdn - ! - interface wireless - ip address 10.0.6.0/32 - ipv6 address 2001:6::0/128 - ! - mobmodel - coreapi - basic_range - ! - } - custom-config { - custom-config-id basic_range - custom-command {3 3 9 9 9} - config { - range=275 - bandwidth=54000000 - jitter=0 - delay=20000 - error=0 - } - } - canvas c1 - iconcoords {683.0 127.0} - labelcoords {683.0 159.0} - interface-peer {e0 n8} - interface-peer {e1 n9} - interface-peer {e2 n10} -} - -link l1 { - nodes {n2 n6} - bandwidth 0 -} - -link l2 { - nodes {n2 n4} - bandwidth 0 -} - -link l3 { - nodes {n3 n7} - bandwidth 0 -} - -link l4 { - nodes {n3 n5} - bandwidth 0 -} - -link l5 { - nodes {n1 n2} - bandwidth 0 -} - -link l6 { - nodes {n1 n3} - bandwidth 0 -} - -link l7 { - nodes {n11 n8} -} - -link l8 { - nodes {n11 n9} -} - -link l9 { - nodes {n11 n10} -} - -canvas c1 { - name {Canvas1} -} - -option global { - interface_names no - ip_addresses yes - ipv6_addresses no - node_labels yes - link_labels yes - show_api no - background_images no - annotations yes - grid yes - traffic_start 0 - mac_address_start 80 -} - -option session { -} - diff --git a/gui/configs/sample2-ssh.imn b/gui/configs/sample2-ssh.imn deleted file mode 100644 index d79a5f3b..00000000 --- a/gui/configs/sample2-ssh.imn +++ /dev/null @@ -1,248 +0,0 @@ -node n8 { - type router - model router - network-config { - hostname n8 - ! - interface eth3 - ip address 10.0.6.2/24 - ipv6 address a:6::2/64 - ! - interface eth2 - ip address 10.0.3.1/24 - ipv6 address a:3::1/64 - ! - interface eth1 - ip address 10.0.1.1/24 - ipv6 address a:1::1/64 - ! - interface eth0 - ip address 10.0.0.1/24 - ipv6 address a:0::1/64 - ! - } - canvas c1 - iconcoords {264.0 168.0} - labelcoords {264.0 196.0} - interface-peer {eth0 n1} - interface-peer {eth1 n4} - interface-peer {eth2 n7} - interface-peer {eth3 n6} -} - -node n1 { - type router - model router - network-config { - hostname n1 - ! - interface eth3 - ip address 10.0.5.1/24 - ipv6 address a:5::1/64 - ! - interface eth2 - ip address 10.0.4.2/24 - ipv6 address a:4::2/64 - ! - interface eth1 - ip address 10.0.2.1/24 - ipv6 address a:2::1/64 - ! - interface eth0 - ip address 10.0.0.2/24 - ipv6 address a:0::2/64 - ! - } - canvas c1 - iconcoords {528.0 312.0} - labelcoords {528.0 340.0} - interface-peer {eth0 n8} - interface-peer {eth1 n5} - interface-peer {eth2 n7} - interface-peer {eth3 n6} -} - -node n2 { - type router - model host - cpu {{min 0} {max 100} {weight 1}} - network-config { - hostname sshserver - ! - interface eth0 - ip address 10.0.2.10/24 - ipv6 address a:2::10/64 - ! - } - canvas c1 - iconcoords {732.0 84.0} - labelcoords {671.0 95.0} - interface-peer {eth0 n5} -} - -node n3 { - type router - model PC - cpu {{min 0} {max 100} {weight 1}} - network-config { - hostname sshclient - ! - interface eth0 - ip address 10.0.1.20/24 - ipv6 address a:1::20/64 - ! - } - canvas c1 - iconcoords {72.0 252.0} - labelcoords {86.0 295.0} - interface-peer {eth0 n4} -} - -node n4 { - type lanswitch - network-config { - hostname n4 - ! - } - canvas c1 - iconcoords {120.0 120.0} - labelcoords {120.0 148.0} - interface-peer {e0 n3} - interface-peer {e1 n8} -} - -node n5 { - type lanswitch - network-config { - hostname n5 - ! - } - canvas c1 - iconcoords {708.0 204.0} - labelcoords {708.0 232.0} - interface-peer {e0 n1} - interface-peer {e1 n2} -} - -node n6 { - type router - model router - network-config { - hostname n6 - ! - interface eth1 - ip address 10.0.6.1/24 - ipv6 address a:6::1/64 - ! - interface eth0 - ip address 10.0.5.2/24 - ipv6 address a:5::2/64 - ! - } - canvas c1 - iconcoords {480.0 132.0} - labelcoords {480.0 160.0} - interface-peer {eth0 n1} - interface-peer {eth1 n8} -} - -node n7 { - type router - model router - network-config { - hostname n7 - ! - interface eth1 - ip address 10.0.4.1/24 - ipv6 address a:4::1/64 - ! - interface eth0 - ip address 10.0.3.2/24 - ipv6 address a:3::2/64 - ! - } - canvas c1 - iconcoords {312.0 348.0} - labelcoords {312.0 376.0} - interface-peer {eth0 n8} - interface-peer {eth1 n1} -} - -link l0 { - nodes {n8 n1} - bandwidth 0 -} - -link l1 { - nodes {n4 n3} - bandwidth 0 -} - -link l2 { - nodes {n4 n8} - bandwidth 0 -} - -link l3 { - nodes {n1 n5} - bandwidth 0 -} - -link l4 { - nodes {n5 n2} - bandwidth 0 -} - -link l5 { - nodes {n8 n7} - bandwidth 0 -} - -link l6 { - nodes {n7 n1} - bandwidth 0 -} - -link l7 { - nodes {n1 n6} - bandwidth 0 -} - -link l8 { - nodes {n6 n8} - bandwidth 0 -} - -annotation a0 { - iconcoords {202 75 612 405} - type rectangle - label {provider network} - labelcolor black - fontfamily {Arial} - fontsize 10 - color #f8f8d6 - width 0 - border black - rad 25 - canvas c1 -} - -canvas c1 { - name {Canvas1} -} - -option global { - interface_names no - ip_addresses yes - ipv6_addresses yes - node_labels yes - link_labels yes - ipsec_configs yes - remote_exec no - exec_errors yes - show_api no - background_images no - annotations yes - grid yes -} - diff --git a/gui/configs/sample3-bgp.imn b/gui/configs/sample3-bgp.imn deleted file mode 100644 index b31693ef..00000000 --- a/gui/configs/sample3-bgp.imn +++ /dev/null @@ -1,657 +0,0 @@ -node n1 { - type router - model router - network-config { - hostname router1 - ! - interface eth2 - ip address 10.0.8.2/24 - ! - interface eth1 - ip address 10.0.6.1/24 - ! - interface eth0 - ip address 10.0.5.2/24 - ! - } - iconcoords {168.0 264.0} - labelcoords {168.0 288.0} - interface-peer {eth0 n16} - interface-peer {eth1 n2} - interface-peer {eth2 n3} - canvas c1 - services {zebra BGP IPForward} - custom-config { - custom-config-id service:zebra:/usr/local/etc/quagga/Quagga.conf - custom-command /usr/local/etc/quagga/Quagga.conf - config { - interface eth2 - ip address 10.0.8.2/24 - ! - interface eth1 - ip address 10.0.6.1/24 - ! - interface eth0 - ip address 10.0.5.2/24 - ! - router bgp 105 - bgp router-id 10.0.8.2 - redistribute connected - neighbor 10.0.6.2 remote-as 105 - neighbor 10.0.6.2 next-hop-self - neighbor 10.0.5.1 remote-as 105 - neighbor 10.0.5.1 next-hop-self - neighbor 10.0.8.1 remote-as 2901 - neighbor 10.0.8.1 next-hop-self - ! - } - } -} - -node n2 { - type router - model router - network-config { - hostname router2 - ! - interface eth2 - ip address 10.0.9.1/24 - ! - interface eth1 - ip address 10.0.7.1/24 - ! - interface eth0 - ip address 10.0.6.2/24 - ! - } - iconcoords {312.0 168.0} - labelcoords {312.0 192.0} - interface-peer {eth0 n1} - interface-peer {eth1 n16} - interface-peer {eth2 n6} - canvas c1 - services {zebra BGP IPForward} - custom-config { - custom-config-id service:zebra:/usr/local/etc/quagga/Quagga.conf - custom-command /usr/local/etc/quagga/Quagga.conf - config { - interface eth2 - ip address 10.0.9.1/24 - ! - interface eth1 - ip address 10.0.7.1/24 - ! - interface eth0 - ip address 10.0.6.2/24 - ! - router bgp 105 - bgp router-id 10.0.8.2 - redistribute connected - neighbor 10.0.7.2 remote-as 105 - neighbor 10.0.7.2 next-hop-self - neighbor 10.0.6.1 remote-as 105 - neighbor 10.0.6.1 next-hop-self - neighbor 10.0.9.2 remote-as 2902 - neighbor 10.0.9.2 next-hop-self - ! - } - } -} - -node n3 { - type router - model router - network-config { - hostname router3 - ! - interface eth1 - ip address 10.0.8.1/24 - ! - interface eth0 - ip address 10.0.2.1/24 - ! - } - iconcoords {96.0 408.0} - labelcoords {96.0 432.0} - interface-peer {eth0 n4} - interface-peer {eth1 n1} - canvas c1 - services {zebra BGP IPForward} - custom-config { - custom-config-id service:zebra:/usr/local/etc/quagga/Quagga.conf - custom-command /usr/local/etc/quagga/Quagga.conf - config { - interface eth1 - ip address 10.0.8.1/24 - ! - interface eth0 - ip address 10.0.2.1/24 - ! - router bgp 2901 - bgp router-id 10.0.2.1 - redistribute connected - neighbor 10.0.2.2 remote-as 2901 - neighbor 10.0.2.2 next-hop-self - neighbor 10.0.8.2 remote-as 105 - neighbor 10.0.8.2 next-hop-self - ! - } - } -} - -node n4 { - type router - model router - network-config { - hostname router4 - ! - interface eth0 - ip address 10.0.2.2/24 - ! - interface eth1 - ip address 10.0.10.1/24 - ! - interface eth2 - ip address 10.0.0.1/24 - ! - } - iconcoords {240.0 432.0} - labelcoords {240.0 456.0} - interface-peer {eth2 n9} - interface-peer {eth0 n3} - interface-peer {eth1 n7} - canvas c1 - services {zebra BGP IPForward} - custom-config { - custom-config-id service:zebra:/usr/local/etc/quagga/Quagga.conf - custom-command /usr/local/etc/quagga/Quagga.conf - config { - interface eth0 - ip address 10.0.2.2/24 - ! - interface eth1 - ip address 10.0.10.1/24 - ! - interface eth2 - ip address 10.0.0.1/24 - ! - router bgp 2901 - bgp router-id 10.0.10.1 - redistribute connected - neighbor 10.0.2.1 remote-as 2901 - neighbor 10.0.2.1 next-hop-self - neighbor 10.0.10.2 remote-as 2902 - neighbor 10.0.10.2 next-hop-self - network 10.0.0.0 mask 255.255.255.0 - ! - } - } -} - -node n5 { - type router - model router - network-config { - hostname router5 - ! - interface eth1 - ip address 10.0.4.1/24 - ! - interface eth0 - ip address 10.0.3.2/24 - ! - interface eth2 - ip address 10.0.1.1/24 - ! - } - iconcoords {528.0 336.0} - labelcoords {528.0 360.0} - interface-peer {eth2 n8} - interface-peer {eth0 n7} - interface-peer {eth1 n6} - canvas c1 - services {zebra BGP IPForward} - custom-config { - custom-config-id service:zebra:/usr/local/etc/quagga/Quagga.conf - custom-command /usr/local/etc/quagga/Quagga.conf - config { - interface eth1 - ip address 10.0.4.1/24 - ! - interface eth0 - ip address 10.0.3.2/24 - ! - interface eth2 - ip address 10.0.1.1/24 - ! - router bgp 2902 - bgp router-id 10.0.4.1 - redistribute connected - neighbor 10.0.4.2 remote-as 2902 - neighbor 10.0.4.2 next-hop-self - neighbor 10.0.3.1 remote-as 2902 - neighbor 10.0.3.1 next-hop-self - network 10.0.1.0 mask 255.255.255.0 - ! - } - } -} - -node n6 { - type router - model router - network-config { - hostname router6 - ! - interface eth1 - ip address 10.0.9.2/24 - ! - interface eth0 - ip address 10.0.4.2/24 - ! - router bgp 2902 - bgp router-id 10.0.9.2 - redistribute connected - neighbor 10.0.4.1 remote-as 2902 - neighbor 10.0.4.1 next-hop-self - neighbor 10.0.9.1 remote-as 105 - neighbor 10.0.9.1 next-hop-self - ! - } - iconcoords {624.0 240.0} - labelcoords {624.0 264.0} - interface-peer {eth0 n5} - interface-peer {eth1 n2} - canvas c1 - services {zebra BGP IPForward} - custom-config { - custom-config-id service:zebra:/usr/local/etc/quagga/Quagga.conf - custom-command /usr/local/etc/quagga/Quagga.conf - config { - interface eth1 - ip address 10.0.9.2/24 - ! - interface eth0 - ip address 10.0.4.2/24 - ! - router bgp 2902 - bgp router-id 10.0.9.2 - redistribute connected - neighbor 10.0.4.1 remote-as 2902 - neighbor 10.0.4.1 next-hop-self - neighbor 10.0.9.1 remote-as 105 - neighbor 10.0.9.1 next-hop-self - ! - } - } -} - -node n7 { - type router - model router - network-config { - hostname router7 - ! - interface eth1 - ip address 10.0.10.2/24 - ! - interface eth0 - ip address 10.0.3.1/24 - ! - } - iconcoords {528.0 456.0} - labelcoords {528.0 480.0} - interface-peer {eth0 n5} - interface-peer {eth1 n4} - canvas c1 - services {zebra BGP IPForward} - custom-config { - custom-config-id service:zebra:/usr/local/etc/quagga/Quagga.conf - custom-command /usr/local/etc/quagga/Quagga.conf - config { - interface eth1 - ip address 10.0.10.2/24 - ! - interface eth0 - ip address 10.0.3.1/24 - ! - router bgp 2902 - bgp router-id 10.0.3.1 - redistribute connected - neighbor 10.0.3.2 remote-as 2902 - neighbor 10.0.3.2 next-hop-self - neighbor 10.0.10.1 remote-as 2901 - neighbor 10.0.10.1 next-hop-self - ! - } - } -} - -node n8 { - type lanswitch - network-config { - hostname lanswitch8 - ! - } - iconcoords {672.0 432.0} - labelcoords {672.0 456.0} - interface-peer {e0 n5} - interface-peer {e1 n10} - interface-peer {e2 n11} - canvas c1 -} - -node n9 { - type hub - network-config { - hostname hub9 - ! - } - iconcoords {120.0 504.0} - labelcoords {120.0 528.0} - interface-peer {e0 n4} - interface-peer {e1 n15} - interface-peer {e2 n14} - interface-peer {e3 n13} - interface-peer {e4 n12} - canvas c1 -} - -node n10 { - type router - model host - network-config { - hostname host10 - ! - interface eth0 - ip address 10.0.1.10/24 - ! - } - iconcoords {576.0 552.0} - labelcoords {576.0 584.0} - interface-peer {eth0 n8} - canvas c1 -} - -node n11 { - type router - model host - network-config { - hostname host11 - ! - interface eth0 - ip address 10.0.1.11/24 - ! - } - iconcoords {696.0 552.0} - labelcoords {696.0 584.0} - interface-peer {eth0 n8} - canvas c1 -} - -node n12 { - type router - model PC - network-config { - hostname pc12 - ! - interface eth0 - ip address 10.0.0.23/24 - ! - } - iconcoords {288.0 576.0} - labelcoords {288.0 608.0} - interface-peer {eth0 n9} - canvas c1 -} - -node n13 { - type router - model PC - network-config { - hostname pc13 - ! - interface eth0 - ip address 10.0.0.22/24 - ! - } - iconcoords {216.0 600.0} - labelcoords {216.0 632.0} - interface-peer {eth0 n9} - canvas c1 -} - -node n14 { - type router - model PC - network-config { - hostname pc14 - ! - interface eth0 - ip address 10.0.0.21/24 - ! - } - iconcoords {120.0 624.0} - labelcoords {120.0 656.0} - interface-peer {eth0 n9} - canvas c1 -} - -node n15 { - type router - model PC - network-config { - hostname pc15 - ! - interface eth0 - ip address 10.0.0.20/24 - ! - } - iconcoords {24.0 576.0} - labelcoords {24.0 608.0} - interface-peer {eth0 n9} - canvas c1 -} - -node n16 { - type router - model router - network-config { - hostname router0 - ! - interface eth0 - ip address 10.0.5.1/24 - ! - interface eth1 - ip address 10.0.7.2/24 - ! - } - iconcoords {120.0 120.0} - labelcoords {120.0 144.0} - interface-peer {eth0 n1} - interface-peer {eth1 n2} - canvas c1 - services {zebra BGP IPForward} - custom-config { - custom-config-id service:zebra:/usr/local/etc/quagga/Quagga.conf - custom-command /usr/local/etc/quagga/Quagga.conf - config { - interface eth0 - ip address 10.0.5.1/24 - ! - interface eth1 - ip address 10.0.7.2/24 - ! - router bgp 105 - bgp router-id 10.0.5.1 - redistribute connected - neighbor 10.0.7.1 remote-as 105 - neighbor 10.0.7.1 next-hop-self - neighbor 10.0.5.2 remote-as 105 - neighbor 10.0.5.2 next-hop-self - ! - } - } -} - -link l0 { - nodes {n9 n4} - bandwidth 100000000 -} - -link l1 { - nodes {n8 n5} - bandwidth 100000000 -} - -link l2 { - nodes {n15 n9} - bandwidth 100000000 -} - -link l3 { - nodes {n14 n9} - bandwidth 100000000 -} - -link l4 { - nodes {n13 n9} - bandwidth 100000000 -} - -link l5 { - nodes {n12 n9} - bandwidth 100000000 -} - -link l6 { - nodes {n10 n8} - bandwidth 100000000 -} - -link l7 { - nodes {n11 n8} - bandwidth 100000000 -} - -link l8 { - nodes {n3 n4} - bandwidth 2048000 - delay 2500 -} - -link l9 { - nodes {n7 n5} - bandwidth 2048000 - delay 2500 -} - -link l10 { - nodes {n5 n6} - bandwidth 2048000 - delay 2500 -} - -link l11 { - nodes {n16 n1} - bandwidth 2048000 - delay 2500 -} - -link l12 { - nodes {n1 n2} - bandwidth 2048000 - delay 2500 -} - -link l13 { - nodes {n2 n16} - bandwidth 2048000 - delay 2500 -} - -link l14 { - nodes {n3 n1} - bandwidth 10000000 - delay 650000 -} - -link l15 { - nodes {n2 n6} - bandwidth 10000000 - delay 650000 -} - -link l16 { - nodes {n4 n7} - bandwidth 5000000 - delay 7500 -} - -annotation a0 { - iconcoords { 70 55 345 330 } - type oval - label {AS 105} - labelcolor #CFCFAC - fontfamily {Arial} - fontsize {12} - color #FFFFCC - width 0 - border black - canvas c1 -} - -annotation a1 { - iconcoords { 470 170 740 630 } - type oval - label {AS 2902} - labelcolor #C0C0CF - fontfamily {Arial} - fontsize {12} - color #F0F0FF - width 0 - border black - canvas c1 -} - -annotation a2 { - iconcoords { 0 355 320 660 } - type oval - label {AS 2901} - labelcolor #C0C0CF - fontfamily {Arial} - fontsize {12} - color #F0F0FF - width 0 - border black - canvas c1 -} - -annotation a10 { - type text - canvas c1 - iconcoords { 450 55 } - color #FFCCCC - fontsize {20} - label {Sample Topology 1} -} - -canvas c1 { - name {Canvas1} - size {900 706.0} -} - -option global { - interface_names yes - ip_addresses yes - ipv6_addresses yes - node_labels yes - link_labels yes - ipsec_configs yes - remote_exec no - exec_errors yes - show_api no - background_images no - annotations yes - grid yes -} diff --git a/gui/configs/sample4-bg.jpg b/gui/configs/sample4-bg.jpg deleted file mode 100644 index 2b3d29dc..00000000 Binary files a/gui/configs/sample4-bg.jpg and /dev/null differ diff --git a/gui/configs/sample4-nrlsmf.imn b/gui/configs/sample4-nrlsmf.imn deleted file mode 100644 index 165c424f..00000000 --- a/gui/configs/sample4-nrlsmf.imn +++ /dev/null @@ -1,546 +0,0 @@ -comments { -Joe Macker NRL -Last updated: Sept 2010,2015(to fix mobility script) -Nov 2010 Jeff Ahrenholz - updated for new services model and renamed - (was 2groups_10nodes_smf.imn) - -This scenario is a simple SMF example for testing multicast within CORE. - -There are several dependencies for these scenarios to work; - -nrlsmf must be installed and the binary must be within the path when executing. -This should also be built along with protolib from the NRL pf.itd.nrl.navy.mil -repository or from nightly snapshots by using the Makefile.core build file. -This avoids some of the potential problems that arise with protolib call and -proper netns support in various kernel releases. For now the Makefile.core -approach patches around the problem. - -This scenario will launch 10 quagga manet-ospf and smf classical flooding -router nodes. A mobility pattern can be used to cause periodic fragmentation -and coalescing among 5 groups that move together as a somewhat randomized -cluster. - -Within netns and core the following must be used as nrlsmf params. hash mode -and instance ids. -This script uses nodenames as instance ids and MD5 as the hash mode. -Distributed optimized relay selection is not provided in this example but works -in nrlsmf with both quagga manetospf-mdr and with nrlolsr or newer nhdp code -being developed. Relays can also be manually configured if that is of some use -in a scneario. Classical flodding still provides duplication detection in this -mode but of course has additional overhead. - ------ -Traffic testing etc. You can try sending your own multicast apps or use a -testtool. - -mgen is recommended as a test tool, but ping -t 5 224.225.226.227 type testing -can also be used. - -an example mgen script to source multicast from a terminal window is as follows: - -mgen event "on 1 udp dst 224.225.226.227/5000 periodic [1 500]" - -this sends 500 bytes packets every second. See mgen users guide for the myriad -of choices/options. - -on a receive node terminal the follow can work. - -mgen event "join 224.225.226.227" event "listen udp 5000" output -without output it will stream to stdout. -} - -node n1 { - type router - model mdr - network-config { - hostname n1 - ! - interface eth0 - ip address 10.0.0.1/32 - ipv6 address a:0::1/128 - ! - } - iconcoords {186.2364578872143 137.89039496012572} - labelcoords {186.2364578872143 161.89039496012572} - canvas c1 - interface-peer {eth0 n11} - custom-image $CORE_DATA_DIR/icons/normal/router_green.gif - services {zebra OSPFv3MDR SMF IPForward UserDefined} - custom-config { - custom-config-id service:UserDefined:custom-post-config-commands.sh - custom-command custom-post-config-commands.sh - config { - route add default dev eth0 - route add -net 224.0.0.0 netmask 224.0.0.0 dev eth0 - } - } - custom-config { - custom-config-id service:UserDefined - custom-command UserDefined - config { - files=('custom-post-config-commands.sh', ) - startidx=35 - cmdup=('sh custom-post-config-commands.sh', ) - } - } -} - -node n2 { - type router - model mdr - network-config { - hostname n2 - ! - interface eth0 - ip address 10.0.0.2/32 - ipv6 address a:0::2/128 - ! - } - iconcoords {49.97421009111123 297.31725181124926} - labelcoords {49.97421009111123 321.31725181124926} - canvas c1 - interface-peer {eth0 n11} - custom-image $CORE_DATA_DIR/icons/normal/router_green.gif - services {zebra OSPFv3MDR SMF IPForward UserDefined} - custom-config { - custom-config-id service:UserDefined:custom-post-config-commands.sh - custom-command custom-post-config-commands.sh - config { - route add default dev eth0 - route add -net 224.0.0.0 netmask 224.0.0.0 dev eth0 - } - } - custom-config { - custom-config-id service:UserDefined - custom-command UserDefined - config { - files=('custom-post-config-commands.sh', ) - startidx=35 - cmdup=('sh custom-post-config-commands.sh', ) - } - } -} - -node n3 { - type router - model mdr - network-config { - hostname n3 - ! - interface eth0 - ip address 10.0.0.3/32 - ipv6 address a:0::3/128 - ! - } - iconcoords {176.46110847174833 328.14864514530865} - labelcoords {176.46110847174833 352.14864514530865} - canvas c1 - interface-peer {eth0 n11} - custom-image $CORE_DATA_DIR/icons/normal/router_green.gif - services {zebra OSPFv3MDR SMF IPForward UserDefined} - custom-config { - custom-config-id service:UserDefined:custom-post-config-commands.sh - custom-command custom-post-config-commands.sh - config { - route add default dev eth0 - route add -net 224.0.0.0 netmask 224.0.0.0 dev eth0 - } - } - custom-config { - custom-config-id service:UserDefined - custom-command UserDefined - config { - files=('custom-post-config-commands.sh', ) - startidx=35 - cmdup=('sh custom-post-config-commands.sh', ) - } - } -} - -node n4 { - type router - model mdr - network-config { - hostname n4 - ! - interface eth0 - ip address 10.0.0.4/32 - ipv6 address a:0::4/128 - ! - } - iconcoords {145.04062040794378 195.27962082775758} - labelcoords {145.04062040794378 219.27962082775758} - canvas c1 - interface-peer {eth0 n11} - custom-image $CORE_DATA_DIR/icons/normal/router_green.gif - services {zebra OSPFv3MDR SMF IPForward UserDefined} - custom-config { - custom-config-id service:UserDefined:custom-post-config-commands.sh - custom-command custom-post-config-commands.sh - config { - route add default dev eth0 - route add -net 224.0.0.0 netmask 224.0.0.0 dev eth0 - } - } - custom-config { - custom-config-id service:UserDefined - custom-command UserDefined - config { - files=('custom-post-config-commands.sh', ) - startidx=35 - cmdup=('sh custom-post-config-commands.sh', ) - } - } -} - -node n5 { - type router - model mdr - network-config { - hostname n5 - ! - interface eth0 - ip address 10.0.0.5/32 - ipv6 address a:0::5/128 - ! - } - iconcoords {137.9101266949479 257.51849231830334} - labelcoords {137.9101266949479 281.51849231830334} - canvas c1 - interface-peer {eth0 n11} - custom-image $CORE_DATA_DIR/icons/normal/router_green.gif - services {zebra OSPFv3MDR SMF IPForward UserDefined} - custom-config { - custom-config-id service:UserDefined:custom-post-config-commands.sh - custom-command custom-post-config-commands.sh - config { - route add default dev eth0 - route add -net 224.0.0.0 netmask 224.0.0.0 dev eth0 - } - } - custom-config { - custom-config-id service:UserDefined - custom-command UserDefined - config { - files=('custom-post-config-commands.sh', ) - startidx=35 - cmdup=('sh custom-post-config-commands.sh', ) - } - } -} - -node n6 { - type router - model mdr - network-config { - hostname n6 - ! - interface eth0 - ip address 10.0.0.6/32 - ipv6 address a:0::6/128 - ! - } - iconcoords {119.15850324229558 93.2505296351548} - labelcoords {119.15850324229558 117.2505296351548} - canvas c1 - interface-peer {eth0 n11} - custom-image $CORE_DATA_DIR/icons/normal/router_red.gif - services {zebra OSPFv3MDR SMF IPForward UserDefined} - custom-config { - custom-config-id service:UserDefined:custom-post-config-commands.sh - custom-command custom-post-config-commands.sh - config { - route add default dev eth0 - route add -net 224.0.0.0 netmask 224.0.0.0 dev eth0 - } - } - custom-config { - custom-config-id service:UserDefined - custom-command UserDefined - config { - files=('custom-post-config-commands.sh', ) - startidx=35 - cmdup=('sh custom-post-config-commands.sh', ) - } - } -} - -node n7 { - type router - model mdr - network-config { - hostname n7 - ! - interface eth0 - ip address 10.0.0.7/32 - ipv6 address a:0::7/128 - ! - } - iconcoords {79.1102256826161 50.123535235375556} - labelcoords {79.1102256826161 74.12353523537556} - canvas c1 - interface-peer {eth0 n11} - custom-image $CORE_DATA_DIR/icons/normal/router_red.gif - services {zebra OSPFv3MDR SMF IPForward UserDefined} - custom-config { - custom-config-id service:UserDefined:custom-post-config-commands.sh - custom-command custom-post-config-commands.sh - config { - route add default dev eth0 - route add -net 224.0.0.0 netmask 224.0.0.0 dev eth0 - } - } - custom-config { - custom-config-id service:UserDefined - custom-command UserDefined - config { - files=('custom-post-config-commands.sh', ) - startidx=35 - cmdup=('sh custom-post-config-commands.sh', ) - } - } -} - -node n8 { - type router - model mdr - network-config { - hostname n8 - ! - interface eth0 - ip address 10.0.0.8/32 - ipv6 address a:0::8/128 - ! - } - iconcoords {159.90259315202974 8.220638318379141} - labelcoords {159.90259315202974 32.220638318379144} - canvas c1 - interface-peer {eth0 n11} - custom-image $CORE_DATA_DIR/icons/normal/router_red.gif - services {zebra OSPFv3MDR SMF IPForward UserDefined} - custom-config { - custom-config-id service:UserDefined:custom-post-config-commands.sh - custom-command custom-post-config-commands.sh - config { - route add default dev eth0 - route add -net 224.0.0.0 netmask 224.0.0.0 dev eth0 - } - } - custom-config { - custom-config-id service:UserDefined - custom-command UserDefined - config { - files=('custom-post-config-commands.sh', ) - startidx=35 - cmdup=('sh custom-post-config-commands.sh', ) - } - } -} - -node n9 { - type router - model mdr - network-config { - hostname n9 - ! - interface eth0 - ip address 10.0.0.9/32 - ipv6 address a:0::9/128 - ! - } - iconcoords {150.43010603614704 165.70781621981482} - labelcoords {150.43010603614704 189.70781621981482} - canvas c1 - interface-peer {eth0 n11} - custom-image $CORE_DATA_DIR/icons/normal/router_red.gif - services {zebra OSPFv3MDR SMF IPForward UserDefined} - custom-config { - custom-config-id service:UserDefined:custom-post-config-commands.sh - custom-command custom-post-config-commands.sh - config { - route add default dev eth0 - route add -net 224.0.0.0 netmask 224.0.0.0 dev eth0 - } - } - custom-config { - custom-config-id service:UserDefined - custom-command UserDefined - config { - files=('custom-post-config-commands.sh', ) - startidx=35 - cmdup=('sh custom-post-config-commands.sh', ) - } - } -} - -node n10 { - type router - model mdr - network-config { - hostname n10 - ! - interface eth0 - ip address 10.0.0.10/32 - ipv6 address a:0::10/128 - ! - } - iconcoords {64.19289632467826 42.49909518554088} - labelcoords {64.19289632467826 66.49909518554088} - canvas c1 - interface-peer {eth0 n11} - custom-image $CORE_DATA_DIR/icons/normal/router_red.gif - services {zebra OSPFv3MDR SMF IPForward UserDefined} - custom-config { - custom-config-id service:UserDefined:custom-post-config-commands.sh - custom-command custom-post-config-commands.sh - config { - route add default dev eth0 - route add -net 224.0.0.0 netmask 224.0.0.0 dev eth0 - } - } - custom-config { - custom-config-id service:UserDefined - custom-command UserDefined - config { - files=('custom-post-config-commands.sh', ) - startidx=35 - cmdup=('sh custom-post-config-commands.sh', ) - } - } -} - -node n11 { - type wlan - network-config { - hostname wlan11 - ! - interface wireless - ip address 10.0.0.0/32 - ipv6 address a:0::0/128 - ! - mobmodel - coreapi - basic_range - ns2script - ! - } - iconcoords {0 0} - labelcoords {0 0} - canvas c1 - interface-peer {e0 n1} - interface-peer {e1 n2} - interface-peer {e2 n3} - interface-peer {e3 n4} - interface-peer {e4 n5} - interface-peer {e5 n6} - interface-peer {e6 n7} - interface-peer {e7 n8} - interface-peer {e8 n9} - interface-peer {e9 n10} - custom-config { - custom-config-id ns2script - custom-command {10 3 11 10 10} - config { - file=sample4.scen - refresh_ms=50 - loop=1 - autostart=5 - map= - } - } - custom-config { - custom-config-id basic_range - custom-command {3 3 9 9 9} - config { - range=200 - bandwidth=54000000 - jitter=0 - delay=50000 - error=0 - } - } -} - -link l1 { - nodes {n11 n1} - bandwidth 54000000 - delay 50000 -} - -link l2 { - nodes {n11 n2} - bandwidth 54000000 - delay 50000 -} - -link l3 { - nodes {n11 n3} - bandwidth 54000000 - delay 50000 -} - -link l4 { - nodes {n11 n4} - bandwidth 54000000 - delay 50000 -} - -link l5 { - nodes {n11 n5} - bandwidth 54000000 - delay 50000 -} - -link l6 { - nodes {n11 n6} - bandwidth 54000000 - delay 50000 -} - -link l7 { - nodes {n11 n7} - bandwidth 54000000 - delay 50000 -} - -link l8 { - nodes {n11 n8} - bandwidth 54000000 - delay 50000 -} - -link l9 { - nodes {n11 n9} - bandwidth 54000000 - delay 50000 -} - -link l10 { - nodes {n11 n10} - bandwidth 54000000 - delay 50000 -} - -canvas c1 { - name {Canvas1} - wallpaper-style {upperleft} - wallpaper {sample4-bg.jpg} - size {1000 750} -} - -option global { - interface_names no - ip_addresses yes - ipv6_addresses yes - node_labels yes - link_labels yes - show_api no - background_images no - annotations yes - grid no - traffic_start 0 -} - -option session { -} - diff --git a/gui/configs/sample4.scen b/gui/configs/sample4.scen deleted file mode 100644 index 939176e7..00000000 --- a/gui/configs/sample4.scen +++ /dev/null @@ -1,2791 +0,0 @@ -$node_(1) set X_ 196.387421 -$node_(1) set Y_ 462.134022 -$ns_ at 0.000000 "$node_(1) setdest 196.387421 462.134022 1.000000" -$ns_ at 0.000000 "$node_(1) setdest 195.956911 462.201568 0.435777" -$node_(2) set X_ 108.414716 -$node_(2) set Y_ 393.160360 -$ns_ at 0.000000 "$node_(2) setdest 108.414716 393.160360 1.000000" -$ns_ at 0.000000 "$node_(2) setdest 108.686466 392.778045 0.469055" -$node_(3) set X_ 14.254378 -$node_(3) set Y_ 541.257030 -$ns_ at 0.000000 "$node_(3) setdest 14.254378 541.257030 1.000000" -$ns_ at 0.000000 "$node_(3) setdest 14.839150 541.372844 0.596131" -$node_(4) set X_ 41.851670 -$node_(4) set Y_ 545.867138 -$ns_ at 0.000000 "$node_(4) setdest 41.851670 545.867138 1.000000" -$ns_ at 0.000000 "$node_(4) setdest 42.442273 545.926217 0.593550" -$node_(5) set X_ 182.809226 -$node_(5) set Y_ 513.055969 -$ns_ at 0.000000 "$node_(5) setdest 182.809226 513.055969 1.000000" -$ns_ at 0.000000 "$node_(5) setdest 183.335280 513.337339 0.596575" -$node_(6) set X_ 122.027997 -$node_(6) set Y_ 524.087717 -$ns_ at 0.000000 "$node_(6) setdest 122.027997 524.087717 1.000000" -$ns_ at 0.000000 "$node_(6) setdest 122.475860 524.470641 0.589248" -$node_(7) set X_ 186.692167 -$node_(7) set Y_ 453.103964 -$ns_ at 0.000000 "$node_(7) setdest 186.692167 453.103964 1.000000" -$ns_ at 0.000000 "$node_(7) setdest 186.362331 453.043815 0.335275" -$node_(8) set X_ 6.841010 -$node_(8) set Y_ 411.004614 -$ns_ at 0.000000 "$node_(8) setdest 6.841010 411.004614 1.000000" -$ns_ at 0.000000 "$node_(8) setdest 6.715910 410.970880 0.129569" -$node_(9) set X_ 180.514289 -$node_(9) set Y_ 395.901964 -$ns_ at 0.000000 "$node_(9) setdest 180.514289 395.901964 1.000000" -$ns_ at 0.000000 "$node_(9) setdest 180.863640 396.303766 0.532438" -$node_(10) set X_ 148.853602 -$node_(10) set Y_ 357.991260 -$ns_ at 0.000000 "$node_(10) setdest 148.853602 357.991260 1.000000" -$ns_ at 0.000000 "$node_(10) setdest 148.959253 358.166829 0.204906" - -$ns_ at 1.000000 "$node_(1) setdest 194.187758 463.051431 1.962694" -$ns_ at 1.000000 "$node_(2) setdest 109.321754 390.842582 2.037058" -$ns_ at 1.000000 "$node_(3) setdest 16.393600 542.808055 2.115690" -$ns_ at 1.000000 "$node_(4) setdest 44.634359 546.049079 2.195526" -$ns_ at 1.000000 "$node_(5) setdest 184.328928 515.246522 2.152281" -$ns_ at 1.000000 "$node_(6) setdest 123.835691 526.192539 2.194099" -$ns_ at 1.000000 "$node_(7) setdest 184.877733 452.038170 1.793140" -$ns_ at 1.000000 "$node_(8) setdest 6.671562 410.117567 0.854465" -$ns_ at 1.000000 "$node_(9) setdest 181.894113 398.159435 2.122590" -$ns_ at 1.000000 "$node_(10) setdest 148.870931 359.695988 1.531708" - -$ns_ at 2.000000 "$node_(1) setdest 190.851655 464.311512 3.566145" -$ns_ at 2.000000 "$node_(2) setdest 110.783099 387.546466 3.605539" -$ns_ at 2.000000 "$node_(3) setdest 14.881262 545.183484 2.815996" -$ns_ at 2.000000 "$node_(4) setdest 48.394729 546.584695 3.798324" -$ns_ at 2.000000 "$node_(5) setdest 184.473917 519.006641 3.762914" -$ns_ at 2.000000 "$node_(6) setdest 126.386821 528.676353 3.560561" -$ns_ at 2.000000 "$node_(7) setdest 182.160868 450.006458 3.392523" -$ns_ at 2.000000 "$node_(8) setdest 8.577394 409.839307 1.926038" -$ns_ at 2.000000 "$node_(9) setdest 182.309184 401.800750 3.664895" -$ns_ at 2.000000 "$node_(10) setdest 149.229189 362.797090 3.121727" - -$ns_ at 3.000000 "$node_(1) setdest 185.998912 466.082945 5.165955" -$ns_ at 3.000000 "$node_(2) setdest 114.977824 384.500577 5.183932" -$ns_ at 3.000000 "$node_(3) setdest 12.849462 546.572220 2.461056" -$ns_ at 3.000000 "$node_(4) setdest 52.522431 543.493688 5.156767" -$ns_ at 3.000000 "$node_(5) setdest 181.227267 523.091806 5.218171" -$ns_ at 3.000000 "$node_(6) setdest 122.849749 526.513462 4.145958" -$ns_ at 3.000000 "$node_(7) setdest 178.377101 446.748671 4.993003" -$ns_ at 3.000000 "$node_(8) setdest 11.957948 411.081133 3.601427" -$ns_ at 3.000000 "$node_(9) setdest 179.694536 406.348826 5.246083" -$ns_ at 3.000000 "$node_(10) setdest 150.721736 367.286506 4.731021" - -$ns_ at 4.000000 "$node_(1) setdest 179.555767 468.148449 6.766123" -$ns_ at 4.000000 "$node_(2) setdest 121.705230 383.835205 6.760230" -$ns_ at 4.000000 "$node_(3) setdest 12.743213 545.655478 0.922878" -$ns_ at 4.000000 "$node_(4) setdest 54.718112 536.856974 6.990493" -$ns_ at 4.000000 "$node_(5) setdest 174.581069 521.988831 6.737099" -$ns_ at 4.000000 "$node_(6) setdest 117.358177 524.776868 5.759612" -$ns_ at 4.000000 "$node_(7) setdest 173.583229 442.224357 6.591709" -$ns_ at 4.000000 "$node_(8) setdest 16.085272 414.253650 5.205734" -$ns_ at 4.000000 "$node_(9) setdest 174.174132 410.497488 6.905523" -$ns_ at 4.000000 "$node_(10) setdest 152.442894 373.377115 6.329131" - -$ns_ at 5.000000 "$node_(1) setdest 184.255964 467.324102 4.771939" -$ns_ at 5.000000 "$node_(2) setdest 130.096253 384.724742 8.438041" -$ns_ at 5.000000 "$node_(3) setdest 13.104636 545.386686 0.450418" -$ns_ at 5.000000 "$node_(4) setdest 60.821055 533.607888 6.913933" -$ns_ at 5.000000 "$node_(5) setdest 176.727658 522.545813 2.217673" -$ns_ at 5.000000 "$node_(6) setdest 109.928718 524.861347 7.429940" -$ns_ at 5.000000 "$node_(7) setdest 168.331832 435.943930 8.186631" -$ns_ at 5.000000 "$node_(8) setdest 20.338476 419.569962 6.808298" -$ns_ at 5.000000 "$node_(9) setdest 166.303912 413.725191 8.506376" -$ns_ at 5.000000 "$node_(10) setdest 153.598648 381.217946 7.925553" - -$ns_ at 6.000000 "$node_(1) setdest 190.713020 468.199291 6.516097" -$ns_ at 6.000000 "$node_(2) setdest 140.041968 386.083359 10.038083" -$ns_ at 6.000000 "$node_(3) setdest 15.010480 545.397474 1.905875" -$ns_ at 6.000000 "$node_(4) setdest 69.199175 531.278561 8.695899" -$ns_ at 6.000000 "$node_(5) setdest 180.271997 521.405130 3.723372" -$ns_ at 6.000000 "$node_(6) setdest 100.969155 523.987540 9.002072" -$ns_ at 6.000000 "$node_(7) setdest 162.840946 427.835646 9.792553" -$ns_ at 6.000000 "$node_(8) setdest 24.574187 426.845069 8.418339" -$ns_ at 6.000000 "$node_(9) setdest 156.473605 416.105660 10.114424" -$ns_ at 6.000000 "$node_(10) setdest 153.809976 390.743972 9.528370" - -$ns_ at 7.000000 "$node_(1) setdest 198.802940 468.836289 8.114961" -$ns_ at 7.000000 "$node_(2) setdest 151.520674 388.001681 11.637897" -$ns_ at 7.000000 "$node_(3) setdest 18.516288 545.400428 3.505809" -$ns_ at 7.000000 "$node_(4) setdest 79.188417 528.784398 10.295912" -$ns_ at 7.000000 "$node_(5) setdest 185.412195 520.020244 5.323489" -$ns_ at 7.000000 "$node_(6) setdest 91.080154 520.135759 10.612660" -$ns_ at 7.000000 "$node_(7) setdest 157.194066 417.952547 11.382569" -$ns_ at 7.000000 "$node_(8) setdest 29.470473 435.584536 10.017580" -$ns_ at 7.000000 "$node_(9) setdest 144.909476 418.020989 11.721670" -$ns_ at 7.000000 "$node_(10) setdest 154.204220 401.865406 11.128419" - -$ns_ at 8.000000 "$node_(1) setdest 208.501664 469.415232 9.715988" -$ns_ at 8.000000 "$node_(2) setdest 164.443430 390.863715 13.235894" -$ns_ at 8.000000 "$node_(3) setdest 23.619197 545.235409 5.105577" -$ns_ at 8.000000 "$node_(4) setdest 90.784905 526.131143 11.896146" -$ns_ at 8.000000 "$node_(5) setdest 192.096154 518.214428 6.923603" -$ns_ at 8.000000 "$node_(6) setdest 80.107574 514.731340 12.231323" -$ns_ at 8.000000 "$node_(7) setdest 153.494434 405.549908 12.942672" -$ns_ at 8.000000 "$node_(8) setdest 34.279206 446.159167 11.616658" -$ns_ at 8.000000 "$node_(9) setdest 131.868827 420.741097 13.321318" -$ns_ at 8.000000 "$node_(10) setdest 155.452554 414.535462 12.731405" - -$ns_ at 9.000000 "$node_(1) setdest 219.760670 470.533402 11.314394" -$ns_ at 9.000000 "$node_(2) setdest 178.682089 395.031168 14.836006" -$ns_ at 9.000000 "$node_(3) setdest 30.308442 544.767661 6.705579" -$ns_ at 9.000000 "$node_(4) setdest 103.964771 523.226201 13.496205" -$ns_ at 9.000000 "$node_(5) setdest 200.282657 515.840475 8.523761" -$ns_ at 9.000000 "$node_(6) setdest 69.403546 506.039069 13.788828" -$ns_ at 9.000000 "$node_(7) setdest 157.365544 391.985292 14.106179" -$ns_ at 9.000000 "$node_(8) setdest 38.646714 458.620995 13.205010" -$ns_ at 9.000000 "$node_(9) setdest 117.255049 423.747093 14.919736" -$ns_ at 9.000000 "$node_(10) setdest 155.850673 428.857711 14.327781" - -$ns_ at 10.000000 "$node_(1) setdest 232.472738 472.803312 12.913139" -$ns_ at 10.000000 "$node_(2) setdest 194.127048 400.653131 16.436339" -$ns_ at 10.000000 "$node_(3) setdest 38.581962 544.035935 8.305815" -$ns_ at 10.000000 "$node_(4) setdest 118.685377 519.880090 15.096115" -$ns_ at 10.000000 "$node_(5) setdest 210.050487 513.181447 10.123286" -$ns_ at 10.000000 "$node_(6) setdest 59.302514 494.374293 15.430420" -$ns_ at 10.000000 "$node_(7) setdest 169.643190 381.472758 16.163353" -$ns_ at 10.000000 "$node_(8) setdest 40.877385 473.255023 14.803063" -$ns_ at 10.000000 "$node_(9) setdest 100.860701 425.784585 16.520473" -$ns_ at 10.000000 "$node_(10) setdest 154.521863 444.723981 15.921817" - -$ns_ at 11.000000 "$node_(1) setdest 246.478612 476.598268 14.510900" -$ns_ at 11.000000 "$node_(2) setdest 210.951195 407.159256 18.038337" -$ns_ at 11.000000 "$node_(3) setdest 48.438708 543.050999 9.905834" -$ns_ at 11.000000 "$node_(4) setdest 134.861031 515.746212 16.695530" -$ns_ at 11.000000 "$node_(5) setdest 221.527307 510.799257 11.721444" -$ns_ at 11.000000 "$node_(6) setdest 49.457411 480.494289 17.017067" -$ns_ at 11.000000 "$node_(7) setdest 180.598709 367.456279 17.790028" -$ns_ at 11.000000 "$node_(8) setdest 39.538357 489.562934 16.362792" -$ns_ at 11.000000 "$node_(9) setdest 83.020566 428.952409 18.119203" -$ns_ at 11.000000 "$node_(10) setdest 151.821820 462.044995 17.530195" - -$ns_ at 12.000000 "$node_(1) setdest 261.629729 482.087033 16.114679" -$ns_ at 12.000000 "$node_(2) setdest 229.245871 414.133015 19.578776" -$ns_ at 12.000000 "$node_(3) setdest 59.881260 541.845844 11.505842" -$ns_ at 12.000000 "$node_(4) setdest 152.423948 510.621388 18.295352" -$ns_ at 12.000000 "$node_(5) setdest 234.527040 507.889458 13.321411" -$ns_ at 12.000000 "$node_(6) setdest 40.966307 463.915095 18.627091" -$ns_ at 12.000000 "$node_(7) setdest 185.609934 356.000078 12.504276" -$ns_ at 12.000000 "$node_(8) setdest 30.885561 505.096833 17.781252" -$ns_ at 12.000000 "$node_(9) setdest 63.625003 431.905828 19.619138" -$ns_ at 12.000000 "$node_(10) setdest 146.050593 480.248923 19.096860" - -$ns_ at 13.000000 "$node_(1) setdest 278.393127 487.812114 17.714064" -$ns_ at 13.000000 "$node_(2) setdest 248.189196 420.533024 19.995242" -$ns_ at 13.000000 "$node_(3) setdest 72.938784 540.726815 13.105387" -$ns_ at 13.000000 "$node_(4) setdest 171.235204 504.613101 19.747478" -$ns_ at 13.000000 "$node_(5) setdest 249.025623 504.352557 14.923758" -$ns_ at 13.000000 "$node_(6) setdest 30.880946 446.819434 19.848832" -$ns_ at 13.000000 "$node_(7) setdest 184.657559 357.512927 1.787661" -$ns_ at 13.000000 "$node_(8) setdest 14.206642 507.144149 16.804101" -$ns_ at 13.000000 "$node_(9) setdest 44.005432 428.793757 19.864857" -$ns_ at 13.000000 "$node_(10) setdest 132.025204 492.782747 18.809792" - -$ns_ at 14.000000 "$node_(1) setdest 297.118073 492.525399 19.309031" -$ns_ at 14.000000 "$node_(2) setdest 267.609451 425.285611 19.993334" -$ns_ at 14.000000 "$node_(3) setdest 87.624368 539.967665 14.705193" -$ns_ at 14.000000 "$node_(4) setdest 190.013797 497.736791 19.997979" -$ns_ at 14.000000 "$node_(5) setdest 265.067340 500.390654 16.523722" -$ns_ at 14.000000 "$node_(6) setdest 22.990420 428.699834 19.763105" -$ns_ at 14.000000 "$node_(7) setdest 182.833109 360.375049 3.394165" -$ns_ at 14.000000 "$node_(8) setdest 11.626599 492.727976 14.645227" -$ns_ at 14.000000 "$node_(9) setdest 26.668091 418.946242 19.938830" -$ns_ at 14.000000 "$node_(10) setdest 123.299921 486.526765 10.736287" - -$ns_ at 15.000000 "$node_(1) setdest 316.902786 495.404161 19.993052" -$ns_ at 15.000000 "$node_(2) setdest 287.409944 428.039581 19.991095" -$ns_ at 15.000000 "$node_(3) setdest 103.927453 539.724173 16.304903" -$ns_ at 15.000000 "$node_(4) setdest 208.447762 489.981073 19.999056" -$ns_ at 15.000000 "$node_(5) setdest 282.569771 495.688589 18.123038" -$ns_ at 15.000000 "$node_(6) setdest 32.358017 413.328574 18.000764" -$ns_ at 15.000000 "$node_(7) setdest 180.522818 364.802409 4.993892" -$ns_ at 15.000000 "$node_(8) setdest 17.250049 478.879349 14.946828" -$ns_ at 15.000000 "$node_(9) setdest 19.305071 401.972918 18.501562" -$ns_ at 15.000000 "$node_(10) setdest 122.308127 476.484801 10.090823" - -$ns_ at 16.000000 "$node_(1) setdest 336.810376 497.321840 19.999742" -$ns_ at 16.000000 "$node_(2) setdest 307.390871 428.541832 19.987239" -$ns_ at 16.000000 "$node_(3) setdest 121.831706 539.952811 17.905713" -$ns_ at 16.000000 "$node_(4) setdest 227.120033 482.822730 19.997389" -$ns_ at 16.000000 "$node_(5) setdest 301.236586 489.579183 19.641151" -$ns_ at 16.000000 "$node_(6) setdest 46.948370 420.814042 16.398495" -$ns_ at 16.000000 "$node_(7) setdest 177.898557 370.854610 6.596658" -$ns_ at 16.000000 "$node_(8) setdest 30.672025 469.903968 16.146420" -$ns_ at 16.000000 "$node_(9) setdest 28.762169 396.296220 11.030031" -$ns_ at 16.000000 "$node_(10) setdest 119.039643 465.199922 11.748680" - -$ns_ at 17.000000 "$node_(1) setdest 356.723919 496.365486 19.936494" -$ns_ at 17.000000 "$node_(2) setdest 327.327857 427.009656 19.995774" -$ns_ at 17.000000 "$node_(3) setdest 141.310307 540.046329 19.478826" -$ns_ at 17.000000 "$node_(4) setdest 246.180029 476.772114 19.997335" -$ns_ at 17.000000 "$node_(5) setdest 320.056175 482.812486 19.999128" -$ns_ at 17.000000 "$node_(6) setdest 50.106366 436.546462 16.046245" -$ns_ at 17.000000 "$node_(7) setdest 175.044087 378.536882 8.195444" -$ns_ at 17.000000 "$node_(8) setdest 48.497193 467.760705 17.953557" -$ns_ at 17.000000 "$node_(9) setdest 38.413556 402.420929 11.430719" -$ns_ at 17.000000 "$node_(10) setdest 114.693546 452.584125 13.343422" - -$ns_ at 18.000000 "$node_(1) setdest 376.664288 496.703412 19.943231" -$ns_ at 18.000000 "$node_(2) setdest 346.945189 423.241158 19.976018" -$ns_ at 18.000000 "$node_(3) setdest 161.304062 539.571077 19.999402" -$ns_ at 18.000000 "$node_(4) setdest 265.558802 471.836704 19.997378" -$ns_ at 18.000000 "$node_(5) setdest 338.448532 474.970956 19.994209" -$ns_ at 18.000000 "$node_(6) setdest 54.288270 451.088370 15.131272" -$ns_ at 18.000000 "$node_(7) setdest 172.073073 387.868710 9.793362" -$ns_ at 18.000000 "$node_(8) setdest 67.655050 465.445201 19.297281" -$ns_ at 18.000000 "$node_(9) setdest 49.709921 408.850378 12.997910" -$ns_ at 18.000000 "$node_(10) setdest 114.878490 437.804560 14.780722" - -$ns_ at 19.000000 "$node_(1) setdest 396.221169 500.830441 19.987596" -$ns_ at 19.000000 "$node_(2) setdest 364.910034 414.653995 19.911680" -$ns_ at 19.000000 "$node_(3) setdest 181.265387 538.352550 19.998483" -$ns_ at 19.000000 "$node_(4) setdest 285.155517 467.848358 19.998454" -$ns_ at 19.000000 "$node_(5) setdest 356.023480 465.435990 19.994859" -$ns_ at 19.000000 "$node_(6) setdest 59.822992 466.650093 16.516669" -$ns_ at 19.000000 "$node_(7) setdest 170.484709 399.136223 11.378916" -$ns_ at 19.000000 "$node_(8) setdest 84.504418 457.452149 18.649130" -$ns_ at 19.000000 "$node_(9) setdest 63.410973 414.003103 14.637944" -$ns_ at 19.000000 "$node_(10) setdest 124.979075 425.189235 16.160700" - -$ns_ at 20.000000 "$node_(1) setdest 414.959731 507.703787 19.959373" -$ns_ at 20.000000 "$node_(2) setdest 380.876777 402.624609 19.991073" -$ns_ at 20.000000 "$node_(3) setdest 201.169537 536.405487 19.999156" -$ns_ at 20.000000 "$node_(4) setdest 304.943032 464.963448 19.996711" -$ns_ at 20.000000 "$node_(5) setdest 372.787924 454.543588 19.992274" -$ns_ at 20.000000 "$node_(6) setdest 70.020001 481.532051 18.040280" -$ns_ at 20.000000 "$node_(7) setdest 170.249709 412.128831 12.994733" -$ns_ at 20.000000 "$node_(8) setdest 93.638312 442.200433 17.777595" -$ns_ at 20.000000 "$node_(9) setdest 78.562641 419.829513 16.233302" -$ns_ at 20.000000 "$node_(10) setdest 142.579167 424.108364 17.633250" - -$ns_ at 21.000000 "$node_(1) setdest 429.209520 521.348596 19.729097" -$ns_ at 21.000000 "$node_(2) setdest 397.102346 390.982114 19.970398" -$ns_ at 21.000000 "$node_(3) setdest 220.965783 533.570502 19.998213" -$ns_ at 21.000000 "$node_(4) setdest 324.852277 463.066604 19.999402" -$ns_ at 21.000000 "$node_(5) setdest 388.665021 442.382765 19.999195" -$ns_ at 21.000000 "$node_(6) setdest 86.716919 491.602850 19.498924" -$ns_ at 21.000000 "$node_(7) setdest 169.847567 426.715435 14.592147" -$ns_ at 21.000000 "$node_(8) setdest 97.710618 423.903178 18.744951" -$ns_ at 21.000000 "$node_(9) setdest 95.770736 424.404680 17.805917" -$ns_ at 21.000000 "$node_(10) setdest 161.156216 426.885868 18.783538" - -$ns_ at 22.000000 "$node_(1) setdest 430.473009 540.114895 18.808785" -$ns_ at 22.000000 "$node_(2) setdest 416.281990 386.251137 19.754515" -$ns_ at 22.000000 "$node_(3) setdest 240.636740 529.963240 19.998972" -$ns_ at 22.000000 "$node_(4) setdest 344.804967 461.695943 19.999714" -$ns_ at 22.000000 "$node_(5) setdest 405.064820 430.950640 19.991171" -$ns_ at 22.000000 "$node_(6) setdest 105.990772 495.255793 19.616967" -$ns_ at 22.000000 "$node_(7) setdest 167.385262 442.713557 16.186502" -$ns_ at 22.000000 "$node_(8) setdest 103.162186 405.249727 19.433755" -$ns_ at 22.000000 "$node_(9) setdest 115.163365 425.341594 19.415248" -$ns_ at 22.000000 "$node_(10) setdest 179.829755 431.479678 19.230293" - -$ns_ at 23.000000 "$node_(1) setdest 415.678953 543.404262 15.155331" -$ns_ at 23.000000 "$node_(2) setdest 435.187649 392.319327 19.855651" -$ns_ at 23.000000 "$node_(3) setdest 260.149758 525.579574 19.999361" -$ns_ at 23.000000 "$node_(4) setdest 364.757106 460.319210 19.999581" -$ns_ at 23.000000 "$node_(5) setdest 423.001973 422.178788 19.967143" -$ns_ at 23.000000 "$node_(6) setdest 123.055577 489.304227 18.072872" -$ns_ at 23.000000 "$node_(7) setdest 163.127378 459.989903 17.793305" -$ns_ at 23.000000 "$node_(8) setdest 100.668183 387.349777 18.072860" -$ns_ at 23.000000 "$node_(9) setdest 134.745751 421.781273 19.903410" -$ns_ at 23.000000 "$node_(10) setdest 192.254617 443.561434 17.330494" - -$ns_ at 24.000000 "$node_(1) setdest 406.160525 540.747525 9.882242" -$ns_ at 24.000000 "$node_(2) setdest 449.530999 405.814727 19.694098" -$ns_ at 24.000000 "$node_(3) setdest 279.642597 521.105699 19.999658" -$ns_ at 24.000000 "$node_(4) setdest 384.596757 457.826144 19.995677" -$ns_ at 24.000000 "$node_(5) setdest 442.473674 417.861163 19.944649" -$ns_ at 24.000000 "$node_(6) setdest 134.199736 475.485411 17.752521" -$ns_ at 24.000000 "$node_(7) setdest 160.485918 479.161017 19.352233" -$ns_ at 24.000000 "$node_(8) setdest 89.621312 373.738896 17.529673" -$ns_ at 24.000000 "$node_(9) setdest 151.033770 410.479558 19.824942" -$ns_ at 24.000000 "$node_(10) setdest 187.121532 459.497919 16.742763" - -$ns_ at 25.000000 "$node_(1) setdest 409.358404 540.925330 3.202818" -$ns_ at 25.000000 "$node_(2) setdest 458.447905 423.373342 19.693049" -$ns_ at 25.000000 "$node_(3) setdest 299.300679 517.470033 19.991455" -$ns_ at 25.000000 "$node_(4) setdest 404.207394 453.940099 19.991959" -$ns_ at 25.000000 "$node_(5) setdest 462.251199 419.968804 19.889511" -$ns_ at 25.000000 "$node_(6) setdest 137.331615 457.789340 17.971076" -$ns_ at 25.000000 "$node_(7) setdest 163.430534 498.853924 19.911840" -$ns_ at 25.000000 "$node_(8) setdest 77.657124 359.369184 18.698407" -$ns_ at 25.000000 "$node_(9) setdest 164.260780 395.480602 19.998061" -$ns_ at 25.000000 "$node_(10) setdest 184.039441 474.459839 15.276071" - -$ns_ at 26.000000 "$node_(1) setdest 413.898194 539.190016 4.860144" -$ns_ at 26.000000 "$node_(2) setdest 472.249585 436.422368 18.993774" -$ns_ at 26.000000 "$node_(3) setdest 319.267001 516.756455 19.979069" -$ns_ at 26.000000 "$node_(4) setdest 422.915330 447.007413 19.951166" -$ns_ at 26.000000 "$node_(5) setdest 477.938097 430.823097 19.076018" -$ns_ at 26.000000 "$node_(6) setdest 140.850027 439.467490 18.656618" -$ns_ at 26.000000 "$node_(7) setdest 173.893091 515.708878 19.838210" -$ns_ at 26.000000 "$node_(8) setdest 62.077819 360.254769 15.604455" -$ns_ at 26.000000 "$node_(9) setdest 179.407140 382.455787 19.976437" -$ns_ at 26.000000 "$node_(10) setdest 185.534654 490.826466 16.434784" - -$ns_ at 27.000000 "$node_(1) setdest 419.345130 535.713495 6.461836" -$ns_ at 27.000000 "$node_(2) setdest 485.947996 449.586921 18.998734" -$ns_ at 27.000000 "$node_(3) setdest 339.044367 519.533812 19.971427" -$ns_ at 27.000000 "$node_(4) setdest 438.826119 435.000710 19.932740" -$ns_ at 27.000000 "$node_(5) setdest 473.471267 424.832381 7.472701" -$ns_ at 27.000000 "$node_(6) setdest 135.925019 421.904243 18.240706" -$ns_ at 27.000000 "$node_(7) setdest 186.435379 531.166580 19.906018" -$ns_ at 27.000000 "$node_(8) setdest 57.119411 374.294350 14.889447" -$ns_ at 27.000000 "$node_(9) setdest 192.143744 373.866180 15.362370" -$ns_ at 27.000000 "$node_(10) setdest 185.569664 508.866862 18.040430" - -$ns_ at 28.000000 "$node_(1) setdest 425.125458 530.097247 8.059430" -$ns_ at 28.000000 "$node_(2) setdest 493.049174 466.718934 18.545421" -$ns_ at 28.000000 "$node_(3) setdest 358.303469 524.898542 19.992332" -$ns_ at 28.000000 "$node_(4) setdest 450.847143 419.080495 19.948891" -$ns_ at 28.000000 "$node_(5) setdest 466.757695 428.118270 7.474565" -$ns_ at 28.000000 "$node_(6) setdest 128.600444 404.149699 19.206072" -$ns_ at 28.000000 "$node_(7) setdest 190.977325 534.505975 5.637449" -$ns_ at 28.000000 "$node_(8) setdest 50.549060 388.112799 15.300949" -$ns_ at 28.000000 "$node_(9) setdest 191.629729 374.111864 0.569712" -$ns_ at 28.000000 "$node_(10) setdest 181.834449 527.981880 19.476543" - -$ns_ at 29.000000 "$node_(1) setdest 431.663417 522.972367 9.669997" -$ns_ at 29.000000 "$node_(2) setdest 500.999975 483.730217 18.777619" -$ns_ at 29.000000 "$node_(3) setdest 378.191935 526.327594 19.939741" -$ns_ at 29.000000 "$node_(4) setdest 458.446194 400.622892 19.960678" -$ns_ at 29.000000 "$node_(5) setdest 461.699992 435.699961 9.113857" -$ns_ at 29.000000 "$node_(6) setdest 122.697249 385.435598 19.623081" -$ns_ at 29.000000 "$node_(7) setdest 183.725190 529.813555 8.637839" -$ns_ at 29.000000 "$node_(8) setdest 38.920729 400.522858 17.006694" -$ns_ at 29.000000 "$node_(9) setdest 190.433575 375.757305 2.034271" -$ns_ at 29.000000 "$node_(10) setdest 169.338208 541.367431 18.311990" - -$ns_ at 30.000000 "$node_(1) setdest 440.262619 515.700706 11.261586" -$ns_ at 30.000000 "$node_(2) setdest 500.811238 501.442061 17.712850" -$ns_ at 30.000000 "$node_(3) setdest 397.439899 521.321197 19.888392" -$ns_ at 30.000000 "$node_(4) setdest 464.984365 381.792314 19.933348" -$ns_ at 30.000000 "$node_(5) setdest 458.178246 445.894374 10.785581" -$ns_ at 30.000000 "$node_(6) setdest 117.489012 366.365374 19.768641" -$ns_ at 30.000000 "$node_(7) setdest 174.343370 525.704745 10.242113" -$ns_ at 30.000000 "$node_(8) setdest 24.090640 411.759729 18.606419" -$ns_ at 30.000000 "$node_(9) setdest 187.828459 378.293814 3.636002" -$ns_ at 30.000000 "$node_(10) setdest 152.821188 535.712898 17.458113" - -$ns_ at 31.000000 "$node_(1) setdest 451.405438 509.290896 12.854885" -$ns_ at 31.000000 "$node_(2) setdest 491.700571 517.036414 18.060678" -$ns_ at 31.000000 "$node_(3) setdest 413.171544 509.240492 19.835022" -$ns_ at 31.000000 "$node_(4) setdest 480.918024 372.117997 18.640651" -$ns_ at 31.000000 "$node_(5) setdest 456.464076 458.133299 12.358384" -$ns_ at 31.000000 "$node_(6) setdest 116.659357 360.796271 5.630563" -$ns_ at 31.000000 "$node_(7) setdest 164.951174 518.581014 11.788168" -$ns_ at 31.000000 "$node_(8) setdest 8.936318 423.738537 19.316970" -$ns_ at 31.000000 "$node_(9) setdest 184.393707 382.243473 5.234245" -$ns_ at 31.000000 "$node_(10) setdest 139.669561 526.256345 16.198509" - -$ns_ at 32.000000 "$node_(1) setdest 464.725397 503.658293 14.461934" -$ns_ at 32.000000 "$node_(2) setdest 479.083065 531.312050 19.052435" -$ns_ at 32.000000 "$node_(3) setdest 421.035268 491.095019 19.776156" -$ns_ at 32.000000 "$node_(4) setdest 490.592449 383.745440 15.125870" -$ns_ at 32.000000 "$node_(5) setdest 456.762816 472.118321 13.988212" -$ns_ at 32.000000 "$node_(6) setdest 116.717596 368.408818 7.612770" -$ns_ at 32.000000 "$node_(7) setdest 156.422329 508.202089 13.433662" -$ns_ at 32.000000 "$node_(8) setdest 11.745791 420.358995 4.394820" -$ns_ at 32.000000 "$node_(9) setdest 180.640795 387.951388 6.831153" -$ns_ at 32.000000 "$node_(10) setdest 126.512644 516.165541 16.580976" - -$ns_ at 33.000000 "$node_(1) setdest 480.312677 499.837211 16.048799" -$ns_ at 33.000000 "$node_(2) setdest 464.103605 542.498822 18.695670" -$ns_ at 33.000000 "$node_(3) setdest 415.566812 472.559995 19.324884" -$ns_ at 33.000000 "$node_(4) setdest 492.444864 398.380771 14.752097" -$ns_ at 33.000000 "$node_(5) setdest 454.811405 487.581008 15.585336" -$ns_ at 33.000000 "$node_(6) setdest 117.946938 377.618577 9.291444" -$ns_ at 33.000000 "$node_(7) setdest 147.983933 495.750139 15.041861" -$ns_ at 33.000000 "$node_(8) setdest 16.630884 421.422038 4.999419" -$ns_ at 33.000000 "$node_(9) setdest 176.046756 395.024567 8.434160" -$ns_ at 33.000000 "$node_(10) setdest 114.664512 502.380973 18.176703" - -$ns_ at 34.000000 "$node_(1) setdest 497.919072 498.422291 17.663158" -$ns_ at 34.000000 "$node_(2) setdest 467.653826 541.046000 3.835981" -$ns_ at 34.000000 "$node_(3) setdest 405.186017 464.081358 13.403290" -$ns_ at 34.000000 "$node_(4) setdest 490.175129 414.347121 16.126873" -$ns_ at 34.000000 "$node_(5) setdest 451.792079 504.480069 17.166671" -$ns_ at 34.000000 "$node_(6) setdest 121.883147 387.777476 10.894815" -$ns_ at 34.000000 "$node_(7) setdest 138.114893 482.374086 16.622777" -$ns_ at 34.000000 "$node_(8) setdest 22.994022 423.191629 6.604618" -$ns_ at 34.000000 "$node_(9) setdest 170.044883 403.068060 10.035948" -$ns_ at 34.000000 "$node_(10) setdest 107.004140 484.410586 19.534997" - -$ns_ at 35.000000 "$node_(1) setdest 517.152845 499.275087 19.252670" -$ns_ at 35.000000 "$node_(2) setdest 469.760083 536.639542 4.883974" -$ns_ at 35.000000 "$node_(3) setdest 406.522026 464.499466 1.399905" -$ns_ at 35.000000 "$node_(4) setdest 486.192447 431.664927 17.769867" -$ns_ at 35.000000 "$node_(5) setdest 441.963945 520.294525 18.619593" -$ns_ at 35.000000 "$node_(6) setdest 124.346991 399.961894 12.431032" -$ns_ at 35.000000 "$node_(7) setdest 124.150809 470.712739 18.192929" -$ns_ at 35.000000 "$node_(8) setdest 30.684577 426.047417 8.203668" -$ns_ at 35.000000 "$node_(9) setdest 162.654904 412.053873 11.634287" -$ns_ at 35.000000 "$node_(10) setdest 107.841118 465.759378 18.669978" - -$ns_ at 36.000000 "$node_(1) setdest 536.528998 504.082029 19.963517" -$ns_ at 36.000000 "$node_(2) setdest 474.403635 532.108135 6.488160" -$ns_ at 36.000000 "$node_(3) setdest 409.528015 464.468428 3.006149" -$ns_ at 36.000000 "$node_(4) setdest 484.427652 450.881008 19.296950" -$ns_ at 36.000000 "$node_(5) setdest 426.470273 532.788799 19.903788" -$ns_ at 36.000000 "$node_(6) setdest 120.932715 413.505237 13.967084" -$ns_ at 36.000000 "$node_(7) setdest 105.532349 464.813463 19.530707" -$ns_ at 36.000000 "$node_(8) setdest 39.253080 430.783080 9.790084" -$ns_ at 36.000000 "$node_(9) setdest 153.536221 421.645072 13.234104" -$ns_ at 36.000000 "$node_(10) setdest 117.666134 450.695452 17.984794" - -$ns_ at 37.000000 "$node_(1) setdest 554.428542 512.921944 19.963411" -$ns_ at 37.000000 "$node_(2) setdest 481.127335 527.610678 8.089206" -$ns_ at 37.000000 "$node_(3) setdest 414.102043 465.013680 4.606412" -$ns_ at 37.000000 "$node_(4) setdest 489.773407 469.940100 19.794597" -$ns_ at 37.000000 "$node_(5) setdest 408.058188 532.100718 18.424937" -$ns_ at 37.000000 "$node_(6) setdest 109.012095 423.192684 15.360592" -$ns_ at 37.000000 "$node_(7) setdest 85.728992 467.102452 19.935205" -$ns_ at 37.000000 "$node_(8) setdest 48.361002 437.630220 11.394629" -$ns_ at 37.000000 "$node_(9) setdest 142.102893 431.075459 14.820701" -$ns_ at 37.000000 "$node_(10) setdest 131.161133 437.935237 18.572509" - -$ns_ at 38.000000 "$node_(1) setdest 566.932229 527.655226 19.323866" -$ns_ at 38.000000 "$node_(2) setdest 490.148231 524.075412 9.688895" -$ns_ at 38.000000 "$node_(3) setdest 420.185075 466.255244 6.208443" -$ns_ at 38.000000 "$node_(4) setdest 501.252538 485.927117 19.681340" -$ns_ at 38.000000 "$node_(5) setdest 405.981429 521.845202 10.463677" -$ns_ at 38.000000 "$node_(6) setdest 91.954174 422.557957 17.069726" -$ns_ at 38.000000 "$node_(7) setdest 66.578736 472.830545 19.988581" -$ns_ at 38.000000 "$node_(8) setdest 58.379443 445.916629 13.001297" -$ns_ at 38.000000 "$node_(9) setdest 128.348746 440.069498 16.433785" -$ns_ at 38.000000 "$node_(10) setdest 139.114132 421.205939 18.523488" - -$ns_ at 39.000000 "$node_(1) setdest 567.143596 529.512240 1.869004" -$ns_ at 39.000000 "$node_(2) setdest 501.202329 521.792270 11.287418" -$ns_ at 39.000000 "$node_(3) setdest 427.677364 468.446739 7.806218" -$ns_ at 39.000000 "$node_(4) setdest 511.141012 502.780491 19.540167" -$ns_ at 39.000000 "$node_(5) setdest 413.374406 514.767835 10.234513" -$ns_ at 39.000000 "$node_(6) setdest 75.493177 413.507199 18.785117" -$ns_ at 39.000000 "$node_(7) setdest 46.764183 471.773954 19.842703" -$ns_ at 39.000000 "$node_(8) setdest 69.942011 454.838968 14.604833" -$ns_ at 39.000000 "$node_(9) setdest 112.291115 448.251876 18.022176" -$ns_ at 39.000000 "$node_(10) setdest 141.846200 402.561193 18.843852" - -$ns_ at 40.000000 "$node_(1) setdest 564.578377 527.996748 2.979440" -$ns_ at 40.000000 "$node_(2) setdest 514.059687 520.805131 12.895197" -$ns_ at 40.000000 "$node_(3) setdest 436.538030 471.609166 9.408100" -$ns_ at 40.000000 "$node_(4) setdest 519.473141 520.208352 19.317213" -$ns_ at 40.000000 "$node_(5) setdest 419.858457 504.879506 11.824634" -$ns_ at 40.000000 "$node_(6) setdest 87.235668 420.830481 13.838951" -$ns_ at 40.000000 "$node_(7) setdest 64.203274 476.552061 18.081820" -$ns_ at 40.000000 "$node_(8) setdest 84.829204 454.481993 14.891472" -$ns_ at 40.000000 "$node_(9) setdest 125.059425 443.474044 13.632954" -$ns_ at 40.000000 "$node_(10) setdest 148.729503 397.886383 8.320679" - -$ns_ at 41.000000 "$node_(1) setdest 560.539286 525.794333 4.600531" -$ns_ at 41.000000 "$node_(2) setdest 528.559240 520.724740 14.499776" -$ns_ at 41.000000 "$node_(3) setdest 446.636223 475.986259 11.006019" -$ns_ at 41.000000 "$node_(4) setdest 526.125692 538.415388 19.384339" -$ns_ at 41.000000 "$node_(5) setdest 424.189640 492.212788 13.386743" -$ns_ at 41.000000 "$node_(6) setdest 102.775617 424.456016 15.957271" -$ns_ at 41.000000 "$node_(7) setdest 83.933552 478.414079 19.817945" -$ns_ at 41.000000 "$node_(8) setdest 101.442514 452.999884 16.679290" -$ns_ at 41.000000 "$node_(9) setdest 140.551926 441.300742 15.644194" -$ns_ at 41.000000 "$node_(10) setdest 158.699125 396.791989 10.029510" - -$ns_ at 42.000000 "$node_(1) setdest 554.946328 523.113767 6.202145" -$ns_ at 42.000000 "$node_(2) setdest 544.648492 520.084739 16.101976" -$ns_ at 42.000000 "$node_(3) setdest 457.867768 481.716252 12.608743" -$ns_ at 42.000000 "$node_(4) setdest 542.996006 542.160589 17.281030" -$ns_ at 42.000000 "$node_(5) setdest 427.836410 477.619041 15.042485" -$ns_ at 42.000000 "$node_(6) setdest 120.073180 427.461833 17.556783" -$ns_ at 42.000000 "$node_(7) setdest 103.908927 479.371110 19.998288" -$ns_ at 42.000000 "$node_(8) setdest 119.693903 451.998492 18.278840" -$ns_ at 42.000000 "$node_(9) setdest 157.508841 438.167173 17.244020" -$ns_ at 42.000000 "$node_(10) setdest 170.268449 395.614996 11.629039" - -$ns_ at 43.000000 "$node_(1) setdest 548.011229 519.540767 7.801405" -$ns_ at 43.000000 "$node_(2) setdest 559.640611 513.386833 16.420280" -$ns_ at 43.000000 "$node_(3) setdest 470.540438 488.142494 14.208911" -$ns_ at 43.000000 "$node_(4) setdest 557.442321 534.605141 16.302785" -$ns_ at 43.000000 "$node_(5) setdest 432.038134 461.515754 16.642426" -$ns_ at 43.000000 "$node_(6) setdest 139.110535 429.593024 19.156274" -$ns_ at 43.000000 "$node_(7) setdest 123.907121 479.374828 19.998194" -$ns_ at 43.000000 "$node_(8) setdest 139.427933 451.544210 19.739258" -$ns_ at 43.000000 "$node_(9) setdest 176.047394 434.787992 18.844013" -$ns_ at 43.000000 "$node_(10) setdest 183.465605 394.695269 13.229166" - -$ns_ at 44.000000 "$node_(1) setdest 540.245181 514.250782 9.396566" -$ns_ at 44.000000 "$node_(2) setdest 557.197334 501.679640 11.959430" -$ns_ at 44.000000 "$node_(3) setdest 484.194340 496.104414 15.805733" -$ns_ at 44.000000 "$node_(4) setdest 569.805764 524.976564 15.670489" -$ns_ at 44.000000 "$node_(5) setdest 437.187949 444.017164 18.240648" -$ns_ at 44.000000 "$node_(6) setdest 159.082551 430.599768 19.997374" -$ns_ at 44.000000 "$node_(7) setdest 143.880972 478.393510 19.997942" -$ns_ at 44.000000 "$node_(8) setdest 159.427822 451.554805 19.999892" -$ns_ at 44.000000 "$node_(9) setdest 195.825003 432.098619 19.959623" -$ns_ at 44.000000 "$node_(10) setdest 198.232049 393.331915 14.829248" - -$ns_ at 45.000000 "$node_(1) setdest 531.522089 507.546145 11.002022" -$ns_ at 45.000000 "$node_(2) setdest 547.805553 492.435892 13.177725" -$ns_ at 45.000000 "$node_(3) setdest 499.562490 504.256506 17.396455" -$ns_ at 45.000000 "$node_(4) setdest 586.131716 520.450839 16.941632" -$ns_ at 45.000000 "$node_(5) setdest 444.245357 425.600998 19.722124" -$ns_ at 45.000000 "$node_(6) setdest 179.081213 430.697528 19.998900" -$ns_ at 45.000000 "$node_(7) setdest 163.775015 476.359693 19.997735" -$ns_ at 45.000000 "$node_(8) setdest 179.427632 451.479451 19.999952" -$ns_ at 45.000000 "$node_(9) setdest 215.744509 430.326634 19.998166" -$ns_ at 45.000000 "$node_(10) setdest 214.511122 391.127338 16.427671" - -$ns_ at 46.000000 "$node_(1) setdest 521.224593 500.285353 12.599902" -$ns_ at 46.000000 "$node_(2) setdest 537.140911 482.188971 14.789658" -$ns_ at 46.000000 "$node_(3) setdest 517.239989 511.230267 19.003350" -$ns_ at 46.000000 "$node_(4) setdest 596.737679 531.230366 15.122323" -$ns_ at 46.000000 "$node_(5) setdest 450.567683 406.626744 19.999853" -$ns_ at 46.000000 "$node_(6) setdest 199.077088 430.293213 19.999963" -$ns_ at 46.000000 "$node_(7) setdest 183.547456 473.359299 19.998794" -$ns_ at 46.000000 "$node_(8) setdest 199.426772 451.293967 19.999999" -$ns_ at 46.000000 "$node_(9) setdest 235.727172 429.545275 19.997933" -$ns_ at 46.000000 "$node_(10) setdest 232.313482 388.287908 18.027380" - -$ns_ at 47.000000 "$node_(1) setdest 509.132728 492.839445 14.200519" -$ns_ at 47.000000 "$node_(2) setdest 529.956513 467.566241 16.292323" -$ns_ at 47.000000 "$node_(3) setdest 530.443547 512.706866 13.285868" -$ns_ at 47.000000 "$node_(4) setdest 593.888061 544.610217 13.679939" -$ns_ at 47.000000 "$node_(5) setdest 455.365546 387.217155 19.993791" -$ns_ at 47.000000 "$node_(6) setdest 219.066969 429.662345 19.999833" -$ns_ at 47.000000 "$node_(7) setdest 203.164862 469.479130 19.997458" -$ns_ at 47.000000 "$node_(8) setdest 219.417361 451.789967 19.996742" -$ns_ at 47.000000 "$node_(9) setdest 255.709496 428.728816 19.998997" -$ns_ at 47.000000 "$node_(10) setdest 251.796297 386.439234 19.570326" - -$ns_ at 48.000000 "$node_(1) setdest 494.811654 486.211110 15.780621" -$ns_ at 48.000000 "$node_(2) setdest 523.405915 450.824130 17.978004" -$ns_ at 48.000000 "$node_(3) setdest 527.369831 511.982215 3.157982" -$ns_ at 48.000000 "$node_(4) setdest 596.143329 540.896760 4.344652" -$ns_ at 48.000000 "$node_(5) setdest 452.127739 368.087344 19.401882" -$ns_ at 48.000000 "$node_(6) setdest 239.040183 428.633694 19.999686" -$ns_ at 48.000000 "$node_(7) setdest 222.507492 464.407083 19.996575" -$ns_ at 48.000000 "$node_(8) setdest 239.319828 453.699710 19.993882" -$ns_ at 48.000000 "$node_(9) setdest 275.658454 427.303064 19.999843" -$ns_ at 48.000000 "$node_(10) setdest 271.767272 385.393628 19.998328" - -$ns_ at 49.000000 "$node_(1) setdest 477.936814 482.029186 17.385301" -$ns_ at 49.000000 "$node_(2) setdest 511.589591 435.283606 19.522638" -$ns_ at 49.000000 "$node_(3) setdest 522.811495 510.411820 4.821262" -$ns_ at 49.000000 "$node_(4) setdest 596.364469 534.992612 5.908287" -$ns_ at 49.000000 "$node_(5) setdest 441.999585 365.539662 10.443668" -$ns_ at 49.000000 "$node_(6) setdest 259.000403 427.373742 19.999946" -$ns_ at 49.000000 "$node_(7) setdest 241.427668 457.938519 19.995384" -$ns_ at 49.000000 "$node_(8) setdest 258.949550 457.488811 19.992080" -$ns_ at 49.000000 "$node_(9) setdest 295.601472 425.794473 19.999995" -$ns_ at 49.000000 "$node_(10) setdest 291.764641 385.099501 19.999532" - -$ns_ at 50.000000 "$node_(1) setdest 460.251786 475.213570 18.952911" -$ns_ at 50.000000 "$node_(2) setdest 494.572859 425.450831 19.653312" -$ns_ at 50.000000 "$node_(3) setdest 516.437962 509.551212 6.431374" -$ns_ at 50.000000 "$node_(4) setdest 595.905073 527.487889 7.518771" -$ns_ at 50.000000 "$node_(5) setdest 435.704871 370.756310 8.175380" -$ns_ at 50.000000 "$node_(6) setdest 278.984020 426.603522 19.998455" -$ns_ at 50.000000 "$node_(7) setdest 259.940900 450.373613 19.999189" -$ns_ at 50.000000 "$node_(8) setdest 278.151718 463.062180 19.994642" -$ns_ at 50.000000 "$node_(9) setdest 315.561187 424.532692 19.999558" -$ns_ at 50.000000 "$node_(10) setdest 311.760339 384.687257 19.999947" - -$ns_ at 51.000000 "$node_(1) setdest 445.750485 461.773203 19.771980" -$ns_ at 51.000000 "$node_(2) setdest 477.062237 431.160008 18.417833" -$ns_ at 51.000000 "$node_(3) setdest 508.417207 509.293695 8.024888" -$ns_ at 51.000000 "$node_(4) setdest 596.138322 518.372789 9.118084" -$ns_ at 51.000000 "$node_(5) setdest 427.847555 376.601237 9.792885" -$ns_ at 51.000000 "$node_(6) setdest 298.977580 426.115506 19.999515" -$ns_ at 51.000000 "$node_(7) setdest 278.425975 442.746479 19.996779" -$ns_ at 51.000000 "$node_(8) setdest 297.021088 469.690556 19.999713" -$ns_ at 51.000000 "$node_(9) setdest 335.550946 423.983930 19.997290" -$ns_ at 51.000000 "$node_(10) setdest 331.755079 384.949165 19.996455" - -$ns_ at 52.000000 "$node_(1) setdest 440.756113 442.613683 19.799772" -$ns_ at 52.000000 "$node_(2) setdest 463.491729 442.499863 17.684767" -$ns_ at 52.000000 "$node_(3) setdest 498.797256 509.801163 9.633327" -$ns_ at 52.000000 "$node_(4) setdest 595.872849 507.661271 10.714807" -$ns_ at 52.000000 "$node_(5) setdest 421.543150 385.787102 11.141168" -$ns_ at 52.000000 "$node_(6) setdest 318.966418 425.467482 19.999339" -$ns_ at 52.000000 "$node_(7) setdest 297.432455 436.535728 19.995493" -$ns_ at 52.000000 "$node_(8) setdest 316.154504 475.504807 19.997327" -$ns_ at 52.000000 "$node_(9) setdest 355.519975 424.976200 19.993668" -$ns_ at 52.000000 "$node_(10) setdest 351.681172 386.619992 19.996020" - -$ns_ at 53.000000 "$node_(1) setdest 439.775796 422.648723 19.989013" -$ns_ at 53.000000 "$node_(2) setdest 454.163430 457.931863 18.032299" -$ns_ at 53.000000 "$node_(3) setdest 487.566288 509.968935 11.232221" -$ns_ at 53.000000 "$node_(4) setdest 593.366650 495.626354 12.293098" -$ns_ at 53.000000 "$node_(5) setdest 426.618346 394.729658 10.282360" -$ns_ at 53.000000 "$node_(6) setdest 338.963772 425.552181 19.997533" -$ns_ at 53.000000 "$node_(7) setdest 316.854629 431.777866 19.996452" -$ns_ at 53.000000 "$node_(8) setdest 335.626595 480.039122 19.993058" -$ns_ at 53.000000 "$node_(9) setdest 375.323130 427.689354 19.988150" -$ns_ at 53.000000 "$node_(10) setdest 371.379909 390.033338 19.992278" - -$ns_ at 54.000000 "$node_(1) setdest 445.215882 403.632184 19.779365" -$ns_ at 54.000000 "$node_(2) setdest 454.059564 475.725275 17.793715" -$ns_ at 54.000000 "$node_(3) setdest 474.763417 509.199397 12.825977" -$ns_ at 54.000000 "$node_(4) setdest 586.634251 483.521630 13.850977" -$ns_ at 54.000000 "$node_(5) setdest 434.740699 390.416312 9.196607" -$ns_ at 54.000000 "$node_(6) setdest 358.922646 426.804947 19.998152" -$ns_ at 54.000000 "$node_(7) setdest 336.584130 428.536703 19.993958" -$ns_ at 54.000000 "$node_(8) setdest 355.462297 482.552656 19.994323" -$ns_ at 54.000000 "$node_(9) setdest 394.479217 433.330580 19.969455" -$ns_ at 54.000000 "$node_(10) setdest 390.644077 395.375055 19.991051" - -$ns_ at 55.000000 "$node_(1) setdest 453.489395 385.467485 19.960143" -$ns_ at 55.000000 "$node_(2) setdest 462.180023 491.875553 18.076873" -$ns_ at 55.000000 "$node_(3) setdest 460.781091 505.762029 14.398644" -$ns_ at 55.000000 "$node_(4) setdest 575.183381 473.135665 15.459324" -$ns_ at 55.000000 "$node_(5) setdest 443.385083 383.339482 11.171700" -$ns_ at 55.000000 "$node_(6) setdest 378.818295 428.840950 19.999553" -$ns_ at 55.000000 "$node_(7) setdest 356.438978 426.133796 19.999724" -$ns_ at 55.000000 "$node_(8) setdest 375.442154 483.043104 19.985875" -$ns_ at 55.000000 "$node_(9) setdest 411.603795 443.510768 19.922032" -$ns_ at 55.000000 "$node_(10) setdest 409.167270 402.886591 19.988293" - -$ns_ at 56.000000 "$node_(1) setdest 459.358776 366.350314 19.997896" -$ns_ at 56.000000 "$node_(2) setdest 474.439207 506.513884 19.093672" -$ns_ at 56.000000 "$node_(3) setdest 448.331346 496.551801 15.486266" -$ns_ at 56.000000 "$node_(4) setdest 559.796949 465.725065 17.078034" -$ns_ at 56.000000 "$node_(5) setdest 453.233562 375.205933 12.772907" -$ns_ at 56.000000 "$node_(6) setdest 398.640054 431.491358 19.998170" -$ns_ at 56.000000 "$node_(7) setdest 376.341269 424.293425 19.987200" -$ns_ at 56.000000 "$node_(8) setdest 395.289271 480.727854 19.981702" -$ns_ at 56.000000 "$node_(9) setdest 424.686463 458.541108 19.926549" -$ns_ at 56.000000 "$node_(10) setdest 426.588462 412.682524 19.986450" - -$ns_ at 57.000000 "$node_(1) setdest 474.147494 357.589355 17.188968" -$ns_ at 57.000000 "$node_(2) setdest 487.397435 521.211648 19.594386" -$ns_ at 57.000000 "$node_(3) setdest 449.175044 489.763733 6.840299" -$ns_ at 57.000000 "$node_(4) setdest 541.945847 460.100331 18.716289" -$ns_ at 57.000000 "$node_(5) setdest 461.910819 364.190126 14.022938" -$ns_ at 57.000000 "$node_(6) setdest 418.176323 435.711193 19.986816" -$ns_ at 57.000000 "$node_(7) setdest 395.624998 428.517124 19.740868" -$ns_ at 57.000000 "$node_(8) setdest 414.491546 475.216368 19.977584" -$ns_ at 57.000000 "$node_(9) setdest 432.332273 476.914703 19.900939" -$ns_ at 57.000000 "$node_(10) setdest 442.302058 425.016869 19.976315" - -$ns_ at 58.000000 "$node_(1) setdest 481.754901 367.368742 12.389877" -$ns_ at 58.000000 "$node_(2) setdest 501.253150 535.247087 19.722434" -$ns_ at 58.000000 "$node_(3) setdest 452.555239 490.811571 3.538882" -$ns_ at 58.000000 "$node_(4) setdest 523.200618 453.356899 19.921282" -$ns_ at 58.000000 "$node_(5) setdest 462.037992 362.225513 1.968725" -$ns_ at 58.000000 "$node_(6) setdest 436.692511 443.161055 19.958699" -$ns_ at 58.000000 "$node_(7) setdest 407.232993 444.170234 19.487570" -$ns_ at 58.000000 "$node_(8) setdest 432.402128 466.376774 19.973166" -$ns_ at 58.000000 "$node_(9) setdest 433.371712 496.829333 19.941738" -$ns_ at 58.000000 "$node_(10) setdest 455.460442 440.041839 19.972301" - -$ns_ at 59.000000 "$node_(1) setdest 490.840101 378.013714 13.994866" -$ns_ at 59.000000 "$node_(2) setdest 517.254096 544.656606 18.562578" -$ns_ at 59.000000 "$node_(3) setdest 456.805761 493.906270 5.257765" -$ns_ at 59.000000 "$node_(4) setdest 505.296597 444.480311 19.983688" -$ns_ at 59.000000 "$node_(5) setdest 459.985759 364.047842 2.744548" -$ns_ at 59.000000 "$node_(6) setdest 452.558464 455.227354 19.932988" -$ns_ at 59.000000 "$node_(7) setdest 405.781902 462.093611 17.982022" -$ns_ at 59.000000 "$node_(8) setdest 448.131072 454.084488 19.962465" -$ns_ at 59.000000 "$node_(9) setdest 431.643951 516.751552 19.996999" -$ns_ at 59.000000 "$node_(10) setdest 465.450760 457.326282 19.963928" - -$ns_ at 60.000000 "$node_(1) setdest 498.659527 391.489267 15.579922" -$ns_ at 60.000000 "$node_(2) setdest 534.755136 543.334674 17.550895" -$ns_ at 60.000000 "$node_(3) setdest 462.401977 497.870630 6.858118" -$ns_ at 60.000000 "$node_(4) setdest 488.791604 433.220713 19.979823" -$ns_ at 60.000000 "$node_(5) setdest 456.842494 367.045729 4.343667" -$ns_ at 60.000000 "$node_(6) setdest 465.331500 470.591333 19.980047" -$ns_ at 60.000000 "$node_(7) setdest 408.815556 476.318798 14.545068" -$ns_ at 60.000000 "$node_(8) setdest 460.493008 438.434407 19.943483" -$ns_ at 60.000000 "$node_(9) setdest 438.396275 534.407383 18.902969" -$ns_ at 60.000000 "$node_(10) setdest 472.292912 476.109195 19.990319" - -$ns_ at 61.000000 "$node_(1) setdest 506.422494 406.848972 17.210003" -$ns_ at 61.000000 "$node_(2) setdest 550.122906 534.408750 17.771901" -$ns_ at 61.000000 "$node_(3) setdest 469.441169 502.553605 8.454613" -$ns_ at 61.000000 "$node_(4) setdest 473.810761 419.970774 19.999664" -$ns_ at 61.000000 "$node_(5) setdest 452.869841 371.468100 5.944690" -$ns_ at 61.000000 "$node_(6) setdest 475.369253 487.873233 19.985509" -$ns_ at 61.000000 "$node_(7) setdest 420.177106 474.634595 11.485703" -$ns_ at 61.000000 "$node_(8) setdest 468.519800 420.146652 19.971764" -$ns_ at 61.000000 "$node_(9) setdest 456.064353 537.336055 17.909162" -$ns_ at 61.000000 "$node_(10) setdest 480.398446 494.324173 19.937028" - -$ns_ at 62.000000 "$node_(1) setdest 514.243671 423.949759 18.804460" -$ns_ at 62.000000 "$node_(2) setdest 558.597008 518.822165 17.741252" -$ns_ at 62.000000 "$node_(3) setdest 478.289486 507.332608 10.056420" -$ns_ at 62.000000 "$node_(4) setdest 459.228341 406.299144 19.989007" -$ns_ at 62.000000 "$node_(5) setdest 448.065246 377.284900 7.544488" -$ns_ at 62.000000 "$node_(6) setdest 483.292150 506.217705 19.982291" -$ns_ at 62.000000 "$node_(7) setdest 431.806592 467.919195 13.429130" -$ns_ at 62.000000 "$node_(8) setdest 473.157337 400.709492 19.982741" -$ns_ at 62.000000 "$node_(9) setdest 471.569985 531.759731 16.477864" -$ns_ at 62.000000 "$node_(10) setdest 493.533931 509.329068 19.942113" - -$ns_ at 63.000000 "$node_(1) setdest 526.606177 439.546625 19.902105" -$ns_ at 63.000000 "$node_(2) setdest 563.865355 500.625921 18.943568" -$ns_ at 63.000000 "$node_(3) setdest 488.865584 512.231308 11.655519" -$ns_ at 63.000000 "$node_(4) setdest 443.896167 393.463964 19.995435" -$ns_ at 63.000000 "$node_(5) setdest 443.134296 384.956898 9.119968" -$ns_ at 63.000000 "$node_(6) setdest 483.704532 525.909424 19.696036" -$ns_ at 63.000000 "$node_(7) setdest 441.488756 456.383377 15.060524" -$ns_ at 63.000000 "$node_(8) setdest 471.609423 381.023538 19.746717" -$ns_ at 63.000000 "$node_(9) setdest 484.411309 520.929706 16.798483" -$ns_ at 63.000000 "$node_(10) setdest 509.195143 521.746549 19.986681" - -$ns_ at 64.000000 "$node_(1) setdest 540.433816 453.956062 19.970865" -$ns_ at 64.000000 "$node_(2) setdest 568.124533 481.658093 19.440142" -$ns_ at 64.000000 "$node_(3) setdest 501.350038 516.664198 13.248098" -$ns_ at 64.000000 "$node_(4) setdest 433.455434 376.647829 19.793718" -$ns_ at 64.000000 "$node_(5) setdest 440.254466 395.258128 10.696204" -$ns_ at 64.000000 "$node_(6) setdest 469.652755 537.742107 18.370216" -$ns_ at 64.000000 "$node_(7) setdest 449.511886 441.764181 16.676076" -$ns_ at 64.000000 "$node_(8) setdest 457.550576 367.766860 19.323320" -$ns_ at 64.000000 "$node_(9) setdest 498.202162 508.754862 18.396045" -$ns_ at 64.000000 "$node_(10) setdest 527.839755 528.576108 19.856093" - -$ns_ at 65.000000 "$node_(1) setdest 536.004799 446.599409 8.586997" -$ns_ at 65.000000 "$node_(2) setdest 564.983309 461.913673 19.992735" -$ns_ at 65.000000 "$node_(3) setdest 500.747238 516.306833 0.700769" -$ns_ at 65.000000 "$node_(4) setdest 438.545894 357.691580 19.627842" -$ns_ at 65.000000 "$node_(5) setdest 441.586829 385.431591 9.916452" -$ns_ at 65.000000 "$node_(6) setdest 457.118274 526.488725 16.844935" -$ns_ at 65.000000 "$node_(7) setdest 457.806607 425.470338 18.283646" -$ns_ at 65.000000 "$node_(8) setdest 439.123220 364.402269 18.732003" -$ns_ at 65.000000 "$node_(9) setdest 510.416367 493.167415 19.802912" -$ns_ at 65.000000 "$node_(10) setdest 547.813104 529.300629 19.986485" - -$ns_ at 66.000000 "$node_(1) setdest 535.511187 436.310624 10.300619" -$ns_ at 66.000000 "$node_(2) setdest 562.492130 442.069901 19.999531" -$ns_ at 66.000000 "$node_(3) setdest 500.517193 514.277017 2.042810" -$ns_ at 66.000000 "$node_(4) setdest 445.642038 338.993091 19.999719" -$ns_ at 66.000000 "$node_(5) setdest 444.691682 374.116179 11.733655" -$ns_ at 66.000000 "$node_(6) setdest 455.508240 510.110942 16.456730" -$ns_ at 66.000000 "$node_(7) setdest 468.428808 408.858654 19.717485" -$ns_ at 66.000000 "$node_(8) setdest 419.931073 364.342807 19.192239" -$ns_ at 66.000000 "$node_(9) setdest 524.816169 479.714481 19.706235" -$ns_ at 66.000000 "$node_(10) setdest 567.683020 530.920241 19.935814" - -$ns_ at 67.000000 "$node_(1) setdest 534.977282 424.421906 11.900701" -$ns_ at 67.000000 "$node_(2) setdest 560.569724 422.162987 19.999522" -$ns_ at 67.000000 "$node_(3) setdest 500.250852 510.644079 3.642688" -$ns_ at 67.000000 "$node_(4) setdest 452.955902 320.378413 19.999972" -$ns_ at 67.000000 "$node_(5) setdest 448.073535 361.217857 13.334303" -$ns_ at 67.000000 "$node_(6) setdest 451.399100 495.313815 15.357083" -$ns_ at 67.000000 "$node_(7) setdest 481.733772 393.932468 19.995327" -$ns_ at 67.000000 "$node_(8) setdest 408.322022 365.329378 11.650896" -$ns_ at 67.000000 "$node_(9) setdest 539.158447 466.290889 19.644179" -$ns_ at 67.000000 "$node_(10) setdest 586.678542 530.162271 19.010638" - -$ns_ at 68.000000 "$node_(1) setdest 534.442950 410.931909 13.500575" -$ns_ at 68.000000 "$node_(2) setdest 558.901130 402.232965 19.999749" -$ns_ at 68.000000 "$node_(3) setdest 500.103546 505.403612 5.242537" -$ns_ at 68.000000 "$node_(4) setdest 460.080618 301.691006 19.999519" -$ns_ at 68.000000 "$node_(5) setdest 452.196525 346.864412 14.933869" -$ns_ at 68.000000 "$node_(6) setdest 438.416880 485.903560 16.034056" -$ns_ at 68.000000 "$node_(7) setdest 492.545093 377.214664 19.909034" -$ns_ at 68.000000 "$node_(8) setdest 416.839668 364.609333 8.548026" -$ns_ at 68.000000 "$node_(9) setdest 555.040544 454.694707 19.665006" -$ns_ at 68.000000 "$node_(10) setdest 586.825175 529.031950 1.139792" - -$ns_ at 69.000000 "$node_(1) setdest 534.282344 395.832941 15.099822" -$ns_ at 69.000000 "$node_(2) setdest 557.329589 382.294855 19.999950" -$ns_ at 69.000000 "$node_(3) setdest 500.199783 498.561725 6.842563" -$ns_ at 69.000000 "$node_(4) setdest 466.364502 282.705492 19.998423" -$ns_ at 69.000000 "$node_(5) setdest 457.330300 331.148052 16.533591" -$ns_ at 69.000000 "$node_(6) setdest 422.274174 478.513804 17.753744" -$ns_ at 69.000000 "$node_(7) setdest 503.862909 361.836359 19.094115" -$ns_ at 69.000000 "$node_(8) setdest 427.020554 367.160258 10.495602" -$ns_ at 69.000000 "$node_(9) setdest 571.735283 444.352269 19.638745" -$ns_ at 69.000000 "$node_(10) setdest 585.455531 526.966140 2.478608" - -$ns_ at 70.000000 "$node_(1) setdest 534.838474 379.142686 16.699517" -$ns_ at 70.000000 "$node_(2) setdest 555.525020 362.376742 19.999692" -$ns_ at 70.000000 "$node_(3) setdest 500.519465 490.124854 8.442926" -$ns_ at 70.000000 "$node_(4) setdest 471.472022 263.373599 19.995221" -$ns_ at 70.000000 "$node_(5) setdest 463.120393 313.962864 18.134383" -$ns_ at 70.000000 "$node_(6) setdest 408.213514 466.311334 18.617262" -$ns_ at 70.000000 "$node_(7) setdest 507.696506 363.297112 4.102471" -$ns_ at 70.000000 "$node_(8) setdest 439.013807 368.678079 12.088916" -$ns_ at 70.000000 "$node_(9) setdest 589.464572 437.178961 19.125482" -$ns_ at 70.000000 "$node_(10) setdest 583.204839 523.564669 4.078679" - -$ns_ at 71.000000 "$node_(1) setdest 536.112282 360.887514 18.299561" -$ns_ at 71.000000 "$node_(2) setdest 553.523133 342.477773 19.999413" -$ns_ at 71.000000 "$node_(3) setdest 501.048110 480.096108 10.042669" -$ns_ at 71.000000 "$node_(4) setdest 475.511485 243.786853 19.998948" -$ns_ at 71.000000 "$node_(5) setdest 469.394485 295.340571 19.650802" -$ns_ at 71.000000 "$node_(6) setdest 409.735707 449.316228 17.063139" -$ns_ at 71.000000 "$node_(7) setdest 509.753088 368.161673 5.281428" -$ns_ at 71.000000 "$node_(8) setdest 452.539013 366.922685 13.638644" -$ns_ at 71.000000 "$node_(9) setdest 593.411094 420.224329 17.407888" -$ns_ at 71.000000 "$node_(10) setdest 580.200954 518.748793 5.675913" - -$ns_ at 72.000000 "$node_(1) setdest 538.243058 341.252788 19.750004" -$ns_ at 72.000000 "$node_(2) setdest 552.067476 322.531052 19.999766" -$ns_ at 72.000000 "$node_(3) setdest 502.043198 468.496468 11.642244" -$ns_ at 72.000000 "$node_(4) setdest 478.483272 224.011916 19.996990" -$ns_ at 72.000000 "$node_(5) setdest 475.540955 276.308901 19.999589" -$ns_ at 72.000000 "$node_(6) setdest 417.775607 434.844392 16.555181" -$ns_ at 72.000000 "$node_(7) setdest 510.902737 374.952179 6.887138" -$ns_ at 72.000000 "$node_(8) setdest 467.088300 362.216077 15.291629" -$ns_ at 72.000000 "$node_(9) setdest 588.386379 404.792399 16.229363" -$ns_ at 72.000000 "$node_(10) setdest 576.937804 512.244383 7.277053" - -$ns_ at 73.000000 "$node_(1) setdest 540.337760 321.362851 19.999934" -$ns_ at 73.000000 "$node_(2) setdest 550.508182 302.593413 19.998521" -$ns_ at 73.000000 "$node_(3) setdest 503.738640 455.363500 13.241955" -$ns_ at 73.000000 "$node_(4) setdest 480.607929 204.125582 19.999511" -$ns_ at 73.000000 "$node_(5) setdest 482.491192 257.559586 19.996064" -$ns_ at 73.000000 "$node_(6) setdest 424.060892 418.184577 17.806018" -$ns_ at 73.000000 "$node_(7) setdest 511.222289 383.432144 8.485983" -$ns_ at 73.000000 "$node_(8) setdest 483.575039 358.506602 16.898898" -$ns_ at 73.000000 "$node_(9) setdest 581.016072 390.553508 16.033323" -$ns_ at 73.000000 "$node_(10) setdest 573.633501 504.005362 8.876930" - -$ns_ at 74.000000 "$node_(1) setdest 542.640833 301.496124 19.999775" -$ns_ at 74.000000 "$node_(2) setdest 547.211487 282.875900 19.991211" -$ns_ at 74.000000 "$node_(3) setdest 506.228546 440.731667 14.842176" -$ns_ at 74.000000 "$node_(4) setdest 483.949062 184.414401 19.992345" -$ns_ at 74.000000 "$node_(5) setdest 490.772371 239.358717 19.996239" -$ns_ at 74.000000 "$node_(6) setdest 428.971719 399.458697 19.359101" -$ns_ at 74.000000 "$node_(7) setdest 510.977845 393.521870 10.092687" -$ns_ at 74.000000 "$node_(8) setdest 501.649850 360.807649 18.220692" -$ns_ at 74.000000 "$node_(9) setdest 574.169947 374.218269 17.711845" -$ns_ at 74.000000 "$node_(10) setdest 569.666315 494.308359 10.477138" - -$ns_ at 75.000000 "$node_(1) setdest 545.286982 281.676690 19.995301" -$ns_ at 75.000000 "$node_(2) setdest 541.579801 263.698851 19.986873" -$ns_ at 75.000000 "$node_(3) setdest 509.521933 424.622555 16.442319" -$ns_ at 75.000000 "$node_(4) setdest 489.316472 165.158057 19.990394" -$ns_ at 75.000000 "$node_(5) setdest 499.170013 221.211394 19.996143" -$ns_ at 75.000000 "$node_(6) setdest 433.995690 380.248856 19.855938" -$ns_ at 75.000000 "$node_(7) setdest 509.830491 405.143663 11.678292" -$ns_ at 75.000000 "$node_(8) setdest 514.956828 375.067165 19.504088" -$ns_ at 75.000000 "$node_(9) setdest 563.225009 358.537277 19.122897" -$ns_ at 75.000000 "$node_(10) setdest 564.059199 483.616863 12.072607" - -$ns_ at 76.000000 "$node_(1) setdest 550.377288 262.356101 19.979900" -$ns_ at 76.000000 "$node_(2) setdest 533.540653 245.403103 19.984051" -$ns_ at 76.000000 "$node_(3) setdest 513.154562 406.949557 18.042473" -$ns_ at 76.000000 "$node_(4) setdest 496.890661 146.658823 19.989748" -$ns_ at 76.000000 "$node_(5) setdest 507.041942 202.829163 19.996842" -$ns_ at 76.000000 "$node_(6) setdest 441.406995 362.103882 19.600192" -$ns_ at 76.000000 "$node_(7) setdest 506.263148 417.944045 13.288180" -$ns_ at 76.000000 "$node_(8) setdest 523.622151 393.089514 19.997322" -$ns_ at 76.000000 "$node_(9) setdest 562.694870 356.369564 2.231598" -$ns_ at 76.000000 "$node_(10) setdest 556.855146 471.989381 13.678331" - -$ns_ at 77.000000 "$node_(1) setdest 559.088417 244.398391 19.959036" -$ns_ at 77.000000 "$node_(2) setdest 521.840951 229.244414 19.949593" -$ns_ at 77.000000 "$node_(3) setdest 516.301733 387.623702 19.580433" -$ns_ at 77.000000 "$node_(4) setdest 505.320440 128.522356 19.999815" -$ns_ at 77.000000 "$node_(5) setdest 515.254078 184.596382 19.996837" -$ns_ at 77.000000 "$node_(6) setdest 437.257639 351.072545 11.785905" -$ns_ at 77.000000 "$node_(7) setdest 500.846086 431.809163 14.885767" -$ns_ at 77.000000 "$node_(8) setdest 529.413794 412.094108 19.867504" -$ns_ at 77.000000 "$node_(9) setdest 565.572234 358.356299 3.496619" -$ns_ at 77.000000 "$node_(10) setdest 548.808724 459.002515 15.277551" - -$ns_ at 78.000000 "$node_(1) setdest 568.615890 226.866730 19.953243" -$ns_ at 78.000000 "$node_(2) setdest 506.765408 216.107743 19.996103" -$ns_ at 78.000000 "$node_(3) setdest 518.586099 367.756661 19.997941" -$ns_ at 78.000000 "$node_(4) setdest 511.394728 109.548785 19.922183" -$ns_ at 78.000000 "$node_(5) setdest 521.978222 165.767794 19.993245" -$ns_ at 78.000000 "$node_(6) setdest 429.959797 352.164602 7.379098" -$ns_ at 78.000000 "$node_(7) setdest 494.140339 446.876872 16.492510" -$ns_ at 78.000000 "$node_(8) setdest 525.963760 430.106023 18.339351" -$ns_ at 78.000000 "$node_(9) setdest 569.000240 362.124933 5.094490" -$ns_ at 78.000000 "$node_(10) setdest 540.470647 444.327845 16.878077" - -$ns_ at 79.000000 "$node_(1) setdest 574.185687 207.679959 19.978859" -$ns_ at 79.000000 "$node_(2) setdest 491.733402 202.925804 19.993117" -$ns_ at 79.000000 "$node_(3) setdest 519.783067 347.795031 19.997485" -$ns_ at 79.000000 "$node_(4) setdest 508.990521 89.908093 19.787293" -$ns_ at 79.000000 "$node_(5) setdest 526.722730 146.349523 19.989487" -$ns_ at 79.000000 "$node_(6) setdest 421.402925 354.646309 8.909485" -$ns_ at 79.000000 "$node_(7) setdest 484.722595 462.296802 18.068430" -$ns_ at 79.000000 "$node_(8) setdest 513.980626 443.368125 17.873971" -$ns_ at 79.000000 "$node_(9) setdest 572.479374 367.825573 6.678447" -$ns_ at 79.000000 "$node_(10) setdest 529.744275 429.315243 18.450834" - -$ns_ at 80.000000 "$node_(1) setdest 576.539904 187.859407 19.959875" -$ns_ at 80.000000 "$node_(2) setdest 480.207033 186.703672 19.900119" -$ns_ at 80.000000 "$node_(3) setdest 519.812887 327.797852 19.997201" -$ns_ at 80.000000 "$node_(4) setdest 497.292409 73.848971 19.868096" -$ns_ at 80.000000 "$node_(5) setdest 528.886672 126.481962 19.985060" -$ns_ at 80.000000 "$node_(6) setdest 415.020974 363.015006 10.524466" -$ns_ at 80.000000 "$node_(7) setdest 471.817545 477.042190 19.595070" -$ns_ at 80.000000 "$node_(8) setdest 503.184441 458.887502 18.905255" -$ns_ at 80.000000 "$node_(9) setdest 575.661628 375.491501 8.300193" -$ns_ at 80.000000 "$node_(10) setdest 514.499292 416.740217 19.762106" - -$ns_ at 81.000000 "$node_(1) setdest 574.626392 167.968199 19.983034" -$ns_ at 81.000000 "$node_(2) setdest 475.821624 167.311287 19.882063" -$ns_ at 81.000000 "$node_(3) setdest 518.646194 307.835016 19.996899" -$ns_ at 81.000000 "$node_(4) setdest 483.578324 59.304461 19.990471" -$ns_ at 81.000000 "$node_(5) setdest 527.651007 106.553198 19.967035" -$ns_ at 81.000000 "$node_(6) setdest 410.440591 374.312692 12.190882" -$ns_ at 81.000000 "$node_(7) setdest 456.292988 489.616829 19.978324" -$ns_ at 81.000000 "$node_(8) setdest 498.005915 477.169448 19.001228" -$ns_ at 81.000000 "$node_(9) setdest 579.725346 384.508368 9.890283" -$ns_ at 81.000000 "$node_(10) setdest 495.634540 410.515884 19.865074" - -$ns_ at 82.000000 "$node_(1) setdest 573.744222 148.036265 19.951446" -$ns_ at 82.000000 "$node_(2) setdest 474.558082 147.369780 19.981497" -$ns_ at 82.000000 "$node_(3) setdest 516.187480 287.990063 19.996686" -$ns_ at 82.000000 "$node_(4) setdest 474.515345 41.610136 19.880309" -$ns_ at 82.000000 "$node_(5) setdest 522.091375 87.379602 19.963374" -$ns_ at 82.000000 "$node_(6) setdest 414.780703 386.764139 13.186170" -$ns_ at 82.000000 "$node_(7) setdest 438.763875 499.134151 19.946158" -$ns_ at 82.000000 "$node_(8) setdest 500.792450 494.938482 17.986199" -$ns_ at 82.000000 "$node_(9) setdest 588.726105 391.049918 11.126794" -$ns_ at 82.000000 "$node_(10) setdest 475.806091 412.296842 19.908270" - -$ns_ at 83.000000 "$node_(1) setdest 577.404142 128.397041 19.977341" -$ns_ at 83.000000 "$node_(2) setdest 471.772322 127.583434 19.981491" -$ns_ at 83.000000 "$node_(3) setdest 512.431069 268.349770 19.996293" -$ns_ at 83.000000 "$node_(4) setdest 467.791067 22.805362 19.970865" -$ns_ at 83.000000 "$node_(5) setdest 513.352198 69.412545 19.979699" -$ns_ at 83.000000 "$node_(6) setdest 426.772346 396.441652 15.409535" -$ns_ at 83.000000 "$node_(7) setdest 419.593750 498.212291 19.192278" -$ns_ at 83.000000 "$node_(8) setdest 513.064464 506.922013 17.152474" -$ns_ at 83.000000 "$node_(9) setdest 594.729903 387.107313 7.182599" -$ns_ at 83.000000 "$node_(10) setdest 456.101092 415.641689 19.986870" - -$ns_ at 84.000000 "$node_(1) setdest 583.213841 109.262849 19.996747" -$ns_ at 84.000000 "$node_(2) setdest 476.419501 108.372979 19.764560" -$ns_ at 84.000000 "$node_(3) setdest 507.266385 249.033080 19.995211" -$ns_ at 84.000000 "$node_(4) setdest 462.492387 11.625346 12.372096" -$ns_ at 84.000000 "$node_(5) setdest 502.089366 52.902858 19.985523" -$ns_ at 84.000000 "$node_(6) setdest 437.511332 409.573265 16.963640" -$ns_ at 84.000000 "$node_(7) setdest 412.014189 481.555847 18.299914" -$ns_ at 84.000000 "$node_(8) setdest 526.654692 519.163066 18.290371" -$ns_ at 84.000000 "$node_(9) setdest 592.714197 381.218901 6.223863" -$ns_ at 84.000000 "$node_(10) setdest 436.259652 418.153011 19.999737" - -$ns_ at 85.000000 "$node_(1) setdest 587.867212 89.874667 19.938793" -$ns_ at 85.000000 "$node_(2) setdest 489.338727 93.291200 19.858662" -$ns_ at 85.000000 "$node_(3) setdest 500.466087 230.231287 19.993786" -$ns_ at 85.000000 "$node_(4) setdest 463.199929 17.989912 6.403773" -$ns_ at 85.000000 "$node_(5) setdest 487.155522 39.734993 19.910107" -$ns_ at 85.000000 "$node_(6) setdest 443.956620 426.937800 18.522117" -$ns_ at 85.000000 "$node_(7) setdest 404.982373 466.107830 16.973145" -$ns_ at 85.000000 "$node_(8) setdest 537.501281 535.276226 19.423759" -$ns_ at 85.000000 "$node_(9) setdest 588.601285 374.648766 7.751304" -$ns_ at 85.000000 "$node_(10) setdest 417.844644 423.934655 19.301293" - -$ns_ at 86.000000 "$node_(1) setdest 583.707241 70.590453 19.727804" -$ns_ at 86.000000 "$node_(2) setdest 507.837671 86.031211 19.872553" -$ns_ at 86.000000 "$node_(3) setdest 492.487335 211.892008 19.999741" -$ns_ at 86.000000 "$node_(4) setdest 460.684485 25.836346 8.239780" -$ns_ at 86.000000 "$node_(5) setdest 468.395888 33.126211 19.889693" -$ns_ at 86.000000 "$node_(6) setdest 439.617458 445.683926 19.241766" -$ns_ at 86.000000 "$node_(7) setdest 405.686381 458.064025 8.074554" -$ns_ at 86.000000 "$node_(8) setdest 552.956635 544.737738 18.121484" -$ns_ at 86.000000 "$node_(9) setdest 579.604555 372.897661 9.165562" -$ns_ at 86.000000 "$node_(10) setdest 417.084191 434.018891 10.112869" - -$ns_ at 87.000000 "$node_(1) setdest 568.163720 58.723273 19.555844" -$ns_ at 87.000000 "$node_(2) setdest 527.597802 85.380885 19.770830" -$ns_ at 87.000000 "$node_(3) setdest 484.486710 193.561998 19.999982" -$ns_ at 87.000000 "$node_(4) setdest 458.575323 35.422524 9.815466" -$ns_ at 87.000000 "$node_(5) setdest 448.529777 33.971581 19.884089" -$ns_ at 87.000000 "$node_(6) setdest 425.906823 457.123064 17.855963" -$ns_ at 87.000000 "$node_(7) setdest 408.452236 458.872840 2.881690" -$ns_ at 87.000000 "$node_(8) setdest 568.879506 540.146677 16.571531" -$ns_ at 87.000000 "$node_(9) setdest 569.851338 377.857203 10.941769" -$ns_ at 87.000000 "$node_(10) setdest 421.850394 441.875446 9.189240" - -$ns_ at 88.000000 "$node_(1) setdest 548.683399 54.449519 19.943618" -$ns_ at 88.000000 "$node_(2) setdest 546.933768 82.546059 19.542668" -$ns_ at 88.000000 "$node_(3) setdest 476.681038 175.148773 19.999384" -$ns_ at 88.000000 "$node_(4) setdest 461.366028 46.344763 11.273125" -$ns_ at 88.000000 "$node_(5) setdest 430.847089 43.014463 19.860795" -$ns_ at 88.000000 "$node_(6) setdest 410.587500 453.395095 15.766401" -$ns_ at 88.000000 "$node_(7) setdest 412.362473 461.216708 4.558911" -$ns_ at 88.000000 "$node_(8) setdest 582.276440 530.346179 16.599024" -$ns_ at 88.000000 "$node_(9) setdest 560.884729 386.754776 12.631979" -$ns_ at 88.000000 "$node_(10) setdest 424.841637 452.326111 10.870324" - -$ns_ at 89.000000 "$node_(1) setdest 529.270019 51.276340 19.671004" -$ns_ at 89.000000 "$node_(2) setdest 565.972708 77.913315 19.594477" -$ns_ at 89.000000 "$node_(3) setdest 469.023624 156.673222 19.999549" -$ns_ at 89.000000 "$node_(4) setdest 471.973165 53.282586 12.674571" -$ns_ at 89.000000 "$node_(5) setdest 419.286989 58.968693 19.702116" -$ns_ at 89.000000 "$node_(6) setdest 404.803098 439.911564 14.671910" -$ns_ at 89.000000 "$node_(7) setdest 416.934945 465.341967 6.158349" -$ns_ at 89.000000 "$node_(8) setdest 595.673075 523.961962 14.840082" -$ns_ at 89.000000 "$node_(9) setdest 554.608120 399.466950 14.177277" -$ns_ at 89.000000 "$node_(10) setdest 428.943927 464.092911 12.461395" - -$ns_ at 90.000000 "$node_(1) setdest 510.446672 45.560687 19.671987" -$ns_ at 90.000000 "$node_(2) setdest 581.900465 67.427062 19.069739" -$ns_ at 90.000000 "$node_(3) setdest 460.852421 138.421298 19.997532" -$ns_ at 90.000000 "$node_(4) setdest 486.548028 54.559831 14.630720" -$ns_ at 90.000000 "$node_(5) setdest 417.520328 78.793399 19.903267" -$ns_ at 90.000000 "$node_(6) setdest 412.989536 428.553731 14.000647" -$ns_ at 90.000000 "$node_(7) setdest 421.706379 471.443160 7.745395" -$ns_ at 90.000000 "$node_(8) setdest 596.698144 525.418757 1.781297" -$ns_ at 90.000000 "$node_(9) setdest 552.296746 415.092034 15.795117" -$ns_ at 90.000000 "$node_(10) setdest 437.002050 475.535203 13.994977" - -$ns_ at 91.000000 "$node_(1) setdest 491.216630 41.851459 19.584506" -$ns_ at 91.000000 "$node_(2) setdest 597.391272 59.977823 17.188841" -$ns_ at 91.000000 "$node_(3) setdest 451.041441 121.016462 19.979581" -$ns_ at 91.000000 "$node_(4) setdest 502.763761 55.445814 16.239919" -$ns_ at 91.000000 "$node_(5) setdest 420.064577 98.608541 19.977814" -$ns_ at 91.000000 "$node_(6) setdest 427.036725 421.558974 15.692359" -$ns_ at 91.000000 "$node_(7) setdest 425.224219 480.087841 9.333043" -$ns_ at 91.000000 "$node_(8) setdest 595.078325 527.548271 2.675565" -$ns_ at 91.000000 "$node_(9) setdest 555.215513 432.214111 17.369074" -$ns_ at 91.000000 "$node_(10) setdest 450.540971 483.206577 15.561245" - -$ns_ at 92.000000 "$node_(1) setdest 471.659908 39.220660 19.732878" -$ns_ at 92.000000 "$node_(2) setdest 599.260739 62.844430 3.422330" -$ns_ at 92.000000 "$node_(3) setdest 437.200521 106.710742 19.905394" -$ns_ at 92.000000 "$node_(4) setdest 520.463512 57.440346 17.811775" -$ns_ at 92.000000 "$node_(5) setdest 425.407301 117.784600 19.906430" -$ns_ at 92.000000 "$node_(6) setdest 441.106703 411.581456 17.248628" -$ns_ at 92.000000 "$node_(7) setdest 426.330437 490.960272 10.928563" -$ns_ at 92.000000 "$node_(8) setdest 592.410482 530.533599 4.003694" -$ns_ at 92.000000 "$node_(9) setdest 564.412524 448.873432 19.029397" -$ns_ at 92.000000 "$node_(10) setdest 467.267881 487.413523 17.247838" - -$ns_ at 93.000000 "$node_(1) setdest 453.466313 33.175001 19.171774" -$ns_ at 93.000000 "$node_(2) setdest 598.291343 67.449039 4.705545" -$ns_ at 93.000000 "$node_(3) setdest 420.425409 96.070528 19.865007" -$ns_ at 93.000000 "$node_(4) setdest 539.462165 61.491498 19.425773" -$ns_ at 93.000000 "$node_(5) setdest 434.020030 135.209813 19.437519" -$ns_ at 93.000000 "$node_(6) setdest 455.272226 399.073428 18.897428" -$ns_ at 93.000000 "$node_(7) setdest 427.424847 503.463387 12.550921" -$ns_ at 93.000000 "$node_(8) setdest 593.809342 529.223559 1.916510" -$ns_ at 93.000000 "$node_(9) setdest 576.244847 464.961799 19.970965" -$ns_ at 93.000000 "$node_(10) setdest 485.902916 490.396138 18.872215" - -$ns_ at 94.000000 "$node_(1) setdest 440.069927 20.181823 18.662418" -$ns_ at 94.000000 "$node_(2) setdest 596.289520 73.428855 6.305989" -$ns_ at 94.000000 "$node_(3) setdest 418.138459 85.885901 10.438235" -$ns_ at 94.000000 "$node_(4) setdest 559.121472 65.074947 19.983229" -$ns_ at 94.000000 "$node_(5) setdest 433.752323 153.363814 18.155975" -$ns_ at 94.000000 "$node_(6) setdest 468.907539 384.565199 19.910059" -$ns_ at 94.000000 "$node_(7) setdest 423.892158 517.002474 13.992382" -$ns_ at 94.000000 "$node_(8) setdest 594.496732 525.690274 3.599529" -$ns_ at 94.000000 "$node_(9) setdest 587.176402 481.519615 19.840871" -$ns_ at 94.000000 "$node_(10) setdest 505.557558 493.894481 19.963551" - -$ns_ at 95.000000 "$node_(1) setdest 427.052116 6.847278 18.635275" -$ns_ at 95.000000 "$node_(2) setdest 594.485579 81.120759 7.900607" -$ns_ at 95.000000 "$node_(3) setdest 420.911514 86.122459 2.783127" -$ns_ at 95.000000 "$node_(4) setdest 579.042638 65.882017 19.937508" -$ns_ at 95.000000 "$node_(5) setdest 419.915636 161.815294 16.213618" -$ns_ at 95.000000 "$node_(6) setdest 479.384927 367.530238 19.999139" -$ns_ at 95.000000 "$node_(7) setdest 413.636242 520.451794 10.820426" -$ns_ at 95.000000 "$node_(8) setdest 595.480416 520.598937 5.185494" -$ns_ at 95.000000 "$node_(9) setdest 588.142218 501.154215 19.658340" -$ns_ at 95.000000 "$node_(10) setdest 525.501306 495.121901 19.981483" - -$ns_ at 96.000000 "$node_(1) setdest 410.783725 0.750524 17.373284" -$ns_ at 96.000000 "$node_(2) setdest 593.127576 90.529264 9.506006" -$ns_ at 96.000000 "$node_(3) setdest 424.469755 88.906562 4.517998" -$ns_ at 96.000000 "$node_(4) setdest 589.252016 52.033514 17.205011" -$ns_ at 96.000000 "$node_(5) setdest 406.673798 155.191050 14.806312" -$ns_ at 96.000000 "$node_(6) setdest 483.266169 352.608643 15.418108" -$ns_ at 96.000000 "$node_(7) setdest 410.018337 513.556034 7.787216" -$ns_ at 96.000000 "$node_(8) setdest 595.625065 513.990687 6.609832" -$ns_ at 96.000000 "$node_(9) setdest 576.073216 515.525770 18.767056" -$ns_ at 96.000000 "$node_(10) setdest 544.912679 490.672198 19.914850" - -$ns_ at 97.000000 "$node_(1) setdest 419.156506 3.762852 8.898179" -$ns_ at 97.000000 "$node_(2) setdest 591.679304 101.541365 11.106928" -$ns_ at 97.000000 "$node_(3) setdest 429.445594 92.463295 6.116317" -$ns_ at 97.000000 "$node_(4) setdest 580.554829 37.419012 17.006609" -$ns_ at 97.000000 "$node_(5) setdest 406.950962 153.565137 1.649367" -$ns_ at 97.000000 "$node_(6) setdest 479.856644 351.887222 3.485012" -$ns_ at 97.000000 "$node_(7) setdest 408.684567 504.276932 9.374469" -$ns_ at 97.000000 "$node_(8) setdest 590.406909 507.617288 8.237073" -$ns_ at 97.000000 "$node_(9) setdest 559.752265 523.162622 18.019294" -$ns_ at 97.000000 "$node_(10) setdest 561.124452 479.086372 19.926187" - -$ns_ at 98.000000 "$node_(1) setdest 429.488659 2.608879 10.396395" -$ns_ at 98.000000 "$node_(2) setdest 589.054917 113.968791 12.701509" -$ns_ at 98.000000 "$node_(3) setdest 436.124983 96.326552 7.716151" -$ns_ at 98.000000 "$node_(4) setdest 574.740693 23.094755 15.459253" -$ns_ at 98.000000 "$node_(5) setdest 409.384783 153.230897 2.456664" -$ns_ at 98.000000 "$node_(6) setdest 474.746734 352.016833 5.111553" -$ns_ at 98.000000 "$node_(7) setdest 413.021931 494.129886 11.035183" -$ns_ at 98.000000 "$node_(8) setdest 580.882175 505.117671 9.847266" -$ns_ at 98.000000 "$node_(9) setdest 542.784470 531.635980 18.965860" -$ns_ at 98.000000 "$node_(10) setdest 575.265149 465.030323 19.938201" - -$ns_ at 99.000000 "$node_(1) setdest 441.489099 2.335719 12.003549" -$ns_ at 99.000000 "$node_(2) setdest 586.056851 127.939810 14.289078" -$ns_ at 99.000000 "$node_(3) setdest 444.433154 100.546506 9.318461" -$ns_ at 99.000000 "$node_(4) setdest 563.604426 11.802092 15.860034" -$ns_ at 99.000000 "$node_(5) setdest 413.431025 153.540340 4.058058" -$ns_ at 99.000000 "$node_(6) setdest 468.323715 353.930297 6.701979" -$ns_ at 99.000000 "$node_(7) setdest 422.987216 486.505659 12.547341" -$ns_ at 99.000000 "$node_(8) setdest 569.510780 507.343850 11.587256" -$ns_ at 99.000000 "$node_(9) setdest 530.489038 544.913627 18.096231" -$ns_ at 99.000000 "$node_(10) setdest 581.656414 446.357042 19.736760" - -$ns_ at 100.000000 "$node_(1) setdest 454.447553 5.677176 13.382334" -$ns_ at 100.000000 "$node_(2) setdest 586.790587 143.764948 15.842139" -$ns_ at 100.000000 "$node_(3) setdest 454.264488 105.292106 10.916769" -$ns_ at 100.000000 "$node_(4) setdest 547.205392 5.747685 17.480967" -$ns_ at 100.000000 "$node_(5) setdest 419.055426 154.172769 5.659845" -$ns_ at 100.000000 "$node_(6) setdest 468.513902 353.682612 0.312280" -$ns_ at 100.000000 "$node_(7) setdest 425.531876 476.300999 10.517147" -$ns_ at 100.000000 "$node_(8) setdest 568.125928 506.009333 1.923214" -$ns_ at 100.000000 "$node_(9) setdest 534.125064 533.948308 11.552442" -$ns_ at 100.000000 "$node_(10) setdest 574.270722 427.825799 19.948820" - -$ns_ at 101.000000 "$node_(1) setdest 463.974595 17.337902 15.057791" -$ns_ at 101.000000 "$node_(2) setdest 588.818288 160.985039 17.339062" -$ns_ at 101.000000 "$node_(3) setdest 465.953584 109.763324 12.515061" -$ns_ at 101.000000 "$node_(4) setdest 528.686907 4.225543 18.580936" -$ns_ at 101.000000 "$node_(5) setdest 426.301451 153.959775 7.249155" -$ns_ at 101.000000 "$node_(6) setdest 468.409172 351.964764 1.721038" -$ns_ at 101.000000 "$node_(7) setdest 425.627464 463.860769 12.440598" -$ns_ at 101.000000 "$node_(8) setdest 568.230938 502.795685 3.215363" -$ns_ at 101.000000 "$node_(9) setdest 534.843844 520.422103 13.545289" -$ns_ at 101.000000 "$node_(10) setdest 565.376509 409.915463 19.997179" - -$ns_ at 102.000000 "$node_(1) setdest 469.266398 33.192266 16.714186" -$ns_ at 102.000000 "$node_(2) setdest 583.250087 179.129202 18.979345" -$ns_ at 102.000000 "$node_(3) setdest 479.708421 112.845067 14.095839" -$ns_ at 102.000000 "$node_(4) setdest 513.846746 13.845484 17.685407" -$ns_ at 102.000000 "$node_(5) setdest 434.772540 151.433158 8.839861" -$ns_ at 102.000000 "$node_(6) setdest 467.957451 348.674042 3.321581" -$ns_ at 102.000000 "$node_(7) setdest 425.462374 449.821538 14.040202" -$ns_ at 102.000000 "$node_(8) setdest 568.504849 497.988118 4.815363" -$ns_ at 102.000000 "$node_(9) setdest 536.479818 505.366286 15.144440" -$ns_ at 102.000000 "$node_(10) setdest 555.303153 392.642708 19.995513" - -$ns_ at 103.000000 "$node_(1) setdest 465.730169 51.026601 18.181541" -$ns_ at 103.000000 "$node_(2) setdest 566.879047 186.735999 18.051989" -$ns_ at 103.000000 "$node_(3) setdest 495.386590 112.701027 15.678831" -$ns_ at 103.000000 "$node_(4) setdest 498.374210 23.147625 18.053509" -$ns_ at 103.000000 "$node_(5) setdest 443.971210 146.477076 10.448841" -$ns_ at 103.000000 "$node_(6) setdest 467.040158 343.838883 4.921401" -$ns_ at 103.000000 "$node_(7) setdest 424.846982 434.193648 15.640001" -$ns_ at 103.000000 "$node_(8) setdest 568.959563 491.588797 6.415456" -$ns_ at 103.000000 "$node_(9) setdest 539.291404 488.859842 16.744184" -$ns_ at 103.000000 "$node_(10) setdest 543.978114 376.161913 19.996828" - -$ns_ at 104.000000 "$node_(1) setdest 453.885584 66.862210 19.775255" -$ns_ at 104.000000 "$node_(2) setdest 550.420005 182.065219 17.108953" -$ns_ at 104.000000 "$node_(3) setdest 512.035228 108.074256 17.279588" -$ns_ at 104.000000 "$node_(4) setdest 480.422154 28.888008 18.847502" -$ns_ at 104.000000 "$node_(5) setdest 453.481156 139.084396 12.045363" -$ns_ at 104.000000 "$node_(6) setdest 465.522276 337.496223 6.521756" -$ns_ at 104.000000 "$node_(7) setdest 423.890552 416.980065 17.240133" -$ns_ at 104.000000 "$node_(8) setdest 569.408345 483.586152 8.015219" -$ns_ at 104.000000 "$node_(9) setdest 542.421361 470.785101 18.343743" -$ns_ at 104.000000 "$node_(10) setdest 532.315171 359.914903 19.999739" - -$ns_ at 105.000000 "$node_(1) setdest 441.554672 82.598803 19.992292" -$ns_ at 105.000000 "$node_(2) setdest 539.013776 170.214626 16.448058" -$ns_ at 105.000000 "$node_(3) setdest 529.234106 100.206225 18.913152" -$ns_ at 105.000000 "$node_(4) setdest 461.595790 33.254097 19.326011" -$ns_ at 105.000000 "$node_(5) setdest 463.150011 129.433979 13.660795" -$ns_ at 105.000000 "$node_(6) setdest 464.066377 329.507246 8.120554" -$ns_ at 105.000000 "$node_(7) setdest 423.478241 398.145310 18.839268" -$ns_ at 105.000000 "$node_(8) setdest 569.653858 473.974181 9.615106" -$ns_ at 105.000000 "$node_(9) setdest 544.689190 451.144354 19.771242" -$ns_ at 105.000000 "$node_(10) setdest 521.557519 343.060211 19.995192" - -$ns_ at 106.000000 "$node_(1) setdest 426.035377 95.120154 19.940731" -$ns_ at 106.000000 "$node_(2) setdest 527.796998 156.046188 18.070991" -$ns_ at 106.000000 "$node_(3) setdest 546.577423 90.292431 19.976836" -$ns_ at 106.000000 "$node_(4) setdest 442.458573 31.949902 19.181606" -$ns_ at 106.000000 "$node_(5) setdest 473.667535 118.375737 15.261160" -$ns_ at 106.000000 "$node_(6) setdest 463.038352 319.841988 9.719776" -$ns_ at 106.000000 "$node_(7) setdest 424.022196 378.194573 19.958150" -$ns_ at 106.000000 "$node_(8) setdest 569.813158 462.759869 11.215443" -$ns_ at 106.000000 "$node_(9) setdest 547.190950 431.303404 19.998052" -$ns_ at 106.000000 "$node_(10) setdest 512.059389 325.464003 19.996025" - -$ns_ at 107.000000 "$node_(1) setdest 413.339629 110.424764 19.884997" -$ns_ at 107.000000 "$node_(2) setdest 522.889895 138.019659 18.682489" -$ns_ at 107.000000 "$node_(3) setdest 562.785458 78.657080 19.951987" -$ns_ at 107.000000 "$node_(4) setdest 424.326276 36.316554 18.650680" -$ns_ at 107.000000 "$node_(5) setdest 485.278736 106.151196 16.859994" -$ns_ at 107.000000 "$node_(6) setdest 462.686740 308.528017 11.319434" -$ns_ at 107.000000 "$node_(7) setdest 425.056084 358.221365 19.999950" -$ns_ at 107.000000 "$node_(8) setdest 570.011307 449.945947 12.815454" -$ns_ at 107.000000 "$node_(9) setdest 550.802202 411.635114 19.997070" -$ns_ at 107.000000 "$node_(10) setdest 504.100758 307.123887 19.992490" - -$ns_ at 108.000000 "$node_(1) setdest 403.484524 120.881194 14.368718" -$ns_ at 108.000000 "$node_(2) setdest 522.671723 118.777356 19.243540" -$ns_ at 108.000000 "$node_(3) setdest 566.030236 61.969468 17.000146" -$ns_ at 108.000000 "$node_(4) setdest 406.729266 43.449566 18.987750" -$ns_ at 108.000000 "$node_(5) setdest 498.299352 93.063657 18.461314" -$ns_ at 108.000000 "$node_(6) setdest 463.350139 295.626592 12.918469" -$ns_ at 108.000000 "$node_(7) setdest 425.713473 338.232633 19.999539" -$ns_ at 108.000000 "$node_(8) setdest 570.151839 435.531284 14.415348" -$ns_ at 108.000000 "$node_(9) setdest 553.849836 391.873169 19.995562" -$ns_ at 108.000000 "$node_(10) setdest 497.862638 288.126445 19.995423" - -$ns_ at 109.000000 "$node_(1) setdest 403.989736 119.896423 1.106803" -$ns_ at 109.000000 "$node_(2) setdest 528.443915 101.055487 18.638209" -$ns_ at 109.000000 "$node_(3) setdest 555.086711 59.581719 11.200986" -$ns_ at 109.000000 "$node_(4) setdest 419.658364 34.543594 15.699616" -$ns_ at 109.000000 "$node_(5) setdest 512.018250 78.744240 19.830629" -$ns_ at 109.000000 "$node_(6) setdest 465.226532 281.230082 14.518276" -$ns_ at 109.000000 "$node_(7) setdest 425.892742 318.233998 19.999438" -$ns_ at 109.000000 "$node_(8) setdest 569.845697 419.519895 16.014315" -$ns_ at 109.000000 "$node_(9) setdest 555.287187 371.932228 19.992677" -$ns_ at 109.000000 "$node_(10) setdest 493.133245 268.700773 19.993096" - -$ns_ at 110.000000 "$node_(1) setdest 405.689023 117.799747 2.698820" -$ns_ at 110.000000 "$node_(2) setdest 542.452784 89.981334 17.857360" -$ns_ at 110.000000 "$node_(3) setdest 541.878384 60.468639 13.238071" -$ns_ at 110.000000 "$node_(4) setdest 431.508634 26.710829 14.204967" -$ns_ at 110.000000 "$node_(5) setdest 525.437273 63.918876 19.996540" -$ns_ at 110.000000 "$node_(6) setdest 468.870766 265.532533 16.115008" -$ns_ at 110.000000 "$node_(7) setdest 425.465752 298.239034 19.999523" -$ns_ at 110.000000 "$node_(8) setdest 568.423672 401.966936 17.610467" -$ns_ at 110.000000 "$node_(9) setdest 554.604727 351.953670 19.990211" -$ns_ at 110.000000 "$node_(10) setdest 490.462288 248.888314 19.991687" - -$ns_ at 111.000000 "$node_(1) setdest 409.267839 115.417933 4.298949" -$ns_ at 111.000000 "$node_(2) setdest 559.897956 86.045463 17.883655" -$ns_ at 111.000000 "$node_(3) setdest 527.059137 59.782209 14.835137" -$ns_ at 111.000000 "$node_(4) setdest 443.573833 19.915640 13.847152" -$ns_ at 111.000000 "$node_(5) setdest 538.192908 48.515225 19.999468" -$ns_ at 111.000000 "$node_(6) setdest 473.714036 248.485385 17.721809" -$ns_ at 111.000000 "$node_(7) setdest 424.698720 278.254092 19.999656" -$ns_ at 111.000000 "$node_(8) setdest 566.060462 382.899839 19.212989" -$ns_ at 111.000000 "$node_(9) setdest 551.708859 332.174554 19.989984" -$ns_ at 111.000000 "$node_(10) setdest 489.396329 228.922479 19.994270" - -$ns_ at 112.000000 "$node_(1) setdest 414.950785 113.903111 5.881374" -$ns_ at 112.000000 "$node_(2) setdest 578.124561 87.480642 18.283021" -$ns_ at 112.000000 "$node_(3) setdest 510.636699 60.626058 16.444104" -$ns_ at 112.000000 "$node_(4) setdest 457.652786 13.663710 15.404660" -$ns_ at 112.000000 "$node_(5) setdest 551.827674 34.309326 19.690465" -$ns_ at 112.000000 "$node_(6) setdest 478.228138 229.700152 19.319992" -$ns_ at 112.000000 "$node_(7) setdest 422.398639 258.396580 19.990277" -$ns_ at 112.000000 "$node_(8) setdest 565.174425 362.924990 19.994490" -$ns_ at 112.000000 "$node_(9) setdest 546.871512 312.774624 19.993929" -$ns_ at 112.000000 "$node_(10) setdest 491.447099 209.200491 19.828325" - -$ns_ at 113.000000 "$node_(1) setdest 422.446166 114.130760 7.498837" -$ns_ at 113.000000 "$node_(2) setdest 591.915195 78.408014 16.507397" -$ns_ at 113.000000 "$node_(3) setdest 492.624699 59.666840 18.037523" -$ns_ at 113.000000 "$node_(4) setdest 472.214347 5.489961 16.698779" -$ns_ at 113.000000 "$node_(5) setdest 551.486872 35.177611 0.932773" -$ns_ at 113.000000 "$node_(6) setdest 482.217820 210.104151 19.998020" -$ns_ at 113.000000 "$node_(7) setdest 417.831564 238.927314 19.997762" -$ns_ at 113.000000 "$node_(8) setdest 564.744712 342.930184 19.999424" -$ns_ at 113.000000 "$node_(9) setdest 540.209785 293.926814 19.990462" -$ns_ at 113.000000 "$node_(10) setdest 504.489346 196.354667 18.306158" - -$ns_ at 114.000000 "$node_(1) setdest 431.271998 116.305610 9.089845" -$ns_ at 114.000000 "$node_(2) setdest 588.736507 63.560605 15.183860" -$ns_ at 114.000000 "$node_(3) setdest 473.963039 54.031040 19.494096" -$ns_ at 114.000000 "$node_(4) setdest 473.434460 2.312632 3.403542" -$ns_ at 114.000000 "$node_(5) setdest 548.218838 37.090081 3.786501" -$ns_ at 114.000000 "$node_(6) setdest 484.657569 190.258834 19.994725" -$ns_ at 114.000000 "$node_(7) setdest 414.150519 219.279742 19.989426" -$ns_ at 114.000000 "$node_(8) setdest 563.955033 322.946138 19.999642" -$ns_ at 114.000000 "$node_(9) setdest 531.976806 275.701992 19.998151" -$ns_ at 114.000000 "$node_(10) setdest 520.244752 190.438199 16.829659" - -$ns_ at 115.000000 "$node_(1) setdest 440.908069 120.949190 10.696574" -$ns_ at 115.000000 "$node_(2) setdest 580.431419 50.836504 15.194645" -$ns_ at 115.000000 "$node_(3) setdest 456.876131 43.692246 19.971307" -$ns_ at 115.000000 "$node_(4) setdest 472.869595 2.467477 0.585704" -$ns_ at 115.000000 "$node_(5) setdest 543.700691 40.023340 5.386804" -$ns_ at 115.000000 "$node_(6) setdest 485.938648 170.301151 19.998756" -$ns_ at 115.000000 "$node_(7) setdest 414.076804 199.317789 19.962089" -$ns_ at 115.000000 "$node_(8) setdest 563.190475 302.961948 19.998810" -$ns_ at 115.000000 "$node_(9) setdest 522.369871 258.168219 19.993159" -$ns_ at 115.000000 "$node_(10) setdest 534.924858 194.630099 15.266877" - -$ns_ at 116.000000 "$node_(1) setdest 451.284786 127.573697 12.310985" -$ns_ at 116.000000 "$node_(2) setdest 569.402032 38.175636 16.791217" -$ns_ at 116.000000 "$node_(3) setdest 440.770647 31.838598 19.997390" -$ns_ at 116.000000 "$node_(4) setdest 472.841751 4.274661 1.807398" -$ns_ at 116.000000 "$node_(5) setdest 537.436100 43.104717 6.981403" -$ns_ at 116.000000 "$node_(6) setdest 486.954575 150.332081 19.994896" -$ns_ at 116.000000 "$node_(7) setdest 417.830901 179.685288 19.988205" -$ns_ at 116.000000 "$node_(8) setdest 563.641683 282.971460 19.995579" -$ns_ at 116.000000 "$node_(9) setdest 511.298664 241.517648 19.995328" -$ns_ at 116.000000 "$node_(10) setdest 550.011999 194.908027 15.089700" - -$ns_ at 117.000000 "$node_(1) setdest 462.138089 136.267655 13.906081" -$ns_ at 117.000000 "$node_(2) setdest 556.634968 24.940619 18.389225" -$ns_ at 117.000000 "$node_(3) setdest 425.324448 19.136132 19.998443" -$ns_ at 117.000000 "$node_(4) setdest 473.314494 7.680851 3.438840" -$ns_ at 117.000000 "$node_(5) setdest 529.438223 46.226951 8.585708" -$ns_ at 117.000000 "$node_(6) setdest 490.129007 130.598208 19.987566" -$ns_ at 117.000000 "$node_(7) setdest 423.966373 160.668563 19.981989" -$ns_ at 117.000000 "$node_(8) setdest 565.740884 263.087161 19.994799" -$ns_ at 117.000000 "$node_(9) setdest 499.055031 225.704650 19.998936" -$ns_ at 117.000000 "$node_(10) setdest 563.557238 186.500635 15.942326" - -$ns_ at 118.000000 "$node_(1) setdest 473.241458 147.092544 15.506870" -$ns_ at 118.000000 "$node_(2) setdest 539.814754 14.774438 19.653774" -$ns_ at 118.000000 "$node_(3) setdest 409.111886 8.883379 19.182442" -$ns_ at 118.000000 "$node_(4) setdest 473.692202 12.706450 5.039772" -$ns_ at 118.000000 "$node_(5) setdest 519.739209 49.337753 10.185674" -$ns_ at 118.000000 "$node_(6) setdest 496.431453 111.642085 19.976371" -$ns_ at 118.000000 "$node_(7) setdest 432.569997 142.630498 19.984847" -$ns_ at 118.000000 "$node_(8) setdest 568.702436 243.307677 19.999970" -$ns_ at 118.000000 "$node_(9) setdest 485.443278 211.070870 19.985678" -$ns_ at 118.000000 "$node_(10) setdest 570.192106 171.160831 16.713200" - -$ns_ at 119.000000 "$node_(1) setdest 487.251601 156.862702 17.080401" -$ns_ at 119.000000 "$node_(2) setdest 520.683497 9.021841 19.977421" -$ns_ at 119.000000 "$node_(3) setdest 417.073766 12.056418 8.570864" -$ns_ at 119.000000 "$node_(4) setdest 474.036968 19.336302 6.638810" -$ns_ at 119.000000 "$node_(5) setdest 508.315867 52.234824 11.784981" -$ns_ at 119.000000 "$node_(6) setdest 506.265369 94.271345 19.961175" -$ns_ at 119.000000 "$node_(7) setdest 443.201855 125.694874 19.996294" -$ns_ at 119.000000 "$node_(8) setdest 571.628211 223.523019 19.999821" -$ns_ at 119.000000 "$node_(9) setdest 470.395480 197.901690 19.996588" -$ns_ at 119.000000 "$node_(10) setdest 581.059668 156.562270 18.199503" - -$ns_ at 120.000000 "$node_(1) setdest 504.954771 159.215359 17.858813" -$ns_ at 120.000000 "$node_(2) setdest 501.192874 10.606251 19.554916" -$ns_ at 120.000000 "$node_(3) setdest 423.571462 19.617907 9.969763" -$ns_ at 120.000000 "$node_(4) setdest 474.472309 27.560057 8.235270" -$ns_ at 120.000000 "$node_(5) setdest 495.207683 54.945946 13.385614" -$ns_ at 120.000000 "$node_(6) setdest 520.516470 80.409235 19.880946" -$ns_ at 120.000000 "$node_(7) setdest 453.570709 108.596480 19.996705" -$ns_ at 120.000000 "$node_(8) setdest 573.762328 203.638794 19.998422" -$ns_ at 120.000000 "$node_(9) setdest 453.975818 186.542303 19.965996" -$ns_ at 120.000000 "$node_(10) setdest 592.135494 143.826225 16.878411" - -$ns_ at 121.000000 "$node_(1) setdest 509.718099 146.506082 13.572583" -$ns_ at 121.000000 "$node_(2) setdest 484.117793 19.082124 19.063023" -$ns_ at 121.000000 "$node_(3) setdest 433.058684 26.201559 11.547808" -$ns_ at 121.000000 "$node_(4) setdest 476.147484 37.254243 9.837858" -$ns_ at 121.000000 "$node_(5) setdest 480.493467 57.703401 14.970361" -$ns_ at 121.000000 "$node_(6) setdest 537.165573 83.737558 16.978527" -$ns_ at 121.000000 "$node_(7) setdest 464.612917 91.921714 19.999454" -$ns_ at 121.000000 "$node_(8) setdest 575.622097 183.725674 19.999777" -$ns_ at 121.000000 "$node_(9) setdest 435.402591 179.523497 19.855186" -$ns_ at 121.000000 "$node_(10) setdest 589.495037 140.928854 3.920047" - -$ns_ at 122.000000 "$node_(1) setdest 501.618767 135.407562 13.739589" -$ns_ at 122.000000 "$node_(2) setdest 468.354636 30.000884 19.175412" -$ns_ at 122.000000 "$node_(3) setdest 444.780251 32.212762 13.173066" -$ns_ at 122.000000 "$node_(4) setdest 478.682436 48.409195 11.439359" -$ns_ at 122.000000 "$node_(5) setdest 465.298067 64.267961 16.552753" -$ns_ at 122.000000 "$node_(6) setdest 544.950948 98.256877 16.474910" -$ns_ at 122.000000 "$node_(7) setdest 475.946542 75.443825 19.999297" -$ns_ at 122.000000 "$node_(8) setdest 576.534377 163.749996 19.996499" -$ns_ at 122.000000 "$node_(9) setdest 434.434766 179.467028 0.969471" -$ns_ at 122.000000 "$node_(10) setdest 584.521690 139.425209 5.195683" - -$ns_ at 123.000000 "$node_(1) setdest 492.075637 123.450755 15.298253" -$ns_ at 123.000000 "$node_(2) setdest 455.863068 44.093278 18.831751" -$ns_ at 123.000000 "$node_(3) setdest 458.619999 37.371581 14.769972" -$ns_ at 123.000000 "$node_(4) setdest 482.138433 60.980026 13.037244" -$ns_ at 123.000000 "$node_(5) setdest 449.568122 73.372764 18.174944" -$ns_ at 123.000000 "$node_(6) setdest 555.460624 109.423500 15.334495" -$ns_ at 123.000000 "$node_(7) setdest 488.072608 59.566099 19.978580" -$ns_ at 123.000000 "$node_(8) setdest 575.616599 143.782691 19.988386" -$ns_ at 123.000000 "$node_(9) setdest 437.345563 182.540188 4.232854" -$ns_ at 123.000000 "$node_(10) setdest 578.082071 137.243055 6.799300" - -$ns_ at 124.000000 "$node_(1) setdest 481.629922 110.164467 16.900841" -$ns_ at 124.000000 "$node_(2) setdest 442.838643 58.392410 19.341686" -$ns_ at 124.000000 "$node_(3) setdest 474.615429 40.719637 16.342070" -$ns_ at 124.000000 "$node_(4) setdest 486.172579 75.052483 14.639275" -$ns_ at 124.000000 "$node_(5) setdest 430.524277 77.428350 19.470897" -$ns_ at 124.000000 "$node_(6) setdest 570.380491 116.561320 16.539374" -$ns_ at 124.000000 "$node_(7) setdest 503.421106 46.832482 19.942953" -$ns_ at 124.000000 "$node_(8) setdest 571.969243 124.135771 19.982610" -$ns_ at 124.000000 "$node_(9) setdest 437.850553 188.097996 5.580703" -$ns_ at 124.000000 "$node_(10) setdest 570.292753 134.115544 8.393736" - -$ns_ at 125.000000 "$node_(1) setdest 468.764309 108.362457 12.991198" -$ns_ at 125.000000 "$node_(2) setdest 424.365917 65.103086 19.653874" -$ns_ at 125.000000 "$node_(3) setdest 458.785742 38.071495 16.049662" -$ns_ at 125.000000 "$node_(4) setdest 485.862028 75.256264 0.371442" -$ns_ at 125.000000 "$node_(5) setdest 410.538520 78.179722 19.999876" -$ns_ at 125.000000 "$node_(6) setdest 586.519711 124.964926 18.196017" -$ns_ at 125.000000 "$node_(7) setdest 522.204110 40.543630 19.807850" -$ns_ at 125.000000 "$node_(8) setdest 565.283378 105.313652 19.974308" -$ns_ at 125.000000 "$node_(9) setdest 438.236927 188.566948 0.607619" -$ns_ at 125.000000 "$node_(10) setdest 561.454881 129.437687 9.999516" - -$ns_ at 126.000000 "$node_(1) setdest 453.894330 110.665395 15.047252" -$ns_ at 126.000000 "$node_(2) setdest 404.988454 70.046829 19.998166" -$ns_ at 126.000000 "$node_(3) setdest 440.858781 37.340840 17.941845" -$ns_ at 126.000000 "$node_(4) setdest 484.107042 74.965456 1.778916" -$ns_ at 126.000000 "$node_(5) setdest 390.542704 78.440085 19.997511" -$ns_ at 126.000000 "$node_(6) setdest 592.964875 127.196911 6.820696" -$ns_ at 126.000000 "$node_(7) setdest 542.036992 42.707094 19.950533" -$ns_ at 126.000000 "$node_(8) setdest 554.346165 88.643407 19.937896" -$ns_ at 126.000000 "$node_(9) setdest 438.863799 187.609138 1.144713" -$ns_ at 126.000000 "$node_(10) setdest 550.853562 124.755186 11.589383" - -$ns_ at 127.000000 "$node_(1) setdest 437.536983 113.753231 16.646247" -$ns_ at 127.000000 "$node_(2) setdest 385.400042 74.078678 19.999042" -$ns_ at 127.000000 "$node_(3) setdest 421.408233 35.863244 19.506591" -$ns_ at 127.000000 "$node_(4) setdest 480.756885 74.527052 3.378720" -$ns_ at 127.000000 "$node_(5) setdest 370.587368 77.185177 19.994756" -$ns_ at 127.000000 "$node_(6) setdest 591.806569 125.973434 1.684805" -$ns_ at 127.000000 "$node_(7) setdest 561.938216 44.598425 19.990894" -$ns_ at 127.000000 "$node_(8) setdest 538.791423 76.225827 19.903424" -$ns_ at 127.000000 "$node_(9) setdest 439.851088 185.026858 2.764582" -$ns_ at 127.000000 "$node_(10) setdest 538.598737 119.856049 13.197813" - -$ns_ at 128.000000 "$node_(1) setdest 419.670201 117.456660 18.246569" -$ns_ at 128.000000 "$node_(2) setdest 365.724919 77.666346 19.999545" -$ns_ at 128.000000 "$node_(3) setdest 401.445644 34.670369 19.998197" -$ns_ at 128.000000 "$node_(4) setdest 475.797670 74.087926 4.978620" -$ns_ at 128.000000 "$node_(5) setdest 350.726157 74.834010 19.999892" -$ns_ at 128.000000 "$node_(6) setdest 589.270539 123.860295 3.301031" -$ns_ at 128.000000 "$node_(7) setdest 581.791247 44.803262 19.854088" -$ns_ at 128.000000 "$node_(8) setdest 520.702123 67.707079 19.994795" -$ns_ at 128.000000 "$node_(9) setdest 441.303563 180.909826 4.365734" -$ns_ at 128.000000 "$node_(10) setdest 525.473635 113.036002 14.791260" - -$ns_ at 129.000000 "$node_(1) setdest 400.190414 120.538102 19.722002" -$ns_ at 129.000000 "$node_(2) setdest 345.957172 80.701765 19.999440" -$ns_ at 129.000000 "$node_(3) setdest 381.449576 34.354000 19.998570" -$ns_ at 129.000000 "$node_(4) setdest 469.225898 73.791977 6.578432" -$ns_ at 129.000000 "$node_(5) setdest 330.797553 73.177839 19.997304" -$ns_ at 129.000000 "$node_(6) setdest 585.243076 121.062983 4.903612" -$ns_ at 129.000000 "$node_(7) setdest 588.511397 48.281694 7.567028" -$ns_ at 129.000000 "$node_(8) setdest 502.905331 58.615452 19.984581" -$ns_ at 129.000000 "$node_(9) setdest 443.695561 175.443621 5.966662" -$ns_ at 129.000000 "$node_(10) setdest 511.499269 104.458277 16.396959" - -$ns_ at 130.000000 "$node_(1) setdest 380.319010 122.788460 19.998421" -$ns_ at 130.000000 "$node_(2) setdest 326.114659 83.198800 19.999013" -$ns_ at 130.000000 "$node_(3) setdest 361.450892 34.562067 19.999767" -$ns_ at 130.000000 "$node_(4) setdest 461.047591 73.796428 8.178308" -$ns_ at 130.000000 "$node_(5) setdest 310.805689 73.087262 19.992069" -$ns_ at 130.000000 "$node_(6) setdest 580.472921 116.653619 6.495912" -$ns_ at 130.000000 "$node_(7) setdest 586.575808 48.184730 1.938017" -$ns_ at 130.000000 "$node_(8) setdest 485.758668 48.322000 19.999080" -$ns_ at 130.000000 "$node_(9) setdest 446.859035 168.570017 7.566637" -$ns_ at 130.000000 "$node_(10) setdest 497.658476 92.981586 17.980044" - -$ns_ at 131.000000 "$node_(1) setdest 360.365366 124.127494 19.998522" -$ns_ at 131.000000 "$node_(2) setdest 306.164975 84.538799 19.994637" -$ns_ at 131.000000 "$node_(3) setdest 341.453459 34.881321 19.999981" -$ns_ at 131.000000 "$node_(4) setdest 451.277647 74.201781 9.778349" -$ns_ at 131.000000 "$node_(5) setdest 290.929481 75.205162 19.988725" -$ns_ at 131.000000 "$node_(6) setdest 575.708834 110.114534 8.090498" -$ns_ at 131.000000 "$node_(7) setdest 583.023276 48.266735 3.553478" -$ns_ at 131.000000 "$node_(8) setdest 468.711352 37.876329 19.993075" -$ns_ at 131.000000 "$node_(9) setdest 451.428019 160.631101 9.159804" -$ns_ at 131.000000 "$node_(10) setdest 485.035837 78.081245 19.528215" - -$ns_ at 132.000000 "$node_(1) setdest 340.372607 124.577953 19.997833" -$ns_ at 132.000000 "$node_(2) setdest 286.178506 84.073191 19.991892" -$ns_ at 132.000000 "$node_(3) setdest 321.454012 34.894377 19.999451" -$ns_ at 132.000000 "$node_(4) setdest 439.923459 74.951472 11.378912" -$ns_ at 132.000000 "$node_(5) setdest 271.481106 79.805860 19.985138" -$ns_ at 132.000000 "$node_(6) setdest 571.726779 101.275821 9.694308" -$ns_ at 132.000000 "$node_(7) setdest 577.934453 49.068828 5.151648" -$ns_ at 132.000000 "$node_(8) setdest 450.507813 29.624318 19.986609" -$ns_ at 132.000000 "$node_(9) setdest 457.527500 151.759105 10.766428" -$ns_ at 132.000000 "$node_(10) setdest 474.583709 61.040590 19.990771" - -$ns_ at 133.000000 "$node_(1) setdest 320.380450 124.065568 19.998722" -$ns_ at 133.000000 "$node_(2) setdest 266.383509 81.306673 19.987384" -$ns_ at 133.000000 "$node_(3) setdest 301.478147 33.972686 19.997117" -$ns_ at 133.000000 "$node_(4) setdest 426.974114 75.826178 12.978853" -$ns_ at 133.000000 "$node_(5) setdest 252.963837 87.304381 19.977914" -$ns_ at 133.000000 "$node_(6) setdest 568.310797 90.505002 11.299534" -$ns_ at 133.000000 "$node_(7) setdest 571.352734 50.591970 6.755663" -$ns_ at 133.000000 "$node_(8) setdest 430.748481 26.892605 19.947266" -$ns_ at 133.000000 "$node_(9) setdest 464.585787 141.605483 12.365900" -$ns_ at 133.000000 "$node_(10) setdest 461.707413 45.848981 19.914416" - -$ns_ at 134.000000 "$node_(1) setdest 300.449527 122.443033 19.996858" -$ns_ at 134.000000 "$node_(2) setdest 247.068943 76.153410 19.990212" -$ns_ at 134.000000 "$node_(3) setdest 281.620279 31.641423 19.994242" -$ns_ at 134.000000 "$node_(4) setdest 412.407798 76.413196 14.578139" -$ns_ at 134.000000 "$node_(5) setdest 236.182515 98.124469 19.967150" -$ns_ at 134.000000 "$node_(6) setdest 565.493969 77.924687 12.891814" -$ns_ at 134.000000 "$node_(7) setdest 563.139327 52.127120 8.355642" -$ns_ at 134.000000 "$node_(8) setdest 416.947036 15.226109 18.071719" -$ns_ at 134.000000 "$node_(9) setdest 472.330576 129.982714 13.966765" -$ns_ at 134.000000 "$node_(10) setdest 445.040272 34.848403 19.970135" - -$ns_ at 135.000000 "$node_(1) setdest 280.660058 119.566270 19.997470" -$ns_ at 135.000000 "$node_(2) setdest 228.579859 68.567935 19.984636" -$ns_ at 135.000000 "$node_(3) setdest 261.870140 28.489966 19.999992" -$ns_ at 135.000000 "$node_(4) setdest 396.230443 76.619532 16.178671" -$ns_ at 135.000000 "$node_(5) setdest 221.570082 111.764000 19.988997" -$ns_ at 135.000000 "$node_(6) setdest 565.462360 63.456976 14.467745" -$ns_ at 135.000000 "$node_(7) setdest 553.580974 54.883009 9.947715" -$ns_ at 135.000000 "$node_(8) setdest 426.301069 2.292969 15.961330" -$ns_ at 135.000000 "$node_(9) setdest 481.564388 117.456807 15.561543" -$ns_ at 135.000000 "$node_(10) setdest 426.598641 27.230647 19.953044" - -$ns_ at 136.000000 "$node_(1) setdest 260.964022 116.093665 19.999821" -$ns_ at 136.000000 "$node_(2) setdest 211.157455 58.763950 19.991455" -$ns_ at 136.000000 "$node_(3) setdest 242.069536 25.684400 19.998378" -$ns_ at 136.000000 "$node_(4) setdest 378.451498 76.635633 17.778952" -$ns_ at 136.000000 "$node_(5) setdest 207.405609 125.883222 19.999618" -$ns_ at 136.000000 "$node_(6) setdest 570.550150 48.286694 16.000721" -$ns_ at 136.000000 "$node_(7) setdest 543.178360 59.884928 11.542685" -$ns_ at 136.000000 "$node_(8) setdest 439.426261 7.213786 14.017314" -$ns_ at 136.000000 "$node_(9) setdest 492.799836 104.479486 17.165259" -$ns_ at 136.000000 "$node_(10) setdest 416.515775 29.332216 10.299553" - -$ns_ at 137.000000 "$node_(1) setdest 241.166659 113.273096 19.997279" -$ns_ at 137.000000 "$node_(2) setdest 193.607811 49.185768 19.993288" -$ns_ at 137.000000 "$node_(3) setdest 222.148163 23.923978 19.999004" -$ns_ at 137.000000 "$node_(4) setdest 359.072806 76.657629 19.378705" -$ns_ at 137.000000 "$node_(5) setdest 192.886203 139.634471 19.997750" -$ns_ at 137.000000 "$node_(6) setdest 583.970533 42.100482 14.777547" -$ns_ at 137.000000 "$node_(7) setdest 532.296270 67.248819 13.139511" -$ns_ at 137.000000 "$node_(8) setdest 453.839916 9.148842 14.542968" -$ns_ at 137.000000 "$node_(9) setdest 505.861846 91.012627 18.760928" -$ns_ at 137.000000 "$node_(10) setdest 417.284418 30.284041 1.223431" - -$ns_ at 138.000000 "$node_(1) setdest 221.227107 111.767797 19.996292" -$ns_ at 138.000000 "$node_(2) setdest 175.271841 41.218919 19.991961" -$ns_ at 138.000000 "$node_(3) setdest 202.333247 21.224188 19.997993" -$ns_ at 138.000000 "$node_(4) setdest 339.081034 77.216611 19.999585" -$ns_ at 138.000000 "$node_(5) setdest 177.604021 152.479213 19.963278" -$ns_ at 138.000000 "$node_(6) setdest 588.327423 50.944124 9.858625" -$ns_ at 138.000000 "$node_(7) setdest 521.858823 77.648040 14.733774" -$ns_ at 138.000000 "$node_(8) setdest 470.072953 9.536007 16.237653" -$ns_ at 138.000000 "$node_(9) setdest 520.526387 77.499927 19.940959" -$ns_ at 138.000000 "$node_(10) setdest 420.076823 30.790374 2.837939" - -$ns_ at 139.000000 "$node_(1) setdest 201.240697 111.066682 19.998704" -$ns_ at 139.000000 "$node_(2) setdest 164.466411 38.985513 11.033831" -$ns_ at 139.000000 "$node_(3) setdest 184.238943 13.733066 19.583686" -$ns_ at 139.000000 "$node_(4) setdest 319.132136 78.610994 19.997570" -$ns_ at 139.000000 "$node_(5) setdest 159.330537 160.396138 19.914767" -$ns_ at 139.000000 "$node_(6) setdest 588.282286 62.792033 11.847995" -$ns_ at 139.000000 "$node_(7) setdest 512.243129 90.872745 16.350976" -$ns_ at 139.000000 "$node_(8) setdest 487.878750 9.368775 17.806582" -$ns_ at 139.000000 "$node_(9) setdest 536.534192 65.547922 19.977493" -$ns_ at 139.000000 "$node_(10) setdest 424.324084 29.536639 4.428439" - -$ns_ at 140.000000 "$node_(1) setdest 181.242347 111.274656 19.999432" -$ns_ at 140.000000 "$node_(2) setdest 175.502159 37.272010 11.167982" -$ns_ at 140.000000 "$node_(3) setdest 182.074451 1.712658 12.213731" -$ns_ at 140.000000 "$node_(4) setdest 299.283899 81.049008 19.997411" -$ns_ at 140.000000 "$node_(5) setdest 139.532044 162.682204 19.930038" -$ns_ at 140.000000 "$node_(6) setdest 589.138402 76.155223 13.390586" -$ns_ at 140.000000 "$node_(7) setdest 501.789191 105.467392 17.952396" -$ns_ at 140.000000 "$node_(8) setdest 505.637603 16.818056 19.257951" -$ns_ at 140.000000 "$node_(9) setdest 554.813129 57.628754 19.920661" -$ns_ at 140.000000 "$node_(10) setdest 429.800533 26.943825 6.059223" - -$ns_ at 141.000000 "$node_(1) setdest 161.247046 111.473323 19.996287" -$ns_ at 141.000000 "$node_(2) setdest 185.373829 29.829709 12.362755" -$ns_ at 141.000000 "$node_(3) setdest 183.778520 1.889613 1.713232" -$ns_ at 141.000000 "$node_(4) setdest 279.550001 84.297092 19.999419" -$ns_ at 141.000000 "$node_(5) setdest 119.793534 159.666849 19.967502" -$ns_ at 141.000000 "$node_(6) setdest 592.156148 90.830024 14.981874" -$ns_ at 141.000000 "$node_(7) setdest 488.189099 119.413179 19.479412" -$ns_ at 141.000000 "$node_(8) setdest 523.321051 26.105433 19.973976" -$ns_ at 141.000000 "$node_(9) setdest 571.486632 63.791740 17.776055" -$ns_ at 141.000000 "$node_(10) setdest 436.921300 24.140901 7.652561" - -$ns_ at 142.000000 "$node_(1) setdest 141.772095 115.540184 19.895051" -$ns_ at 142.000000 "$node_(2) setdest 196.339570 29.318053 10.977671" -$ns_ at 142.000000 "$node_(3) setdest 184.812005 4.915605 3.197612" -$ns_ at 142.000000 "$node_(4) setdest 259.803815 87.459443 19.997808" -$ns_ at 142.000000 "$node_(5) setdest 100.096591 156.319135 19.979409" -$ns_ at 142.000000 "$node_(6) setdest 590.692452 107.433540 16.667908" -$ns_ at 142.000000 "$node_(7) setdest 471.797782 130.833795 19.977632" -$ns_ at 142.000000 "$node_(8) setdest 541.126366 35.173355 19.981403" -$ns_ at 142.000000 "$node_(9) setdest 567.782585 75.167477 11.963585" -$ns_ at 142.000000 "$node_(10) setdest 446.013398 22.445407 9.248835" - -$ns_ at 143.000000 "$node_(1) setdest 127.450194 128.944032 19.615810" -$ns_ at 143.000000 "$node_(2) setdest 197.147859 36.740438 7.466266" -$ns_ at 143.000000 "$node_(3) setdest 185.893987 9.604906 4.812507" -$ns_ at 143.000000 "$node_(4) setdest 239.858385 88.607005 19.978416" -$ns_ at 143.000000 "$node_(5) setdest 80.175258 157.537770 19.958571" -$ns_ at 143.000000 "$node_(6) setdest 585.791697 124.971994 18.210293" -$ns_ at 143.000000 "$node_(7) setdest 454.924266 141.549003 19.988276" -$ns_ at 143.000000 "$node_(8) setdest 556.871642 47.471369 19.978860" -$ns_ at 143.000000 "$node_(9) setdest 558.206517 84.854499 13.621287" -$ns_ at 143.000000 "$node_(10) setdest 456.841721 21.664948 10.856413" - -$ns_ at 144.000000 "$node_(1) setdest 118.524599 146.840858 19.999066" -$ns_ at 144.000000 "$node_(2) setdest 196.591811 45.826445 9.103005" -$ns_ at 144.000000 "$node_(3) setdest 187.092769 15.899568 6.407796" -$ns_ at 144.000000 "$node_(4) setdest 220.066145 86.102236 19.950103" -$ns_ at 144.000000 "$node_(5) setdest 60.964143 162.769298 19.910697" -$ns_ at 144.000000 "$node_(6) setdest 574.313128 140.914141 19.644582" -$ns_ at 144.000000 "$node_(7) setdest 441.557267 156.254138 19.872536" -$ns_ at 144.000000 "$node_(8) setdest 571.374396 61.086555 19.892289" -$ns_ at 144.000000 "$node_(9) setdest 552.626228 98.963335 15.172307" -$ns_ at 144.000000 "$node_(10) setdest 469.299904 21.561095 12.458615" - -$ns_ at 145.000000 "$node_(1) setdest 112.115498 165.696718 19.915321" -$ns_ at 145.000000 "$node_(2) setdest 190.250128 47.613148 6.588570" -$ns_ at 145.000000 "$node_(3) setdest 187.313861 23.900730 8.004216" -$ns_ at 145.000000 "$node_(4) setdest 203.065906 94.794565 19.093577" -$ns_ at 145.000000 "$node_(5) setdest 45.972008 175.619703 19.745810" -$ns_ at 145.000000 "$node_(6) setdest 560.255115 155.135300 19.996727" -$ns_ at 145.000000 "$node_(7) setdest 438.601722 175.534770 19.505846" -$ns_ at 145.000000 "$node_(8) setdest 588.750250 69.671374 19.380903" -$ns_ at 145.000000 "$node_(9) setdest 551.878665 115.778256 16.831530" -$ns_ at 145.000000 "$node_(10) setdest 483.345939 22.123346 14.057284" - -$ns_ at 146.000000 "$node_(1) setdest 111.731159 185.496144 19.803156" -$ns_ at 146.000000 "$node_(2) setdest 183.547590 43.776632 7.722881" -$ns_ at 146.000000 "$node_(3) setdest 185.862180 33.389020 9.598699" -$ns_ at 146.000000 "$node_(4) setdest 190.626206 108.639388 18.612503" -$ns_ at 146.000000 "$node_(5) setdest 47.072918 193.458445 17.872681" -$ns_ at 146.000000 "$node_(6) setdest 545.916182 169.049201 19.980032" -$ns_ at 146.000000 "$node_(7) setdest 444.782179 193.174570 18.691190" -$ns_ at 146.000000 "$node_(8) setdest 586.255822 69.734557 2.495228" -$ns_ at 146.000000 "$node_(9) setdest 554.631147 134.007561 18.435936" -$ns_ at 146.000000 "$node_(10) setdest 498.884774 24.015570 15.653623" - -$ns_ at 147.000000 "$node_(1) setdest 111.899554 186.471049 0.989342" -$ns_ at 147.000000 "$node_(2) setdest 175.795557 38.607572 9.317360" -$ns_ at 147.000000 "$node_(3) setdest 182.523745 44.090935 11.210537" -$ns_ at 147.000000 "$node_(4) setdest 179.070997 123.870067 19.117961" -$ns_ at 147.000000 "$node_(5) setdest 62.376736 192.812895 15.317427" -$ns_ at 147.000000 "$node_(6) setdest 531.919229 183.302102 19.976483" -$ns_ at 147.000000 "$node_(7) setdest 436.724006 199.709287 10.374810" -$ns_ at 147.000000 "$node_(8) setdest 576.168467 67.370369 10.360701" -$ns_ at 147.000000 "$node_(9) setdest 562.586604 152.129905 19.791631" -$ns_ at 147.000000 "$node_(10) setdest 515.441797 28.772088 17.226708" - -$ns_ at 148.000000 "$node_(1) setdest 108.990066 180.641200 6.515540" -$ns_ at 148.000000 "$node_(2) setdest 167.327952 31.720295 10.914894" -$ns_ at 148.000000 "$node_(3) setdest 179.086940 56.426752 12.805624" -$ns_ at 148.000000 "$node_(4) setdest 163.850105 134.459779 18.542318" -$ns_ at 148.000000 "$node_(5) setdest 69.482057 179.583763 15.016508" -$ns_ at 148.000000 "$node_(6) setdest 513.623888 191.062746 19.873276" -$ns_ at 148.000000 "$node_(7) setdest 426.833193 195.609739 10.706749" -$ns_ at 148.000000 "$node_(8) setdest 564.268369 67.203121 11.901272" -$ns_ at 148.000000 "$node_(9) setdest 570.951086 170.282477 19.987006" -$ns_ at 148.000000 "$node_(10) setdest 531.755709 38.134043 18.809304" - -$ns_ at 149.000000 "$node_(1) setdest 104.753756 173.710069 8.123232" -$ns_ at 149.000000 "$node_(2) setdest 156.878825 24.944390 12.453801" -$ns_ at 149.000000 "$node_(3) setdest 176.599709 70.622921 14.412410" -$ns_ at 149.000000 "$node_(4) setdest 146.434634 142.639565 19.240778" -$ns_ at 149.000000 "$node_(5) setdest 75.707512 165.318603 15.564417" -$ns_ at 149.000000 "$node_(6) setdest 493.935495 190.646337 19.692796" -$ns_ at 149.000000 "$node_(7) setdest 417.399684 187.603159 12.373213" -$ns_ at 149.000000 "$node_(8) setdest 551.157370 70.606676 13.545571" -$ns_ at 149.000000 "$node_(9) setdest 576.243443 189.189175 19.633448" -$ns_ at 149.000000 "$node_(10) setdest 546.734747 51.323269 19.958137" - -$ns_ at 150.000000 "$node_(1) setdest 99.278520 165.679385 9.719573" -$ns_ at 150.000000 "$node_(2) setdest 143.075068 24.363392 13.815978" -$ns_ at 150.000000 "$node_(3) setdest 173.400696 86.306718 16.006723" -$ns_ at 150.000000 "$node_(4) setdest 130.649757 153.943580 19.415023" -$ns_ at 150.000000 "$node_(5) setdest 88.488112 154.041636 17.044464" -$ns_ at 150.000000 "$node_(6) setdest 475.349957 183.326049 19.975206" -$ns_ at 150.000000 "$node_(7) setdest 414.624429 174.179041 13.707991" -$ns_ at 150.000000 "$node_(8) setdest 537.189239 76.498837 15.160021" -$ns_ at 150.000000 "$node_(9) setdest 575.465562 180.778988 8.446085" -$ns_ at 150.000000 "$node_(10) setdest 560.401937 65.884227 19.970318" - -$ns_ at 151.000000 "$node_(1) setdest 91.813160 157.170777 11.319364" -$ns_ at 151.000000 "$node_(2) setdest 138.004596 35.391633 12.138031" -$ns_ at 151.000000 "$node_(3) setdest 168.114267 103.099736 17.605447" -$ns_ at 151.000000 "$node_(4) setdest 119.996573 169.374810 18.751351" -$ns_ at 151.000000 "$node_(5) setdest 105.657672 146.388340 18.798051" -$ns_ at 151.000000 "$node_(6) setdest 459.956503 171.347805 19.504788" -$ns_ at 151.000000 "$node_(7) setdest 416.813764 158.732695 15.600731" -$ns_ at 151.000000 "$node_(8) setdest 521.788366 83.114604 16.761720" -$ns_ at 151.000000 "$node_(9) setdest 577.687876 171.392622 9.645857" -$ns_ at 151.000000 "$node_(10) setdest 569.087851 83.782994 19.894998" - -$ns_ at 152.000000 "$node_(1) setdest 82.097039 148.659628 12.916759" -$ns_ at 152.000000 "$node_(2) setdest 146.119591 45.797946 13.196382" -$ns_ at 152.000000 "$node_(3) setdest 160.937701 120.920891 19.211888" -$ns_ at 152.000000 "$node_(4) setdest 105.936747 181.378621 18.487028" -$ns_ at 152.000000 "$node_(5) setdest 124.801631 141.076851 19.867135" -$ns_ at 152.000000 "$node_(6) setdest 448.544469 155.827294 19.264495" -$ns_ at 152.000000 "$node_(7) setdest 417.880719 141.561761 17.204051" -$ns_ at 152.000000 "$node_(8) setdest 503.612706 85.135031 18.287612" -$ns_ at 152.000000 "$node_(9) setdest 582.520079 161.274967 11.212365" -$ns_ at 152.000000 "$node_(10) setdest 569.702380 103.596801 19.823334" - -$ns_ at 153.000000 "$node_(1) setdest 70.379904 140.091185 14.515835" -$ns_ at 153.000000 "$node_(2) setdest 158.134566 54.430381 14.794545" -$ns_ at 153.000000 "$node_(3) setdest 156.219850 140.328761 19.973071" -$ns_ at 153.000000 "$node_(4) setdest 88.725972 189.580626 19.065247" -$ns_ at 153.000000 "$node_(5) setdest 144.327183 138.526583 19.691395" -$ns_ at 153.000000 "$node_(6) setdest 442.382049 137.609253 19.232068" -$ns_ at 153.000000 "$node_(7) setdest 416.376540 122.816638 18.805376" -$ns_ at 153.000000 "$node_(8) setdest 483.914674 83.287628 19.784472" -$ns_ at 153.000000 "$node_(9) setdest 586.204849 149.285184 12.543222" -$ns_ at 153.000000 "$node_(10) setdest 559.010783 119.996465 19.577008" - -$ns_ at 154.000000 "$node_(1) setdest 55.997138 132.866034 16.095551" -$ns_ at 154.000000 "$node_(2) setdest 172.406373 62.536019 16.412977" -$ns_ at 154.000000 "$node_(3) setdest 151.635699 159.667002 19.874155" -$ns_ at 154.000000 "$node_(4) setdest 78.054821 195.479620 12.193096" -$ns_ at 154.000000 "$node_(5) setdest 163.592391 140.383876 19.354528" -$ns_ at 154.000000 "$node_(6) setdest 441.383428 118.459568 19.175706" -$ns_ at 154.000000 "$node_(7) setdest 412.338720 103.315957 19.914330" -$ns_ at 154.000000 "$node_(8) setdest 464.344857 79.349340 19.962160" -$ns_ at 154.000000 "$node_(9) setdest 576.816577 139.350201 13.669073" -$ns_ at 154.000000 "$node_(10) setdest 540.866973 128.225326 19.922651" - -$ns_ at 155.000000 "$node_(1) setdest 41.252307 123.224103 17.617516" -$ns_ at 155.000000 "$node_(2) setdest 186.611964 72.729002 17.484157" -$ns_ at 155.000000 "$node_(3) setdest 144.090830 165.764530 9.700768" -$ns_ at 155.000000 "$node_(4) setdest 84.150229 193.306525 6.471193" -$ns_ at 155.000000 "$node_(5) setdest 178.718241 150.366969 18.123286" -$ns_ at 155.000000 "$node_(6) setdest 439.600336 99.066105 19.475263" -$ns_ at 155.000000 "$node_(7) setdest 407.087226 84.024775 19.993196" -$ns_ at 155.000000 "$node_(8) setdest 447.207539 69.162889 19.936185" -$ns_ at 155.000000 "$node_(9) setdest 561.438062 134.917972 16.004480" -$ns_ at 155.000000 "$node_(10) setdest 526.487380 140.831521 19.122992" - -$ns_ at 156.000000 "$node_(1) setdest 34.078752 105.954513 18.700231" -$ns_ at 156.000000 "$node_(2) setdest 187.094893 73.875178 1.243760" -$ns_ at 156.000000 "$node_(3) setdest 141.135685 162.335572 4.526658" -$ns_ at 156.000000 "$node_(4) setdest 92.326017 193.380787 8.176125" -$ns_ at 156.000000 "$node_(5) setdest 191.326981 163.978216 18.553877" -$ns_ at 156.000000 "$node_(6) setdest 441.938872 80.015861 19.193242" -$ns_ at 156.000000 "$node_(7) setdest 410.869511 64.803585 19.589788" -$ns_ at 156.000000 "$node_(8) setdest 431.974289 56.242401 19.974757" -$ns_ at 156.000000 "$node_(9) setdest 545.448883 127.932357 17.448572" -$ns_ at 156.000000 "$node_(10) setdest 515.851572 156.904956 19.273705" - -$ns_ at 157.000000 "$node_(1) setdest 43.916030 90.582641 18.250109" -$ns_ at 157.000000 "$node_(2) setdest 185.047818 73.249294 2.140618" -$ns_ at 157.000000 "$node_(3) setdest 137.743986 157.188007 6.164499" -$ns_ at 157.000000 "$node_(4) setdest 102.029528 194.793971 9.805877" -$ns_ at 157.000000 "$node_(5) setdest 189.463671 163.013794 2.098103" -$ns_ at 157.000000 "$node_(6) setdest 447.800127 61.558044 19.366087" -$ns_ at 157.000000 "$node_(7) setdest 421.274390 47.730933 19.993423" -$ns_ at 157.000000 "$node_(8) setdest 417.596276 42.348809 19.993978" -$ns_ at 157.000000 "$node_(9) setdest 533.516072 113.369140 18.827619" -$ns_ at 157.000000 "$node_(10) setdest 508.458281 174.872098 19.428817" - -$ns_ at 158.000000 "$node_(1) setdest 55.511989 78.080336 17.052094" -$ns_ at 158.000000 "$node_(2) setdest 181.442077 72.235518 3.745545" -$ns_ at 158.000000 "$node_(3) setdest 134.731133 150.035278 7.761367" -$ns_ at 158.000000 "$node_(4) setdest 113.388357 195.826949 11.405702" -$ns_ at 158.000000 "$node_(5) setdest 189.430347 155.904971 7.108901" -$ns_ at 158.000000 "$node_(6) setdest 451.172245 42.328961 19.522521" -$ns_ at 158.000000 "$node_(7) setdest 430.947390 30.485112 19.773347" -$ns_ at 158.000000 "$node_(8) setdest 416.344354 24.696906 17.696242" -$ns_ at 158.000000 "$node_(9) setdest 532.772610 95.462924 17.921644" -$ns_ at 158.000000 "$node_(10) setdest 499.709975 191.961210 19.198193" - -$ns_ at 159.000000 "$node_(1) setdest 62.113656 61.761513 17.603579" -$ns_ at 159.000000 "$node_(2) setdest 176.123023 71.889821 5.330276" -$ns_ at 159.000000 "$node_(3) setdest 131.954733 141.086339 9.369734" -$ns_ at 159.000000 "$node_(4) setdest 126.380996 196.373692 13.004139" -$ns_ at 159.000000 "$node_(5) setdest 187.683229 147.360821 8.720947" -$ns_ at 159.000000 "$node_(6) setdest 451.279335 22.737061 19.592193" -$ns_ at 159.000000 "$node_(7) setdest 436.024525 11.839659 19.324342" -$ns_ at 159.000000 "$node_(8) setdest 426.226077 23.617931 9.940454" -$ns_ at 159.000000 "$node_(9) setdest 526.035117 80.351338 16.545509" -$ns_ at 159.000000 "$node_(10) setdest 503.894359 181.756466 11.029318" - -$ns_ at 160.000000 "$node_(1) setdest 65.960718 43.172044 18.983367" -$ns_ at 160.000000 "$node_(2) setdest 169.348075 73.331064 6.926551" -$ns_ at 160.000000 "$node_(3) setdest 128.796997 130.584343 10.966459" -$ns_ at 160.000000 "$node_(4) setdest 140.930810 195.800748 14.561090" -$ns_ at 160.000000 "$node_(5) setdest 187.045369 137.058154 10.322393" -$ns_ at 160.000000 "$node_(6) setdest 444.402909 18.604950 8.022441" -$ns_ at 160.000000 "$node_(7) setdest 434.909325 14.365720 2.761278" -$ns_ at 160.000000 "$node_(8) setdest 424.301771 22.863179 2.067028" -$ns_ at 160.000000 "$node_(9) setdest 512.812174 79.050168 13.286808" -$ns_ at 160.000000 "$node_(10) setdest 495.740867 177.608074 9.148147" - -$ns_ at 161.000000 "$node_(1) setdest 72.042419 24.842076 19.312556" -$ns_ at 161.000000 "$node_(2) setdest 161.871350 77.405615 8.514892" -$ns_ at 161.000000 "$node_(3) setdest 126.355196 118.254232 12.569568" -$ns_ at 161.000000 "$node_(4) setdest 150.057613 187.830197 12.117269" -$ns_ at 161.000000 "$node_(5) setdest 187.048576 125.133800 11.924355" -$ns_ at 161.000000 "$node_(6) setdest 434.736032 18.300064 9.671684" -$ns_ at 161.000000 "$node_(7) setdest 431.202382 15.736051 3.952118" -$ns_ at 161.000000 "$node_(8) setdest 421.173291 24.251968 3.422882" -$ns_ at 161.000000 "$node_(9) setdest 497.627026 80.566955 15.260713" -$ns_ at 161.000000 "$node_(10) setdest 485.182776 174.616363 10.973770" - -$ns_ at 162.000000 "$node_(1) setdest 76.823348 6.990102 18.481078" -$ns_ at 162.000000 "$node_(2) setdest 155.188412 84.965774 10.090474" -$ns_ at 162.000000 "$node_(3) setdest 123.148854 104.452853 14.168934" -$ns_ at 162.000000 "$node_(4) setdest 146.530739 184.039119 5.177945" -$ns_ at 162.000000 "$node_(5) setdest 185.580284 111.692807 13.520953" -$ns_ at 162.000000 "$node_(6) setdest 423.465948 18.099012 11.271878" -$ns_ at 162.000000 "$node_(7) setdest 426.070562 17.854362 5.551829" -$ns_ at 162.000000 "$node_(8) setdest 416.609786 26.350567 5.022917" -$ns_ at 162.000000 "$node_(9) setdest 480.789422 81.428650 16.859639" -$ns_ at 162.000000 "$node_(10) setdest 473.049914 171.315733 12.573802" - -$ns_ at 163.000000 "$node_(1) setdest 74.663686 11.270534 4.794396" -$ns_ at 163.000000 "$node_(2) setdest 150.947840 95.880837 11.709870" -$ns_ at 163.000000 "$node_(3) setdest 117.765575 89.646315 15.754785" -$ns_ at 163.000000 "$node_(4) setdest 140.287067 180.992837 6.947177" -$ns_ at 163.000000 "$node_(5) setdest 184.617717 96.618690 15.104819" -$ns_ at 163.000000 "$node_(6) setdest 410.594549 18.024662 12.871613" -$ns_ at 163.000000 "$node_(7) setdest 419.556244 20.806580 7.152058" -$ns_ at 163.000000 "$node_(8) setdest 410.491787 28.885939 6.622539" -$ns_ at 163.000000 "$node_(9) setdest 462.331560 81.229685 18.458934" -$ns_ at 163.000000 "$node_(10) setdest 459.326921 167.770043 14.173654" - -$ns_ at 164.000000 "$node_(1) setdest 77.700460 16.056801 5.668364" -$ns_ at 164.000000 "$node_(2) setdest 148.502806 108.986321 13.331613" -$ns_ at 164.000000 "$node_(3) setdest 109.149818 74.597894 17.340307" -$ns_ at 164.000000 "$node_(4) setdest 131.820856 181.190189 8.468511" -$ns_ at 164.000000 "$node_(5) setdest 185.147114 79.901197 16.725873" -$ns_ at 164.000000 "$node_(6) setdest 396.123158 17.912799 14.471824" -$ns_ at 164.000000 "$node_(7) setdest 411.667762 24.597608 8.752145" -$ns_ at 164.000000 "$node_(8) setdest 402.783503 31.748758 8.222735" -$ns_ at 164.000000 "$node_(9) setdest 442.549827 79.886156 19.827305" -$ns_ at 164.000000 "$node_(10) setdest 443.980346 164.127469 15.772942" - -$ns_ at 165.000000 "$node_(1) setdest 80.751011 22.632665 7.248989" -$ns_ at 165.000000 "$node_(2) setdest 147.928686 123.907075 14.931795" -$ns_ at 165.000000 "$node_(3) setdest 96.035595 60.970960 18.912329" -$ns_ at 165.000000 "$node_(4) setdest 122.502042 185.210639 10.149105" -$ns_ at 165.000000 "$node_(5) setdest 185.141179 61.579353 18.321845" -$ns_ at 165.000000 "$node_(6) setdest 380.051979 17.762097 16.071885" -$ns_ at 165.000000 "$node_(7) setdest 402.404607 29.219681 10.352276" -$ns_ at 165.000000 "$node_(8) setdest 393.507649 34.981420 9.823012" -$ns_ at 165.000000 "$node_(9) setdest 422.735375 77.199676 19.995742" -$ns_ at 165.000000 "$node_(10) setdest 426.942629 160.730540 17.373052" - -$ns_ at 166.000000 "$node_(1) setdest 82.726194 31.276530 8.866665" -$ns_ at 166.000000 "$node_(2) setdest 148.987588 140.420750 16.547590" -$ns_ at 166.000000 "$node_(3) setdest 78.637722 51.317801 19.896468" -$ns_ at 166.000000 "$node_(4) setdest 111.343377 182.740860 11.428718" -$ns_ at 166.000000 "$node_(5) setdest 183.940304 41.880407 19.735515" -$ns_ at 166.000000 "$node_(6) setdest 362.380169 17.752944 17.671813" -$ns_ at 166.000000 "$node_(7) setdest 391.653384 34.440900 11.951984" -$ns_ at 166.000000 "$node_(8) setdest 382.669885 38.590161 11.422790" -$ns_ at 166.000000 "$node_(9) setdest 403.199353 72.940877 19.994837" -$ns_ at 166.000000 "$node_(10) setdest 408.274085 157.340788 18.973796" - -$ns_ at 167.000000 "$node_(1) setdest 83.836001 41.676120 10.458640" -$ns_ at 167.000000 "$node_(2) setdest 153.399183 157.898562 18.025984" -$ns_ at 167.000000 "$node_(3) setdest 58.975217 50.354423 19.686091" -$ns_ at 167.000000 "$node_(4) setdest 103.966143 171.791634 13.202619" -$ns_ at 167.000000 "$node_(5) setdest 192.412042 25.101152 18.796642" -$ns_ at 167.000000 "$node_(6) setdest 343.128857 18.513654 19.266336" -$ns_ at 167.000000 "$node_(7) setdest 379.364734 40.154703 13.552065" -$ns_ at 167.000000 "$node_(8) setdest 370.163237 42.213745 13.021007" -$ns_ at 167.000000 "$node_(9) setdest 384.109842 66.996327 19.993677" -$ns_ at 167.000000 "$node_(10) setdest 388.699756 153.273291 19.992471" - -$ns_ at 168.000000 "$node_(1) setdest 84.894126 53.682119 12.052537" -$ns_ at 168.000000 "$node_(2) setdest 167.272527 171.355308 19.327536" -$ns_ at 168.000000 "$node_(3) setdest 50.795974 63.637111 15.599033" -$ns_ at 168.000000 "$node_(4) setdest 99.748116 157.437131 14.961400" -$ns_ at 168.000000 "$node_(5) setdest 198.947067 22.026635 7.222133" -$ns_ at 168.000000 "$node_(6) setdest 323.346757 21.396871 19.991109" -$ns_ at 168.000000 "$node_(7) setdest 365.975599 47.239433 15.148014" -$ns_ at 168.000000 "$node_(8) setdest 355.878352 45.327028 14.620207" -$ns_ at 168.000000 "$node_(9) setdest 365.020316 61.038320 19.997696" -$ns_ at 168.000000 "$node_(10) setdest 369.105098 149.269829 19.999458" - -$ns_ at 169.000000 "$node_(1) setdest 89.451531 66.521653 13.624375" -$ns_ at 169.000000 "$node_(2) setdest 185.788334 169.598855 18.598931" -$ns_ at 169.000000 "$node_(3) setdest 57.023606 66.857513 7.011019" -$ns_ at 169.000000 "$node_(4) setdest 94.375213 141.785412 16.548244" -$ns_ at 169.000000 "$node_(5) setdest 197.685641 21.098308 1.566202" -$ns_ at 169.000000 "$node_(6) setdest 303.800583 25.627234 19.998722" -$ns_ at 169.000000 "$node_(7) setdest 351.976358 56.428967 16.745934" -$ns_ at 169.000000 "$node_(8) setdest 339.845401 47.794114 16.221653" -$ns_ at 169.000000 "$node_(9) setdest 345.625203 56.166910 19.997526" -$ns_ at 169.000000 "$node_(10) setdest 349.412594 145.778646 19.999576" - -$ns_ at 170.000000 "$node_(1) setdest 98.595971 78.660537 15.197805" -$ns_ at 170.000000 "$node_(2) setdest 191.824229 152.854155 17.799355" -$ns_ at 170.000000 "$node_(3) setdest 65.505872 65.288800 8.626105" -$ns_ at 170.000000 "$node_(4) setdest 84.771789 126.399680 18.136882" -$ns_ at 170.000000 "$node_(5) setdest 194.447590 20.748193 3.256924" -$ns_ at 170.000000 "$node_(6) setdest 284.422089 30.561769 19.996891" -$ns_ at 170.000000 "$node_(7) setdest 336.488392 66.266943 18.348375" -$ns_ at 170.000000 "$node_(8) setdest 322.137911 49.798598 17.820583" -$ns_ at 170.000000 "$node_(9) setdest 325.954317 52.576373 19.995892" -$ns_ at 170.000000 "$node_(10) setdest 329.735957 142.201287 19.999189" - -$ns_ at 171.000000 "$node_(1) setdest 112.977297 87.271027 16.761953" -$ns_ at 171.000000 "$node_(2) setdest 191.611035 136.352639 16.502893" -$ns_ at 171.000000 "$node_(3) setdest 75.600405 63.592078 10.236135" -$ns_ at 171.000000 "$node_(4) setdest 69.325659 114.455881 19.525298" -$ns_ at 171.000000 "$node_(5) setdest 189.626370 20.167736 4.856036" -$ns_ at 171.000000 "$node_(6) setdest 265.427300 36.816797 19.998184" -$ns_ at 171.000000 "$node_(7) setdest 319.125355 75.725898 19.772377" -$ns_ at 171.000000 "$node_(8) setdest 302.740361 50.564467 19.412663" -$ns_ at 171.000000 "$node_(9) setdest 306.097225 50.200000 19.998782" -$ns_ at 171.000000 "$node_(10) setdest 310.324303 137.409564 19.994322" - -$ns_ at 172.000000 "$node_(1) setdest 130.889740 91.652087 18.440426" -$ns_ at 172.000000 "$node_(2) setdest 188.195099 119.984720 16.720568" -$ns_ at 172.000000 "$node_(3) setdest 87.261624 61.566337 11.835863" -$ns_ at 172.000000 "$node_(4) setdest 50.408455 108.069384 19.966171" -$ns_ at 172.000000 "$node_(5) setdest 183.210315 19.462493 6.454698" -$ns_ at 172.000000 "$node_(6) setdest 246.804372 44.105199 19.998357" -$ns_ at 172.000000 "$node_(7) setdest 300.903681 83.960245 19.995847" -$ns_ at 172.000000 "$node_(8) setdest 282.761368 49.802834 19.993506" -$ns_ at 172.000000 "$node_(9) setdest 286.178420 48.427559 19.997508" -$ns_ at 172.000000 "$node_(10) setdest 291.419852 130.900985 19.993495" - -$ns_ at 173.000000 "$node_(1) setdest 150.117221 96.445478 19.815968" -$ns_ at 173.000000 "$node_(2) setdest 186.605797 101.739334 18.314476" -$ns_ at 173.000000 "$node_(3) setdest 100.596739 59.980711 13.429055" -$ns_ at 173.000000 "$node_(4) setdest 30.490170 107.030632 19.945353" -$ns_ at 173.000000 "$node_(5) setdest 175.384564 17.552862 8.055375" -$ns_ at 173.000000 "$node_(6) setdest 228.279753 51.641445 19.998913" -$ns_ at 173.000000 "$node_(7) setdest 282.201859 91.043224 19.998168" -$ns_ at 173.000000 "$node_(8) setdest 263.086759 46.344289 19.976279" -$ns_ at 173.000000 "$node_(9) setdest 266.189461 47.940458 19.994893" -$ns_ at 173.000000 "$node_(10) setdest 273.195059 122.679443 19.993419" - -$ns_ at 174.000000 "$node_(1) setdest 168.902350 103.226473 19.971554" -$ns_ at 174.000000 "$node_(2) setdest 184.513754 82.093305 19.757102" -$ns_ at 174.000000 "$node_(3) setdest 115.623096 60.000922 15.026371" -$ns_ at 174.000000 "$node_(4) setdest 11.378375 105.199769 19.199290" -$ns_ at 174.000000 "$node_(5) setdest 165.905684 15.739495 9.650776" -$ns_ at 174.000000 "$node_(6) setdest 210.524312 60.821660 19.988297" -$ns_ at 174.000000 "$node_(7) setdest 263.237099 97.391304 19.999006" -$ns_ at 174.000000 "$node_(8) setdest 244.452806 39.179900 19.963784" -$ns_ at 174.000000 "$node_(9) setdest 246.259591 49.492870 19.990241" -$ns_ at 174.000000 "$node_(10) setdest 255.875893 112.695630 19.990749" - -$ns_ at 175.000000 "$node_(1) setdest 179.680069 118.492693 18.687341" -$ns_ at 175.000000 "$node_(2) setdest 180.258778 62.740869 19.814682" -$ns_ at 175.000000 "$node_(3) setdest 132.021670 62.570627 16.598693" -$ns_ at 175.000000 "$node_(4) setdest 5.755446 88.484328 17.635853" -$ns_ at 175.000000 "$node_(5) setdest 155.223912 16.670444 10.722262" -$ns_ at 175.000000 "$node_(6) setdest 194.092342 72.196532 19.984929" -$ns_ at 175.000000 "$node_(7) setdest 244.024859 102.944527 19.998711" -$ns_ at 175.000000 "$node_(8) setdest 226.039257 31.479843 19.958700" -$ns_ at 175.000000 "$node_(9) setdest 226.666973 53.441639 19.986582" -$ns_ at 175.000000 "$node_(10) setdest 239.867016 100.730485 19.986216" - -$ns_ at 176.000000 "$node_(1) setdest 178.455056 113.826735 4.824088" -$ns_ at 176.000000 "$node_(2) setdest 170.317497 46.270492 19.238045" -$ns_ at 176.000000 "$node_(3) setdest 148.852278 69.512159 18.205884" -$ns_ at 176.000000 "$node_(4) setdest 7.747696 72.189753 16.415914" -$ns_ at 176.000000 "$node_(5) setdest 155.067960 17.267330 0.616923" -$ns_ at 176.000000 "$node_(6) setdest 179.520253 85.870172 19.982848" -$ns_ at 176.000000 "$node_(7) setdest 224.758061 108.308526 19.999549" -$ns_ at 176.000000 "$node_(8) setdest 206.348654 28.206572 19.960815" -$ns_ at 176.000000 "$node_(9) setdest 207.773501 59.963121 19.987322" -$ns_ at 176.000000 "$node_(10) setdest 225.733708 86.607919 19.979922" - -$ns_ at 177.000000 "$node_(1) setdest 175.246544 108.496016 6.221826" -$ns_ at 177.000000 "$node_(2) setdest 157.726290 31.362125 19.514044" -$ns_ at 177.000000 "$node_(3) setdest 164.683417 81.103727 19.621148" -$ns_ at 177.000000 "$node_(4) setdest 17.513917 60.031501 15.594941" -$ns_ at 177.000000 "$node_(5) setdest 156.535342 17.780235 1.554439" -$ns_ at 177.000000 "$node_(6) setdest 167.122891 101.545865 19.985543" -$ns_ at 177.000000 "$node_(7) setdest 205.299075 112.923724 19.998805" -$ns_ at 177.000000 "$node_(8) setdest 186.493072 30.105946 19.946222" -$ns_ at 177.000000 "$node_(9) setdest 189.928589 68.956396 19.982989" -$ns_ at 177.000000 "$node_(10) setdest 213.261658 71.046403 19.942738" - -$ns_ at 178.000000 "$node_(1) setdest 172.424003 101.197065 7.825690" -$ns_ at 178.000000 "$node_(2) setdest 142.888376 19.133692 19.227539" -$ns_ at 178.000000 "$node_(3) setdest 174.810337 98.211073 19.880034" -$ns_ at 178.000000 "$node_(4) setdest 31.152481 49.569283 17.189195" -$ns_ at 178.000000 "$node_(5) setdest 159.699097 18.019297 3.172774" -$ns_ at 178.000000 "$node_(6) setdest 157.052647 118.802745 19.980234" -$ns_ at 178.000000 "$node_(7) setdest 185.768249 117.229326 19.999784" -$ns_ at 178.000000 "$node_(8) setdest 167.818405 37.111714 19.945525" -$ns_ at 178.000000 "$node_(9) setdest 173.871013 80.833808 19.972948" -$ns_ at 178.000000 "$node_(10) setdest 196.419365 70.738967 16.845098" - -$ns_ at 179.000000 "$node_(1) setdest 170.753363 91.918408 9.427858" -$ns_ at 179.000000 "$node_(2) setdest 125.010723 12.749372 18.983414" -$ns_ at 179.000000 "$node_(3) setdest 181.874760 116.920836 19.999033" -$ns_ at 179.000000 "$node_(4) setdest 46.551054 38.789818 18.796620" -$ns_ at 179.000000 "$node_(5) setdest 163.906434 16.048997 4.645834" -$ns_ at 179.000000 "$node_(6) setdest 150.159618 137.551322 19.975559" -$ns_ at 179.000000 "$node_(7) setdest 166.344084 121.993628 19.999919" -$ns_ at 179.000000 "$node_(8) setdest 150.738069 47.480338 19.981147" -$ns_ at 179.000000 "$node_(9) setdest 160.581359 95.722920 19.957469" -$ns_ at 179.000000 "$node_(10) setdest 195.672687 84.091040 13.372934" - -$ns_ at 180.000000 "$node_(1) setdest 170.379290 80.898702 11.026053" -$ns_ at 180.000000 "$node_(2) setdest 106.108663 11.307135 18.957001" -$ns_ at 180.000000 "$node_(3) setdest 186.831517 136.224536 19.929934" -$ns_ at 180.000000 "$node_(4) setdest 63.824239 28.948857 19.879825" -$ns_ at 180.000000 "$node_(5) setdest 169.419179 13.556525 6.050023" -$ns_ at 180.000000 "$node_(6) setdest 147.828308 157.269197 19.855216" -$ns_ at 180.000000 "$node_(7) setdest 147.059157 127.267473 19.993046" -$ns_ at 180.000000 "$node_(8) setdest 134.966214 59.765581 19.991963" -$ns_ at 180.000000 "$node_(9) setdest 151.747848 113.601200 19.941509" -$ns_ at 180.000000 "$node_(10) setdest 189.493134 92.502152 10.437130" - -$ns_ at 181.000000 "$node_(1) setdest 171.163052 68.288192 12.634842" -$ns_ at 181.000000 "$node_(2) setdest 91.123305 20.053465 17.351060" -$ns_ at 181.000000 "$node_(3) setdest 188.637831 156.141046 19.998253" -$ns_ at 181.000000 "$node_(4) setdest 82.685943 28.747684 18.862777" -$ns_ at 181.000000 "$node_(5) setdest 172.747269 19.290485 6.629817" -$ns_ at 181.000000 "$node_(6) setdest 160.476531 170.330272 18.181563" -$ns_ at 181.000000 "$node_(7) setdest 128.509912 134.706388 19.985292" -$ns_ at 181.000000 "$node_(8) setdest 117.253969 68.951910 19.952752" -$ns_ at 181.000000 "$node_(9) setdest 145.153561 132.482364 19.999575" -$ns_ at 181.000000 "$node_(10) setdest 178.683836 98.024600 12.138302" - -$ns_ at 182.000000 "$node_(1) setdest 172.888706 54.198358 14.195116" -$ns_ at 182.000000 "$node_(2) setdest 83.890009 35.949121 17.464032" -$ns_ at 182.000000 "$node_(3) setdest 190.094980 176.021799 19.934083" -$ns_ at 182.000000 "$node_(4) setdest 96.855632 39.340425 17.691417" -$ns_ at 182.000000 "$node_(5) setdest 173.027925 27.952089 8.666149" -$ns_ at 182.000000 "$node_(6) setdest 177.244737 175.603016 17.577672" -$ns_ at 182.000000 "$node_(7) setdest 111.416146 145.032855 19.970798" -$ns_ at 182.000000 "$node_(8) setdest 97.650034 72.426294 19.909435" -$ns_ at 182.000000 "$node_(9) setdest 139.260466 151.590578 19.996310" -$ns_ at 182.000000 "$node_(10) setdest 167.962697 106.536181 13.689040" - -$ns_ at 183.000000 "$node_(1) setdest 180.428826 40.405392 15.719393" -$ns_ at 183.000000 "$node_(2) setdest 80.665629 54.207418 18.540821" -$ns_ at 183.000000 "$node_(3) setdest 196.076606 187.662698 13.087794" -$ns_ at 183.000000 "$node_(4) setdest 113.096835 43.407822 16.742771" -$ns_ at 183.000000 "$node_(5) setdest 175.004921 38.052270 10.291850" -$ns_ at 183.000000 "$node_(6) setdest 192.567746 173.044954 15.535067" -$ns_ at 183.000000 "$node_(7) setdest 94.933105 156.301721 19.966922" -$ns_ at 183.000000 "$node_(8) setdest 78.202415 68.303846 19.879749" -$ns_ at 183.000000 "$node_(9) setdest 128.466810 168.153105 19.769176" -$ns_ at 183.000000 "$node_(10) setdest 155.692441 115.659456 15.290302" - -$ns_ at 184.000000 "$node_(1) setdest 194.682139 32.290056 16.401695" -$ns_ at 184.000000 "$node_(2) setdest 71.721236 70.341996 18.447948" -$ns_ at 184.000000 "$node_(3) setdest 195.005636 184.210017 3.614967" -$ns_ at 184.000000 "$node_(4) setdest 131.373418 43.329977 18.276749" -$ns_ at 184.000000 "$node_(5) setdest 177.681189 49.641032 11.893773" -$ns_ at 184.000000 "$node_(6) setdest 192.538130 172.725928 0.320398" -$ns_ at 184.000000 "$node_(7) setdest 76.208559 163.180223 19.947993" -$ns_ at 184.000000 "$node_(8) setdest 59.386392 61.528995 19.998534" -$ns_ at 184.000000 "$node_(9) setdest 119.659162 170.816167 9.201443" -$ns_ at 184.000000 "$node_(10) setdest 139.468774 119.990598 16.791848" - -$ns_ at 185.000000 "$node_(1) setdest 195.613467 33.069178 1.214250" -$ns_ at 185.000000 "$node_(2) setdest 72.027737 89.787372 19.447792" -$ns_ at 185.000000 "$node_(3) setdest 194.672645 188.582756 4.385400" -$ns_ at 185.000000 "$node_(4) setdest 134.492679 47.692958 5.363338" -$ns_ at 185.000000 "$node_(5) setdest 173.964993 62.431439 13.319333" -$ns_ at 185.000000 "$node_(6) setdest 191.099665 172.527656 1.452065" -$ns_ at 185.000000 "$node_(7) setdest 56.380453 165.404161 19.952436" -$ns_ at 185.000000 "$node_(8) setdest 40.804330 54.137082 19.998335" -$ns_ at 185.000000 "$node_(9) setdest 119.805941 169.859912 0.967454" -$ns_ at 185.000000 "$node_(10) setdest 121.371407 116.477413 18.435216" - -$ns_ at 186.000000 "$node_(1) setdest 195.523460 35.547228 2.479684" -$ns_ at 186.000000 "$node_(2) setdest 72.860222 109.769952 19.999913" -$ns_ at 186.000000 "$node_(3) setdest 193.465576 194.532746 6.071194" -$ns_ at 186.000000 "$node_(4) setdest 134.472696 54.482129 6.789201" -$ns_ at 186.000000 "$node_(5) setdest 169.445995 76.675295 14.943519" -$ns_ at 186.000000 "$node_(6) setdest 188.017704 172.548818 3.082034" -$ns_ at 186.000000 "$node_(7) setdest 36.936529 161.362410 19.859555" -$ns_ at 186.000000 "$node_(8) setdest 21.592497 48.640305 19.982719" -$ns_ at 186.000000 "$node_(9) setdest 120.575903 167.393762 2.583551" -$ns_ at 186.000000 "$node_(10) setdest 104.372214 106.231584 19.848162" - -$ns_ at 187.000000 "$node_(1) setdest 195.465659 39.626432 4.079614" -$ns_ at 187.000000 "$node_(2) setdest 73.033876 129.767033 19.997835" -$ns_ at 187.000000 "$node_(3) setdest 192.328990 202.117959 7.669894" -$ns_ at 187.000000 "$node_(4) setdest 134.718626 62.867220 8.388696" -$ns_ at 187.000000 "$node_(5) setdest 165.002660 92.609977 16.542591" -$ns_ at 187.000000 "$node_(6) setdest 183.363363 172.076516 4.678243" -$ns_ at 187.000000 "$node_(7) setdest 27.040671 147.302132 17.193587" -$ns_ at 187.000000 "$node_(8) setdest 15.086590 34.481154 15.582310" -$ns_ at 187.000000 "$node_(9) setdest 122.262624 163.566603 4.182365" -$ns_ at 187.000000 "$node_(10) setdest 87.019330 96.377428 19.955625" - -$ns_ at 188.000000 "$node_(1) setdest 195.493442 45.306014 5.679650" -$ns_ at 188.000000 "$node_(2) setdest 72.088632 149.742168 19.997487" -$ns_ at 188.000000 "$node_(3) setdest 191.694603 211.364885 9.268662" -$ns_ at 188.000000 "$node_(4) setdest 135.397225 72.832879 9.988737" -$ns_ at 188.000000 "$node_(5) setdest 160.860419 110.273346 18.142567" -$ns_ at 188.000000 "$node_(6) setdest 177.331385 170.366266 6.269746" -$ns_ at 188.000000 "$node_(7) setdest 33.339932 142.144690 8.141247" -$ns_ at 188.000000 "$node_(8) setdest 25.950932 28.357513 12.471284" -$ns_ at 188.000000 "$node_(9) setdest 125.574753 158.840877 5.770848" -$ns_ at 188.000000 "$node_(10) setdest 73.723879 81.531864 19.928868" - -$ns_ at 189.000000 "$node_(1) setdest 195.501926 52.585695 7.279686" -$ns_ at 189.000000 "$node_(2) setdest 70.118723 169.643281 19.998371" -$ns_ at 189.000000 "$node_(3) setdest 191.784503 222.234607 10.870094" -$ns_ at 189.000000 "$node_(4) setdest 136.587465 84.360558 11.588963" -$ns_ at 189.000000 "$node_(5) setdest 157.134792 129.574013 19.656960" -$ns_ at 189.000000 "$node_(6) setdest 170.511875 166.445811 7.866110" -$ns_ at 189.000000 "$node_(7) setdest 42.075135 137.545000 9.872230" -$ns_ at 189.000000 "$node_(8) setdest 39.756298 24.207709 14.415582" -$ns_ at 189.000000 "$node_(9) setdest 131.266657 154.174797 7.360033" -$ns_ at 189.000000 "$node_(10) setdest 62.437001 65.038639 19.985497" - -$ns_ at 190.000000 "$node_(1) setdest 195.416493 61.464644 8.879359" -$ns_ at 190.000000 "$node_(2) setdest 67.278825 189.439428 19.998811" -$ns_ at 190.000000 "$node_(3) setdest 192.074302 234.702462 12.471222" -$ns_ at 190.000000 "$node_(4) setdest 138.172614 97.454006 13.189051" -$ns_ at 190.000000 "$node_(5) setdest 154.020435 149.328771 19.998742" -$ns_ at 190.000000 "$node_(6) setdest 163.520779 160.060724 9.468092" -$ns_ at 190.000000 "$node_(7) setdest 51.690561 131.290754 11.470484" -$ns_ at 190.000000 "$node_(8) setdest 55.087819 19.437284 16.056541" -$ns_ at 190.000000 "$node_(9) setdest 139.311546 150.191848 8.976865" -$ns_ at 190.000000 "$node_(10) setdest 59.419189 45.948052 19.327640" - -$ns_ at 191.000000 "$node_(1) setdest 195.032236 71.937101 10.479504" -$ns_ at 191.000000 "$node_(2) setdest 63.774126 209.129366 19.999414" -$ns_ at 191.000000 "$node_(3) setdest 192.134525 248.773197 14.070864" -$ns_ at 191.000000 "$node_(4) setdest 140.151210 112.110209 14.789156" -$ns_ at 191.000000 "$node_(5) setdest 151.528492 169.172266 19.999351" -$ns_ at 191.000000 "$node_(6) setdest 156.653106 151.371539 11.075507" -$ns_ at 191.000000 "$node_(7) setdest 61.020362 122.160481 13.054006" -$ns_ at 191.000000 "$node_(8) setdest 72.246356 15.431568 17.619908" -$ns_ at 191.000000 "$node_(9) setdest 149.037901 146.020315 10.583179" -$ns_ at 191.000000 "$node_(10) setdest 62.233515 26.981985 19.173735" - -$ns_ at 192.000000 "$node_(1) setdest 194.328858 83.995651 12.079047" -$ns_ at 192.000000 "$node_(2) setdest 60.068139 228.782066 19.999074" -$ns_ at 192.000000 "$node_(3) setdest 191.210367 264.413225 15.667308" -$ns_ at 192.000000 "$node_(4) setdest 142.034412 128.390629 16.388976" -$ns_ at 192.000000 "$node_(5) setdest 149.209226 189.037194 19.999859" -$ns_ at 192.000000 "$node_(6) setdest 149.885588 140.648727 12.679826" -$ns_ at 192.000000 "$node_(7) setdest 70.178665 110.699923 14.670341" -$ns_ at 192.000000 "$node_(8) setdest 91.480263 14.579377 19.252776" -$ns_ at 192.000000 "$node_(9) setdest 160.621424 145.650484 11.589425" -$ns_ at 192.000000 "$node_(10) setdest 71.531198 10.851366 18.618372" - -$ns_ at 193.000000 "$node_(1) setdest 193.150556 97.624358 13.679549" -$ns_ at 193.000000 "$node_(2) setdest 56.962041 248.539067 19.999673" -$ns_ at 193.000000 "$node_(3) setdest 188.728422 281.499973 17.266065" -$ns_ at 193.000000 "$node_(4) setdest 143.661611 146.305417 17.988535" -$ns_ at 193.000000 "$node_(5) setdest 146.639128 208.871240 19.999870" -$ns_ at 193.000000 "$node_(6) setdest 141.678111 128.965386 14.278065" -$ns_ at 193.000000 "$node_(7) setdest 77.526460 96.240451 16.219323" -$ns_ at 193.000000 "$node_(8) setdest 111.285642 11.901841 19.985551" -$ns_ at 193.000000 "$node_(9) setdest 162.320582 151.191100 5.795306" -$ns_ at 193.000000 "$node_(10) setdest 69.434904 14.512209 4.218556" - -$ns_ at 194.000000 "$node_(1) setdest 191.331293 112.793988 15.278331" -$ns_ at 194.000000 "$node_(2) setdest 54.045499 268.325206 19.999938" -$ns_ at 194.000000 "$node_(3) setdest 184.809887 299.958796 18.870163" -$ns_ at 194.000000 "$node_(4) setdest 144.576980 165.824228 19.540263" -$ns_ at 194.000000 "$node_(5) setdest 143.541952 228.628802 19.998844" -$ns_ at 194.000000 "$node_(6) setdest 132.011405 116.363647 15.882350" -$ns_ at 194.000000 "$node_(7) setdest 81.390315 78.832201 17.831897" -$ns_ at 194.000000 "$node_(8) setdest 130.995388 8.526521 19.996672" -$ns_ at 194.000000 "$node_(9) setdest 158.304055 156.109234 6.349844" -$ns_ at 194.000000 "$node_(10) setdest 64.357297 23.822765 10.605120" - -$ns_ at 195.000000 "$node_(1) setdest 188.282059 129.392447 16.876216" -$ns_ at 195.000000 "$node_(2) setdest 51.150472 288.114471 19.999904" -$ns_ at 195.000000 "$node_(3) setdest 179.637007 319.243200 19.966145" -$ns_ at 195.000000 "$node_(4) setdest 144.982177 185.819869 19.999746" -$ns_ at 195.000000 "$node_(5) setdest 139.870629 248.288518 19.999576" -$ns_ at 195.000000 "$node_(6) setdest 122.921583 101.453520 17.462438" -$ns_ at 195.000000 "$node_(7) setdest 80.824768 59.414565 19.425870" -$ns_ at 195.000000 "$node_(8) setdest 150.685052 6.112369 19.837111" -$ns_ at 195.000000 "$node_(9) setdest 153.669623 162.564787 7.946831" -$ns_ at 195.000000 "$node_(10) setdest 62.963882 36.031903 12.288395" - -$ns_ at 196.000000 "$node_(1) setdest 183.957321 147.358510 18.479253" -$ns_ at 196.000000 "$node_(2) setdest 48.611087 307.952411 19.999809" -$ns_ at 196.000000 "$node_(3) setdest 172.922634 338.070779 19.989011" -$ns_ at 196.000000 "$node_(4) setdest 145.105736 205.819344 19.999857" -$ns_ at 196.000000 "$node_(5) setdest 135.716006 267.851495 19.999273" -$ns_ at 196.000000 "$node_(6) setdest 114.965812 84.111046 19.080244" -$ns_ at 196.000000 "$node_(7) setdest 77.199943 39.771797 19.974427" -$ns_ at 196.000000 "$node_(8) setdest 170.172454 10.569598 19.990641" -$ns_ at 196.000000 "$node_(9) setdest 146.820750 169.209669 9.542616" -$ns_ at 196.000000 "$node_(10) setdest 65.562221 49.704614 13.917413" - -$ns_ at 197.000000 "$node_(1) setdest 179.424231 166.672897 19.839215" -$ns_ at 197.000000 "$node_(2) setdest 46.811525 327.868842 19.997566" -$ns_ at 197.000000 "$node_(3) setdest 163.939414 355.929108 19.990452" -$ns_ at 197.000000 "$node_(4) setdest 145.006109 225.818471 19.999375" -$ns_ at 197.000000 "$node_(5) setdest 130.662166 287.197475 19.995206" -$ns_ at 197.000000 "$node_(6) setdest 106.357417 66.062345 19.996501" -$ns_ at 197.000000 "$node_(7) setdest 75.946021 20.181201 19.630684" -$ns_ at 197.000000 "$node_(8) setdest 188.099728 18.417830 19.569923" -$ns_ at 197.000000 "$node_(9) setdest 138.645810 176.738594 11.113701" -$ns_ at 197.000000 "$node_(10) setdest 71.277978 64.136289 15.522342" - -$ns_ at 198.000000 "$node_(1) setdest 175.356307 186.254820 19.999992" -$ns_ at 198.000000 "$node_(2) setdest 45.427324 347.820835 19.999951" -$ns_ at 198.000000 "$node_(3) setdest 152.416252 372.246071 19.975649" -$ns_ at 198.000000 "$node_(4) setdest 143.832197 245.780166 19.996183" -$ns_ at 198.000000 "$node_(5) setdest 123.549176 305.874927 19.986041" -$ns_ at 198.000000 "$node_(6) setdest 95.007893 49.716550 19.899666" -$ns_ at 198.000000 "$node_(7) setdest 89.910882 8.256505 18.363434" -$ns_ at 198.000000 "$node_(8) setdest 186.767229 35.321285 16.955895" -$ns_ at 198.000000 "$node_(9) setdest 140.360459 185.666801 9.091364" -$ns_ at 198.000000 "$node_(10) setdest 79.585340 79.054188 17.075010" - -$ns_ at 199.000000 "$node_(1) setdest 171.310371 205.841290 19.999985" -$ns_ at 199.000000 "$node_(2) setdest 45.246485 367.808943 19.988926" -$ns_ at 199.000000 "$node_(3) setdest 141.026187 379.353825 13.425861" -$ns_ at 199.000000 "$node_(4) setdest 141.471649 265.638334 19.997976" -$ns_ at 199.000000 "$node_(5) setdest 113.615585 323.205618 19.975712" -$ns_ at 199.000000 "$node_(6) setdest 77.769915 49.534854 17.238935" -$ns_ at 199.000000 "$node_(7) setdest 106.824065 10.366785 17.044326" -$ns_ at 199.000000 "$node_(8) setdest 175.640526 47.155431 16.243476" -$ns_ at 199.000000 "$node_(9) setdest 145.881782 184.022631 5.760929" -$ns_ at 199.000000 "$node_(10) setdest 88.755604 95.337817 18.688240" - -$ns_ at 200.000000 "$node_(1) setdest 167.224719 225.419522 19.999993" -$ns_ at 200.000000 "$node_(2) setdest 49.050666 387.354600 19.912420" -$ns_ at 200.000000 "$node_(3) setdest 144.119591 377.312601 3.706177" -$ns_ at 200.000000 "$node_(4) setdest 138.256986 285.377161 19.998884" -$ns_ at 200.000000 "$node_(5) setdest 100.527566 338.285629 19.967548" -$ns_ at 200.000000 "$node_(6) setdest 72.091162 65.514596 16.958785" -$ns_ at 200.000000 "$node_(7) setdest 122.081158 16.304017 16.371610" -$ns_ at 200.000000 "$node_(8) setdest 160.926667 51.839992 15.441592" -$ns_ at 200.000000 "$node_(9) setdest 149.142428 177.126205 7.628401" -$ns_ at 200.000000 "$node_(10) setdest 99.613365 111.937528 19.835356" - -$ns_ at 201.000000 "$node_(1) setdest 163.241486 245.018750 19.999897" -$ns_ at 201.000000 "$node_(2) setdest 61.654558 402.610167 19.788644" -$ns_ at 201.000000 "$node_(3) setdest 149.076068 375.294812 5.351461" -$ns_ at 201.000000 "$node_(4) setdest 134.200711 304.958942 19.997488" -$ns_ at 201.000000 "$node_(5) setdest 84.538504 350.240382 19.964123" -$ns_ at 201.000000 "$node_(6) setdest 67.136324 80.376662 15.666251" -$ns_ at 201.000000 "$node_(7) setdest 139.717702 18.648063 17.791633" -$ns_ at 201.000000 "$node_(8) setdest 145.832431 59.287246 16.831446" -$ns_ at 201.000000 "$node_(9) setdest 152.552155 168.551362 9.227902" -$ns_ at 201.000000 "$node_(10) setdest 117.014782 121.404332 19.809839" - -$ns_ at 202.000000 "$node_(1) setdest 159.391115 264.644218 19.999609" -$ns_ at 202.000000 "$node_(2) setdest 78.236392 413.777419 19.991617" -$ns_ at 202.000000 "$node_(3) setdest 155.820516 373.560161 6.963950" -$ns_ at 202.000000 "$node_(4) setdest 129.372934 324.366691 19.999203" -$ns_ at 202.000000 "$node_(5) setdest 66.671342 359.206049 19.990464" -$ns_ at 202.000000 "$node_(6) setdest 59.005599 94.783951 16.543236" -$ns_ at 202.000000 "$node_(7) setdest 158.694781 17.342255 19.021952" -$ns_ at 202.000000 "$node_(8) setdest 128.180124 62.164422 17.885247" -$ns_ at 202.000000 "$node_(9) setdest 155.239978 158.052038 10.837906" -$ns_ at 202.000000 "$node_(10) setdest 136.907991 122.875448 19.947530" - -$ns_ at 203.000000 "$node_(1) setdest 156.090421 284.369430 19.999465" -$ns_ at 203.000000 "$node_(2) setdest 95.064626 424.526948 19.968521" -$ns_ at 203.000000 "$node_(3) setdest 163.970693 371.055823 8.526259" -$ns_ at 203.000000 "$node_(4) setdest 123.550868 343.497632 19.997233" -$ns_ at 203.000000 "$node_(5) setdest 47.626658 365.068247 19.926499" -$ns_ at 203.000000 "$node_(6) setdest 44.129184 104.390756 17.708711" -$ns_ at 203.000000 "$node_(7) setdest 173.699979 7.360376 18.022038" -$ns_ at 203.000000 "$node_(8) setdest 113.299302 53.211896 17.366248" -$ns_ at 203.000000 "$node_(9) setdest 158.404079 146.023580 12.437658" -$ns_ at 203.000000 "$node_(10) setdest 156.369232 118.860713 19.871034" - -$ns_ at 204.000000 "$node_(1) setdest 153.023861 304.132837 19.999901" -$ns_ at 204.000000 "$node_(2) setdest 111.823384 435.393263 19.973301" -$ns_ at 204.000000 "$node_(3) setdest 169.826488 362.901841 10.038813" -$ns_ at 204.000000 "$node_(4) setdest 116.289633 362.124419 19.992067" -$ns_ at 204.000000 "$node_(5) setdest 28.522161 370.489417 19.858773" -$ns_ at 204.000000 "$node_(6) setdest 27.051512 112.644070 18.967447" -$ns_ at 204.000000 "$node_(7) setdest 180.486356 8.534284 6.887160" -$ns_ at 204.000000 "$node_(8) setdest 98.103987 42.322359 18.694375" -$ns_ at 204.000000 "$node_(9) setdest 161.029362 132.243002 14.028416" -$ns_ at 204.000000 "$node_(10) setdest 172.443816 107.486758 19.691600" - -$ns_ at 205.000000 "$node_(1) setdest 149.277393 323.777154 19.998380" -$ns_ at 205.000000 "$node_(2) setdest 129.394110 444.945228 19.999261" -$ns_ at 205.000000 "$node_(3) setdest 168.110917 364.353857 2.247562" -$ns_ at 205.000000 "$node_(4) setdest 106.734376 379.674290 19.982515" -$ns_ at 205.000000 "$node_(5) setdest 24.594624 377.857992 8.349937" -$ns_ at 205.000000 "$node_(6) setdest 9.174780 116.138563 18.215078" -$ns_ at 205.000000 "$node_(7) setdest 181.039157 13.299606 4.797278" -$ns_ at 205.000000 "$node_(8) setdest 82.787587 30.297708 19.472656" -$ns_ at 205.000000 "$node_(9) setdest 162.200630 116.656242 15.630705" -$ns_ at 205.000000 "$node_(10) setdest 181.116590 90.598550 18.984958" - -$ns_ at 206.000000 "$node_(1) setdest 144.598638 343.219337 19.997231" -$ns_ at 206.000000 "$node_(2) setdest 147.113812 454.211788 19.996424" -$ns_ at 206.000000 "$node_(3) setdest 161.975039 369.257123 7.854363" -$ns_ at 206.000000 "$node_(4) setdest 94.731875 395.657510 19.988080" -$ns_ at 206.000000 "$node_(5) setdest 28.110519 380.700946 4.521493" -$ns_ at 206.000000 "$node_(6) setdest 5.389523 111.880557 5.697261" -$ns_ at 206.000000 "$node_(7) setdest 182.643028 19.505356 6.409660" -$ns_ at 206.000000 "$node_(8) setdest 66.703839 19.152674 19.567798" -$ns_ at 206.000000 "$node_(9) setdest 163.096529 99.441502 17.238037" -$ns_ at 206.000000 "$node_(10) setdest 185.879217 71.902868 19.292773" - -$ns_ at 207.000000 "$node_(1) setdest 138.750622 362.341225 19.996146" -$ns_ at 207.000000 "$node_(2) setdest 163.876030 465.070012 19.971805" -$ns_ at 207.000000 "$node_(3) setdest 153.481555 373.421602 9.459501" -$ns_ at 207.000000 "$node_(4) setdest 81.367103 410.535184 19.999058" -$ns_ at 207.000000 "$node_(5) setdest 33.182405 384.121656 6.117622" -$ns_ at 207.000000 "$node_(6) setdest 7.670427 109.002037 3.672656" -$ns_ at 207.000000 "$node_(7) setdest 183.240979 27.459965 7.977052" -$ns_ at 207.000000 "$node_(8) setdest 48.471800 15.353912 18.623584" -$ns_ at 207.000000 "$node_(9) setdest 164.150679 80.632580 18.838438" -$ns_ at 207.000000 "$node_(10) setdest 185.014933 52.993766 18.928844" - -$ns_ at 208.000000 "$node_(1) setdest 131.154711 380.829290 19.987657" -$ns_ at 208.000000 "$node_(2) setdest 180.272876 476.520635 19.999333" -$ns_ at 208.000000 "$node_(3) setdest 143.368479 377.932962 11.073692" -$ns_ at 208.000000 "$node_(4) setdest 69.391507 426.525693 19.977769" -$ns_ at 208.000000 "$node_(5) setdest 39.946435 387.849275 7.723163" -$ns_ at 208.000000 "$node_(6) setdest 10.931499 104.858445 5.272945" -$ns_ at 208.000000 "$node_(7) setdest 180.816137 36.719425 9.571701" -$ns_ at 208.000000 "$node_(8) setdest 30.381523 9.369616 19.054393" -$ns_ at 208.000000 "$node_(9) setdest 164.385587 60.684667 19.949297" -$ns_ at 208.000000 "$node_(10) setdest 174.507313 38.662418 17.770695" - -$ns_ at 209.000000 "$node_(1) setdest 121.092963 398.095887 19.984348" -$ns_ at 209.000000 "$node_(2) setdest 189.211708 490.664051 16.731375" -$ns_ at 209.000000 "$node_(3) setdest 131.945788 383.417256 12.671044" -$ns_ at 209.000000 "$node_(4) setdest 59.975120 444.153298 19.985015" -$ns_ at 209.000000 "$node_(5) setdest 48.328073 391.937141 9.325369" -$ns_ at 209.000000 "$node_(6) setdest 14.411675 98.942625 6.863568" -$ns_ at 209.000000 "$node_(7) setdest 175.728098 46.705469 11.207551" -$ns_ at 209.000000 "$node_(8) setdest 12.204122 7.859309 18.240037" -$ns_ at 209.000000 "$node_(9) setdest 159.026552 41.578356 19.843648" -$ns_ at 209.000000 "$node_(10) setdest 163.369819 23.521448 18.796083" - -$ns_ at 210.000000 "$node_(1) setdest 108.982057 413.993854 19.985480" -$ns_ at 210.000000 "$node_(2) setdest 180.764820 496.526252 10.281795" -$ns_ at 210.000000 "$node_(3) setdest 119.741871 390.808564 14.267692" -$ns_ at 210.000000 "$node_(4) setdest 53.047125 462.900705 19.986555" -$ns_ at 210.000000 "$node_(5) setdest 57.929229 397.148381 10.924249" -$ns_ at 210.000000 "$node_(6) setdest 16.629371 90.783736 8.454918" -$ns_ at 210.000000 "$node_(7) setdest 170.109979 58.216735 12.809079" -$ns_ at 210.000000 "$node_(8) setdest 7.612919 9.823576 4.993745" -$ns_ at 210.000000 "$node_(9) setdest 144.943214 27.647777 19.809125" -$ns_ at 210.000000 "$node_(10) setdest 151.654646 8.351943 19.166615" - -$ns_ at 211.000000 "$node_(1) setdest 94.765433 428.045068 19.988722" -$ns_ at 211.000000 "$node_(2) setdest 169.488840 501.292361 12.241876" -$ns_ at 211.000000 "$node_(3) setdest 106.907423 400.126968 15.860507" -$ns_ at 211.000000 "$node_(4) setdest 49.262673 482.502882 19.964153" -$ns_ at 211.000000 "$node_(5) setdest 68.775716 403.409497 12.523891" -$ns_ at 211.000000 "$node_(6) setdest 18.101119 80.820271 10.071578" -$ns_ at 211.000000 "$node_(7) setdest 164.220636 71.367090 14.408894" -$ns_ at 211.000000 "$node_(8) setdest 8.398181 10.582628 1.092152" -$ns_ at 211.000000 "$node_(9) setdest 126.252440 20.979851 19.844553" -$ns_ at 211.000000 "$node_(10) setdest 150.671362 7.925031 1.071962" - -$ns_ at 212.000000 "$node_(1) setdest 79.694798 440.482197 19.539862" -$ns_ at 212.000000 "$node_(2) setdest 158.086396 509.199851 13.876027" -$ns_ at 212.000000 "$node_(3) setdest 93.891593 411.784206 17.472923" -$ns_ at 212.000000 "$node_(4) setdest 51.602803 502.238394 19.873768" -$ns_ at 212.000000 "$node_(5) setdest 79.786377 412.225707 14.105326" -$ns_ at 212.000000 "$node_(6) setdest 18.082994 69.169270 11.651015" -$ns_ at 212.000000 "$node_(7) setdest 156.452151 85.357032 16.002119" -$ns_ at 212.000000 "$node_(8) setdest 10.252534 12.543807 2.699046" -$ns_ at 212.000000 "$node_(9) setdest 106.444082 18.349570 19.982227" -$ns_ at 212.000000 "$node_(10) setdest 150.561643 9.241322 1.320856" - -$ns_ at 213.000000 "$node_(1) setdest 74.331248 439.156532 5.524948" -$ns_ at 213.000000 "$node_(2) setdest 147.109484 520.059714 15.441154" -$ns_ at 213.000000 "$node_(3) setdest 78.802986 423.444845 19.069257" -$ns_ at 213.000000 "$node_(4) setdest 64.714464 515.886813 18.926040" -$ns_ at 213.000000 "$node_(5) setdest 90.367257 423.848581 15.717704" -$ns_ at 213.000000 "$node_(6) setdest 15.231940 56.211466 13.267750" -$ns_ at 213.000000 "$node_(7) setdest 146.294162 99.736602 17.605590" -$ns_ at 213.000000 "$node_(8) setdest 12.764348 16.030199 4.296992" -$ns_ at 213.000000 "$node_(9) setdest 87.094251 13.355646 19.983875" -$ns_ at 213.000000 "$node_(10) setdest 150.265932 12.167440 2.941022" - -$ns_ at 214.000000 "$node_(1) setdest 75.387413 435.963971 3.362726" -$ns_ at 214.000000 "$node_(2) setdest 134.637490 531.303365 16.791972" -$ns_ at 214.000000 "$node_(3) setdest 63.111503 435.821747 19.985253" -$ns_ at 214.000000 "$node_(4) setdest 82.741655 517.689625 18.117113" -$ns_ at 214.000000 "$node_(5) setdest 100.190863 438.094362 17.304495" -$ns_ at 214.000000 "$node_(6) setdest 11.435316 41.831751 14.872477" -$ns_ at 214.000000 "$node_(7) setdest 134.405054 114.825240 19.209838" -$ns_ at 214.000000 "$node_(8) setdest 15.786921 21.097420 5.900227" -$ns_ at 214.000000 "$node_(9) setdest 67.206233 11.386313 19.985283" -$ns_ at 214.000000 "$node_(10) setdest 150.233247 16.709509 4.542186" - -$ns_ at 215.000000 "$node_(1) setdest 78.105600 431.749429 5.015068" -$ns_ at 215.000000 "$node_(2) setdest 119.211728 527.255675 15.947976" -$ns_ at 215.000000 "$node_(3) setdest 48.423135 449.394750 19.999364" -$ns_ at 215.000000 "$node_(4) setdest 100.521552 517.808971 17.780297" -$ns_ at 215.000000 "$node_(5) setdest 109.423660 454.614792 18.925357" -$ns_ at 215.000000 "$node_(6) setdest 16.762073 29.826767 13.133696" -$ns_ at 215.000000 "$node_(7) setdest 121.638439 130.219167 19.998986" -$ns_ at 215.000000 "$node_(8) setdest 20.223833 27.143327 7.499279" -$ns_ at 215.000000 "$node_(9) setdest 47.635785 14.277190 19.782811" -$ns_ at 215.000000 "$node_(10) setdest 149.981298 22.846536 6.142197" - -$ns_ at 216.000000 "$node_(1) setdest 82.316111 426.647880 6.614696" -$ns_ at 216.000000 "$node_(2) setdest 110.714063 514.069971 15.686717" -$ns_ at 216.000000 "$node_(3) setdest 34.234170 463.437881 19.963373" -$ns_ at 216.000000 "$node_(4) setdest 119.756878 518.623367 19.252559" -$ns_ at 216.000000 "$node_(5) setdest 118.021417 472.643823 19.974168" -$ns_ at 216.000000 "$node_(6) setdest 24.439905 33.577223 8.544883" -$ns_ at 216.000000 "$node_(7) setdest 109.264356 145.928934 19.997868" -$ns_ at 216.000000 "$node_(8) setdest 26.436807 33.784570 9.094347" -$ns_ at 216.000000 "$node_(9) setdest 34.763093 28.005283 18.819318" -$ns_ at 216.000000 "$node_(10) setdest 149.466985 30.571752 7.742318" - -$ns_ at 217.000000 "$node_(1) setdest 87.966643 420.681429 8.217484" -$ns_ at 217.000000 "$node_(2) setdest 106.139891 497.477479 17.211446" -$ns_ at 217.000000 "$node_(3) setdest 24.871837 481.006527 19.907551" -$ns_ at 217.000000 "$node_(4) setdest 139.198045 521.043816 19.591262" -$ns_ at 217.000000 "$node_(5) setdest 125.144910 491.320562 19.989115" -$ns_ at 217.000000 "$node_(6) setdest 29.906717 42.714611 10.647906" -$ns_ at 217.000000 "$node_(7) setdest 95.624683 160.464758 19.933160" -$ns_ at 217.000000 "$node_(8) setdest 35.012079 40.154365 10.682209" -$ns_ at 217.000000 "$node_(9) setdest 26.794592 44.498695 18.317469" -$ns_ at 217.000000 "$node_(10) setdest 148.822317 39.891733 9.342250" - -$ns_ at 218.000000 "$node_(1) setdest 95.567803 414.482141 9.808608" -$ns_ at 218.000000 "$node_(2) setdest 101.751650 479.151427 18.844119" -$ns_ at 218.000000 "$node_(3) setdest 21.772410 500.718610 19.954264" -$ns_ at 218.000000 "$node_(4) setdest 156.440799 529.170085 19.061711" -$ns_ at 218.000000 "$node_(5) setdest 136.804828 507.434328 19.889875" -$ns_ at 218.000000 "$node_(6) setdest 34.936287 53.901566 12.265583" -$ns_ at 218.000000 "$node_(7) setdest 77.559907 162.800620 18.215168" -$ns_ at 218.000000 "$node_(8) setdest 46.265277 45.048070 12.271219" -$ns_ at 218.000000 "$node_(9) setdest 18.369496 61.553834 19.022618" -$ns_ at 218.000000 "$node_(10) setdest 148.315037 50.819341 10.939376" - -$ns_ at 219.000000 "$node_(1) setdest 105.384019 408.666566 11.409602" -$ns_ at 219.000000 "$node_(2) setdest 105.257830 460.439311 19.037767" -$ns_ at 219.000000 "$node_(3) setdest 20.836622 520.669754 19.973078" -$ns_ at 219.000000 "$node_(4) setdest 169.726291 541.962081 18.442870" -$ns_ at 219.000000 "$node_(5) setdest 151.392428 509.951508 14.803185" -$ns_ at 219.000000 "$node_(6) setdest 39.985524 66.816926 13.867275" -$ns_ at 219.000000 "$node_(7) setdest 65.983518 149.611440 17.548997" -$ns_ at 219.000000 "$node_(8) setdest 60.002002 46.833409 13.852258" -$ns_ at 219.000000 "$node_(9) setdest 12.671632 79.346833 18.683052" -$ns_ at 219.000000 "$node_(10) setdest 149.329428 63.307247 12.529038" - -$ns_ at 220.000000 "$node_(1) setdest 117.372851 403.595980 13.017025" -$ns_ at 220.000000 "$node_(2) setdest 114.312002 443.838623 18.909280" -$ns_ at 220.000000 "$node_(3) setdest 32.633983 533.959274 17.770455" -$ns_ at 220.000000 "$node_(4) setdest 186.809428 545.300049 17.406194" -$ns_ at 220.000000 "$node_(5) setdest 154.136381 499.903314 10.416116" -$ns_ at 220.000000 "$node_(6) setdest 38.966285 82.245893 15.462596" -$ns_ at 220.000000 "$node_(7) setdest 74.429529 163.526860 16.278023" -$ns_ at 220.000000 "$node_(8) setdest 62.748658 50.955781 4.953592" -$ns_ at 220.000000 "$node_(9) setdest 16.722542 97.580963 18.678688" -$ns_ at 220.000000 "$node_(10) setdest 147.564335 77.337282 14.140630" - -$ns_ at 221.000000 "$node_(1) setdest 130.510749 397.211113 14.607220" -$ns_ at 221.000000 "$node_(2) setdest 126.001789 428.533431 19.258765" -$ns_ at 221.000000 "$node_(3) setdest 47.085796 524.976442 17.016055" -$ns_ at 221.000000 "$node_(4) setdest 195.470877 545.496075 8.663667" -$ns_ at 221.000000 "$node_(5) setdest 153.537843 487.668110 12.249835" -$ns_ at 221.000000 "$node_(6) setdest 37.659369 99.258980 17.063211" -$ns_ at 221.000000 "$node_(7) setdest 81.550077 180.240654 18.167363" -$ns_ at 221.000000 "$node_(8) setdest 62.598894 57.433367 6.479317" -$ns_ at 221.000000 "$node_(9) setdest 23.470822 116.374653 19.968527" -$ns_ at 221.000000 "$node_(10) setdest 144.701469 92.814988 15.740247" - -$ns_ at 222.000000 "$node_(1) setdest 145.829089 392.029894 16.170856" -$ns_ at 222.000000 "$node_(2) setdest 140.217574 415.094347 19.562657" -$ns_ at 222.000000 "$node_(3) setdest 60.241100 516.107987 15.865420" -$ns_ at 222.000000 "$node_(4) setdest 195.175480 544.049314 1.476611" -$ns_ at 222.000000 "$node_(5) setdest 153.773151 473.824698 13.845411" -$ns_ at 222.000000 "$node_(6) setdest 36.836689 117.903151 18.662312" -$ns_ at 222.000000 "$node_(7) setdest 88.469997 198.652396 19.669203" -$ns_ at 222.000000 "$node_(8) setdest 62.213896 65.503403 8.079215" -$ns_ at 222.000000 "$node_(9) setdest 31.284840 134.781911 19.997150" -$ns_ at 222.000000 "$node_(10) setdest 140.588071 109.660694 17.340642" - -$ns_ at 223.000000 "$node_(1) setdest 163.506752 392.575980 17.686096" -$ns_ at 223.000000 "$node_(2) setdest 154.063643 401.028161 19.737558" -$ns_ at 223.000000 "$node_(3) setdest 74.782464 518.041618 14.669363" -$ns_ at 223.000000 "$node_(4) setdest 194.480877 541.034819 3.093486" -$ns_ at 223.000000 "$node_(5) setdest 154.461775 458.388033 15.452018" -$ns_ at 223.000000 "$node_(6) setdest 36.889515 137.817056 19.913975" -$ns_ at 223.000000 "$node_(7) setdest 93.285752 218.049531 19.986004" -$ns_ at 223.000000 "$node_(8) setdest 61.558857 75.160595 9.679381" -$ns_ at 223.000000 "$node_(9) setdest 40.120888 152.722334 19.998363" -$ns_ at 223.000000 "$node_(10) setdest 135.370957 127.870138 18.942073" - -$ns_ at 224.000000 "$node_(1) setdest 181.923802 396.004220 18.733408" -$ns_ at 224.000000 "$node_(2) setdest 167.390779 386.339495 19.833544" -$ns_ at 224.000000 "$node_(3) setdest 88.812375 526.590208 16.429145" -$ns_ at 224.000000 "$node_(4) setdest 193.757794 536.395966 4.694870" -$ns_ at 224.000000 "$node_(5) setdest 155.534575 441.369278 17.052534" -$ns_ at 224.000000 "$node_(6) setdest 37.937125 157.787942 19.998344" -$ns_ at 224.000000 "$node_(7) setdest 95.263234 237.932451 19.981015" -$ns_ at 224.000000 "$node_(8) setdest 60.618285 86.400311 11.279002" -$ns_ at 224.000000 "$node_(9) setdest 49.705686 170.274483 19.998657" -$ns_ at 224.000000 "$node_(10) setdest 129.766491 147.053821 19.985588" - -$ns_ at 225.000000 "$node_(1) setdest 169.232343 395.048481 12.727394" -$ns_ at 225.000000 "$node_(2) setdest 178.021040 369.992559 19.499353" -$ns_ at 225.000000 "$node_(3) setdest 105.697669 532.818640 17.997403" -$ns_ at 225.000000 "$node_(4) setdest 193.626695 530.109972 6.287361" -$ns_ at 225.000000 "$node_(5) setdest 157.030780 422.777712 18.651674" -$ns_ at 225.000000 "$node_(6) setdest 39.945670 177.684547 19.997729" -$ns_ at 225.000000 "$node_(7) setdest 93.862395 257.856020 19.972755" -$ns_ at 225.000000 "$node_(8) setdest 59.031456 99.180711 12.878534" -$ns_ at 225.000000 "$node_(9) setdest 59.205275 187.873059 19.998802" -$ns_ at 225.000000 "$node_(10) setdest 124.063931 166.223553 19.999945" - -$ns_ at 226.000000 "$node_(1) setdest 156.800156 391.440287 12.945205" -$ns_ at 226.000000 "$node_(2) setdest 181.618992 357.273651 13.218014" -$ns_ at 226.000000 "$node_(3) setdest 124.505138 538.184199 19.557865" -$ns_ at 226.000000 "$node_(4) setdest 193.643917 522.227082 7.882909" -$ns_ at 226.000000 "$node_(5) setdest 158.657327 402.933793 19.910469" -$ns_ at 226.000000 "$node_(6) setdest 43.108409 197.429911 19.997057" -$ns_ at 226.000000 "$node_(7) setdest 88.502871 277.089742 19.966486" -$ns_ at 226.000000 "$node_(8) setdest 56.808037 113.487980 14.479003" -$ns_ at 226.000000 "$node_(9) setdest 67.791820 205.933327 19.997551" -$ns_ at 226.000000 "$node_(10) setdest 117.964834 185.269423 19.998604" - -$ns_ at 227.000000 "$node_(1) setdest 142.278798 390.812500 14.534922" -$ns_ at 227.000000 "$node_(2) setdest 180.809611 361.122439 3.932972" -$ns_ at 227.000000 "$node_(3) setdest 139.353761 542.830733 15.558660" -$ns_ at 227.000000 "$node_(4) setdest 190.918757 513.212438 9.417553" -$ns_ at 227.000000 "$node_(5) setdest 158.201943 382.958722 19.980261" -$ns_ at 227.000000 "$node_(6) setdest 47.461748 216.947467 19.997164" -$ns_ at 227.000000 "$node_(7) setdest 79.883191 295.123722 19.988080" -$ns_ at 227.000000 "$node_(8) setdest 54.120836 129.341065 16.079222" -$ns_ at 227.000000 "$node_(9) setdest 75.603470 224.344458 19.999791" -$ns_ at 227.000000 "$node_(10) setdest 111.317961 204.132478 19.999894" - -$ns_ at 228.000000 "$node_(1) setdest 126.803939 394.954915 16.019702" -$ns_ at 228.000000 "$node_(2) setdest 181.453885 366.636563 5.551636" -$ns_ at 228.000000 "$node_(3) setdest 139.679950 541.809477 1.072084" -$ns_ at 228.000000 "$node_(4) setdest 182.221684 506.884617 10.755483" -$ns_ at 228.000000 "$node_(5) setdest 147.532398 367.471383 18.806830" -$ns_ at 228.000000 "$node_(6) setdest 53.185240 236.106169 19.995355" -$ns_ at 228.000000 "$node_(7) setdest 69.135376 311.964610 19.978263" -$ns_ at 228.000000 "$node_(8) setdest 50.220110 146.582020 17.676713" -$ns_ at 228.000000 "$node_(9) setdest 83.229589 242.832888 19.999493" -$ns_ at 228.000000 "$node_(10) setdest 104.487873 222.930048 19.999968" - -$ns_ at 229.000000 "$node_(1) setdest 112.719153 405.732941 17.735474" -$ns_ at 229.000000 "$node_(2) setdest 184.190891 373.250673 7.158048" -$ns_ at 229.000000 "$node_(3) setdest 138.130687 540.190583 2.240767" -$ns_ at 229.000000 "$node_(4) setdest 170.893314 511.903508 12.390368" -$ns_ at 229.000000 "$node_(5) setdest 131.769906 373.894402 17.020909" -$ns_ at 229.000000 "$node_(6) setdest 60.421096 254.745402 19.994464" -$ns_ at 229.000000 "$node_(7) setdest 55.227342 326.293985 19.969086" -$ns_ at 229.000000 "$node_(8) setdest 46.727716 165.535396 19.272448" -$ns_ at 229.000000 "$node_(9) setdest 90.276455 261.550003 19.999718" -$ns_ at 229.000000 "$node_(10) setdest 98.003508 241.846149 19.996647" - -$ns_ at 230.000000 "$node_(1) setdest 96.091336 415.488575 19.278400" -$ns_ at 230.000000 "$node_(2) setdest 183.469209 381.617058 8.397453" -$ns_ at 230.000000 "$node_(3) setdest 135.135321 537.790149 3.838527" -$ns_ at 230.000000 "$node_(4) setdest 159.237705 520.178185 14.294178" -$ns_ at 230.000000 "$node_(5) setdest 126.003487 389.332246 16.479642" -$ns_ at 230.000000 "$node_(6) setdest 69.231636 272.693606 19.994091" -$ns_ at 230.000000 "$node_(7) setdest 39.927801 339.173368 19.998862" -$ns_ at 230.000000 "$node_(8) setdest 44.917086 185.446450 19.993211" -$ns_ at 230.000000 "$node_(9) setdest 96.877144 280.425405 19.996247" -$ns_ at 230.000000 "$node_(10) setdest 92.829898 261.161671 19.996390" - -$ns_ at 231.000000 "$node_(1) setdest 76.542960 419.096553 19.878544" -$ns_ at 231.000000 "$node_(2) setdest 176.455767 382.214395 7.038833" -$ns_ at 231.000000 "$node_(3) setdest 130.270647 535.384863 5.426828" -$ns_ at 231.000000 "$node_(4) setdest 147.767236 531.122795 15.854216" -$ns_ at 231.000000 "$node_(5) setdest 120.093704 403.690952 15.527329" -$ns_ at 231.000000 "$node_(6) setdest 79.612346 289.781035 19.993483" -$ns_ at 231.000000 "$node_(7) setdest 24.003817 350.585990 19.591355" -$ns_ at 231.000000 "$node_(8) setdest 44.961975 205.440954 19.994554" -$ns_ at 231.000000 "$node_(9) setdest 99.747344 300.145262 19.927640" -$ns_ at 231.000000 "$node_(10) setdest 89.013268 280.789285 19.995247" - -$ns_ at 232.000000 "$node_(1) setdest 57.010907 414.931045 19.971292" -$ns_ at 232.000000 "$node_(2) setdest 170.625082 375.887436 8.603912" -$ns_ at 232.000000 "$node_(3) setdest 123.401898 533.915668 7.024119" -$ns_ at 232.000000 "$node_(4) setdest 133.831007 536.334199 14.878750" -$ns_ at 232.000000 "$node_(5) setdest 112.784511 418.983603 16.949616" -$ns_ at 232.000000 "$node_(6) setdest 91.565883 305.808159 19.993893" -$ns_ at 232.000000 "$node_(7) setdest 24.991666 366.397074 15.841913" -$ns_ at 232.000000 "$node_(8) setdest 46.668910 225.364489 19.996521" -$ns_ at 232.000000 "$node_(9) setdest 95.297668 319.497789 19.857489" -$ns_ at 232.000000 "$node_(10) setdest 86.767611 300.658389 19.995606" - -$ns_ at 233.000000 "$node_(1) setdest 39.647141 405.570459 19.726149" -$ns_ at 233.000000 "$node_(2) setdest 163.274148 368.970881 10.093313" -$ns_ at 233.000000 "$node_(3) setdest 114.780291 533.380993 8.638170" -$ns_ at 233.000000 "$node_(4) setdest 131.539148 532.333883 4.610330" -$ns_ at 233.000000 "$node_(5) setdest 104.102864 435.367253 18.541710" -$ns_ at 233.000000 "$node_(6) setdest 103.303347 321.997575 19.996631" -$ns_ at 233.000000 "$node_(7) setdest 30.412033 380.296306 14.918748" -$ns_ at 233.000000 "$node_(8) setdest 49.123918 245.211852 19.998622" -$ns_ at 233.000000 "$node_(9) setdest 83.212825 335.267364 19.867635" -$ns_ at 233.000000 "$node_(10) setdest 86.025912 320.638077 19.993450" - -$ns_ at 234.000000 "$node_(1) setdest 27.316123 390.616503 19.382332" -$ns_ at 234.000000 "$node_(2) setdest 152.190026 371.188100 11.303708" -$ns_ at 234.000000 "$node_(3) setdest 104.559734 533.881666 10.232813" -$ns_ at 234.000000 "$node_(4) setdest 134.437047 528.843275 4.536757" -$ns_ at 234.000000 "$node_(5) setdest 99.490371 454.660971 19.837405" -$ns_ at 234.000000 "$node_(6) setdest 113.260598 339.320990 19.981180" -$ns_ at 234.000000 "$node_(7) setdest 34.878867 395.284625 15.639767" -$ns_ at 234.000000 "$node_(8) setdest 52.561370 264.911186 19.996995" -$ns_ at 234.000000 "$node_(9) setdest 66.066130 345.377223 19.905235" -$ns_ at 234.000000 "$node_(10) setdest 87.285070 340.587013 19.988635" - -$ns_ at 235.000000 "$node_(1) setdest 20.218846 372.865040 19.117682" -$ns_ at 235.000000 "$node_(2) setdest 142.051256 379.923957 13.383193" -$ns_ at 235.000000 "$node_(3) setdest 92.840981 535.571717 11.839993" -$ns_ at 235.000000 "$node_(4) setdest 138.217326 524.011125 6.135160" -$ns_ at 235.000000 "$node_(5) setdest 91.141238 472.512581 19.707562" -$ns_ at 235.000000 "$node_(6) setdest 120.629818 357.902574 19.989513" -$ns_ at 235.000000 "$node_(7) setdest 37.667906 412.302677 17.245082" -$ns_ at 235.000000 "$node_(8) setdest 57.399640 284.312240 19.995243" -$ns_ at 235.000000 "$node_(9) setdest 47.135371 351.684805 19.953928" -$ns_ at 235.000000 "$node_(10) setdest 91.171326 360.189136 19.983649" - -$ns_ at 236.000000 "$node_(1) setdest 24.598928 356.149629 17.279760" -$ns_ at 236.000000 "$node_(2) setdest 133.409494 392.148552 14.970664" -$ns_ at 236.000000 "$node_(3) setdest 79.429653 536.017371 13.418731" -$ns_ at 236.000000 "$node_(4) setdest 141.644180 517.087121 7.725617" -$ns_ at 236.000000 "$node_(5) setdest 82.659254 489.792059 19.249010" -$ns_ at 236.000000 "$node_(6) setdest 124.911845 377.382671 19.945173" -$ns_ at 236.000000 "$node_(7) setdest 36.308163 431.068874 18.815394" -$ns_ at 236.000000 "$node_(8) setdest 63.770885 303.263885 19.993940" -$ns_ at 236.000000 "$node_(9) setdest 27.530214 350.712658 19.629245" -$ns_ at 236.000000 "$node_(10) setdest 98.063978 378.939773 19.977363" - -$ns_ at 237.000000 "$node_(1) setdest 40.321183 353.037350 16.027339" -$ns_ at 237.000000 "$node_(2) setdest 125.329380 406.653920 16.604033" -$ns_ at 237.000000 "$node_(3) setdest 64.843715 532.584356 14.984497" -$ns_ at 237.000000 "$node_(4) setdest 144.634350 508.245730 9.333344" -$ns_ at 237.000000 "$node_(5) setdest 82.909106 508.254419 18.464050" -$ns_ at 237.000000 "$node_(6) setdest 118.133725 394.817452 18.706002" -$ns_ at 237.000000 "$node_(7) setdest 29.233267 449.643599 19.876483" -$ns_ at 237.000000 "$node_(8) setdest 71.818285 321.564343 19.991683" -$ns_ at 237.000000 "$node_(9) setdest 29.921966 351.885394 2.663792" -$ns_ at 237.000000 "$node_(10) setdest 108.291461 396.089794 19.968090" - -$ns_ at 238.000000 "$node_(1) setdest 45.596210 362.703271 11.011628" -$ns_ at 238.000000 "$node_(2) setdest 116.291703 422.438321 18.188648" -$ns_ at 238.000000 "$node_(3) setdest 50.905662 523.641287 16.560429" -$ns_ at 238.000000 "$node_(4) setdest 147.083186 497.586315 10.937090" -$ns_ at 238.000000 "$node_(5) setdest 86.823206 527.075434 19.223704" -$ns_ at 238.000000 "$node_(6) setdest 100.295091 394.820595 17.838634" -$ns_ at 238.000000 "$node_(7) setdest 14.754694 462.701263 19.496965" -$ns_ at 238.000000 "$node_(8) setdest 82.106778 338.696777 19.984329" -$ns_ at 238.000000 "$node_(9) setdest 29.384525 352.572171 0.872069" -$ns_ at 238.000000 "$node_(10) setdest 121.581838 411.004409 19.976983" - -$ns_ at 239.000000 "$node_(1) setdest 43.050325 374.782260 12.344371" -$ns_ at 239.000000 "$node_(2) setdest 109.603123 440.967025 19.698985" -$ns_ at 239.000000 "$node_(3) setdest 40.281591 508.934509 18.142774" -$ns_ at 239.000000 "$node_(4) setdest 150.186991 485.439022 12.537557" -$ns_ at 239.000000 "$node_(5) setdest 88.363743 540.891623 13.901811" -$ns_ at 239.000000 "$node_(6) setdest 83.872867 392.609649 16.570387" -$ns_ at 239.000000 "$node_(7) setdest 2.120167 462.131925 12.647348" -$ns_ at 239.000000 "$node_(8) setdest 94.881055 354.058754 19.979301" -$ns_ at 239.000000 "$node_(9) setdest 28.147365 354.727230 2.484924" -$ns_ at 239.000000 "$node_(10) setdest 137.437686 423.128242 19.959841" - -$ns_ at 240.000000 "$node_(1) setdest 38.556092 388.011135 13.971445" -$ns_ at 240.000000 "$node_(2) setdest 102.994537 459.843356 19.999731" -$ns_ at 240.000000 "$node_(3) setdest 34.511155 490.212704 19.590914" -$ns_ at 240.000000 "$node_(4) setdest 153.699183 471.745840 14.136432" -$ns_ at 240.000000 "$node_(5) setdest 87.677276 538.921027 2.086741" -$ns_ at 240.000000 "$node_(6) setdest 67.844685 393.430187 16.049172" -$ns_ at 240.000000 "$node_(7) setdest 2.807388 458.762773 3.438526" -$ns_ at 240.000000 "$node_(8) setdest 109.948493 367.184167 19.982596" -$ns_ at 240.000000 "$node_(9) setdest 26.581030 358.478450 4.065102" -$ns_ at 240.000000 "$node_(10) setdest 155.787822 430.945677 19.945921" - -$ns_ at 241.000000 "$node_(1) setdest 36.249641 403.358559 15.519767" -$ns_ at 241.000000 "$node_(2) setdest 95.054734 478.197050 19.997464" -$ns_ at 241.000000 "$node_(3) setdest 38.588756 470.902314 19.736210" -$ns_ at 241.000000 "$node_(4) setdest 158.039693 456.618076 15.738147" -$ns_ at 241.000000 "$node_(5) setdest 85.810743 535.721185 3.704447" -$ns_ at 241.000000 "$node_(6) setdest 50.254348 394.635888 17.631610" -$ns_ at 241.000000 "$node_(7) setdest 5.492504 454.380668 5.139327" -$ns_ at 241.000000 "$node_(8) setdest 125.740547 379.432191 19.985071" -$ns_ at 241.000000 "$node_(9) setdest 26.686133 364.112657 5.635187" -$ns_ at 241.000000 "$node_(10) setdest 175.328309 429.760207 19.576413" - -$ns_ at 242.000000 "$node_(1) setdest 37.522192 420.480349 17.169015" -$ns_ at 242.000000 "$node_(2) setdest 90.631305 497.645680 19.945323" -$ns_ at 242.000000 "$node_(3) setdest 50.739464 455.055826 19.968748" -$ns_ at 242.000000 "$node_(4) setdest 162.672725 439.910564 17.337991" -$ns_ at 242.000000 "$node_(5) setdest 82.862827 531.310088 5.305468" -$ns_ at 242.000000 "$node_(6) setdest 31.030156 394.391413 19.225746" -$ns_ at 242.000000 "$node_(7) setdest 9.560885 449.014231 6.734268" -$ns_ at 242.000000 "$node_(8) setdest 138.863619 394.470220 19.958891" -$ns_ at 242.000000 "$node_(9) setdest 30.044622 370.532583 7.245336" -$ns_ at 242.000000 "$node_(10) setdest 184.068040 414.234527 17.816555" - -$ns_ at 243.000000 "$node_(1) setdest 37.985476 439.243636 18.769005" -$ns_ at 243.000000 "$node_(2) setdest 87.433717 517.377092 19.988827" -$ns_ at 243.000000 "$node_(3) setdest 62.449094 438.866145 19.980520" -$ns_ at 243.000000 "$node_(4) setdest 167.366807 421.571460 18.930323" -$ns_ at 243.000000 "$node_(5) setdest 79.256025 525.421283 6.905580" -$ns_ at 243.000000 "$node_(6) setdest 11.506341 396.543000 19.642013" -$ns_ at 243.000000 "$node_(7) setdest 15.539098 443.203051 8.337197" -$ns_ at 243.000000 "$node_(8) setdest 147.973211 412.218070 19.949207" -$ns_ at 243.000000 "$node_(9) setdest 36.059140 377.050285 8.868758" -$ns_ at 243.000000 "$node_(10) setdest 177.685561 398.128349 17.324694" - -$ns_ at 244.000000 "$node_(1) setdest 39.206090 459.137583 19.931358" -$ns_ at 244.000000 "$node_(2) setdest 83.154377 536.500088 19.595961" -$ns_ at 244.000000 "$node_(3) setdest 78.636311 427.281132 19.905741" -$ns_ at 244.000000 "$node_(4) setdest 170.390886 401.818715 19.982892" -$ns_ at 244.000000 "$node_(5) setdest 74.252665 518.545692 8.503374" -$ns_ at 244.000000 "$node_(6) setdest 7.973051 410.375276 14.276414" -$ns_ at 244.000000 "$node_(7) setdest 23.323807 437.026222 9.937551" -$ns_ at 244.000000 "$node_(8) setdest 153.374916 431.467556 19.993027" -$ns_ at 244.000000 "$node_(9) setdest 44.032723 383.856539 10.483469" -$ns_ at 244.000000 "$node_(10) setdest 172.718843 382.551826 16.349201" - -$ns_ at 245.000000 "$node_(1) setdest 34.618867 478.486864 19.885606" -$ns_ at 245.000000 "$node_(2) setdest 84.300844 531.592510 5.039713" -$ns_ at 245.000000 "$node_(3) setdest 94.940590 415.825326 19.926490" -$ns_ at 245.000000 "$node_(4) setdest 172.304961 394.881002 7.196912" -$ns_ at 245.000000 "$node_(5) setdest 68.133382 510.504064 10.105117" -$ns_ at 245.000000 "$node_(6) setdest 17.059711 420.972002 13.959154" -$ns_ at 245.000000 "$node_(7) setdest 32.971174 430.706107 11.533236" -$ns_ at 245.000000 "$node_(8) setdest 157.601063 450.999458 19.983881" -$ns_ at 245.000000 "$node_(9) setdest 53.145590 391.780127 12.075909" -$ns_ at 245.000000 "$node_(10) setdest 169.004729 365.196387 17.748406" - -$ns_ at 246.000000 "$node_(1) setdest 23.314948 494.915448 19.941839" -$ns_ at 246.000000 "$node_(2) setdest 80.388414 526.333405 6.554791" -$ns_ at 246.000000 "$node_(3) setdest 105.925896 399.190915 19.934407" -$ns_ at 246.000000 "$node_(4) setdest 172.261920 400.073454 5.192630" -$ns_ at 246.000000 "$node_(5) setdest 60.662128 501.492990 11.705516" -$ns_ at 246.000000 "$node_(6) setdest 25.067644 434.285222 15.536049" -$ns_ at 246.000000 "$node_(7) setdest 44.416211 424.250797 13.140012" -$ns_ at 246.000000 "$node_(8) setdest 157.547382 470.971881 19.972495" -$ns_ at 246.000000 "$node_(9) setdest 61.816142 402.356439 13.676142" -$ns_ at 246.000000 "$node_(10) setdest 159.697284 354.841814 13.922848" - -$ns_ at 247.000000 "$node_(1) setdest 11.471594 510.982443 19.960295" -$ns_ at 247.000000 "$node_(2) setdest 73.667647 521.515333 8.269373" -$ns_ at 247.000000 "$node_(3) setdest 115.687404 381.745967 19.990329" -$ns_ at 247.000000 "$node_(4) setdest 172.542353 406.883343 6.815660" -$ns_ at 247.000000 "$node_(5) setdest 53.043729 490.595790 13.296201" -$ns_ at 247.000000 "$node_(6) setdest 35.532652 447.799237 17.092249" -$ns_ at 247.000000 "$node_(7) setdest 57.583686 417.635230 14.735946" -$ns_ at 247.000000 "$node_(8) setdest 155.807521 490.895157 19.999102" -$ns_ at 247.000000 "$node_(9) setdest 70.586313 414.874960 15.284936" -$ns_ at 247.000000 "$node_(10) setdest 150.705382 353.022498 9.174106" - -$ns_ at 248.000000 "$node_(1) setdest 6.250205 530.216206 19.929890" -$ns_ at 248.000000 "$node_(2) setdest 64.550481 517.738746 9.868400" -$ns_ at 248.000000 "$node_(3) setdest 129.575043 368.902786 18.915967" -$ns_ at 248.000000 "$node_(4) setdest 172.766820 415.295599 8.415251" -$ns_ at 248.000000 "$node_(5) setdest 45.664917 477.649441 14.901504" -$ns_ at 248.000000 "$node_(6) setdest 49.236481 460.622756 18.767994" -$ns_ at 248.000000 "$node_(7) setdest 72.542200 411.059556 16.340032" -$ns_ at 248.000000 "$node_(8) setdest 154.151119 510.826019 19.999573" -$ns_ at 248.000000 "$node_(9) setdest 80.048453 428.859710 16.885062" -$ns_ at 248.000000 "$node_(10) setdest 150.693495 353.348529 0.326248" - -$ns_ at 249.000000 "$node_(1) setdest 15.633937 545.116140 17.608591" -$ns_ at 249.000000 "$node_(2) setdest 53.897778 513.466205 11.477573" -$ns_ at 249.000000 "$node_(3) setdest 147.143605 364.268821 18.169425" -$ns_ at 249.000000 "$node_(4) setdest 172.715108 425.310616 10.015150" -$ns_ at 249.000000 "$node_(5) setdest 40.276620 462.090927 16.465147" -$ns_ at 249.000000 "$node_(6) setdest 66.591813 470.358500 19.899554" -$ns_ at 249.000000 "$node_(7) setdest 89.011277 403.945945 17.939731" -$ns_ at 249.000000 "$node_(8) setdest 153.637467 522.766334 11.951358" -$ns_ at 249.000000 "$node_(9) setdest 90.366944 444.196722 18.484999" -$ns_ at 249.000000 "$node_(10) setdest 152.055411 354.274810 1.647062" - -$ns_ at 250.000000 "$node_(1) setdest 32.767440 547.185729 17.258045" -$ns_ at 250.000000 "$node_(2) setdest 42.327370 507.405581 13.061605" -$ns_ at 250.000000 "$node_(3) setdest 166.110136 361.566966 19.158010" -$ns_ at 250.000000 "$node_(4) setdest 171.517760 436.860424 11.611706" -$ns_ at 250.000000 "$node_(5) setdest 39.663162 444.108944 17.992445" -$ns_ at 250.000000 "$node_(6) setdest 82.640473 482.268268 19.985046" -$ns_ at 250.000000 "$node_(7) setdest 106.691634 395.709099 19.504889" -$ns_ at 250.000000 "$node_(8) setdest 156.539558 511.951326 11.197613" -$ns_ at 250.000000 "$node_(9) setdest 102.661633 459.753615 19.828673" -$ns_ at 250.000000 "$node_(10) setdest 155.016298 355.644768 3.262459" - diff --git a/gui/configs/sample5-mgen.imn b/gui/configs/sample5-mgen.imn deleted file mode 100644 index d80a58a6..00000000 --- a/gui/configs/sample5-mgen.imn +++ /dev/null @@ -1,127 +0,0 @@ -node n1 { - type router - model router - network-config { - hostname n1 - ! - interface eth0 - ip address 10.0.0.2/24 - ipv6 address a:0::2/64 - ! - router ospf - router-id 10.0.0.2 - network 10.0.0.0/24 area 0 - ! - router ospf6 - router-id 10.0.0.2 - interface eth0 area 0.0.0.0 - ! - } - canvas c1 - iconcoords {312.0 120.0} - labelcoords {312.0 148.0} - interface-peer {eth0 n2} - custom-config { - custom-config-id service:UserDefined:mgen.sh - custom-command mgen.sh - config { - #!/bin/sh - SCRIPTDIR=$SESSION_DIR - LOGDIR=/var/log - if [ `uname` = "Linux" ]; then - cd $SCRIPTDIR - else - cd /tmp/e0_`hostname` - fi - ( - cat << 'EOF' - # mgen receiver script - 15.0 LISTEN UDP 5001 - EOF - ) > recv.mgn - mgen input recv.mgn output $LOGDIR/mgen.log > /dev/null 2> /dev/null < /dev/null & - } - } - custom-config { - custom-config-id service:UserDefined - custom-command UserDefined - config { - files=('mgen.sh', ) - startidx=35 - cmdup=('sh mgen.sh', ) - } - } - services {zebra OSPFv2 OSPFv3 IPForward UserDefined} -} - -node n2 { - type router - model router - network-config { - hostname n2 - ! - interface eth0 - ip address 10.0.0.1/24 - ipv6 address a:0::1/64 - ! - } - canvas c1 - iconcoords {72.0 48.0} - labelcoords {72.0 76.0} - interface-peer {eth0 n1} - custom-config { - custom-config-id service:UserDefined - custom-command UserDefined - config { - files=('mgen.sh', ) - startidx=35 - cmdup=('sh mgen.sh', ) - } - } - custom-config { - custom-config-id service:UserDefined:mgen.sh - custom-command mgen.sh - config { - #!/bin/sh - HN=`hostname` - SCRIPTDIR=$SESSION_DIR - LOGDIR=/var/log - - cd $SCRIPTDIR - ( - cat << 'EOF' - # mgen sender script: send UDP traffic to UDP port 5001 after 15 seconds - 15.0 ON 1 UDP SRC 5000 DST 10.0.0.2/5001 PERIODIC [1 4096] - EOF - ) > send_$HN.mgn - mgen input send_$HN.mgn output $LOGDIR/mgen_$HN.log > /dev/null 2> /dev/null < /dev/null & - } - } - services {zebra OSPFv2 OSPFv3 IPForward UserDefined} -} - -link l1 { - nodes {n2 n1} - bandwidth 0 -} - -canvas c1 { - name {Canvas1} -} - -option global { - interface_names no - ip_addresses yes - ipv6_addresses yes - node_labels yes - link_labels yes - show_api no - background_images no - annotations yes - grid yes - traffic_start 0 -} - -option session { -} - diff --git a/gui/configs/sample6-emane-rfpipe.imn b/gui/configs/sample6-emane-rfpipe.imn deleted file mode 100644 index 9e0cc045..00000000 --- a/gui/configs/sample6-emane-rfpipe.imn +++ /dev/null @@ -1,271 +0,0 @@ -node n1 { - type router - model mdr - network-config { - hostname n1 - ! - interface eth0 - ip address 10.0.0.1/32 - ipv6 address a:0::1/128 - ! - } - iconcoords {263.148836492 76.94184084899999} - labelcoords {263.148836492 100.94184084899999} - canvas c1 - interface-peer {eth0 n11} -} - -node n2 { - type router - model mdr - network-config { - hostname n2 - ! - interface eth0 - ip address 10.0.0.2/32 - ipv6 address a:0::2/128 - ! - } - iconcoords {184.35166313500002 532.524009667} - labelcoords {184.35166313500002 556.524009667} - canvas c1 - interface-peer {eth0 n11} -} - -node n3 { - type router - model mdr - network-config { - hostname n3 - ! - interface eth0 - ip address 10.0.0.3/32 - ipv6 address a:0::3/128 - ! - } - iconcoords {121.17243156500001 313.104176223} - labelcoords {121.17243156500001 337.104176223} - canvas c1 - interface-peer {eth0 n11} -} - -node n4 { - type router - model mdr - network-config { - hostname n4 - ! - interface eth0 - ip address 10.0.0.4/32 - ipv6 address a:0::4/128 - ! - } - iconcoords {443.031505695 586.805480735} - labelcoords {443.031505695 610.805480735} - canvas c1 - interface-peer {eth0 n11} -} - -node n5 { - type router - model mdr - network-config { - hostname n5 - ! - interface eth0 - ip address 10.0.0.5/32 - ipv6 address a:0::5/128 - ! - } - iconcoords {548.817758443 209.207353139} - labelcoords {548.817758443 233.207353139} - canvas c1 - interface-peer {eth0 n11} -} - -node n6 { - type router - model mdr - network-config { - hostname n6 - ! - interface eth0 - ip address 10.0.0.6/32 - ipv6 address a:0::6/128 - ! - } - iconcoords {757.062318769 61.533941783} - labelcoords {757.062318769 85.533941783} - canvas c1 - interface-peer {eth0 n11} -} - -node n7 { - type router - model mdr - network-config { - hostname n7 - ! - interface eth0 - ip address 10.0.0.7/32 - ipv6 address a:0::7/128 - ! - } - iconcoords {778.142667152 489.227596061} - labelcoords {778.142667152 513.227596061} - canvas c1 - interface-peer {eth0 n11} -} - -node n8 { - type router - model mdr - network-config { - hostname n8 - ! - interface eth0 - ip address 10.0.0.8/32 - ipv6 address a:0::8/128 - ! - } - iconcoords {93.895107521 135.228007484} - labelcoords {93.895107521 159.228007484} - canvas c1 - interface-peer {eth0 n11} -} - -node n9 { - type router - model mdr - network-config { - hostname n9 - ! - interface eth0 - ip address 10.0.0.9/32 - ipv6 address a:0::9/128 - ! - } - iconcoords {528.693178831 84.9814304098} - labelcoords {528.693178831 108.9814304098} - canvas c1 - interface-peer {eth0 n11} -} - -node n10 { - type router - model mdr - network-config { - hostname n10 - ! - interface eth0 - ip address 10.0.0.10/32 - ipv6 address a:0::10/128 - ! - } - iconcoords {569.534639911 475.46828902} - labelcoords {569.534639911 499.46828902} - canvas c1 - interface-peer {eth0 n11} -} - -node n11 { - bandwidth 54000000 - type wlan - range 275 - network-config { - hostname wlan11 - ! - interface wireless - ip address 10.0.0.0/32 - ipv6 address a:0::0/128 - ! - mobmodel - coreapi - emane_rfpipe - ! - } - canvas c1 - iconcoords {65.0 558.0} - labelcoords {65.0 582.0} - interface-peer {e0 n1} - interface-peer {e1 n2} - interface-peer {e2 n3} - interface-peer {e3 n4} - interface-peer {e4 n5} - interface-peer {e5 n6} - interface-peer {e6 n7} - interface-peer {e7 n8} - interface-peer {e8 n9} - interface-peer {e9 n10} -} - -link l1 { - nodes {n11 n1} - bandwidth 54000000 -} - -link l2 { - nodes {n11 n2} - bandwidth 54000000 -} - -link l3 { - nodes {n11 n3} - bandwidth 54000000 -} - -link l4 { - nodes {n11 n4} - bandwidth 54000000 -} - -link l5 { - nodes {n11 n5} - bandwidth 54000000 -} - -link l6 { - nodes {n11 n6} - bandwidth 54000000 -} - -link l7 { - nodes {n11 n7} - bandwidth 54000000 -} - -link l8 { - nodes {n11 n8} - bandwidth 54000000 -} - -link l9 { - nodes {n11 n9} - bandwidth 54000000 -} - -link l10 { - nodes {n11 n10} - bandwidth 54000000 -} - -canvas c1 { - name {Canvas1} -} - -option global { - interface_names no - ip_addresses yes - ipv6_addresses yes - node_labels yes - link_labels yes - ipsec_configs yes - remote_exec no - exec_errors yes - show_api no - background_images no - annotations yes - grid yes - traffic_start 0 -} - diff --git a/gui/configs/sample7-emane-ieee80211abg.imn b/gui/configs/sample7-emane-ieee80211abg.imn deleted file mode 100644 index b1323f6f..00000000 --- a/gui/configs/sample7-emane-ieee80211abg.imn +++ /dev/null @@ -1,274 +0,0 @@ -node n1 { - type router - model mdr - network-config { - hostname n1 - ! - interface eth0 - ip address 10.0.0.1/32 - ipv6 address a:0::1/128 - ! - } - iconcoords {115.14883649199999 139.941840849} - labelcoords {115.14883649199999 167.941840849} - canvas c1 - interface-peer {eth0 n11} -} - -node n2 { - type router - model mdr - network-config { - hostname n2 - ! - interface eth0 - ip address 10.0.0.2/32 - ipv6 address a:0::2/128 - ! - } - iconcoords {190.35166313500002 519.524009667} - labelcoords {190.35166313500002 547.524009667} - canvas c1 - interface-peer {eth0 n11} -} - -node n3 { - type router - model mdr - network-config { - hostname n3 - ! - interface eth0 - ip address 10.0.0.3/32 - ipv6 address a:0::3/128 - ! - } - iconcoords {142.172431565 307.104176223} - labelcoords {142.172431565 335.104176223} - canvas c1 - interface-peer {eth0 n11} -} - -node n4 { - type router - model mdr - network-config { - hostname n4 - ! - interface eth0 - ip address 10.0.0.4/32 - ipv6 address a:0::4/128 - ! - } - iconcoords {395.031505695 589.805480735} - labelcoords {395.031505695 617.805480735} - canvas c1 - interface-peer {eth0 n11} -} - -node n5 { - type router - model mdr - network-config { - hostname n5 - ! - interface eth0 - ip address 10.0.0.5/32 - ipv6 address a:0::5/128 - ! - } - iconcoords {250.817758443 27.20735313899999} - labelcoords {250.817758443 55.20735313899999} - canvas c1 - interface-peer {eth0 n11} -} - -node n6 { - type router - model mdr - network-config { - hostname n6 - ! - interface eth0 - ip address 10.0.0.6/32 - ipv6 address a:0::6/128 - ! - } - iconcoords {757.062318769 61.533941783} - labelcoords {757.062318769 89.533941783} - canvas c1 - interface-peer {eth0 n11} -} - -node n7 { - type router - model mdr - network-config { - hostname n7 - ! - interface eth0 - ip address 10.0.0.7/32 - ipv6 address a:0::7/128 - ! - } - iconcoords {909.142667152 593.227596061} - labelcoords {909.142667152 621.227596061} - canvas c1 - interface-peer {eth0 n11} -} - -node n8 { - type router - model mdr - network-config { - hostname n8 - ! - interface eth0 - ip address 10.0.0.8/32 - ipv6 address a:0::8/128 - ! - } - iconcoords {351.895107521 337.228007484} - labelcoords {351.895107521 365.228007484} - canvas c1 - interface-peer {eth0 n11} -} - -node n9 { - type router - model mdr - network-config { - hostname n9 - ! - interface eth0 - ip address 10.0.0.9/32 - ipv6 address a:0::9/128 - ! - } - iconcoords {528.693178831 84.9814304098} - labelcoords {528.693178831 112.98143041} - canvas c1 - interface-peer {eth0 n11} -} - -node n10 { - type router - model mdr - network-config { - hostname n10 - ! - interface eth0 - ip address 10.0.0.10/32 - ipv6 address a:0::10/128 - ! - } - iconcoords {568.534639911 526.4682890199999} - labelcoords {568.534639911 554.4682890199999} - canvas c1 - interface-peer {eth0 n11} -} - -node n11 { - bandwidth 54000000 - type wlan - range 275 - network-config { - hostname wlan11 - ! - interface wireless - ip address 10.0.0.0/32 - ipv6 address a:0::0/128 - ! - mobmodel - coreapi - emane_ieee80211abg - ! - } - canvas c1 - iconcoords {65.0 558.0} - labelcoords {65.0 590.0} - interface-peer {e0 n1} - interface-peer {e1 n2} - interface-peer {e2 n3} - interface-peer {e3 n4} - interface-peer {e4 n5} - interface-peer {e5 n6} - interface-peer {e6 n7} - interface-peer {e7 n8} - interface-peer {e8 n9} - interface-peer {e9 n10} -} - -link l1 { - nodes {n11 n1} - bandwidth 54000000 -} - -link l2 { - nodes {n11 n2} - bandwidth 54000000 -} - -link l3 { - nodes {n11 n3} - bandwidth 54000000 -} - -link l4 { - nodes {n11 n4} - bandwidth 54000000 -} - -link l5 { - nodes {n11 n5} - bandwidth 54000000 -} - -link l6 { - nodes {n11 n6} - bandwidth 54000000 -} - -link l7 { - nodes {n11 n7} - bandwidth 54000000 -} - -link l8 { - nodes {n11 n8} - bandwidth 54000000 -} - -link l9 { - nodes {n11 n9} - bandwidth 54000000 -} - -link l10 { - nodes {n11 n10} - bandwidth 54000000 -} - -canvas c1 { - name {Canvas1} - refpt {0 0 47.5791667 -122.132322 2.0} - scale 350.0 - size {1000 750} -} - -option global { - interface_names no - ip_addresses yes - ipv6_addresses yes - node_labels yes - link_labels yes - ipsec_configs yes - remote_exec no - exec_errors yes - show_api no - background_images no - annotations yes - grid yes - traffic_start 0 -} - diff --git a/gui/configs/sample8-ipsec-service.imn b/gui/configs/sample8-ipsec-service.imn deleted file mode 100644 index fb82881f..00000000 --- a/gui/configs/sample8-ipsec-service.imn +++ /dev/null @@ -1,920 +0,0 @@ -comments { -Sample scenario showing IPsec service configuration. - -There are three red routers having the IPsec service enabled. The IPsec service -must be customized with the tunnel hosts (peers) and their keys, and the subnet -addresses that should be tunneled. - -For simplicity, the same keys and certificates are used in each of the three -IPsec gateways. These are written to node n1's configuration directory. Keys -can be generated using the openssl utility. - -Note that this scenario may require at patched kernel in order to work; see the -kernels subdirectory of the CORE source for kernel patches. - -The racoon keying daemon and setkey from the ipsec-tools package should also be -installed. -} - -node n1 { - type router - model router - network-config { - hostname n1 - ! - interface eth3 - ip address 192.168.6.1/24 - ipv6 address 2001:6::1/64 - ! - interface eth2 - ip address 192.168.5.1/24 - ipv6 address 2001:5::1/64 - ! - interface eth1 - ip address 192.168.1.1/24 - ipv6 address 2001:1::1/64 - ! - interface eth0 - ip address 192.168.0.1/24 - ipv6 address 2001:0::1/64 - ! - } - canvas c1 - iconcoords {210.0 172.0} - labelcoords {210.0 200.0} - interface-peer {eth0 n2} - interface-peer {eth1 n3} - interface-peer {eth2 n7} - interface-peer {eth3 n8} - custom-config { - custom-config-id service:IPsec:copycerts.sh - custom-command copycerts.sh - config { - #!/bin/sh - - FILES="test1.pem test1.key ca-cert.pem" - - mkdir -p /tmp/certs - - for f in $FILES; do - cp $f /tmp/certs - done - } - } - custom-config { - custom-config-id service:IPsec:ca-cert.pem - custom-command ca-cert.pem - config { - Certificate: - Data: - Version: 3 (0x2) - Serial Number: 16615976057451940887 (0xe697ce3064d18c17) - Signature Algorithm: sha1WithRSAEncryption - Issuer: C=US, ST=WA, O=CORE CA/emailAddress=root@localhost - Validity - Not Before: Sep 9 17:18:04 2013 GMT - Not After : Sep 7 17:18:04 2023 GMT - Subject: C=US, ST=WA, O=CORE CA/emailAddress=root@localhost - Subject Public Key Info: - Public Key Algorithm: rsaEncryption - Public-Key: (1024 bit) - Modulus: - 00:d3:0d:ab:91:72:50:ca:10:43:8d:18:d8:92:05: - 9d:d9:aa:16:2b:d1:25:f8:be:52:48:e4:e7:7a:83: - 9b:b4:3b:26:12:fa:46:23:df:09:cb:34:ba:6f:f6: - 5e:38:9c:d4:90:ea:44:ad:65:f6:bd:85:6f:ac:9f: - 4c:83:d4:10:ab:0a:0e:cd:ba:99:1a:ae:f7:b7:e2: - c3:00:0b:c1:02:69:16:c7:55:e3:cf:4c:c3:72:77: - 10:be:da:66:ce:91:b2:cc:92:e1:a8:f0:74:fe:b9: - 03:38:fc:49:97:73:bb:40:55:1b:7d:3e:41:63:02: - b5:ad:f4:33:95:76:fd:7b:61 - Exponent: 65537 (0x10001) - X509v3 extensions: - X509v3 Subject Key Identifier: - 9A:EF:A7:36:28:06:4A:0A:2F:F9:2E:99:BE:6F:06:E1:83:9C:A2:0E - X509v3 Authority Key Identifier: - keyid:9A:EF:A7:36:28:06:4A:0A:2F:F9:2E:99:BE:6F:06:E1:83:9C:A2:0E - - X509v3 Basic Constraints: - CA:TRUE - Signature Algorithm: sha1WithRSAEncryption - 2d:88:84:20:19:9b:97:90:2d:18:86:7d:db:6c:d0:5e:ae:c2: - 55:61:af:ca:86:5b:3b:e8:15:c5:31:de:ea:d3:7e:9e:39:61: - 2e:b4:a0:93:43:bf:a2:95:f8:b6:13:b3:2f:cb:f8:fb:72:8c: - 40:95:50:db:03:cc:f7:b8:a5:d8:fb:77:88:c4:f5:f9:65:85: - 29:c8:0c:e9:ce:c9:fa:1d:4e:b2:3f:92:dc:b5:2e:73:50:c3: - c8:3e:90:9e:9a:34:ef:fd:ed:de:74:0b:19:73:6a:95:de:90: - 3b:ee:db:b0:be:14:fd:bf:3e:c6:7b:cd:7d:3c:ba:45:3c:f1: - 46:d7 - -----BEGIN CERTIFICATE----- - MIICZDCCAc2gAwIBAgIJAOaXzjBk0YwXMA0GCSqGSIb3DQEBBQUAMEsxCzAJBgNV - BAYTAlVTMQswCQYDVQQIDAJXQTEQMA4GA1UECgwHQ09SRSBDQTEdMBsGCSqGSIb3 - DQEJARYOcm9vdEBsb2NhbGhvc3QwHhcNMTMwOTA5MTcxODA0WhcNMjMwOTA3MTcx - ODA0WjBLMQswCQYDVQQGEwJVUzELMAkGA1UECAwCV0ExEDAOBgNVBAoMB0NPUkUg - Q0ExHTAbBgkqhkiG9w0BCQEWDnJvb3RAbG9jYWxob3N0MIGfMA0GCSqGSIb3DQEB - AQUAA4GNADCBiQKBgQDTDauRclDKEEONGNiSBZ3ZqhYr0SX4vlJI5Od6g5u0OyYS - +kYj3wnLNLpv9l44nNSQ6kStZfa9hW+sn0yD1BCrCg7Nupkarve34sMAC8ECaRbH - VePPTMNydxC+2mbOkbLMkuGo8HT+uQM4/EmXc7tAVRt9PkFjArWt9DOVdv17YQID - AQABo1AwTjAdBgNVHQ4EFgQUmu+nNigGSgov+S6Zvm8G4YOcog4wHwYDVR0jBBgw - FoAUmu+nNigGSgov+S6Zvm8G4YOcog4wDAYDVR0TBAUwAwEB/zANBgkqhkiG9w0B - AQUFAAOBgQAtiIQgGZuXkC0Yhn3bbNBersJVYa/Khls76BXFMd7q036eOWEutKCT - Q7+ilfi2E7Mvy/j7coxAlVDbA8z3uKXY+3eIxPX5ZYUpyAzpzsn6HU6yP5LctS5z - UMPIPpCemjTv/e3edAsZc2qV3pA77tuwvhT9vz7Ge819PLpFPPFG1w== - -----END CERTIFICATE----- - - } - } - custom-config { - custom-config-id service:IPsec:test1.pem - custom-command test1.pem - config { - Certificate: - Data: - Version: 3 (0x2) - Serial Number: 16098433458223693585 (0xdf691fefe5afbf11) - Signature Algorithm: sha1WithRSAEncryption - Issuer: C=US, ST=WA, O=CORE CA/emailAddress=root@localhost - Validity - Not Before: Sep 9 17:44:47 2013 GMT - Not After : Sep 7 17:44:47 2023 GMT - Subject: C=US, ST=WA, O=core-dev, CN=test1 - Subject Public Key Info: - Public Key Algorithm: rsaEncryption - Public-Key: (1024 bit) - Modulus: - 00:b3:26:ed:b6:eb:26:ea:c0:5a:d1:09:6f:d4:5f: - 8d:11:cc:3c:ff:d7:5e:37:e6:55:71:5c:eb:c9:e8: - f8:8e:a3:85:99:2c:3e:a2:8e:b2:1c:2f:fe:99:c6: - 0d:d3:ce:c0:ed:c1:e2:4d:bc:10:35:f6:61:02:b9: - 8f:cc:c5:80:d1:7f:c8:2e:2d:9a:32:9f:8a:bb:32: - ea:14:82:e0:6f:cb:3d:9d:d5:1c:f1:43:52:9f:49: - 79:f1:94:03:48:2c:91:51:c7:8f:32:90:a7:c2:c0: - 25:64:34:f1:c7:f2:ac:d5:96:87:a2:0a:fb:e5:b3: - 0b:90:bf:6f:08:75:5d:54:cb - Exponent: 65537 (0x10001) - X509v3 extensions: - X509v3 Basic Constraints: - CA:FALSE - Netscape Comment: - OpenSSL Generated Certificate - X509v3 Subject Key Identifier: - B3:EC:1A:56:77:F9:DC:0E:60:0F:B7:69:C9:DC:43:2D:09:39:A6:1C - X509v3 Authority Key Identifier: - keyid:9A:EF:A7:36:28:06:4A:0A:2F:F9:2E:99:BE:6F:06:E1:83:9C:A2:0E - - Signature Algorithm: sha1WithRSAEncryption - c5:3f:65:1f:b6:a4:33:fd:c8:04:a1:da:07:f6:e0:3b:55:b9: - 76:b7:aa:78:55:4a:59:ad:36:7f:cb:00:1c:32:cb:fe:40:72: - eb:49:27:b4:9d:5d:05:6f:30:37:1d:49:35:5e:0b:6b:5d:c5: - 07:3d:c8:63:1f:b6:46:6d:f9:c9:52:ce:1d:1f:d9:e8:02:46: - 95:18:26:39:ec:17:fe:ae:07:cf:55:25:45:1f:8a:e4:bb:f2: - 73:d2:e1:01:c3:8e:5f:eb:e4:7e:80:44:40:e6:a1:cd:85:9b: - e8:fb:16:d0:7b:4f:ad:3b:4c:eb:bd:67:02:2c:08:2b:62:f1: - c5:0a - -----BEGIN CERTIFICATE----- - MIICgTCCAeqgAwIBAgIJAN9pH+/lr78RMA0GCSqGSIb3DQEBBQUAMEsxCzAJBgNV - BAYTAlVTMQswCQYDVQQIDAJXQTEQMA4GA1UECgwHQ09SRSBDQTEdMBsGCSqGSIb3 - DQEJARYOcm9vdEBsb2NhbGhvc3QwHhcNMTMwOTA5MTc0NDQ3WhcNMjMwOTA3MTc0 - NDQ3WjA9MQswCQYDVQQGEwJVUzELMAkGA1UECAwCV0ExETAPBgNVBAoMCGNvcmUt - ZGV2MQ4wDAYDVQQDDAV0ZXN0MTCBnzANBgkqhkiG9w0BAQEFAAOBjQAwgYkCgYEA - sybttusm6sBa0Qlv1F+NEcw8/9deN+ZVcVzryej4jqOFmSw+oo6yHC/+mcYN087A - 7cHiTbwQNfZhArmPzMWA0X/ILi2aMp+KuzLqFILgb8s9ndUc8UNSn0l58ZQDSCyR - UcePMpCnwsAlZDTxx/Ks1ZaHogr75bMLkL9vCHVdVMsCAwEAAaN7MHkwCQYDVR0T - BAIwADAsBglghkgBhvhCAQ0EHxYdT3BlblNTTCBHZW5lcmF0ZWQgQ2VydGlmaWNh - dGUwHQYDVR0OBBYEFLPsGlZ3+dwOYA+3acncQy0JOaYcMB8GA1UdIwQYMBaAFJrv - pzYoBkoKL/kumb5vBuGDnKIOMA0GCSqGSIb3DQEBBQUAA4GBAMU/ZR+2pDP9yASh - 2gf24DtVuXa3qnhVSlmtNn/LABwyy/5AcutJJ7SdXQVvMDcdSTVeC2tdxQc9yGMf - tkZt+clSzh0f2egCRpUYJjnsF/6uB89VJUUfiuS78nPS4QHDjl/r5H6AREDmoc2F - m+j7FtB7T607TOu9ZwIsCCti8cUK - -----END CERTIFICATE----- - - } - } - custom-config { - custom-config-id service:IPsec:test1.key - custom-command test1.key - config { - -----BEGIN PRIVATE KEY----- - MIICdgIBADANBgkqhkiG9w0BAQEFAASCAmAwggJcAgEAAoGBALMm7bbrJurAWtEJ - b9RfjRHMPP/XXjfmVXFc68no+I6jhZksPqKOshwv/pnGDdPOwO3B4k28EDX2YQK5 - j8zFgNF/yC4tmjKfirsy6hSC4G/LPZ3VHPFDUp9JefGUA0gskVHHjzKQp8LAJWQ0 - 8cfyrNWWh6IK++WzC5C/bwh1XVTLAgMBAAECgYB1zJIgZe04DPVqYC8lURL8cfRm - MeIlFZJ3MSdlo4fUmtddCYfB8dxRxok96cnrzRZ0/7jjblamdPQDC6rvdaqmfLFx - nJ/RVhCj6HqDMrQnv/9tnl6UQmkaYSnYvTn2GgmpqvBf9RUQk4+kjwgRgdqKxaIz - oH8j0ZxMh2DOZuzJMQJBAOJwEnbG085q2k1Qg8PQz0cpVG9QCE3sJUNs0hMPC7dk - IzknFtidlpCf6NMboJ2Nt9dzmJmKLqWb3oauyQRQA6MCQQDKin0wElLV1268IbcF - RXhkVlxcg5fDEazeNL9p1z5vmwaq0IcLtSPrIaect2hacCkfJoREhcA+f9YIpcod - lby5AkEApyXla0ofpXqYxIOPkGc96qCmlDh2uNZ9N0VH2Qu9MVW47oJdSe8h6oYv - /k2hhUvMjjzlQ0mOX28slyzEc+uAkwJAWlAsiE3zX+UjPIJwIMqcZ2lW3+3Rsyrj - gWXV4HUZIxzmeS5ouWC5NnSYT7o8ru8KdxhurDtTwMqx/sMmf9CwCQJAIDbMwwIs - XStw0y/M9+hdPUkccVoHyXKPTensyX/miAUwHZN/oadGUUOZO7XBKb1uNFv1uowU - 29bGgXa+mvb6aA== - -----END PRIVATE KEY----- - - } - } - custom-config { - custom-config-id service:IPsec:ipsec.sh - custom-command ipsec.sh - config { - #!/bin/sh - # set up static tunnel mode security assocation for service (security.py) - # -------- CUSTOMIZATION REQUIRED -------- - # - # The IPsec service builds ESP tunnels between the specified peers using the - # racoon IKEv2 keying daemon. You need to provide keys and the addresses of - # peers, along with subnets to tunnel. - - # directory containing the certificate and key described below - keydir=/tmp/certs - - # the name used for the "$certname.pem" x509 certificate and - # "$certname.key" RSA private key, which can be generated using openssl - certname=test1 - - # list the public-facing IP addresses, starting with the localhost and followed - # by each tunnel peer, separated with a single space - tunnelhosts="192.168.0.1AND192.168.0.2 192.168.1.1AND192.168.1.2" - - # Define T where i is the index for each tunnel peer host from - # the tunnel_hosts list above (0 is localhost). - # T is a list of IPsec tunnels with peer i, with a local subnet address - # followed by the remote subnet address: - # T="AND AND" - # For example, 192.168.0.0/24 is a local network (behind this node) to be - # tunneled and 192.168.2.0/24 is a remote network (behind peer 1) - T1="192.168.5.0/24AND192.168.8.0/24" - T2="192.168.5.0/24AND192.168.4.0/24 192.168.6.0/24AND192.168.4.0/24" - - # -------- END CUSTOMIZATION -------- - - echo "building config $PWD/ipsec.conf..." - echo "building config $PWD/ipsec.conf..." > $PWD/ipsec.log - - checkip=0 - if [ "$(dpkg -l | grep " sipcalc ")" = "" ]; then - echo "WARNING: ip validation disabled because package sipcalc not installed - " >> $PWD/ipsec.log - checkip=1 - fi - - echo "#!/usr/sbin/setkey -f - # Flush the SAD and SPD - flush; - spdflush; - - # Security policies \ - " > $PWD/ipsec.conf - i=0 - for hostpair in $tunnelhosts; do - i=`expr $i + 1` - # parse tunnel host IP - thishost=${hostpair%%AND*} - peerhost=${hostpair##*AND} - if [ $checkip = "0" ] && - [ "$(sipcalc "$thishost" "$peerhost" | grep ERR)" != "" ]; then - echo "ERROR: invalid host address $thishost or $peerhost \ - " >> $PWD/ipsec.log - fi - # parse each tunnel addresses - tunnel_list_var_name=T$i - eval tunnels="$"$tunnel_list_var_name"" - for ttunnel in $tunnels; do - lclnet=${ttunnel%%AND*} - rmtnet=${ttunnel##*AND} - if [ $checkip = "0" ] && - [ "$(sipcalc "$lclnet" "$rmtnet"| grep ERR)" != "" ]; then - echo "ERROR: invalid tunnel address $lclnet and $rmtnet \ - " >> $PWD/ipsec.log - fi - # add tunnel policies - echo " - spdadd $lclnet $rmtnet any -P out ipsec - esp/tunnel/$thishost-$peerhost/require; - spdadd $rmtnet $lclnet any -P in ipsec - esp/tunnel/$peerhost-$thishost/require; \ - " >> $PWD/ipsec.conf - done - done - - echo "building config $PWD/racoon.conf..." - if [ ! -e $keydir\/$certname.key ] || [ ! -e $keydir\/$certname.pem ]; then - echo "ERROR: missing certification files under $keydir \ - $certname.key or $certname.pem " >> $PWD/ipsec.log - fi - echo " - path certificate \"$keydir\"; - listen { - adminsock disabled; - } - remote anonymous - { - exchange_mode main; - certificate_type x509 \"$certname.pem\" \"$certname.key\"; - ca_type x509 \"ca-cert.pem\"; - my_identifier asn1dn; - peers_identifier asn1dn; - - proposal { - encryption_algorithm 3des ; - hash_algorithm sha1; - authentication_method rsasig ; - dh_group modp768; - } - } - sainfo anonymous - { - pfs_group modp768; - lifetime time 1 hour ; - encryption_algorithm 3des, blowfish 448, rijndael ; - authentication_algorithm hmac_sha1, hmac_md5 ; - compression_algorithm deflate ; - } - " > $PWD/racoon.conf - - # the setkey program is required from the ipsec-tools package - echo "running setkey -f $PWD/ipsec.conf..." - setkey -f $PWD/ipsec.conf - - echo "running racoon -d -f $PWD/racoon.conf..." - racoon -d -f $PWD/racoon.conf -l racoon.log - - } - } - custom-config { - custom-config-id service:IPsec - custom-command IPsec - config { - files=('ipsec.sh', 'test1.key', 'test1.pem', 'ca-cert.pem', 'copycerts.sh', ) - } - } - services {zebra OSPFv2 OSPFv3 IPForward IPsec} - custom-image $CORE_DATA_DIR/icons/normal/router_red.gif -} - -node n2 { - type router - model router - network-config { - hostname n2 - ! - interface eth3 - ip address 192.168.8.1/24 - ipv6 address 2001:8::1/64 - ! - interface eth2 - ip address 192.168.7.1/24 - ipv6 address 2001:7::1/64 - ! - interface eth1 - ip address 192.168.2.1/24 - ipv6 address 2001:2::1/64 - ! - interface eth0 - ip address 192.168.0.2/24 - ipv6 address 2001:0::2/64 - ! - } - canvas c1 - iconcoords {455.0 173.0} - labelcoords {455.0 201.0} - interface-peer {eth0 n1} - interface-peer {eth1 n4} - interface-peer {eth2 n9} - interface-peer {eth3 n10} - custom-config { - custom-config-id service:IPsec:ipsec.sh - custom-command ipsec.sh - config { - #!/bin/sh - # set up static tunnel mode security assocation for service (security.py) - # -------- CUSTOMIZATION REQUIRED -------- - # - # The IPsec service builds ESP tunnels between the specified peers using the - # racoon IKEv2 keying daemon. You need to provide keys and the addresses of - # peers, along with subnets to tunnel. - - # directory containing the certificate and key described below - keydir=/tmp/certs - - # the name used for the "$certname.pem" x509 certificate and - # "$certname.key" RSA private key, which can be generated using openssl - certname=test1 - - # list the public-facing IP addresses, starting with the localhost and followed - # by each tunnel peer, separated with a single space - tunnelhosts="192.168.0.2AND192.168.0.1" - - # Define T where i is the index for each tunnel peer host from - # the tunnel_hosts list above (0 is localhost). - # T is a list of IPsec tunnels with peer i, with a local subnet address - # followed by the remote subnet address: - # T="AND AND" - # For example, 192.168.0.0/24 is a local network (behind this node) to be - # tunneled and 192.168.2.0/24 is a remote network (behind peer 1) - T1="192.168.8.0/24AND192.168.5.0/24" - - # -------- END CUSTOMIZATION -------- - - echo "building config $PWD/ipsec.conf..." - echo "building config $PWD/ipsec.conf..." > $PWD/ipsec.log - - checkip=0 - if [ "$(dpkg -l | grep " sipcalc ")" = "" ]; then - echo "WARNING: ip validation disabled because package sipcalc not installed - " >> $PWD/ipsec.log - checkip=1 - fi - - echo "#!/usr/sbin/setkey -f - # Flush the SAD and SPD - flush; - spdflush; - - # Security policies \ - " > $PWD/ipsec.conf - i=0 - for hostpair in $tunnelhosts; do - i=`expr $i + 1` - # parse tunnel host IP - thishost=${hostpair%%AND*} - peerhost=${hostpair##*AND} - if [ $checkip = "0" ] && - [ "$(sipcalc "$thishost" "$peerhost" | grep ERR)" != "" ]; then - echo "ERROR: invalid host address $thishost or $peerhost \ - " >> $PWD/ipsec.log - fi - # parse each tunnel addresses - tunnel_list_var_name=T$i - eval tunnels="$"$tunnel_list_var_name"" - for ttunnel in $tunnels; do - lclnet=${ttunnel%%AND*} - rmtnet=${ttunnel##*AND} - if [ $checkip = "0" ] && - [ "$(sipcalc "$lclnet" "$rmtnet"| grep ERR)" != "" ]; then - echo "ERROR: invalid tunnel address $lclnet and $rmtnet \ - " >> $PWD/ipsec.log - fi - # add tunnel policies - echo " - spdadd $lclnet $rmtnet any -P out ipsec - esp/tunnel/$thishost-$peerhost/require; - spdadd $rmtnet $lclnet any -P in ipsec - esp/tunnel/$peerhost-$thishost/require; \ - " >> $PWD/ipsec.conf - done - done - - echo "building config $PWD/racoon.conf..." - if [ ! -e $keydir\/$certname.key ] || [ ! -e $keydir\/$certname.pem ]; then - echo "ERROR: missing certification files under $keydir \ - $certname.key or $certname.pem " >> $PWD/ipsec.log - fi - echo " - path certificate \"$keydir\"; - listen { - adminsock disabled; - } - remote anonymous - { - exchange_mode main; - certificate_type x509 \"$certname.pem\" \"$certname.key\"; - ca_type x509 \"ca-cert.pem\"; - my_identifier asn1dn; - peers_identifier asn1dn; - - proposal { - encryption_algorithm 3des ; - hash_algorithm sha1; - authentication_method rsasig ; - dh_group modp768; - } - } - sainfo anonymous - { - pfs_group modp768; - lifetime time 1 hour ; - encryption_algorithm 3des, blowfish 448, rijndael ; - authentication_algorithm hmac_sha1, hmac_md5 ; - compression_algorithm deflate ; - } - " > $PWD/racoon.conf - - # the setkey program is required from the ipsec-tools package - echo "running setkey -f $PWD/ipsec.conf..." - setkey -f $PWD/ipsec.conf - - echo "running racoon -d -f $PWD/racoon.conf..." - racoon -d -f $PWD/racoon.conf -l racoon.log - - } - } - services {zebra OSPFv2 OSPFv3 IPForward IPsec} - custom-image $CORE_DATA_DIR/icons/normal/router_red.gif -} - -node n3 { - type router - model router - network-config { - hostname n3 - ! - interface eth2 - ip address 192.168.4.1/24 - ipv6 address 2001:4::1/64 - ! - interface eth1 - ip address 192.168.3.1/24 - ipv6 address 2001:3::1/64 - ! - interface eth0 - ip address 192.168.1.2/24 - ipv6 address 2001:1::2/64 - ! - } - canvas c1 - iconcoords {211.0 375.0} - labelcoords {211.0 403.0} - interface-peer {eth0 n1} - interface-peer {eth1 n5} - interface-peer {eth2 n6} - custom-config { - custom-config-id service:IPsec:ipsec.sh - custom-command ipsec.sh - config { - #!/bin/sh - # set up static tunnel mode security assocation for service (security.py) - # -------- CUSTOMIZATION REQUIRED -------- - # - # The IPsec service builds ESP tunnels between the specified peers using the - # racoon IKEv2 keying daemon. You need to provide keys and the addresses of - # peers, along with subnets to tunnel. - - # directory containing the certificate and key described below - keydir=/tmp/certs - - # the name used for the "$certname.pem" x509 certificate and - # "$certname.key" RSA private key, which can be generated using openssl - certname=test1 - - # list the public-facing IP addresses, starting with the localhost and followed - # by each tunnel peer, separated with a single space - tunnelhosts="192.168.1.2AND192.168.1.1" - - # Define T where i is the index for each tunnel peer host from - # the tunnel_hosts list above (0 is localhost). - # T is a list of IPsec tunnels with peer i, with a local subnet address - # followed by the remote subnet address: - # T="AND AND" - # For example, 192.168.0.0/24 is a local network (behind this node) to be - # tunneled and 192.168.2.0/24 is a remote network (behind peer 1) - T1="192.168.4.0/24AND192.168.5.0/24 192.168.4.0/24AND192.168.6.0/24" - - # -------- END CUSTOMIZATION -------- - - echo "building config $PWD/ipsec.conf..." - echo "building config $PWD/ipsec.conf..." > $PWD/ipsec.log - - checkip=0 - if [ "$(dpkg -l | grep " sipcalc ")" = "" ]; then - echo "WARNING: ip validation disabled because package sipcalc not installed - " >> $PWD/ipsec.log - checkip=1 - fi - - echo "#!/usr/sbin/setkey -f - # Flush the SAD and SPD - flush; - spdflush; - - # Security policies \ - " > $PWD/ipsec.conf - i=0 - for hostpair in $tunnelhosts; do - i=`expr $i + 1` - # parse tunnel host IP - thishost=${hostpair%%AND*} - peerhost=${hostpair##*AND} - if [ $checkip = "0" ] && - [ "$(sipcalc "$thishost" "$peerhost" | grep ERR)" != "" ]; then - echo "ERROR: invalid host address $thishost or $peerhost \ - " >> $PWD/ipsec.log - fi - # parse each tunnel addresses - tunnel_list_var_name=T$i - eval tunnels="$"$tunnel_list_var_name"" - for ttunnel in $tunnels; do - lclnet=${ttunnel%%AND*} - rmtnet=${ttunnel##*AND} - if [ $checkip = "0" ] && - [ "$(sipcalc "$lclnet" "$rmtnet"| grep ERR)" != "" ]; then - echo "ERROR: invalid tunnel address $lclnet and $rmtnet \ - " >> $PWD/ipsec.log - fi - # add tunnel policies - echo " - spdadd $lclnet $rmtnet any -P out ipsec - esp/tunnel/$thishost-$peerhost/require; - spdadd $rmtnet $lclnet any -P in ipsec - esp/tunnel/$peerhost-$thishost/require; \ - " >> $PWD/ipsec.conf - done - done - - echo "building config $PWD/racoon.conf..." - if [ ! -e $keydir\/$certname.key ] || [ ! -e $keydir\/$certname.pem ]; then - echo "ERROR: missing certification files under $keydir \ - $certname.key or $certname.pem " >> $PWD/ipsec.log - fi - echo " - path certificate \"$keydir\"; - listen { - adminsock disabled; - } - remote anonymous - { - exchange_mode main; - certificate_type x509 \"$certname.pem\" \"$certname.key\"; - ca_type x509 \"ca-cert.pem\"; - my_identifier asn1dn; - peers_identifier asn1dn; - - proposal { - encryption_algorithm 3des ; - hash_algorithm sha1; - authentication_method rsasig ; - dh_group modp768; - } - } - sainfo anonymous - { - pfs_group modp768; - lifetime time 1 hour ; - encryption_algorithm 3des, blowfish 448, rijndael ; - authentication_algorithm hmac_sha1, hmac_md5 ; - compression_algorithm deflate ; - } - " > $PWD/racoon.conf - - # the setkey program is required from the ipsec-tools package - echo "running setkey -f $PWD/ipsec.conf..." - setkey -f $PWD/ipsec.conf - - echo "running racoon -d -f $PWD/racoon.conf..." - racoon -d -f $PWD/racoon.conf -l racoon.log - - } - } - services {zebra OSPFv2 OSPFv3 IPForward IPsec} - custom-image $CORE_DATA_DIR/icons/normal/router_red.gif -} - -node n4 { - type router - model router - network-config { - hostname n4 - ! - interface eth1 - ip address 192.168.9.1/24 - ipv6 address 2001:9::1/64 - ! - interface eth0 - ip address 192.168.2.2/24 - ipv6 address 2001:2::2/64 - ! - } - canvas c1 - iconcoords {456.0 376.0} - labelcoords {456.0 404.0} - interface-peer {eth0 n2} - interface-peer {eth1 n11} -} - -node n5 { - type router - model host - network-config { - hostname n5 - ! - interface eth0 - ip address 192.168.3.10/24 - ipv6 address 2001:3::10/64 - ! - } - canvas c1 - iconcoords {50.0 472.0} - labelcoords {50.0 504.0} - interface-peer {eth0 n3} -} - -node n6 { - type router - model host - network-config { - hostname n6 - ! - interface eth0 - ip address 192.168.4.10/24 - ipv6 address 2001:4::10/64 - ! - } - canvas c1 - iconcoords {44.0 292.0} - labelcoords {44.0 324.0} - interface-peer {eth0 n3} -} - -node n7 { - type router - model host - network-config { - hostname n7 - ! - interface eth0 - ip address 192.168.5.10/24 - ipv6 address 2001:5::10/64 - ! - } - canvas c1 - iconcoords {41.0 62.0} - labelcoords {41.0 94.0} - interface-peer {eth0 n1} -} - -node n8 { - type router - model host - network-config { - hostname n8 - ! - interface eth0 - ip address 192.168.6.10/24 - ipv6 address 2001:6::10/64 - ! - } - canvas c1 - iconcoords {39.0 121.0} - labelcoords {39.0 153.0} - interface-peer {eth0 n1} -} - -node n9 { - type router - model host - network-config { - hostname n9 - ! - interface eth0 - ip address 192.168.7.10/24 - ipv6 address 2001:7::10/64 - ! - } - canvas c1 - iconcoords {653.0 69.0} - labelcoords {653.0 101.0} - interface-peer {eth0 n2} -} - -node n10 { - type router - model host - network-config { - hostname n10 - ! - interface eth0 - ip address 192.168.8.10/24 - ipv6 address 2001:8::10/64 - ! - } - canvas c1 - iconcoords {454.0 48.0} - labelcoords {484.0 59.0} - interface-peer {eth0 n2} -} - -node n11 { - type router - model host - network-config { - hostname n11 - ! - interface eth0 - ip address 192.168.9.10/24 - ipv6 address 2001:9::10/64 - ! - } - canvas c1 - iconcoords {654.0 460.0} - labelcoords {654.0 492.0} - interface-peer {eth0 n4} -} - -link l1 { - nodes {n1 n2} - bandwidth 0 -} - -link l2 { - nodes {n1 n3} - bandwidth 0 -} - -link l3 { - nodes {n2 n4} - bandwidth 0 -} - -link l4 { - nodes {n3 n5} - bandwidth 0 -} - -link l5 { - nodes {n3 n6} - bandwidth 0 -} - -link l6 { - nodes {n1 n7} - bandwidth 0 -} - -link l7 { - nodes {n1 n8} - bandwidth 0 -} - -link l8 { - nodes {n2 n9} - bandwidth 0 -} - -link l9 { - nodes {n2 n10} - bandwidth 0 -} - -link l10 { - nodes {n4 n11} - bandwidth 0 -} - -annotation a1 { - iconcoords {8.0 6.0 514.0 99.0} - type rectangle - label {Tunnel 1} - labelcolor black - fontfamily {Arial} - fontsize {12} - color #ffd0d0 - width 0 - border #00ff00 - rad 22 - canvas c1 -} - -annotation a2 { - iconcoords {8.0 6.0 137.0 334.0} - type rectangle - label {Tunnel 2} - labelcolor black - fontfamily {Arial} - fontsize {12} - color #ffe1e1 - width 0 - border black - rad 23 - canvas c1 -} - -annotation a5 { - iconcoords {263.0 127.0} - type text - label {} - labelcolor black - fontfamily {Arial} - fontsize {12} - effects {underline} - canvas c1 -} - -canvas c1 { - name {Canvas1} -} - -option global { - interface_names yes - ip_addresses yes - ipv6_addresses no - node_labels yes - link_labels yes - ipsec_configs yes - exec_errors yes - show_api no - background_images no - annotations yes - grid yes - traffic_start 0 -} - diff --git a/gui/configs/sample9-vpn.imn b/gui/configs/sample9-vpn.imn deleted file mode 100644 index 095c2db4..00000000 --- a/gui/configs/sample9-vpn.imn +++ /dev/null @@ -1,1015 +0,0 @@ -comments { -Sample scenario showing VPNClient and VPNServer service configuration. - -This topology features an OpenVPN client and server for virtual private -networking. The client can access the private 10.0.6.0/24 network via the VPN -server. First wait until routing converges in the center routers (try using the -Adjacency Widget and wait for blue lines, meaning full adjacencies), then open -a shell on the vpnclient and try pinging the private address of the vpnserver: - - vpnclient> ping 10.0.6.1 - -You can also access the other 10.0.6.* hosts behind the server. Try running -tcpudmp on one of the center routers, e.g. the n2 eth1/10.0.5.2 interface, and -you'll see UDP packets with TLS encrypted data instead of ICMP packets. - -Keys are included as extra files in the VPNClient and VPNServer service -configuration. -} - -node n1 { - type router - model router - network-config { - hostname n1 - ! - interface eth2 - ip address 10.0.4.2/24 - ipv6 address 2001:4::2/64 - ! - interface eth1 - ip address 10.0.2.1/24 - ipv6 address 2001:2::1/64 - ! - interface eth0 - ip address 10.0.0.1/24 - ipv6 address 2001:0::1/64 - ! - } - canvas c1 - iconcoords {297.0 236.0} - labelcoords {297.0 264.0} - interface-peer {eth0 n6} - interface-peer {eth1 n2} - interface-peer {eth2 n3} -} - -node n2 { - type router - model router - network-config { - hostname n2 - ! - interface eth1 - ip address 10.0.5.2/24 - ipv6 address 2001:5::2/64 - ! - interface eth0 - ip address 10.0.2.2/24 - ipv6 address 2001:2::2/64 - ! - } - canvas c1 - iconcoords {298.0 432.0} - labelcoords {298.0 460.0} - interface-peer {eth0 n1} - interface-peer {eth1 n4} -} - -node n3 { - type router - model router - network-config { - hostname n3 - ! - interface eth1 - ip address 10.0.4.1/24 - ipv6 address 2001:4::1/64 - ! - interface eth0 - ip address 10.0.3.1/24 - ipv6 address 2001:3::1/64 - ! - } - canvas c1 - iconcoords {573.0 233.0} - labelcoords {573.0 261.0} - interface-peer {eth0 n4} - interface-peer {eth1 n1} -} - -node n4 { - type router - model router - network-config { - hostname n4 - ! - interface eth2 - ip address 10.0.5.1/24 - ipv6 address 2001:5::1/64 - ! - interface eth1 - ip address 10.0.3.2/24 - ipv6 address 2001:3::2/64 - ! - interface eth0 - ip address 10.0.1.1/24 - ipv6 address 2001:1::1/64 - ! - } - canvas c1 - iconcoords {574.0 429.0} - labelcoords {574.0 457.0} - interface-peer {eth0 n5} - interface-peer {eth1 n3} - interface-peer {eth2 n2} -} - -node n5 { - type router - model host - network-config { - hostname vpnserver - ! - interface eth1 - ipv6 address 2001:6::10/64 - ip address 10.0.6.1/24 - ! - interface eth0 - ip address 10.0.1.10/24 - ipv6 address 2001:1::10/64 - ! - } - canvas c1 - iconcoords {726.0 511.0} - labelcoords {726.0 543.0} - interface-peer {eth0 n4} - interface-peer {eth1 n7} - custom-config { - custom-config-id service:VPNServer:vpnserver.pem - custom-command vpnserver.pem - config { - Certificate: - Data: - Version: 3 (0x2) - Serial Number: 1 (0x1) - Signature Algorithm: sha256WithRSAEncryption - Issuer: C=US, ST=WA, O=core-dev/emailAddress=root@localhost - Validity - Not Before: May 19 02:09:57 2015 GMT - Not After : Apr 25 02:09:57 2115 GMT - Subject: C=US, ST=WA, O=core-dev, CN=vpnserver/emailAddress=root@localhost - Subject Public Key Info: - Public Key Algorithm: rsaEncryption - Public-Key: (2048 bit) - Modulus: - 00:d2:88:b2:9b:32:ac:38:ca:45:e0:6b:db:1c:92: - 5d:9a:42:23:df:64:a0:3b:c2:c4:f2:3a:75:bb:d6: - 54:12:61:6e:aa:ac:0f:a6:2e:d9:3b:63:dc:3d:48: - 02:f1:36:c8:97:d3:ef:24:6f:7f:dd:b7:9a:9d:6d: - c1:c9:e2:11:49:1c:e0:67:d6:b0:b7:62:84:9a:f8: - c3:af:4f:f7:77:29:74:01:81:47:49:84:d6:1c:0c: - 36:41:42:a2:3e:92:28:83:50:7a:9c:fd:f3:66:7c: - f8:d9:c7:f6:63:d2:59:d2:fd:9a:a4:9b:75:a6:16: - ec:37:de:05:dd:05:a2:31:65:79:66:eb:b3:82:41: - af:b9:e8:4a:bc:02:d6:a1:68:49:6c:09:e1:c5:9f: - 3e:cf:52:76:d9:63:65:7a:a5:34:75:ee:ce:a3:c6: - 92:f3:0d:2f:7f:b0:b4:12:fe:44:5f:77:10:25:98: - b2:45:af:69:c8:9b:13:fc:f9:de:c6:be:b5:cf:62: - 06:01:32:71:d5:84:1d:14:b9:28:46:80:f6:98:35: - 12:e4:c8:e4:7a:94:e5:99:a3:6b:34:de:be:33:fe: - 63:21:a3:cc:c4:64:15:49:e0:9d:57:84:b9:11:e5: - 05:79:ba:22:6e:e4:24:b0:64:f0:54:13:1a:f4:73: - 8a:ff - Exponent: 65537 (0x10001) - X509v3 extensions: - X509v3 Basic Constraints: - CA:FALSE - Netscape Cert Type: - SSL Server - Netscape Comment: - OpenSSL Generated Server Certificate - X509v3 Subject Key Identifier: - A5:A6:80:4D:3C:CD:E2:FE:AD:32:FD:9D:B2:7C:B6:00:76:16:C0:41 - X509v3 Authority Key Identifier: - keyid:DB:D2:9C:8D:22:D9:D7:E2:38:A0:8D:6C:3B:BE:33:CE:8D:2A:BE:C8 - DirName:/C=US/ST=WA/O=core-dev/emailAddress=root@localhost - serial:CE:78:96:91:DB:9B:84:FD - - X509v3 Extended Key Usage: - TLS Web Server Authentication - X509v3 Key Usage: - Digital Signature, Key Encipherment - Signature Algorithm: sha256WithRSAEncryption - 3b:40:af:3a:c0:95:10:bc:d4:63:4a:1b:0f:9d:af:9c:27:29: - 34:c9:80:dc:c2:2d:72:40:0e:50:15:fe:b4:87:bc:59:56:de: - 81:96:1f:4f:ec:1a:44:ce:23:ba:69:b1:f5:ed:4b:1a:22:cf: - 16:17:29:f9:bb:69:12:3c:42:87:09:48:26:a2:b3:88:40:3e: - 3c:06:92:e1:65:6e:c0:62:50:55:08:5d:a0:4b:3a:0f:ff:9d: - 65:91:b9:bf:d3:69:b9:ac:27:83:2c:fd:5a:bd:58:d3:75:a0: - 70:e6:21:e9:f0:0d:19:a6:5f:2b:2d:1f:c9:fb:72:73:06:40: - 32:5a:f8:81:30:59:b7:cb:3a:a7:3e:6f:af:4c:4b:57:eb:4a: - d8:24:65:13:c3:86:fd:35:d3:6d:a0:3a:4b:63:40:9e:b4:98: - e0:a2:c7:f2:71:42:d5:08:72:95:fd:df:8f:05:e9:68:a8:f8: - 13:db:e6:0a:ec:c2:df:29:65:33:52:57:52:e5:7e:1d:09:2c: - 56:0b:cc:d3:2d:dd:46:72:f0:cb:8b:2d:53:c4:d3:9d:63:a6: - 6e:9f:dd:1a:7c:b2:87:d1:9e:4e:a0:b2:36:85:4a:5e:89:f9: - 01:82:94:3d:3a:86:17:84:48:d4:0c:c4:25:25:54:3f:d7:65: - 6b:85:c2:44:b3:6a:f5:74:69:f4:be:b2:13:68:a0:99:82:88: - 07:23:8e:a3:67:e0:88:07:fe:fd:ba:85:f8:8a:1f:ac:1e:7d: - ac:1e:f9:d1:3d:a8:fd:d9:91:9e:b2:3d:4f:f1:b4:80:9e:0b: - aa:bb:44:6a:20:08:68:a4:45:0e:21:21:4d:d1:5f:ab:a8:96: - 5a:29:e1:0f:9a:ff:a4:58:c6:80:15:51:98:ac:3c:23:4e:9e: - 8f:a2:34:c1:f6:4c:26:f0:33:8d:db:15:b9:30:03:a7:b3:17: - 31:9f:9a:5a:e7:a1:10:5e:61:57:04:bf:9a:6f:ec:87:15:4e: - 33:2a:0c:e4:4a:b0:66:ab:04:7a:32:4d:66:44:af:d9:ad:41: - a9:b1:05:c4:7d:2a:ba:2b:bb:c9:1e:5a:ff:cd:e0:e3:54:39: - b6:be:e2:70:6c:db:e6:71:dc:27:7e:ef:e9:11:1f:cb:fa:cd: - e1:57:a9:b9:ba:d6:69:fc:c0:d7:57:b0:51:4d:c4:2a:2f:1b: - 99:fc:b7:65:11:99:fe:0b:58:4e:11:aa:06:c6:e1:53:20:c7: - 56:0a:de:a6:65:c1:a6:41:e1:7b:1d:d7:17:45:b0:e4:66:50: - 26:d8:85:c3:c3:93:2d:df:b0:35:6d:29:9a:6b:cc:cc:75:de: - cf:72:37:8b:2d:24:b2:45 - -----BEGIN CERTIFICATE----- - MIIFQTCCAymgAwIBAgIBATANBgkqhkiG9w0BAQsFADBMMQswCQYDVQQGEwJVUzEL - MAkGA1UECBMCV0ExETAPBgNVBAoTCGNvcmUtZGV2MR0wGwYJKoZIhvcNAQkBFg5y - b290QGxvY2FsaG9zdDAgFw0xNTA1MTkwMjA5NTdaGA8yMTE1MDQyNTAyMDk1N1ow - YDELMAkGA1UEBhMCVVMxCzAJBgNVBAgTAldBMREwDwYDVQQKEwhjb3JlLWRldjES - MBAGA1UEAxMJdnBuc2VydmVyMR0wGwYJKoZIhvcNAQkBFg5yb290QGxvY2FsaG9z - dDCCASIwDQYJKoZIhvcNAQEBBQADggEPADCCAQoCggEBANKIspsyrDjKReBr2xyS - XZpCI99koDvCxPI6dbvWVBJhbqqsD6Yu2Ttj3D1IAvE2yJfT7yRvf923mp1twcni - EUkc4GfWsLdihJr4w69P93cpdAGBR0mE1hwMNkFCoj6SKINQepz982Z8+NnH9mPS - WdL9mqSbdaYW7DfeBd0FojFleWbrs4JBr7noSrwC1qFoSWwJ4cWfPs9SdtljZXql - NHXuzqPGkvMNL3+wtBL+RF93ECWYskWvacibE/z53sa+tc9iBgEycdWEHRS5KEaA - 9pg1EuTI5HqU5ZmjazTevjP+YyGjzMRkFUngnVeEuRHlBXm6Im7kJLBk8FQTGvRz - iv8CAwEAAaOCARYwggESMAkGA1UdEwQCMAAwEQYJYIZIAYb4QgEBBAQDAgZAMDMG - CWCGSAGG+EIBDQQmFiRPcGVuU1NMIEdlbmVyYXRlZCBTZXJ2ZXIgQ2VydGlmaWNh - dGUwHQYDVR0OBBYEFKWmgE08zeL+rTL9nbJ8tgB2FsBBMHwGA1UdIwR1MHOAFNvS - nI0i2dfiOKCNbDu+M86NKr7IoVCkTjBMMQswCQYDVQQGEwJVUzELMAkGA1UECBMC - V0ExETAPBgNVBAoTCGNvcmUtZGV2MR0wGwYJKoZIhvcNAQkBFg5yb290QGxvY2Fs - aG9zdIIJAM54lpHbm4T9MBMGA1UdJQQMMAoGCCsGAQUFBwMBMAsGA1UdDwQEAwIF - oDANBgkqhkiG9w0BAQsFAAOCAgEAO0CvOsCVELzUY0obD52vnCcpNMmA3MItckAO - UBX+tIe8WVbegZYfT+waRM4jummx9e1LGiLPFhcp+btpEjxChwlIJqKziEA+PAaS - 4WVuwGJQVQhdoEs6D/+dZZG5v9Npuawngyz9Wr1Y03WgcOYh6fANGaZfKy0fyfty - cwZAMlr4gTBZt8s6pz5vr0xLV+tK2CRlE8OG/TXTbaA6S2NAnrSY4KLH8nFC1Qhy - lf3fjwXpaKj4E9vmCuzC3yllM1JXUuV+HQksVgvM0y3dRnLwy4stU8TTnWOmbp/d - Gnyyh9GeTqCyNoVKXon5AYKUPTqGF4RI1AzEJSVUP9dla4XCRLNq9XRp9L6yE2ig - mYKIByOOo2fgiAf+/bqF+IofrB59rB750T2o/dmRnrI9T/G0gJ4LqrtEaiAIaKRF - DiEhTdFfq6iWWinhD5r/pFjGgBVRmKw8I06ej6I0wfZMJvAzjdsVuTADp7MXMZ+a - WuehEF5hVwS/mm/shxVOMyoM5EqwZqsEejJNZkSv2a1BqbEFxH0quiu7yR5a/83g - 41Q5tr7icGzb5nHcJ37v6REfy/rN4VepubrWafzA11ewUU3EKi8bmfy3ZRGZ/gtY - ThGqBsbhUyDHVgrepmXBpkHhex3XF0Ww5GZQJtiFw8OTLd+wNW0pmmvMzHXez3I3 - iy0kskU= - -----END CERTIFICATE----- - } - } - custom-config { - custom-config-id service:VPNServer:vpnserver.key - custom-command vpnserver.key - config { - -----BEGIN PRIVATE KEY----- - MIIEvwIBADANBgkqhkiG9w0BAQEFAASCBKkwggSlAgEAAoIBAQDSiLKbMqw4ykXg - a9sckl2aQiPfZKA7wsTyOnW71lQSYW6qrA+mLtk7Y9w9SALxNsiX0+8kb3/dt5qd - bcHJ4hFJHOBn1rC3YoSa+MOvT/d3KXQBgUdJhNYcDDZBQqI+kiiDUHqc/fNmfPjZ - x/Zj0lnS/Zqkm3WmFuw33gXdBaIxZXlm67OCQa+56Eq8AtahaElsCeHFnz7PUnbZ - Y2V6pTR17s6jxpLzDS9/sLQS/kRfdxAlmLJFr2nImxP8+d7GvrXPYgYBMnHVhB0U - uShGgPaYNRLkyOR6lOWZo2s03r4z/mMho8zEZBVJ4J1XhLkR5QV5uiJu5CSwZPBU - Exr0c4r/AgMBAAECggEATaktMUC09NHwisNedSCstI13TB2DWegT3EKiUWLTamBU - gVKtByE68sR4ZoacxzvtLMx555fVtATZXP8yv/TLaYvkX4l7cHo/7iabkJzP7T32 - U+PLVxxQGtKKZPJehPRHS4ExaZ3n3kN1TGiNw+7BQapZFCVgdZ75DfaxdQFx/gQD - 4htDr7SZL/jG1Sn08Cf7DRQ9U0rISecmm9nG9LV1LXMfnbdWTwvmm/z0a6wjDZ4n - Byfd5jOOI4cpgetHhAQCH+ksComY0GBf21MOsfQT/NzfuW/KFGag992Yub8tBUFa - AG+SlaNZBiLAPYfMegjCxR1jZeUCthlB2kdzYKcmyQKBgQD4lgbktGO/VKjnKnGD - SR8oJT82HvkfB16M/pSlTNOTmAAbbY9yMNj/zKPJDOhxHLhFxmXqVnvs70Ye+pfT - 3o3v0NkAfdIhzNzqbFlUA15QqELhrXHaTtpU3/nyw+/lQhoiEof9yj9vuGBy4iDf - GdP1R8G7OWqJIDXwZd3s99XujQKBgQDY0CPvCe1j43wfG8MjI/bLeDWmxjGaLWJu - IKbMepEbqcaz9x+25Ey3E35DYtfLjeAQ+qRc5T4Cj6L9iG/mS89/ShPGj91xyFzQ - qoZf4lGB0/A80aTgmDiF4FxHFzWpXKaJPS1gTfWZ9Qs7r0LP8Uwni9dhO8LGPNAr - 9Ky3jaHyuwKBgQDxml74yZpoyw+eHVJWFyuBCTJ2l4Po9HCg+I3gWtsICCOShNl2 - UqOVen91WGZSCWfP6RQEvimUDrpIQaZu9U9eVc2S/LbOwx2zebsYPG3eVqsqTDjr - xNfOxiFYIbd3Ste7ZedmcrtVCg4zmjP4olGvgx53qUYyIGxMSbV4KyhxwQKBgQCQ - ba7SSLGrrdl8O5k1Knr3tb8/tp1KUFtWc0fJxQgu/lzQe5nT0qdL+Z9NsmWAQqV1 - ihG9lDRHrnlsHNw19GBoMeeUiTeB2XACzOWwr+mN66oISbtkpeJZREkUTmC/zmld - 2LQGiEhIY9U00B5YuSv62AwEyLOKLO6bqWT47U9piwKBgQDm2+ufGU+ZBr0qpyCf - TiZFngJ1fGK0tyVrERm1y83vWzbqaW9nX5hJilqYDB3jpHARvbY56+jWVSm4ADwG - dlqEpmPHBgDRYBkdLUl50TN5vINcXQCGlA0zOHAueAUESyL5nLnO7NsK/McSRDd5 - XonR43XumudHzs3R6BwBTKv1gw== - -----END PRIVATE KEY----- - } - } - custom-config { - custom-config-id service:VPNServer:vpnserver.sh - custom-command vpnserver.sh - config { - #!/bin/sh - # custom VPN Server Configuration for service (security.py) - # -------- CUSTOMIZATION REQUIRED -------- - # - # The VPNServer service sets up the OpenVPN server for building VPN tunnels - # that allow access via TUN/TAP device to private networks. - # - # note that the IPForward and DefaultRoute services should be enabled - - # directory containing the certificate and key described below, in addition to - # a CA certificate and DH key - certdir=$SESSION_DIR/certs - keydir=$PWD - - # the name used for a "$keyname.pem" certificate and "$keyname.key" private key. - keyname=vpnserver - - # the VPN subnet address from which the client VPN IP (for the TUN/TAP) - # will be allocated - vpnsubnet=10.0.200.0 - - # public IP address of this vpn server (same as VPNClient vpnserver= setting) - vpnserver=10.0.1.10 - - # optional list of private subnets reachable behind this VPN server - # each subnet and next hop is separated by a space - # ", , ..." - privatenets="10.0.6.0,10.0.1.10" - - # optional list of VPN clients, for statically assigning IP addresses to - # clients; also, an optional client subnet can be specified for adding static - # routes via the client - # Note: VPN addresses x.x.x.0-3 are reserved - # ",, ,, ..." - #vpnclients="client1KeyFilename,10.0.200.5,10.0.0.0 client2KeyFilename,," - vpnclients="" - - # NOTE: you may need to enable the StaticRoutes service on nodes within the - # private subnet, in order to have routes back to the client. - # /sbin/ip ro add /24 via - # /sbin/ip ro add /24 via - - # -------- END CUSTOMIZATION -------- - - echo > $PWD/vpnserver.log - rm -f -r $PWD/ccd - - # validate key and certification files - check-key-file() { - if [ ! -e $1 ]; then - echo "ERROR: missing certification or key file: $1" >> $PWD/vpnserver.log - fi - } - - check-key-file $keydir/$keyname.key - check-key-file $keydir/$keyname.pem - check-key-file $certdir/ca-cert.pem - check-key-file $certdir/dh2048.pem - - # validate configuration IP addresses - checkip=0 - if [ "$(dpkg -l | grep sipcalc)" = "" ]; then - echo "WARNING: ip validation disabled because package sipcalc not installed\ - " >> $PWD/vpnserver.log - checkip=1 - else - if [ "$(sipcalc "$vpnsubnet" "$vpnserver" | grep ERR)" != "" ]; then - echo "ERROR: invalid vpn subnet or server address \ - $vpnsubnet or $vpnserver " >> $PWD/vpnserver.log - fi - fi - - # create client vpn ip pool file - ( - cat << EOF - EOF - )> $PWD/ippool.txt - - # create server.conf file - ( - cat << EOF - # openvpn server config - local $vpnserver - server $vpnsubnet 255.255.255.0 - push redirect-gateway def1 - EOF - )> $PWD/server.conf - - # add routes to VPN server private subnets, and push these routes to clients - for privatenet in $privatenets; do - if [ $privatenet != "" ]; then - net=${privatenet%%,*} - nexthop=${privatenet##*,} - if [ $checkip = "0" ] && - [ "$(sipcalc "$net" "$nexthop" | grep ERR)" != "" ]; then - echo "ERROR: invalid vpn server private net address \ - $net or $nexthop " >> $PWD/vpnserver.log - fi - echo push route $net 255.255.255.0 >> $PWD/server.conf - fi - done - - # allow subnet through this VPN, one route for each client subnet - for client in $vpnclients; do - if [ $client != "" ]; then - cSubnetIP=${client##*,} - cVpnIP=${client#*,} - cVpnIP=${cVpnIP%%,*} - cKeyFilename=${client%%,*} - if [ "$cSubnetIP" != "" ]; then - if [ $checkip = "0" ] && - [ "$(sipcalc "$cSubnetIP" "$cVpnIP" | grep ERR)" != "" ]; then - echo "ERROR: invalid vpn client and subnet address \ - $cSubnetIP or $cVpnIP " >> $PWD/vpnserver.log - fi - echo route $cSubnetIP 255.255.255.0 >> $PWD/server.conf - if ! test -d $PWD/ccd; then - mkdir -p $PWD/ccd - echo client-config-dir $PWD/ccd >> $PWD/server.conf - fi - if test -e $PWD/ccd/$cKeyFilename; then - echo iroute $cSubnetIP 255.255.255.0 >> $PWD/ccd/$cKeyFilename - else - echo iroute $cSubnetIP 255.255.255.0 > $PWD/ccd/$cKeyFilename - fi - fi - if [ "$cVpnIP" != "" ]; then - echo $cKeyFilename,$cVpnIP >> $PWD/ippool.txt - fi - fi - done - - ( - cat << EOF - keepalive 10 120 - ca $certdir/ca-cert.pem - cert $keydir/$keyname.pem - key $keydir/$keyname.key - dh $certdir/dh2048.pem - cipher AES-256-CBC - status /var/log/openvpn-status.log - log /var/log/openvpn-server.log - ifconfig-pool-linear - ifconfig-pool-persist $PWD/ippool.txt - port 1194 - proto udp - dev tun - verb 4 - daemon - EOF - )>> $PWD/server.conf - - # start vpn server - openvpn --config server.conf - - } - } - custom-config { - custom-config-id service:VPNServer - custom-command VPNServer - config { - - ('vpnserver.sh', 'vpnserver.key', 'vpnserver.pem', ) - 50 - ('bash vpnserver.sh', ) - ('killall openvpn', ) - ('pidof openvpn', ) - - } - } - services {IPForward DefaultRoute SSH VPNServer} -} - -node n6 { - type router - model PC - network-config { - hostname vpnclient - ! - interface eth0 - ip address 10.0.0.20/24 - ipv6 address 2001:0::20/64 - ! - } - canvas c1 - iconcoords {120.0 133.0} - labelcoords {120.0 165.0} - interface-peer {eth0 n1} - custom-config { - custom-config-id service:VPNClient:vpnclient.key - custom-command vpnclient.key - config { - -----BEGIN PRIVATE KEY----- - MIIEvQIBADANBgkqhkiG9w0BAQEFAASCBKcwggSjAgEAAoIBAQC6T+1XG/EQX8pj - vGSq5QMS6G8sqozjDPInZz8hSukeJCueE9Ib/nbg9wXLST6fAVA/VsY4eGXZzQNB - vl6BxVXjjj/UkY4R+RXchKjg85fq+I37uZnzUL3S2jIalswB4LsLSGusBbTTfe8v - 0rMCPVUzojMSXhkOVJs1gzusmdNnqEg7TZ+W4Ov12jzACbRdGMA572sXvnXRPhdR - BI4CSfrsPRueWPO317oLDCECMrxzza9y65UFS3oPFvf2s6oR7FlAIEq0Z1YUQayx - LDH0kE1ZjhLxBmaqNO7hD0gCjYYX8XSHOpiq045N+OGmKcI3Th8ZsGkXKMMyQ1yN - a1c2PuehAgMBAAECggEAVVqYmPesEJxR1C9SzxfruJXTmNrpgHtF1NdwDIiNE8nu - UZUzBLAnNhj1BpSfo6iuYtYWKXi+8HEDtPLJyRnmp0Fb7L5iH8nFQilkVOpEBtmn - 8lKtPNMYo6him9vJynJyPlEHQt+6X8mp8nbMm5INnoIIc7m4MOCB2poslH5EY4/j - /WTohzXVdx3nhYAJ5v5uVi/i6jeNHfY+6sj6pBKDq82OrfxgjrtABRj3/K5UcVd0 - UBsaqXXObHxSvJkHFOSxK+qhVivuT3svZZlaYaleRB1oDmMx3uRNvtxdkhVz5zZY - zeEddu5/BQzHPpIwKR/HScpFes92fiQ639bJxIzGAQKBgQDtNoE7V2CVpvMVgTsX - 3WsqjTZZOnH8jWfWrOMPgRWmDWSA7P7SNSL7dCIftqdMv3pPxCoYVzH7Skp18HGD - 8EVRqrBUupfj7NXOWlG624qtlilWQsNwPkpjXWciQQapdAhEX+T+1/d5UrVR/mY9 - gP4M6rnT87ShcPPi/Otvr/B6SQKBgQDJEWj0wR5GyCfDA0L8ez3OzAwkiWB3K+8b - usc0Cs/+ZFOjQd4Qxahoo6lL8G17TaIcSvdrULaWsQ/oeJ40M2xzsdlwrrtr6ueL - 7q/mqsJeGLIN0h0I0i6DTUYWwzTR5CXCox967FZV46FQ8Jof3c7fsXCNUajHzcUh - zxqp+AdCmQKBgHeV5bqTxzZKrvtlZfQXBOKzw/VhuHs4kmOwTtvPGKnY0JUKZUB1 - 10fq+RUB0P+o/DFgVFRnCOSFRFqGt8NrCpcsNK7STqZyDCt2bwODkDsIm5hIGhzo - 2jmTqd2j6Ibe3xgRO/GZ0MHSB2TpmoNhFzJN1xbaInLM7ba+CLcKfHI5AoGBAIaS - b3O4uSHYnrwnt7KybXi2Gr5tb7HzJrKhfOf5AKKb1VqkIBOLpx55wzp/LVdka0aS - aixaNgp/cU0/RWtcq453jzeayvf8nYKLexFgYnyF/M3BPguEWPsqQenENtrv3tH5 - SX2FJnePxY0dq5n+Y5JV+SWsbNFliDYLniX6SimpAoGAR9ABECd9DMnhgi+WkhZs - 55YBE8P8jFuSUASBIKVmke60nDn4oot0YD74kykb6TxasGXX5lC1vCje/olNBIGM - y687YmrudDfXWxEUwlHMoec5wrHDGIGCnBRAlt4whDoCREH1H+fp/9BgAThcjv58 - NyNDfW+vGpDlkbwFvyhc4pY= - -----END PRIVATE KEY----- - } - } - custom-config { - custom-config-id service:VPNClient:vpnclient.pem - custom-command vpnclient.pem - config { - Certificate: - Data: - Version: 3 (0x2) - Serial Number: 2 (0x2) - Signature Algorithm: sha256WithRSAEncryption - Issuer: C=US, ST=WA, O=core-dev/emailAddress=root@localhost - Validity - Not Before: May 19 02:09:57 2015 GMT - Not After : Apr 25 02:09:57 2115 GMT - Subject: C=US, ST=WA, O=core-dev, CN=vpnclient/emailAddress=root@localhost - Subject Public Key Info: - Public Key Algorithm: rsaEncryption - Public-Key: (2048 bit) - Modulus: - 00:ba:4f:ed:57:1b:f1:10:5f:ca:63:bc:64:aa:e5: - 03:12:e8:6f:2c:aa:8c:e3:0c:f2:27:67:3f:21:4a: - e9:1e:24:2b:9e:13:d2:1b:fe:76:e0:f7:05:cb:49: - 3e:9f:01:50:3f:56:c6:38:78:65:d9:cd:03:41:be: - 5e:81:c5:55:e3:8e:3f:d4:91:8e:11:f9:15:dc:84: - a8:e0:f3:97:ea:f8:8d:fb:b9:99:f3:50:bd:d2:da: - 32:1a:96:cc:01:e0:bb:0b:48:6b:ac:05:b4:d3:7d: - ef:2f:d2:b3:02:3d:55:33:a2:33:12:5e:19:0e:54: - 9b:35:83:3b:ac:99:d3:67:a8:48:3b:4d:9f:96:e0: - eb:f5:da:3c:c0:09:b4:5d:18:c0:39:ef:6b:17:be: - 75:d1:3e:17:51:04:8e:02:49:fa:ec:3d:1b:9e:58: - f3:b7:d7:ba:0b:0c:21:02:32:bc:73:cd:af:72:eb: - 95:05:4b:7a:0f:16:f7:f6:b3:aa:11:ec:59:40:20: - 4a:b4:67:56:14:41:ac:b1:2c:31:f4:90:4d:59:8e: - 12:f1:06:66:aa:34:ee:e1:0f:48:02:8d:86:17:f1: - 74:87:3a:98:aa:d3:8e:4d:f8:e1:a6:29:c2:37:4e: - 1f:19:b0:69:17:28:c3:32:43:5c:8d:6b:57:36:3e: - e7:a1 - Exponent: 65537 (0x10001) - X509v3 extensions: - X509v3 Basic Constraints: - CA:FALSE - X509v3 Subject Key Identifier: - 55:33:21:40:42:B6:63:7F:EA:A5:20:FA:18:21:C7:27:5B:6F:65:68 - X509v3 Authority Key Identifier: - keyid:DB:D2:9C:8D:22:D9:D7:E2:38:A0:8D:6C:3B:BE:33:CE:8D:2A:BE:C8 - DirName:/C=US/ST=WA/O=core-dev/emailAddress=root@localhost - serial:CE:78:96:91:DB:9B:84:FD - - Signature Algorithm: sha256WithRSAEncryption - 33:e5:aa:b3:19:63:ce:24:c7:ee:2f:11:18:5b:7b:1d:6b:4c: - 71:2d:0b:ea:6f:9b:5e:43:11:45:50:a6:00:fc:19:11:50:46: - 6a:d8:1d:38:eb:9f:3a:81:09:6e:dc:ae:b3:df:71:85:e2:16: - 7e:b8:bf:4c:ec:36:97:ae:58:a6:d9:d1:64:47:cf:8b:e8:0e: - 8c:41:2e:c3:a7:32:ef:a0:90:c2:5c:e5:6f:aa:03:ca:15:7f: - fb:ef:42:b1:22:28:47:fe:0a:df:58:b5:88:5b:a6:15:f8:13: - 3f:7e:19:da:ec:3f:63:72:0b:e5:c6:94:9f:53:1c:99:60:48: - 25:b5:b4:60:9a:4a:94:ab:68:be:5a:08:67:4c:c8:b5:7e:12: - 32:2c:e9:e7:fb:d1:a2:40:a8:e6:68:0e:37:a1:48:99:17:b6: - 40:f6:50:0a:f7:16:d1:90:e6:8a:3e:b0:c7:21:aa:9a:b9:79: - 6a:69:5c:25:9b:4b:29:b7:0e:13:80:ea:e8:5c:6d:95:cd:5c: - 69:de:20:69:d7:df:20:ec:6f:7b:9f:1d:61:c2:d1:59:6f:1e: - 0a:45:01:f6:25:02:e5:be:fb:91:a9:82:08:c8:42:2a:3e:2c: - 75:bb:4e:9c:0a:b6:07:24:52:e5:4f:f5:81:45:7b:77:ca:19: - 38:56:7f:17:63:5e:1f:a4:be:03:7d:d3:48:fc:e9:43:5c:2b: - b1:d5:da:44:c0:0c:56:23:4a:7d:bf:c0:ac:c6:9c:93:6d:69: - 9a:b9:02:3e:aa:1b:27:3e:b1:c8:6a:39:96:09:1d:c0:08:c8: - 1c:a4:82:ea:d2:72:e7:e1:47:66:7f:76:ac:d5:8c:99:59:02: - 25:ee:ec:ad:76:65:0f:8a:ba:5f:a7:33:ef:8e:34:71:d2:f5: - 3c:63:b0:c4:b2:65:c2:55:2d:35:d7:13:04:9c:87:d2:76:6b: - af:37:ba:58:d2:63:e0:fb:9c:a4:3a:97:e4:e6:79:0f:ca:d4: - 07:8c:39:80:4d:5e:d4:09:3a:09:1f:16:1a:58:c0:96:58:19: - e8:f7:56:bc:bd:fd:23:f4:4b:93:eb:a4:f2:22:7d:7c:d2:f3: - 6b:5a:13:24:a6:b8:1a:33:0c:fa:cd:77:36:12:c8:c6:ac:e9: - 0f:29:1a:4f:c3:3c:92:53:8c:af:80:04:ac:9b:2a:73:af:a8: - 0f:ef:7d:9f:5e:7c:52:d3:03:2e:19:6f:25:b0:f7:17:ef:c9: - 37:b9:50:ad:60:b0:c7:d9:ba:8f:9e:93:27:ba:52:27:70:b8: - ae:2b:9a:f7:33:2a:fd:a6:51:f5:e2:42:1a:e9:e6:08:5e:62: - 75:e9:b2:1b:ca:ce:cd:d1 - -----BEGIN CERTIFICATE----- - MIIE1TCCAr2gAwIBAgIBAjANBgkqhkiG9w0BAQsFADBMMQswCQYDVQQGEwJVUzEL - MAkGA1UECBMCV0ExETAPBgNVBAoTCGNvcmUtZGV2MR0wGwYJKoZIhvcNAQkBFg5y - b290QGxvY2FsaG9zdDAgFw0xNTA1MTkwMjA5NTdaGA8yMTE1MDQyNTAyMDk1N1ow - YDELMAkGA1UEBhMCVVMxCzAJBgNVBAgTAldBMREwDwYDVQQKEwhjb3JlLWRldjES - MBAGA1UEAxMJdnBuY2xpZW50MR0wGwYJKoZIhvcNAQkBFg5yb290QGxvY2FsaG9z - dDCCASIwDQYJKoZIhvcNAQEBBQADggEPADCCAQoCggEBALpP7Vcb8RBfymO8ZKrl - AxLobyyqjOMM8idnPyFK6R4kK54T0hv+duD3BctJPp8BUD9Wxjh4ZdnNA0G+XoHF - VeOOP9SRjhH5FdyEqODzl+r4jfu5mfNQvdLaMhqWzAHguwtIa6wFtNN97y/SswI9 - VTOiMxJeGQ5UmzWDO6yZ02eoSDtNn5bg6/XaPMAJtF0YwDnvaxe+ddE+F1EEjgJJ - +uw9G55Y87fXugsMIQIyvHPNr3LrlQVLeg8W9/azqhHsWUAgSrRnVhRBrLEsMfSQ - TVmOEvEGZqo07uEPSAKNhhfxdIc6mKrTjk344aYpwjdOHxmwaRcowzJDXI1rVzY+ - 56ECAwEAAaOBqzCBqDAJBgNVHRMEAjAAMB0GA1UdDgQWBBRVMyFAQrZjf+qlIPoY - IccnW29laDB8BgNVHSMEdTBzgBTb0pyNItnX4jigjWw7vjPOjSq+yKFQpE4wTDEL - MAkGA1UEBhMCVVMxCzAJBgNVBAgTAldBMREwDwYDVQQKEwhjb3JlLWRldjEdMBsG - CSqGSIb3DQEJARYOcm9vdEBsb2NhbGhvc3SCCQDOeJaR25uE/TANBgkqhkiG9w0B - AQsFAAOCAgEAM+WqsxljziTH7i8RGFt7HWtMcS0L6m+bXkMRRVCmAPwZEVBGatgd - OOufOoEJbtyus99xheIWfri/TOw2l65YptnRZEfPi+gOjEEuw6cy76CQwlzlb6oD - yhV/++9CsSIoR/4K31i1iFumFfgTP34Z2uw/Y3IL5caUn1McmWBIJbW0YJpKlKto - vloIZ0zItX4SMizp5/vRokCo5mgON6FImRe2QPZQCvcW0ZDmij6wxyGqmrl5amlc - JZtLKbcOE4Dq6Fxtlc1cad4gadffIOxve58dYcLRWW8eCkUB9iUC5b77kamCCMhC - Kj4sdbtOnAq2ByRS5U/1gUV7d8oZOFZ/F2NeH6S+A33TSPzpQ1wrsdXaRMAMViNK - fb/ArMack21pmrkCPqobJz6xyGo5lgkdwAjIHKSC6tJy5+FHZn92rNWMmVkCJe7s - rXZlD4q6X6cz7440cdL1PGOwxLJlwlUtNdcTBJyH0nZrrze6WNJj4PucpDqX5OZ5 - D8rUB4w5gE1e1Ak6CR8WGljAllgZ6PdWvL39I/RLk+uk8iJ9fNLza1oTJKa4GjMM - +s13NhLIxqzpDykaT8M8klOMr4AErJsqc6+oD+99n158UtMDLhlvJbD3F+/JN7lQ - rWCwx9m6j56TJ7pSJ3C4riua9zMq/aZR9eJCGunmCF5idemyG8rOzdE= - -----END CERTIFICATE----- - } - } - custom-config { - custom-config-id service:VPNClient:vpnclient.sh - custom-command vpnclient.sh - config { - #!/bin/sh - # custom VPN Client configuration for service (security.py) - # -------- CUSTOMIZATION REQUIRED -------- - # - # The VPNClient service builds a VPN tunnel to the specified VPN server using - # OpenVPN software and a virtual TUN/TAP device. - - # directory containing the certificate and key described below - certdir=$SESSION_DIR/certs - keydir=$PWD - - # the name used for a "$keyname.pem" certificate and "$keyname.key" private key. - keyname=vpnclient - - # the public IP address of the VPN server this client should connect with - vpnserver="10.0.1.10" - - # optional next hop for adding a static route to reach the VPN server - nexthop="" - - # --------- END CUSTOMIZATION -------- - - # validate addresses - if [ "$(dpkg -l | grep sipcalc)" = "" ]; then - echo "WARNING: ip validation disabled because package sipcalc not installed - " > $PWD/vpnclient.log - else - if [ "$(sipcalc "$vpnserver" "$nexthop" | grep ERR)" != "" ]; then - echo "ERROR: invalide address $vpnserver or $nexthop \ - " > $PWD/vpnclient.log - fi - fi - - # validate key and certification files - check-key-file() { - if [ ! -e $1 ]; then - echo "ERROR: missing certification or key file: $1" >> $PWD/vpnserver.log - fi - } - - check-key-file $keydir/$keyname.key - check-key-file $keydir/$keyname.pem - check-key-file $certdir/ca-cert.pem - check-key-file $certdir/dh2048.pem - - # if necessary, add a static route for reaching the VPN server IP via the IF - vpnservernet=${vpnserver%.*}.0/24 - if [ "$nexthop" != "" ]; then - /sbin/ip route add $vpnservernet via $nexthop - fi - - # create openvpn client.conf - ( - cat << EOF - client - dev tun - proto udp - remote $vpnserver 1194 - nobind - ca $certdir/ca-cert.pem - cert $keydir/$keyname.pem - key $keydir/$keyname.key - dh $certdir/dh2048.pem - cipher AES-256-CBC - log /var/log/openvpn-client.log - verb 4 - daemon - EOF - ) > client.conf - - openvpn --config client.conf - - } - } - custom-config { - custom-config-id service:VPNClient - custom-command VPNClient - config { - - ('vpnclient.sh', 'vpnclient.pem', 'vpnclient.key', ) - 60 - ('bash vpnclient.sh', ) - ('killall openvpn', ) - ('pidof openvpn', ) - - } - } - services {DefaultRoute VPNClient} -} - -node n7 { - type lanswitch - network-config { - hostname n7 - ! - } - canvas c1 - iconcoords {824.0 458.0} - labelcoords {824.0 482.0} - interface-peer {e0 n5} - interface-peer {e1 n8} - interface-peer {e2 n9} - interface-peer {e3 n10} -} - -node n8 { - type router - model PC - network-config { - hostname n8 - ! - interface eth0 - ip address 10.0.6.20/24 - ipv6 address 2001:6::20/64 - ! - } - canvas c1 - iconcoords {801.0 264.0} - labelcoords {801.0 296.0} - interface-peer {eth0 n7} -} - -node n9 { - type router - model PC - network-config { - hostname n9 - ! - interface eth0 - ip address 10.0.6.21/24 - ipv6 address 2001:6::21/64 - ! - } - canvas c1 - iconcoords {885.0 305.0} - labelcoords {885.0 337.0} - interface-peer {eth0 n7} -} - -node n10 { - type router - model PC - network-config { - hostname n10 - ! - interface eth0 - ip address 10.0.6.22/24 - ipv6 address 2001:6::22/64 - ! - } - canvas c1 - iconcoords {954.0 353.0} - labelcoords {954.0 385.0} - interface-peer {eth0 n7} -} - -link l1 { - nodes {n6 n1} - bandwidth 0 -} - -link l2 { - nodes {n4 n5} - bandwidth 0 -} - -link l3 { - nodes {n1 n2} - bandwidth 0 -} - -link l4 { - nodes {n3 n4} - bandwidth 0 -} - -link l5 { - nodes {n3 n1} - bandwidth 0 -} - -link l6 { - nodes {n4 n2} - bandwidth 0 -} - -link l7 { - nodes {n5 n7} - bandwidth 0 -} - -link l8 { - nodes {n8 n7} - bandwidth 0 -} - -link l9 { - nodes {n9 n7} - bandwidth 0 -} - -link l10 { - nodes {n10 n7} - bandwidth 0 -} - -annotation a1 { - iconcoords {661.0 187.0 997.0 579.0} - type rectangle - label {private network} - labelcolor black - fontfamily {Arial} - fontsize 12 - color #e9e9fe - width 0 - border black - rad 25 - effects {bold} - canvas c1 -} - -canvas c1 { - name {Canvas1} -} - -hook 3:instantiation_hook.sh { -#!/bin/sh -# session hook script; write commands here to execute on the host at the -# specified state - -CERT_DIR=$SESSION_DIR/certs -mkdir $CERT_DIR - -cat > $CERT_DIR/dh2048.pem < $CERT_DIR/ca-cert.pem <] [-s] [-a address] [-p port]" - echo " []" - echo "" - echo "Launches the CORE Tcl/Tk X11 GUI or starts an imn-based emulation." - echo "" - echo " -(-h)elp show help message and exit" - echo " -(-v)ersion show version number and exit" - echo " -(-b)atch batch mode (no X11 GUI)" - echo -n " -(-c)losebatch stop and clean up a batch mode " - echo "session " - echo " -(-s)tart start in execute mode, not edit mode" - echo " -(-a)ddress connect to the specified IP address (default 127.0.0.1)" - echo " -(-p)port connect to the specified TCP port (default 4038)" - echo " (optional) load the specified imn scenario file" - echo "" - echo "With no parameters, starts the GUI in edit mode with a blank canvas." - echo "" - exit 0 - ;; --v | --version) - exec echo "`basename $0` version @PACKAGE_VERSION@ (@PACKAGE_DATE@)" - exit 0 - ;; -esac - -SHELL=/bin/sh -export SHELL - -export LIBDIR="@CORE_LIB_DIR@" -export SBINDIR="@sbindir@" -# eval is used here to expand "~" to user's home dir -if [ x$CONFDIR = x ]; then export CONFDIR=`eval "echo @CORE_GUI_CONF_DIR@"` ; fi -export CORE_STATE_DIR="@CORE_STATE_DIR@" -export CORE_DATA_DIR="@CORE_DATA_DIR@" -export CORE_USER=`id -u -n` -export CORE_START_DIR=$PWD - -init_conf_dir() { - echo "Setting up user config area $CONFDIR, $CONFDIR/configs, and " - echo " $CONFDIR/myservices" - mkdir -p $CONFDIR - if [ $? != 0 ]; then echo "error making directory $CONFDIR!"; fi - mkdir -p $CONFDIR/configs - if [ $? != 0 ]; then - echo "error making directory $CONFDIR/configs!"; - else - cp -a $CORE_DATA_DIR/examples/configs/* $CONFDIR/configs/ - fi - mkdir -p $CONFDIR/myservices - if [ $? != 0 ]; then - echo "error making directory $CONFDIR/myservices!"; - else - cp -a $CORE_DATA_DIR/examples/myservices/* $CONFDIR/myservices/ - fi - mkdir -p $CONFDIR/myemane - if [ $? != 0 ]; then - echo "error making directory $CONFDIR/myemane!"; - else - cp -a $CORE_DATA_DIR/examples/myemane/* $CONFDIR/myemane/ - fi -} - -cd $LIBDIR - -core=$LIBDIR/core.tcl - -# locate wish8.5 binaries -WISHLIST="/usr/bin/wish8.6 /usr/local/bin/wish8.5 /usr/bin/wish8.5" -for wishbin in $WISHLIST -do - if [ -x $wishbin ] - then - WISH=$wishbin; - break; - fi; -done; - -if [ a$WISH = a ] -then - echo "CORE could not locate the Tcl/Tk binary (wish8.5)." - exit 1; -fi; - -# create /home/user/.core directory if necessary -if [ ! -e $CONFDIR ] -then - init_conf_dir -fi; - -# check for and fix write permissions on /home/user/.core directory -while [ ! -w $CONFDIR ]; -do - echo " CORE requires write permissions to the '$CONFDIR'" - echo " configuration directory for the user '$CORE_USER'," - echo " would you like to fix this now [Y/n]?" - read yn - if [ "z$yn" = "zn" ]; then - break - fi - echo -n " (sudo may prompt you for a password; if you do not have sudo set" - echo " up for the" - echo " user '$CORE_USER', su to root and run this command:" - echo " chown -R $CORE_USER $CONFDIR )" - sudo chown -R $U $CONFDIR - sudo chmod -R u+w $CONFDIR -done - -# GUI config directory should not be a file (old prefs) -if [ ! -d $CONFDIR ] -then - - mv $CONFDIR $CONFDIR.tmp - if [ $? != 0 ]; then echo "error moving $CONFDIR!"; exit 1; fi - init_conf_dir - echo "Old preferences file $CONFDIR has been moved to $CONFDIR/prefs.conf" - mv $CONFDIR.tmp $CONFDIR/prefs.conf - if [ $? != 0 ]; then echo "error moving $CONFDIR.tmp to $CONFDIR/prefs.conf!"; exit 1; fi -fi; - -case $1 in --b | --batch) - TCLBIN=`echo ${WISH} | sed s/wish/tclsh/g` - exec ${TCLBIN} $core "$@" - ;; --c | --closebatch) - TCLBIN=`echo ${WISH} | sed s/wish/tclsh/g` - exec ${TCLBIN} $core "$@" - ;; --s) - shift - exec ${WISH} $core -- "--start" "$@" - ;; --a) - shift - exec ${WISH} $core -- "--address" "$@" - ;; --p) - shift - exec ${WISH} $core -- "--port" "$@" - ;; -*) - exec ${WISH} $core -- $@ - ;; -esac - -cd $CORE_START_DIR diff --git a/gui/core.tcl b/gui/core.tcl deleted file mode 100644 index aad43fd4..00000000 --- a/gui/core.tcl +++ /dev/null @@ -1,196 +0,0 @@ -# -# Copyright 2004-2008 University of Zagreb, Croatia. -# -# Redistribution and use in source and binary forms, with or without -# modification, are permitted provided that the following conditions -# are met: -# 1. Redistributions of source code must retain the above copyright -# notice, this list of conditions and the following disclaimer. -# 2. Redistributions in binary form must reproduce the above copyright -# notice, this list of conditions and the following disclaimer in the -# documentation and/or other materials provided with the distribution. -# -# THIS SOFTWARE IS PROVIDED BY AUTHOR AND CONTRIBUTORS ``AS IS'' AND -# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE -# ARE DISCLAIMED. IN NO EVENT SHALL AUTHOR OR CONTRIBUTORS BE LIABLE -# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS -# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) -# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY -# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF -# SUCH DAMAGE. -# -# This work was supported in part by Croatian Ministry of Science -# and Technology through the research contract #IP-2003-143. -# - -if {[lindex $argv 0] == "-b" || [lindex $argv 0] == "--batch"} { - set argv [lrange $argv 1 end] - set execMode batch -} elseif {[lindex $argv 0] == "-c" || [lindex $argv 0] == "--closebatch"} { - set argv [lrange $argv 1 end] - set execMode closebatch -} elseif {[lindex $argv 0] == "--addons"} { - set argv [lrange $argv 1 end] - set execMode addons -} else { - set execMode interactive -} - -set LIBDIR "" -set SBINDIR "/usr/local/sbin" -set CONFDIR "." -set CORE_DATA_DIR "." -set CORE_STATE_DIR "." -set CORE_START_DIR "" -set CORE_USER "" -if { [info exists env(LIBDIR)] } { - set LIBDIR $env(LIBDIR) -} -if { [info exists env(SBINDIR)] } { - set SBINDIR $env(SBINDIR) -} -if { [info exists env(CONFDIR)] } { - set CONFDIR $env(CONFDIR) -} -if { [info exists env(CORE_DATA_DIR)] } { - set CORE_DATA_DIR $env(CORE_DATA_DIR) -} -if { [info exists env(CORE_STATE_DIR)] } { - set CORE_STATE_DIR $env(CORE_STATE_DIR) -} -if { [info exists env(CORE_START_DIR)] } { - set CORE_START_DIR $env(CORE_START_DIR) -} -if { [info exists env(CORE_USER)] } { - set CORE_USER $env(CORE_USER) -} - -source "$LIBDIR/version.tcl" - -source "$LIBDIR/linkcfg.tcl" -source "$LIBDIR/nodecfg.tcl" -source "$LIBDIR/ipv4.tcl" -source "$LIBDIR/ipv6.tcl" -source "$LIBDIR/cfgparse.tcl" -source "$LIBDIR/exec.tcl" -source "$LIBDIR/canvas.tcl" - -source "$LIBDIR/editor.tcl" -source "$LIBDIR/annotations.tcl" - -source "$LIBDIR/help.tcl" -source "$LIBDIR/filemgmt.tcl" - -source "$LIBDIR/ns2imunes.tcl" - - -source "$LIBDIR/mobility.tcl" -source "$LIBDIR/api.tcl" -source "$LIBDIR/wlan.tcl" -source "$LIBDIR/wlanscript.tcl" -source "$LIBDIR/util.tcl" -source "$LIBDIR/plugins.tcl" -source "$LIBDIR/nodes.tcl" -source "$LIBDIR/services.tcl" -source "$LIBDIR/traffic.tcl" -source "$LIBDIR/exceptions.tcl" - -# -# Global variables are initialized here -# -set node_list {} -set link_list {} -set annotation_list {} -set canvas_list {} -set eid e0 -set plot_list {} -array set exec_servers {} -loadServersConf ;# populate exec_servers - -# global vars -set showAPI 0 -set mac_byte4 0 -set mac_byte5 0 -set g_mrulist {} -initDefaultPrefs -loadDotFile -loadPluginsConf -checkCommandLineAddressPort -autoConnectPlugins - -set g_abort_session 0 - -# -# Initialization should be complete now, so let's start doing something... -# - -if {$execMode == "interactive"} { - # GUI-related files - source "$LIBDIR/widget.tcl" - source "$LIBDIR/tooltips.tcl" - source "$LIBDIR/initgui.tcl" - source "$LIBDIR/topogen.tcl" - source "$LIBDIR/graph_partitioning.tcl" - source "$LIBDIR/gpgui.tcl" - source "$LIBDIR/debug.tcl" - # Load all Tcl files from the addons directory - foreach file [glob -nocomplain -directory "$LIBDIR/addons" *.tcl] { - if { [catch { if { [file isfile $file ] } { source "$file"; } } e] } { - puts "*** Error loading addon file: $file" - puts " $e" - } - } - setOperMode edit - fileOpenStartUp - foreach arg $argv { - if { $arg == "--start" } { - global currentFile - if { [file extension $currentFile] == ".xml" } { - after 100; update; # yield to other events so XML file - after 100; update; # can be loaded and received - } - startStopButton "exec"; break; - } - } -# Boeing changed elseif to catch batch and else to output error -} elseif {$execMode == "batch"} { - puts "batch execute $argv" - set sock [lindex [getEmulPlugin "*"] 2] - if { $sock == "" || $sock == "-1" || $sock == -1 } { exit.real; } - if {$argv != ""} { - global currentFile - set currentFile [argAbsPathname $argv] - set fileId [open $currentFile r] - set cfg "" - foreach entry [read $fileId] { - lappend cfg $entry - } - close $fileId - after 100 { - loadCfg $cfg - deployCfgAPI $sock - puts "Waiting to enter RUNTIME state..." - } - global vwaitdummy - vwait vwaitdummy - } -} elseif {$execMode == "closebatch"} { - global g_session_choice - set g_session_choice $argv - puts "Attempting to close session $argv ..." - global vwaitdummy - vwait vwaitdummy -} elseif {$execMode == "addons"} { - # pass control to included addons code - foreach file [glob -nocomplain -directory "$LIBDIR/addons" *.tcl] { - if { [file isfile $file ] } { source "$file"; } - } - global vwaitdummy - vwait vwaitdummy -} else { - puts "ERROR: execMode is not set in core.tcl" -} - diff --git a/gui/debug.tcl b/gui/debug.tcl deleted file mode 100644 index 60e45cbc..00000000 --- a/gui/debug.tcl +++ /dev/null @@ -1,46 +0,0 @@ -.menubar.tools add command -label "Debugger..." -command popupDebugger - -set g_last_debug_cmd "puts \"Hello world\"" - -proc popupDebugger {} { - global g_last_debug_cmd - - set wi .debugger - catch { destroy $wi } - toplevel $wi - - wm transient $wi . - wm resizable $wi 300 200 - wm title $wi "CORE Debugger" - - frame $wi.dbg -borderwidth 4 - label $wi.dbg.label1 \ - -text "Enter TCL/Tk commands below, press Run to evaluate:" - text $wi.dbg.cmd -bg white -width 100 -height 3 - - pack $wi.dbg.label1 $wi.dbg.cmd -side top -anchor w -padx 4 -pady 4 - pack $wi.dbg -side top - - $wi.dbg.cmd insert end "$g_last_debug_cmd" - - frame $wi.btn - # evaluate debugging commands entered into the text box below - button $wi.btn.exec -text "Run" -command { - global g_last_debug_cmd - set wi .debugger - set i 1 - set g_last_debug_cmd "" - while { 1 } { - set cmd [$wi.dbg.cmd get $i.0 $i.end] - set g_last_debug_cmd "$g_last_debug_cmd$cmd\n" - if { $cmd == "" } { break } - catch { eval $cmd } output - puts $output - incr i - } - } - button $wi.btn.close -text "Close" -command "destroy .debugger" - - pack $wi.btn.exec $wi.btn.close -side left -padx 4 -pady 4 - pack $wi.btn -side bottom -} diff --git a/gui/editor.tcl b/gui/editor.tcl deleted file mode 100644 index f93d85c1..00000000 --- a/gui/editor.tcl +++ /dev/null @@ -1,5348 +0,0 @@ -# -# Copyright 2004-2008 University of Zagreb, Croatia. -# -# Redistribution and use in source and binary forms, with or without -# modification, are permitted provided that the following conditions -# are met: -# 1. Redistributions of source code must retain the above copyright -# notice, this list of conditions and the following disclaimer. -# 2. Redistributions in binary form must reproduce the above copyright -# notice, this list of conditions and the following disclaimer in the -# documentation and/or other materials provided with the distribution. -# -# THIS SOFTWARE IS PROVIDED BY AUTHOR AND CONTRIBUTORS ``AS IS'' AND -# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE -# ARE DISCLAIMED. IN NO EVENT SHALL AUTHOR OR CONTRIBUTORS BE LIABLE -# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS -# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) -# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY -# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF -# SUCH DAMAGE. -# -# This work was supported in part by the Croatian Ministry of Science -# and Technology through the research contract #IP-2003-143. -# - -#****h* imunes/editor.tcl -# NAME -# editor.tcl -- file used for defining functions that can be used in -# edit mode as well as all the functions which change the appearance -# of the imunes GUI. -# FUNCTION -# This module is used for defining all possible actions in imunes -# edit mode. It is also used for all the GUI related actions. -#**** - - -proc animateCursor {} { - global cursorState - global clock_seconds - - if { [clock seconds] == $clock_seconds } { - update - return - } - set clock_seconds [clock seconds] - if { $cursorState } { - .c config -cursor watch - set cursorState 0 - } else { - .c config -cursor pirate - set cursorState 1 - } - update -} - -#****f* editor.tcl/removeGUILink -# NAME -# removeGUILink -- remove link from GUI -# SYNOPSIS -# renoveGUILink $link_id $atomic -# FUNCTION -# Removes link from GUI. It removes standard links as well as -# split links and links connecting nodes on different canvases. -# INPUTS -# * link_id -- the link id -# * atomic -- defines if the remove was atomic action or a part -# of a composed, non-atomic action (relevant for updating log -# for undo). -#**** - -proc removeGUILink { link atomic } { - global changed - - set nodes [linkPeers $link] - set node1 [lindex $nodes 0] - set node2 [lindex $nodes 1] - if { [nodeType $node1] == "pseudo" } { - removeLink [getLinkMirror $link] - removeLink $link - removeNode [getNodeMirror $node1] - removeNode $node1 - .c delete $node1 - } elseif { [nodeType $node2] == "pseudo" } { - removeLink [getLinkMirror $link] - removeLink $link - removeNode [getNodeMirror $node2] - removeNode $node2 - .c delete $node2 - } else { - removeLink $link - } - .c delete $link - if { $atomic == "atomic" } { - set changed 1 - updateUndoLog - } -} - -#****f* editor.tcl/removeGUINode -# NAME -# removeGUINode -- remove node from GUI -# SYNOPSIS -# renoveGUINode $node_id -# FUNCTION -# Removes node from GUI. When removing a node from GUI the links -# connected to that node are also removed. -# INPUTS -# * node_id -- node id -#**** - -proc removeGUINode { node } { - set type [nodeType $node] - foreach ifc [ifcList $node] { - set peer [peerByIfc $node $ifc] - set link [lindex [.c gettags "link && $node && $peer"] 1] - removeGUILink $link non-atomic - } - if { [lsearch -exact "oval rectangle label text marker" $type] != -1 } { - deleteAnnotation .c $type $node - } elseif { $type != "pseudo" } { - removeNode $node - .c delete $node - } -} - -#****f* editor.tcl/updateUndoLog -# NAME -# updateUndoLog -- update the undo log -# SYNOPSIS -# updateUndoLog -# FUNCTION -# Updates the undo log. Writes the current configuration to the -# undolog array and updates the undolevel variable. -#**** - -proc updateUndoLog {} { - global changed undolog undolevel redolevel - - if { $changed } { - global t_undolog undolog - set t_undolog "" - dumpCfg string t_undolog - incr undolevel - set undolog($undolevel) $t_undolog - set redolevel $undolevel - updateUndoRedoMenu "" -# Boeing: XXX why is this set here? - set changed 0 - } -} - -#****f* editor.tcl/undo -# NAME -# undo -- undo function -# SYNOPSIS -# undo -# FUNCTION -# Undo the change. Reads the undolog and updates the current -# configuration. Reduces the value of undolevel. -#**** - -proc undo {} { - global undolevel undolog oper_mode - - if {$oper_mode == "edit" && $undolevel > 0} { - incr undolevel -1 - updateUndoRedoMenu "" - .c config -cursor watch - loadCfg $undolog($undolevel) - switchCanvas none - } -} - -#****f* editor.tcl/redo -# NAME -# redo -# SYNOPSIS -# redo -# FUNCTION -# Redo the change if possible (redolevel is greater than -# undolevel). Reads the configuration from undolog and -# updates the current configuration. Increases the value -# of undolevel. -#**** - -proc redo {} { - global undolevel redolevel undolog oper_mode - - if {$oper_mode == "edit" && $redolevel > $undolevel} { - incr undolevel - updateUndoRedoMenu "" - .c config -cursor watch - loadCfg $undolog($undolevel) - switchCanvas none - } -} - -proc updateUndoRedoMenu { forced } { - global undolevel redolevel - - if { $forced == "" } { - if { $undolevel > 0 } { set undo "normal" } else { set undo "disabled" } - if { $redolevel > $undolevel } { set redo "normal" - } else { set redo "disabled" } - } else { - set undo $forced - set redo $forced - } - - .menubar.edit entryconfigure "Undo" -state $undo - .menubar.edit entryconfigure "Redo" -state $redo -} - -#****f* editor.tcl/redrawAll -# NAME -# redrawAll -# SYNOPSIS -# redrawAll -# FUNCTION -# Redraws all the objects on the current canvas. -#**** - - -proc redrawAll {} { - global node_list plot_list link_list annotation_list plot_list background sizex sizey grid - global curcanvas zoom - global showAnnotations showGrid - - #Call_Trace ;# debugging when things disappear - - .bottom.zoom config -text "zoom [expr {int($zoom * 100)}]%" - set e_sizex [expr {int($sizex * $zoom)}] - set e_sizey [expr {int($sizey * $zoom)}] - set border 28 - .c configure -scrollregion \ - "-$border -$border [expr {$e_sizex + $border}] \ - [expr {$e_sizey + $border}]" - - - saveRestoreWlanLinks .c save - .c delete all - set background [.c create rectangle 0 0 $e_sizex $e_sizey \ - -fill white -tags "background"] - # Boeing: wallpaper - set wallpaper [lindex [getCanvasWallpaper $curcanvas] 0] - set wallpaperStyle [lindex [getCanvasWallpaper $curcanvas] 1] - if { $wallpaper != "" } { - drawWallpaper .c $wallpaper $wallpaperStyle - } - # end Boeing - - if { $showAnnotations == 1 } { - foreach obj $annotation_list { - # fix annotations having no canvas (from old config) - if { [getNodeCanvas $obj] == "" } { setNodeCanvas $obj $curcanvas} - if { [getNodeCanvas $obj] == $curcanvas } { - drawAnnotation $obj - } - } - } - - # Grid - set e_grid [expr {int($grid * $zoom)}] - set e_grid2 [expr {$e_grid * 2}] - if { $showGrid } { - for { set x $e_grid } { $x < $e_sizex } { incr x $e_grid } { - if { [expr {$x % $e_grid2}] != 0 } { - if { $zoom > 0.5 } { - .c create line $x 1 $x $e_sizey \ - -fill gray -dash {1 7} -tags "grid" - } - } else { - .c create line $x 1 $x $e_sizey -fill gray -dash {1 3} \ - -tags "grid" - } - } - for { set y $e_grid } { $y < $e_sizey } { incr y $e_grid } { - if { [expr {$y % $e_grid2}] != 0 } { - if { $zoom > 0.5 } { - .c create line 1 $y $e_sizex $y \ - -fill gray -dash {1 7} -tags "grid" - } - } else { - .c create line 1 $y $e_sizex $y -fill gray -dash {1 3} \ - -tags "grid" - } - } - } - - .c lower -withtags background - - foreach node $node_list { - if { [getNodeCanvas $node] == $curcanvas } { - drawNode .c $node - } - } - - redrawAllThruplots - foreach link $link_list { - set nodes [linkPeers $link] - if { [getNodeCanvas [lindex $nodes 0]] != $curcanvas || - [getNodeCanvas [lindex $nodes 1]] != $curcanvas } { - continue - } - drawLink $link - redrawLink $link - updateLinkLabel $link - } - saveRestoreWlanLinks .c restore - - .c config -cursor left_ptr - - raiseAll .c -} - -#****f* editor.tcl/drawNode -# NAME -# drawNode -# SYNOPSIS -# drawNode node_id -# FUNCTION -# Draws the specified node. Draws node's image (router pc -# host lanswitch rj45 hub pseudo) and label. -# The visibility of the label depends on the showNodeLabels -# variable for all types of nodes and on invisible variable -# for pseudo nodes. -# INPUTS -# * node_id -- node id -#**** - -proc drawNode { c node } { - global showNodeLabels - global router pc host lanswitch rj45 hub pseudo - global curcanvas zoom - global wlan - if { $c == "" } { set c .c } ;# default canvas - - set type [nodeType $node] - set coords [getNodeCoords $node] - set x [expr {[lindex $coords 0] * $zoom}] - set y [expr {[lindex $coords 1] * $zoom}] - # special handling for custom images, dummy nodes - # could move this to separate getImage function - set model "" - set cimg "" - set imgzoom $zoom - if { $zoom == 0.75 || $zoom == 1.5 } { set imgzoom 1.0 } - if { $type == "router" } { - set model [getNodeModel $node] - set cimg [getNodeTypeImage $model normal] - } - set tmp [absPathname [getCustomImage $node]] - if { $tmp != "" } { set cimg $tmp } - if { $cimg != "" } { - # name of global variable storing the image is the filename without path - set img [file tail $cimg] - # create the variable if the image hasn't been loaded before - global [set img] - if { ![info exists $img] } { - if { [catch { - set [set img] [image create photo -file $cimg] - createScaledImages $img - } e ] } { ;# problem loading image file - puts "icon error: $e" - set cimg "" ;# fall back to default model icon - setCustomImage $node "" ;# prevent errors elsewhere - } - } - if { $cimg != "" } { ;# only if image file loaded - global $img$imgzoom - $c create image $x $y -image [set $img$imgzoom] -tags "node $node" - } - } - if { $cimg == "" } { - if { $type == "pseudo" } { - $c create image $x $y -image [set $type] -tags "node $node" - } else { - # create scaled images based on zoom level - global $type$imgzoom - $c create image $x $y -image [set $type$imgzoom] \ - -tags "node $node" - } - } - set coords [getNodeLabelCoords $node] - set x [expr {[lindex $coords 0] * $zoom}] - set y [expr {[lindex $coords 1] * $zoom}] - if { [nodeType $node] != "pseudo" } { ;# Boeing: show remote server - set loc [getNodeLocation $node] - set labelstr0 "" - if { $loc != "" } { set labelstr0 "([getNodeLocation $node]):" } - set labelstr1 [getNodeName $node]; - set labelstr2 "" - if [info exists getNodePartition] { [getNodePartition $node]; } - set l [format "%s%s\n%s" $labelstr0 $labelstr1 $labelstr2]; - set label [$c create text $x $y -fill blue \ - -text "$l" \ - -tags "nodelabel $node"] - } else { - set pnode [getNodeName $node] - set pcanvas [getNodeCanvas $pnode] - set ifc [ifcByPeer $pnode [getNodeMirror $node]] - if { $pcanvas != $curcanvas } { - set label [$c create text $x $y -fill blue \ - -text "[getNodeName $pnode]:$ifc -@[getCanvasName $pcanvas]" \ - -tags "nodelabel $node" -justify center] - } else { - set label [$c create text $x $y -fill blue \ - -text "[getNodeName $pnode]:$ifc" \ - -tags "nodelabel $node" -justify center] - } - } - if { $showNodeLabels == 0} { - $c itemconfigure $label -state hidden - } - global invisible - if { $invisible == 1 && [nodeType $node] == "pseudo" } { - $c itemconfigure $label -state hidden - } -} - -#****f* editor.tcl/drawLink -# NAME -# drawLink -# SYNOPSIS -# drawLink link_id -# FUNCTION -# Draws the specified link. An arrow is displayed for links -# connected to pseudo nodes. If the variable invisible -# is specified link connecting a pseudo node stays hidden. -# INPUTS -# * link_id -- link id -#**** - -proc drawLink { link } { - set nodes [linkPeers $link] - set lnode1 [lindex $nodes 0] - set lnode2 [lindex $nodes 1] - set lwidth [getLinkWidth $link] - if { [getLinkMirror $link] != "" } { - set newlink [.c create line 0 0 0 0 \ - -fill [getLinkColor $link] -width $lwidth \ - -tags "link $link $lnode1 $lnode2" -arrow both] - } else { - set newlink [.c create line 0 0 0 0 \ - -fill [getLinkColor $link] -width $lwidth \ - -tags "link $link $lnode1 $lnode2"] - } - # Boeing: links between two nodes on different servers - if { [getNodeLocation $lnode1] != [getNodeLocation $lnode2]} { - .c itemconfigure $newlink -dash ","; - } - # end Boeing - # XXX Invisible pseudo-liks - global invisible - if { $invisible == 1 && [getLinkMirror $link] != "" } { - .c itemconfigure $link -state hidden - } - # Boeing: wlan links are hidden - if { [nodeType $lnode1] == "wlan" || [nodeType $lnode2] == "wlan" } { - global zoom - set imgzoom $zoom - if { $zoom == 0.75 || $zoom == 1.5 } { set imgzoom 1.0 } - global antenna$imgzoom - .c itemconfigure $link -state hidden - .c create image 0 0 -image [set antenna$imgzoom] \ - -tags "antenna $lnode2 $link" - .c create text 0 0 -tags "interface $lnode1 $link" -justify center - .c create text 0 0 -tags "interface $lnode2 $link" -justify center - .c raise interface "link || linklabel || background" - } else { - .c raise $newlink background - .c create text 0 0 -tags "linklabel $link" -justify center - .c create text 0 0 -tags "interface $lnode1 $link" -justify center - .c create text 0 0 -tags "interface $lnode2 $link" -justify center - .c raise linklabel "link || background" - .c raise interface "link || linklabel || background" - } - foreach n [list $lnode1 $lnode2] { - if { [getNodeHidden $n] } { - hideNode $n - statline "Hidden node(s) exist." - } - } -} - - -# draw a green link between wireless nodes (or other color if multiple WLANs) -# WLAN links appear on the canvas but not in the global link_list -proc drawWlanLink { node1 node2 wlan } { - global zoom defLinkWidth curcanvas - set c .c - - set wlanlink [$c find withtag "wlanlink && $node1 && $node2 && $wlan"] - if { $wlanlink != "" } { - return $wlanlink ;# already exists - } - - set color [getWlanColor $wlan] - - set xy [getNodeCoords $node1] - set x [lindex $xy 0]; set y [lindex $xy 1] - set pxy [getNodeCoords $node2] - set px [lindex $pxy 0]; set py [lindex $pxy 1] - - set wlanlink [$c create line [expr {$x*$zoom}] [expr {$y*$zoom}] \ - [expr {$px*$zoom}] [expr {$py*$zoom}] \ - -fill $color -width $defLinkWidth \ - -tags "wlanlink $node1 $node2 $wlan"] - - if { [getNodeCanvas $node1] == $curcanvas && - [getNodeCanvas $node2] == $curcanvas} { - $c itemconfigure $wlanlink -state normal - $c raise $wlanlink "background || grid || oval || rectangle" - } else { - $c itemconfigure $wlanlink -state hidden - } - - return $wlanlink -} - - -#****f* editor.tcl/chooseIfName -# NAME -# chooseIfName -- choose interface name -# SYNOPSIS -# set ifcName [chooseIfName $lnode1 $lnode2] -# FUNCTION -# Choose intreface name. The name can be: -# * eth -- for interface connecting pc, host and router -# * e -- for interface connecting hub and lanswitch -# INPUTS -# * link_id -- link id -# RESULT -# * ifcName -- the name of the interface -#**** - -proc chooseIfName { lnode1 lnode2 } { - global $lnode1 $lnode2 - - # TODO: just check if layer == NETWORK and return eth, LINK return e - switch -exact -- [nodeType $lnode1] { - pc { - return eth - } - host { - return eth - } - hub { - return e - } - lanswitch { - return e - } - router { - return eth - } - rj45 { - return - } - tunnel { - return e - } - ktunnel { - return - } - wlan { - return e - } - default { - return eth -# end Boeing: below - } - } -} - - -#****f* editor.tcl/listLANNodes -# NAME -# listLANNodes -- list LAN nodes -# SYNOPSIS -# set l2peers [listLANNodes $l2node $l2peers] -# FUNCTION -# Recursive function for finding all link layer nodes that are -# connected to node l2node. Returns the list of all link layer -# nodes that are on the same LAN as l2node. -# INPUTS -# * l2node -- node id of a link layer node -# * l2peers -- old link layer nodes on the same LAN -# RESULT -# * l2peers -- new link layer nodes on the same LAN -#**** - -proc listLANnodes { l2node l2peers } { - lappend l2peers $l2node - foreach ifc [ifcList $l2node] { - set peer [logicalPeerByIfc $l2node $ifc] - set type [nodeType $peer] - # Boeing - if { [ lsearch {lanswitch hub wlan} $type] != -1 } { - if { [lsearch $l2peers $peer] == -1 } { - set l2peers [listLANnodes $peer $l2peers] - } - } - } - return $l2peers -} - -#****f* editor.tcl/calcDxDy -# NAME -# calcDxDy lnode -- list LAN nodes -# SYNOPSIS -# calcDxDy $lnode -# FUNCTION -# Calculates dx and dy variables of the calling function. -# INPUTS -# * lnode -- node id of a node whose dx and dy coordinates are -# calculated -#**** - -proc calcDxDy { lnode } { - global showIfIPaddrs showIfIPv6addrs zoom - upvar dx x - upvar dy y - - if { $zoom > 1.0 } { - set x 1 - set y 1 - return - } - switch -exact -- [nodeType $lnode] { - hub { - set x [expr {1.5 / $zoom}] - set y [expr {2.6 / $zoom}] - } - lanswitch { - set x [expr {1.5 / $zoom}] - set y [expr {2.6 / $zoom}] - } - router { - set x [expr {1 / $zoom}] - set y [expr {2 / $zoom}] - } - rj45 { - set x [expr {1 / $zoom}] - set y [expr {1 / $zoom}] - } - tunnel { - set x [expr {1 / $zoom}] - set y [expr {1 / $zoom}] - } - wlan { - set x [expr {1.5 / $zoom}] - set y [expr {2.6 / $zoom}] - } - default { - set x [expr {1 / $zoom}] - set y [expr {2 / $zoom}] - } - } - return -} - -#****f* editor.tcl/updateIfcLabel -# NAME -# updateIfcLabel -- update interface label -# SYNOPSIS -# updateIfcLabel $lnode1 $lnode2 -# FUNCTION -# Updates the interface label, including interface name, -# interface state (* for interfaces that are down), IPv4 -# address and IPv6 address. -# INPUTS -# * lnode1 -- node id of a node where the interface resides -# * lnode2 -- node id of the node that is connected by this -# interface. -#**** -proc updateIfcLabel { lnode1 lnode2 } { - global showIfNames showIfIPaddrs showIfIPv6addrs - - set link [lindex [.c gettags "link && $lnode1 && $lnode2"] 1] - set ifc [ifcByPeer $lnode1 $lnode2] - set ifipv4addr [getIfcIPv4addr $lnode1 $ifc] - set ifipv6addr [getIfcIPv6addr $lnode1 $ifc] - if { $ifc == 0 } { - set ifc "" - } - if { [getIfcOperState $lnode1 $ifc] == "down" } { - set labelstr "*" - } else { - set labelstr "" - } - if { $showIfNames } { - set labelstr "$labelstr$ifc -" - } - if { $showIfIPaddrs && $ifipv4addr != "" } { - set labelstr "$labelstr$ifipv4addr -" - } - if { $showIfIPv6addrs && $ifipv6addr != "" } { - set labelstr "$labelstr$ifipv6addr -" - } - set labelstr \ - [string range $labelstr 0 [expr {[string length $labelstr] - 2}]] - .c itemconfigure "interface && $lnode1 && $link" \ - -text "$labelstr" - # Boeing: hide ifc label on wlans - if { [nodeType $lnode1] == "wlan" } { - .c itemconfigure "interface && $lnode1 && $link" -state hidden - } -} - - -#****f* editor.tcl/updateLinkLabel -# NAME -# updateLinkLabel -- update link label -# SYNOPSIS -# updateLinkLabel $link -# FUNCTION -# Updates the link label, including link bandwidth, link delay, -# BER and duplicate values. -# INPUTS -# * link -- link id of the link whose labels are updated. -#**** -proc updateLinkLabel { link } { - global showLinkLabels - - set bwstr [getLinkBandwidthString $link] - set delstr [getLinkDelayString $link] - set berstr [getLinkBERString $link] - set dupstr [getLinkDupString $link] - set labelstr " -" - if { "$bwstr" != "" } { - set labelstr "$labelstr$bwstr -" - } - if { "$delstr" != "" } { - set labelstr "$labelstr$delstr -" - } - if { "$berstr" != "" } { - set labelstr "$labelstr$berstr -" - } - if { "$dupstr" != "" } { - set labelstr "$labelstr$dupstr -" - } - set labelstr \ - [string range $labelstr 0 [expr {[string length $labelstr] - 2}]] - .c itemconfigure "linklabel && $link" -text "$labelstr" - if { $showLinkLabels == 0} { - .c itemconfigure "linklabel && $link" -state hidden - } -} - - -#****f* editor.tcl/redrawAllLinks -# NAME -# redrawAllLinks -- redraw all links -# SYNOPSIS -# redrawAllLinks -# FUNCTION -# Redraws all links on the current canvas. -#**** -proc redrawAllLinks {} { - global link_list curcanvas - - foreach link $link_list { - set nodes [linkPeers $link] - if { [getNodeCanvas [lindex $nodes 0]] != $curcanvas || - [getNodeCanvas [lindex $nodes 1]] != $curcanvas } { - continue - } - redrawLink $link - } -} - - -#****f* editor.tcl/redrawLink -# NAME -# redrawLink -- redraw a links -# SYNOPSIS -# redrawLink $link -# FUNCTION -# Redraws the specified link. -# INPUTS -# * link -- link id -#**** -proc redrawLink { link } { - global $link - - set limages [.c find withtag "link && $link"] - set limage1 [lindex $limages 0] - set limage2 [lindex $limages 1] - set tags [.c gettags $limage1] - set link [lindex $tags 1] - set lnode1 [lindex $tags 2] - set lnode2 [lindex $tags 3] - - set coords1 [.c coords "node && $lnode1"] - set coords2 [.c coords "node && $lnode2"] - set x1 [lindex $coords1 0] - set y1 [lindex $coords1 1] - set x2 [lindex $coords2 0] - set y2 [lindex $coords2 1] - - .c coords $limage1 $x1 $y1 $x2 $y2 - .c coords $limage2 $x1 $y1 $x2 $y2 - - set lx [expr {0.5 * ($x1 + $x2)}] - set ly [expr {0.5 * ($y1 + $y2)}] - .c coords "linklabel && $link" $lx $ly - - set n [expr {sqrt (($x1 - $x2) * ($x1 - $x2) + \ - ($y1 - $y2) * ($y1 - $y2)) * 0.015}] - if { $n < 1 } { - set n 1 - } - - calcDxDy $lnode1 - set lx [expr {($x1 * ($n * $dx - 1) + $x2) / $n / $dx}] - set ly [expr {($y1 * ($n * $dy - 1) + $y2) / $n / $dy}] - .c coords "interface && $lnode1 && $link" $lx $ly - updateIfcLabel $lnode1 $lnode2 - - calcDxDy $lnode2 - set lx [expr {($x1 + $x2 * ($n * $dx - 1)) / $n / $dx}] - set ly [expr {($y1 + $y2 * ($n * $dy - 1)) / $n / $dy}] - .c coords "interface && $lnode2 && $link" $lx $ly - updateIfcLabel $lnode2 $lnode1 - # Boeing - wlan antennas - if { [nodeType $lnode1] == "wlan" } { - global zoom - set an [lsearch -exact [findWlanNodes $lnode2] $lnode1] - if { $an < 0 || $an >= 5 } { set an 0 } - set dx [expr {20 - (10*$an)}] - .c coords "antenna && $lnode2 && $link" [expr {$x2-($dx*$zoom)}] \ - [expr {$y2-(20*$zoom)}] - } -} - -# Boeing -proc redrawWlanLink { link } { - global $link - - set tags [.c gettags $link] - set lnode1 [lindex $tags 1] - set lnode2 [lindex $tags 2] - set coords1 [.c coords "node && $lnode1"] - set coords2 [.c coords "node && $lnode2"] - set x1 [lindex $coords1 0] - set y1 [lindex $coords1 1] - set x2 [lindex $coords2 0] - set y2 [lindex $coords2 1] - set lx [expr {0.5 * ($x1 + $x2)}] - set ly [expr {0.5 * ($y1 + $y2)}] - - .c coords $link $x1 $y1 $x2 $y2 - .c coords "linklabel && $lnode2 && $lnode1" $lx $ly - - return -} -# end Boeing - -#****f* editor.tcl/splitGUILink -# NAME -# splitGUILink -- splits a links -# SYNOPSIS -# splitGUILink $link -# FUNCTION -# Splits the link and draws new links and new pseudo nodes -# on the canvas. -# INPUTS -# * link -- link id -#**** -proc splitGUILink { link } { - global changed zoom - - set peer_nodes [linkPeers $link] - set new_nodes [splitLink $link pseudo] - set orig_node1 [lindex $peer_nodes 0] - set orig_node2 [lindex $peer_nodes 1] - set new_node1 [lindex $new_nodes 0] - set new_node2 [lindex $new_nodes 1] - set new_link1 [linkByPeers $orig_node1 $new_node1] - set new_link2 [linkByPeers $orig_node2 $new_node2] - setLinkMirror $new_link1 $new_link2 - setLinkMirror $new_link2 $new_link1 - setNodeMirror $new_node1 $new_node2 - setNodeMirror $new_node2 $new_node1 - setNodeName $new_node1 $orig_node2 - setNodeName $new_node2 $orig_node1 - - set x1 [lindex [getNodeCoords $orig_node1] 0] - set y1 [lindex [getNodeCoords $orig_node1] 1] - set x2 [lindex [getNodeCoords $orig_node2] 0] - set y2 [lindex [getNodeCoords $orig_node2] 1] - - setNodeCoords $new_node1 \ - "[expr {($x1 + 0.4 * ($x2 - $x1)) / $zoom}] \ - [expr {($y1 + 0.4 * ($y2 - $y1)) / $zoom}]" - setNodeCoords $new_node2 \ - "[expr {($x1 + 0.6 * ($x2 - $x1)) / $zoom}] \ - [expr {($y1 + 0.6 * ($y2 - $y1)) / $zoom}]" - setNodeLabelCoords $new_node1 [getNodeCoords $new_node1] - setNodeLabelCoords $new_node2 [getNodeCoords $new_node2] - - set changed 1 - updateUndoLog - redrawAll -} - - -#****f* editor.tcl/selectNode -# NAME -# selectNode -- select node -# SYNOPSIS -# selectNode $c $obj -# FUNCTION -# Crates the selecting box around the specified canvas -# object. -# INPUTS -# * c -- tk canvas -# * obj -- tk canvas object tag id -#**** -proc selectNode { c obj } { - set node [lindex [$c gettags $obj] 1] - if { $node == "" } { return } ;# Boeing: fix occassional error - $c addtag selected withtag "node && $node" - if { [nodeType $node] == "pseudo" } { - set bbox [$c bbox "nodelabel && $node"] - } elseif { [nodeType $node] == "rectangle" } { - $c addtag selected withtag "rectangle && $node" - set bbox [$c bbox "rectangle && $node"] - } elseif { [nodeType $node] == "text" } { - $c addtag selected withtag "text && $node" - set bbox [$c bbox "text && $node"] - } elseif { [nodeType $node] == "oval" } { - $c addtag selected withtag "oval && $node" - set bbox [$c bbox "oval && $node"] - } else { - set bbox [$c bbox "node && $node"] - } - set bx1 [expr {[lindex $bbox 0] - 2}] - set by1 [expr {[lindex $bbox 1] - 2}] - set bx2 [expr {[lindex $bbox 2] + 1}] - set by2 [expr {[lindex $bbox 3] + 1}] - $c delete -withtags "selectmark && $node" - $c create line $bx1 $by1 $bx2 $by1 $bx2 $by2 $bx1 $by2 $bx1 $by1 \ - -dash {6 4} -fill black -width 1 -tags "selectmark $node" -} - -proc selectNodes { nodelist } { - foreach node $nodelist { - selectNode .c [.c find withtag "node && $node"] - } -} - -proc selectedNodes {} { - set selected {} - foreach obj [.c find withtag "node && selected"] { - lappend selected [lindex [.c gettags $obj] 1] - } - foreach obj [.c find withtag "oval && selected"] { - lappend selected [lindex [.c gettags $obj] 1] - } - foreach obj [.c find withtag "rectangle && selected"] { - lappend selected [lindex [.c gettags $obj] 1] - } - foreach obj [.c find withtag "text && selected"] { - lappend selected [lindex [.c gettags $obj] 1] - } - return $selected -} - -proc selectedRealNodes {} { - set selected {} - foreach obj [.c find withtag "node && selected"] { - set node [lindex [.c gettags $obj] 1] - if { [getNodeMirror $node] != "" || - [nodeType $node] == "rj45" } { - continue - } - lappend selected $node - } - return $selected -} - -proc selectAdjacent {} { - global curcanvas - - set selected [selectedNodes] - set adjacent {} - foreach node $selected { - foreach ifc [ifcList $node] { - set peer [peerByIfc $node $ifc] - if { [getNodeMirror $peer] != "" } { - return - } - if { [lsearch $adjacent $peer] < 0 } { - lappend adjacent $peer - } - } - } - selectNodes $adjacent -} - -#****f* editor.tcl/button3link -# NAME -# button3link -# SYNOPSIS -# button3link $c $x $y -# FUNCTION -# This procedure is called when a right mouse button is -# clicked on the canvas. If there is a link on the place of -# mouse click this procedure creates and configures a popup -# menu. The options in the menu are: -# * Configure -- configure the link -# * Delete -- delete the link -# * Split -- split the link -# * Merge -- this option is active only if the link is previously -# been split, by this action the link is merged. -# INPUTS -# * c -- tk canvas -# * x -- x coordinate for popup menu -# * y -- y coordinate for popup menu -#**** -proc button3link { c x y } { - global oper_mode env eid canvas_list node_list - global curcanvas - - set link [lindex [$c gettags {link && current}] 1] - if { $link == "" } { - set link [lindex [$c gettags {linklabel && current}] 1] - if { $link == "" } { - return - } - } - - .button3menu delete 0 end - - # - # Configure link - # - .button3menu add command -label "Configure" \ - -command "popupConfigDialog $c" - - # - # Delete link - # - if { $oper_mode != "exec" } { - .button3menu add command -label "Delete" \ - -command "removeGUILink $link atomic" - } else { - .button3menu add command -label "Delete" \ - -state disabled - } - - # - # Split link - # - if { $oper_mode != "exec" && [getLinkMirror $link] == "" } { - .button3menu add command -label "Split" \ - -command "splitGUILink $link" - } else { - .button3menu add command -label "Split" \ - -state disabled - } - - # - # Merge two pseudo nodes / links - # - if { $oper_mode != "exec" && [getLinkMirror $link] != "" && - [getNodeCanvas [getNodeMirror [lindex [linkPeers $link] 1]]] == - $curcanvas } { - .button3menu add command -label "Merge" \ - -command "mergeGUINode [lindex [linkPeers $link] 1]" - } else { - .button3menu add command -label "Merge" -state disabled - } - - set x [winfo pointerx .] - set y [winfo pointery .] - tk_popup .button3menu $x $y -} - - -#****f* editor.tcl/movetoCanvas -# NAME -# movetoCanvas -- move to canvas -# SYNOPSIS -# movetoCanvas $canvas -# FUNCTION -# This procedure moves all the nodes selected in the GUI to -# the specified canvas. -# INPUTS -# * canvas -- canvas id. -#**** -proc movetoCanvas { canvas } { - global changed - - set selected_nodes [selectedNodes] - foreach node $selected_nodes { - setNodeCanvas $node $canvas - set changed 1 - } - foreach obj [.c find withtag "linklabel"] { - set link [lindex [.c gettags $obj] 1] - set link_peers [linkPeers $link] - set peer1 [lindex $link_peers 0] - set peer2 [lindex $link_peers 1] - set peer1_in_selected [lsearch $selected_nodes $peer1] - set peer2_in_selected [lsearch $selected_nodes $peer2] - if { ($peer1_in_selected == -1 && $peer2_in_selected != -1) || - ($peer1_in_selected != -1 && $peer2_in_selected == -1) } { - if { [nodeType $peer2] == "pseudo" } { - setNodeCanvas $peer2 $canvas - if { [getNodeCanvas [getNodeMirror $peer2]] == $canvas } { - mergeLink $link - } - continue - } - set new_nodes [splitLink $link pseudo] - set new_node1 [lindex $new_nodes 0] - set new_node2 [lindex $new_nodes 1] - setNodeMirror $new_node1 $new_node2 - setNodeMirror $new_node2 $new_node1 - setNodeName $new_node1 $peer2 - setNodeName $new_node2 $peer1 - set link1 [linkByPeers $peer1 $new_node1] - set link2 [linkByPeers $peer2 $new_node2] - setLinkMirror $link1 $link2 - setLinkMirror $link2 $link1 - } - } - updateUndoLog - redrawAll -} - - -#****f* editor.tcl/mergeGUINode -# NAME -# mergeGUINode -- merge GUI node -# SYNOPSIS -# mergeGUINode $node -# FUNCTION -# This procedure removes the specified pseudo node as well -# as it's mirror copy. Also this procedure removes the -# pseudo links and reestablish the original link between -# the non-pseudo nodes. -# INPUTS -# * node -- node id of a pseudo node. -#**** -proc mergeGUINode { node } { - set link [lindex [linkByIfc $node [ifcList $node]] 0] - mergeLink $link - redrawAll -} - - -#****f* editor.tcl/button3node -# NAME -# button3node -# SYNOPSIS -# button3node $c $x $y -# FUNCTION -# This procedure is called when a right mouse button is -# clicked on the canvas. Also called when double-clicking -# on a node during runtime. -# If there is a node on the place of -# mouse click this procedure creates and configures a popup -# menu. The options in the menu are: -# * Configure -- configure the node -# * Create link to -- create a link to any available node, -# it can be on the same canvas or on a different canvas. -# * Move to -- move to some other canvas -# * Merge -- this option is available only for pseudo nodes -# that have mirror nodes on the same canvas (Pseudo nodes -# created by splitting a link). -# * Delete -- delete the node -# * Shell window -- specifies the shell window to open in -# exec mode. This option is available only to nodes on a -# network layer -# * Ethereal -- opens a Ethereal program for the specified -# node and the specified interface. This option is available -# only for network layer nodes in exec mode. -# INPUTS -# * c -- tk canvas -# * x -- x coordinate for popup menu -# * y -- y coordinate for popup menu -#**** -#old proc button3node { c x y } -#Boeing -proc button3node { c x y button } { - global oper_mode env eid canvas_list node_list curcanvas systype g_prefs - - set node [lindex [$c gettags {node && current}] 1] - if { $node == "" } { - set node [lindex [$c gettags {nodelabel && current}] 1] - if { $node == "" } { - return - } - } - set mirror_node [getNodeMirror $node] - - if { [$c gettags "node && $node && selected"] == "" } { - $c dtag node selected - $c delete -withtags selectmark - selectNode $c [$c find withtag "current"] - } - - # open up shells upon double-click or shift/ctrl-click - set shell $g_prefs(shell) - if { $button == "shift" || $button == "ctrl" } { - if { [nodeType $node] == "pseudo" } { - # - # Hyperlink to another canvas - # - set curcanvas [getNodeCanvas [getNodeMirror $node]] - switchCanvas none - return - } - # only open bash shells for NETWORK nodes and remote routers - if { [[typemodel $node].layer] != "NETWORK" } { - if { [typemodel $node] == "wlan" } { - wlanDoubleClick $node $button - } - return - } - if { $button == "shift" } { ;# normal bash shell - spawnShell $node $shell - } else { ;# right-click vtysh shell - set cmd [[typemodel $node].shellcmd $node] - if { $cmd != "/bin/sh" && $cmd != "" } { spawnShell $node $cmd } - } - return ;# open shell, don't post a menu - } - - # - # below here we build and post a menu - # - .button3menu delete 0 end - - # - # Configure node - # - if { [nodeType $node] != "pseudo" } { - .button3menu add command -label "Configure" \ - -command "popupConfigDialog $c" - } else { - .button3menu add command -label "Configure" \ - -command "popupConfigDialog $c" -state disabled - } - - # - # Select adjacent - # - if { [nodeType $node] != "pseudo" } { - .button3menu add command -label "Select adjacent" \ - -command "selectAdjacent" - } else { - .button3menu add command -label "Select adjacent" \ - -command "selectAdjacent" -state disabled - } - - # - # Create a new link - can be between different canvases - # - .button3menu.connect delete 0 end - if { $oper_mode == "exec" || [nodeType $node] == "pseudo" } { - #.button3menu add cascade -label "Create link to" \ - -menu .button3menu.connect -state disabled - } else { - .button3menu add cascade -label "Create link to" \ - -menu .button3menu.connect - } - destroy .button3menu.connect.selected - menu .button3menu.connect.selected -tearoff 0 - .button3menu.connect add cascade -label "Selected" \ - -menu .button3menu.connect.selected - .button3menu.connect.selected add command \ - -label "Chain" -command "P \[selectedRealNodes\]" - .button3menu.connect.selected add command \ - -label "Star" \ - -command "Kb \[lindex \[selectedRealNodes\] 0\] \ - \[lrange \[selectedNodes\] 1 end\]" - .button3menu.connect.selected add command \ - -label "Cycle" -command "C \[selectedRealNodes\]" - .button3menu.connect.selected add command \ - -label "Clique" -command "K \[selectedRealNodes\]" - .button3menu.connect add separator - foreach canvas $canvas_list { - destroy .button3menu.connect.$canvas - menu .button3menu.connect.$canvas -tearoff 0 - .button3menu.connect add cascade -label [getCanvasName $canvas] \ - -menu .button3menu.connect.$canvas - } - foreach peer_node $node_list { - set canvas [getNodeCanvas $peer_node] - if { $node != $peer_node && [nodeType $node] != "rj45" && - [lsearch {pseudo rj45} [nodeType $peer_node]] < 0 && - [ifcByLogicalPeer $node $peer_node] == "" } { - .button3menu.connect.$canvas add command \ - -label [getNodeName $peer_node] \ - -command "newGUILink $node $peer_node" - } elseif { [nodeType $peer_node] != "pseudo" } { - .button3menu.connect.$canvas add command \ - -label [getNodeName $peer_node] \ - -state disabled - } - } - # - # assign to emulation server - # - if { $oper_mode != "exec" } { - global exec_servers node_location - .button3menu.assign delete 0 end - .button3menu add cascade -label "Assign to" -menu .button3menu.assign - .button3menu.assign add command -label "(none)" \ - -command "assignSelection \"\"" - foreach server [lsort -dictionary [array names exec_servers]] { - .button3menu.assign add command -label "$server" \ - -command "assignSelection $server" - } - } - - # - # wlan link to all nodes - # - if { [nodeType $node] == "wlan" } { - .button3menu add command -label "Link to all routers" \ - -command "linkAllNodes $node" - set msg "Select new WLAN $node members:" - set cmd "linkSelectedNodes $node" - .button3menu add command -label "Select WLAN members..." \ - -command "popupSelectNodes \"$msg\" \"\" {$cmd}" - set state normal - if { $oper_mode != "exec" } { set state disabled } - .button3menu add command -label "Mobility script..." \ - -command "showMobilityScriptPopup $node" -state $state - } - - # - # Move to another canvas - # - .button3menu.moveto delete 0 end - if { $oper_mode != "exec" && [nodeType $node] != "pseudo" } { - .button3menu add cascade -label "Move to" \ - -menu .button3menu.moveto - .button3menu.moveto add command -label "Canvas:" -state disabled - foreach canvas $canvas_list { - if { $canvas != $curcanvas } { - .button3menu.moveto add command \ - -label [getCanvasName $canvas] \ - -command "movetoCanvas $canvas" - } else { - .button3menu.moveto add command \ - -label [getCanvasName $canvas] -state disabled - } - } - } - - # - # Merge two pseudo nodes / links - # - if { $oper_mode != "exec" && [nodeType $node] == "pseudo" && \ - [getNodeCanvas $mirror_node] == $curcanvas } { - .button3menu add command -label "Merge" \ - -command "mergeGUINode $node" - } - - # - # Delete selection - # - if { $oper_mode != "exec" } { - .button3menu add command -label "Cut" -command cutSelection - .button3menu add command -label "Copy" -command copySelection - .button3menu add command -label "Paste" -command pasteSelection - .button3menu add command -label "Delete" -command deleteSelection - } - - .button3menu add command -label "Hide" -command "hideSelected" - - # Boeing: flag used below - set execstate disabled - if { $oper_mode == "exec" } { set execstate normal } - - # - # Shell selection - # - .button3menu.shell delete 0 end - if { $oper_mode == "exec" && [[typemodel $node].layer] == "NETWORK" } { - .button3menu add cascade -label "Shell window" \ - -menu .button3menu.shell - set cmd [[typemodel $node].shellcmd $node] - if { $cmd != "/bin/sh" && $cmd != "" } { ;# typically adds vtysh - .button3menu.shell add command -label "$cmd" \ - -command "spawnShell $node $cmd" - } - .button3menu.shell add command -label "/bin/sh" \ - -command "spawnShell $node sh" - .button3menu.shell add command -label "$shell" \ - -command "spawnShell $node $shell" - } - - # - # services - # - .button3menu.services delete 0 end - if { $oper_mode == "exec" && [[typemodel $node].layer] == "NETWORK" } { - addServicesRightClickMenu .button3menu $node - } else { - .button3menu add command -label "Services..." -command \ - "sendConfRequestMessage -1 $node services 0x1 -1 \"\"" - } - - # - # Tcpdump, gpsd - # - if { $oper_mode == "exec" && [[typemodel $node].layer] == "NETWORK" } { - addInterfaceCommand $node .button3menu "Tcpdump" "tcpdump -n -l -i" \ - $execstate 1 - addInterfaceCommand $node .button3menu "TShark" "tshark -n -l -i" \ - $execstate 1 - addInterfaceCommand $node .button3menu "Wireshark" "wireshark -k -i" \ - $execstate 0 - # wireshark on host veth pair -- need veth pair name - #wireshark -k -i - if { [lindex $systype 0] == "Linux" } { - set name [getNodeName $node] - .button3menu add command -label "View log..." -state $execstate \ - -command "spawnShell $node \"less ../$name.log\"" - } - } - - # - # Finally post the popup menu on current pointer position - # - set x [winfo pointerx .] - set y [winfo pointery .] - - tk_popup .button3menu $x $y -} - - -#****f* editor.tcl/spawnShell -# NAME -# spawnShell -- spawn shell -# SYNOPSIS -# spawnShell $node $cmd -# FUNCTION -# This procedure spawns a new shell for a specified node. -# The shell is specified in cmd parameter. -# INPUTS -# * node -- node id of the node for which the shell -# is spawned. -# * cmd -- the path to the shell. -#**** -proc spawnShell { node cmd } { - # request an interactive terminal - set sock [lindex [getEmulPlugin $node] 2] - set flags 0x44 ;# set TTY, critical flags - set exec_num [newExecCallbackRequest shell] - sendExecMessage $sock $node $cmd $exec_num $flags -} - -# add a sub-menu to the parentmenu with the given command for each interface -proc addInterfaceCommand { node parentmenu txt cmd state isnodecmd } { - global g_current_session - set childmenu "$parentmenu.[lindex $cmd 0]" - $childmenu delete 0 end - $parentmenu add cascade -label $txt -menu $childmenu -state $state - if { ! $isnodecmd } { - if { $g_current_session == 0 } { set state disabled } - set ssid [shortSessionID $g_current_session] - } - foreach ifc [ifcList $node] { - set addr [lindex [getIfcIPv4addr $node $ifc] 0] - if { $addr != "" } { set addr " ($addr)" } - if { $isnodecmd } { ;# run command in a node - set icmd "spawnShell $node \"$cmd $ifc\"" - } else { ;# exec a command directly - set node_num [string range $node 1 end] - set hex [format "%x" $node_num] - set ifnum [string range $ifc 3 end] - set ifname "veth$hex\\.$ifnum\\.$ssid" - set icmd "exec $cmd $ifname &" - } - $childmenu add command -label "$ifc$addr" -state $state -command $icmd - } -} - -# Boeing: consolodate various raise statements here -proc raiseAll {c} { - $c raise rectangle background - $c raise oval "rectangle || background" - $c raise grid "oval || rectangle || background" - $c raise link "grid || oval || rectangle || background" - $c raise linklabel "link || grid || oval || rectangle || background" - $c raise newlink "linklabel || link || grid || oval || rectangle || background" - $c raise wlanlink "newlink || linklabel || link || grid || oval || rectangle || background" - $c raise antenna "wlanlink || newlink || linklabel || link || grid || oval || rectangle || background" - $c raise interface "antenna || wlanlink || newlink || linklabel || link || grid || oval || rectangle || background" - $c raise node "interface || antenna || wlanlink || newlink || linklabel || link || grid || oval || rectangle || background" - $c raise nodelabel "node || interface || antenna || wlanlink || newlink || linklabel || link || grid || oval || rectangle || background" - $c raise text "nodelabel || node || interface || antenna || wlanlink || newlink || linklabel || link || grid || oval || rectangle || background" - $c raise -cursor -} -# end Boeing - - -#****f* editor.tcl/button1 -# NAME -# button1 -# SYNOPSIS -# button1 $c $x $y $button -# FUNCTION -# This procedure is called when a left mouse button is -# clicked on the canvas. This procedure selects a new -# node or creates a new node, depending on the selected -# tool. -# INPUTS -# * c -- tk canvas -# * x -- x coordinate -# * y -- y coordinate -# * button -- the keyboard button that is pressed. -#**** -proc button1 { c x y button } { - global node_list plot_list curcanvas zoom - global activetool activetoolp newlink curobj changed def_router_model - global router pc host lanswitch rj45 hub - global oval rectangle text - global lastX lastY - global background selectbox - global defLinkColor defLinkWidth - global resizemode resizeobj - global wlan g_twoNodeSelect - global g_view_locked - - set x [$c canvasx $x] - set y [$c canvasy $y] - - set lastX $x - set lastY $y - - # TODO: clean this up - # - too many global variables - # - too many hardcoded cases (lanswitch, router, etc) - # - should be functionalized since lengthy if-else difficult to read - - set curobj [$c find withtag current] - set curtype [lindex [$c gettags current] 0] - - - if { $curtype == "node" || \ - $curtype == "oval" || $curtype == "rectangle" || $curtype == "text" \ - || ( $curtype == "nodelabel" && \ - [nodeType [lindex [$c gettags $curobj] 1]] == "pseudo") } { - set node [lindex [$c gettags current] 1] - set wasselected \ - [expr {[lsearch [$c find withtag "selected"] \ - [$c find withtag "node && $node"]] > -1}] - if { $button == "ctrl" } { - if { $wasselected } { - $c dtag $node selected - $c delete -withtags "selectmark && $node" - } - } elseif { !$wasselected } { - $c dtag node selected - $c delete -withtags selectmark - } - if { $activetool == "select" && !$wasselected} { - selectNode $c $curobj - } - } elseif { $curtype == "selectmark" } { - setResizeMode $c $x $y - } elseif { $activetool == "plot" } { - # plot tool: create new plot windows when clicking on a link - set link "" - set tags [$c gettags $curobj] - if { $curtype == "link" || $curtype == "linklabel" } { - set link [lindex $tags 1] - } elseif { $curtype == "interface" } { - set link [lindex $tags 2] - } - if { $link != "" } { - thruPlot $c $link $x $y 150 220 false - } - return - } elseif { $button != "ctrl" || $activetool != "select" } { - $c dtag node selected - $c delete -withtags selectmark - } - # user has clicked on a blank area or background item - if { [lsearch [.c gettags $curobj] background] != -1 || - [lsearch [.c gettags $curobj] grid] != -1 || - [lsearch [.c gettags $curobj] annotation] != -1 } { - # left mouse button pressed to create a new node - if { [lsearch {select marker link mobility twonode run stop oval \ - rectangle text} $activetool] < 0 } { - if { $g_view_locked == 1 } { return } - if { $activetoolp == "routers" } { - set node [newNode router] - setNodeModel $node $activetool - } else { - set node [newNode $activetool] - } - setNodeCanvas $node $curcanvas - setNodeCoords $node "[expr {$x / $zoom}] [expr {$y / $zoom}]" - lassign [getDefaultLabelOffsets $activetool] dx dy - setNodeLabelCoords $node "[expr {$x / $zoom + $dx}] \ - [expr {$y / $zoom + $dy}]" - drawNode $c $node - selectNode $c [$c find withtag "node && $node"] - set changed 1 - # remove any existing select box - } elseif { $activetool == "select" \ - && $curtype != "node" && $curtype != "nodelabel"} { - $c config -cursor cross - set lastX $x - set lastY $y - if {$selectbox != ""} { - # We actually shouldn't get here! - $c delete $selectbox - set selectbox "" - } - # begin drawing an annotation - } elseif { $activetoolp == "bgobjs" } { - set newcursor cross - if { $activetool == "text" } { set newcursor xterm } - $c config -cursor $newcursor - set lastX $x - set lastY $y - # draw with the marker - } elseif { $activetool == "marker" } { - global markersize markercolor - set newline [$c create oval $lastX $lastY $x $y \ - -width $markersize -outline $markercolor -tags "marker"] - $c raise $newline "background || link || linklabel || interface" - set lastX $x - set lastY $y - } - } else { - if {$curtype == "node" || $curtype == "nodelabel"} { - $c config -cursor fleur - } - if {$activetool == "link" && $curtype == "node"} { - $c config -cursor cross - set lastX [lindex [$c coords $curobj] 0] - set lastY [lindex [$c coords $curobj] 1] - set newlink [$c create line $lastX $lastY $x $y \ - -fill $defLinkColor -width $defLinkWidth \ - -tags "link"] - # twonode tool support - } elseif {$g_twoNodeSelect != "" && $curtype == "node"} { - set curnode [lindex [$c gettags $curobj] 1] - selectTwoNode $curnode - } elseif { $curtype == "node" } { - selectNode $c $curobj - } - # end Boeing - } - - raiseAll $c -} - -proc setResizeMode { c x y } { - set isThruplot false - set type1 notset - - if {$c == ".c"} { - set t1 [$c gettags current] - set o1 [lindex $t1 1] - set type1 [nodeType $o1] - } else { - set o1 $c - set c .c - set isThruplot true - } - #DYL - #puts "RESIZE NODETYPE = $type1" - global resizemode resizeobj - if {$type1== "oval" || $type1== "rectangle" || $isThruplot == true} { - set resizeobj $o1 - set bbox1 [$c bbox $o1] - set x1 [lindex $bbox1 0] - set y1 [lindex $bbox1 1] - set x2 [lindex $bbox1 2] - set y2 [lindex $bbox1 3] - set l 0 ;# left - set r 0 ;# right - set u 0 ;# up - set d 0 ;# down - - if { $x < [expr $x1+($x2-$x1)/8.0]} { set l 1 } - if { $x > [expr $x2-($x2-$x1)/8.0]} { set r 1 } - if { $y < [expr $y1+($y2-$y1)/8.0]} { set u 1 } - if { $y > [expr $y2-($y2-$y1)/8.0]} { set d 1 } - - if {$l==1} { - if {$u==1} { - set resizemode lu - } elseif {$d==1} { - set resizemode ld - } else { - set resizemode l - } - } elseif {$r==1} { - if {$u==1} { - set resizemode ru - } elseif {$d==1} { - set resizemode rd - } else { - set resizemode r - } - } elseif {$u==1} { - set resizemode u - } elseif {$d==1} { - set resizemode d - } else { - set resizemode false - } - } -} - - -#****f* editor.tcl/button1-motion -# NAME -# button1-motion -# SYNOPSIS -# button1-motion $c $x $y -# FUNCTION -# This procedure is called when a left mouse button is -# pressed and the mouse is moved around the canvas. -# This procedure creates new select box, moves the -# selected nodes or draws a new link. -# INPUTS -# * c -- tk canvas -# * x -- x coordinate -# * y -- y coordinate -#**** -proc button1-motion { c x y } { - global activetool newlink changed - global lastX lastY sizex sizey selectbox background - global oper_mode newoval newrect resizemode - global zoom - global g_view_locked - global thruPlotCur thruPlotDragStart - - set x [$c canvasx $x] - set y [$c canvasy $y] - - if {$thruPlotDragStart == "dragging"} { - #puts "active tool is $activetool" - thruPlotDrag $c $thruPlotCur $x $y null true - return - } - - # fix occasional error - if { $x == "" || $y == "" || $lastX == "" || $lastY == "" } { return } - - set curobj [$c find withtag current] - set curtype [lindex [$c gettags current] 0] - - # display coordinates in the status bar - set zoomx [expr {$x / $zoom}] - set zoomy [expr {$y / $zoom}] - .bottom.textbox config -text "<$zoomx, $zoomy>" - - # prevent dragging outside of the canvas area - if { $x < 0 } { - set x 0 - } elseif { $x > $sizex } { - set x $sizex - } - if { $y < 0 } { - set y 0 - } elseif { $y > $sizey } { - set y $sizey - } - - # marker tool drawing on the canvas - if { $activetool == "marker" } { - global markersize markercolor - set dx [expr {$x-$lastX} ] - set dy [expr {$y-$lastY} ] - # this provides smoother drawing - if { $dx > $markersize || $dy > $markersize } { - set mark [$c create line $lastX $lastY $x $y \ - -width $markersize -fill $markercolor -tags "marker"] - $c raise $mark \ - "marker || background || link || linklabel || interface" - } - set mark [$c create oval $x $y $x $y \ - -width $markersize -fill $markercolor \ - -outline $markercolor -tags "marker"] - $c raise $mark "marker || background || link || linklabel || interface" - set lastX $x - set lastY $y - return - } - # disable all other mouse drags in locked mode - if { $g_view_locked == 1 } { return } - - # don't move nodelabels in exec mode, use calcx,y instead of x,y - if {$oper_mode == "exec" && $curtype == "nodelabel" } { - set node [lindex [$c gettags $curobj] 1] - set curobj [$c find withtag "node && $node"] - set curtype "node" - set coords [$c coords $curobj] - set calcx [expr {[lindex $coords 0] / $zoom}] - set calcy [expr {[lindex $coords 1] / $zoom}] - selectNode $c $curobj - } else { - set calcx $x - set calcy $y - } - # drawing a new link - if {$activetool == "link" && $newlink != ""} { - $c coords $newlink $lastX $lastY $x $y - # draw a selection box - } elseif { $activetool == "select" && \ - ( $curobj == $selectbox || $curtype == "background" || $curtype == "grid")} { - if {$selectbox == ""} { - set selectbox [$c create line \ - $lastX $lastY $x $lastY $x $y $lastX $y $lastX $lastY \ - -dash {10 4} -fill black -width 1 -tags "selectbox"] - $c raise $selectbox "background || link || linklabel || interface" - } else { - $c coords $selectbox \ - $lastX $lastY $x $lastY $x $y $lastX $y $lastX $lastY - } - # move a text annotation - } elseif { $activetool == "select" && $curtype == "text" } { - $c move $curobj [expr {$x - $lastX}] [expr {$y - $lastY}] - set changed 1 - set lastX $x - set lastY $y - $c delete [$c find withtag "selectmark"] - # move a nodelabel apart from a node (edit mode only) - } elseif { $activetool == "select" && $curtype == "nodelabel" \ - && [nodeType [lindex [$c gettags $curobj] 1]] != "pseudo" } { - $c move $curobj [expr {$x - $lastX}] [expr {$y - $lastY}] - set changed 1 - set lastX $x - set lastY $y - # actually we should check if curobj==bkgImage - # annotations - } elseif { $activetool == "oval" && \ - ( $curobj == $newoval || $curobj == $background || $curtype == "background" || $curtype == "grid")} { - # Draw a new oval - if {$newoval == ""} { - set newoval [$c create oval $lastX $lastY $x $y \ - -dash {10 4} -width 1 -tags "newoval"] - $c raise $newoval "background || link || linklabel || interface" - } else { - $c coords $newoval \ - $lastX $lastY $x $y - } - # actually we should check if curobj==bkgImage - } elseif { $activetool == "rectangle" && \ - ( $curobj == $newrect || $curobj == $background || $curtype == "background" || $curtype == "grid")} { - # Draw a new rectangle - if {$newrect == ""} { - set newrect [$c create rectangle $lastX $lastY $x $y \ - -outline blue \ - -dash {10 4} -width 1 -tags "newrect"] - $c raise $newrect "oval || background || link || linklabel || interface" - } else { - $c coords $newrect $lastX $lastY $x $y - } - # resizing an annotation - } elseif { $curtype == "selectmark" } { - foreach o [$c find withtag "selected"] { - set node [lindex [$c gettags $o] 1] - set tagovi [$c gettags $o] - set koord [getNodeCoords $node] - - set oldX1 [lindex $koord 0] - set oldY1 [lindex $koord 1] - set oldX2 [lindex $koord 2] - set oldY2 [lindex $koord 3] - switch -exact -- $resizemode { - lu { - set oldX1 $x - set oldY1 $y - } - ld { - set oldX1 $x - set oldY2 $y - } - l { - set oldX1 $x - } - ru { - set oldX2 $x - set oldY1 $y - } - rd { - set oldX2 $x - set oldY2 $y - } - r { - set oldX2 $x - } - u { - set oldY1 $y - } - d { - set oldY2 $y - } - } - if {$selectbox == ""} { - # Boeing: fix "bad screen distance" error - if { $oldX1 == "" || $oldX2 == "" || $oldY1 == "" || \ - $oldY2 == "" } { return } - # end Boeing - set selectbox [$c create line \ - $oldX1 $oldY1 $oldX2 $oldY1 $oldX2 $oldY2 $oldX1 \ - $oldY2 $oldX1 $oldY1 \ - -dash {10 4} -fill black -width 1 -tags "selectbox"] - $c raise $selectbox \ - "background || link || linklabel || interface" - } else { - $c coords $selectbox \ - $oldX1 $oldY1 $oldX2 $oldY1 $oldX2 $oldY2 $oldX1 \ - $oldY2 $oldX1 $oldY1 - } - } - # selected node(s) are being moved - } else { - foreach img [$c find withtag "selected"] { - set node [lindex [$c gettags $img] 1] - set newcoords [$c coords $img] ;# different than getNodeCoords - set img [$c find withtag "selectmark && $node"] - if {$curtype == "oval" || $curtype == "rectangle"} { - $c move $img [expr {($x - $lastX) / 2}] \ - [expr {($y - $lastY) / 2}] - } else { - $c move $img [expr {$x - $lastX}] [expr {$y - $lastY}] - set img [$c find withtag "node && $node"] - $c move $img [expr {$x - $lastX}] [expr {$y - $lastY}] - set img [$c find withtag "nodelabel && $node"] - $c move $img [expr {$x - $lastX}] [expr {$y - $lastY}] - set img [$c find withtag "twonode && $node"] - if {$img != "" } {; # move Two Node Tool circles around node - $c move $img [expr {$x - $lastX}] [expr {$y - $lastY}] - }; - set img [$c find withtag "rangecircles && $node"] - if {$img != "" } {; # move throughput circles around node - $c move $img [expr {$x - $lastX}] [expr {$y - $lastY}] - }; - $c addtag need_redraw withtag "link && $node" - } - if { $oper_mode == "exec" } { - set newx [expr {[lindex $newcoords 0] / $zoom}] - set newy [expr {[lindex $newcoords 1] / $zoom}] - sendNodePosMessage -1 $node -1 $newx $newy -1 0 - } - $c addtag need_redraw withtag "wlanlink && $node" - widgets_move_node $c $node 0 - } - foreach link [$c find withtag "link && need_redraw"] { - redrawLink [lindex [$c gettags $link] 1] - } - foreach wlanlink [$c find withtag "wlanlink && need_redraw"] { - redrawWlanLink $wlanlink - } - $c dtag wlanlink need_redraw - $c dtag link need_redraw - set changed 1 - set lastX $x - set lastY $y - } -} - - -#****f* editor.tcl/pseudo.layer -# NAME -# pseudo.layer -# SYNOPSIS -# set layer [pseudo.layer] -# FUNCTION -# Returns the layer on which the pseudo node operates -# i.e. returns no layer. -# RESULT -# * layer -- returns an empty string -#**** -proc pseudo.layer {} { -} - - -#****f* editor.tcl/newGUILink -# NAME -# newGUILink -- new GUI link -# SYNOPSIS -# newGUILink $lnode1 $lnode2 -# FUNCTION -# This procedure is called to create a new link between -# nodes lnode1 and lnode2. Nodes can be on the same canvas -# or on different canvases. The result of this function -# is directly visible in GUI. -# INPUTS -# * lnode1 -- node id of the first node -# * lnode2 -- node id of the second node -#**** -proc newGUILink { lnode1 lnode2 } { - global changed - - set link [newLink $lnode1 $lnode2] - if { $link == "" } { - return - } - if { [getNodeCanvas $lnode1] != [getNodeCanvas $lnode2] } { - set new_nodes [splitLink $link pseudo] - set orig_nodes [linkPeers $link] - set new_node1 [lindex $new_nodes 0] - set new_node2 [lindex $new_nodes 1] - set orig_node1 [lindex $orig_nodes 0] - set orig_node2 [lindex $orig_nodes 1] - set new_link1 [linkByPeers $orig_node1 $new_node1] - set new_link2 [linkByPeers $orig_node2 $new_node2] - setNodeMirror $new_node1 $new_node2 - setNodeMirror $new_node2 $new_node1 - setNodeName $new_node1 $orig_node2 - setNodeName $new_node2 $orig_node1 - setLinkMirror $new_link1 $new_link2 - setLinkMirror $new_link2 $new_link1 - } - redrawAll - set changed 1 - updateUndoLog -} - - -#****f* editor.tcl/button1-release -# NAME -# button1-release -# SYNOPSIS -# button1-release $c $x $y -# FUNCTION -# This procedure is called when a left mouse button is -# released. -# The result of this function depends on the actions -# during the button1-motion procedure. -# INPUTS -# * c -- tk canvas -# * x -- x coordinate -# * y -- y coordinate -#**** -proc button1-release { c x y } { - global node_list plot_list activetool newlink curobj grid - global changed undolog undolevel redolevel selectbox - global lastX lastY sizex sizey zoom - global autorearrange_enabled - global resizemode resizeobj - set redrawNeeded 0 - global oper_mode - global g_prefs - global g_view_locked - - set x [$c canvasx $x] - set y [$c canvasy $y] - - $c config -cursor left_ptr - # place a new link between items - if {$activetool == "link" && $newlink != ""} { - if { $g_view_locked == 1 } { return } - $c delete $newlink - set newlink "" - set destobj "" - foreach obj [$c find overlapping $x $y $x $y] { - if {[lindex [$c gettags $obj] 0] == "node"} { - set destobj $obj - break - } - } - if {$destobj != "" && $curobj != "" && $destobj != $curobj} { - set lnode1 [lindex [$c gettags $curobj] 1] - set lnode2 [lindex [$c gettags $destobj] 1] - if { [ifcByLogicalPeer $lnode1 $lnode2] == "" } { - set link [newLink $lnode1 $lnode2] - if { $link != "" } { - drawLink $link - redrawLink $link - updateLinkLabel $link - set changed 1 - } - } - } - # annotations - } elseif {$activetool == "rectangle" || $activetool == "oval" } { - if { $g_view_locked == 1 } { return } - popupAnnotationDialog $c 0 "false" - # edit text annotation - } elseif {$activetool == "text" } { - if { $g_view_locked == 1 } { return } - textEnter $c $x $y - } - - if { $changed == 1 } { - set regular true - if { [lindex [$c gettags $curobj] 0] == "nodelabel" } { - set node [lindex [$c gettags $curobj] 1] - selectNode $c [$c find withtag "node && $node"] - } - set selected {} - foreach img [$c find withtag "selected"] { - set node [lindex [$c gettags $img] 1] - lappend selected $node - set coords [$c coords $img] - set x [expr {[lindex $coords 0] / $zoom}] - set y [expr {[lindex $coords 1] / $zoom}] - if { $autorearrange_enabled == 0 && $g_prefs(gui_snap_grid)} { - set dx [expr {(int($x / $grid + 0.5) * $grid - $x) * $zoom}] - set dy [expr {(int($y / $grid + 0.5) * $grid - $y) * $zoom}] - $c move $img $dx $dy - set coords [$c coords $img] - set x [expr {[lindex $coords 0] / $zoom}] - set y [expr {[lindex $coords 1] / $zoom}] - } else { - set dx 0 - set dy 0 - } - if {$x < 0 || $y < 0 || $x > $sizex || $y > $sizey} { - set regular false - } - # nodes with four coordinates - if { [lindex [$c gettags $node] 0] == "oval" || - [lindex [$c gettags $node] 0] == "rectangle" } { - set bbox [$c bbox "selectmark && $node"] - # Boeing: bbox causes annotations to grow, subtract 5 - if { [llength $bbox] > 3 } { - set x1 [lindex $bbox 0] - set y1 [lindex $bbox 1] - set x2 [expr {[lindex $bbox 2] - 5}] - set y2 [expr {[lindex $bbox 3] - 5}] - setNodeCoords $node "$x1 $y1 $x2 $y2" - set redrawNeeded 1 - if {$x1 < 0 || $y1 < 0 || $x1 > $sizex || $y1 > $sizey || \ - $x2 < 0 || $y2 < 0 || $x2 > $sizex || $y2 > $sizey} { - set regular false - } - } - # nodes with two coordinates - } else { - setNodeCoords $node "$x $y" - } - if {[$c find withtag "nodelabel && $node"] != "" } { - $c move "nodelabel && $node" $dx $dy - set coords [$c coords "nodelabel && $node"] - set x [expr {[lindex $coords 0] / $zoom}] - set y [expr {[lindex $coords 1] / $zoom}] - setNodeLabelCoords $node "$x $y" - if {$x < 0 || $y < 0 || $x > $sizex || $y > $sizey} { - set regular false - } - } - $c move "selectmark && $node" $dx $dy - $c addtag need_redraw withtag "link && $node" - set changed 1 - if { $oper_mode == "exec" } { - # send node position update using x,y stored in node - set xy [getNodeCoords $node] ;# read new coordinates - sendNodePosMessage -1 $node -1 [lindex $xy 0] [lindex $xy 1] \ - -1 0 - widgets_move_node $c $node 1 - } - $c addtag need_redraw withtag "wlanlink && $node" - } ;# end of: foreach img selected - if {$regular == "true"} { - # user has dragged something within the canvas boundaries - foreach link [$c find withtag "link && need_redraw"] { - redrawLink [lindex [$c gettags $link] 1] - } - } else { - # user has dragged something beyond the canvas boundaries - .c config -cursor watch - loadCfg $undolog($undolevel) - redrawAll - if {$activetool == "select" } { - selectNodes $selected - } - set changed 0 - } - $c dtag link need_redraw - nodeEnter $c - - # $changed!=1 - } elseif {$activetool == "select" } { - if {$selectbox == ""} { - set x1 $x - set y1 $y - rearrange_off - } else { - set coords [$c coords $selectbox] - set x [lindex $coords 0] - set y [lindex $coords 1] - set x1 [lindex $coords 4] - set y1 [lindex $coords 5] - $c delete $selectbox - set selectbox "" - } - - if { $resizemode == "false" } { - # select tool mouse button release while drawing select box - set enclosed {} - # fix occasional error - if { $x == "" || $y == "" || $x1 == "" || $y1 == "" } { return } - foreach obj [$c find enclosed $x $y $x1 $y1] { - set tags [$c gettags $obj] - if {[lindex $tags 0] == "node" && [lsearch $tags selected] == -1} { - lappend enclosed $obj - } - if {[lindex $tags 0] == "oval" && [lsearch $tags selected] == -1} { - lappend enclosed $obj - } - if {[lindex $tags 0] == "rectangle" && [lsearch $tags selected] == -1} { - lappend enclosed $obj - } - if {[lindex $tags 0] == "text" && [lsearch $tags selected] == -1} { - lappend enclosed $obj - } - } - foreach obj $enclosed { - selectNode $c $obj - } - } else { - # select tool resizing an object by dragging its handles - # DYL bugfix. if x,y does not change, do not resize! - # fixes a bug where the object dissappears - if { $x != $x1 || $y != $y1 } { - setNodeCoords $resizeobj "$x $y $x1 $y1" - } - set redrawNeeded 1 - set resizemode false - } - } - - if { $redrawNeeded } { - set redrawNeeded 0 - redrawAll - } else { - raiseAll $c - } - update - updateUndoLog -} - - -#****f* editor.tcl/nodeEnter -# NAME -# nodeEnter -# SYNOPSIS -# nodeEnter $c -# FUNCTION -# This procedure prints the node id, node name and -# node model (if exists), as well as all the interfaces -# of the node in the status line. -# Information is presented for the node above which is -# the mouse pointer. -# INPUTS -# * c -- tk canvas -#**** -proc nodeEnter { c } { - global activetool - - set curtags [$c gettags current] - if { [lsearch -exact "node nodelabel" [lindex $curtags 0]] < 0 } { - return ;# allow this proc to be called from button1-release - } - set node [lindex $curtags 1] - set type [nodeType $node] - set name [getNodeName $node] - set model [getNodeModel $node] - if { $model != "" } { - set line "{$node} $name ($model):" - } else { - set line "{$node} $name:" - } - if { $type != "rj45" && $type != "tunnel" } { - foreach ifc [ifcList $node] { - set line "$line $ifc:[getIfcIPv4addr $node $ifc]" - } - } - set xy [getNodeCoords $node] - set line "$line <[lindex $xy 0], [lindex $xy 1]>" - .bottom.textbox config -text "$line" - widgetObserveNode $c $node -} - - -#****f* editor.tcl/linkEnter -# NAME -# linkEnter -# SYNOPSIS -# linkEnter $c -# FUNCTION -# This procedure prints the link id, link bandwidth -# and link delay in the status line. -# Information is presented for the link above which is -# the mouse pointer. -# INPUTS -# * c -- tk canvas -#**** -proc linkEnter {c} { - global activetool link_list - - set link [lindex [$c gettags current] 1] - if { [lsearch $link_list $link] == -1 } { - return - } - set line "$link: [getLinkBandwidthString $link] [getLinkDelayString $link]" - .bottom.textbox config -text "$line" -} - - -#****f* editor.tcl/anyLeave -# NAME -# anyLeave -# SYNOPSIS -# anyLeave $c -# FUNCTION -# This procedure clears the status line. -# INPUTS -# * c -- tk canvas -#**** -proc anyLeave {c} { - global activetool - - .bottom.textbox config -text "" -# Boeing - widgetObserveNode $c "" -# nodeHighlights $c "" off "" -# end Boeing -} - - -#****f* editor.tcl/checkIntRange -# NAME -# checkIntRange -- check integer range -# SYNOPSIS -# set check [checkIntRange $str $low $high] -# FUNCTION -# This procedure checks the input string to see if it is -# an integer between the low and high value. -# INPUTS -# str -- string to check -# low -- the bottom value -# high -- the top value -# RESULT -# * check -- set to 1 if the str is string between low and high -# value, 0 otherwise. -#**** -proc checkIntRange { str low high } { - if { $str == "" } { - return 1 - } - set str [string trimleft $str 0] - if { $str == "" } { - set str 0 - } - if { ![string is integer $str] } { - return 0 - } - if { $str < $low || $str > $high } { - return 0 - } - return 1 -} - -proc checkFloatRange { str low high } { - if { $str == "" } { - return 1 - } - set str [string trimleft $str 0] - if { $str == "" } { - set str 0 - } - if { ![string is double $str] } { - return 0 - } - if { $str < $low || $str > $high } { - return 0 - } - return 1 -} - -proc checkHostname { str } { - # per RFC 952 and RFC 1123, any letter, number, or hyphen - return [regexp {^[A-Za-z0-9-]+$} $str] -} - - -#****f* editor.tcl/focusAndFlash -# NAME -# focusAndFlash -- focus and flash -# SYNOPSIS -# focusAndFlash $W $count -# FUNCTION -# This procedure sets the focus on the bad entry field -# and on this filed it provides an effect of flashing -# for approximately 1 second. -# INPUTS -# * W -- textbox field that caused the bed entry -# * count -- the parameter that causes flashes. -# It can be left blank. -#**** -proc focusAndFlash {W {count 9}} { - global badentry - - set fg black - set bg white - - if { $badentry == -1 } { - return - } else { - set badentry 1 - } - - focus -force $W - if {$count<1} { - $W configure -foreground $fg -background $bg - set badentry 0 - } else { - if {$count%2} { - $W configure -foreground $bg -background $fg - } else { - $W configure -foreground $fg -background $bg - } - after 200 [list focusAndFlash $W [expr {$count - 1}]] - } -} - - -#****f* editor.tcl/popupConfigDialog -# NAME -# popupConfigDialog -- popup Configuration Dialog Box -# SYNOPSIS -# popupConfigDialog $c -# FUNCTION -# Dynamically creates a popup dialog box for configuring -# links or nodes in IMUNES. -# INPUTS -# * c -- canvas id -#**** -proc popupConfigDialog { c } { - global activetool router_model link_color oper_mode - global badentry curcanvas - global node_location systype - global plugin_img_del - set type "" - - set wi .popup - if { [winfo exists $wi ] } { - return - } - catch {destroy $wi} - toplevel $wi - - wm transient $wi . - wm resizable $wi 1 1 - - set object_type "" - set tk_type [lindex [$c gettags current] 0] - set target [lindex [$c gettags current] 1] - if { [lsearch {node nodelabel interface} $tk_type] > -1 } { - set object_type node - } - if { [lsearch {link linklabel} $tk_type] > -1 } { - set object_type link - } - if { [lsearch {oval} $tk_type] > -1 } { - set object_type oval - } - if { [lsearch {rectangle} $tk_type] > -1 } { - set object_type rectangle - } - if { [lsearch {text} $tk_type] > -1 } { - set object_type text - } - if { "$object_type" == ""} { - destroy $wi - return - } - if { $object_type == "link" } { - set n0 [lindex [linkPeers $target] 0] - set n1 [lindex [linkPeers $target] 1] - # Boeing: added tunnel check - #if { [nodeType $n0] == "rj45" || [nodeType $n1] == "rj45" || \ - # [nodeType $n0] == "tunnel" || [nodeType $n1] == "tunnel" } { - # destroy $wi - # return - #} - } - $c dtag node selected - $c delete -withtags selectmark - - switch -exact -- $object_type { - node { - set type [nodeType $target] - if { $type == "pseudo" } { - # - # Hyperlink to another canvas - # - destroy $wi - set curcanvas [getNodeCanvas [getNodeMirror $target]] - switchCanvas none - return - } - set model [getNodeModel $target] - set router_model $model - wm title $wi "$type configuration" - ttk::frame $wi.ftop -borderwidth 4 - ttk::entry $wi.ftop.name -width 16 \ - -validate focus -invalidcommand "focusAndFlash %W" - if { $type == "rj45" } { - ttk::label $wi.ftop.name_label -text "Physical interface:" - } elseif { $type == "tunnel" } { - ttk::label $wi.ftop.name_label -text "IP address of tunnel peer:" - } else { - ttk::label $wi.ftop.name_label -text "Node name:" - $wi.ftop.name configure -validatecommand {checkHostname %P} - } - $wi.ftop.name insert 0 [getNodeName $target] - set img [getNodeImage $target] - ttk::button $wi.ftop.img -image $img -command "popupCustomImage $target" - - if { $type == "rj45" } { - rj45ifclist $wi $target 0 - } - # execution server - global exec_servers node_location - set node_location [getNodeLocation $target] - set servers [lsort -dictionary [array names exec_servers]] - set servers "(none) $servers" - if { $node_location == "" } { set node_location "(none)" } - eval tk_optionMenu $wi.ftop.menu node_location $servers - pack $wi.ftop.img $wi.ftop.menu $wi.ftop.name $wi.ftop.name_label \ - -side right -padx 4 -pady 4 - # end Boeing - pack $wi.ftop -side top - if { $type == "router" } { - - ttk::frame $wi.model -borderwidth 4 - ttk::label $wi.model.label -text "Type:" - set runstate "disabled" - if { $oper_mode == "edit" } { - eval tk_optionMenu $wi.model.menu router_model \ - [getNodeTypeNames] - set runstate "normal" - } else { - tk_optionMenu $wi.model.menu router_model $model - } - # would be nice to update the image upon selection; binding to - # will not work - #tkwait variable router_model "customImageApply $wi $target" - set sock [lindex [getEmulPlugin $target] 2] - ttk::button $wi.model.services -text "Services..." -state $runstate \ - -command \ - "sendConfRequestMessage $sock $target services 0x1 -1 \"\"" - pack $wi.model.services $wi.model.menu $wi.model.label \ - -side right -padx 0 -pady 0 - pack $wi.model -side top - } - - if { $type == "wlan" } { - wlanConfigDialogHelper $wi $target 0 - } elseif { $type == "tunnel" } { - # - # tunnel controls - # - ttk::frame $wi.con2 - global conntap - set conntap [netconfFetchSection $target "tunnel-tap"] - if { $conntap == "" } { set conntap off } - # TODO: clean this up - ttk::radiobutton $wi.con2.dotap0 \ - -variable conntap -value off \ - -text "tunnel to another CORE emulation" - ttk::frame $wi.con2.key - ttk::label $wi.con2.key.lab -text "GRE key:" - ttk::entry $wi.con2.key.key -width 6 - ttk::radiobutton $wi.con2.dotap1 -state disabled \ - -variable conntap -value on \ - -text "tunnel to the virtual TAP interface of another system" - pack $wi.con2.key.lab $wi.con2.key.key -side left - pack $wi.con2.dotap0 -side top -anchor w - pack $wi.con2.key -side top - pack $wi.con2.dotap1 -side top -anchor w - pack $wi.con2 -side top - set key [netconfFetchSection $target "tunnel-key"] - if { $key == "" } { set key 1 } - $wi.con2.key.key insert 0 $key - - # TODO: clean this up - ttk::frame $wi.conn - ttk::label $wi.conn.label -text "Transport type:" - tk_optionMenu $wi.conn.conntype conntype "UDP" "TCP" - $wi.conn.conntype configure -state disabled - pack $wi.conn.label $wi.conn.conntype -side left -anchor w - pack $wi.conn -side top - global conntype - set conntype [netconfFetchSection $target "tunnel-type"] - if { $conntype == "" } { set conntype "UDP" } - - - # TODO: clean this up - ttk::frame $wi.linfo - ttk::label $wi.linfo.label -text "Local hook:" - ttk::entry $wi.linfo.local -state disabled - set localhook [netconfFetchSection $target "local-hook"] - if { $localhook == "" || $localhook == "(none)" } { - # automatically generate local hook name - set ifc [lindex [ifcList $target] 0] - if { $ifc != "" } { - set hname [info hostname] - set peer [peerByIfc $target $ifc] - set localhook "$hname$peer" - } else { - set localhook "(none)" - } - } - $wi.linfo.local insert 0 $localhook - pack $wi.linfo.label $wi.linfo.local -side left -anchor w - pack $wi.linfo -side top - - ttk::frame $wi.pinfo - ttk::label $wi.pinfo.label -text "Peer hook:" - ttk::entry $wi.pinfo.peer -state disabled - $wi.pinfo.peer insert 0 \ - [netconfFetchSection $target "peer-hook"] - pack $wi.pinfo.label $wi.pinfo.peer -side left -anchor w - pack $wi.pinfo -side top - } - - # interface list - if { [[typemodel $target].layer] == "NETWORK" } { - # canvas used for scrolling frames for each interface - ttk::frame $wi.ifaces - set height [expr {100 * [llength [ifcList $target]]}] - if { $height > 300 } { set height 300 } - canvas $wi.ifaces.c -height $height -highlightthickness 0 \ - -yscrollcommand "$wi.ifaces.scroll set" - scrollbar $wi.ifaces.scroll -command "$wi.ifaces.c yview" - pack $wi.ifaces.c -side left -fill both -expand 1 - pack $wi.ifaces.scroll -side right -fill y - pack $wi.ifaces -side top -fill both -expand 1 - set y 0 - - foreach ifc [lsort -ascii [ifcList $target]] { - set fr $wi.ifaces.c.if$ifc - ttk::labelframe $fr -text "Interface $ifc" - $wi.ifaces.c create window 4 $y -window $fr -anchor nw - incr y 100 - - set peer [peerByIfc $target $ifc] - if { [isEmane $peer] } { - ttk::frame $fr.opts - set caps [getCapabilities $peer "mobmodel"] - set cap [lindex $caps 0] - set cmd "sendConfRequestMessage -1 $target $cap 0x1 -1 \"\"" - ttk::button $fr.opts.cfg -command $cmd \ - -text "$cap options..." - pack $fr.opts.cfg -side left -padx 4 - pack $fr.opts -side top -anchor w - incr y 28 - } - - ttk::frame $fr.cfg - # - # MAC address - # - ttk::frame $fr.cfg.mac - ttk::label $fr.cfg.mac.addrl -text "MAC address" \ - -anchor w - set macaddr [getIfcMacaddr $target $ifc] - global if${ifc}_auto_mac - if { $macaddr == "" } { - set if${ifc}_auto_mac 1 - set state disabled - } else { - set if${ifc}_auto_mac 0 - set state normal - } - ttk::checkbutton $fr.cfg.mac.auto -text "auto-assign" \ - -variable if${ifc}_auto_mac \ - -command "macEntryHelper $wi $ifc" - ttk::entry $fr.cfg.mac.addrv -width 15 \ - -state $state - $fr.cfg.mac.addrv insert 0 $macaddr - pack $fr.cfg.mac.addrl $fr.cfg.mac.auto \ - $fr.cfg.mac.addrv -side left -padx 4 - pack $fr.cfg.mac -side top -anchor w - - # - # IPv4 address - # - ttk::frame $fr.cfg.ipv4 - ttk::label $fr.cfg.ipv4.addrl -text "IPv4 address" \ - -anchor w - ttk::entry $fr.cfg.ipv4.addrv -width 30 \ - -validate focus -invalidcommand "focusAndFlash %W" - $fr.cfg.ipv4.addrv insert 0 \ - [getIfcIPv4addr $target $ifc] - $fr.cfg.ipv4.addrv configure \ - -validatecommand {checkIPv4Net %P} - ttk::button $fr.cfg.ipv4.clear -image $plugin_img_del \ - -command "$fr.cfg.ipv4.addrv delete 0 end" - pack $fr.cfg.ipv4.addrl $fr.cfg.ipv4.addrv \ - $fr.cfg.ipv4.clear -side left - pack $fr.cfg.ipv4 -side top -anchor w -padx 4 - - # - # IPv6 address - # - ttk::frame $fr.cfg.ipv6 - ttk::label $fr.cfg.ipv6.addrl -text "IPv6 address" \ - -anchor w - ttk::entry $fr.cfg.ipv6.addrv -width 30 \ - -validate focus -invalidcommand "focusAndFlash %W" - $fr.cfg.ipv6.addrv insert 0 \ - [getIfcIPv6addr $target $ifc] - $fr.cfg.ipv6.addrv configure -validatecommand {checkIPv6Net %P} - ttk::button $fr.cfg.ipv6.clear -image $plugin_img_del \ - -command "$fr.cfg.ipv6.addrv delete 0 end" - pack $fr.cfg.ipv6.addrl $fr.cfg.ipv6.addrv \ - $fr.cfg.ipv6.clear -side left - pack $fr.cfg.ipv6 -side top -anchor w -padx 4 - pack $fr.cfg -side left - bind $fr.cfg <4> "$wi.ifaces.c yview scroll -1 units" - bind $fr.cfg <5> "$wi.ifaces.c yview scroll 1 units" - } ;# end foreach ifc - $wi.ifaces.c configure -scrollregion "0 0 250 $y" - # mouse wheel bindings for scrolling - foreach ctl [list $wi.ifaces.c $wi.ifaces.scroll] { - bind $ctl <4> "$wi.ifaces.c yview scroll -1 units" - bind $ctl <5> "$wi.ifaces.c yview scroll 1 units" - bind $ctl "$wi.ifaces.c yview scroll -1 units" - bind $ctl "$wi.ifaces.c yview scroll 1 units" - } - } - } - oval { - destroy $wi - annotationConfig $c $target - return - } - rectangle { - destroy $wi - annotationConfig $c $target - return - } - text { - destroy $wi - annotationConfig $c $target - return - } - link { - wm title $wi "link configuration" - ttk::frame $wi.ftop -borderwidth 6 - set nam0 [getNodeName $n0] - set nam1 [getNodeName $n1] - ttk::label $wi.ftop.name_label -justify left -text \ - "Link from $nam0 to $nam1" - pack $wi.ftop.name_label -side right - pack $wi.ftop -side top - - set spinbox [getspinbox] - global g_link_config_uni_state - set g_link_config_uni_state "bid" - - ttk::frame $wi.preset -borderwidth 4 - global link_preset_val - set link_preset_val unlimited - set linkpreMenu [tk_optionMenu $wi.preset.linkpre link_preset_val a] - # unidirectional links not always supported - if { [isUniSupported $n0 $n1] } { - set unistate normal - } else { - set unistate disabled - } - ttk::button $wi.preset.uni -text " >> " -state $unistate \ - -command "linkConfigUni $wi" - pack $wi.preset.uni $wi.preset.linkpre -side right - linkPresets $wi $linkpreMenu init - pack $wi.preset -side top -anchor e - - ttk::frame $wi.unilabel -borderwidth 4 - ttk::label $wi.unilabel.updown -text "Symmetric link effects:" - pack $wi.unilabel.updown -side left -anchor w - pack $wi.unilabel -side top -anchor w - - ttk::frame $wi.bandwidth -borderwidth 4 - ttk::label $wi.bandwidth.label -anchor e -text "Bandwidth (bps):" - $spinbox $wi.bandwidth.value -justify right -width 10 \ - -validate focus -invalidcommand "focusAndFlash %W" - $wi.bandwidth.value insert 0 [getLinkBandwidth $target] - $wi.bandwidth.value configure \ - -validatecommand {checkIntRange %P 0 1000000000} \ - -from 0 -to 1000000000 -increment 1000000 - pack $wi.bandwidth.value $wi.bandwidth.label -side right - pack $wi.bandwidth -side top -anchor e - - ttk::frame $wi.delay -borderwidth 4 - ttk::label $wi.delay.label -anchor e -text "Delay (us):" - $spinbox $wi.delay.value -justify right -width 10 \ - -validate focus -invalidcommand "focusAndFlash %W" - $wi.delay.value insert 0 [getLinkDelay $target] - # 274 seconds is maximum netem delay for Linux 3.2.0-60-generic kernel - $wi.delay.value configure \ - -validatecommand {checkIntRange %P 0 274000000} \ - -from 0 -to 10000000 -increment 5 - pack $wi.delay.value $wi.delay.label -side right - pack $wi.delay -side top -anchor e - - ttk::frame $wi.jitter -borderwidth 4 - ttk::label $wi.jitter.label -anchor e -text "Jitter (us):" - $spinbox $wi.jitter.value -justify right -width 10 \ - -validate focus -invalidcommand "focusAndFlash %W" - $wi.jitter.value insert 0 [getLinkJitter $target] - $wi.jitter.value configure \ - -validatecommand {checkIntRange %P 0 10000000} \ - -from 0 -to 10000000 -increment 5 - pack $wi.jitter.value $wi.jitter.label -side right - pack $wi.jitter -side top -anchor e - - ttk::frame $wi.ber -borderwidth 4 - if { [lindex $systype 0] == "Linux" } { - set bertext "Loss (%):" - set berinc 0.1 - set bermax 100.0 - } else { ;# netgraph uses BER - set bertext "BER (1/N):" - set berinc 1000 - set bermax 10000000000000 - } - ttk::label $wi.ber.label -anchor e -text $bertext - $spinbox $wi.ber.value -justify right -width 10 \ - -validate focus -invalidcommand "focusAndFlash %W" - $wi.ber.value insert 0 [getLinkBER $target] - $wi.ber.value configure \ - -validatecommand "checkFloatRange %P 0.0 $bermax" \ - -from 0.0 -to $bermax -increment $berinc - pack $wi.ber.value $wi.ber.label -side right - pack $wi.ber -side top -anchor e - - ttk::frame $wi.dup -borderwidth 4 - ttk::label $wi.dup.label -anchor e -text "Duplicate (%):" - $spinbox $wi.dup.value -justify right -width 10 \ - -validate focus -invalidcommand "focusAndFlash %W" - $wi.dup.value insert 0 [getLinkDup $target] - $wi.dup.value configure \ - -validatecommand {checkFloatRange %P 0 50} \ - -from 0 -to 50 -increment 1 - pack $wi.dup.value $wi.dup.label -side right - pack $wi.dup -side top -anchor e - -# Boeing: jitter -# frame $wi.jitter -borderwidth 4 -# label $wi.jitter.label -anchor e -text "Jitter (us):" -# spinbox $wi.jitter.value -bg white -justify right -width 10 \ -# -validate focus -invalidcommand "focusAndFlash %W" -# $wi.jitter.value insert 0 [getLinkJitter $target] -# $wi.jitter.value configure \ -# -validatecommand {checkIntRange %P 0 10000000} \ -# -from 0 -to 10000000 -increment 5 -# pack $wi.jitter.value $wi.jitter.label -side right -# pack $wi.jitter -side top -anchor e -# end Boeing - - ttk::frame $wi.color -borderwidth 4 - ttk::label $wi.color.label -anchor e -text "Color:" - set link_color [getLinkColor $target] - tk_optionMenu $wi.color.value link_color \ - Red Green Blue Yellow Magenta Cyan Black - $wi.color.value configure -width 8 - pack $wi.color.value $wi.color.label -side right - pack $wi.color -side top -anchor e - - ttk::frame $wi.width -borderwidth 4 - ttk::label $wi.width.label -anchor e -text "Width:" - $spinbox $wi.width.value -justify right -width 10 \ - -validate focus -invalidcommand "focusAndFlash %W" - $wi.width.value insert 0 [getLinkWidth $target] - $wi.width.value configure \ - -validatecommand {checkIntRange %P 1 8} \ - -from 1 -to 8 -increment 1 - pack $wi.width.value $wi.width.label -side right - pack $wi.width -side top -anchor e - - # auto-expand upstream if values exist - set bw [getLinkBandwidth $target up] - set dl [getLinkDelay $target up] - set jt [getLinkJitter $target up] - set ber [getLinkBER $target up] - set dup [getLinkDup $target up] - if { $bw > 0 || $dl > 0 || $jt > 0 || $ber > 0 || $dup > 0 } { - linkConfigUni $wi - $wi.bandwidth.value2 delete 0 end - $wi.bandwidth.value2 insert 0 $bw - $wi.delay.value2 delete 0 end - $wi.delay.value2 insert 0 $dl - $wi.jitter.value2 delete 0 end - $wi.jitter.value2 insert 0 $jt - $wi.ber.value2 delete 0 end - $wi.ber.value2 insert 0 $ber - $wi.dup.value2 delete 0 end - $wi.dup.value2 insert 0 $dup - } - } - } ;# end switch - - ttk::frame $wi.butt -borderwidth 6 - # NOTE: plugins.tcl:popupCapabilityConfig may read this command option - ttk::button $wi.butt.apply -text "Apply" -command \ - "popupConfigApply $wi $object_type $target 0" - focus $wi.butt.apply - # Boeing: remove range circles upon cancel - if {$type == "wlan"} { - set cancelcmd "set badentry -1 ; destroy $wi;" - set cancelcmd "$cancelcmd updateRangeCircles $target 0" - } else { - set cancelcmd "set badentry -1 ; destroy $wi" - } - ttk::button $wi.butt.cancel -text "Cancel" -command $cancelcmd - #end Boeing - pack $wi.butt.cancel $wi.butt.apply -side right - pack $wi.butt -side bottom - bind $wi $cancelcmd -# bind $wi "popupConfigApply $wi $object_type $target 0" -} - - -proc linkConfigUni { wi } { - global g_link_config_uni_state - - set capt [lindex [$wi.preset.uni configure -text] 4] - - if { $capt == " >> " } { - set g_link_config_uni_state "uni" - $wi.preset.uni configure -text " << " - set txt "Asymmetric effects: downstream / upstream" - $wi.unilabel.updown configure -text $txt - - set spinbox [getspinbox] - if { ![winfo exists $wi.bandwidth.value2] } { - $spinbox $wi.bandwidth.value2 -justify right \ - -width 10 -validate focus -invalidcommand "focusAndFlash %W" - $wi.bandwidth.value2 configure \ - -validatecommand {checkIntRange %P 0 1000000000} \ - -from 0 -to 1000000000 -increment 1000000 - } - $wi.bandwidth.value2 delete 0 end - $wi.bandwidth.value2 insert 0 [$wi.bandwidth.value get] - pack $wi.bandwidth.value2 -side right - pack $wi.bandwidth.value2 -before $wi.bandwidth.value - - if { ![winfo exists $wi.delay.value2] } { - $spinbox $wi.delay.value2 -justify right -width 10 \ - -validate focus -invalidcommand "focusAndFlash %W" - $wi.delay.value2 configure \ - -validatecommand {checkIntRange %P 0 10000000} \ - -from 0 -to 10000000 -increment 5 - } - $wi.delay.value2 delete 0 end - $wi.delay.value2 insert 0 [$wi.delay.value get] - pack $wi.delay.value2 -side right - pack $wi.delay.value2 -before $wi.delay.value - - if { ![winfo exists $wi.jitter.value2] } { - $spinbox $wi.jitter.value2 -justify right -width 10 \ - -validate focus -invalidcommand "focusAndFlash %W" - $wi.jitter.value2 configure \ - -validatecommand {checkIntRange %P 0 10000000} \ - -from 0 -to 10000000 -increment 5 - } - $wi.jitter.value2 delete 0 end - $wi.jitter.value2 insert 0 [$wi.jitter.value get] - pack $wi.jitter.value2 -side right - pack $wi.jitter.value2 -before $wi.jitter.value - - if { ![winfo exists $wi.ber.value2] } { - $spinbox $wi.ber.value2 -justify right -width 10 \ - -validate focus -invalidcommand "focusAndFlash %W" - $wi.ber.value2 configure \ - -validatecommand "checkFloatRange %P 0.0 100.0" \ - -from 0.0 -to 100.0 -increment 0.1 - } - $wi.ber.value2 delete 0 end - $wi.ber.value2 insert 0 [$wi.ber.value get] - pack $wi.ber.value2 -side right - pack $wi.ber.value2 -before $wi.ber.value - - if { ![winfo exists $wi.dup.value2] } { - $spinbox $wi.dup.value2 -justify right -width 10 \ - -validate focus -invalidcommand "focusAndFlash %W" - $wi.dup.value2 configure \ - -validatecommand {checkFloatRange %P 0 50} \ - -from 0 -to 50 -increment 1 - } - $wi.dup.value2 delete 0 end - $wi.dup.value2 insert 0 [$wi.dup.value get] - pack $wi.dup.value2 -side right - pack $wi.dup.value2 -before $wi.dup.value - } else { - set g_link_config_uni_state "bid" - $wi.preset.uni configure -text " >> " - $wi.unilabel.updown configure -text "Symmetric link effects:" - pack forget $wi.bandwidth.value2 - pack forget $wi.delay.value2 - pack forget $wi.jitter.value2 - pack forget $wi.ber.value2 - pack forget $wi.dup.value2 - } -} - -# unidirectional links are not always supported -proc isUniSupported { n1 n2 } { - set blacklist [list "hub" "lanswitch"] - set type1 [nodeType $n1] - set type2 [nodeType $n2] - # not yet supported for GRE tap device - if { $type1 == "tunnel" || $type2 == "tunnel" } { - return false - } - # unidirectional links are supported between two switches/hubs - if { [lsearch $blacklist $type1] != -1 && \ - [lsearch $blacklist $type2] != -1 } { - return true - } - # unidirectional links not supported between hub/switch and something else - if { [lsearch $blacklist $type1] != -1 || \ - [lsearch $blacklist $type2] != -1 } { - return false - } - # unidirectional links are supported between routers, rj45s, etc. - # WLANs not included here because they have no link dialog - return true -} - -# toggle the state of the mac address entry, and insert MAC address template -proc macEntryHelper { wi ifc } { - set fr $wi.ifaces.c.if$ifc - set ctl $fr.cfg.mac.addrv - set s normal - if { [$ctl cget -state] == $s } { set s disabled } - $ctl configure -state $s - - if { [$ctl get] == "" } { $ctl insert 0 "00:00:00:00:00:00" } -} - - -#****f* editor.tcl/popupConfigApply -# NAME -# popupConfigApply -- popup configuration apply -# SYNOPSIS -# popupConfigApply $w $object_type $target $phase -# FUNCTION -# This procedure is called when the button apply is pressed in -# popup configuration dialog box. It reads different -# configuration parameters depending on the object_type. -# INPUTS -# * w -- widget -# * object_type -- describes the object type that is currently -# configured. It can be either link or node. -# * target -- node id of the configured node or link id of the -# configured link -# * phase -- This procedure is invoked in two diffenet phases -# to enable validation of the entry that was the last made. -# When calling this function always use the phase parameter -# set to 0. -#**** -proc popupConfigApply { wi object_type target phase } { - global changed oper_mode router_model link_color badentry - global customEnabled ipsecEnabled - global eid - - $wi config -cursor watch - update - if { $phase == 0 } { - set badentry 0 - focus . - after 100 "popupConfigApply $wi $object_type $target 1" - return - } elseif { $badentry } { - $wi config -cursor left_ptr - return - } - switch -exact -- $object_type { - # - # Node - # - node { - set type [nodeType $target] - set model [getNodeModel $target] - set name [string trim [$wi.ftop.name get]] - set changed_to_remote 0 - global node_location - if { $node_location != [getNodeLocation $target] } { - if { $node_location == "(none)" } { set node_location "" } - setNodeLocation $target $node_location - set changed 1 - } - set node_location "" - if { $name != [getNodeName $target] } { - setNodeName $target $name - set changed 1 - } - if { $oper_mode == "edit" && $type == "router" && \ - $router_model != $model } { - setNodeModel $target $router_model - set changed 1 - if { $router_model == "remote" } { set changed_to_remote 1 };#Boeing - } - -# Boeing - added wlan, remote, tunnel, ktunnel items - if { $type == "wlan" } { - wlanConfigDialogHelper $wi $target 1 - } elseif { $type == "tunnel" } { - # - # apply tunnel items - # - set ipaddr "$name/24" ;# tunnel name == IP address of peer - set oldipaddr [getIfcIPv4addr $target e0] - if { $ipaddr != $oldipaddr } { - setIfcIPv4addr $target e0 $ipaddr - } - global conntype conntap - set oldconntype [netconfFetchSection $target "tunnel-type"] - if { $oldconntype != $conntype } { - netconfInsertSection $target [list "tunnel-type" $conntype] - } - set oldconntap [netconfFetchSection $target "tunnel-tap"] - if { $oldconntap != $conntap } { - netconfInsertSection $target [list "tunnel-tap" $conntap] - } - set oldkey [netconfFetchSection $target "tunnel-key"] - set key [$wi.con2.key.key get] - if { $oldkey != $key } { - netconfInsertSection $target [list "tunnel-key" $key] - } - - set oldlocal [netconfFetchSection $target "local-hook"] - set local [$wi.linfo.local get] - if { $oldlocal != $local } { - netconfInsertSection $target [list "local-hook" $local] - } - - set oldpeer [netconfFetchSection $target "peer-hook"] - set peer [$wi.pinfo.peer get] - if { $oldpeer != $peer } { - netconfInsertSection $target [list "peer-hook" $peer] - } - } elseif { $type == "ktunnel" } { - # - # apply ktunnel items - # - set oldlocal [netconfFetchSection $target "local-hook"] - set local [$wi.linfo.local get] - if { $oldlocal != $local } { - netconfInsertSection $target [list "local-hook" $local] - } -# Boeing changing to interface name for RJ45 -# } elseif { $type == "rj45" } { -# # -# # apply rj45 items -# # -# set ifcName [string trim [$wi.interface.name get]] -# puts "$ifcName\n" -# - } elseif { $type == "router" && [getNodeModel $target] == "remote" } { - if { $changed_to_remote == 0 } { - set i 1 - set remoteIP [string trim [$wi.remoteinfo.ip.text get $i.0 $i.end]] - if { $remoteIP != [router.remote.getRemoteIP $target] } { - router.remote.setRemoteIP $target $remoteIP - set changed 1 - } - set ifc [string trim [$wi.remoteinfo.ifc.text get $i.0 $i.end]] - if { $ifc != [router.remote.getCInterface $target] } { - router.remote.setCInterface $target $ifc - set changed 1 - } - set startcmd [string trim [$wi.remotecommands.start.text get $i.0 $i.end]] - if { $startcmd != [router.remote.getStartCmd $target] } { - router.remote.setStartCmd $target $startcmd - set changed 1 - } - set stopcmd [string trim [$wi.remotecommands.stop.text get $i.0 $i.end]] - if { $stopcmd != [router.remote.getStopCmd $target] } { - router.remote.setStopCmd $target $stopcmd - set changed 1 - } - } - } - - if {[[typemodel $target].layer] == "NETWORK"} { - foreach ifc [ifcList $target] { - set fr $wi.ifaces.c.if$ifc - set macaddr [$fr.cfg.mac.addrv get] - global if${ifc}_auto_mac - if { [set if${ifc}_auto_mac] == 1 } { set macaddr "" } - set oldmacaddr [getIfcMacaddr $target $ifc] - if { $macaddr != $oldmacaddr } { - setIfcMacaddr $target $ifc $macaddr - set changed 1 - } - set ipaddr [$fr.cfg.ipv4.addrv get] - set oldipaddr [getIfcIPv4addr $target $ifc] - if { $ipaddr != $oldipaddr } { - setIfcIPv4addr $target $ifc $ipaddr - set changed 1 - } - set ipaddr [$fr.cfg.ipv6.addrv get] - set oldipaddr [getIfcIPv6addr $target $ifc] - if { $ipaddr != $oldipaddr } { - setIfcIPv6addr $target $ifc $ipaddr - set changed 1 - } - } - } - } - - link { - global g_link_config_uni_state - set mirror [getLinkMirror $target] - - if { [setIfChanged $target $mirror $wi "bandwidth" "LinkBandwidth"] } { - set changed 1 - } - if { [setIfChanged $target $mirror $wi "delay" "LinkDelay"] } { - set changed 1 - } - if { [setIfChanged $target $mirror $wi "ber" "LinkBER"] } { - set changed 1 - } - if { [setIfChanged $target $mirror $wi "dup" "LinkDup"] } { - set changed 1 - } - if { [setIfChanged $target $mirror $wi "jitter" "LinkJitter"] } { - set changed 1 - } - - if { $link_color != [getLinkColor $target] } { - setLinkColor $target $link_color - if { $mirror != "" } { - setLinkColor $mirror $link_color - } - set changed 1 - } - set width [$wi.width.value get] - if { $width != [getLinkWidth $target] } { - setLinkWidth $target $width - if { $mirror != "" } { - setLinkWidth $mirror $width - } - set changed 1 - } - if { $changed == 1 && $oper_mode == "exec" } { - execSetLinkParams $eid $target - } - } - - } - - popdownConfig $wi -} - -# helper for Link Config dialog -# ctl must exist as $wi.$ctl.value{2}, and {get,set}$procname must be valid -# returns true when value has changed, false otherwise -proc setIfChanged { target mirror wi ctl procname } { - global g_link_config_uni_state - - set val [$wi.$ctl.value get] - if { $g_link_config_uni_state == "uni" } { - set val [list $val [$wi.$ctl.value2 get]] - } - set oldval [get$procname $target] - set oldval2 [get$procname $target "up"] - if { $oldval2 != "" } { - set oldval [list $oldval $oldval2] - } - if { $val != $oldval } { - set$procname $target $val - if { $mirror != "" } { - set$procname $mirror $val - } - return true - } - return false -} - -#****f* editor.tcl/printCanvas -# NAME -# printCanvas -- print canvas -# SYNOPSIS -# printCanvas $w -# FUNCTION -# This procedure is called when the print button in -# print dialog box is pressed. -# INPUTS -# * w -- print dialog widget -#**** -proc printCanvas { w } { - global sizex sizey - - set prncmd [$w.e1 get] - destroy $w - set p [open "|$prncmd" WRONLY] - puts $p [.c postscript -height $sizey -width $sizex -x 0 -y 0 -rotate yes -pageheight 297m -pagewidth 210m] - close $p -} - - -#****f* editor.tcl/deleteSelection -# NAME -# deleteSelection -- delete selection -# SYNOPSIS -# deleteSelection -# FUNCTION -# By calling this procedure all the selected nodes in imunes will -# be deleted. -#**** -proc deleteSelection { } { - global changed - global background - global viewid - catch {unset viewid} - .c config -cursor watch; update - - foreach lnode [selectedNodes] { - if { $lnode != "" } { - removeGUINode $lnode - } - set changed 1 - } - - raiseAll .c - updateUndoLog - .c config -cursor left_ptr - .bottom.textbox config -text "" -} - - -proc assignSelection { server } { - global changed - .c config -cursor watch; update - - foreach node [selectedNodes] { - if { $node != "" } { - setNodeLocation $node $server - } - set changed 1 - } - - redrawAll - updateUndoLog - .c config -cursor left_ptr - .bottom.textbox config -text "" -} - - -proc align2grid {} { - global sizex sizey grid zoom changed - - set node_objects [.c find withtag node] - if { [llength $node_objects] == 0 } { - return - } - - set step [expr {$grid * 4}] - - for { set x $step } { $x <= [expr {$sizex - $step}] } { incr x $step } { - for { set y $step } { $y <= [expr {$sizey - $step}] } { incr y $step } { - if { [llength $node_objects] == 0 } { - set changed 1 - updateUndoLog - redrawAll - return - } - set node [lindex [.c gettags [lindex $node_objects 0]] 1] - set node_objects [lreplace $node_objects 0 0] - setNodeCoords $node "$x $y" - lassign [getDefaultLabelOffsets [nodeType $node]] dx dy - setNodeLabelCoords $node "[expr {$x + $dx}] [expr {$y + $dy}]" - } - } -} - -#****f* editor.tcl/rearrange -# NAME -# rearrange -# SYNOPSIS -# rearrange $mode -# FUNCTION -# This procedure rearranges the position of nodes in imunes. -# It can be used to rearrange all the nodes or only the selected -# nodes. -# INPUTS -# * mode -- when set to "selected" only the selected nodes will be -# rearranged. -#**** -proc rearrange { mode } { - global link_list autorearrange_enabled sizex sizey curcanvas zoom activetool - - set activetool select - - if { $autorearrange_enabled } { - rearrange_off - return - } - set autorearrange_enabled 1 - .bottom.mbuf config -text "autorearrange" - if { $mode == "selected" } { - .menubar.tools entryconfigure "Auto rearrange all" -state disabled - .menubar.tools entryconfigure "Auto rearrange all" -indicatoron off - .menubar.tools entryconfigure "Auto rearrange selected" -indicatoron on - set tagmatch "node && selected" - } else { - .menubar.tools entryconfigure "Auto rearrange all" -indicatoron on - .menubar.tools entryconfigure "Auto rearrange selected" -state disabled - .menubar.tools entryconfigure "Auto rearrange selected" -indicatoron off - set tagmatch "node" - } - set otime [clock clicks -milliseconds] - while { $autorearrange_enabled } { - set ntime [clock clicks -milliseconds] - if { $otime == $ntime } { - set dt 0.001 - } else { - set dt [expr {($ntime - $otime) * 0.001}] - if { $dt > 0.2 } { - set dt 0.2 - } - set otime $ntime - } - - set objects [.c find withtag $tagmatch] - set peer_objects [.c find withtag node] - foreach obj $peer_objects { - set node [lindex [.c gettags $obj] 1] - set coords [.c coords $obj] - set x [expr {[lindex $coords 0] / $zoom}] - set y [expr {[lindex $coords 1] / $zoom}] - set x_t($node) $x - set y_t($node) $y - - if { $x > 0 } { - set fx [expr {1000 / ($x * $x + 100)}] - } else { - set fx 10 - } - set dx [expr {$sizex - $x}] - if { $dx > 0 } { - set fx [expr {$fx - 1000 / ($dx * $dx + 100)}] - } else { - set fx [expr {$fx - 10}] - } - - if { $y > 0 } { - set fy [expr {1000 / ($y * $y + 100)}] - } else { - set fy 10 - } - set dy [expr {$sizey - $y}] - if { $dy > 0 } { - set fy [expr {$fy - 1000 / ($dy * $dy + 100)}] - } else { - set fy [expr {$fy - 10}] - } - set fx_t($node) $fx - set fy_t($node) $fy - } - - foreach obj $objects { - set node [lindex [.c gettags $obj] 1] - set i [lsearch -exact $peer_objects $obj] - set peer_objects [lreplace $peer_objects $i $i] - set x $x_t($node) - set y $y_t($node) - foreach other_obj $peer_objects { - set other [lindex [.c gettags $other_obj] 1] - set o_x $x_t($other) - set o_y $y_t($other) - set dx [expr {$x - $o_x}] - set dy [expr {$y - $o_y}] - set d [expr {hypot($dx, $dy)}] - set d2 [expr {$d * $d}] - set p_fx [expr {1000.0 * $dx / ($d2 * $d + 100)}] - set p_fy [expr {1000.0 * $dy / ($d2 * $d + 100)}] - if {[linkByPeers $node $other] != ""} { - set p_fx [expr {$p_fx - $dx * $d2 * .0000000005}] - set p_fy [expr {$p_fy - $dy * $d2 * .0000000005}] - } - set fx_t($node) [expr {$fx_t($node) + $p_fx}] - set fy_t($node) [expr {$fy_t($node) + $p_fy}] - set fx_t($other) [expr {$fx_t($other) - $p_fx}] - set fy_t($other) [expr {$fy_t($other) - $p_fy}] - } - - foreach link $link_list { - set nodes [linkPeers $link] - if { [getNodeCanvas [lindex $nodes 0]] != $curcanvas || - [getNodeCanvas [lindex $nodes 1]] != $curcanvas || - [getLinkMirror $link] != "" } { - continue - } - set peers [linkPeers $link] - set coords0 [getNodeCoords [lindex $peers 0]] - set coords1 [getNodeCoords [lindex $peers 1]] - set o_x \ - [expr {([lindex $coords0 0] + [lindex $coords1 0]) * .5}] - set o_y \ - [expr {([lindex $coords0 1] + [lindex $coords1 1]) * .5}] - set dx [expr {$x - $o_x}] - set dy [expr {$y - $o_y}] - set d [expr {hypot($dx, $dy)}] - set d2 [expr {$d * $d}] - set fx_t($node) \ - [expr {$fx_t($node) + 500.0 * $dx / ($d2 * $d + 100)}] - set fy_t($node) \ - [expr {$fy_t($node) + 500.0 * $dy / ($d2 * $d + 100)}] - } - } - - foreach obj $objects { - set node [lindex [.c gettags $obj] 1] - if { [catch "set v_t($node)" v] } { - set vx 0.0 - set vy 0.0 - } else { - set vx [lindex $v_t($node) 0] - set vy [lindex $v_t($node) 1] - } - set vx [expr {$vx + 1000.0 * $fx_t($node) * $dt}] - set vy [expr {$vy + 1000.0 * $fy_t($node) * $dt}] - set dampk [expr {0.5 + ($vx * $vx + $vy * $vy) * 0.00001}] - set vx [expr {$vx * exp( - $dampk * $dt)}] - set vy [expr {$vy * exp( - $dampk * $dt)}] - set dx [expr {$vx * $dt}] - set dy [expr {$vy * $dt}] - set x [expr {$x_t($node) + $dx}] - set y [expr {$y_t($node) + $dy}] - set v_t($node) "$vx $vy" - - setNodeCoords $node "$x $y" - set e_dx [expr {$dx * $zoom}] - set e_dy [expr {$dy * $zoom}] - .c move $obj $e_dx $e_dy - set img [.c find withtag "selectmark && $node"] - .c move $img $e_dx $e_dy - set img [.c find withtag "nodelabel && $node"] - .c move $img $e_dx $e_dy - set x [expr {[lindex [.c coords $img] 0] / $zoom}] - set y [expr {[lindex [.c coords $img] 1] / $zoom}] - setNodeLabelCoords $node "$x $y" - .c addtag need_redraw withtag "link && $node" - } - foreach link [.c find withtag "link && need_redraw"] { - redrawLink [lindex [.c gettags $link] 1] - } - .c dtag link need_redraw - update - } - - rearrange_off - .bottom.mbuf config -text "" -} - -proc rearrange_off { } { - global autorearrange_enabled - set autorearrange_enabled 0 - .menubar.tools entryconfigure "Auto rearrange all" -state normal - .menubar.tools entryconfigure "Auto rearrange all" -indicatoron off - .menubar.tools entryconfigure "Auto rearrange selected" -state normal - .menubar.tools entryconfigure "Auto rearrange selected" -indicatoron off -} - - -#****f* editor.tcl/switchCanvas -# NAME -# switchCanvas -- switch canvas -# SYNOPSIS -# switchCanvas $direction -# FUNCTION -# This procedure switches the canvas in one of the defined -# directions (previous, next, first and last). -# INPUTS -# * direction -- the direction of switching canvas. Can be: prev -- -# previus, next -- next, first -- first, last -- last. -#**** -proc switchCanvas { direction } { - global canvas_list curcanvas - global sizex sizey - - set i [lsearch $canvas_list $curcanvas] - switch -exact -- $direction { - prev { - incr i -1 - if { $i < 0 } { - set curcanvas [lindex $canvas_list end] - } else { - set curcanvas [lindex $canvas_list $i] - } - } - next { - incr i - if { $i >= [llength $canvas_list] } { - set curcanvas [lindex $canvas_list 0] - } else { - set curcanvas [lindex $canvas_list $i] - } - } - first { - set curcanvas [lindex $canvas_list 0] - } - last { - set curcanvas [lindex $canvas_list end] - } - } - - .hframe.t delete all - set x 0 - foreach canvas $canvas_list { - set text [.hframe.t create text 0 0 \ - -text "[getCanvasName $canvas]" -tags "text $canvas"] - set ox [lindex [.hframe.t bbox $text] 2] - set oy [lindex [.hframe.t bbox $text] 3] - set tab [.hframe.t create polygon $x 0 [expr {$x + 7}] 18 \ - [expr {$x + 2 * $ox + 17}] 18 [expr {$x + 2 * $ox + 24}] 0 $x 0 \ - -fill gray -tags "tab $canvas"] - set line [.hframe.t create line 0 0 $x 0 [expr {$x + 7}] 18 \ - [expr {$x + 2 * $ox + 17}] 18 [expr {$x + 2 * $ox + 24}] 0 999 0 \ - -fill #808080 -width 2 -tags "line $canvas"] - .hframe.t coords $text [expr {$x + $ox + 12}] [expr {$oy + 2}] - .hframe.t raise $text - incr x [expr {2 * $ox + 17}] - } - incr x 7 - .hframe.t raise "$curcanvas" - .hframe.t itemconfigure "tab && $curcanvas" -fill #e0e0e0 - .hframe.t configure -scrollregion "0 0 $x 18" - update - set width [lindex [.hframe.t configure -width] 4] - set lborder [lindex [.hframe.t bbox "tab && $curcanvas"] 0] - set rborder [lindex [.hframe.t bbox "tab && $curcanvas"] 2] - set lmargin [expr {[lindex [.hframe.t xview] 0] * $x - 1}] - set rmargin [expr {[lindex [.hframe.t xview] 1] * $x + 1}] - if { $lborder < $lmargin } { - .hframe.t xview moveto [expr {1.0 * ($lborder - 10) / $x}] - } - if { $rborder > $rmargin } { - .hframe.t xview moveto [expr {1.0 * ($rborder - $width + 10) / $x}] - } - - set sizex [lindex [getCanvasSize $curcanvas] 0] - set sizey [lindex [getCanvasSize $curcanvas] 1] - - redrawAll -} - -proc resizeCanvasPopup {} { - global curcanvas - - set w .canvasSizeScaleDialog - catch {destroy $w} - toplevel $w - - wm transient $w . - wm title $w "Canvas Size and Scale" - - frame $w.buttons - pack $w.buttons -side bottom -fill x -pady 2m - button $w.buttons.print -text "Apply" -command "resizeCanvasApply $w" - button $w.buttons.cancel -text "Cancel" -command "destroy $w" - pack $w.buttons.print $w.buttons.cancel -side left -expand 1 - - set cursize [getCanvasSize $curcanvas] - set x [lindex $cursize 0] - set y [lindex $cursize 1] - set scale [getCanvasScale $curcanvas] - set refpt [getCanvasRefPoint $curcanvas] - set refx [lindex $refpt 0] - set refy [lindex $refpt 1] - set latitude [lindex $refpt 2] - set longitude [lindex $refpt 3] - set altitude [lindex $refpt 4] - - - labelframe $w.size -text "Size" - frame $w.size.pixels - pack $w.size $w.size.pixels -side top -padx 4 -pady 4 -fill x - spinbox $w.size.pixels.x -bg white -width 5 - $w.size.pixels.x insert 0 $x - $w.size.pixels.x configure -from 300 -to 5000 -increment 2 - label $w.size.pixels.label -text "W x" - spinbox $w.size.pixels.y -bg white -width 5 - $w.size.pixels.y insert 0 $y - $w.size.pixels.y configure -from 300 -to 5000 -increment 2 - label $w.size.pixels.label2 -text "H pixels" - pack $w.size.pixels.x $w.size.pixels.label $w.size.pixels.y \ - $w.size.pixels.label2 -side left -pady 2 -padx 2 -fill x - - frame $w.size.meters - pack $w.size.meters -side top -padx 4 -pady 4 -fill x - spinbox $w.size.meters.x -bg white -width 7 - $w.size.meters.x configure -from 300 -to 10000 -increment 100 - label $w.size.meters.label -text "x" - spinbox $w.size.meters.y -bg white -width 7 - $w.size.meters.y configure -from 300 -to 10000 -increment 100 - label $w.size.meters.label2 -text "meters" - pack $w.size.meters.x $w.size.meters.label $w.size.meters.y \ - $w.size.meters.label2 -side left -pady 2 -padx 2 -fill x - - labelframe $w.scale -text "Scale" - frame $w.scale.ppm - pack $w.scale $w.scale.ppm -side top -padx 4 -pady 4 -fill x - label $w.scale.ppm.label -text "100 pixels =" - entry $w.scale.ppm.metersper100 -bg white -width 10 - $w.scale.ppm.metersper100 insert 0 $scale - label $w.scale.ppm.label2 -text "meters" - pack $w.scale.ppm.label $w.scale.ppm.metersper100 \ - $w.scale.ppm.label2 -side left -pady 2 -padx 2 -fill x - - bind $w.size.pixels.x