Difference between revisions of "HICN/How To Configure the Hicn Plugin of VPP with Open DayLight"

From fd.io
Jump to: navigation, search
(Created page with "= Configure the Hicn Plugin of VPP with Open DayLight = This tutorial shows how to perform the following operations: * Deploy a Docker container with vpp, the hicn-plugin, s...")
 
Line 47: Line 47:
  
  
Deploy the icnteam/vswitch docker image
+
Deploy the icnteam/vswitch docker image. We will use udp faces with port 55555, so we need to expose that port when running the container:
  
 
<syntaxhighlight lang="bash">
 
<syntaxhighlight lang="bash">
 
CONTAINER=vswitch
 
CONTAINER=vswitch
$ docker run -d --privileged --name ${CONTAINER} icnteam/vswitch  
+
PORT=55555
 +
$ docker run --cap-add=NET_ADMIN --device=/dev/vhost-net --device=/dev/net/tun -p ${PORT}:${PORT} --name ${CONTAINER} icnteam/vswitch  
 
</syntaxhighlight>
 
</syntaxhighlight>
  
Create a hicn private network:
+
Connect the vpp forwarder to the external network.
  
 
<syntaxhighlight lang="bash">
 
<syntaxhighlight lang="bash">
$ GATEWAY=192.168.0.254
+
$ TAP_ADDRESS_VPP=192.168.0.2
$ docker network create --subnet 192.168.0.0/24 --gateway ${GATEWAY} hicn-network
+
$ TAP_ADDRESS_KER=192.168.0.1
 +
$ TAP_ADDRESS_NET=192.168.0.0/24
 +
$ TAP_ID=0
 +
$ TAP_NAME=tap${TAP_ID}
 +
$ docker exec -it ${CONTAINER} -- apt update && apt -y install iptables
 +
$ docker exec -it ${CONTAINER} vppctl create tap id ${TAP_ID}
 +
$ docker exec -it ${CONTAINER} vppctl set int state ${TAP_NAME} up
 +
$ docker exec -it ${CONTAINER} vppctl set interface ip address tap0 ${TAP_ADDRESS_VPP}/24
 +
$ docker exec -it ${CONTAINER} ip addr add ${TAP_ADDRESS_KER}/24 brd + dev ${TAP_NAME}
 +
# Redirect the udp traffic on port 55555 (The one used for hicn) to VPP
 +
$ docker exec -it ${CONTAINER} iptables -t nat -A PREROUTING -p udp --dport ${PORT} -j DNAT --to-destination ${TAP_ADDRESS_VPP}:${PORT}
 +
# Masquerade all the traffic coming from VPP
 +
$ docker exec -it ${CONTAINER} iptables -t nat -A POSTROUTING -j MASQUERADE --src ${TAP_ADDRESS_NET} ! --dst ${TAP_ADDRESS_NET} -o eth0
 +
# Add default route to vpp
 +
$ docker exec -it ${CONTAINER} ip route add 0.0.0.0/0 via ${TAP_ADDRESS_KER} ${TAP_NAME}
 
</syntaxhighlight>
 
</syntaxhighlight>
  
Connect the proxy container to the hicn network:
 
  
<syntaxhighlight lang="bash">
+
== Deploy a Open Daylight Docker container ==
$ docker network connect hicn-network ${CONTAINER}
+
</syntaxhighlight>
+
  
Connect the hicn network to the vpp forwarder:
+
Deploy the icnteam/odl docker image
  
 
<syntaxhighlight lang="bash">
 
<syntaxhighlight lang="bash">
$ IP_ADDRESS=$(docker inspect -f "{{with index .NetworkSettings.Networks \"hicn-network\"}}{{.IPAddress}}{{end}}"${CONTAINER})
 
$ INTERFACE=$(docker exec -it${CONTAINER} ifconfig | grep -B 1 ${IP_ADDRESS} | awk 'NR==1 {gsub(":","",$1); print $1}')
 
$ docker exec -it ${CONTAINER} ip addr flush dev ${INTERFACE}
 
$ docker exec -it ${CONTAINER} ethtool -K ${INTERFACE} tx off rx off ufo off gso off gro off tso off
 
$ docker exec -it ${CONTAINER} vppctl create host-interface name ${INTERFACE}
 
$ docker exec -it ${CONTAINER} vppctl set interface state host-${INTERFACE} up
 
$ docker exec -it ${CONTAINER} vppctl set interface ip address host-${INTERFACE} ${IP_ADDRESS}/24
 
