<commit_before># Test Setup - MultiSwitch

## Mininext
```bash
$ cd ~/sdx-ryu/examples/test-ms/mininext
$ sudo ./sdx_mininext.py
```

## Run RefMon

```bash
$ ryu-manager ~/sdx-ryu/flanc/refmon.py --refmon-config ~/sdx-ryu/examples/test-ms/config/sdx_global.cfg
```

## Run xctrl

```bash
$ cd ~/sdx-ryu/xctrl/
$ ./xctrl.py ~/sdx-ryu/examples/test-ms/config/sdx_global.cfg
```

## Run arpproxy

```bash
$ cd ~/sdx-ryu/arproxy/
$ sudo python arproxy.py test-ms
```

## Run xrs

```bash
$ cd ~/sdx-ryu/xrs/
$ sudo python route_server.py test-ms
```

## Run pctrl

```bash
$ cd ~/sdx-ryu/pctrl/
$ sudo python participant_controller.py test-ms 1
$ sudo python participant_controller.py test-ms 2
$ sudo python participant_controller.py test-ms 3
```

## Run ExaBGP

```bash
exabgp ~/sdx-ryu/examples/test-ms/config/bgp.conf
```

## Run iperf to test the policies

### Test 1

Outbound policy of a1: match(tcp_port=80) >> fwd(b1)

```bash
mininext> b1 iperf -s -B 192.168.3.11 -p 80 &  
mininext> a1 iperf -c 192.168.3.11 -B 172.16.17.32 -p 80 -t 2
```

### Test 2

Outbound policy of a1: match(tcp_port=4321) >> fwd(c)
and Inbound policy of c: match(tcp_port=4321) >> fwd(c1)

```bash
mininext> c1 iperf -s -B 192.168.3.11 -p 4321 &
mininext> a1 iperf -c 192.168.3.11 -B 172.16.17.32 -p 4321 -t 2  
```

### Test 3 

Outbound policy of a1: match(tcp_port=4322) >> fwd(c)
and Inbound policy of c: match(tcp_port=4322) >> fwd(c2)

```bash
mininext> c2 iperf -s -B 192.168.3.11 -p 4322 &  
mininext> a1 iperf -c 192.168.3.11 -B 172.16.17.32 -p 4322 -t 2  
```

### Note

Always check with ```route``` whether ```a1``` sees ```172.16.17.32/24``` and ```192.168.127.12/24```, ```b1```/```c1```/```c2``` see ```192.168.127.12/24``` and ```192.168.127.12/24```

## Different Setup (not yet tested)

### Mininet with SDNIP

```bash
$ cd ~/sdx-ryu/examples/test-ms/mininet/
$ sudo ./simple_sdx.py
```<commit_msg>Added the instructions to use the scripts to launch pctrl and cleanup<commit_after># Test Setup - MultiSwitch

## Mininext
```bash
$ cd ~/sdx-ryu/examples/test-ms/mininext
$ sudo ./sdx_mininext.py
```

## Run RefMon

```bash
$ ryu-manager ~/sdx-ryu/flanc/refmon.py --refmon-config ~/sdx-ryu/examples/test-ms/config/sdx_global.cfg
```

## Run xctrl

```bash
$ cd ~/sdx-ryu/xctrl/
$ ./xctrl.py ~/sdx-ryu/examples/test-ms/config/sdx_global.cfg
```

## Run arpproxy

```bash
$ cd ~/sdx-ryu/arproxy/
$ sudo python arproxy.py test-ms
```

## Run xrs

```bash
$ cd ~/sdx-ryu/xrs/
$ sudo python route_server.py test-ms
```

## Run pctrl

```bash
$ cd ~/sdx-ryu/pctrl/
$ sh run_pctrlr.sh
```

## Run ExaBGP

```bash
exabgp ~/sdx-ryu/examples/test-ms/config/bgp.conf
```

## Run iperf to test the policies

### Test 1

Outbound policy of a1: match(tcp_port=80) >> fwd(b1)

```bash
mininext> b1 iperf -s -B 192.168.3.11 -p 80 &  
mininext> a1 iperf -c 192.168.3.11 -B 172.16.17.32 -p 80 -t 2
```

### Test 2

Outbound policy of a1: match(tcp_port=4321) >> fwd(c)
and Inbound policy of c: match(tcp_port=4321) >> fwd(c1)

```bash
mininext> c1 iperf -s -B 192.168.3.11 -p 4321 &
mininext> a1 iperf -c 192.168.3.11 -B 172.16.17.32 -p 4321 -t 2  
```

### Test 3 

Outbound policy of a1: match(tcp_port=4322) >> fwd(c)
and Inbound policy of c: match(tcp_port=4322) >> fwd(c2)

```bash
mininext> c2 iperf -s -B 192.168.3.11 -p 4322 &  
mininext> a1 iperf -c 192.168.3.11 -B 172.16.17.32 -p 4322 -t 2  
```

### Cleanup
In the `pctrl` directory, run the `clean` script. 
```bash
$ cd ~/sdx-ryu/pctrl/
$ sh clean.sh
```

### Note

Always check with ```route``` whether ```a1``` sees ```172.16.17.32/24``` and ```192.168.127.12/24```, ```b1```/```c1```/```c2``` see ```192.168.127.12/24``` and ```192.168.127.12/24```

## Different Setup (not yet tested)

### Mininet with SDNIP

```bash
$ cd ~/sdx-ryu/examples/test-ms/mininet/
$ sudo ./simple_sdx.py
```
{'fraction_non_alphanumeric': 0.2033898305084746, 'fraction_numerical': 0.10039113428943937, 'mean_word_length': 3.339366515837104, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 35, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 26, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1750368', 'n_tokens_mistral': 2036, 'n_tokens_neox': 1702, 'n_words': 412}