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

    一.网络拓扑

    二.拓扑建立和Python代码,下发流表等

    代码部分:

    from mininet.topo import Topo
       class MyTopo( Topo ):
            "Simple topology example."
    
          def __init__( self ):
    
         # Initialize topology
        Topo.__init__( self )
        s1 = self.addSwitch('s1')
        s2 = self.addSwitch('s2')
        s3 = self.addSwitch('s3')
        s4 = self.addSwitch('s4')
    
        h1 = self.addHost('h1')
        h2 = self.addHost('h2')
        h3 = self.addHost('h3')
        
        self.addLink(h1,s1)
        self.addLink(s1,s2)
        self.addLink(s1,s3)
        self.addLink(s2,s4)
        self.addLink(s3,s4)
        self.addLink(h2,s4)
        self.addLink(h3,s4)
    
        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))
    
       h1h2body1 ='{"flow": [{"id": "1","match": {"ethernet-match":'
                  '{"ethernet-type": {"type": "2048"}},'
                  '"ipv4-source":"10.0.0.1/32","ipv4-destination": "10.0.0.2/32"},'
                  '"instructions": {"instruction": [{"order": "0",'
                  '"apply-actions": {"action": [{"output-action": {'
                  '"output-node-connector": "2"},"order": "0"}]}}]},'
                  '"priority": "100","cookie": "1","table_id": "0"}]}'
    
       mh1h2body1 ='{"flow": [{"id": "1","match": {"ethernet-match":'
                   '{"ethernet-type": {"type": "2048"}},'
                   '"ipv4-source":"10.0.0.1/32","ipv4-destination": "10.0.0.2/32"},'
                   '"instructions": {"instruction": [{"order": "0",'
                   '"apply-actions": {"action": [{"output-action": {'
                   '"output-node-connector": "2"},"order": "0"}]}}]},'
                   '"priority": "102","cookie": "1","table_id": "0"}]}'
    
       h1h2body2 ='{"flow": [{"id": "2","match": {"ethernet-match":'
                  '{"ethernet-type": {"type": "2048"}},'
                  '"ipv4-source":"10.0.0.1/32","ipv4-destination": "10.0.0.2/32"},'
                  '"instructions": {"instruction": [{"order": "0",'
                  '"apply-actions": {"action": [{"output-action": {'
                  '"output-node-connector": "3"},"order": "0"}]}}]},'
                  '"priority": "99","cookie": "2","table_id": "0"}]}'
    
       mh1h2body2 ='{"flow": [{"id": "2","match": {"ethernet-match":'
                   '{"ethernet-type": {"type": "2048"}},'
                   '"ipv4-source":"10.0.0.1/32","ipv4-destination": "10.0.0.2/32"},'
                   '"instructions": {"instruction": [{"order": "0",'
                   '"apply-actions": {"action": [{"output-action": {'
                   '"output-node-connector": "3"},"order": "0"}]}}]},'
                   '"priority": "102","cookie": "2","table_id": "0"}]}'
    
       headers = {'Content-type': 'application/json'}
       num=0
       while num < 4 :
                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/3', body=mh1h2body1, method='PUT',
    headers=headers) time.sleep(0.1) 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/3', body=h1h2body1, 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/2', body=mh1h2body2, method='PUT',headers=headers) time.sleep(0.1) 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/2', body=h1h2body2, method='PUT',headers=headers) print(content.decode()) odl = OdlUtil('127.0.0.1','8181') odl.install_flow()

      相关图片:

    三.任务分工

    主要负责搜集相关资料和拓扑的建立,演讲ppt和后期视频的剪辑等。

    四.课程总结

            主要是学会了一些基本的SDN的网络拓扑知识,学会了在mninet上创建拓扑并通过floodlight验证器正确,用ODL控制器下发流表并通过

    OVS命令查看验证,用Postman通过ODL的北向接口下发流表,用Wireshark抓包验证拓扑结构的正确性,学习了实现较简单的负载均衡场景,

    了解了几种负载均衡的简单算法以及对负载均衡的优化,收获还是挺大的。

  • 相关阅读:
    设计模式(第八式:适配器模式)
    设计模式(第七式:装饰模式)
    设计模式(第六式:代理模式)
    设计模式(第五式:原型模式)
    设计模式(第四式:建造者模式)
    设计模式(第三式:抽象工厂模式)
    ASP.NET C#使用JavaScriptSerializer实现序列化与反序列化得到JSON
    C#中Object转化为json对象
    C# 调用WebApi
    Winform实现调用asp.net数据接口实例
  • 原文地址:https://www.cnblogs.com/fdlpp/p/8351069.html
Copyright © 2011-2022 走看看