knet documentation

37
KNet Documentation Release 1 KNet Solutions Jul 11, 2020

Upload: others

Post on 16-Oct-2021

13 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: KNet Documentation

KNet DocumentationRelease 1

KNet Solutions

Jul 11, 2020

Page 2: KNet Documentation
Page 3: KNet Documentation

Table of Contents:

1 Welcome to KNet’s documentation! 31.1 Overview . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 31.2 Architecture . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 41.3 Quick Start . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 41.4 Command Line Interface . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 91.5 Example Topologies . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 161.6 Topology File explained . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 211.7 Useful Docker Commands . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 241.8 Useful Openvswitch Commands . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 261.9 Traffic Tests . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 261.10 Traditional Networks Topology . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 31

i

Page 4: KNet Documentation

ii

Page 5: KNet Documentation

KNet Documentation, Release 1

Software Defined Networking(SDN) opens the innovation in networking domain. University Students/Research fel-lows does plenty of innovative networking solutions with SDN.

Building the Network Topology for their research activity is still nightmare.

KNet is Virtual Network Topology Builder, it builds the Network Topology as a real network environment. It meansthe Nodes are built with Docker Containers.

User can install any required packages (apache2,mysql,hacking tools.. etc) User have full control on the nodes togenerate the real time original protocol traffic(no simulation).

Table of Contents: 1

Page 6: KNet Documentation

KNet Documentation, Release 1

2 Table of Contents:

Page 7: KNet Documentation

CHAPTER 1

Welcome to KNet’s documentation!

• Overview

• Architecture

1.1 Overview

Software Defined Networking(SDN) opens the innovation in networking domain. University Students/Research fel-lows does plenty of innovative networking solutions with SDN.

Building the Network Topology for their research activity is still nightmare.

KNet is Virtual Network Topology Builder, it builds the Network Topology as a real network environment. It meansthe Nodes are built with Docker Containers. Currently it supports Hosts, Servers, Routers Nodes.

KNet Virtual Network Topology Builder supports building the Traditional Networks as well as SDN Test bed.

Host is built with basic required tools such as iperf, Traceroute, curl, Hping3. Server is built with apache2 webserver.Router is built with Quagga Router.

User can install any required packages (mysql,hacking tools.. etc) in the nodes. User have full control on the nodes togenerate the real time original protocol traffic(no simulation).

3

Page 8: KNet Documentation

KNet Documentation, Release 1

1.2 Architecture

• Quick Start

1.3 Quick Start

In this QuickStart section, we see few quick steps to install and execute the sample topology with RYU Controller.

KNet is compatible with Python 2.7 only.

KNet is currently supported only in Ubuntu 16.04 version.

We have used Ubuntu 16.04 OS for the below demonstations.

The current released version is 1.0.11

1.3.1 Installation

1. Install the Prerequisties. Copy and Paste the below command in the Terminal

curl https://raw.githubusercontent.com/knetsolutions/KNet/master/install.sh | bash

This command will install the Docker, openvswitch and required packages.

2. Once Prerequisties are installed. Execute the below commands to verify the docker and openvswitches areinstalled.

sudo docker imagessudo ovs-vsctl show

3. Install the KNet Topology Builder with below commands,

4 Chapter 1. Welcome to KNet’s documentation!

Page 9: KNet Documentation

KNet Documentation, Release 1

pip install knet

4. Install the KNet WebUI & and Verify the WebUI in browser

git clone https://github.com/knetsolutions/knet-uicd knet-uipython ui/webserver.py >/dev/null 2>&1 &

Open FireFox/Chrome, with URL: http://ip:5000/index.html, and see the empty topology page.

5. Start the KNet CLI and verify the commands

knet-cli

1.3. Quick Start 5

Page 10: KNet Documentation

KNet Documentation, Release 1

1.3.2 Create a sample Topology and Testing

Now Let us Create the Sample Star Topology with RYU SDN Controller.

