zoukankan      html  css  js  c++  java
  • 2019 SDN上机第4次作业

    1. 解压安装OpenDayLight控制器(本次实验统一使用Beryllium版本)

    • 配置java环境
      MxVlFA.png
    • 安装OpenDayLight控制器
      MxVKdH.png

    2. 启动并安装插件

       cd distribution-karaf-0.4.4-Beryllium-SR4/bin/
       ./karaf
       feature:install odl-restconf
       feature:install odl-l2switch-switch-ui
       feature:install odl-openflowplugin-all
       feature:install odl-mdsal-apidocs
       feature:install odl-dlux-core
       feature:install odl-dlux-node
       feature:install odl-dlux-yangui
    

    MxV1JI.png

    3. 用Python脚本搭建如下拓扑,连接OpenDayLight控制器

    • python代码

        from mininet.topo import Topo
        class Topo2( Topo ):
        def __init__( self ):
        # Initialize topology
        Topo.__init__( self )
        # add switches and hosts  
        sw1 = self.addSwitch('s1')
        sw2 = self.addSwitch('s2')
        h1 = self.addHost('h1')
        h2 = self.addHost('h2')
        h3 = self.addHost('h3')
        # add links
        self.addLink(h1,sw1,1,1)
        self.addLink(h2,sw1,1,2)
        self.addLink(h3,sw1,1,3)
        topos = { 'mytopo': ( lambda: Topo2() ) }
      
    • 连通性
      MxVMod.png

    • 可执行
      MxVuee.png

    4. 在控制器提供的WEB UI中下发流表使h2 20s内ping不通h3,20s后恢复

    MxV3Wt.png

    • 下发流表设置过程
      MxVJQf.png
      MxVYy8.png
    • 解释
       id:流表项id,任意值,不冲突即可
       in-port:流表项匹配的进入端口,这里需填h2对应的port号
       ethernet-type:以太网类型0x0800表示以太网帧是ip协议
       layer-3-match:ipv4-match 三层匹配为ipv4匹配
       ipv4-source:数据包源ip匹配项(这里由于port1进入的数据包只可能是h2发送的所以可以不填)
       ipv4-destination:数据包目的ip匹配项
       新增instruction list这是流表项匹配到数据报后要执行的指令
       order:0 指令id0
       instruction:apply-actions-case 执行动作
       新增action list
       action drop-action-case 丢包动作(转发动作为output-action 并要在output-node-connector填写转发端口)
       order:0 动作id0
       flow-name 流表项名字,可不填
       priority 流表项优先级,要大于odl下发的默认流表,这里设置成最大65535
       hard-timeout 硬超时,流表项下发后生效时长
       cookie 可不填,为方便在ovs中查找下发成功的流表项可以设置成容易找的到值如0x02(要填16进制)
       table_id 流表id 默认为0
    
    • 查询链路连接情况
      MxVtOS.png
    • h2 ping h3,发生延时
      MxVUeg.png

    5. 借助Postman通过OpenDayLight的北向接口下发流表,再利用OpenDayLight北向接口查看已下发的流表。

    • 安装运行postman,下发流表json格式
    http://127.0.0.1:8181/restconf/config/opendaylight-inventory:nodes/node/openflow:1/flow-node-inventory:table/0/flow/1
    
    {
        "flow": [
            {
                "id": "1",
                "match": {
                    "in-port": "1",
                    "ethernet-match": {
                        "ethernet-type": {
                            "type": "0x0800"
                        }
                    },
                    "ipv4-destination": "10.0.0.3/32"
                },
                "priority": "65535",
                "hard-timeout": "25",
                "cookie": "2",
                "table_id": "0"
            }
        ]
    }
    
    • 将preview的url复制到地址栏,输入odl的默认账号和密码admin
      MxVawQ.png
    • 将preview的消息粘贴在文本框中,修改id和url里的flow为2,防止与之前的流表重合,点击send后下发成功,然后改为GET并send查看刚下发的流表
      MxVdoj.png
  • 相关阅读:
    leetcode刷题29
    leetcode刷题28
    leetcode刷题27
    leetcode刷题23
    leetcode刷题22
    leetcode刷题21
    leetcode刷题20
    Unity中通过DoTween实现转盘效果
    U3D工作注意事项,不要再犯!
    Unity中String字符串的优化
  • 原文地址:https://www.cnblogs.com/caoyuanfeifeixiong/p/11899703.html
Copyright © 2011-2022 走看看