Difference between revisions of "VPP/Using mTCP user mode TCP stack with VPP"

From fd.io
< VPP
Jump to: navigation, search
 
(8 intermediate revisions by the same user not shown)
Line 1: Line 1:
'''NOTE:''' This page is under construction.
 
  
 
This example shows how to configure and run sample client/server applications using user mode mTCP in 2 linux namespaces (or containers) which communicate through VPP via netmap virtual interfaces.  
 
This example shows how to configure and run sample client/server applications using user mode mTCP in 2 linux namespaces (or containers) which communicate through VPP via netmap virtual interfaces.  
Line 9: Line 8:
 
'''NETMAP'''
 
'''NETMAP'''
  
Download the sources from the upstream repository using following commands:
+
Download the sources from the upstream repository using following command:
  
   git clone git@github.com:vpp-dev/netmap.git
+
   git clone git@github.com:vpp-dev/netmap.git       OR     https://github.com/vpp-dev/netmap/archive/master.zip
OR
+
  https://github.com/vpp-dev/netmap/archive/master.zip
+
  
 
Enter LINUX directory and configure netmap.
 
Enter LINUX directory and configure netmap.
Line 26: Line 23:
  
 
sudo insmod netmap.ko
 
sudo insmod netmap.ko
 +
</pre>
  
 +
To verify that netmap module is loaded, Use the following command which should show (Module-name , Size  and Used by):
 +
<pre>
 
lsmod | grep netmap
 
lsmod | grep netmap
 
</pre>
 
</pre>
Line 32: Line 32:
 
'''VPP'''
 
'''VPP'''
  
 +
We assume that you are already running vpp. If it is not the case, please follow the following link to build, install and test VPP:
  
<pre>
+
  https://wiki.fd.io/view/VPP/Build,_install,_and_test_images
  
</pre>
+
'''mTCP'''
  
 +
Download the sources using following command:
  
'''mTCP'''
+
  git clone git@github.com:vpp-dev/mtcp.git    OR    https://github.com/vpp-dev/mtcp/archive/master.zip
Download or Clone the sources using following links:
+
 
 +
Enter mtcp root directory and configure mtcp. To compile for netmap module:
 +
<pre>
 +
./configure --enable-netmap
 +
 
 +
make
 +
</pre>
  
  git clone git@github.com:vpp-dev/mtcp.git
+
'''Namespaces'''
OR
+
  https://github.com/vpp-dev/mtcp/archive/master.zip
+
  
 +
Create namespaces, using the following commands:
 
<pre>
 
<pre>
 +
sudo ip netns add vpp1
 +
sudo ip netns add vpp2
  
 +
sudo ip netns show
 +
vpp1
 +
vpp2
 
</pre>
 
</pre>
  
Line 53: Line 65:
 
'''VPP'''
 
'''VPP'''
  
Run VPP/VPP-lite and create netmap interfaces using following commands:
+
Run VPP/VPP-lite and create netmap interfaces using the VPP debug Command-line Interface (CLI):
 
<pre>
 
<pre>
 
         create netmap name vale00:vpp1 hw-addr 02:FE:3F:34:15:9B pipe master
 
         create netmap name vale00:vpp1 hw-addr 02:FE:3F:34:15:9B pipe master
Line 64: Line 76:
 
         set int l2 xcon netmap-vale00:vpp2 netmap-vale00:vpp1
 
         set int l2 xcon netmap-vale00:vpp2 netmap-vale00:vpp1
 
</pre>  
 
</pre>  
 +
 +
To verify that interfaces have been created and up, use the following command:
 +
<pre>
 +
vpp# show int
 +
              Name              Idx      State          Counter          Count   
 +
local0                            0        down     
 +
netmap-vale00:vpp1                5        up     
 +
netmap-vale00:vpp2                6        up     
 +
pg/stream-0                      1        down     
 +
pg/stream-1                      2        down     
 +
pg/stream-2                      3        down     
 +
pg/stream-3                      4        down   
 +
</pre>
  
 
=== Modify Config Files ===
 
=== Modify Config Files ===
  
 +
'''mTCP'''
 +
 +
In <mTCP-ROOT>/apps/example/, you can change the epserver.conf file and epwget.conf.
 +
 +
example '''epserver.conf''' file:
 
<pre>
 
<pre>
 +
# module
 +
io = netmap
  
</pre>
+
# Port
 +
port vale00:vpp1}0
  
=== Test ===
+
# Hw addr of port
 +