Topology should be defined in simple YAML file(its just a text file representing the topology).

Example topology files are available in https://github.com/knetsolutions/knet-example-topologies

SDN example topologies are available inside SDN folder of the knet-example-topologies repo.

Example SDN topologies are available for 1. Linear 2. Star 3. Tree 4. Mesh 5. Partial Mesh

Setup the RYU SDN Controller

1. Install the RYU SDN Controller Open the another terminal and execute the below commands,

cd $HOMEexport LC_ALL="en_US.UTF-8"virtualenv ryu. ryu/bin/activatepip install ryu

2. Run the Ryu Simple L3 Switch application,

ryu-manager ryu/lib/python2.7/site-packages/ryu/app/simple_switch_13.py

6 Chapter 1. Welcome to KNet’s documentation!

Page 11: KNet Documentation

KNet Documentation, Release 1

CLI

1. Create a Topology as below in the CLI

CreateTopology /home/suresh/knet-example-topologies/1.0/topo0.yaml

2. Verify the topology digram in UI.

http://ip:5000/index.html

3. Open the another terminal, and verify the switches and nodes. Run the below commands in the new terminaland see the created nodes and switches.

1.3. Quick Start 7

Page 12: KNet Documentation

KNet Documentation, Release 1

sudo docker ps -asudo ovs-vsctl show

4. Trigger the PingAll command from the KNet CLI and check the output Each node pings each other nodes.

PingAll

5. Verify the OVS flows with the below command, sudo ovs-ofctl -O OpenFlow13 dump-flows switch1

1.3.3 Delete the Topology

1. In the KNet CLI, Execute the below command

8 Chapter 1. Welcome to KNet’s documentation!

Page 13: KNet Documentation

KNet Documentation, Release 1

DeleteTopology

2. Exit from the CLI by “Exit” Command

1.3.4 Cleanup

Cleanup command cleans up the Docker container, ovs switches, log files, db records etc.

1. In the KNet CLI, Execute the below command

Cleanup

2. Exit from the CLI by “Exit” Command

• Command Line Interface

1.4 Command Line Interface

KNet CLI is a primary interface for the user to Create/delete/manipulate the Topology. Currently it supports thefollowing commands.

HelpVersionCleanupCreateTopologyDeleteTopology

(continues on next page)

1.4. Command Line Interface 9

Page 14: KNet Documentation

KNet Documentation, Release 1

(continued from previous page)

GetTopologyPingAllPingTcpTestTcpTest_DetachExecUdpTestUdpTest_DetachDeleteNodeDeleteSwitchAdminDownLinkAdminUpLinkExit

1.4.1 Start the CLI

knet-cli

1.4.2 Help commands

Help Command, lists the available commands.

Help <command name> gives the detailed help for a given command

HelpHelp <command name>

Screeshot:

10 Chapter 1. Welcome to KNet’s documentation!

Page 15: KNet Documentation

KNet Documentation, Release 1

1.4.3 Version

Shows the version of KNet.

1.4.4 CreateTopology

CreateTopology command creates a Topology. The Topology input file is defined in YAML format. User can easilydefine any complex topology by writing the YAML file.(Refer: Topology_file section)

There are few example topologies availale in https://github.com/knetsolutions/knet-example-topologies in the reposi-tory.

CreateTopology <Topology file>

Note: Topology file needs to be specified in absolute path. Example; /home/ubuntu/mytopology.yaml

Note: If the Topology file name or Path is not correct, you will see “I/O operation failed” Error.

1.4. Command Line Interface 11

Page 16: KNet Documentation

KNet Documentation, Release 1

1.4.5 GetTopology

GetTopology command gives the detailed information of the Topology, such as Node details(Name, IP, Mac, ID),Switch details(name, datapathid), Link Details(Interface name, Src, Destination).

GetTopology

1.4.6 PingAll

PingAll command, generates 2 ping packets from each node to all other nodes.

1.4.7 Ping