$ docker exec -it ${CONTAINER} vppctl ip route add 10.0.0.0/24 via ${GATEWAY} host-eth1
 
</syntaxhighlight>
 
  
Now the container is able to communicate through the hicn-network bridge, using UDP faces.
 
We must expose a port for injecting incoming ICN traffic inside the hicn vswitch. Here we choose the port 12345.
 
 
<syntaxhighlight lang="bash">
 
$ PORT=12345
 
$ sudo iptables -t nat -A DOCKER -p udp --dport ${PORT} -j DNAT --to-destination ${IP_ADDRESS}:${PORT}
 
$ sudo iptables -t nat -A POSTROUTING -j MASQUERADE -p udp --source ${IP_ADDRESS} --destination ${IP_ADDRESS} --dport ${PORT}
 
$ sudo iptables -A DOCKER -j ACCEPT -p udp --destination ${IP_ADDRESS} --dport ${PORT}
 
 
</syntaxhighlight>
 
</syntaxhighlight>
 
== Deploy a Open Daylight Docker container ==
 

Revision as of 11:32, 22 July 2019

Configure the Hicn Plugin of VPP with Open DayLight

This tutorial shows how to perform the following operations:

  • Deploy a Docker container with vpp, the hicn-plugin, sysrepo and the netopeer2 server
  • Deploy a Open Daylight Docker container
  • Configure opendaylight for connecting to netopeer2, which will in turn connect to the hicn-plugin for pushing the configuration
  • Push the hicn network configuration from to opendaylight using REST
  • Check the configuration is effectively applied on hicn-plugin

Background

Hicn-plugin

Open Daylight

Sysrepo

Netopeer2

For the tutorial we will use a single ubuntu 18.04 machine where the 2 docker containers (the one with the hicn-plugin and the one with ODL) will be running. The two dockers should be able to communicate using the network.

A second machine will be then used for pushing the network configuration to Open Dayligh, using network API (REST).

Deploy a Docker container with vpp, the hicn-plugin, sysrepo and the netopeer2 server

Install docker on the ubuntu machine:

$ sudo apt-get update
$ sudo apt-get install \
    apt-transport-https . \
    ca-certificates \
    curl \
    gnupg-agent \
    software-properties-common
 
$ curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -
$ sudo add-apt-repository \
   "deb [arch=amd64] https://download.docker.com/linux/ubuntu \
   $(lsb_release -cs) \
   stable"
$ sudo apt-get update
$ sudo apt-get install docker-ce docker-ce-cli containerd.io


Deploy the icnteam/vswitch docker image. We will use udp faces with port 55555, so we need to expose that port when running the container:

CONTAINER=vswitch
PORT=55555
$ docker run --cap-add=NET_ADMIN --device=/dev/vhost-net --device=/dev/net/tun -p ${PORT}:${PORT} --name ${CONTAINER} icnteam/vswitch

Connect the vpp forwarder to the external network.

$ TAP_ADDRESS_VPP=192.168.0.2
$ TAP_ADDRESS_KER=192.168.0.1
$ TAP_ADDRESS_NET=192.168.0.0/24
$ TAP_ID=0
$ TAP_NAME=tap${TAP_ID}
$ docker exec -it ${CONTAINER} -- apt update && apt -y install iptables
$ docker exec -it ${CONTAINER} vppctl create tap id ${TAP_ID}
$ docker exec -it ${CONTAINER} vppctl set int state ${TAP_NAME} up
$ docker exec -it ${CONTAINER} vppctl set interface ip address tap0 ${TAP_ADDRESS_VPP}/24
$ docker exec -it ${CONTAINER} ip addr add ${TAP_ADDRESS_KER}/24 brd + dev ${TAP_NAME}
# Redirect the udp traffic on port 55555 (The one used for hicn) to VPP
$ docker exec -it ${CONTAINER} iptables -t nat -A PREROUTING -p udp --dport ${PORT} -j DNAT --to-destination ${TAP_ADDRESS_VPP}:${PORT}
# Masquerade all the traffic coming from VPP
$ docker exec -it ${CONTAINER} iptables -t nat -A POSTROUTING -j MASQUERADE --src ${TAP_ADDRESS_NET} ! --dst ${TAP_ADDRESS_NET} -o eth0
# Add default route to vpp
$ docker exec -it ${CONTAINER} ip route add 0.0.0.0/0 via ${TAP_ADDRESS_KER} ${TAP_NAME}


Deploy a Open Daylight Docker container

Deploy the icnteam/odl docker image