---
# System prepended metadata

title: 賴孟昇 碩論 技術文件
tags: [RYU, Mininet]

---

賴孟昇 碩論 技術文件
===
###### tags: `RYU` `Mininet`

## RYU Controller
- [資訊人筆記:SDN](https://wiki.kshuang.xyz/doku.php/ccis_lab:sdn)
- [SDN Hub](http://sdnhub.org/)
    - It provides a VM with all controller installed.
- [RYU Examples: osrg/ryu](https://github.com/osrg/ryu)
- [RYU Examples: Ehsan70](https://github.com/Ehsan70/RyuApps)
- [STP in RYU](https://github.com/Ehsan70/RyuApps/blob/master/ControllerSTP.py)

### Mansion Controller
- Serveral different versions of controller there
```shell=
~/ryu/master
~/ryu/Examples
```
## Mininet
- Dump flow table
```shell=
sh ovs-ofctl dump-flows s1
```

- Show GUI
```shell=
xterm h1 h2
```

- Link Up/Down
```shell=
link s1 h1 down
link s1 h1 up
```

- Example commands for creating a network topo
```shell=
sudo mn --controller remote,ip=10.10.84.10 --switch ovs,protocol=OpenFlow13 --topo linear,4
sudo mn --link tc,bw=1000 --custom ./Experiment.py --controller remote,ip=10.10.84.10 --switch ovs,protocol=OpenFlow13 --topo mytopo
```


## LLDP
- [LLDP Generator](https://sourceforge.net/p/lldpgenerator/code/ci/master/tree/)
``` shell=
git clone https://git.code.sf.net/p/lldpgenerator/code lldpgenerator-code
h2 sudo ./tool.py -p lldp -i h2-eth0 -tlv chid -local 1 -tlv port-id -local 3
sudo ./LLDP_injection.sh <NIC> <DPID> <PortID>
```

- Replay
    1. TCPDump
    ```shell=
    tcpdump -w xxx.pcap
    ```
    2. TCPReplay
    ```shell=
    tcpreplay -i h3-eth0 --loop 10 xxx.pcap
    ```
    3. Linux editcap 以封包數分割檔案 (1000個唯一組)
    ```shell=
    editcap -c 1000 test.pcapng out.pcapng
    ```

- Injection 攻擊
    ```shell=
    cd ~/lldp/
    sudo ./LLDP_injection.sh <NIC> <DPID> <PortID>
    ```
- Replay 攻擊
    1. 攻擊者1
    ```shell=
    cd ~/lldp/auto_mirror/
    python auto_server.py
    # My IP: "輸入攻擊者1的IP"
    # Interface: "輸入攻擊者1連上網的NIC"
    ```
    2. 攻擊者2
    ```shell=
    cd ~/lldp/auto_mirror/
    python auto_client.py
    # My IP: "輸入攻擊者1的IP"
    # Interface: "輸入攻擊者2連上網的NIC"
    ```
- Flooding 攻擊
    ```shell=
    cd ~/lldp/
    python flood.py
    # Interface: "輸入攻擊者連上網的NIC"
    ```