Ping command, generates 2 ping packets from source node to destination node.

Ping <source node> <destination node>

Screenshot:

1.4.8 Exec

Exec command, helps to execute the system command in the node.

Syntax:

Exec < node> <command>

For example, you want to know the arp entries of the host

12 Chapter 1. Welcome to KNet’s documentation!

Page 17: KNet Documentation

KNet Documentation, Release 1

1.4. Command Line Interface 13

Page 18: KNet Documentation

KNet Documentation, Release 1

Exec a1 arp -aExec a1 ifconfigExec a1 ip routeExec a1 traceroute 10.1.1.2

1.4.9 TcpTest

Helps to perform the Iperf TCP traffic test between two nodes

Refer: Traffic Test session for mode details

1.4.10 UdpTest

Helps to perform the Iperf UDP traffic test between two nodes

Refer: Traffic Test session for mode details

1.4.11 DeleteTopology

DeleteTopology command deletes the entier topology(nodes, switches, links)

DeleteTopology

Screenshot:

1.4.12 AdminDownLink

AdminDownLink command downs the particular link. For example, if want to disconnect the link between node1 tonode2, we can use this command.

1. Identify the Interface name for the link using GetTopology Command

2. Use AdminDownLink command with identified interface name to shutdown the link.

AdminDownLink <interface_name>

In this below example, down the a4 interface.

Screenshot:

1.4.13 AdminUpLink

AdminUpLink command brings up the link back.

AdminDownLink <interface_name>

In this below example, bring up the a4 interface.

Screenshot:

14 Chapter 1. Welcome to KNet’s documentation!

Page 19: KNet Documentation

KNet Documentation, Release 1

1.4. Command Line Interface 15

Page 20: KNet Documentation

KNet Documentation, Release 1

1.5 Example Topologies

https://github.com/knetsolutions/knet-example-topologies repository consists of SDN, and traditional topology ìnputfiles.

SDN Folder consists of the below topology input files,

1. Simple Topology

2. Linear1 Topology

3. Linear2 Topology

4. Ring Topology

5. Partial Mesh Topology

6. Full Mesh Topology

7. Tree Topology

Traditional Folder consists of

1. One Network with Hosts and Server

2. Two Networks with Hosts, Server, Router

3. WAN Topology with Two Routers, Hosts

1.5.1 Star Topology

Filename: simple.yaml

Fig. 1: Simple Star Topology.

This topology consists of 4 nodes, and a switch. All Nodes are connected to a same switch.

16 Chapter 1. Welcome to KNet’s documentation!

Page 21: KNet Documentation

KNet Documentation, Release 1

RYU OpenFlow13 Switch application simple_switch_13.py can be used to test this topology.

1.5.2 Linear Topology1

Filename: linear1.yaml

Fig. 2: Simple Linear Topology.

This topology consists of 4 nodes, and two switches. 2 Nodes are connected in each switch. Also these switches areinterconnected. Also MAC address is explicitly mentioned.

RYU OpenFlow13 Switch application simple_switch_13.py can be used to test this topology.

1.5.3 Linear Topology2

Filename: linear2.yaml

This topology consists of 4 nodes, and four switches. Each node is connected in each switch. Also these switches areconnected linearly and no loop.

RYU OpenFlow13 Switch application simple_switch_13.py can be used to test this topology.

1.5.4 Ring Topology

Filename: ring.yaml

This topology consists of 4 nodes, and four switches. Each node is connected in each switch. Also these switches areconnected linearly and forms the loop.

This topology forms a loop, hence RYU STP application simple_switch_stp_13.py to be used to test this topology.

1.5. Example Topologies 17

Page 22: KNet Documentation

KNet Documentation, Release 1

Fig. 3: Linear Topology with 4 Switches

Fig. 4: Ring Topology.

18 Chapter 1. Welcome to KNet’s documentation!

Page 23: KNet Documentation

KNet Documentation, Release 1

1.5.5 Full Mesh Topology

