---
# System prepended metadata

title: SDN
tags: [SDN, ' openflow', ' mininet']

---

---
tags: SDN, mininet, openflow
---
SDN
===
[TOC]

SDN
---
### openflow
- QoS
    - http://gienmin.blogspot.com/2013/12/qos_18.html

SDN Controller
---
### Ryu

- 參考自：https://ting-kuan.blog/2017/11/05/%e3%80%90ryu%e4%bb%8b%e7%b4%b9%e8%88%87%e5%ae%89%e8%a3%9d%ef%bc%88%e5%88%a9%e7%94%a8pip%e5%ae%89%e8%a3%9d%ef%bc%89-on-ubuntu-16-04%e3%80%91/

#### Install
```bash=
sudo apt-get install python-pip
sudo apt-get install python-setuptools
pip install ryu
ryu-manager [–verbose] [–observe-links]
# []部分為選用參數
# verbose 顯示更多訊息，有利於debug
# observe-link 顯示鏈結間的訊息
```
#### Install by using Git (Recommand)

```bash=
git clone https://github.com/osrg/ryu.git
cd ryu
sudo pip install -r tools/pip-requires
sudo python setup.py install
```
    
#### Ryu GUI Tool
```bash=
pip show –files ryu      # 尋找ryu的安裝路徑
cd /usr/local/lib/python2.7/dist-packages
ryu-manager --verbose --observe-links ryu/app/gui_topology/gui_topoplogy.py
```

### OpenDayLight
#### Setup 
- JAVA > 1.7

```bash= 
apt-get install openjdk-7-jre
```
- https://docs.opendaylight.org/en/latest/downloads.html
- Install ODL
    unzip odl's document
    ```bash=
    cd opendaylight
    vi configuration/config.ini #enable “ovsdb.of.version=1.3”
    ./run.sh -virt ovsdb -of13
    cd bin
    sudo ./keraf 
    ```
- list package
    
    `feature:list -i`
- ODL package
    - DLUX
        - Function: Yang UI, node andtopology visualization
        - URL: http://localhost:8181/index.html
        
Mininet 
---
- reference: http://mininet.org/download/
### Install

```bash=
git clone git://github.com/mininet/mininet
cd mininet
git tag  # list available versions
git checkout -b 2.2.1 2.2.1  # or whatever version you wish to install
cd util
install.sh -a
# To install everything (using your home directory): install.sh -a
# To install everything (using another directory for build): install.sh -s mydir -a
# To install Mininet + user switch + OVS (using your home dir): install.sh -nfv
# To install Mininet + user switch + OVS (using another dir:)install.sh -s mydir -nfv
```

### Command
- Display Mininet CLI commands
    `mininet> help` 
- Display Nodes, Links, Dump information about all nodes.
    `mininet> nodes/net/dump`
    - `mininet> s1 ifconfig -a`
    - `mininet> h1 ps -a`
#### Test connectivity between hosts
- ping 1 time
`mininet> h1 ping -c 1 h2`
- all pair ping
`mininet> pingall`
#### Run simple server and clinet
```bash= 
mininet> h1 python -m SimpleHTTPServer 80 &
mininet> h2 wget -O - h1
...
mininet> h1 kill %python
```
#### Exit CLI
- `mininet> exit`
#### Clean up
- `sudo mn -c`

### Mininet Tool
### MiniEdit
- Function: 
- Setup:
    
    ```bash=
    cd ./mininet/mininet/examples
    sudo python miniedit.py
    ```
### Mininet Wireshark

```bash=
ssh -Y [mininet_hostname]@[mininet.ip]
sudo wireshark &
```
### iperf 
- Function: Make flow
- Command
    - Server
        
        `iperf -s -u -p 5566 -i 1`
        - -p: port
        - -s: server mode
        - -u: UTP mode(define is TCP)
    - Clinet
        
        `iperf -c 10.0.0.1 -p 5566 -u -b 10G -t 100000`
        - -c: clinet
        - -p: port
        - -u: UTP mode
        - -b: flow size
        - -t: time

### sflow-rt
- Funtion: monitor the flow
- Setup:
    
    ```bash=
    wget https://inmon.com/products/sFlow-RT/sflow-rt.tar.gz
    tar -zxvf sflow-rt.tar.gz
    cd sflow-rt
    ./get-app.sh sflow-rt mininet-dashboard
    sh start.sh
    ```
    - dashboard: http://127.0.0.1:8008

### OpenState SDN -- Visualize Mininet Networks
- 資料參考：
    - https://ting-kuan.blog/2018/04/04/%E3%80%90mininam-%E8%A6%96%E8%A6%BA%E5%8C%96%E7%B6%B2%E8%B7%AF%E6%8B%93%E5%A2%A3%E6%A8%A1%E6%93%AC%E5%99%A8%E3%80%91/
    - http://www.cs.ucc.ie/~ak18/MiniNAM/examples
- 相較mininet, 有封包傳遞動畫
- Install
    - 安裝前確認已安裝SDN controller(ryu, odl...)與mininet
    
    ```bash=
    bash -c "$(wget -O – http://openstate-sdn.org/install.sh)"
    wget http://www.cs.ucc.ie/~ak18/MiniNAM/code/MiniNAM.tar.gz # 封包流向動畫
    # 賦予位於MiniNam目錄底下的「paping」和「MiniNam」檔案執行權限
    sudo chmod +x paping
    sudo chmod +x MiniNAM 
    # 執行SDN Controller 與 MiniNam
    ryu-manager –verbose ryu/app/simple_switch_13.py
    sudo ./MiniNAM –topo single,4 –controller remote
    ```
OVS(OpenvSwitch)
---
- Rerefence
    - [大叔筆記 OVS](https://sites.google.com/a/cnsrl.cycu.edu.tw/da-shu-bi-ji/openvswitch)
    - [OVS in Github](https://github.com/openvswitch/ovs)
    - [Openvswitch手册(1): 架构，SSL, Manager, Bridge](https://www.cnblogs.com/popsuper1982/p/3800574.html)
### install
    ```bash=
    sudo apt-get install git dh-autoreconf libssl-dev openssl
    git clone https://github.com/openvswitch/ovs.git
    cd ovs/
    ./boot.sh
    ./configure --with-linux=/lib/modules/$(uname -r)/build
    sudo make
    sudo make install
    sudo make modules_install