hw_addr = 02:fe:3f:34:15:9b
  
 +
# Ip addr of port
 +
ip_addr = 10.0.42.3
  
<pre>
+
# Netmask of port
 +
netmask = 255.255.255.0
  
</pre>
+
# Maximum concurrency per core
 +
max_concurrency = 10000
  
Using the VPP debug Command-line Interface (CLI) we can verify interface statistics.
+
# Maximum number of socket buffers per core
 +
max_num_buffers = 10000
  
Use the VPP CLI command <code> </code>:
+
# Receive buffer size of sockets
 +
rcvbuf = 16384
  
<pre>
+
# Send buffer size of sockets
 +
sndbuf = 16384
  
 +
# TCP timeout seconds
 +
tcp_timeout = 30
 +
 +
# TCP timewait seconds
 +
tcp_timewait = 0
 +
 +
# Interface to print stats
 +
stat_print = vale00:vpp1}0
 
</pre>
 
</pre>
  
Use the command <code>show interface</code>:
+
example '''epwget.conf''' file
 +
<pre>
 +
# module
 +
io = netmap
  
 +
# Port
 +
port vale00:vpp2}0
 +
 +
# Hw addr of port
 +
hw_addr = 02:fe:75:c5:43:66
 +
 +
# Ip addr of port
 +
ip_addr = 10.0.42.2
 +
 +
# Netmask of port
 +
netmask = 255.255.255.0
 +
 +
# Maximum concurrency per core
 +
max_concurrency = 10000
 +
 +
# Maximum number of socket buffers per core
 +
max_num_buffers = 10000
 +
 +
# Receive buffer size of sockets
 +
rcvbuf = 16384
 +
 +
# Send buffer size of sockets
 +
sndbuf = 8192
 +
 +
# TCP timeout seconds
 +
tcp_timeout = 30
 +
 +
# TCP timewait seconds
 +
tcp_timewait = 0
 +
 +
# Interface to print stats
 +
stat_print = vale00:vpp2}0
 +
</pre>
 +
 +
=== Test ===
 +
Enter to <mtcp root>/apps/example/, and create a new directory using the following command:
 
<pre>
 
<pre>
 +
mkdir www
 +
cd www/
 +
nano index.html
 +
</pre>
  
 +
Write something in the file, save and close it.
  
 +
Enter to <mtcp root>/apps/example/ and use the following command to start the http server:
 +
<pre>
 +
sudo ip netns exec vpp1 ./epserver -p www/ -f epserver.conf -c 1 -N 1
 
</pre>
 
</pre>
  
Use the command <code> </code>:
+
On another terminal, Enter to <mtcp root>/apps/example/ and use the following command to start the epwget client:
 +
<pre>
 +
sudo ip netns exec vpp2 ./epwget 10.0.42.3/index.html 1 -N 1 -s 2 -o output.txt
 +
</pre>
  
 +
In VPP CLI, use the command <code>show int</code>:
 
<pre>
 
<pre>
 +
vpp# show int
 +
              Name              Idx      State          Counter          Count   
 +
local0                            0        down     
 +
netmap-vale00:vpp1                5        up      rx packets                  501
 +
                                                    rx bytes                  48460
 +
                                                    tx packets                  601
 +
                                                    tx bytes                  51860
 +
netmap-vale00:vpp2                6        up      rx packets                  601
 +
                                                    rx bytes                  51860
 +
                                                    tx packets                  501
 +
                                                    tx bytes                  48460
 +
pg/stream-0                      1        down     
 +
pg/stream-1                      2        down     
 +
pg/stream-2                      3        down     
 +
pg/stream-3                      4        down
 +
</pre>
  
 +
You can also use the command <code> cat </code> to see the http response output:
 +
<pre>
 +
cat output.txt.0
 +
HTTP/1.1 200 OK
 
</pre>
 
</pre>

Latest revision as of 14:07, 8 June 2016

This example shows how to configure and run sample client/server applications using user mode mTCP in 2 linux namespaces (or containers) which communicate through VPP via netmap virtual interfaces.

In this setup we use 2 different namespaces called vpp1 and vpp2 and two sample applications epserver and epwget available with mTCP.

Setup

NETMAP

Download the sources from the upstream repository using following command:

  git clone git@github.com:vpp-dev/netmap.git       OR      https://github.com/vpp-dev/netmap/archive/master.zip

Enter LINUX directory and configure netmap. To compile only NETMAP/VALE (using unmodified drivers):

./configure --no-drivers

make

make apps

sudo insmod netmap.ko