Filename: fmesh.yaml

Fig. 5: Full Mesh Topology.

This topology consists of 4 nodes, and four switches. Each node is connected in each switch. Also these switches areinterconnected with each other to form a full mesh.

This topology forms a loop, hence RYU STP application simple_switch_stp_13.py to be used to test this topology.

1.5.6 Partial Mesh Topology

Filename: pmesh.yaml

This topology consists of 4 nodes, and four switches. Each node is connected in each switch. Also these switches areinterconnected with some other to form a partial mesh.

This topology forms a loop, hence RYU STP application simple_switch_stp_13.py to be used to test this topology.

1.5.7 Tree Topology

Filename: tree.yaml

This topology consists of 8 nodes, and 7 switches. This topology forms a binary tree with depth 3. Root Switch is S1.Second level switches are S2 and S5. Third level switches are S3, S4, S6, S7. Nodes are connected to switches S3,S4, S6 and S7.

RYU OpenFlow13 Switch application simple_switch_13.py can be used to test this topology.

1.5. Example Topologies 19

Page 24: KNet Documentation

KNet Documentation, Release 1

Fig. 6: Partial Mesh Topology.

Fig. 7: Tree Topology.

20 Chapter 1. Welcome to KNet’s documentation!

Page 25: KNet Documentation

KNet Documentation, Release 1

• Topology File explained

1.6 Topology File explained

Topology input file is defined in YAML(Yet another Markup Language). YAML is human readable data serializationlanguage , commonly used as configuraton file for applications.

Topology Object consists the following main sections,

1.6.1 name

name defines the topology name. Data type is string

Example:

name : Simple Star Topology 1

1.6.2 version

version defines the topology file schema version. The current version is 1.0.

Example:

version: 1.0

1.6.3 description

description is for detailed description of the topology. Its a multiline string.

Example:

description: |This topology consists of 4 nodes, and a switch.All Nodes are connected to a same switch.

1.6.4 controller

controller is a object defined for SDN Controller. This object contains url property. url defines the SDN ControllerURL. Data type is string.

All the switches in the topology will be connected to this controller url.

Example:

controller:url: tcp:0.0.0.0:6633

1.6. Topology File explained 21

Page 26: KNet Documentation

KNet Documentation, Release 1

1.6.5 openflow

openflow is a object defined for openflow protocol. This object contains version property. data type is number.

This openflow version is applied for all the switches in the topology.

Example:

openflow:version: 1.3

1.6.6 network

network is a list for defining the network objects. Each network object containes name and subnet property. KNetwill manages the IP assignment to the nodes in this network. The network name will be used by the nodes object.

Example:

networks:-name: n1subnet: 10.1.1.0/24

1.6.7 qos

qos is a list for defining the qos object. Each qos object containes the name, bandwidth, latency, jitter, pktlossproperty. KNet use this qos object for applying qos in the link using linux traffic shaping tool.

qos object will be consumed by link object.

Example:

qos:-name: q1bandwidth: 100Mbpslatency: 100msjitter: 1mspktloss: 0.5%

1.6.8 nodes

nodes object consists of list of nodes. Each node is represented with the name, image, network, ip, mac properties.

1. name defines the node name. Its a mandatory parameter

2. image defines the docker image for the node. Recommended value is “ubuntu:trusty” image. thats is ubuntu14.04 version. Dont change it until unless you know about this. Its a mandatory parmeter

3. network defines the network belongs to this node. if network is mentioned, IP will be automatically allocatedfrom this network.

4. ip defines the static ip for this node. The given ip will be assigned to the node. Either network or ip shouldpresent.

5. mac defines the mac id for the interface. Its a optional parameter

22 Chapter 1. Welcome to KNet’s documentation!

Page 27: KNet Documentation

KNet Documentation, Release 1

Example1:

nodes:-name: a1image: ubuntu:trustynetwork: n1

Example2:

