2018-07-31 20:57:30 +01:00
|
|
|
# CORE Developer's Guide
|
|
|
|
|
|
|
|
* Table of Contents
|
|
|
|
{:toc}
|
|
|
|
|
2019-09-10 21:39:36 +01:00
|
|
|
## Repository Overview
|
2018-07-31 20:57:30 +01:00
|
|
|
|
2022-03-08 19:30:03 +00:00
|
|
|
The CORE source consists of several programming languages for
|
2020-04-09 22:34:52 +01:00
|
|
|
historical reasons. Current development focuses on the Python modules and
|
|
|
|
daemon. Here is a brief description of the source directories.
|
2018-07-31 20:57:30 +01:00
|
|
|
|
2022-02-25 18:38:14 +00:00
|
|
|
| Directory | Description |
|
|
|
|
|-----------|--------------------------------------------------------------------------------------|
|
|
|
|
| daemon | Python CORE daemon/gui code that handles receiving API calls and creating containers |
|
|
|
|
| docs | Markdown Documentation currently hosted on GitHub |
|
|
|
|
| man | Template files for creating man pages for various CORE command line utilities |
|
|
|
|
| netns | C program for creating CORE containers |
|
2018-07-31 20:57:30 +01:00
|
|
|
|
2019-09-10 21:39:36 +01:00
|
|
|
## Getting started
|
2018-07-31 20:57:30 +01:00
|
|
|
|
2020-03-05 22:16:14 +00:00
|
|
|
To setup CORE for develop we will leverage to automated install script.
|
2018-07-31 20:57:30 +01:00
|
|
|
|
2020-03-05 22:16:14 +00:00
|
|
|
## Clone CORE Repo
|
2019-09-12 22:36:28 +01:00
|
|
|
|
|
|
|
```shell
|
2019-12-20 20:55:52 +00:00
|
|
|
cd ~/Documents
|
|
|
|
git clone https://github.com/coreemu/core.git
|
|
|
|
cd core
|
2020-03-05 22:16:14 +00:00
|
|
|
git checkout develop
|
2019-09-12 22:36:28 +01:00
|
|
|
```
|
|
|
|
|
2020-03-05 22:16:14 +00:00
|
|
|
## Install the Development Environment
|
2019-09-10 21:39:36 +01:00
|
|
|
|
2020-03-05 22:16:14 +00:00
|
|
|
This command will automatically install system dependencies, clone and build OSPF-MDR,
|
2020-07-16 18:09:26 +01:00
|
|
|
build CORE, setup the CORE poetry environment, and install pre-commit hooks. You can
|
|
|
|
refer to the [install docs](install.md) for issues related to different distributions.
|
2019-12-20 20:55:52 +00:00
|
|
|
|
|
|
|
```shell
|
2020-07-16 18:09:26 +01:00
|
|
|
./install -d
|
2019-12-20 20:55:52 +00:00
|
|
|
```
|
|
|
|
|
2020-03-05 22:16:14 +00:00
|
|
|
### pre-commit
|
2019-12-20 20:55:52 +00:00
|
|
|
|
2020-03-05 22:16:14 +00:00
|
|
|
pre-commit hooks help automate running tools to check modified code. Every time a commit is made
|
|
|
|
python utilities will be ran to check validity of code, potentially failing and backing out the commit.
|
|
|
|
These changes are currently mandated as part of the current CI, so add the changes and commit again.
|
2019-12-20 20:55:52 +00:00
|
|
|
|
2020-03-05 22:16:14 +00:00
|
|
|
## Running CORE
|
2019-09-10 21:39:36 +01:00
|
|
|
|
2020-07-16 18:09:26 +01:00
|
|
|
You can now run core as you normally would, or leverage some of the invoke tasks to
|
|
|
|
conveniently run tests, etc.
|
2019-09-10 21:39:36 +01:00
|
|
|
|
|
|
|
```shell
|
2020-07-16 18:09:26 +01:00
|
|
|
# run core-daemon
|
|
|
|
sudo core-daemon
|
|
|
|
|
|
|
|
# run python gui
|
|
|
|
core-pygui
|
2018-07-31 20:57:30 +01:00
|
|
|
|
2022-03-08 19:30:03 +00:00
|
|
|
# run gui
|
2020-07-16 18:09:26 +01:00
|
|
|
core-gui
|
2018-07-31 20:57:30 +01:00
|
|
|
|
2020-07-16 18:09:26 +01:00
|
|
|
# run mocked unit tests
|
2020-07-22 00:52:17 +01:00
|
|
|
cd <CORE_REPO>
|
2020-07-16 18:09:26 +01:00
|
|
|
inv test-mock
|
2019-12-19 20:32:30 +00:00
|
|
|
```
|
2018-07-31 20:57:30 +01:00
|
|
|
|
2019-09-10 21:39:36 +01:00
|
|
|
## Linux Network Namespace Commands
|
2018-07-31 20:57:30 +01:00
|
|
|
|
2019-12-20 20:36:29 +00:00
|
|
|
Linux network namespace containers are often managed using the *Linux Container Tools* or *lxc-tools* package.
|
|
|
|
The lxc-tools website is available here http://lxc.sourceforge.net/ for more information. CORE does not use these
|
|
|
|
management utilities, but includes its own set of tools for instantiating and configuring network namespace containers.
|
2019-09-10 21:39:36 +01:00
|
|
|
This section describes these tools.
|
2018-07-31 20:57:30 +01:00
|
|
|
|
2019-09-10 21:39:36 +01:00
|
|
|
### vnoded
|
2018-07-31 20:57:30 +01:00
|
|
|
|
2019-12-20 20:36:29 +00:00
|
|
|
The *vnoded* daemon is the program used to create a new namespace, and listen on a control channel for commands that
|
|
|
|
may instantiate other processes. This daemon runs as PID 1 in the container. It is launched automatically by the CORE
|
|
|
|
daemon. The control channel is a UNIX domain socket usually named */tmp/pycore.23098/n3*, for node 3 running on CORE
|
2019-09-10 21:39:36 +01:00
|
|
|
session 23098, for example. Root privileges are required for creating a new namespace.
|
2018-07-31 20:57:30 +01:00
|
|
|
|
2019-09-10 21:39:36 +01:00
|
|
|
### vcmd
|
2018-07-31 20:57:30 +01:00
|
|
|
|
2019-12-20 20:36:29 +00:00
|
|
|
The *vcmd* program is used to connect to the *vnoded* daemon in a Linux network namespace, for running commands in the
|
|
|
|
namespace. The CORE daemon uses the same channel for setting up a node and running processes within it. This program
|
|
|
|
has two required arguments, the control channel name, and the command line to be run within the namespace. This command
|
2019-09-10 21:39:36 +01:00
|
|
|
does not need to run with root privileges.
|
2018-07-31 20:57:30 +01:00
|
|
|
|
2019-12-20 20:36:29 +00:00
|
|
|
When you double-click on a node in a running emulation, CORE will open a shell window for that node using a command
|
2019-09-10 21:39:36 +01:00
|
|
|
such as:
|
2018-07-31 20:57:30 +01:00
|
|
|
|
|
|
|
```shell
|
|
|
|
gnome-terminal -e vcmd -c /tmp/pycore.50160/n1 -- bash
|
|
|
|
```
|
|
|
|
|
|
|
|
Similarly, the IPv4 routes Observer Widget will run a command to display the routing table using a command such as:
|
|
|
|
|
|
|
|
```shell
|
|
|
|
vcmd -c /tmp/pycore.50160/n1 -- /sbin/ip -4 ro
|
|
|
|
```
|
|
|
|
|
|
|
|
### core-cleanup script
|
|
|
|
|
2019-12-20 20:36:29 +00:00
|
|
|
A script named *core-cleanup* is provided to clean up any running CORE emulations. It will attempt to kill any
|
|
|
|
remaining vnoded processes, kill any EMANE processes, remove the :file:`/tmp/pycore.*` session directories, and remove
|
2021-05-10 23:07:42 +01:00
|
|
|
any bridges or *nftables* rules. With a *-d* option, it will also kill any running CORE daemon.
|
2018-07-31 20:57:30 +01:00
|
|
|
|
|
|
|
### netns command
|
|
|
|
|
2019-12-20 20:36:29 +00:00
|
|
|
The *netns* command is not used by CORE directly. This utility can be used to run a command in a new network namespace
|
2019-09-10 21:39:36 +01:00
|
|
|
for testing purposes. It does not open a control channel for receiving further commands.
|
2018-07-31 20:57:30 +01:00
|
|
|
|
|
|
|
### Other Useful Commands
|
|
|
|
|
|
|
|
Here are some other Linux commands that are useful for managing the Linux network namespace emulation.
|
|
|
|
|
|
|
|
```shell
|
|
|
|
# view the Linux bridging setup
|
2019-12-23 22:48:56 +00:00
|
|
|
ip link show type bridge
|
2018-07-31 20:57:30 +01:00
|
|
|
# view the netem rules used for applying link effects
|
|
|
|
tc qdisc show
|
|
|
|
# view the rules that make the wireless LAN work
|
2021-05-10 23:07:42 +01:00
|
|
|
nft list ruleset
|
2018-07-31 20:57:30 +01:00
|
|
|
```
|