OpenDaylight-Boron学习笔记: 3 L2Switch模块

SDN 专栏收录该内容
6 篇文章 0 订阅

环境及软件版本说明

===

SN-Controller:

CPU: 2 Cores

RAM: 4GB

Disk: 32GB

Operating System: CentOS7 x86_64 1611(Linux 3.10.0-514) Infrastructure Server

IP1: 10.0.3.100/24 (Public Network)

IP2: 172.16.3.100/24 (SDN Network)

===

OpenDaylight: Boron

下载地址

参考文献

L2 Switch User Guide

《OpenDaylight应用指南》(唐宏 等编著)

L2 Switch架构

L2 Switch项目包含以下几个部分:

  • Packet Handler (包处理) :对发往控制器的数据包进行解析并将数据包正确地转发
  • Loop Remover (环路消除) :消除网络链路中的环路
  • Arp Handler (ARP处理) :解析并处理ARP数据包
  • Address Tracker (地址跟踪) :学习网络中的MAC或IP
  • Host Tracker (主机跟踪) :跟踪网络中的主机位置
  • L2 Switch Main (二层交换主要部件) :根据网络流量对每一个交换机下发流表

安装L2Switch模块

进入karaf控制台,进行以下的指令安装:

opendaylight-user@root>feature:install odl-l2switch-all

odl-l2switch-all包含以下几个模块:

  • odl-l2switch-switch
  • odl-l2switch-switch-rest
  • odl-l2switch-switch-ui
  • odl-l2switch-hosttracker
  • odl-l2switch-addresstracker
  • odl-l2switch-arphandler
  • odl-l2switch-loopremover
  • odl-l2switch-packethandler

功能体验

使用Mininet创建拓扑

Mininet虚拟机参数:

  • HostName:mininet-vm1
  • CPU: 2核
  • RAM: 4GB
  • IP1:10.0.3.101(Public Network)
  • IP2: 172.16.3.101(SDN Network)

在mininet-vm1中创建包含3个交换机,每台交换机各连1台主机的拓扑,并产生网络流量(Ping):

mininet@mininet-vm1:~$ sudo mn --controller=remote,ip=10.0.3.100 --mac --topo=linear,3 --switch ovsk,protocols=OpenFlow13
mininet> pingall

此时在ODL的控制页面中的Topology标签中可以看到网络拓扑。

地址学习检测

在本地使用Rest调试工具(如Opera的RestMan)往ODL控制器发送以下Rest请求,按提示输入用户名(admin)和密码(admin)后,可以查看第一个交换机第一个端口所学习到的MAC和IP地址。

http://10.0.3.100:8181/restconf/operational/opendaylight-inventory:nodes/node/openflow:1/node-connector/openflow:1:1

可以看到响应部分的内容:

{
    "node-connector": [
        {
            "id": "openflow:1:1",
            "flow-node-inventory:state": {
                "link-down": false,
                "live": false,
                "blocked": false
            },
            "flow-node-inventory:name": "s1-eth1",
            "flow-node-inventory:maximum-speed": 0,
            "flow-node-inventory:configuration": "",
            "flow-node-inventory:supported": "",
            "flow-node-inventory:peer-features": "",
            "flow-node-inventory:port-number": "1",
            "flow-node-inventory:advertised-features": "",
            "flow-node-inventory:current-feature": "ten-gb-fd copper",
            "flow-node-inventory:hardware-address": "12:ea:18:e9:ee:28",
            "flow-node-inventory:current-speed": 10000000,
            "opendaylight-port-statistics:flow-capable-node-connector-statistics": {
                "transmit-drops": 0,
                "receive-frame-error": 0,
                "receive-drops": 0,
                "receive-crc-error": 0,
                "bytes": {
                    "transmitted": 10725,
                    "received": 560
                },
                "duration": {
                    "nanosecond": 462000000,
                    "second": 560
                },
                "receive-errors": 0,
                "transmit-errors": 0,
                "receive-over-run-error": 0,
                "collision-count": 0,
                "packets": {
                    "transmitted": 129,
                    "received": 8
                }
            },
            "address-tracker:addresses": [
                {
                    "id": 0,
                    "first-seen": 1494576603869,
                    "mac": "00:00:00:00:00:01",
                    "last-seen": 1494576603869,
                    "ip": "10.0.0.1"
                }
            ]
        }
    ]
}

主机检测

往ODL控制器发送下面的Rest请求,可以查看到全网络链路的所有主机(包括交换机与普通主机)以及之间的链接情况。

http://10.0.3.100:8181/restconf/operational/network-topology:network-topology/topology/flow:1/

得到的响应内容如下:

