• sdn期末作业验收


    一、项目描述

    负载均衡程序

    二、个人分工

    小组成员:李文博,冉思银,侯振源,李熙,汪志彬

    工作:部分流表组表的编写

    三、代码演示及过程描述

    拓扑代码:

    from mininet.topo import Topo
    
    class MyTopo( Topo ):
    "Simple topology example."
    
    def __init__( self ):
    
        # Initialize topology
        Topo.__init__( self )
        h1 = self.addHost('h1')
        h2 = self.addHost('h2')
        h3 = self.addHost('h3')
        h4 = self.addHost('h4')
    
        s1 = self.addSwitch('s1')
        s2 = self.addSwitch('s2')
        s3 = self.addSwitch('s3')
        s4 = self.addSwitch('s4')
    
        self.addLink(h1,s1)
        self.addLink(s1,s2)
        self.addLink(s1,s3)
        self.addLink(s1,s4)
        self.addLink(s2,s4)
        self.addLink(s3,s4)
        self.addLink(s4,h2)
        self.addLink(s4,h3)
        self.addLink(s4,h4)
    topos = { 'mytopo': ( lambda: MyTopo() ) }
    

    发流表:

    import httplib2
    import time
    
    class OdlUtil:
    url = ''
    def init(self, host, port):
    self.url = 'http://' + host + ':' + str(port)
    def install_flow(self, container_name='default',username="admin", password="admin"):
    http = httplib2.Http()
    http.add_credentials(username, password)
    headers = {'Accept': 'application/json'}
    flow_name = 'flow_' + str(int(time.time()*1000))
    s1zbody='{"group": [{ "group-type": "group-select","group-id": "1","group-name": "loadbalance","buckets": {"bucket": [{"bucket-id": "1","weight": "3","action": [{"order": "0","output-action": {"output-node-connector": "4"}}]},{"bucket-id": "2","weight": "2","action": [{"order": "0","output-action": {"output-node-connector": "2"}}]},{"bucket-id": "3","weight": "2","action": [{"order": "0","output-action": {"output-node-connector": "3"}}]}]}}]}'
    s1lbody='{"flow": [{"id": "1","match": {"in-port": "1"},"instructions": {"instruction": [{"order": "0","apply-actions": {"action": [{"order": "0","group-action": {"group-id": "1"}}]}}]},"flow-name": "s1","priority": "1000","cookie": "0x0001","table_id": "0"}]}'
    s2lbody='{"flow": [{"id": "1","match": {"in-port": "1"},"instructions": {"instruction": [{"order": "0","apply-actions": {"action": [{"order": "0","output-action": {"output-node-connector": "2"}}]}}]},"flow-name": "s2","priority": "1000","cookie": "0x0001","table_id": "0"}]}'
    s3lbody='{"flow": [{"id": "1","match": {"in-port": "1"},"instructions": {"instruction": [{"order": "0","apply-actions": {"action": [{"order": "0","output-action": {"output-node-connector": "2"}}]}}]},"flow-name": "s3","priority": "1000","cookie": "0x0001","table_id": "0"}]}'
    s4lbody='{"flow": [{"id": "1","match": {"in-port": "2","ethernet-match": {"ethernet-type": {"type": "0x0800"}},"ipv4-destination": "10.0.0.2/32"},"instructions": {"instruction": [{"order": "0","apply-actions":{"action": [{"order": "0","output-action": {"output-node-connector": "4"}}]}}]},"flow-name": "s4:s2toh2","priority": "1000","cookie": "0x0001","table_id": "0"}]}'
    s4lbody2='{"flow": [{"id": "2","match": {"in-port": "2","ethernet-match": {"ethernet-type": {"type": "0x0800"}},"ipv4-destination": "10.0.0.3/32"},"instructions": {"instruction": [{"order": "0","apply-actions":{"action": [{"order": "0","output-action": {"output-node-connector": "5"}}]}}]},"flow-name": "s4:s2toh3","priority": "1000","cookie": "0x0001","table_id": "0"}]}'
    s4lbody3='{"flow": [{"id": "3","match": {"in-port": "2","ethernet-match": {"ethernet-type": {"type": "0x0800"}},"ipv4-destination": "10.0.0.4/32"},"instructions": {"instruction": [{"order": "0","apply-actions":{"action": [{"order": "0","output-action": {"output-node-connector": "6"}}]}}]},"flow-name": "s4:s2toh4","priority": "1000","cookie": "0x0001","table_id": "0"}]}'
    s4lbody4='{"flow": [{"id": "4","match": {"in-port": "1","ethernet-match": {"ethernet-type": {"type": "0x0800"}},"ipv4-destination": "10.0.0.2/32"},"instructions": {"instruction": [{"order": "0","apply-actions":{"action": [{"order": "0","output-action": {"output-node-connector": "4"}}]}}]},"flow-name": "s4:s1toh2","priority": "1000","cookie": "0x0001","table_id": "0"}]}'
    s4lbody5='{"flow": [{"id": "5","match": {"in-port": "1","ethernet-match": {"ethernet-type": {"type": "0x0800"}},"ipv4-destination": "10.0.0.3/32"},"instructions": {"instruction": [{"order": "0","apply-actions":{"action": [{"order": "0","output-action": {"output-node-connector": "5"}}]}}]},"flow-name": "s4:s1toh3","priority": "1000","cookie": "0x0001","table_id": "0"}]}'
    s4lbody6='{"flow": [{"id": "6","match": {"in-port": "1","ethernet-match": {"ethernet-type": {"type": "0x0800"}},"ipv4-destination": "10.0.0.4/32"},"instructions": {"instruction": [{"order": "0","apply-actions":{"action": [{"order": "0","output-action": {"output-node-connector": "6"}}]}}]},"flow-name": "s4:s1toh4","priority": "1000","cookie": "0x0001","table_id": "0"}]}'
    s4lbody7='{"flow": [{"id": "7","match": {"in-port": "3","ethernet-match": {"ethernet-type": {"type": "0x0800"}},"ipv4-destination": "10.0.0.2/32"},"instructions": {"instruction": [{"order": "0","apply-actions":{"action": [{"order": "0","output-action": {"output-node-connector": "4"}}]}}]},"flow-name": "s4:s3toh2","priority": "1000","cookie": "0x0001","table_id": "0"}]}'
    s4lbody8='{"flow": [{"id": "8","match": {"in-port": "3","ethernet-match": {"ethernet-type": {"type": "0x0800"}},"ipv4-destination": "10.0.0.3/32"},"instructions": {"instruction": [{"order": "0","apply-actions":{"action": [{"order": "0","output-action": {"output-node-connector": "5"}}]}}]},"flow-name": "s4:s3toh3","priority": "1000","cookie": "0x0001","table_id": "0"}]}'
    s4lbody9='{"flow": [{"id": "9","match": {"in-port": "3","ethernet-match": {"ethernet-type": {"type": "0x0800"}},"ipv4-destination": "10.0.0.4/32"},"instructions": {"instruction": [{"order": "0","apply-actions":{"action": [{"order": "0","output-action": {"output-node-connector": "6"}}]}}]},"flow-name": "s4:s3toh4","priority": "1000","cookie": "0x0001","table_id": "0"}]}'
    headers = {'Content-type': 'application/json'}
    num=0
    while num < 1 :
    response, content = http.request(uri='http://127.0.0.1:8181/restconf/config/opendaylight-inventory:nodes/node/openflow:1/flow-node-inventory:group/1', body=s1zbody, method='PUT',headers=headers)
    response, content = http.request(uri='http://127.0.0.1:8181/restconf/config/opendaylight-inventory:nodes/node/openflow:1/flow-node-inventory:table/0/flow/1', body=s1lbody, method='PUT',headers=headers)
    response, content = http.request(uri='http://127.0.0.1:8181/restconf/config/opendaylight-inventory:nodes/node/openflow:2/flow-node-inventory:table/0/flow/1', body=s2lbody, method='PUT',headers=headers)
    response, content = http.request(uri='http://127.0.0.1:8181/restconf/config/opendaylight-inventory:nodes/node/openflow:3/flow-node-inventory:table/0/flow/1', body=s3lbody, 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/1', body=s4lbody, 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/2', body=s4lbody2, 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/3', body=s4lbody3, 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/4', body=s4lbody4, 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/5', body=s4lbody5, 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/6', body=s4lbody6, 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/7', body=s4lbody7, 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/8', body=s4lbody8, 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/9', body=s4lbody9, method='PUT',headers=headers)
    num=num + 1
    print(content.decode())
    odl = OdlUtil('127.0.0.1', '8181')
    odl.install_flow()
    

    视频:
    由于实验失败无视频

    四、课程总结

    1.了解了sdn的基本概念与基本思想。比如SDN 网络体系结构主要包括 SDN 网络应用、北向接口、 SDN 控制器、南向接口和 SDN 数据平面共五部分。
    2.了解了Wireshark抓包验证。
    3.了解了mininet的使用。用图形化界面或者python代码构造拓扑结构。和odl等的基本操作。
    4.了解了负载均衡的概念,在最后一次实践中与小组的其他成员一起做负载均衡的作业。
    虽然最终还是没有实现,尝试了多次还是不知道哪里出错。。感觉非常的遗憾,但通过这门课程还是了解到这门新技术的神奇之处。。

  • 相关阅读:
    Qt音视频开发11-ffmpeg常用命令
    Qt音视频开发10-ffmpeg控制播放
    Qt音视频开发9-ffmpeg录像存储
    Intellij IDEA 与maven 版本不符 Unable to import maven project See logs for details: No implementation for org.apache.maven.model.path.PathTranslator was bound
    Java Map 遍历史上最全
    java new date 结果与操作系统时间相差8小时处理解决方法
    elasticsearch报错
    Pytorch-基于Transformer的情感分类
    Pytorch-LSTM+Attention文本分类
    PHP FFI调用go,居然比go还快
  • 原文地址:https://www.cnblogs.com/Flame09/p/8343535.html
Copyright © 2020-2023  润新知