SDN learning + Mininet + OpenDaylight

SDN

SDN Introduction

SDN literally software-defined network, the entire network will become SDN (NE just) open in the vertical direction, standardization, programmable, so that it is easier, more efficient use of network resources.

In traditional architecture, switches and routers have to operate in the implementation of the entire intelligence network under the control of 6000 kinds of distributed protocols. This means that even if there is only one network element adds a new agreement, all other network elements also need to make appropriate structural changes. In fact, add a new protocol on the network often take years to finalize the standardization process to actual deployment.

Mininet

What is Mininet

Mininet by some virtual terminal node (end-hosts), switches, routers connected together in a network simulator, which uses lightweight virtualization technology allows the system can be comparable to the real network.

Mininet can easily create a support network of SDN: host computer work like a real, like, you can use ssh to log, start the application program can send data packets to the Ethernet port, the packet will be a switch, a router receives and processes . With this network, the flexibility to add new features for the network and associated tests, and then easily deploy it to real hardware environments.

Mininet Installation and Deployment

Mininet virtual machine installation

  1. Download Mininet Mirror: https://github.com/mininet/mininet/releases
  2. Download virtual machine software. VirtualBox , VMware Workstation
  3. Installation image

Local installation (recommended)

By pulling the source Git

git clone git://github.com/mininet/mininet

Installation Mininet, according to mininet / util / install.sh -h command select View

mininet/util/install.sh -n3V 2.5.0

After installation is complete, use the command Mininet test installation was successful

sudo mn --test pingall

SDN_Command

Mininet installation package (the most convenient)

Mininet installation package in Ubuntu

sudo apt install mininet/precise-backports

Problems encountered during installation

Mininet_Q1.png

Tip 6653 port is occupied

sudo service openvswitch-testcontroller stop

Internal interactive command

Create a default topology after use sudo mn enters the interactive

help #查看帮助命令
net #查看链路信息
nodes #查看网络里面有多少节点以及有什么节点
links #查看链路健壮性,看看某条链路是不是在正常工作
pingall #测试所有主机间通信
pingpair #只验证前两个主机连通性-
dump #节点信息
intfs #网络接口信息
iperf h1 h2 #测试H1 H2的带宽
link s1 s2 up#禁用或开始节点间的链路
iperfudp bw h1 h2 #测试H1 H2 的UDP带宽
xterm h1 #节点开启可视化操作
py net.addSwtich("s1") #执行python 表达式

py experiments

Add a h3 and connected to s1

py net.addHost('h3') #添加一个主机h3
py net.addLink(s1,net.get('h3')) #将s1 和 h3连接起来
py s1.attach('s1-eth3') #添加接口s1-eth3
py net.get('h3').cmd('ifconfig h3-eth0 10.3') #给h3设置ip
py dump #查看设备的信息
#发现我们的h3并没有显示我们设置的IP 依然为none
#我们需要h1 ping h3命令,让设备发现他的ip。在dump即可查看正确的设备信息。

OpenDaylight

1. Installation ODL dependencies

  sudo apt-get update
  sudo apt-get install openjdk-8-jdk

2. Download OpenDaylight Controller: http://www.opendaylight.org/software/downloads

 tar zxvf distribution-karaf-0.3.0-Lithium.tar.gz

3. Configure Java environment

Open vi / etc / profile

Add the following code

JAVA_HOME=/usr/lib/jvm/java-1.8.0-openjdk-amd64

JRE_HOME=$JAVA_HOME/jre

CLASS_PATH=.:$JAVA_HOME/lib/dt.jar:$JAVA_HOME/lib/tools.jar:$JRE_HOME/lib

PATH=$PATH:$JAVA_HOME/bin:$JRE_HOME/bin

export JAVA_HOME JRE_HOME CLASS_PATH PATH

source file

source /etc/profile

4. Test whether the installation is successful

cd distribution-karaf-0.3.0-Lithium

Execution ./bin/karaf

After the successful implementation

odl.png

Flow table

The picture shows the current topology

Experimental objectives are:

h1 can not ping h2

dpctl del-flows
#清除所有流表,也可以使用sh ovs-ofctl s1  del-flows 针对S1删除流表
dpctl add-flow in_port=1,actions=output:2 
#让1端口添加output 2端口
dpctl add-flow in_port=2,actions=output:3,output:1 
#让2端口添加output 3,1端口
dpctl add-flow in_port=3,actions=output:2
#让3端口添加output 2端口

Enter pingall results

1   ->  h2 X 
h2  ->  h1 h3 
h3  ->  X  h2 

One more experiment

Mission objectives is to make h1 and h2 through, h3 and h4 pass, h1 and h3 unreasonable.

According to the mission objectives, which is the only host in the same switch can communicate.

h1 s2 is connected to the port 2

h2 is connected to the third port s2

s3 h3 connected to port 2

h4 s3 connection port 3

As long as the switch can not communicate with each other. 1,3 switch port. Delete all flow table, the exchange added 2, 3.

dpctl del-flows 
dpctl add-flow in_port=2,actions=output:3
dpctl add-flow in_port=3,actions=output:2

pingall results:

h1 -> h2 X X 
h2 -> h1 X X 
h3 -> X X h4 
h4 -> X X h3

With another idea

S1 from the router to discard the entire port 1 can be achieved.

 sh ovs-ofctl add-flow s1 priority=50,in_port=1,action=drop

Guess you like

Origin www.cnblogs.com/skyxmao/p/12653335.html