Skip to content

ZOld Assignment: 0. Introduction

Sue Moon edited this page Sep 28, 2021 · 1 revision

Introduction to KENSv3

In most operating systems, the transport and lower layers are implemented in the kernel and are very hard to modify. We have developed a simulation environment called KENSv3 (KAIST Educational Network System) so that you can build and test basic functions of the transport layer not in the kernel but in userspace.

Let’s first start installing KENS on your platform. Go to https://github.com/ANLAB-KAIST/KENSv3/wiki and follow the link to “Getting Started” for your own system.

KENSv3 is an event-driven network simulator that provides a virtual environment for students to build and test TCP and IP stacks. KENS provides the application layer as well as the IP and the layer below. Also included in KENS are reference binaries for the TCP and IP layers so that students can test their own against. Through KENS, students build only the TCP module as if it lies in the kernel. In a typical system, the TCP module is called upon by applications and the lower layer via three events:

  1. a system call from an application
  2. an upcall from the IP layer when a packet arrives
  3. timer expiration.

In order to implement 1. to 3., the following portions of code must be implemented.

  1. When an application makes a system call, KENS turns it into the following callback function.
void TCPAssignment::systemCallback(UUID syscallUUID, int pid,
                                   const SystemCallParameter &param) {


  switch (param.syscallNumber) {
  case SOCKET:
    // this->syscall_socket(syscallUUID, pid, param.param1_int,
    // param.param2_int, param.param3_int);
    break;

...

}
  1. When a packet arrives in the IP layer, the IP layer makes the following upcall:
void TCPAssignment::packetArrived(std::string fromModule, Packet &&packet) {
  (void)from Module;
  (void)packet;
}
  1. When a timer expires, just as in 1. a timer callback is called.

The overall KENS architecture is in the figure below. You only implement specific APIs in the given TCPAssignment.cpp file. You do not write your application code, IP layer code, nor the counterpart (“adversary”). No need to even write main(). The build process differs from platform to platform. Please follow instructions in “Getting Started “at: https://github.com/ANLAB-KAIST/KENSv3/wiki

KENS architecture

A First Step to Build Your Own TCP

In KENS we are not building the complete TCP, but a bare minimum of the protocol. Yet any reference describes TCP in full. In order to help you understand the limited scope of KENS, we will refer to the TCP implementation in [1] and present the scope you should implement in KENS.

First, the TCP layer interacts with the application layer above and the IP layer below and its relationship is drawn in Figure 24.2 of [1].

Figure 24.2

In KENS you only need to implement only the following in KENS:

Figure KENS

The corresponding part in KENS to tcp_input is:

void TCPAssignment::packetArrived(std::string fromModule, Packet &&packet) {
  (void)from Module;
  (void)packet;
}

The corresponding part in KENS to user_request is:

void TCPAssignment::systemCallback(UUID syscallUUID, int pid, const SystemCallParameter &param) {


}

Within TCPAssignment::packetArrived() and TCPAssignment::systemCallback(), you will implement the following state transition diagram.

Figure 24.15

[1] TCP/IP Illustrated, Volume 2, Gary R. Wright and W. Richard Stevens, 1995, Addison-Wesley.