To verify that netmap module is loaded, Use the following command which should show (Module-name , Size and Used by):

lsmod | grep netmap

VPP

We assume that you are already running vpp. If it is not the case, please follow the following link to build, install and test VPP:

  https://wiki.fd.io/view/VPP/Build,_install,_and_test_images

mTCP

Download the sources using following command:

  git clone git@github.com:vpp-dev/mtcp.git     OR    https://github.com/vpp-dev/mtcp/archive/master.zip

Enter mtcp root directory and configure mtcp. To compile for netmap module:

./configure --enable-netmap

make

Namespaces

Create namespaces, using the following commands:

sudo ip netns add vpp1
sudo ip netns add vpp2

sudo ip netns show
vpp1
vpp2

Configure Interfaces

VPP

Run VPP/VPP-lite and create netmap interfaces using the VPP debug Command-line Interface (CLI):

        create netmap name vale00:vpp1 hw-addr 02:FE:3F:34:15:9B pipe master
        create netmap name vale00:vpp2 hw-addr 02:FE:75:C5:43:66 pipe master

        set int state netmap-vale00:vpp2 up
        set int state netmap-vale00:vpp1 up

        set int l2 xcon netmap-vale00:vpp1 netmap-vale00:vpp2
        set int l2 xcon netmap-vale00:vpp2 netmap-vale00:vpp1

To verify that interfaces have been created and up, use the following command:

vpp# show int
              Name               Idx       State          Counter          Count     
local0                            0        down      
netmap-vale00:vpp1                5         up       
netmap-vale00:vpp2                6         up       
pg/stream-0                       1        down      
pg/stream-1                       2        down      
pg/stream-2                       3        down      
pg/stream-3                       4        down    

Modify Config Files

mTCP

In <mTCP-ROOT>/apps/example/, you can change the epserver.conf file and epwget.conf.

example epserver.conf file:

# module
io = netmap

# Port
port vale00:vpp1}0

# Hw addr of port
hw_addr = 02:fe:3f:34:15:9b

# Ip addr of port
ip_addr = 10.0.42.3

# Netmask of port
netmask = 255.255.255.0

# Maximum concurrency per core
max_concurrency = 10000

# Maximum number of socket buffers per core
max_num_buffers = 10000

# Receive buffer size of sockets
rcvbuf = 16384

# Send buffer size of sockets
sndbuf = 16384

# TCP timeout seconds
tcp_timeout = 30

# TCP timewait seconds
tcp_timewait = 0

# Interface to print stats
stat_print = vale00:vpp1}0

example epwget.conf file

# module
io = netmap

# Port
port vale00:vpp2}0

# Hw addr of port
hw_addr = 02:fe:75:c5:43:66

# Ip addr of port
ip_addr = 10.0.42.2

# Netmask of port
netmask = 255.255.255.0

# Maximum concurrency per core
max_concurrency = 10000

# Maximum number of socket buffers per core
max_num_buffers = 10000

# Receive buffer size of sockets
rcvbuf = 16384

# Send buffer size of sockets
sndbuf = 8192

# TCP timeout seconds
tcp_timeout = 30

# TCP timewait seconds
tcp_timewait = 0

# Interface to print stats
stat_print = vale00:vpp2}0

Test

Enter to <mtcp root>/apps/example/, and create a new directory using the following command:

mkdir www
cd www/
nano index.html

Write something in the file, save and close it.

Enter to <mtcp root>/apps/example/ and use the following command to start the http server:

sudo ip netns exec vpp1 ./epserver -p www/ -f epserver.conf -c 1 -N 1

On another terminal, Enter to <mtcp root>/apps/example/ and use the following command to start the epwget client:

sudo ip netns exec vpp2 ./epwget 10.0.42.3/index.html 1 -N 1 -s 2 -o output.txt

In VPP CLI, use the command show int:

vpp# show int
              Name               Idx       State          Counter          Count     
local0                            0        down      
netmap-vale00:vpp1                5         up       rx packets                   501
                                                     rx bytes                   48460
                                                     tx packets                   601
                                                     tx bytes                   51860
netmap-vale00:vpp2                6         up       rx packets                   601
                                                     rx bytes                   51860
                                                     tx packets                   501
                                                     tx bytes                   48460
pg/stream-0                       1        down      
pg/stream-1                       2        down      
pg/stream-2                       3        down      
pg/stream-3                       4        down

You can also use the command cat to see the http response output:

cat output.txt.0
HTTP/1.1 200 OK