{
    "topology": [
        {
            "topology-id": "flow:1",
            "node": [
                {
                    "node-id": "host:00:00:00:00:00:03",
                    "termination-point": [
                        {
                            "tp-id": "host:00:00:00:00:00:03"
                        }
                    ],
                    "host-tracker-service:attachment-points": [
                        {
                            "tp-id": "openflow:3:1",
                            "corresponding-tp": "host:00:00:00:00:00:03",
                            "active": true
                        }
                    ],
                    "host-tracker-service:id": "00:00:00:00:00:03",
                    "host-tracker-service:addresses": [
                        {
                            "id": 0,
                            "mac": "00:00:00:00:00:03",
                            "first-seen": 1494578133413,
                            "last-seen": 1494578133413,
                            "ip": "10.0.0.3"
                        }
                    ]
                },
                {
                    "node-id": "openflow:2",
                    "termination-point": [
                        {
                            "tp-id": "openflow:2:1",
                            "opendaylight-topology-inventory:inventory-node-connector-ref": "/opendaylight-inventory:nodes/opendaylight-inventory:node[opendaylight-inventory:id='openflow:2']/opendaylight-inventory:node-connector[opendaylight-inventory:id='openflow:2:1']"
                        },
                        {
                            "tp-id": "openflow:2:2",
                            "opendaylight-topology-inventory:inventory-node-connector-ref": "/opendaylight-inventory:nodes/opendaylight-inventory:node[opendaylight-inventory:id='openflow:2']/opendaylight-inventory:node-connector[opendaylight-inventory:id='openflow:2:2']"
                        },
                        {
                            "tp-id": "openflow:2:3",
                            "opendaylight-topology-inventory:inventory-node-connector-ref": "/opendaylight-inventory:nodes/opendaylight-inventory:node[opendaylight-inventory:id='openflow:2']/opendaylight-inventory:node-connector[opendaylight-inventory:id='openflow:2:3']"
                        },
                        {
                            "tp-id": "openflow:2:LOCAL",
                            "opendaylight-topology-inventory:inventory-node-connector-ref": "/opendaylight-inventory:nodes/opendaylight-inventory:node[opendaylight-inventory:id='openflow:2']/opendaylight-inventory:node-connector[opendaylight-inventory:id='openflow:2:LOCAL']"
                        }
                    ],
                    "opendaylight-topology-inventory:inventory-node-ref": "/opendaylight-inventory:nodes/opendaylight-inventory:node[opendaylight-inventory:id='openflow:2']"
                },
                {
                    "node-id": "host:00:00:00:00:00:01",
                    "termination-point": [
                        {
                            "tp-id": "host:00:00:00:00:00:01"
                        }
                    ],
                    "host-tracker-service:attachment-points": [
                        {
                            "tp-id": "openflow:1:1",
                            "corresponding-tp": "host:00:00:00:00:00:01",
                            "active": true
                        }
                    ],
                    "host-tracker-service:id": "00:00:00:00:00:01",
                    "host-tracker-service:addresses": [
                        {
                            "id": 1,
                            "mac": "00:00:00:00:00:01",
                            "first-seen": 1494578133519,
                            "last-seen": 1494578133519,
                            "ip": "10.0.0.1"
                        }
                    ]
                },
                {
                    "node-id": "openflow:1",
                    "termination-point": [
                        {
                            "tp-id": "openflow:1:1",
                            "opendaylight-topology-inventory:inventory-node-connector-ref": "/opendaylight-inventory:nodes/opendaylight-inventory:node[opendaylight-inventory:id='openflow:1']/opendaylight-inventory:node-connector[opendaylight-inventory:id='openflow:1:1']"
                        },
                        {
                            "tp-id": "openflow:1:2",
                            "opendaylight-topology-inventory:inventory-node-connector-ref": "/opendaylight-inventory:nodes/opendaylight-inventory:node[opendaylight-inventory:id='openflow:1']/opendaylight-inventory:node-connector[opendaylight-inventory:id='openflow:1:2']"
                        },
                        {
                            "tp-id": "openflow:1:LOCAL",
                            "opendaylight-topology-inventory:inventory-node-connector-ref": "/opendaylight-inventory:nodes/opendaylight-inventory:node[opendaylight-inventory:id='openflow:1']/opendaylight-inventory:node-connector[opendaylight-inventory:id='openflow:1:LOCAL']"
                        }
                    ],
                    "opendaylight-topology-inventory:inventory-node-ref": "/opendaylight-inventory:nodes/opendaylight-inventory:node[opendaylight-inventory:id='openflow:1']"
                },
                {
                    "node-id": "host:00:00:00:00:00:02",
                    "termination-point": [
                        {
                            "tp-id": "host:00:00:00:00:00:02"
                        }
                    ],
                    "host-tracker-service:attachment-points": [
                        {
                            "tp-id": "openflow:2:1",
                            "corresponding-tp": "host:00:00:00:00:00:02",
                            "active": true
                        }
                    ],
                    "host-tracker-service:id": "00:00:00:00:00:02",
                    "host-tracker-service:addresses": [
                        {
                            "id": 2,
                            "mac": "00:00:00:00:00:02",
                            "first-seen": 1494578133523,
                            "last-seen": 1494578133523,
                            "ip": "10.0.0.2"
                        }
                    ]
                },
                {
                    "node-id": "openflow:3",
                    "termination-point": [
                        {
                            "tp-id": "openflow:3:LOCAL",
                            "opendaylight-topology-inventory:inventory-node-connector-ref": "/opendaylight-inventory:nodes/opendaylight-inventory:node[opendaylight-inventory:id='openflow:3']/opendaylight-inventory:node-connector[opendaylight-inventory:id='openflow:3:LOCAL']"
                        },
                        {
                            "tp-id": "openflow:3:1",
                            "opendaylight-topology-inventory:inventory-node-connector-ref": "/opendaylight-inventory:nodes/opendaylight-inventory:node[opendaylight-inventory:id='openflow:3']/opendaylight-inventory:node-connector[opendaylight-inventory:id='openflow:3:1']"
                        },
                        {
                            "tp-id": "openflow:3:2",
                            "opendaylight-topology-inventory:inventory-node-connector-ref": "/opendaylight-inventory:nodes/opendaylight-inventory:node[opendaylight-inventory:id='openflow:3']/opendaylight-inventory:node-connector[opendaylight-inventory:id='openflow:3:2']"
                        }
                    ],
                    "opendaylight-topology-inventory:inventory-node-ref": "/opendaylight-inventory:nodes/opendaylight-inventory:node[opendaylight-inventory:id='openflow:3']"
                }
            ],
            "link": [
                {
                    "link-id": "host:00:00:00:00:00:03/openflow:3:1",
                    "source": {
                        "source-node": "host:00:00:00:00:00:03",
                        "source-tp": "host:00:00:00:00:00:03"
                    },
                    "destination": {
                        "dest-tp": "openflow:3:1",
                        "dest-node": "openflow:3"
                    }
                },
                {
                    "link-id": "openflow:3:1/host:00:00:00:00:00:03",
                    "source": {
                        "source-node": "openflow:3",
                        "source-tp": "openflow:3:1"
                    },
                    "destination": {
                        "dest-tp": "host:00:00:00:00:00:03",
                        "dest-node": "host:00:00:00:00:00:03"
                    }
                },
                {
                    "link-id": "host:00:00:00:00:00:02/openflow:2:1",
                    "source": {
                        "source-node": "host:00:00:00:00:00:02",
                        "source-tp": "host:00:00:00:00:00:02"
                    },
                    "destination": {
                        "dest-tp": "openflow:2:1",
                        "dest-node": "openflow:2"
                    }
                },
                {
                    "link-id": "openflow:1:2",
                    "source": {
                        "source-node": "openflow:1",
                        "source-tp": "openflow:1:2"
                    },
                    "destination": {
                        "dest-tp": "openflow:2:2",
                        "dest-node": "openflow:2"
                    }
                },
                {
                    "link-id": "host:00:00:00:00:00:01/openflow:1:1",
                    "source": {
                        "source-node": "host:00:00:00:00:00:01",
                        "source-tp": "host:00:00:00:00:00:01"
                    },
                    "destination": {
                        "dest-tp": "openflow:1:1",
                        "dest-node": "openflow:1"
                    }
                },
                {
                    "link-id": "openflow:2:2",
                    "source": {
                        "source-node": "openflow:2",
                        "source-tp": "openflow:2:2"
                    },
                    "destination": {
                        "dest-tp": "openflow:1:2",
                        "dest-node": "openflow:1"
                    }
                },
                {
                    "link-id": "openflow:2:3",
                    "source": {
                        "source-node": "openflow:2",
                        "source-tp": "openflow:2:3"
                    },
                    "destination": {
                        "dest-tp": "openflow:3:2",
                        "dest-node": "openflow:3"
                    }
                },
                {
                    "link-id": "openflow:3:2",
                    "source": {
                        "source-node": "openflow:3",
                        "source-tp": "openflow:3:2"
                    },
                    "destination": {
                        "dest-tp": "openflow:2:3",
                        "dest-node": "openflow:2"
                    }
                },
                {
                    "link-id": "openflow:1:1/host:00:00:00:00:00:01",
                    "source": {
                        "source-node": "openflow:1",
                        "source-tp": "openflow:1:1"
                    },
                    "destination": {
                        "dest-tp": "host:00:00:00:00:00:01",
                        "dest-node": "host:00:00:00:00:00:01"
                    }
                },
                {
                    "link-id": "openflow:2:1/host:00:00:00:00:00:02",
                    "source": {
                        "source-node": "openflow:2",
                        "source-tp": "openflow:2:1"
                    },
                    "destination": {
                        "dest-tp": "host:00:00:00:00:00:02",
                        "dest-node": "host:00:00:00:00:00:02"
                    }
                }
            ]
        }
    ]
}
  • 0
    点赞
  • 0
    评论
  • 4
    收藏
  • 一键三连
    一键三连
  • 扫一扫,分享海报

©️2021 CSDN 皮肤主题: 编程工作室 设计师:CSDN官方博客 返回首页
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、C币套餐、付费专栏及课程。

余额充值