Direct Code Execution upgrade

Student: Sourabh Jain

Mentor: Matthieu Coudron and Natale Patriciello

Organization: The ns-3 Network Simulator Project
Project Overview

Direct Code Execution (DCE) is a framework over ns-3 that provides a feature to run simulations using real Linux network stack. Besides, it provides a feature to use real network applications (such as iperf) inside ns-3 environment without changing their code. This feature helps to leverage the functionalities of existing network tools available for Linux inside the ns-3 environment.

DCE currently uses LibOS to exploit the Linux network stack functionality in its environment. LibOS has stopped releasing the new versions of the Linux kernels. This has been the major hindrance for DCE to use latest Linux kernel. An active alternate to LibOS is Linux Kernel Library (LKL) which provides similar features as LibOS and supports latest Linux kernel versions. In this project, DCE is extended to support the networking stack of LKL and embed real libc in LKL.

The motivation behind the Linux Kernel Library (LKL) is to provide an interface to reuse Linux kernel subsystem with minimal efforts. Userspace application currently can reuse the virtual file system, networking stack, task management, scheduling and memory management subsystem of Linux using the APIs provided in LKL. LKL builds Linux kernel as shared object file which can be easily loaded into userspace and have Linux kernel feature directly available to userspace applications. In this project, we reuse the networking stack subsystem of Linux using LKL.

In general, LKL offers userspace applications to use different kernel subsystems like the virtual file system, network stack, and scheduling. The plan is to adapt network stack functionality using LKL system call API. At the time of binary deployment over a node, DCE will load the LKL compiled binary. It then searches for sim_init function and tells to LKL the required set of function for a node. In return, LKL will give a structure of pointer to those functions so that DCE can use it later. In order to make DCE compatible with LKL, we need to adapt the host related function from LKL. There are approximately 35-40 host-related functions which are declared as structure lkl_host_operations in LKL. The objective is to redefine lkl_host_operation in the DCE environment. In addition to redefining those functions for DCE, we need to add glue to code to map LKL host functions to redefined DCE functions.

DCE host in LKL contains an initializer method (sim_init) which initializes the DceHandle and KernelHandle structures. These structures help LKL to make calls to the functions defined in ns-3-dce and DCE to call functions defined in LKL. The DCE Host is tested by loading the LKL shared library liblkl.so in DCE and making a call to the initializer function and callback from LKL to the function defined in ns-3-dce. The functions needed to work with Socket and NetDevice in LKL are implemented. These function contains sock_socket, bind, connect, listen, sendmsg, recvmsg, create_netdevice, dec_rx, de_tx etc. All functions define in Socket and NetDevice are yet to be tested with the existing examples available in ns-3-dce. The overall framework is not yet ready to perform any simulation. We need to run dce-ping example iteratively to figure out the code crash points between LKL and ns-3-dce. This process might need some changes in existing modules to makes ns-3-dce compatible with LKL.

Deliverables

Enabling support for DCE Host in LKL: A host in LKL is basically defining a handle for lkl_host_operations. lkl_host_operation is a structure of pointer to functions of basic functions related to memory allocation, thread handling, timers, semaphore handle (mutex) and panic. In order to run the real code in a discrete time environment, all the host-related functions should be implemented using DCE version of standard functions.

NetDevice and Socket module in LKL: The core network related function is implemented in Netdevice and Socket module. These modules are highly inspired from old NUSE socket and netdevice module. The NetDevice module provides a function to create a virtual network device and function to perform Rx-Tx operations on it. The Socket module helps DCE to create Linux based socket and allows to perform different operation on them. The support operation on socket includes bind, connect, listen, shutdown, getsockname, sock_sendmsg, sock_recvmsg etc.

LKL compatible code in ns-3-dce: These patches contain the module specific changes in ns-3-DCE code. These patches help LKL to use the custom implementation of standard Libc functions. The patch also introduces new function like DcePanic in ns-3-dce to handle kernel panic situation over an ns-3 node. In addition, the ns-3-dce is also made compatible with new sysctl interface of LKL.

sysctl get interface in mainline LKL: This patch helps DCE to extract the sysctl attribute by mounting the /proc/sys interface. The sysctl get interface can also be used by other components in LKL. The patch is sent to LKL team for the review.

assignment_turned_in

Phase 1
Enabling support for DCE Host in LKL

assignment_turned_in

Phase 2
NetDevice and Socket module in LKL

assignment_turned_in

Phase 3
LKL compatible code in ns-3-dce
Steps to reproduce work done on LKL
  1. Clone my LKL repository (git clone https://github.com/sourabhjains/linux)
  2. Checkout to "dce-support" branch (git checkout dce-support)
  3. Build LKL (make -C tools/lkl)
Steps to reproduce work done on ns-3-dce
  1. Clone my ns-3-dce repository (git clone https://github.com/sourabhjains/ns-3-dce/)
  2. Checkout to “lkl-integration” branch (git checkout lkl-integration)
  3. Build ns-3-dce (./waf)
Steps to view my work on LKL
  1. Clone my LKL repository (git clone https://github.com/sourabhjains/linux)
  2. Checkout to "dce-support" branch (git checkout dce-support)
  3. Generate the consolidated patch (git diff master > lkl.patch)
  4. Alternatively, the patch can be downloaded from this link
  5. View project statistics of my work on LKL (git diff master dce-support --stat)
Steps to view my work on ns-3-dce
  1. Clone my ns-3-dce repository (git clone https://github.com/sourabhjains/ns-3-dce/)
  2. Checkout to “lkl-integration” branch (git checkout lkl-integration)
  3. Generate the consolidated patch (git diff master > dce.patch)
  4. Alternatively, the patch can be downloaded from this link
  5. View project statistics of my work on DCE (git diff master lkl-integration --stat)
Scope and Limitations of the Project

This project can be extended further as suggested below:

  1. The network functionality of Linux kernel can be exploited using native LKL functions.
  2. LKL provides API to set queue disciplines over the interface. This functionality can be used to provide traffic control (tc) interface in ns-3-dce.
  3. Currently, manual settings are required to integrate LKL with ns-3-dce. These settings can be automated using the bake tool.
Other Resources