Skip to content

Testing XIA with an echo server

Cody Doucette edited this page Aug 13, 2018 · 11 revisions

Linux XIA can be tested using an echo application written for the XIA stack. The application, net-echo, can run over TCP/IP's UDP and TCP, as well as XIA's XDP and Serval.

Important: The Serval principal is no longer part of Linux XIA since March 9th, 2016.

Table of Contents

Obtaining net-echo

The net-echo application can be obtained by executing:

 git clone git://github.com/AltraMayor/net-echo.git

To build and install programs ecli, eclicork, and eserv into /bin, run:

 $ cd net-echo/
 $ sudo make install

Using net-echo

The main files that will be used are:

  • eserv.c - an echo server
  • ecli.c - an echo client
  • eclicork.c - an echo client that supports socket corking

Running the server

The server is equipped to echo plain text and files back to the client, and it returns every packet immediately upon receipt. To run the server, issue one of the following forms:

 ./eserv datagram ip PORT # UDP
 ./eserv stream ip PORT # TCP
 ./eserv datagram xip SERVER_ADDRESS_FILE # XDP

The following option will not work, because the Serval principal has been deprecated:

 ./eserv stream xip SERVER_ADDRESS_FILE # Serval

For the IP stack, replace "PORT" to the desired port number on which eserv will accept echo requests. For the XIP stack, replace "SERVER_ADDRESS_FILE" to the name of a file that holds the XIP address that eserv will use to bind its listening socket.

Information about XIP addresses format can be found on the page Human readable XIP address format. The following one-line example file can be used to test eserv with XDP:

 xdp-007f4e38904e83634acc7e1340ef7665e3f1f57a-0

Running the client

To run a client, issue the command:

 ./ecli datagram ip IP_ADDRESS PORT # UDP
 ./ecli stream ip IP_ADDRESS PORT # TCP
 ./ecli datagram xip CLIENT_ADDRESS_FILE SERVER_ADDRESS_FILE # XDP

The following option will not work, because the Serval principal has been deprecated:

 ./ecli stream xip CLIENT_ADDRESS_FILE SERVER_ADDRESS_FILE # Serval

For the IP stack, replace "IP_ADDRESS" to the IP address of the host where eserv is running, and "PORT" to the port number on which eserv will accept echo requests. For the XIP stack, replace "CLIENT_ADDRESS_FILE" to the name of a file that holds the XIP address that ecli will use to bind its connecting socket, and replace "SERVER_ADDRESS_FILE" to the name of a file that holds the XIP address to reach the server; it can be the same file passed to eserv.

The following one-line example file can be used to test ecli with XDP:

 XDP-007f4e38904e83634acc7e1340ef7665e3f1f57b-0

Once the client is running, it accepts both plain text and files to be echoed. The client accepts requests in the form:

 [-f] string

Where "-f" is optionally specified to denote "string" as the name of the file to be sent to the echo server. Otherwise, "string" is interpreted as the plain text to be echoed.

The client will then either print the echoed plain text message, or create an echoed file of the name "<string></string>_echo" which can found in the working directory.

For example, a sample interaction might be:

 $ ./ecli datagram ip 128.197.12.4 9950
 This is a test packet.
 This is a test packet.
 -f file.txt

Note that there is no output written to the standard output device after the last command. The output of echoing a file is a copy of the file in the working directory.

Running the corked client

net-echo also provides an option for the user to run a "corked" client. Using this client, the output socket is "corked" so that even after bytes are written to the socket, a packet will not be sent. The packet will only be sent when the socket is "uncorked," which happens when the socket contains CORK_SIZE bytes. CORK_SIZE is defined in eclicork.c.

To run the corked client, issue one of the following commands:

 ./eclicork datagram ip IP_ADDRESS PORT # UDP
 ./eclicork datagram xip CLIENT_ADDRESS_FILE SERVER_ADDRESS_FILE # XDP

The parameters have the same meaning as for ecli. At the time of this writing, eclicork has not been extended to support TCP and Serval.

While running the client, the user can also specify:

 [-f] string

When enough bytes have been collected in the buffer (specified by CORK_SIZE in the code), the packet is uncorked and the data is echoed. This means that when a new plain text message is written to a socket, part of the message could be sent and part of the message might remain in a new corked buffer until it is released.

Note that if there is already plain text in the buffering packet and the user attempts to echo a file, the socket will be uncorked and the "partial" plain text packet will be released before the file data is processed. Also, when the file has been processed completely, the packet is uncorked as well, so that there is no residual data from the file left in an incomplete packet.

For example, a sample interaction might be:

 $ ./eclicork datagram ip 128.197.12.4 9950
 This is a test packet.
 -f file.txt
 This is a test packet.

Note the difference between this interaction and the one in the above section. Here, “This is a test packet.” is not more than CORK_SIZE bytes (if CORK_SIZE is, say, 64 bytes), so it is held in the packet buffer and not immediately echoed. However, once the file is specified to be echoed, the partial packet is sent before the file is processed.

Running in Mininet

To run the echo experiment in XIA using Mininet, first follow the setup instructions in XIA in Mininet.

Objective

The objective of this demo is to create a Mininet topology and test the net-echo application. The Mininet hosts will start pre-configured with HIDs and won't require explicit configuration. The echo application is a client-server paradigm application. The client sends some content (text or file) to the server which is echoed back to the client.

Run the Mininet Script

Once Mininet is installed, change director into the Mininet examples directory and run the following commands:

 cd mininet/mininet/examples/
 sudo python xiaecho.py

This will load the needed XIA kernel modules, configure the network, and start the Mininet command line interface.

Create Address Files

The two nodes that the experiment script created, xia1 and xia2, will be the server and client for the echo application, respectively.

Run the following command to get the HID of the server, xia1:

 mininet> xia1 xip hid showaddrs
 to hid-6753896adc3c7ab80bc1672ad894d7018aab5cb1
 flags []

You will likely see a different HID string.

Do the same for xia2:

 mininet> xia2 xip hid showaddrs
 to hid-f7e3126adc345ab24bc16fead7a415018aab5ab3
 flags []

Open another terminal on the host, and change directory to the examples directory:

 cd mininet/mininet/examples

Create a file named serv_addr in this directory, which will be the server's DAG address. Fill this file with the HID from the server followed by a random XDP XID (any 40 character hex string):

 hid-6753896adc3c7ab80bc1672ad894d7018aab5cb1-1:
 xdp-2093723472747047808047502873423749070990-0

Then, create a file named cli_addr (also in the examples directory), which will be the client's DAG address. It should have HID of xia2 followed by another random XDP XID:

 hid-f7e3126adc345ab24bc16fead7a415018aab5ab3-1:
 xdp-309372347274704780804750287342374907099f-0

Run the Echo Server and Client

Back in the Mininet shell, create two xterm sessions:

 xterm xia1
 xterm xia2

In the terminal for xia1, run the echo server with the server address you created:

 eserv datagram xip serv_add

In the terminal for xia2, run the echo client and specify both address files:

 ecli datagram xip cli_add serv_add

Type in some text in the client xterm and press Enter. If your setup was correct you'll see the echoed text in client terminal. You can also send a file to be echoed (create the file to be sent in the mininet/examples directory):

 -f filename

The echoed file will be present in the mininet/examples directory with name filename_echo.

Some Useful Mininet Commands

View the nodes in the topology:

 mininet> nodes

View how the nodes are connected:

 mininet> net

Start a separate terminal for a node:

 mininet> xterm nodename