1. Running Monitor Applications in Inline Mode¶
This page describes how one can set up a mOS middlebox in inline mode and how a developer can control live traffic that goes through the node.
Please note that the monitor application in this mode is capable of dropping (e.g., if used as a firewall or an IDS) or manipulating traffic (e.g., NAT) going through it.
1.1. Environment¶
This section assumes an environment configured as described below.
where:
- Data Network: Any Ethernet network including end hosts that sends and receives traffic via Host 1.
- Host 1: A host which is placed in between two networks so that it can monitor, drop,
or manipulate the traffic between them. This host runs Middlebox Stats (midstat),
which runs on mOS networking stack. It has two Ethernet interfaces named
dpdk0
anddpdk1
, which are connected to each Data Network.
1.2. Configuration Steps¶
1.2.1. Compile and build mOS library and applications¶
Follow the directions in Compiling the mOS net library to set up the mOS net library and the environment.
- In this case, the IP addresses that are assigned to
dpdk0
anddpdk1
do not matter. You are only required to configure the network (i.e., just typeifconfig dpdk0 0.0.0.0 up
;ifconfig dpdk1 0.0.0.0 up
) so that Host 1 can monitor the traffic you want. The mOS core’s dpdk driver always intializes the network interfaces in promiscuous mode.
Refer to Compile and run sample applications, and make sure that you successfully compile the mOS application.
- In Host 1, please compile midstat.
$ cd samples/midstat
$ make
1.2.2. Setup mOS application configurations¶
Before running the midstat
application, you need to the configuration the application.
- In Host 1, please configure
mos.conf
as below. We assume that Host 1 uses CPU core 0~7 for running mOSmidstat
. Please make sure that you setforward = 1
to allow themidstat
application to forward the traffic if the ruleset permits. Also set thenic_forward_table
appropriately.
#######################
# MOS-RELATED OPTIONS #
#######################
mos {
forward = 1
#######################
##### I/O OPTIONS #####
#######################
# number of memory channels per socket [mandatory for DPDK]
nb_mem_channels = 4
# devices used for MOS applications [mandatory]
netdev {
dpdk0 0x00FF
dpdk1 0x00FF
}
#######################
### LOGGING OPTIONS ###
#######################
# NICs to print network statistics per second
# if enabled, mTCP will print xx Gbps and xx pps for RX and TX
stat_print = dpdk0 dpdk1
# A directory contains MOS system log files
mos_log = logs/
# dpdk0 and dpdk1 will forward traffic in either direction
nic_forward_table {
dpdk0 dpdk1
}
}
1.3. Run midstat¶
In Host 1, run midstat
with sudo privileges. You would see
TCP states of ongoing flows per second.
$ sudo ./midstat
1.4. Troubleshooting¶
If your mOS program crashes, search through the printed log messages to check if you missed any of the following requirements:
- You should load only the dpdk-registered interfaces (after loading the
igb_uio
driver) and configure hugepages as described in Compiling the mOS net library.- You should create a log folder specified in
mos_log
parameter inmos.conf
(logs/
in our example) within the same directory that contains the mOS application binary.- Please check if your system is running out of memory by looking at the memory footprint (OOM errors). If you have memory deficiency issues, please reduce the number of socket buffers in
mos.conf
.
If the traffic fails to pass through Host 1, check the following issues:
- Check whether you achieve connectivity by reverting back to kernel network driver for the interfaces (see option 5 in Configure runtime environment for mOS applications with DPDK). You can try testing your setup as a network bridge with default Linux kernel network drivers.
Warning
Please note that the mOS stack currently can only run on a CPU processor with 16 CPU
cores or less. This restriction will be removed in future versions of the stack. For now,
we suggest that the user disables all CPU core IDs > 16 using the sysfs
interface.
$ cd /sys/devices/system/cpu
$ for i in {16..$MAX_CPU}
do
cd $i
echo 0 > online
cd ..
done
1.5. Testing ‘midstat’¶
You can pick two nodes on either side of Host 1 that can be used as TCP server and client applications. A typical server application can be a web server (see http://nginx.org or http://www.apache.org for further information) or simple evaluation tool such as nuttcp (server mode). A typical client application can be a web client (see https://www.gnu.org/software/wget/) or nuttcp (client mode).
You can test basic connectivity of your setup by first testing whether ping messages are propogated across the network.