软件定义网络实验(六)----OpenDaylight 及 Postman实现流表下发

OpenDaylight 实验—OpenDaylight 及 Postman实现流表下发

 一、实验目的

      熟悉 Postman 的使用;熟悉如何使用 OpenDaylight 通过 Postman 下发流表。

二、实验任务

      流表有软超时和硬超时的概念,分别对应流表中的 idle_timeout 和hard_timeout。

      1、idle timeout:如果值为非 0,那么在对应的时间内如果没有数据包匹配流表,时间到该流表将被删除;值为 0 不设软超时机制。

      2、hard timeout:如果值为非 0,那么在对应的时间内不论是否有数据包匹配流表,时间到流表都会被删除;值为 0 不设硬超时机制。

推荐阅读:SDNLAB 文章:OpenFlow 协议超时机制简介https://www.sdnlab.com/22563.html

     本实验通过 OpenDaylight 及 Postman 下发关于硬超时的流表,实现拓扑内主机h1 和 h3 在一定时间内的网络断开。Postman 是一个 http 请求工具,可用于 REST API 的接口调试。实验拓扑如下:

三、实验步骤
 
    1、实验环境

    安装了 Ubuntu 18.04.5 Desktop amd64 的虚拟机。

    2. 实验过程

       (1) Postman 安装

            下载网址:https://www.postman.com/downloads/


           站点会监测系统版本,请下载 Linux 版本,解压到/home/ubuntu/你的用户名/目录下即可。指导书示例目录:/home/ubuntu/sdn/Postman,进入上述目录,运行Postman 文件即可。

       (2) 清理旧数据

             1、启动 OpenDaylight,通过 Postman 的 Delete 动作清空残留流表(如有)

          DELETE      http://127.0.0.1:8181/restconf/config/opendaylight-inventory:nodes/node/openflow:1/

           2、清空 Mininet 数据

               sudo mn -c

     (3) 生成拓扑并连接 OpenDaylight

            sudo mn --topo=single,3 --controller=remote,ip=127.0.0.1,port=6633 --switch ovsk,protocols=OpenFlow13

 

 

 

          正常情况下,三台主机是互通的。

 

 

       如果不通,可能控制器有旧的流表残留。

   (4) 使用 Postman 填入 JSON 格式的 http 请求(参考附录)

           先在MininetCLI中运行h1 ping h3,再在Postman处选择动作PUT,填入硬超时流表内容(见附录),可以先阅读一下流表的内容,关注match匹配字段以及对应的instructions 指令中的动作action,这里是直接drop数据包。为了让流表能够匹配,将优先级priority 调到最大。点击右.上角send,发送请求。

         JSON代码 

{
    "flow":[
        {
            "id":"1",
            "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", 
                                         "drop-action": {}
                                    }
                                ]
                           }
                      }
                  ]
             },
              "flow-name": "flow1", 
              "priority": "65535", 
              "hard-timeout": "10", 
              "cookie": "2",
              "table_id": "0" 
        }
    ]
}

(5)验证结果

h1  ping  h3有10秒时间是中断的,结果符合预期。

四、实验总结

    BUG1:在解压Postman后打不开应用

    Solution:进去名为Postman的文件夹里面执行命令 ./Postman 而且不要移动Postman文件夹。

  BUG2:在执行json时发现一张得不到实验结果

    Solution:先认证,然后检查json的缩进以及括号匹配。在此之前确保前面的步骤都正确执行 

posted @ 2020-10-07 23:13  Tiny484  阅读(343)  评论(0编辑  收藏  举报