nodes:-name: a1image: ubuntu:trustyip: 10.10.10.2/24mac: 00:00:00:00:00:01

1.6.9 switches

switches object consists of list of switches. Each switch is represented with the name proerty.

name defines the switch name. Its a mandatory parameter.

Example1:

switches:-name: switch1

1.6.10 links

links object consists of list of links. Each link is represented with the nodes and switches.

There are two types of links.

1. Switch to Node Link: This means, Switch is connected with one or more nodes.

2. Switch to Switch Link: This means, switch to connected with another switch.

Switch to Node Link

links:-switches:

- switch1nodes:

- name: a1- name: a2- name: a3-

name: a4qos: q2

In the above example, switch1 is connected with 4 nodes (a1, a2, a3, a4), and switch to a4 link will have qos configured.

Switch to Switch Link

1.6. Topology File explained 23

Page 28: KNet Documentation

KNet Documentation, Release 1

links:-switches:

- switch2- switch3

In the above example, switch2 is connected with switch3

• Useful Docker Commands

1.7 Useful Docker Commands

1.7.1 List the Nodes:

The following command lists all the nodes. You can identify the node with “name” names, its same as node namegiven in the topology file.

sudo docker ps -a

Screenshot:

1.7.2 How to Install the package(application) in the Node:

Each node is a Ubuntu Linux Container. So you can execute all the linux commands in the Container once you loggedin.

To Login to the node:

sudo docker exec -it <node name> bashExample:sudo docker exec -it a1 bash

Screenshot:

To Install the package in the node,

First login to the node as mentioned above,

apt-get updateapt-get install <package name>

Example:apt-get install iperf3

24 Chapter 1. Welcome to KNet’s documentation!

Page 29: KNet Documentation

KNet Documentation, Release 1

Screenshot:

1.7.3 Exit from the node shell

exit

Screenshot:

• Useful Openvswitch Commands

1.7. Useful Docker Commands 25

Page 30: KNet Documentation

KNet Documentation, Release 1

1.8 Useful Openvswitch Commands

1.8.1 List the Switches:

The following command lists all the switches. You can identify the switch with “name” names, its same as switchname given in the topology file.

sudo ovs-vsctl show

Screenshot:

1.8.2 List the Flows installed in the Switch

sudo ovs-ofctl -O <openflow version> dump-flows <switch name>

Example :sudo ovs-ofctl -O OpenFlow13 dump-flows switch1

Screenshot:

• Traffic Tests

1.9 Traffic Tests

KNet Supports UDP, TCP tests as simple Commands. KNet runs IPERF in the node to perform this test.

26 Chapter 1. Welcome to KNet’s documentation!

Page 31: KNet Documentation

KNet Documentation, Release 1

1.9.1 TCP Test :

TcpTest command performs the TCP test between two nodes for 10s

KNet-cli#help TcpTest['TcpTest']

****************************************************

Runs IPERF TCP test.Args: source destination Number-of-connectionsreturn: resultExample: TcpTest a1 a2 1

TcpTest a1 a2 10

****************************************************

1.9.2 UDP Test:

UdpTest command performs the UDP test between two nodes for 10s

KNet-cli#help UdpTest['UdpTest']

****************************************************

Runs IPERF UDP test.Args: source destination Bandwitdh(Mbps) Number-of-connectionsreturn: resultExample: UdTest a1 a2 10 1

UdpTest a1 a2 1 1

****************************************************

References

IPERF supports UDP Traffic tests as well , Below links can help you for udp tests.

1. https://iperf.fr/iperf-doc.php

2. https://openmaniak.com/iperf.php

1.9.3 HTTP Tests Using Apache WebServer & Locust :

As all nodes are ubuntu nodes, we can just install Apache Webserver and Locust https://locust.io/ (HTTP Load TestingTool) start using it.

Objective is create the example topology0, and Install the Apache Web Server in a4 node. Install Locust in a1 node.Trigger the Locust to test the apache web server(a4). Locust will generate huge http connections to the Apache webserver and load it.

