Merge pull request #700 from coreemu/enhancement/opt-core
Enhancement/opt core
This commit is contained in:
commit
5202b2fa04
55 changed files with 592 additions and 188 deletions
|
@ -21,10 +21,7 @@ DISTCLEANFILES = Makefile.in
|
|||
|
||||
# files to include with distribution tarball
|
||||
EXTRA_DIST = core \
|
||||
data \
|
||||
doc/conf.py.in \
|
||||
examples \
|
||||
scripts \
|
||||
tests \
|
||||
setup.cfg \
|
||||
poetry.lock \
|
||||
|
|
103
daemon/core/scripts/cleanup.py
Executable file
103
daemon/core/scripts/cleanup.py
Executable file
|
@ -0,0 +1,103 @@
|
|||
import argparse
|
||||
import os
|
||||
import subprocess
|
||||
import sys
|
||||
import time
|
||||
|
||||
|
||||
def check_root() -> None:
|
||||
if os.geteuid() != 0:
|
||||
print("permission denied, run this script as root")
|
||||
sys.exit(1)
|
||||
|
||||
|
||||
def parse_args() -> argparse.Namespace:
|
||||
parser = argparse.ArgumentParser(
|
||||
description="helps cleanup lingering core processes and files",
|
||||
formatter_class=argparse.ArgumentDefaultsHelpFormatter,
|
||||
)
|
||||
parser.add_argument(
|
||||
"-d", "--daemon", action="store_true", help="also kill core-daemon"
|
||||
)
|
||||
return parser.parse_args()
|
||||
|
||||
|
||||
def cleanup_daemon() -> None:
|
||||
print("killing core-daemon process ... ", end="")
|
||||
result = subprocess.call("pkill -9 core-daemon", shell=True)
|
||||
if result:
|
||||
print("not found")
|
||||
else:
|
||||
print("done")
|
||||
|
||||
|
||||
def cleanup_nodes() -> None:
|
||||
print("killing vnoded processes ... ", end="")
|
||||
result = subprocess.call("pkill -KILL vnoded", shell=True)
|
||||
if result:
|
||||
print("none found")
|
||||
else:
|
||||
time.sleep(1)
|
||||
print("done")
|
||||
|
||||
|
||||
def cleanup_emane() -> None:
|
||||
print("killing emane processes ... ", end="")
|
||||
result = subprocess.call("pkill emane", shell=True)
|
||||
if result:
|
||||
print("none found")
|
||||
else:
|
||||
print("done")
|
||||
|
||||
|
||||
def cleanup_sessions() -> None:
|
||||
print("removing session directories ... ", end="")
|
||||
result = subprocess.call("rm -rf /tmp/pycore*", shell=True)
|
||||
if result:
|
||||
print("none found")
|
||||
else:
|
||||
print("done")
|
||||
|
||||
|
||||
def cleanup_interfaces() -> None:
|
||||
print("cleaning up devices")
|
||||
output = subprocess.check_output("ip -o -br link show", shell=True)
|
||||
lines = output.decode().strip().split("\n")
|
||||
for line in lines:
|
||||
values = line.split()
|
||||
name = values[0]
|
||||
if (
|
||||
name.startswith("veth")
|
||||
or name.startswith("gt.")
|
||||
or name.startswith("b.")
|
||||
or name.startswith("ctrl")
|
||||
):
|
||||
result = subprocess.call(f"ip link delete {name}", shell=True)
|
||||
if result:
|
||||
print(f"failed to remove {name}")
|
||||
else:
|
||||
print(f"removed {name}")
|
||||
if name.startswith("b."):
|
||||
result = subprocess.call(
|
||||
f"nft delete table bridge {name}",
|
||||
stdout=subprocess.DEVNULL,
|
||||
stderr=subprocess.DEVNULL,
|
||||
shell=True,
|
||||
)
|
||||
if not result:
|
||||
print(f"cleared nft rules for {name}")
|
||||
|
||||
|
||||
def main() -> None:
|
||||
check_root()
|
||||
args = parse_args()
|
||||
if args.daemon:
|
||||
cleanup_daemon()
|
||||
cleanup_nodes()
|
||||
cleanup_emane()
|
||||
cleanup_interfaces()
|
||||
cleanup_sessions()
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
|
@ -1,4 +1,3 @@
|
|||
#!/usr/bin/env python3
|
||||
import json
|
||||
import sys
|
||||
from argparse import (
|
||||
|
@ -32,7 +31,9 @@ NODE_TYPES = [x.name 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)
|
||||
return MessageToDict(
|
||||
message, including_default_value_fields=True, preserving_proto_field_name=True
|
||||
)
|
||||
|
||||
|
||||
def print_json(data: Any) -> None:
|
||||
|
@ -122,18 +123,15 @@ def get_current_session(core: CoreGrpcClient, session_id: Optional[int]) -> int:
|
|||
return sessions[0].id
|
||||
|
||||
|
||||
def create_iface(iface_id: int, mac: str, ip4_net: IPNetwork, ip6_net: IPNetwork) -> Interface:
|
||||
def create_iface(
|
||||
iface_id: int, mac: str, ip4_net: IPNetwork, ip6_net: IPNetwork
|
||||
) -> Interface:
|
||||
ip4 = str(ip4_net.ip) if ip4_net else None
|
||||
ip4_mask = ip4_net.prefixlen if ip4_net else None
|
||||
ip6 = str(ip6_net.ip) if ip6_net else None
|
||||
ip6_mask = ip6_net.prefixlen if ip6_net else None
|
||||
return Interface(
|
||||
id=iface_id,
|
||||
mac=mac,
|
||||
ip4=ip4,
|
||||
ip4_mask=ip4_mask,
|
||||
ip6=ip6,
|
||||
ip6_mask=ip6_mask,
|
||||
id=iface_id, mac=mac, ip4=ip4, ip4_mask=ip4_mask, ip6=ip6, ip6_mask=ip6_mask
|
||||
)
|
||||
|
||||
|
||||
|
@ -216,12 +214,14 @@ def query_session(core: CoreGrpcClient, args: Namespace) -> None:
|
|||
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(
|
||||
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("Node | ", end="")
|
||||
print_iface_header()
|
||||
print(f"{n1:<6} | ", end="")
|
||||
if link.iface1:
|
||||
|
@ -248,7 +248,9 @@ def query_node(core: CoreGrpcClient, args: Namespace) -> None:
|
|||
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}")
|
||||
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="")
|
||||
|
@ -348,10 +350,14 @@ def add_link(core: CoreGrpcClient, args: Namespace) -> None:
|
|||
session_id = get_current_session(core, args.session)
|
||||
iface1 = None
|
||||
if args.iface1_id is not None:
|
||||
iface1 = create_iface(args.iface1_id, args.iface1_mac, args.iface1_ip4, args.iface1_ip6)
|
||||
iface1 = create_iface(
|
||||
args.iface1_id, args.iface1_mac, args.iface1_ip4, args.iface1_ip6
|
||||
)
|
||||
iface2 = None
|
||||
if args.iface2_id is not None:
|
||||
iface2 = create_iface(args.iface2_id, args.iface2_mac, args.iface2_ip4, args.iface2_ip6)
|
||||
iface2 = create_iface(
|
||||
args.iface2_id, args.iface2_mac, args.iface2_ip4, args.iface2_ip6
|
||||
)
|
||||
options = LinkOptions(
|
||||
bandwidth=args.bandwidth,
|
||||
loss=args.loss,
|
||||
|
@ -432,13 +438,17 @@ def setup_node_parser(parent) -> None:
|
|||
add_parser.add_argument(
|
||||
"-t", "--type", choices=NODE_TYPES, default="DEFAULT", help="type of node"
|
||||
)
|
||||
add_parser.add_argument("-m", "--model", help="used to determine services, optional")
|
||||
add_parser.add_argument(
|
||||
"-m", "--model", help="used to determine services, optional"
|
||||
)
|
||||
group = add_parser.add_mutually_exclusive_group(required=True)
|
||||
group.add_argument("-p", "--pos", type=position_type, help="x,y position")
|
||||
group.add_argument("-g", "--geo", type=geo_type, help="lon,lat,alt position")
|
||||
add_parser.add_argument("-ic", "--icon", help="icon to use, optional")
|
||||
add_parser.add_argument("-im", "--image", help="container image, optional")
|
||||
add_parser.add_argument("-e", "--emane", help="emane model, only required for emane nodes")
|
||||
add_parser.add_argument(
|
||||
"-e", "--emane", help="emane model, only required for emane nodes"
|
||||
)
|
||||
add_parser.set_defaults(func=add_node)
|
||||
|
||||
edit_parser = subparsers.add_parser("edit", help="edit a node")
|
||||
|
@ -449,7 +459,9 @@ def setup_node_parser(parent) -> None:
|
|||
|
||||
move_parser = subparsers.add_parser("move", help="move a node")
|
||||
move_parser.formatter_class = ArgumentDefaultsHelpFormatter
|
||||
move_parser.add_argument("-i", "--id", type=int, help="id to use, optional", required=True)
|
||||
move_parser.add_argument(
|
||||
"-i", "--id", type=int, help="id to use, optional", required=True
|
||||
)
|
||||
group = move_parser.add_mutually_exclusive_group(required=True)
|
||||
group.add_argument("-p", "--pos", type=position_type, help="x,y position")
|
||||
group.add_argument("-g", "--geo", type=geo_type, help="lon,lat,alt position")
|
||||
|
@ -474,19 +486,33 @@ def setup_link_parser(parent) -> None:
|
|||
add_parser.add_argument("-n1", "--node1", type=int, help="node1 id", required=True)
|
||||
add_parser.add_argument("-n2", "--node2", type=int, help="node2 id", required=True)
|
||||
add_parser.add_argument("-i1-i", "--iface1-id", type=int, help="node1 interface id")
|
||||
add_parser.add_argument("-i1-m", "--iface1-mac", type=mac_type, help="node1 interface mac")
|
||||
add_parser.add_argument("-i1-4", "--iface1-ip4", type=ip4_type, help="node1 interface ip4")
|
||||
add_parser.add_argument("-i1-6", "--iface1-ip6", type=ip6_type, help="node1 interface ip6")
|
||||
add_parser.add_argument(
|
||||
"-i1-m", "--iface1-mac", type=mac_type, help="node1 interface mac"
|
||||
)
|
||||
add_parser.add_argument(
|
||||
"-i1-4", "--iface1-ip4", type=ip4_type, help="node1 interface ip4"
|
||||
)
|
||||
add_parser.add_argument(
|
||||
"-i1-6", "--iface1-ip6", type=ip6_type, help="node1 interface ip6"
|
||||
)
|
||||
add_parser.add_argument("-i2-i", "--iface2-id", type=int, help="node2 interface id")
|
||||
add_parser.add_argument("-i2-m", "--iface2-mac", type=mac_type, help="node2 interface mac")
|
||||
add_parser.add_argument("-i2-4", "--iface2-ip4", type=ip4_type, help="node2 interface ip4")
|
||||
add_parser.add_argument("-i2-6", "--iface2-ip6", type=ip6_type, help="node2 interface ip6")
|
||||
add_parser.add_argument(
|
||||
"-i2-m", "--iface2-mac", type=mac_type, help="node2 interface mac"
|
||||
)
|
||||
add_parser.add_argument(
|
||||
"-i2-4", "--iface2-ip4", type=ip4_type, help="node2 interface ip4"
|
||||
)
|
||||
add_parser.add_argument(
|
||||
"-i2-6", "--iface2-ip6", type=ip6_type, help="node2 interface ip6"
|
||||
)
|
||||
add_parser.add_argument("-b", "--bandwidth", type=int, help="bandwidth (bps)")
|
||||
add_parser.add_argument("-l", "--loss", type=float, help="loss (%%)")
|
||||
add_parser.add_argument("-j", "--jitter", type=int, help="jitter (us)")
|
||||
add_parser.add_argument("-de", "--delay", type=int, help="delay (us)")
|
||||
add_parser.add_argument("-du", "--duplicate", type=int, help="duplicate (%%)")
|
||||
add_parser.add_argument("-u", "--uni", action="store_true", help="is link unidirectional?")
|
||||
add_parser.add_argument(
|
||||
"-u", "--uni", action="store_true", help="is link unidirectional?"
|
||||
)
|
||||
add_parser.set_defaults(func=add_link)
|
||||
|
||||
edit_parser = subparsers.add_parser("edit", help="edit a link")
|
||||
|
@ -507,8 +533,12 @@ def setup_link_parser(parent) -> None:
|
|||
|
||||
delete_parser = subparsers.add_parser("delete", help="delete a link")
|
||||
delete_parser.formatter_class = ArgumentDefaultsHelpFormatter
|
||||
delete_parser.add_argument("-n1", "--node1", type=int, help="node1 id", required=True)
|
||||
delete_parser.add_argument("-n2", "--node2", type=int, help="node1 id", required=True)
|
||||
delete_parser.add_argument(
|
||||
"-n1", "--node1", type=int, help="node1 id", required=True
|
||||
)
|
||||
delete_parser.add_argument(
|
||||
"-n2", "--node2", type=int, help="node1 id", required=True
|
||||
)
|
||||
delete_parser.add_argument("-i1", "--iface1", type=int, help="node1 interface id")
|
||||
delete_parser.add_argument("-i2", "--iface2", type=int, help="node2 interface id")
|
||||
delete_parser.set_defaults(func=delete_link)
|
||||
|
@ -526,20 +556,28 @@ def setup_query_parser(parent) -> None:
|
|||
|
||||
session_parser = subparsers.add_parser("session", help="query session")
|
||||
session_parser.formatter_class = ArgumentDefaultsHelpFormatter
|
||||
session_parser.add_argument("-i", "--id", type=int, help="session to query", required=True)
|
||||
session_parser.add_argument(
|
||||
"-i", "--id", type=int, help="session to query", required=True
|
||||
)
|
||||
session_parser.set_defaults(func=query_session)
|
||||
|
||||
node_parser = subparsers.add_parser("node", help="query node")
|
||||
node_parser.formatter_class = ArgumentDefaultsHelpFormatter
|
||||
node_parser.add_argument("-i", "--id", type=int, help="session to query", required=True)
|
||||
node_parser.add_argument("-n", "--node", type=int, help="node to query", required=True)
|
||||
node_parser.add_argument(
|
||||
"-i", "--id", type=int, help="session to query", required=True
|
||||
)
|
||||
node_parser.add_argument(
|
||||
"-n", "--node", type=int, help="node to query", required=True
|
||||
)
|
||||
node_parser.set_defaults(func=query_node)
|
||||
|
||||
|
||||
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)
|
||||
parser.add_argument(
|
||||
"-f", "--file", type=file_type, help="xml file to open", required=True
|
||||
)
|
||||
parser.add_argument("-s", "--start", action="store_true", help="start the session?")
|
||||
parser.set_defaults(func=open_xml)
|
||||
|
|
@ -1,4 +1,3 @@
|
|||
#!/usr/bin/env python3
|
||||
"""
|
||||
core-daemon: the CORE daemon is a server process that receives CORE API
|
||||
messages and instantiates emulated nodes and networks within the kernel. Various
|
||||
|
@ -61,18 +60,35 @@ def get_merged_config(filename):
|
|||
defaults = {
|
||||
"grpcport": default_grpc_port,
|
||||
"grpcaddress": default_address,
|
||||
"logfile": default_log
|
||||
"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("--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}")
|
||||
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(
|
||||
"--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
|
|
@ -1,4 +1,3 @@
|
|||
#!/usr/bin/env python3
|
||||
import argparse
|
||||
import logging
|
||||
from logging.handlers import TimedRotatingFileHandler
|
||||
|
@ -9,12 +8,19 @@ from core.gui.app import Application
|
|||
|
||||
def main() -> None:
|
||||
# parse flags
|
||||
parser = argparse.ArgumentParser(description=f"CORE Python GUI")
|
||||
parser.add_argument("-l", "--level", choices=["DEBUG", "INFO", "WARNING", "ERROR", "CRITICAL"], default="INFO",
|
||||
help="logging level")
|
||||
parser = argparse.ArgumentParser(description="CORE Python GUI")
|
||||
parser.add_argument(
|
||||
"-l",
|
||||
"--level",
|
||||
choices=["DEBUG", "INFO", "WARNING", "ERROR", "CRITICAL"],
|
||||
default="INFO",
|
||||
help="logging level",
|
||||
)
|
||||
parser.add_argument("-p", "--proxy", action="store_true", help="enable proxy")
|
||||
parser.add_argument("-s", "--session", type=int, help="session id to join")
|
||||
parser.add_argument("--create-dir", action="store_true", help="create gui directory and exit")
|
||||
parser.add_argument(
|
||||
"--create-dir", action="store_true", help="create gui directory and exit"
|
||||
)
|
||||
args = parser.parse_args()
|
||||
|
||||
# check home directory exists and create if necessary
|
||||
|
@ -25,9 +31,13 @@ def main() -> None:
|
|||
# setup logging
|
||||
log_format = "%(asctime)s - %(levelname)s - %(module)s:%(funcName)s - %(message)s"
|
||||
stream_handler = logging.StreamHandler()
|
||||
file_handler = TimedRotatingFileHandler(filename=appconfig.LOG_PATH, when="D", backupCount=5)
|
||||
file_handler = TimedRotatingFileHandler(
|
||||
filename=appconfig.LOG_PATH, when="D", backupCount=5
|
||||
)
|
||||
log_level = logging.getLevelName(args.level)
|
||||
logging.basicConfig(level=log_level, format=log_format, handlers=[stream_handler, file_handler])
|
||||
logging.basicConfig(
|
||||
level=log_level, format=log_format, handlers=[stream_handler, file_handler]
|
||||
)
|
||||
logging.getLogger("PIL").setLevel(logging.ERROR)
|
||||
|
||||
# start app
|
|
@ -1,5 +1,3 @@
|
|||
#!/usr/bin/env python3
|
||||
|
||||
import argparse
|
||||
import logging
|
||||
import sys
|
||||
|
@ -31,7 +29,10 @@ def parse_args() -> argparse.Namespace:
|
|||
"-f", "--file", required=True, type=path_type, help="core file to play"
|
||||
)
|
||||
parser.add_argument(
|
||||
"-s", "--session", type=int, help="session to play to, first found session otherwise"
|
||||
"-s",
|
||||
"--session",
|
||||
type=int,
|
||||
help="session to play to, first found session otherwise",
|
||||
)
|
||||
return parser.parse_args()
|
||||
|
|
@ -1,4 +1,3 @@
|
|||
#!/usr/bin/env python3
|
||||
import argparse
|
||||
import enum
|
||||
import select
|
||||
|
@ -60,15 +59,15 @@ class SdtClient:
|
|||
|
||||
class RouterMonitor:
|
||||
def __init__(
|
||||
self,
|
||||
session: int,
|
||||
src: str,
|
||||
dst: str,
|
||||
pkt: str,
|
||||
rate: int,
|
||||
dead: int,
|
||||
sdt_host: str,
|
||||
sdt_port: int,
|
||||
self,
|
||||
session: int,
|
||||
src: str,
|
||||
dst: str,
|
||||
pkt: str,
|
||||
rate: int,
|
||||
dead: int,
|
||||
sdt_host: str,
|
||||
sdt_port: int,
|
||||
) -> None:
|
||||
self.queue = Queue()
|
||||
self.core = CoreGrpcClient()
|
|
@ -1,4 +1,3 @@
|
|||
#!/usr/bin/env python3
|
||||
import argparse
|
||||
import re
|
||||
from io import TextIOWrapper
|
||||
|
@ -6,9 +5,15 @@ from io import TextIOWrapper
|
|||
|
||||
def parse_args() -> argparse.Namespace:
|
||||
parser = argparse.ArgumentParser(
|
||||
description=f"Helps transition older CORE services to work with newer versions")
|
||||
parser.add_argument("-f", "--file", dest="file", type=argparse.FileType("r"),
|
||||
help=f"service file to update")
|
||||
description="Helps transition older CORE services to work with newer versions"
|
||||
)
|
||||
parser.add_argument(
|
||||
"-f",
|
||||
"--file",
|
||||
dest="file",
|
||||
type=argparse.FileType("r"),
|
||||
help="service file to update",
|
||||
)
|
||||
return parser.parse_args()
|
||||
|
||||
|
||||
|
@ -20,17 +25,32 @@ def update_service(service_file: TextIOWrapper) -> None:
|
|||
# rename dirs to directories
|
||||
line = re.sub(r"^(\s+)dirs", r"\1directories", line)
|
||||
# fix import states for service
|
||||
line = re.sub(r"^.+import.+CoreService.+$",
|
||||
r"from core.services.coreservices import CoreService", line)
|
||||
line = re.sub(
|
||||
r"^.+import.+CoreService.+$",
|
||||
r"from core.services.coreservices import CoreService",
|
||||
line,
|
||||
)
|
||||
# fix method signatures
|
||||
line = re.sub(r"def generateconfig\(cls, node, filename, services\)",
|
||||
r"def generate_config(cls, node, filename)", line)
|
||||
line = re.sub(r"def getvalidate\(cls, node, services\)",
|
||||
r"def get_validate(cls, node)", line)
|
||||
line = re.sub(r"def getstartup\(cls, node, services\)",
|
||||
r"def get_startup(cls, node)", line)
|
||||
line = re.sub(r"def getconfigfilenames\(cls, nodenum, services\)",
|
||||
r"def get_configs(cls, node)", line)
|
||||
line = re.sub(
|
||||
r"def generateconfig\(cls, node, filename, services\)",
|
||||
r"def generate_config(cls, node, filename)",
|
||||
line,
|
||||
)
|
||||
line = re.sub(
|
||||
r"def getvalidate\(cls, node, services\)",
|
||||
r"def get_validate(cls, node)",
|
||||
line,
|
||||
)
|
||||
line = re.sub(
|
||||
r"def getstartup\(cls, node, services\)",
|
||||
r"def get_startup(cls, node)",
|
||||
line,
|
||||
)
|
||||
line = re.sub(
|
||||
r"def getconfigfilenames\(cls, nodenum, services\)",
|
||||
r"def get_configs(cls, node)",
|
||||
line,
|
||||
)
|
||||
# remove unwanted lines
|
||||
if re.search(r"addservice\(", line):
|
||||
continue
|
|
@ -1,54 +0,0 @@
|
|||
[core-daemon]
|
||||
#distributed_address = 127.0.0.1
|
||||
grpcaddress = localhost
|
||||
grpcport = 50051
|
||||
quagga_bin_search = "/usr/local/bin /usr/bin /usr/lib/quagga"
|
||||
quagga_sbin_search = "/usr/local/sbin /usr/sbin /usr/lib/quagga"
|
||||
frr_bin_search = "/usr/local/bin /usr/bin /usr/lib/frr"
|
||||
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/<user>/.coregui/custom_services
|
||||
#custom_config_services_dir = /home/<user>/.coregui/custom_services
|
||||
|
||||
# uncomment to establish a standalone control backchannel for accessing nodes
|
||||
# (overriden by the session option of the same name)
|
||||
#controlnet = 172.16.0.0/24
|
||||
|
||||
# uncomment and edit to establish a distributed control backchannel
|
||||
#controlnet = core1:172.16.1.0/24 core2:172.16.2.0/24 core3:172.16.3.0/24 core4:172.16.4.0/24 core5:172.16.5.0/24
|
||||
|
||||
# uncomment and edit to establish distributed auxiliary control channels.
|
||||
#controlnet1 = core1:172.17.1.0/24 core2:172.17.2.0/24 core3:172.17.3.0/24 core4:172.17.4.0/24 core5:172.17.5.0/24
|
||||
#controlnet2 = core1:172.18.1.0/24 core2:172.18.2.0/24 core3:172.18.3.0/24 core4:172.18.4.0/24 core5:172.18.5.0/24
|
||||
#controlnet3 = core1:172.19.1.0/24 core2:172.19.2.0/24 core3:172.19.3.0/24 core4:172.19.4.0/24 core5:172.19.5.0/24
|
||||
|
||||
# uncomment and edit to assign host interfaces to auxilary control channels
|
||||
# for use in connecting with other servers in a distributed environments.
|
||||
# Note: This is valid for auxiliary control channels only. The primary control
|
||||
# channel, specified by 'controlnet', is tunneled across servers.
|
||||
#controlnetif1 = eth2
|
||||
#controlnetif2 = eth3
|
||||
#controlnetif3 = eth4
|
||||
|
||||
# optional controlnet configuration script for controlnet, uncomment to
|
||||
# activate, and likely edit the script.
|
||||
# Note: the controlnet_updown_script is not used by the auxiliary control
|
||||
# channels.
|
||||
# controlnet_updown_script = /usr/local/share/core/examples/controlnet_updown
|
||||
# publish nodes' control IP addresses to /etc/hosts
|
||||
#update_etc_hosts = True
|
||||
|
||||
# EMANE configuration
|
||||
emane_platform_port = 8101
|
||||
emane_transform_port = 8201
|
||||
emane_event_generate = True
|
||||
emane_event_monitor = False
|
||||
#emane_models_dir = /home/<user>/.coregui/custom_emane
|
||||
# EMANE log level range [0,4] default: 2
|
||||
#emane_log_level = 2
|
||||
emane_realtime = True
|
||||
# prefix used for emane installation
|
||||
# emane_prefix = /usr
|
|
@ -1,33 +0,0 @@
|
|||
{
|
||||
"version": 1,
|
||||
"handlers": {
|
||||
"console": {
|
||||
"class": "logging.StreamHandler",
|
||||
"formatter": "default",
|
||||
"level": "DEBUG",
|
||||
"stream": "ext://sys.stdout"
|
||||
}
|
||||
},
|
||||
"formatters": {
|
||||
"default": {
|
||||
"format": "%(asctime)s - %(levelname)s - %(module)s:%(funcName)s - %(message)s"
|
||||
}
|
||||
},
|
||||
"loggers": {
|
||||
"": {
|
||||
"level": "WARNING",
|
||||
"handlers": ["console"],
|
||||
"propagate": false
|
||||
},
|
||||
"core": {
|
||||
"level": "INFO",
|
||||
"handlers": ["console"],
|
||||
"propagate": false
|
||||
},
|
||||
"__main__": {
|
||||
"level": "INFO",
|
||||
"handlers": ["console"],
|
||||
"propagate": false
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,35 +0,0 @@
|
|||
import logging
|
||||
|
||||
from core.emulator.coreemu import CoreEmu
|
||||
from core.emulator.data import IpPrefixes
|
||||
from core.emulator.enumerations import EventTypes
|
||||
from core.nodes.base import CoreNode
|
||||
from core.nodes.network import SwitchNode
|
||||
|
||||
if __name__ == "__main__":
|
||||
logging.basicConfig(level=logging.DEBUG)
|
||||
|
||||
# setup basic network
|
||||
prefixes = IpPrefixes(ip4_prefix="10.83.0.0/16")
|
||||
coreemu = CoreEmu()
|
||||
session = coreemu.create_session()
|
||||
session.set_state(EventTypes.CONFIGURATION_STATE)
|
||||
switch = session.add_node(SwitchNode)
|
||||
|
||||
# node one
|
||||
options = CoreNode.create_options()
|
||||
options.config_services = ["DefaultRoute", "IPForward"]
|
||||
node1 = session.add_node(CoreNode, options=options)
|
||||
interface = prefixes.create_iface(node1)
|
||||
session.add_link(node1.id, switch.id, iface1_data=interface)
|
||||
|
||||
# node two
|
||||
node2 = session.add_node(CoreNode, options=options)
|
||||
interface = prefixes.create_iface(node2)
|
||||
session.add_link(node2.id, switch.id, iface1_data=interface)
|
||||
|
||||
# start session and run services
|
||||
session.instantiate()
|
||||
|
||||
input("press enter to exit")
|
||||
session.shutdown()
|
|
@ -1,53 +0,0 @@
|
|||
#!/bin/bash
|
||||
# Sample controlnet up/down script that will be executed when the control
|
||||
# network is brought up or down. This script either adds an interface to the
|
||||
# controlnet bridge or adds a permissive iptables firewall rule.
|
||||
|
||||
controlnet_intf=$1
|
||||
action=$2
|
||||
|
||||
config_type=iptables # iptables or brctl
|
||||
|
||||
iptables_address=10.205.15.132
|
||||
brctl_intf=eth2
|
||||
|
||||
BRCTL=/sbin/brctl
|
||||
IPTABLES=/usr/sbin/iptables
|
||||
|
||||
case "$action" in
|
||||
startup)
|
||||
case "$config_type" in
|
||||
iptables)
|
||||
$IPTABLES -I FORWARD -i $controlnet_intf -d $iptables_address -j ACCEPT
|
||||
$IPTABLES -I FORWARD -o $controlnet_intf -s $iptables_address -j ACCEPT
|
||||
;;
|
||||
brctl)
|
||||
$BRCTL addif $controlnet_intf $brctl_intf
|
||||
;;
|
||||
*)
|
||||
echo "Invalid config_type $config_type"
|
||||
;;
|
||||
esac
|
||||
;;
|
||||
|
||||
shutdown)
|
||||
case "$config_type" in
|
||||
iptables)
|
||||
$IPTABLES -D FORWARD -i $controlnet_intf -d $iptables_address -j ACCEPT
|
||||
$IPTABLES -D FORWARD -o $controlnet_intf -s $iptables_address -j ACCEPT
|
||||
;;
|
||||
brctl)
|
||||
$BRCTL delif $controlnet_intf $brctl_intf
|
||||
;;
|
||||
*)
|
||||
echo "Invalid config_type $config_type"
|
||||
;;
|
||||
esac
|
||||
;;
|
||||
|
||||
*)
|
||||
echo "Invalid action $action"
|
||||
exit 1
|
||||
;;
|
||||
esac
|
||||
exit 0
|
|
@ -1,35 +0,0 @@
|
|||
import logging
|
||||
|
||||
from core.emulator.coreemu import CoreEmu
|
||||
from core.emulator.data import IpPrefixes
|
||||
from core.emulator.enumerations import EventTypes
|
||||
from core.nodes.base import CoreNode
|
||||
from core.nodes.docker import DockerNode
|
||||
|
||||
if __name__ == "__main__":
|
||||
logging.basicConfig(level=logging.DEBUG)
|
||||
coreemu = CoreEmu()
|
||||
session = coreemu.create_session()
|
||||
session.set_state(EventTypes.CONFIGURATION_STATE)
|
||||
|
||||
try:
|
||||
prefixes = IpPrefixes(ip4_prefix="10.83.0.0/16")
|
||||
|
||||
# create node one
|
||||
options = DockerNode.create_options()
|
||||
options.image = "ubuntu"
|
||||
node1 = session.add_node(DockerNode, options=options)
|
||||
interface1_data = prefixes.create_iface(node1)
|
||||
|
||||
# create node two
|
||||
node2 = session.add_node(CoreNode)
|
||||
interface2_data = prefixes.create_iface(node2)
|
||||
|
||||
# add link
|
||||
session.add_link(node1.id, node2.id, interface1_data, interface2_data)
|
||||
|
||||
# instantiate
|
||||
session.instantiate()
|
||||
finally:
|
||||
input("continue to shutdown")
|
||||
coreemu.shutdown()
|
|
@ -1,36 +0,0 @@
|
|||
import logging
|
||||
|
||||
from core.emulator.coreemu import CoreEmu
|
||||
from core.emulator.data import IpPrefixes
|
||||
from core.emulator.enumerations import EventTypes
|
||||
from core.nodes.docker import DockerNode
|
||||
|
||||
if __name__ == "__main__":
|
||||
logging.basicConfig(level=logging.DEBUG)
|
||||
|
||||
coreemu = CoreEmu()
|
||||
session = coreemu.create_session()
|
||||
session.set_state(EventTypes.CONFIGURATION_STATE)
|
||||
|
||||
# create nodes and interfaces
|
||||
try:
|
||||
prefixes = IpPrefixes(ip4_prefix="10.83.0.0/16")
|
||||
|
||||
# create node one
|
||||
options = DockerNode.create_options()
|
||||
options.image = "ubuntu"
|
||||
node1 = session.add_node(DockerNode, options=options)
|
||||
interface1_data = prefixes.create_iface(node1)
|
||||
|
||||
# create node two
|
||||
node2 = session.add_node(DockerNode, options=options)
|
||||
interface2_data = prefixes.create_iface(node2)
|
||||
|
||||
# add link
|
||||
session.add_link(node1.id, node2.id, interface1_data, interface2_data)
|
||||
|
||||
# instantiate
|
||||
session.instantiate()
|
||||
finally:
|
||||
input("continue to shutdown")
|
||||
coreemu.shutdown()
|
|
@ -1,48 +0,0 @@
|
|||
import logging
|
||||
|
||||
from core.emulator.coreemu import CoreEmu
|
||||
from core.emulator.data import IpPrefixes
|
||||
from core.emulator.enumerations import EventTypes
|
||||
from core.nodes.base import CoreNode
|
||||
from core.nodes.docker import DockerNode
|
||||
from core.nodes.network import SwitchNode
|
||||
|
||||
if __name__ == "__main__":
|
||||
logging.basicConfig(level=logging.DEBUG)
|
||||
|
||||
# create core session
|
||||
coreemu = CoreEmu()
|
||||
session = coreemu.create_session()
|
||||
session.set_state(EventTypes.CONFIGURATION_STATE)
|
||||
try:
|
||||
prefixes = IpPrefixes(ip4_prefix="10.83.0.0/16")
|
||||
|
||||
# create switch
|
||||
switch = session.add_node(SwitchNode)
|
||||
|
||||
# node one
|
||||
options = DockerNode.create_options()
|
||||
options.image = "ubuntu"
|
||||
node1 = session.add_node(DockerNode, options=options)
|
||||
interface1_data = prefixes.create_iface(node1)
|
||||
|
||||
# node two
|
||||
node2 = session.add_node(DockerNode, options=options)
|
||||
interface2_data = prefixes.create_iface(node2)
|
||||
|
||||
# node three
|
||||
node_three = session.add_node(CoreNode)
|
||||
interface_three = prefixes.create_iface(node_three)
|
||||
|
||||
# add links
|
||||
session.add_link(node1.id, switch.id, interface1_data)
|
||||
session.add_link(node2.id, switch.id, interface2_data)
|
||||
session.add_link(node_three.id, switch.id, interface_three)
|
||||
|
||||
# instantiate
|
||||
session.instantiate()
|
||||
|
||||
print(f"{node2.name}: {node2.volumes.values()}")
|
||||
finally:
|
||||
input("continue to shutdown")
|
||||
coreemu.shutdown()
|
|
@ -1,64 +0,0 @@
|
|||
import argparse
|
||||
import logging
|
||||
|
||||
from core.api.grpc import client
|
||||
from core.api.grpc.wrappers import NodeType, Position, Server
|
||||
|
||||
|
||||
def log_event(event):
|
||||
logging.info("event: %s", event)
|
||||
|
||||
|
||||
def main(args):
|
||||
# helper to create interfaces
|
||||
interface_helper = client.InterfaceHelper(ip4_prefix="10.83.0.0/16")
|
||||
|
||||
# create grpc client and connect
|
||||
core = client.CoreGrpcClient()
|
||||
core.connect()
|
||||
|
||||
# create session
|
||||
session = core.create_session()
|
||||
|
||||
# add distributed server
|
||||
server = Server(name="core2", host=args.server)
|
||||
session.servers.append(server)
|
||||
|
||||
# handle events session may broadcast
|
||||
core.events(session.id, log_event)
|
||||
|
||||
# create switch node
|
||||
position = Position(x=150, y=100)
|
||||
switch = session.add_node(1, _type=NodeType.SWITCH, position=position)
|
||||
position = Position(x=100, y=50)
|
||||
node1 = session.add_node(2, position=position)
|
||||
position = Position(x=200, y=50)
|
||||
node2 = session.add_node(3, position=position, server=server.name)
|
||||
|
||||
# create links
|
||||
iface1 = interface_helper.create_iface(node1.id, 0)
|
||||
session.add_link(node1=node1, node2=switch, iface1=iface1)
|
||||
iface1 = interface_helper.create_iface(node2.id, 0)
|
||||
session.add_link(node1=node2, node2=switch, iface1=iface1)
|
||||
|
||||
# start session
|
||||
core.start_session(session)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
logging.basicConfig(level=logging.DEBUG)
|
||||
parser = argparse.ArgumentParser(description="Run distributed_switch example")
|
||||
parser.add_argument(
|
||||
"-a",
|
||||
"--address",
|
||||
required=True,
|
||||
help="local address that distributed servers will use for gre tunneling",
|
||||
)
|
||||
parser.add_argument(
|
||||
"-s",
|
||||
"--server",
|
||||
required=True,
|
||||
help="distributed server to use for creating nodes",
|
||||
)
|
||||
args = parser.parse_args()
|
||||
main(args)
|
|
@ -1,38 +0,0 @@
|
|||
# required imports
|
||||
from core.api.grpc import client
|
||||
from core.api.grpc.wrappers import NodeType, Position
|
||||
from core.emane.models.ieee80211abg import EmaneIeee80211abgModel
|
||||
|
||||
# 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)
|
||||
emane = session.add_node(
|
||||
1, _type=NodeType.EMANE, position=position, emane=EmaneIeee80211abgModel.name
|
||||
)
|
||||
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=emane, iface1=iface1)
|
||||
iface1 = iface_helper.create_iface(node2.id, 0)
|
||||
session.add_link(node1=node2, node2=emane, iface1=iface1)
|
||||
|
||||
# setup emane configurations using a dict mapping currently support values as strings
|
||||
emane.set_emane_model(
|
||||
EmaneIeee80211abgModel.name, {"eventservicettl": "2", "unicastrate": "3"}
|
||||
)
|
||||
|
||||
# start session
|
||||
core.start_session(session)
|
|
@ -1,26 +0,0 @@
|
|||
from core.api.grpc import client
|
||||
from core.api.grpc.wrappers import 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=100, y=100)
|
||||
node1 = session.add_node(1, position=position)
|
||||
position = Position(x=300, y=100)
|
||||
node2 = session.add_node(2, position=position)
|
||||
|
||||
# create link
|
||||
iface1 = iface_helper.create_iface(node1.id, 0)
|
||||
iface2 = iface_helper.create_iface(node2.id, 0)
|
||||
session.add_link(node1=node1, node2=node2, iface1=iface1, iface2=iface2)
|
||||
|
||||
# start session
|
||||
core.start_session(session)
|
|
@ -1,29 +0,0 @@
|
|||
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)
|
||||
switch = session.add_node(1, _type=NodeType.SWITCH, position=position)
|
||||
position = Position(x=100, y=100)
|
||||
node1 = session.add_node(2, position=position)
|
||||
position = Position(x=300, y=100)
|
||||
node2 = session.add_node(3, position=position)
|
||||
|
||||
# create links
|
||||
iface1 = iface_helper.create_iface(node1.id, 0)
|
||||
session.add_link(node1=node1, node2=switch, iface1=iface1)
|
||||
iface1 = iface_helper.create_iface(node2.id, 0)
|
||||
session.add_link(node1=node2, node2=switch, iface1=iface1)
|
||||
|
||||
# start session
|
||||
core.start_session(session)
|
|
@ -1,29 +0,0 @@
|
|||
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)
|
|
@ -1,41 +0,0 @@
|
|||
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_LAN, 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)
|
||||
|
||||
# set wlan config using a dict mapping currently
|
||||
# support values as strings
|
||||
wlan.set_wlan(
|
||||
{
|
||||
"range": "280",
|
||||
"bandwidth": "55000000",
|
||||
"delay": "6000",
|
||||
"jitter": "5",
|
||||
"error": "5",
|
||||
}
|
||||
)
|
||||
|
||||
# start session
|
||||
core.start_session(session)
|
|
@ -1,35 +0,0 @@
|
|||
import logging
|
||||
|
||||
from core.emulator.coreemu import CoreEmu
|
||||
from core.emulator.data import IpPrefixes
|
||||
from core.emulator.enumerations import EventTypes
|
||||
from core.nodes.base import CoreNode
|
||||
from core.nodes.lxd import LxcNode
|
||||
|
||||
if __name__ == "__main__":
|
||||
logging.basicConfig(level=logging.DEBUG)
|
||||
coreemu = CoreEmu()
|
||||
session = coreemu.create_session()
|
||||
session.set_state(EventTypes.CONFIGURATION_STATE)
|
||||
|
||||
try:
|
||||
prefixes = IpPrefixes(ip4_prefix="10.83.0.0/16")
|
||||
|
||||
# create node one
|
||||
options = LxcNode.create_options()
|
||||
options.image = "ubuntu"
|
||||
node1 = session.add_node(LxcNode, options=options)
|
||||
interface1_data = prefixes.create_iface(node1)
|
||||
|
||||
# create node two
|
||||
node2 = session.add_node(CoreNode)
|
||||
interface2_data = prefixes.create_iface(node2)
|
||||
|
||||
# add link
|
||||
session.add_link(node1.id, node2.id, interface1_data, interface2_data)
|
||||
|
||||
# instantiate
|
||||
session.instantiate()
|
||||
finally:
|
||||
input("continue to shutdown")
|
||||
coreemu.shutdown()
|
|
@ -1,36 +0,0 @@
|
|||
import logging
|
||||
|
||||
from core.emulator.coreemu import CoreEmu
|
||||
from core.emulator.data import IpPrefixes
|
||||
from core.emulator.enumerations import EventTypes
|
||||
from core.nodes.lxd import LxcNode
|
||||
|
||||
if __name__ == "__main__":
|
||||
logging.basicConfig(level=logging.INFO)
|
||||
|
||||
coreemu = CoreEmu()
|
||||
session = coreemu.create_session()
|
||||
session.set_state(EventTypes.CONFIGURATION_STATE)
|
||||
|
||||
# create nodes and interfaces
|
||||
try:
|
||||
prefixes = IpPrefixes(ip4_prefix="10.83.0.0/16")
|
||||
|
||||
# create node one
|
||||
options = LxcNode.create_options()
|
||||
options.image = "ubuntu:18.04"
|
||||
node1 = session.add_node(LxcNode, options=options)
|
||||
interface1_data = prefixes.create_iface(node1)
|
||||
|
||||
# create node two
|
||||
node2 = session.add_node(LxcNode, options=options)
|
||||
interface2_data = prefixes.create_iface(node2)
|
||||
|
||||
# add link
|
||||
session.add_link(node1.id, node2.id, interface1_data, interface2_data)
|
||||
|
||||
# instantiate
|
||||
session.instantiate()
|
||||
finally:
|
||||
input("continue to shutdown")
|
||||
coreemu.shutdown()
|
|
@ -1,46 +0,0 @@
|
|||
import logging
|
||||
|
||||
from core.emulator.coreemu import CoreEmu
|
||||
from core.emulator.data import IpPrefixes
|
||||
from core.emulator.enumerations import EventTypes
|
||||
from core.nodes.base import CoreNode
|
||||
from core.nodes.lxd import LxcNode
|
||||
from core.nodes.network import SwitchNode
|
||||
|
||||
if __name__ == "__main__":
|
||||
logging.basicConfig(level=logging.DEBUG)
|
||||
|
||||
coreemu = CoreEmu()
|
||||
session = coreemu.create_session()
|
||||
session.set_state(EventTypes.CONFIGURATION_STATE)
|
||||
|
||||
try:
|
||||
prefixes = IpPrefixes(ip4_prefix="10.83.0.0/16")
|
||||
|
||||
# create switch
|
||||
switch = session.add_node(SwitchNode)
|
||||
|
||||
# node one
|
||||
options = LxcNode.create_options()
|
||||
options.image = "ubuntu"
|
||||
node1 = session.add_node(LxcNode, options=options)
|
||||
interface1_data = prefixes.create_iface(node1)
|
||||
|
||||
# node two
|
||||
node2 = session.add_node(LxcNode, options=options)
|
||||
interface2_data = prefixes.create_iface(node2)
|
||||
|
||||
# node three
|
||||
node3 = session.add_node(CoreNode)
|
||||
interface3_data = prefixes.create_iface(node3)
|
||||
|
||||
# add links
|
||||
session.add_link(node1.id, switch.id, interface1_data)
|
||||
session.add_link(node2.id, switch.id, interface2_data)
|
||||
session.add_link(node3.id, switch.id, interface3_data)
|
||||
|
||||
# instantiate
|
||||
session.instantiate()
|
||||
finally:
|
||||
input("continue to shutdown")
|
||||
coreemu.shutdown()
|
|
@ -1,73 +0,0 @@
|
|||
"""
|
||||
Example custom emane model.
|
||||
"""
|
||||
from pathlib import Path
|
||||
from typing import Dict, List, Optional, Set
|
||||
|
||||
from core.config import Configuration
|
||||
from core.emane import emanemanifest, emanemodel
|
||||
|
||||
|
||||
class ExampleModel(emanemodel.EmaneModel):
|
||||
"""
|
||||
Custom emane model.
|
||||
|
||||
:cvar name: defines the emane model name that will show up in the GUI
|
||||
|
||||
Mac Definition:
|
||||
:cvar mac_library: defines that mac library that the model will reference
|
||||
:cvar mac_xml: defines the mac manifest file that will be parsed to obtain configuration options,
|
||||
that will be displayed within the GUI
|
||||
:cvar mac_defaults: allows you to override options that are maintained within the manifest file above
|
||||
:cvar mac_config: parses the manifest file and converts configurations into core supported formats
|
||||
|
||||
Phy Definition:
|
||||
NOTE: phy configuration will default to the universal model as seen below and the below section does not
|
||||
have to be included
|
||||
:cvar phy_library: defines that phy library that the model will reference, used if you need to
|
||||
provide a custom phy
|
||||
:cvar phy_xml: defines the phy manifest file that will be parsed to obtain configuration options,
|
||||
that will be displayed within the GUI
|
||||
:cvar phy_defaults: allows you to override options that are maintained within the manifest file above
|
||||
or for the default universal model
|
||||
:cvar phy_config: parses the manifest file and converts configurations into core supported formats
|
||||
|
||||
Custom Override Options:
|
||||
NOTE: these options default to what's seen below and do not have to be included
|
||||
:cvar config_ignore: allows you to ignore options within phy/mac, used typically if you needed to add
|
||||
a custom option for display within the gui
|
||||
"""
|
||||
|
||||
name: str = "emane_example"
|
||||
mac_library: str = "rfpipemaclayer"
|
||||
mac_xml: str = "rfpipemaclayer.xml"
|
||||
mac_defaults: Dict[str, str] = {
|
||||
"pcrcurveuri": "/usr/share/emane/xml/models/mac/rfpipe/rfpipepcr.xml"
|
||||
}
|
||||
mac_config: List[Configuration] = []
|
||||
phy_library: Optional[str] = None
|
||||
phy_xml: str = "emanephy.xml"
|
||||
phy_defaults: Dict[str, str] = {
|
||||
"subid": "1",
|
||||
"propagationmodel": "2ray",
|
||||
"noisemode": "none",
|
||||
}
|
||||
phy_config: List[Configuration] = []
|
||||
config_ignore: Set[str] = set()
|
||||
|
||||
@classmethod
|
||||
def load(cls, emane_prefix: Path) -> None:
|
||||
"""
|
||||
Called after being loaded within the EmaneManager. Provides configured
|
||||
emane_prefix for parsing xml files.
|
||||
|
||||
:param emane_prefix: configured emane prefix path
|
||||
:return: nothing
|
||||
"""
|
||||
manifest_path = "share/emane/manifest"
|
||||
# load mac configuration
|
||||
mac_xml_path = emane_prefix / manifest_path / cls.mac_xml
|
||||
cls.mac_config = emanemanifest.parse(mac_xml_path, cls.mac_defaults)
|
||||
# load phy configuration
|
||||
phy_xml_path = emane_prefix / manifest_path / cls.phy_xml
|
||||
cls.phy_config = emanemanifest.parse(phy_xml_path, cls.phy_defaults)
|
|
@ -1,7 +0,0 @@
|
|||
"""myservices
|
||||
|
||||
Custom services that you define can be put in this directory. Everything
|
||||
listed in __all__ is automatically loaded when you add this directory to the
|
||||
custom_services_dir = '/full/path/to/here' core.conf file option.
|
||||
"""
|
||||
__all__ = ["sample"]
|
|
@ -1,115 +0,0 @@
|
|||
"""
|
||||
Simple example custom service, used to drive shell commands on a node.
|
||||
"""
|
||||
from typing import Tuple
|
||||
|
||||
from core.nodes.base import CoreNode
|
||||
from core.services.coreservices import CoreService, ServiceMode
|
||||
|
||||
|
||||
class ExampleService(CoreService):
|
||||
"""
|
||||
Example Custom CORE Service
|
||||
|
||||
:cvar name: name used as a unique ID for this service and is required, no spaces
|
||||
:cvar group: allows you to group services within the GUI under a common name
|
||||
:cvar executables: executables this service depends on to function, if executable is
|
||||
not on the path, service will not be loaded
|
||||
:cvar dependencies: services that this service depends on for startup, tuple of
|
||||
service names
|
||||
:cvar dirs: directories that this service will create within a node
|
||||
:cvar configs: files that this service will generate, without a full path this file
|
||||
goes in the node's directory e.g. /tmp/pycore.12345/n1.conf/myfile
|
||||
:cvar startup: commands used to start this service, any non-zero exit code will
|
||||
cause a failure
|
||||
:cvar validate: commands used to validate that a service was started, any non-zero
|
||||
exit code will cause a failure
|
||||
:cvar validation_mode: validation mode, used to determine startup success.
|
||||
NON_BLOCKING - runs startup commands, and validates success with validation commands
|
||||
BLOCKING - runs startup commands, and validates success with the startup commands themselves
|
||||
TIMER - runs startup commands, and validates success by waiting for "validation_timer" alone
|
||||
:cvar validation_timer: time in seconds for a service to wait for validation, before
|
||||
determining success in TIMER/NON_BLOCKING modes.
|
||||
:cvar validation_period: period in seconds to wait before retrying validation,
|
||||
only used in NON_BLOCKING mode
|
||||
:cvar shutdown: shutdown commands to stop this service
|
||||
"""
|
||||
|
||||
name: str = "ExampleService"
|
||||
group: str = "Utility"
|
||||
executables: Tuple[str, ...] = ()
|
||||
dependencies: Tuple[str, ...] = ()
|
||||
dirs: Tuple[str, ...] = ()
|
||||
configs: Tuple[str, ...] = ("myservice1.sh", "myservice2.sh")
|
||||
startup: Tuple[str, ...] = tuple(f"sh {x}" for x in configs)
|
||||
validate: Tuple[str, ...] = ()
|
||||
validation_mode: ServiceMode = ServiceMode.NON_BLOCKING
|
||||
validation_timer: int = 5
|
||||
validation_period: float = 0.5
|
||||
shutdown: Tuple[str, ...] = ()
|
||||
|
||||
@classmethod
|
||||
def on_load(cls) -> None:
|
||||
"""
|
||||
Provides a way to run some arbitrary logic when the service is loaded, possibly
|
||||
to help facilitate dynamic settings for the environment.
|
||||
|
||||
:return: nothing
|
||||
"""
|
||||
pass
|
||||
|
||||
@classmethod
|
||||
def get_configs(cls, node: CoreNode) -> Tuple[str, ...]:
|
||||
"""
|
||||
Provides a way to dynamically generate the config files from the node a service
|
||||
will run. Defaults to the class definition and can be left out entirely if not
|
||||
needed.
|
||||
|
||||
:param node: core node that the service is being ran on
|
||||
:return: tuple of config files to create
|
||||
"""
|
||||
return cls.configs
|
||||
|
||||
@classmethod
|
||||
def generate_config(cls, node: CoreNode, filename: str) -> str:
|
||||
"""
|
||||
Returns a string representation for a file, given the node the service is
|
||||
starting on the config filename that this information will be used for. This
|
||||
must be defined, if "configs" are defined.
|
||||
|
||||
:param node: core node that the service is being ran on
|
||||
:param filename: configuration file to generate
|
||||
:return: configuration file content
|
||||
"""
|
||||
cfg = "#!/bin/sh\n"
|
||||
if filename == cls.configs[0]:
|
||||
cfg += "# auto-generated by MyService (sample.py)\n"
|
||||
for iface in node.get_ifaces():
|
||||
cfg += f'echo "Node {node.name} has interface {iface.name}"\n'
|
||||
elif filename == cls.configs[1]:
|
||||
cfg += "echo hello"
|
||||
return cfg
|
||||
|
||||
@classmethod
|
||||
def get_startup(cls, node: CoreNode) -> Tuple[str, ...]:
|
||||
"""
|
||||
Provides a way to dynamically generate the startup commands from the node a
|
||||
service will run. Defaults to the class definition and can be left out entirely
|
||||
if not needed.
|
||||
|
||||
:param node: core node that the service is being ran on
|
||||
:return: tuple of startup commands to run
|
||||
"""
|
||||
return cls.startup
|
||||
|
||||
@classmethod
|
||||
def get_validate(cls, node: CoreNode) -> Tuple[str, ...]:
|
||||
"""
|
||||
Provides a way to dynamically generate the validate commands from the node a
|
||||
service will run. Defaults to the class definition and can be left out entirely
|
||||
if not needed.
|
||||
|
||||
:param node: core node that the service is being ran on
|
||||
:return: tuple of commands to validate service startup with
|
||||
"""
|
||||
return cls.validate
|
|
@ -1,82 +0,0 @@
|
|||
"""
|
||||
Example for scripting a standalone distributed EMANE session that does not interact
|
||||
with the GUI.
|
||||
"""
|
||||
|
||||
import argparse
|
||||
import logging
|
||||
|
||||
from core.emane.models.ieee80211abg import EmaneIeee80211abgModel
|
||||
from core.emane.nodes import EmaneNet
|
||||
from core.emulator.coreemu import CoreEmu
|
||||
from core.emulator.data import IpPrefixes
|
||||
from core.emulator.enumerations import EventTypes
|
||||
from core.nodes.base import CoreNode
|
||||
|
||||
|
||||
def parse(name):
|
||||
parser = argparse.ArgumentParser(description=f"Run {name} example")
|
||||
parser.add_argument(
|
||||
"-a",
|
||||
"--address",
|
||||
help="local address that distributed servers will use for gre tunneling",
|
||||
)
|
||||
parser.add_argument(
|
||||
"-s", "--server", help="distributed server to use for creating nodes"
|
||||
)
|
||||
options = parser.parse_args()
|
||||
return options
|
||||
|
||||
|
||||
def main(args):
|
||||
# ip generator for example
|
||||
prefixes = IpPrefixes(ip4_prefix="10.83.0.0/16")
|
||||
|
||||
# create emulator instance for creating sessions and utility methods
|
||||
coreemu = CoreEmu(
|
||||
{
|
||||
"controlnet": "core1:172.16.1.0/24 core2:172.16.2.0/24 core3:172.16.3.0/24 "
|
||||
"core4:172.16.4.0/24 core5:172.16.5.0/24",
|
||||
"distributed_address": args.address,
|
||||
}
|
||||
)
|
||||
session = coreemu.create_session()
|
||||
|
||||
# initialize distributed
|
||||
server_name = "core2"
|
||||
session.distributed.add_server(server_name, args.server)
|
||||
|
||||
# must be in configuration state for nodes to start, when using "node_add" below
|
||||
session.set_state(EventTypes.CONFIGURATION_STATE)
|
||||
|
||||
# create local node, switch, and remote nodes
|
||||
options = CoreNode.create_options()
|
||||
options.model = "mdr"
|
||||
node1 = session.add_node(CoreNode, options=options)
|
||||
options = EmaneNet.create_options()
|
||||
options.emane_model = EmaneIeee80211abgModel.name
|
||||
emane_net = session.add_node(EmaneNet, options=options)
|
||||
options = CoreNode.create_options()
|
||||
options.server = server_name
|
||||
node2 = session.add_node(CoreNode, options=options)
|
||||
|
||||
# create node interfaces and link
|
||||
interface1_data = prefixes.create_iface(node1)
|
||||
interface2_data = prefixes.create_iface(node2)
|
||||
session.add_link(node1.id, emane_net.id, iface1_data=interface1_data)
|
||||
session.add_link(node2.id, emane_net.id, iface1_data=interface2_data)
|
||||
|
||||
# instantiate session
|
||||
session.instantiate()
|
||||
|
||||
# pause script for verification
|
||||
input("press enter for shutdown")
|
||||
|
||||
# shutdown session
|
||||
coreemu.shutdown()
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
logging.basicConfig(level=logging.INFO)
|
||||
args = parse(__file__)
|
||||
main(args)
|
|
@ -1,69 +0,0 @@
|
|||
"""
|
||||
Example for scripting a standalone distributed LXD session that does not interact
|
||||
with the GUI.
|
||||
"""
|
||||
|
||||
import argparse
|
||||
import logging
|
||||
|
||||
from core.emulator.coreemu import CoreEmu
|
||||
from core.emulator.data import IpPrefixes
|
||||
from core.emulator.enumerations import EventTypes
|
||||
from core.nodes.lxd import LxcNode
|
||||
|
||||
|
||||
def parse(name):
|
||||
parser = argparse.ArgumentParser(description=f"Run {name} example")
|
||||
parser.add_argument(
|
||||
"-a",
|
||||
"--address",
|
||||
help="local address that distributed servers will use for gre tunneling",
|
||||
)
|
||||
parser.add_argument(
|
||||
"-s", "--server", help="distributed server to use for creating nodes"
|
||||
)
|
||||
options = parser.parse_args()
|
||||
return options
|
||||
|
||||
|
||||
def main(args):
|
||||
# ip generator for example
|
||||
prefixes = IpPrefixes(ip4_prefix="10.83.0.0/16")
|
||||
|
||||
# create emulator instance for creating sessions and utility methods
|
||||
coreemu = CoreEmu({"distributed_address": args.address})
|
||||
session = coreemu.create_session()
|
||||
|
||||
# initialize distributed
|
||||
server_name = "core2"
|
||||
session.distributed.add_server(server_name, args.server)
|
||||
|
||||
# must be in configuration state for nodes to start, when using "node_add" below
|
||||
session.set_state(EventTypes.CONFIGURATION_STATE)
|
||||
|
||||
# create local node, switch, and remote nodes
|
||||
options = LxcNode.create_options()
|
||||
options.image = "ubuntu:18.04"
|
||||
node1 = session.add_node(LxcNode, options=options)
|
||||
options.server = server_name
|
||||
node2 = session.add_node(LxcNode, options=options)
|
||||
|
||||
# create node interfaces and link
|
||||
interface1_data = prefixes.create_iface(node1)
|
||||
interface2_data = prefixes.create_iface(node2)
|
||||
session.add_link(node1.id, node2.id, interface1_data, interface2_data)
|
||||
|
||||
# instantiate session
|
||||
session.instantiate()
|
||||
|
||||
# pause script for verification
|
||||
input("press enter for shutdown")
|
||||
|
||||
# shutdown session
|
||||
coreemu.shutdown()
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
logging.basicConfig(level=logging.INFO)
|
||||
args = parse(__file__)
|
||||
main(args)
|
|
@ -1,66 +0,0 @@
|
|||
"""
|
||||
Example for scripting a standalone distributed peer to peer session that does not
|
||||
interact with the GUI.
|
||||
"""
|
||||
|
||||
import argparse
|
||||
import logging
|
||||
|
||||
from core.emulator.coreemu import CoreEmu
|
||||
from core.emulator.data import IpPrefixes
|
||||
from core.emulator.enumerations import EventTypes
|
||||
from core.nodes.base import CoreNode
|
||||
|
||||
|
||||
def parse(name):
|
||||
parser = argparse.ArgumentParser(description=f"Run {name} example")
|
||||
parser.add_argument(
|
||||
"-a",
|
||||
"--address",
|
||||
help="local address that distributed servers will use for gre tunneling",
|
||||
)
|
||||
parser.add_argument(
|
||||
"-s", "--server", help="distributed server to use for creating nodes"
|
||||
)
|
||||
options = parser.parse_args()
|
||||
return options
|
||||
|
||||
|
||||
def main(args):
|
||||
# ip generator for example
|
||||
prefixes = IpPrefixes(ip4_prefix="10.83.0.0/16")
|
||||
|
||||
# create emulator instance for creating sessions and utility methods
|
||||
coreemu = CoreEmu({"distributed_address": args.address})
|
||||
session = coreemu.create_session()
|
||||
|
||||
# initialize distributed
|
||||
server_name = "core2"
|
||||
session.distributed.add_server(server_name, args.server)
|
||||
|
||||
# must be in configuration state for nodes to start, when using "node_add" below
|
||||
session.set_state(EventTypes.CONFIGURATION_STATE)
|
||||
|
||||
# create local node, switch, and remote nodes
|
||||
node1 = session.add_node(CoreNode)
|
||||
node2 = session.add_node(CoreNode, server=server_name)
|
||||
|
||||
# create node interfaces and link
|
||||
interface1_data = prefixes.create_iface(node1)
|
||||
interface2_data = prefixes.create_iface(node2)
|
||||
session.add_link(node1.id, node2.id, interface1_data, interface2_data)
|
||||
|
||||
# instantiate session
|
||||
session.instantiate()
|
||||
|
||||
# pause script for verification
|
||||
input("press enter for shutdown")
|
||||
|
||||
# shutdown session
|
||||
coreemu.shutdown()
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
logging.basicConfig(level=logging.INFO)
|
||||
args = parse(__file__)
|
||||
main(args)
|
|
@ -1,73 +0,0 @@
|
|||
"""
|
||||
Example for scripting a standalone distributed switch session that does not
|
||||
interact with the GUI.
|
||||
"""
|
||||
|
||||
import argparse
|
||||
import logging
|
||||
|
||||
from core.emulator.coreemu import CoreEmu
|
||||
from core.emulator.data import IpPrefixes
|
||||
from core.emulator.enumerations import EventTypes
|
||||
from core.nodes.base import CoreNode
|
||||
from core.nodes.network import SwitchNode
|
||||
|
||||
|
||||
def parse(name):
|
||||
parser = argparse.ArgumentParser(description=f"Run {name} example")
|
||||
parser.add_argument(
|
||||
"-a",
|
||||
"--address",
|
||||
help="local address that distributed servers will use for gre tunneling",
|
||||
)
|
||||
parser.add_argument(
|
||||
"-s", "--server", help="distributed server to use for creating nodes"
|
||||
)
|
||||
options = parser.parse_args()
|
||||
return options
|
||||
|
||||
|
||||
def main(args):
|
||||
# ip generator for example
|
||||
prefixes = IpPrefixes(ip4_prefix="10.83.0.0/16")
|
||||
|
||||
# create emulator instance for creating sessions and utility methods
|
||||
coreemu = CoreEmu(
|
||||
{"controlnet": "172.16.0.0/24", "distributed_address": args.address}
|
||||
)
|
||||
session = coreemu.create_session()
|
||||
|
||||
# initialize distributed
|
||||
server_name = "core2"
|
||||
session.distributed.add_server(server_name, args.server)
|
||||
|
||||
# must be in configuration state for nodes to start, when using "node_add" below
|
||||
session.set_state(EventTypes.CONFIGURATION_STATE)
|
||||
|
||||
# create local node, switch, and remote nodes
|
||||
node1 = session.add_node(CoreNode)
|
||||
switch = session.add_node(SwitchNode)
|
||||
options = CoreNode.create_options()
|
||||
options.server = server_name
|
||||
node2 = session.add_node(CoreNode, options=options)
|
||||
|
||||
# create node interfaces and link
|
||||
interface1_data = prefixes.create_iface(node1)
|
||||
interface2_data = prefixes.create_iface(node2)
|
||||
session.add_link(node1.id, switch.id, iface1_data=interface1_data)
|
||||
session.add_link(node2.id, switch.id, iface1_data=interface2_data)
|
||||
|
||||
# instantiate session
|
||||
session.instantiate()
|
||||
|
||||
# pause script for verification
|
||||
input("press enter for shutdown")
|
||||
|
||||
# shutdown session
|
||||
coreemu.shutdown()
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
logging.basicConfig(level=logging.INFO)
|
||||
args = parse(__file__)
|
||||
main(args)
|
|
@ -1,62 +0,0 @@
|
|||
# required imports
|
||||
from core.emane.models.ieee80211abg import EmaneIeee80211abgModel
|
||||
from core.emane.nodes import EmaneNet
|
||||
from core.emulator.coreemu import CoreEmu
|
||||
from core.emulator.data import IpPrefixes
|
||||
from core.emulator.enumerations import EventTypes
|
||||
from core.nodes.base import CoreNode, Position
|
||||
|
||||
# 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()
|
||||
|
||||
# location information is required to be set for emane
|
||||
session.location.setrefgeo(47.57917, -122.13232, 2.0)
|
||||
session.location.refscale = 150.0
|
||||
|
||||
# must be in configuration state for nodes to start, when using "node_add" below
|
||||
session.set_state(EventTypes.CONFIGURATION_STATE)
|
||||
|
||||
# create emane
|
||||
options = EmaneNet.create_options()
|
||||
options.emane_model = EmaneIeee80211abgModel.name
|
||||
position = Position(x=200, y=200)
|
||||
emane = session.add_node(EmaneNet, position=position, options=options)
|
||||
|
||||
# create nodes
|
||||
options = CoreNode.create_options()
|
||||
options.model = "mdr"
|
||||
position = Position(x=100, y=100)
|
||||
n1 = session.add_node(CoreNode, position=position, options=options)
|
||||
options = CoreNode.create_options()
|
||||
options.model = "mdr"
|
||||
position = Position(x=300, y=100)
|
||||
n2 = session.add_node(CoreNode, position=position, options=options)
|
||||
|
||||
# configure general emane settings
|
||||
config = session.emane.get_configs()
|
||||
config.update({"eventservicettl": "2"})
|
||||
|
||||
# configure emane model settings
|
||||
# using a dict mapping currently support values as strings
|
||||
session.emane.set_model_config(
|
||||
emane.id, EmaneIeee80211abgModel.name, {"unicastrate": "3"}
|
||||
)
|
||||
|
||||
# link nodes to emane
|
||||
iface1 = ip_prefixes.create_iface(n1)
|
||||
session.add_link(n1.id, emane.id, iface1)
|
||||
iface1 = ip_prefixes.create_iface(n2)
|
||||
session.add_link(n2.id, emane.id, iface1)
|
||||
|
||||
# start session
|
||||
session.instantiate()
|
||||
|
||||
# do whatever you like here
|
||||
input("press enter to shutdown")
|
||||
|
||||
# stop session
|
||||
session.shutdown()
|
|
@ -1,35 +0,0 @@
|
|||
# required imports
|
||||
from core.emulator.coreemu import CoreEmu
|
||||
from core.emulator.data import IpPrefixes
|
||||
from core.emulator.enumerations import EventTypes
|
||||
from core.nodes.base import CoreNode, Position
|
||||
|
||||
# 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, when using "node_add" below
|
||||
session.set_state(EventTypes.CONFIGURATION_STATE)
|
||||
|
||||
# create nodes
|
||||
position = Position(x=100, y=100)
|
||||
n1 = session.add_node(CoreNode, position=position)
|
||||
position = Position(x=300, y=100)
|
||||
n2 = session.add_node(CoreNode, position=position)
|
||||
|
||||
# link nodes together
|
||||
iface1 = ip_prefixes.create_iface(n1)
|
||||
iface2 = ip_prefixes.create_iface(n2)
|
||||
session.add_link(n1.id, n2.id, iface1, iface2)
|
||||
|
||||
# start session
|
||||
session.instantiate()
|
||||
|
||||
# do whatever you like here
|
||||
input("press enter to shutdown")
|
||||
|
||||
# stop session
|
||||
session.shutdown()
|
|
@ -1,41 +0,0 @@
|
|||
# required imports
|
||||
from core.emulator.coreemu import CoreEmu
|
||||
from core.emulator.data import IpPrefixes
|
||||
from core.emulator.enumerations import EventTypes
|
||||
from core.nodes.base import CoreNode, Position
|
||||
from core.nodes.network import SwitchNode
|
||||
|
||||
# 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, when using "node_add" below
|
||||
session.set_state(EventTypes.CONFIGURATION_STATE)
|
||||
|
||||
# create switch
|
||||
position = Position(x=200, y=200)
|
||||
switch = session.add_node(SwitchNode, position=position)
|
||||
|
||||
# create nodes
|
||||
position = Position(x=100, y=100)
|
||||
n1 = session.add_node(CoreNode, position=position)
|
||||
position = Position(x=300, y=100)
|
||||
n2 = session.add_node(CoreNode, position=position)
|
||||
|
||||
# link nodes to switch
|
||||
iface1 = ip_prefixes.create_iface(n1)
|
||||
session.add_link(n1.id, switch.id, iface1)
|
||||
iface1 = ip_prefixes.create_iface(n2)
|
||||
session.add_link(n2.id, switch.id, iface1)
|
||||
|
||||
# start session
|
||||
session.instantiate()
|
||||
|
||||
# do whatever you like here
|
||||
input("press enter to shutdown")
|
||||
|
||||
# stop session
|
||||
session.shutdown()
|
|
@ -1,50 +0,0 @@
|
|||
# required imports
|
||||
import logging
|
||||
|
||||
from core.emulator.coreemu import CoreEmu
|
||||
from core.emulator.data import IpPrefixes
|
||||
from core.emulator.enumerations import EventTypes
|
||||
from core.nodes.base import CoreNode, Position
|
||||
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
|
||||
position = Position(x=200, y=200)
|
||||
wireless = session.add_node(WlanNode, position=position)
|
||||
|
||||
# create nodes
|
||||
options = CoreNode.create_options()
|
||||
options.model = "mdr"
|
||||
position = Position(x=100, y=100)
|
||||
n1 = session.add_node(CoreNode, position=position, options=options)
|
||||
options = CoreNode.create_options()
|
||||
options.model = "mdr"
|
||||
position = Position(x=300, y=100)
|
||||
n2 = session.add_node(CoreNode, position=position, 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()
|
|
@ -1,59 +0,0 @@
|
|||
# required imports
|
||||
from core.emulator.coreemu import CoreEmu
|
||||
from core.emulator.data import IpPrefixes
|
||||
from core.emulator.enumerations import EventTypes
|
||||
from core.location.mobility import BasicRangeModel
|
||||
from core.nodes.base import CoreNode, Position
|
||||
from core.nodes.network import WlanNode
|
||||
|
||||
# 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, when using "node_add" below
|
||||
session.set_state(EventTypes.CONFIGURATION_STATE)
|
||||
|
||||
# create wlan
|
||||
position = Position(x=200, y=200)
|
||||
wlan = session.add_node(WlanNode, position=position)
|
||||
|
||||
# create nodes
|
||||
options = CoreNode.create_options()
|
||||
options.model = "mdr"
|
||||
position = Position(x=100, y=100)
|
||||
n1 = session.add_node(CoreNode, position=position, options=options)
|
||||
options = CoreNode.create_options()
|
||||
options.model = "mdr"
|
||||
position = Position(x=300, y=100)
|
||||
n2 = session.add_node(CoreNode, position=position, options=options)
|
||||
|
||||
# configuring wlan
|
||||
session.mobility.set_model_config(
|
||||
wlan.id,
|
||||
BasicRangeModel.name,
|
||||
{
|
||||
"range": "280",
|
||||
"bandwidth": "55000000",
|
||||
"delay": "6000",
|
||||
"jitter": "5",
|
||||
"error": "5",
|
||||
},
|
||||
)
|
||||
|
||||
# link nodes to wlan
|
||||
iface1 = ip_prefixes.create_iface(n1)
|
||||
session.add_link(n1.id, wlan.id, iface1)
|
||||
iface1 = ip_prefixes.create_iface(n2)
|
||||
session.add_link(n2.id, wlan.id, iface1)
|
||||
|
||||
# start session
|
||||
session.instantiate()
|
||||
|
||||
# do whatever you like here
|
||||
input("press enter to shutdown")
|
||||
|
||||
# stop session
|
||||
session.shutdown()
|
|
@ -1,30 +0,0 @@
|
|||
# -------- CUSTOMIZATION REQUIRED --------
|
||||
#
|
||||
# Below are sample iptables firewall rules that you can uncomment and edit.
|
||||
# You can also use ip6tables rules for IPv6.
|
||||
#
|
||||
|
||||
# start by flushing all firewall rules (so this script may be re-run)
|
||||
#iptables -F
|
||||
|
||||
# allow traffic related to established connections
|
||||
#iptables -A INPUT -m state --state ESTABLISHED,RELATED -j ACCEPT
|
||||
|
||||
# allow TCP packets from any source destined for 192.168.1.1
|
||||
#iptables -A INPUT -s 0/0 -i eth0 -d 192.168.1.1 -p TCP -j ACCEPT
|
||||
|
||||
# allow OpenVPN server traffic from eth0
|
||||
#iptables -A INPUT -p udp --dport 1194 -j ACCEPT
|
||||
#iptables -A INPUT -i eth0 -j DROP
|
||||
#iptables -A OUTPUT -p udp --sport 1194 -j ACCEPT
|
||||
#iptables -A OUTPUT -o eth0 -j DROP
|
||||
|
||||
# allow ICMP ping traffic
|
||||
#iptables -A OUTPUT -p icmp --icmp-type echo-request -j ACCEPT
|
||||
#iptables -A INPUT -p icmp --icmp-type echo-reply -j ACCEPT
|
||||
|
||||
# allow SSH traffic
|
||||
#iptables -A -p tcp -m state --state NEW -m tcp --dport 22 -j ACCEPT
|
||||
|
||||
# drop all other traffic coming in eth0
|
||||
#iptables -A INPUT -i eth0 -j DROP
|
|
@ -1,119 +0,0 @@
|
|||
# -------- 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=/etc/core/keys
|
||||
|
||||
# the name used for the "$certname.pem" x509 certificate and
|
||||
# "$certname.key" RSA private key, which can be generated using openssl
|
||||
certname=ipsec1
|
||||
|
||||
# list the public-facing IP addresses, starting with the localhost and followed
|
||||
# by each tunnel peer, separated with a single space
|
||||
tunnelhosts="172.16.0.1AND172.16.0.2 172.16.0.1AND172.16.2.1"
|
||||
|
||||
# Define T<i> where i is the index for each tunnel peer host from
|
||||
# the tunnel_hosts list above (0 is localhost).
|
||||
# T<i> is a list of IPsec tunnels with peer i, with a local subnet address
|
||||
# followed by the remote subnet address:
|
||||
# T<i>="<local>AND<remote> <local>AND<remote>"
|
||||
# For example, 172.16.0.0/24 is a local network (behind this node) to be
|
||||
# tunneled and 172.16.2.0/24 is a remote network (behind peer 1)
|
||||
T1="172.16.3.0/24AND172.16.5.0/24"
|
||||
T2="172.16.4.0/24AND172.16.5.0/24 172.16.4.0/24AND172.16.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
|
|
@ -1,63 +0,0 @@
|
|||
# -------- 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
|
||||
keydir=/etc/core/keys
|
||||
|
||||
# the name used for a "$keyname.crt" certificate and "$keyname.key" private key.
|
||||
keyname=client1
|
||||
|
||||
# the public IP address of the VPN server this client should connect with
|
||||
vpnserver="10.0.2.10"
|
||||
|
||||
# optional next hop for adding a static route to reach the VPN server
|
||||
#nexthop="10.0.1.1"
|
||||
|
||||
# --------- 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
|
||||
if [ ! -e $keydir\/$keyname.key ] || [ ! -e $keydir\/$keyname.crt ] \
|
||||
|| [ ! -e $keydir\/ca.crt ] || [ ! -e $keydir\/dh1024.pem ]; then
|
||||
echo "ERROR: missing certification or key files under $keydir \
|
||||
$keyname.key or $keyname.crt or ca.crt or dh1024.pem" >> $PWD/vpnclient.log
|
||||
fi
|
||||
|
||||
# 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 $keydir/ca.crt
|
||||
cert $keydir/$keyname.crt
|
||||
key $keydir/$keyname.key
|
||||
dh $keydir/dh1024.pem
|
||||
cipher AES-256-CBC
|
||||
log $PWD/openvpn-client.log
|
||||
verb 4
|
||||
daemon
|
||||
EOF
|
||||
) > client.conf
|
||||
|
||||
openvpn --config client.conf
|
|
@ -1,147 +0,0 @@
|
|||
# -------- 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
|
||||
keydir=/etc/core/keys
|
||||
|
||||
# the name used for a "$keyname.crt" certificate and "$keyname.key" private key.
|
||||
keyname=server2
|
||||
|
||||
# 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.2.10
|
||||
|
||||
# optional list of private subnets reachable behind this VPN server
|
||||
# each subnet and next hop is separated by a space
|
||||
# "<subnet1>,<nexthop1> <subnet2>,<nexthop2> ..."
|
||||
#privatenets="10.0.11.0,10.0.10.1 10.0.12.0,10.0.10.1"
|
||||
|
||||
# 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
|
||||
# "<keyname>,<vpnIP>,<subnetIP> <keyname>,<vpnIP>,<subnetIP> ..."
|
||||
#vpnclients="client1KeyFilename,10.0.200.5,10.0.0.0 client2KeyFilename,,"
|
||||
|
||||
# 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 <vpnsubnet>/24 via <vpnServerRemoteInterface>
|
||||
# /sbin/ip ro add <vpnClientSubnet>/24 via <vpnServerRemoteInterface>
|
||||
|
||||
# -------- END CUSTOMIZATION --------
|
||||
|
||||
echo > $PWD/vpnserver.log
|
||||
rm -f -r $PWD/ccd
|
||||
|
||||
# validate key and certification files
|
||||
if [ ! -e $keydir\/$keyname.key ] || [ ! -e $keydir\/$keyname.crt ] \
|
||||
|| [ ! -e $keydir\/ca.crt ] || [ ! -e $keydir\/dh1024.pem ]; then
|
||||
echo "ERROR: missing certification or key files under $keydir \
|
||||
$keyname.key or $keyname.crt or ca.crt or dh1024.pem" >> $PWD/vpnserver.log
|
||||
fi
|
||||
|
||||
# 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
|
||||
/sbin/ip ro add $net/24 via $nexthop
|
||||
/sbin/ip ro add $vpnsubnet/24 via $nexthop
|
||||
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 $keydir/ca.crt
|
||||
cert $keydir/$keyname.crt
|
||||
key $keydir/$keyname.key
|
||||
dh $keydir/dh1024.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
|
|
@ -1,17 +0,0 @@
|
|||
<emane-tdma-schedule >
|
||||
<structure frames="1" slots="10" slotoverhead="0" slotduration="1500" bandwidth="1M"/>
|
||||
<multiframe frequency="2.4G" power="0" class="0" datarate="100M">
|
||||
<frame index="0">
|
||||
<slot index="0" nodes="1"/>
|
||||
<slot index="1" nodes="2"/>
|
||||
<slot index="2" nodes="3"/>
|
||||
<slot index="3" nodes="4"/>
|
||||
<slot index="4" nodes="5"/>
|
||||
<slot index="5" nodes="6"/>
|
||||
<slot index="6" nodes="7"/>
|
||||
<slot index="7" nodes="8"/>
|
||||
<slot index="8" nodes="9"/>
|
||||
<slot index="9" nodes="10"/>
|
||||
</frame>
|
||||
</multiframe>
|
||||
</emane-tdma-schedule>
|
|
@ -14,6 +14,14 @@ include = [
|
|||
]
|
||||
exclude = ["core/constants.py.in"]
|
||||
|
||||
[tool.poetry.scripts]
|
||||
core-daemon = "core.scripts.daemon:main"
|
||||
core-cli = "core.scripts.cli:main"
|
||||
core-gui = "core.scripts.gui:main"
|
||||
core-player = "core.scripts.player:main"
|
||||
core-route-monitor = "core.scripts.routemonitor:main"
|
||||
core-service-update = "core.scripts.serviceupdate:main"
|
||||
core-cleanup = "core.scripts.cleanup:main"
|
||||
|
||||
[tool.poetry.dependencies]
|
||||
python = "^3.6"
|
||||
|
|
|
@ -1,71 +0,0 @@
|
|||
#!/bin/sh
|
||||
|
||||
if [ "z$1" = "z-h" -o "z$1" = "z--help" ]; then
|
||||
echo "usage: $0 [-d [-l]]"
|
||||
echo -n " Clean up all CORE namespaces processes, bridges, interfaces, "
|
||||
echo "and session\n directories. Options:"
|
||||
echo " -h show this help message and exit"
|
||||
echo " -d also kill the Python daemon"
|
||||
echo " -l remove the core-daemon.log file"
|
||||
exit 0
|
||||
fi
|
||||
|
||||
if [ `id -u` != 0 ]; then
|
||||
echo "Permission denied. Re-run this script as root."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
PATH="/sbin:/bin:/usr/sbin:/usr/bin"
|
||||
export PATH
|
||||
|
||||
if [ "z$1" = "z-d" ]; then
|
||||
pypids=`pidof python3 python`
|
||||
for p in $pypids; do
|
||||
grep -q core-daemon /proc/$p/cmdline
|
||||
if [ $? = 0 ]; then
|
||||
echo "cleaning up core-daemon process: $p"
|
||||
kill -9 $p
|
||||
fi
|
||||
done
|
||||
fi
|
||||
|
||||
if [ "z$2" = "z-l" ]; then
|
||||
rm -f /var/log/core-daemon.log
|
||||
fi
|
||||
|
||||
kaopts="-v"
|
||||
killall --help 2>&1 | grep -q namespace
|
||||
if [ $? = 0 ]; then
|
||||
kaopts="$kaopts --ns 0"
|
||||
fi
|
||||
|
||||
vnodedpids=`pidof vnoded`
|
||||
if [ "z$vnodedpids" != "z" ]; then
|
||||
echo "cleaning up old vnoded processes: $vnodedpids"
|
||||
killall $kaopts -KILL vnoded
|
||||
# pause for 1 second for interfaces to disappear
|
||||
sleep 1
|
||||
fi
|
||||
killall -q emane
|
||||
killall -q emanetransportd
|
||||
killall -q emaneeventservice
|
||||
|
||||
if [ -d /sys/class/net ]; then
|
||||
ifcommand="ls -1 /sys/class/net"
|
||||
else
|
||||
ifcommand="ip -o link show | sed -r -e 's/[0-9]+: ([^[:space:]]+): .*/\1/'"
|
||||
fi
|
||||
|
||||
eval "$ifcommand" | awk '
|
||||
/^veth[0-9]+\./ {print "removing interface " $1; system("ip link del " $1);}
|
||||
/tmp\./ {print "removing interface " $1; system("ip link del " $1);}
|
||||
/gt\./ {print "removing interface " $1; system("ip link del " $1);}
|
||||
/b\./ {print "removing bridge " $1; system("ip link set " $1 " down; ip link del " $1);}
|
||||
/ctrl[0-9]+\./ {print "removing bridge " $1; system("ip link set " $1 " down; ip link del " $1);}
|
||||
'
|
||||
|
||||
nft list ruleset | awk '
|
||||
$3 ~ /^b\./ {print "removing nftables " $3; system("nft delete table bridge " $3);}
|
||||
'
|
||||
|
||||
rm -rf /tmp/pycore*
|
Loading…
Add table
Add a link
Reference in a new issue