一.配置好openflow交换机
配置好交换机的管理地址,可先用串口登,使管理口地址与controller地址在同一个网络中.
在交换机上配置controller地址:
如:
先用命令新建一个bridge,并加入其接口.
[[email protected] ]# ovs-vsctl set-controller br0 tcp:192.168.1.1:6633 --->此地址为controller IP地址
二.将若干PC机与交换机接口相连,并在controller上查看floodlight的信息,可以发现有OpenFlow Switch与之相连,并能查看连接上的PC机与拓扑。进入 http://localhost:8080/ui/index.html
8080为floodlightdefault.properties文件中所指定的端口号.可以登录floodligt的web界面.
三.通过controller控制openflow交换机
当floodlightdefault.properties配置文件中加载了转发模块(net.floodlightcontroller.forwarding.Forwarding).则连接在交换机上的PC机是可以互相ping通 的.floodlight中没有加载此模块时,须要用使添加流表来控制流向.下面介绍一下从控制器端对openflow交换机添加与删除流表.
添加流表:
[[email protected] ]# curl -d ‘{"switch": "00:00:00:00:00:00:00:01", "name":"flow-mod-1", "cookie":"0", "priority":"2232", "ingress- port":"1","active":"true", "actions":"output=2"}‘ http://:8080/wm/staticflowentrypusher/json
[[email protected] ]# curl -d ‘{"switch": "00:00:00:00:00:00:00:01", "name":"flow-mod-2", "cookie":"0", "priority":"2232", "ingress- port":"2","active":"true", "actions":"output=1"}‘ http://:8080/wm/staticflowentrypusher/json
这两条流表为1号端口的流向2号接口,2号端口的流向1号接口.
连接在这两个接口上的PC机可以互相通信.
可变参数解析:
"00:00:00:00:00:00:00:01"为openflow交换机与controller交互所产生的DPID.
"flow-mod-1"为该流表的名字(索引),后可用此名字(索引)来删除该流表.
"ingress-port":后面的参数为入接口
"actions":后面的参数为出接口
填入controller的IP
读取流表:
[[email protected] ]# curl http://192.168.1.100:8080/wm/core/switch/1/flow/json
[[email protected] ]# curl http://192.168.1.100:8080/wm/staticflowentrypusher/list/all/json
删除流表:
1.删除所有流表
[[email protected] ]# curl http://192.168.1.208:8080/wm/staticflowentrypusher/clear//json
2.删除单条流表
[[email protected] ]# curl -X DELETE -d ‘{"name":"flow-mod-1"}‘ http://:8080/wm/staticflowentrypusher/json