4. Building mOS Applications

This chapter describes how we can compile and run applications in an DPDK environment. At the same time, we inform the user how you can set up or configure mOS applications in your network for development (on testbed settings) or deployment.

4.1. Configure network settings

Using the mOS networking stack, one can build and run applications for end-point hosts, i.e., run mTCP applications as well as mid-dlebox applications (e.g., firewall or IDS).

The Running Applications guide shows how one can run a mOS application in either end or mid mode. The guide also shows how one can deploy sample applications in testbed as well as real-world settings.

4.2. Compile and run sample applications

The mOS package provides several sample applications for the user. You can refer to the Sample Applications User Guide for a brief explanation and walkthrough of the application source code. In order to compile and run them, please go through the following steps.

4.2.1. Compile and run the sample application

We choose midstat sample middlebox mOS networking application for this guide. midstat can be considered as a netstat equivalent application for network middleboxes. Interested readers can refer to Middlebox Stats (midstat) to know more details regarding midstat.

Go to the midstat sample application folder, and type make.

$ cd samples/midstat
$ make


Makefiles for sample applications are generated automatically when you run the setup script. You can generate your own Makefile as described in Create Makefile for compiling your application.

4.2.2. Update the mOS configuration file

You can update the mOS-specific configuration used in the sample application as follows.

$ $(EDITOR) config/mos.conf

Please refer to Configuration Parameter Tuning to see how you can adjust your mOS configuration parameters according to your setup.

4.2.3. Run the sample application

You can run the sample application as follows.

$ sudo ./midstat


This needs to be updated.

4.3. Create, compile, and run custom mOS applications

4.3.1. Write your own mOS application

If you plan to build your own mOS application, we suggest that you refer to the mOS API specification (http://www.ndsl.kaist.edu/mos_api/) and Programmer’s Guide to understand how mOS library can be used. Our sample applications guide, Sample Applications User Guide, can also help the reader in developing new applications.

4.3.2. Create Makefile for compiling your application

After building up your own program, you need to generate a Makefile for compiling your program:

Step 1. Copy the Makefile template file to your folder

$ cp docs/Makefile.template samples/(app_name)/Makefile

Step 2. Open the Makefile and replace (app_name) with yours.

TARGET = (app_name)

Step 3. Copy the following line(s) to ‘I/O library’ section in Makefile

LIBS    += -m64 -g -pthread -lrt -march=native -Wl,-export-dynamic   \
-L../../dpdk/lib -Wl,-lnuma -Wl,-lmtcp -Wl,-lpthread -Wl,-lrt        \
-Wl,-ldl -Wl,$(shell cat ../../drivers/dpdk/lib/ldflags.txt)

4.3.3. Compile and run the sample application

Compile your code using the make command.

$ make

When you run make, it would generate a binary named as you entered in the previous section. Please note that a mOS application always requires sudo privileges for execution.

$ sudo ./(app_name)