a1 node ip is 10.20.20.2 a4 node ip is 10.20.20.5

Create the Topology using KNet CLI.

1.9. Traffic Tests 27

Page 32: KNet Documentation

KNet Documentation, Release 1

View the Topology Web UI

Start the Ryu Controller L4Switch application,

L4Switch(https://github.com/knetsolutions/knet/L4Switch.py) application creates flow based on srcip, dstip, proto-col,srcport, dstport.

Install the Apache WebServer on a4 node

sudo docker exec -it a4 bashsudo apt-get updatesudo apt-get install apache2sudo service apache restart

Install the Locust Tool on a1 node

sudo docker exec -it a1 bashsudo apt-get updatesudo apt-get install python-dev python-pipsudo pip install locustio

Run the Locust HTTP Load test

In the a1 node, Create a locust input file (loadtest.py)

28 Chapter 1. Welcome to KNet’s documentation!

Page 33: KNet Documentation

KNet Documentation, Release 1

1.9. Traffic Tests 29

Page 34: KNet Documentation

KNet Documentation, Release 1

from locust import HttpLocust, TaskSetdef index(l):

l.client.get("/index.html")

class UserBehavior(TaskSet):tasks = {index: 2}

class WebsiteUser(HttpLocust):task_set = UserBehaviormin_wait = 0max_wait = 0

Start the locust as below, 10.20.20.5 is a4 IP

locust -f loadtest.py --no-web --host http://10.20.20.5

The output shows , how many connections per second requested and the response time, etc.

Check the flow tables in ovs

30 Chapter 1. Welcome to KNet’s documentation!

Page 35: KNet Documentation

KNet Documentation, Release 1

sudo ovs-ofctl -O OpenFlow13 dump-flows switch1sudo ovs-ofctl -O OpenFlow13 dump-flows switch1 | wc

I could able to simulate around 2000 Flows in 2 minutes. we can test flow setup rate using this test.

• Traditional Networks Topology

1.10 Traditional Networks Topology

KNet Supports building Traditional Network Topology with Routers, Firewall Nodes.

Router node is built with “bird routing daemon” and “shorewall” firewall sofware.

http://bird.network.cz/

http://shorewall.net/shorewall_quickstart_guide.htm

Example traditional network topology examples are available in knet-example-topologies repository.

1.10.1 Network Topology with Routers:

Topology example (ex2 - Simple WAN Topology) consists of two routers . Router node is inbuilt with firewall.

Provisioning the Router Node:

1. Login to Router Node shell

sudo docker exec -it R1 bash

2. Edit the bird configuration file (/etc/bird.conf). The default configuration consists of ospf configuration.

vi /etc/bird.conf

1.10. Traditional Networks Topology 31

Page 36: KNet Documentation

KNet Documentation, Release 1

Change the router id:

router id 1.1.1.1;

Enable the ospf configuration in the required interfaces

protocol ospf MyOSPF {rfc1583compat yes;area 0.0.0.0 {

stub no;interface "eth1" {

hello 10;retransmit 6;cost 10;transmit delay 5;dead count 5;wait 50;type broadcast;

};

interface "eth2" {hello 10;retransmit 6;cost 10;transmit delay 5;dead count 5;wait 50;type broadcast;

};

};}

3. Start the bird routing daemon

bird -c /etc/bird.conf -d &

4. Check the log files

cat /var/log/bird.log

The detailed information of bird routing configuration is available in bird website.

Repeat the same for all the Routers.

Testing

1. Check the Routing tables of Router Node.

ip route

2. Perform the Ping end to end ping from the hosts

1.10.2 How to configure Firewall:

1. Login to the Router Node

32 Chapter 1. Welcome to KNet’s documentation!

Page 37: KNet Documentation

KNet Documentation, Release 1

2. Edit the shorewall configuration.

3. Start the shorewall.

1.10. Traditional Networks Topology 33