zoukankan      html  css  js  c++  java
  • 实验6:OpenDaylight 实验 —— OpenDaylight 及 Postman 实现流表下发

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

    一、实验目的

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

    二 、实验 任务

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

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

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

    推荐阅读:SDNLAB 文章:OpenFlow 协议超时机制简介

    https://www.sdnlab.com/22563.html

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

    image-20201011155023313

    三 、 实验步骤

    1. 实验环境

    安装了 Ubuntu 18.04.5 Desktop amd64 的虚拟机

    2. 实验过程

    (1) Postman 安装

    https://www.postman.com/downloads/

    image-20201011155550010

    站点会监测系统版本,请下载 Linux 版本,解压到/home/ubuntu/sdn/Postman下即可。进入目录 sdn/Postman/Postman/Postman 下,运行 Postman 文件即可

    image-20201011164455026

    (2) 清理旧数据

    • 先打开 OpenDaylight 控制器

      $ cd sdn/OpenDaylight/distribution-karaf-0.6.4-Carbon/bin #进入OpenDaylight目录
      $ ./karaf #启动控制器
      

    • DELETE

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

    • 清空 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 请求

    • 新建put类型请求

      请求URL: http://127.0.0.1:8181/restconf/config/opendaylight-inventory:nodes/node/openflow:1/flow-node-inventory:table/0/flow/1

    • 设置type为 Basic Auth, username和password都为 admin

    image-20201011164148802

    • 设置Body, 选择raw, 参数类型为JSON,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) 验证结果

    • 先在 Mininet CLI 中运行 h1 ping h3

    • 点击右上角 send,发送请求。

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

    总结

    实验过程中有遇到 Postman 请求405错误, 打听到的解决方法是重新安装 OpenDaylight ,感谢小yu姐!!!

  • 相关阅读:
    数据持久化
    在职场久了,才知道这样安排工作日程,方能实现真正的高效
    HIS系统-如何设置单病种结算方式
    HIS系统-你给我制作一个二级库吧!
    开机的一篇英文是怎么回事呢?
    系统故障之-冲动360
    每天看一遍你潦倒至今的原因
    如何配置给自己配置一台适合自己的台式机
    如何配置给自己配置一台电脑
    单网卡、双网卡如何实现同时上内网和外网
  • 原文地址:https://www.cnblogs.com/juejues/p/13798362.html
Copyright © 2011-2022 走看看