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
|
|
|
|
2019-09-10 21:39:36 +01:00
|
|
|
The CORE source consists of several different programming languages for 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
|
|
|
|
2019-09-10 21:39:36 +01:00
|
|
|
| Directory | Description |
|
|
|
|
|---|---|
|
|
|
|
|daemon|Python CORE daemon code that handles receiving API calls and creating containers|
|
|
|
|
|docs|Markdown Documentation currently hosted on GitHub|
|
|
|
|
|gui|Tcl/Tk GUI|
|
|
|
|
|man|Template files for creating man pages for various CORE command line utilities|
|
|
|
|
|netns|Python C extension modules for creating CORE containers|
|
|
|
|
|ns3|Experimental python ns3 script support for running CORE|
|
|
|
|
|scripts|Template files used for running CORE as a service|
|
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
|
|
|
|
2019-09-10 21:39:36 +01:00
|
|
|
Overview for setting up the pipenv environment, building core, installing the GUI and netns, then running
|
|
|
|
the core-daemon for development.
|
2018-07-31 20:57:30 +01:00
|
|
|
|
2019-12-19 20:32:30 +00:00
|
|
|
### Clone CORE Repo
|
|
|
|
|
|
|
|
```shell
|
|
|
|
git clone https://github.com/coreemu/core.git
|
|
|
|
cd core
|
|
|
|
```
|
|
|
|
|
2019-09-10 21:39:36 +01:00
|
|
|
### Setup Python Environment
|
|
|
|
|
2019-09-11 19:23:31 +01:00
|
|
|
To leverage the dev environment you need python 3.6+.
|
2019-09-10 21:39:36 +01:00
|
|
|
|
|
|
|
```shell
|
|
|
|
# change to daemon directory
|
|
|
|
cd $REPO/daemon
|
|
|
|
|
2019-09-24 06:45:27 +01:00
|
|
|
# copy setup.py for installation
|
|
|
|
cp setup.py.in setup.py
|
|
|
|
|
2019-09-10 21:39:36 +01:00
|
|
|
# install pipenv
|
2019-09-11 19:23:31 +01:00
|
|
|
pip3 install pipenv
|
2019-09-10 21:39:36 +01:00
|
|
|
|
|
|
|
# setup a virtual environment and install all required development dependencies
|
2019-09-11 19:23:31 +01:00
|
|
|
python3 -m pipenv install --dev
|
2019-09-10 21:39:36 +01:00
|
|
|
```
|
|
|
|
|
2019-09-12 22:36:28 +01:00
|
|
|
### Setup pre-commit
|
|
|
|
|
2019-12-19 20:32:30 +00:00
|
|
|
Install pre-commit hooks to help automate running tool checks against code. Once installed every time a commit is made
|
|
|
|
python utilities will be ran to check validity of code, potentially failing and backing out the commit. This allows
|
|
|
|
one to review changes being made by tools ro the fix the issue noted. Then add the changes and commit again.
|
2019-09-12 22:36:28 +01:00
|
|
|
|
|
|
|
```shell
|
|
|
|
python3 -m pipenv run pre-commit install
|
|
|
|
```
|
|
|
|
|
2019-09-10 21:39:36 +01:00
|
|
|
### Build CORE
|
|
|
|
|
|
|
|
```shell
|
|
|
|
./bootstrap.sh
|
|
|
|
./configure --prefix=/usr
|
|
|
|
make
|
|
|
|
```
|
|
|
|
|
|
|
|
### Install netns and GUI
|
|
|
|
|
|
|
|
Below commands assume your development will be focused on the daemon.
|
|
|
|
|
|
|
|
```shell
|
|
|
|
# install GUI
|
|
|
|
cd $REPO/gui
|
|
|
|
sudo make install
|
|
|
|
|
|
|
|
# install netns scripts
|
|
|
|
cd $REPO/netns
|
|
|
|
sudo make install
|
|
|
|
```
|
|
|
|
|
2019-09-13 00:27:12 +01:00
|
|
|
### Adding EMANE to Pipenv
|
|
|
|
|
|
|
|
EMANE bindings are not available through pip, you will need to build and install from source.
|
|
|
|
|
|
|
|
[Build EMANE](https://github.com/adjacentlink/emane/wiki/Build#general-build-instructions)
|
|
|
|
|
|
|
|
```shell
|
|
|
|
# after building emane above
|
|
|
|
# ./autogen.sh && ./configure --prefix=/usr && make
|
2019-12-19 20:32:30 +00:00
|
|
|
python3 -m pipenv install $EMANEREPO/src/python
|
2019-09-13 00:27:12 +01:00
|
|
|
```
|
|
|
|
|
2019-09-10 21:39:36 +01:00
|
|
|
### Running CORE
|
|
|
|
|
|
|
|
This will run the core-daemon server using the configuration files within the repo.
|
|
|
|
|
|
|
|
```shell
|
2019-12-20 00:07:17 +00:00
|
|
|
sudo python3 -m pipenv run core
|
2019-09-10 21:39:36 +01:00
|
|
|
```
|
2018-07-31 20:57:30 +01:00
|
|
|
|
2019-12-19 20:32:30 +00:00
|
|
|
### Running CORE Python GUI
|
2018-07-31 20:57:30 +01:00
|
|
|
|
2019-12-19 20:32:30 +00:00
|
|
|
Must be ran after the daemon above or will fail to connect.
|
2018-07-31 20:57:30 +01:00
|
|
|
|
2019-12-19 20:32:30 +00:00
|
|
|
```shell
|
|
|
|
python3 -m pipenv run coretk
|
|
|
|
```
|
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-09-10 21:39:36 +01: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.
|
|
|
|
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-09-10 21:39:36 +01: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
|
|
|
|
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-09-10 21:39:36 +01: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
|
|
|
|
does not need to run with root privileges.
|
2018-07-31 20:57:30 +01:00
|
|
|
|
2019-09-10 21:39:36 +01:00
|
|
|
When you double-click on a node in a running emulation, CORE will open a shell window for that node using a command
|
|
|
|
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-09-10 21:39:36 +01: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
|
|
|
|
any bridges or *ebtables* rules. With a *-d* option, it will also kill any running CORE daemon.
|
2018-07-31 20:57:30 +01:00
|
|
|
|
|
|
|
### netns command
|
|
|
|
|
2019-09-10 21:39:36 +01:00
|
|
|
The *netns* command is not used by CORE directly. This utility can be used to run a command in a new network namespace
|
|
|
|
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
|
|
|
|
brctl show
|
|
|
|
# view the netem rules used for applying link effects
|
|
|
|
tc qdisc show
|
|
|
|
# view the rules that make the wireless LAN work
|
|
|
|
ebtables -L
|
|
|
|
```
|