博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
期末作业验收
阅读量:7059 次
发布时间:2019-06-28

本文共 5290 字,大约阅读时间需要 17 分钟。

负载均衡程序

  • 拓扑设计

1288343-20180126222540303-878820895.png

  • 部分control代码展示

while(True):            #获取s4端口1的流量            uri = 'http://127.0.0.1:8181/restconf/operational/opendaylight-inventory:nodes/node/openflow:4/node-connector/openflow:4:1'            response, content = http.request(uri=uri, method='GET')            content = json.loads(content)            statistics = content['node-connector'][0]['opendaylight-port-statistics:flow-capable-node-connector-statistics']            bytes1 = statistics['bytes']['transmitted']            #1秒后再次获取            time.sleep(1)            response, content = http.request(uri=uri, method='GET')            content = json.loads(content)            statistics = content['node-connector'][0]['opendaylight-port-statistics:flow-capable-node-connector-statistics']            bytes2 = statistics['bytes']['transmitted']            #在检测到s4的1口流量空闲时发的流表            speed=float(bytes2-bytes1)/1            if speed !=0 :#获取有效的速度                if speed < 1000 :                    print 'speed =',speed,',  s2端口1空闲,数据包往1口通过'                #下发默认的流表                                response, content = http.request(uri='http://127.0.0.1:8181/restconf/config/opendaylight-inventory:nodes/node/openflow:4/flow-node-inventory:table/0/flow/41',                                         body=h2_to_s4_1, method='PUT',headers=headers)                      response, content = http.request(uri='http://127.0.0.1:8181/restconf/config/opendaylight-inventory:nodes/node/openflow:4/flow-node-inventory:table/0/flow/51',                                         body=h3_to_s4_1, method='PUT',headers=headers)                      response, content = http.request(uri='http://127.0.0.1:8181/restconf/config/opendaylight-inventory:nodes/node/openflow:4/flow-node-inventory:table/0/flow/61',                                        body=h4_to_s4_1, method='PUT',headers=headers)                #在检测到s2的1口流量满载时下发新的流表                else :                    print 'speed =',speed,',  s2端口1满载,数据包改为往2口和3口通过'                #h2数据包的流表                    response, content = http.request(uri='http://127.0.0.1:8181/restconf/config/opendaylight-inventory:nodes/node/openflow:4/flow-node-inventory:table/0/flow/41',                                         body=lh2_to_s4_1, method='PUT',headers=headers)                    response, content = http.request(uri='http://127.0.0.1:8181/restconf/config/opendaylight-inventory:nodes/node/openflow:4/flow-node-inventory:table/0/flow/42',                                         body=h2_to_s4_2, method='PUT',headers=headers)                    response, content = http.request(uri='http://127.0.0.1:8181/restconf/config/opendaylight-inventory:nodes/node/openflow:4/flow-node-inventory:table/0/flow/43',                                         body=h2_to_s4_3, method='PUT',headers=headers)                #h3数据包的流表                    response, content = http.request(uri='http://127.0.0.1:8181/restconf/config/opendaylight-inventory:nodes/node/openflow:4/flow-node-inventory:table/0/flow/52',                                         body=h3_to_s4_2, method='PUT',headers=headers)                    response, content = http.request(uri='http://127.0.0.1:8181/restconf/config/opendaylight-inventory:nodes/node/openflow:4/flow-node-inventory:table/0/flow/53',                                         body=h3_to_s4_3, method='PUT',headers=headers)                #h4数据包的流表                    response, content = http.request(uri='http://127.0.0.1:8181/restconf/config/opendaylight-inventory:nodes/node/openflow:4/flow-node-inventory:table/0/flow/62',                                         body=h4_to_s4_2, method='PUT',headers=headers)                    response, content = http.request(uri='http://127.0.0.1:8181/restconf/config/opendaylight-inventory:nodes/node/openflow:4/flow-node-inventory:table/0/flow/63',                                         body=h4_to_s4_3, method='PUT',headers=headers)
  • scene代码

from mininet.topo import Topo    class MyTopo( Topo ):        def __init__( self ):            # initilaize topology               Topo.__init__( self )            # add hosts and switches            host1 = self.addHost( 'h1' )            host2 = self.addHost( 'h2' )        host3 = self.addHost( 'h3' )        host4 = self.addHost( 'h4' )            switch1 = self.addSwitch( 's1' )            switch2 = self.addSwitch( 's2' )            switch3 = self.addSwitch( 's3' )            switch4 = self.addSwitch( 's4' )                    # add links            self.addLink(host1,switch1)            self.addLink(switch1,switch2)            self.addLink(switch1,switch3)            self.addLink(switch1,switch4)            self.addLink(switch2,switch4)            self.addLink(switch3,switch4)                self.addLink(switch4,host2)            self.addLink(switch4,host3)            self.addLink(switch4,host4)    topos = { 'mytopo': ( lambda: MyTopo() ) }

演示视频

程序分工

  • 赖志平:控制流表下发,负载均衡策略实现,实验的统筹与指导实现

  • 陈敏辉:测试与纰漏修改,ReadMe说明

  • 陈甘霖:流表设计和修正和视频录制

  • 陈家进:拓扑搭建、视频剪辑

学期总结

1.了解了什么是 SDN ,openflow,SDN 的基本思想、特点。    2.掌握了在mninet上创建拓扑并通过floodlight验证器正确    3.运用ODL控制器下发流表并通过OVS命令查看验证;运用Postman通过ODL的北向接口下发流表    4.运用Wireshark抓包验证拓扑结构的正确性    5.对ECMP与负载均衡的定义及实现有一些了解,可以实现较简单的负载均衡场景    6.课程新颖,走在时代前沿,一个学期的学习肯定是不够的,只是皮毛,在接下来的日子会继续了解相关方面的知识,以及考虑如何应用

转载于:https://www.cnblogs.com/cmh1111/p/8353871.html

你可能感兴趣的文章
IKAnalyzer使用停用词词典进行分词
查看>>
ExtJS+ASP.NET自己定义曲线
查看>>
transmission简单使用
查看>>
6-8-并查集(等价类)-树和二叉树-第6章-《数据结构》课本源码-严蔚敏吴伟民版...
查看>>
Log4j 输出的日志中时间比系统时间少了8小时的解决方法,log4j日志文件重复输出...
查看>>
UML用例图总结
查看>>
[改善Java代码]优先使用整型池
查看>>
iOS中设置导航栏标题的字体颜色和大小
查看>>
h.264并行解码算法分析
查看>>
ALSA声音编程介绍
查看>>
bootstrap fileinput 文件上传工具
查看>>
C# String 前面不足位数补零的方法
查看>>
route命令
查看>>
KETTLE、spoon使用
查看>>
如何生成密钥,私钥,签名
查看>>
etc下
查看>>
iOS - Swift NSData 数据
查看>>
基础知识→设计模式
查看>>
Chrome 启动参数列表
查看>>
Django中Form的Textarea字段
查看>>