zoukankan      html  css  js  c++  java
  • 期末作业验收

    负载均衡程序

    • 拓扑设计

    • 部分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() ) }
    

    演示视频

    https://github.com/laizhiping/final-exam-sdn#实验场景

    程序分工

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

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

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

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

    学期总结

        1.了解了什么是 SDN ,openflow,SDN 的基本思想、特点。
        2.掌握了在mninet上创建拓扑并通过floodlight验证器正确
        3.运用ODL控制器下发流表并通过OVS命令查看验证;运用Postman通过ODL的北向接口下发流表
        4.运用Wireshark抓包验证拓扑结构的正确性
        5.对ECMP与负载均衡的定义及实现有一些了解,可以实现较简单的负载均衡场景
        6.课程新颖,走在时代前沿,一个学期的学习肯定是不够的,只是皮毛,在接下来的日子会继续了解相关方面的知识,以及考虑如何应用
  • 相关阅读:
    java之JDBC
    git删除未监视的文件
    java之正则表达式
    linux命令之信息显示与搜索文件命令
    linux命令之文件备份与压缩命令
    gitlab中修改项目名称客户端修改方法
    linux中使用unzip命令中文乱码解决办法
    使用Python进行统计量描述
    Machine Learning
    Courase Neural Networks for Machine Learning Lecture1 Note
  • 原文地址:https://www.cnblogs.com/cmh1111/p/8353871.html
Copyright © 2011-2022 走看看