Floodlight的安裝
在proxmox上創建一臺虛擬機,操作系統爲ubuntu server 14 .04。
創建好之後,需要連接網絡進行安裝,安裝過程記錄如下:
一、在命令行模式下輸入命令直接安裝:-
apt-get update
-
apt-get install git
-
apt-get install ant
- apt-get install openjdk-7-jdk
-
git clone git://github.com/floodlight/floodlight.git
-
cd floodlight/
-
ant
- java -jar target/floodlight.jar
sudo apt-get install openvswitch-controller openvswitch-switch openvswitch-datapath-source
-
ps -ea | grep ovs
-
1216 ? 00:00:00 ovsdb-server
-
1250 ? 00:00:06 ovs-vswitchd
- 2421 ? 00:00:00 ovsdb-client
查看OVS版本
-
ovs-appctl --version
-
ovs-appctl (Open vSwitch) 2.0.2
- Compiled Aug 15 2014 14:31:01
查看 OVS 支持的 OpenFlow 協議的版本
-
ovs-ofctl --version
-
ovs-ofctl (Open vSwitch) 2.0.2
-
Compiled Aug 15 2014 14:31:02
- OpenFlow versions 0x1:0x4
登錄OVS節點:
設置ovs的控制器爲floodlight,10.250.3.10,就是floodlight虛擬機的IP。
- ovs-vsctl set-controller ovs-switch tcp:10.250.3.10:6633
- ovs-vsctl set Bridge ovs-switch fail-mode=secure
# ovs-vsctl show
6507c214-0c7a-4159-9813-977074f73aa1
Bridge ovs-switch
Controller "tcp:10.250.3.10:6633"
is_connected: true
fail_mode: secure
Port "p1"
tag: 101
Interface "p1"
type: internal
Port "p2"
Interface "p2"
type: internal
Port "p0"
Interface "p0"
type: internal
Port ovs-switch
Interface ovs-switch
type: internal
ovs_version: "2.0.2"
-
curl -d '{"switch": "00:00:d2:3b:94:ce:41:46", "name":"my-flow1", "cookie":"0","priority":"32768","ingress-port":"100","active":"true", "actions":"output=flood"}' http://10.250.3.10:8080/wm/staticflowentrypusher/json
-
- curl -d '{"switch": "00:00:d2:3b:94:ce:41:46", "name":"my-flow2", "cookie":"0","priority":"32768","ingress-port":"101","active":"true", "actions":"output=flood"}' http://10.250.3.10:8080/wm/staticflowentrypusher/json
驗證是否能從端口 p0 發送數據包到 p1
-
# ip netns exec ns0 ping -c4 192.168.1.101
-
PING 192.168.1.101 (192.168.1.101) 56(84) bytes of data.
-
64 bytes from 192.168.1.101: icmp_seq=1 ttl=64 time=0.625 ms
-
64 bytes from 192.168.1.101: icmp_seq=2 ttl=64 time=0.088 ms
-
64 bytes from 192.168.1.101: icmp_seq=3 ttl=64 time=0.082 ms
- 64 bytes from 192.168.1.101: icmp_seq=4 ttl=64 time=0.048 ms
-
# ovs-ofctl dump-flows ovs-switch
-
NXST_FLOW reply (xid=0x4):
-
cookie=0xa00000626d6af5, duration=111.468s, table=0, n_packets=7, n_bytes=630, idle_age=2, in_port=100 actions=FLOOD
- cookie=0xa00000626d6af6, duration=83.717s, table=0, n_packets=7, n_bytes=630, idle_age=1, in_port=101 actions=FLOOD
- curl http://10.250.3.10:8080/wm/staticflowentrypusher/list/00:00:d2:3b:94:ce:41:46/json | python -mjson.tool
# curl http://10.250.3.10:8080/wm/stati ... 3b:94:ce:41:46/json | python -mjson.tool
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
100 1435 0 1435 0 0 109k 0 --:--:-- --:--:-- --:--:-- 116k
{
"00:00:d2:3b:94:ce:41:46": {
"my-flow1": {
"actions": [
{
"length": 8,
"lengthU": 8,
"maxLength": 32767,
"port": -5,
"type": "OUTPUT"
}
],
"bufferId": -1,
"command": 0,
"cookie": 45035997925042933,
"flags": 0,
"hardTimeout": 0,
"idleTimeout": 0,
"length": 80,
"lengthU": 80,
"match": {
"dataLayerDestination": "00:00:00:00:00:00",
"dataLayerSource": "00:00:00:00:00:00",
"dataLayerType": "0x0000",
"dataLayerVirtualLan": -1,
"dataLayerVirtualLanPriorityCodePoint": 0,
"inputPort": 100,
"networkDestination": "0.0.0.0",
"networkDestinationMaskLen": 0,
"networkProtocol": 0,
"networkSource": "0.0.0.0",
"networkSourceMaskLen": 0,
"networkTypeOfService": 0,
"transportDestination": 0,
"transportSource": 0,
"wildcards": 4194302
},
"outPort": -1,
"priority": -32768,
"type": "FLOW_MOD",
"version": 1,
"xid": 0
},
"my-flow2": {
"actions": [
{
"length": 8,
"lengthU": 8,
"maxLength": 32767,
"port": -5,
"type": "OUTPUT"
}
],
"bufferId": -1,
"command": 0,
"cookie": 45035997925042934,
"flags": 0,
"hardTimeout": 0,
"idleTimeout": 0,
"length": 80,
"lengthU": 80,
"match": {
"dataLayerDestination": "00:00:00:00:00:00",
"dataLayerSource": "00:00:00:00:00:00",
"dataLayerType": "0x0000",
"dataLayerVirtualLan": -1,
"dataLayerVirtualLanPriorityCodePoint": 0,
"inputPort": 101,
"networkDestination": "0.0.0.0",
"networkDestinationMaskLen": 0,
"networkProtocol": 0,
"networkSource": "0.0.0.0",
"networkSourceMaskLen": 0,
"networkTypeOfService": 0,
"transportDestination": 0,
"transportSource": 0,
"wildcards": 4194302
},
"outPort": -1,
"priority": -32768,
"type": "FLOW_MOD",
"version": 1,
"xid": 0
}
}
}
通過 Floodlight 的 RestAPI,刪除交換機上的流表規則
- curl http://10.250.3.10:8080/wm/staticflowentrypusher/clear/00:00:d2:3b:94:ce:41:46/json