Floodlight(controller)+OpenFlow交换机:环境搭建

本文主要介绍了有OpenFlow硬件设备的情况下与controller如何搭建一个OpenFlow环境。
我的设备:controller机器*1  openflow交换机*1  PC机若干
平台细节:
controller机器:Ubuntu12.04+Floodlight
PC机:系统随意


一.controllerd在ubuntu系统下安装Floodlight,并运行,作为OpenFlow环境的控制器
安装Floodlight
[controller@host ]# sudo apt-get install build-essential default-jdk ant python-dev
[controller@host ]git clone git://github.com/floodlight/floodlight.git
[controller@host ]cd floodlight
[controller@host ]git checkout fl-last-passed-build     或者    git checkout stable
[controller@host ]ant    整合
[controller@host ]java -jar target/floodlight.jar   运行floodlight
如果执行卡住,并报错为address already use.说明端口被占用
解决方法为两种(选一):
1:  [controller@host ]netstat -anp | grep  8080   查看端口
[controller@host ]kill -9 <pid>                              关闭端口
2: 修改配置文件,使其不用被占用的端口
在floodlight目录下
[controller@host ]vi src/main/resources/floodlightdefault.properties
把8080改成8085或其它,再整合
[controller@host ]ant
再运行floodlight

注:运行后本终端为卡住状态,并实时输出debug信息.

正常信息为:

.......

12:49:05.079 [main] INFO  o.r.Component.InternalRouter.Server - Starting the Simple [HTTP/1.1] server on port 8080

12:49:05.132 [main] DEBUG n.f.core.internal.Controller - OFListeners for FLOW_REMOVED: staticflowentry,
12:49:05.132 [main] DEBUG n.f.core.internal.Controller - OFListeners for PACKET_IN: linkdiscovery,topology,devicemanager,firewall,forwarding,
12:49:05.132 [main] DEBUG n.f.core.internal.Controller - OFListeners for PORT_STATUS: linkdiscovery,
12:49:05.253 [main] INFO  n.f.core.internal.Controller - Listening for switch connections on 0.0.0.0/0.0.0.0:6633
12:49:11.388 [debugserver-main] INFO  n.f.jython.JythonServer - Starting DebugServer on port 6655
12:49:11.558 [New I/O server worker #1-1] INFO  n.f.core.internal.Controller - New switch connection from /10.0.0.1:47324

12:49:11.601 [New I/O server worker #1-1] DEBUG n.f.core.internal.Controller - This controller's role is null, not sending role request msg to null
12:49:11.609 [main] DEBUG n.f.s.StaticFlowEntryPusher - addedSwitch OFSwitchImpl [/10.0.0.1:47324 DPID[00:34:a0:b3:cc:a3:5f:40]]; processing its static entries

12:49:11.785 [New I/O server worker #1-1] DEBUG n.f.d.internal.DeviceManagerImpl - New device created.......

.......


二.配置好openflow交换机
配置好交换机的管理地址,可先用串口登,使管理口地址与controller地址在同一个网络中.
在交换机上配置controller地址:
如:
先用命令新建一个bridge,并加入其接口.
[switch@shell ] 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交换机添加与删除流表.
添加流表:


[controller@host ]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://<controller_ip>:8080/wm/staticflowentrypusher/json


[controller@host ]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://<controller_ip>:8080/wm/staticflowentrypusher/json


[controller@host ]# curl -d '{"switch":"00:00:00:00:00:00:00:01", "name":"flow-mod-3", "src-ip":"192.168.1.3", "dst-ip":"192.168.1.5", "ether-type":"0x800", "cookie":"0", "priority":"2232", "ingress-port":"1","active":"true", "actions":"output=2"}' http://<controller_ip>: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":后面的参数为入接口

"dst-ip":匹配目的IP

"src-ip":匹配源IP

"ether-type":匹配以太类型

"actions":后面的output参数为出接口 ("actions":"" 引号内不填为drop操作)

<controller_ip>填入controller的IP


读取流表:
[controller@host ]curl http://192.168.1.100:8080/wm/core/switch/1/flow/json
[controller@host ]curl http://192.168.1.100:8080/wm/staticflowentrypusher/list/all/json

删除流表:
1.删除所有流表
[controller@host ]curl http://192.168.1.208:8080/wm/staticflowentrypusher/clear/<dpid>/json
2.删除单条流表
[controller@host ]curl -X DELETE -d '{"name":"flow-mod-1"}' http://<controller_ip>:8080/wm/staticflowentrypusher/json




  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 3
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 3
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值