---
# System prepended metadata

title: AN Lab 3 - SDN
tags: [finished]

---

###### tags: `finished`

:::success
# AN Lab 3 - SDN
:::

## Task 1 - Preparation

:::info
a. Select an SDN controller that you would like to try. For example (opendaylight, Ryu, faucet, ONOS, ...).


b. GNS3 might already have a template for these controllers, try to use these templates as it will save you a lot of time and troubleshooting.

c. You can use OpenVSwitch as your virtual switching solution (check ovs-vsctl command).

d. Try to draw a network scheme before you start the lab. This will help you in the deployment phase.
:::

I chose faucet as the SDN controller. It will be installed on ubuntu, in many ways I made this decision because I had problems with docker inside gns3.

<center>
    
![](https://i.imgur.com/TuVvW5m.png)
Figure 1 - My topology
</center>

## Task 2 - Deployment

:::info
a. Try to redo one of the previous labs, but this time with SDN.
:::

Inside ubuntu:

```
sudo apt-get install curl gnupg apt-transport-https lsb-release
echo "deb https://packagecloud.io/faucetsdn/faucet/$(lsb_release -si | awk '{print →tolower($0)}')/ $(lsb_release -sc) main" | sudo tee /etc/apt/sources.list.d/faucet.list
curl -L https://packagecloud.io/faucetsdn/faucet/gpgkey | sudo apt-key add -sudo apt-get update
sudo apt-get update

#install all components 
sudo apt-get install faucet-all-in-one
```

<center>
    
![](https://i.imgur.com/Qd0Uge6.png)
Figure 2 - Ubuntu config
</center>


Configure Open vSwitch 1:

```
sudo ovs-vsctl add-br br0 set bridge br0 other-config:datapath-id=0000000000000001
sudo ovs-vsctl add-br br0 set bridge br0 other-config:disable-in-band=true
sudo ovs-vsctl add-br br0 set bridge br0 fail_mode=secure

#be sure to give two ports, otherwise it does not work
sudo ovs-vsctl set-controller br0 tcp:192.168.122.232:6653 tcp:192.168.122.232:6654

# I prescribed it manually, because the dhcp did not work correctly, and corrections through the external config (through the device settings in gns3) were not accepted
ifconfig eth0 192.168.122.32 255.255.255.0 192.168.122.1

```


<center>
    
![](https://i.imgur.com/Gq80Ein.png)
Figure 3 - Status of OpenSw1
</center>

And the same settings on Open Switch 2, except `datapath-id=0000000000000002` and IP address (I just decided to check if DHCP would work, and on the second switch it worked):

<center>

![](https://i.imgur.com/6NNObV4.png)
Figure 4 - OpenSw2
    
![](https://i.imgur.com/FxIiPg1.png)
Figure 5 - Status of OpenSw2
</center>

Now let's try to implement SDN into the configuration of the previous labs, I chose VLAN. To do this, we need to make the appropriate changes to the faucet config, namely: 

The VLANs themselves are 100 and 200 and, respectively, their subnets, from which we will then select the IP addresses of the hosts. Then you need to make changes to the switch lines, namely, change the name of the device, remove the first interface, which refers to NAT, and we are not using it now, and do not forget about connecting the switches to each other. And we also need to set the priority to switch 1, since this signals the faucet that it has a root network user defined.

I followed the instructions from the official documentation [[2](https://docs.faucet.nz/_/downloads/en/latest/pdf/#section.1.2)]. 

<center>

![](https://i.imgur.com/cQVkUNe.png)
![](https://i.imgur.com/UjQDWSj.png)
![](https://i.imgur.com/WnYHomR.png)
Figure 6 - Faucet Config
</center>


As you can see in the screenshot below, VLANs work, PS3 and PS2 belong to different VLANs, respectively.
<center>
    
![](https://i.imgur.com/cmeyiUN.png)
Figure 7 - Ping result
</center>
    
## Task 3 - Verification

:::info
a. Show your SDN flows that are related to the previous lab that will redo.

b. Try to explain what are the fields in each flow.
:::

Here we can see different types of messages, for example, the PACKET-IN message means that the switch has sent a packet to the controller, OUT means redirecting the packet to the corresponding switch port (in our case, these are ports 6653 and 6654). Echo messages are forwarded by switches between the controller to check the viability of the line. 

Specifically, in the example below, we see that the packet was sent by the controller to the switch port (OFPT_PACKET_OUT and OFF_CONTROLLER). Also here you can see that the buffer identifier (OFF_NO_BUFFER) is missing, or rather that the packet is missing from it. If the packet is not buffered - either because there is no buffer space, or because of an explicit OFPCML_NO_BUFFER request - the entire packet is included in the information part, and the buffer_id corresponds to OFP_NO_BUFFER.

<center>
    
![](https://i.imgur.com/yDM0a8Y.jpg)

![](https://i.imgur.com/5o3Yx0i.png)


Figure 8, 9 - SDN flows
</center>


## References:

1. [Faucet Documentation: Installation on Ubuntu](https://docs.faucet.nz/_/downloads/en/latest/pdf/#subsection.1.3.1)
2. [Faucet Documentation: Inter-VLAN routing with stacking](https://docs.faucet.nz/_/downloads/en/latest/pdf/#section.1.2)
3. [OpenFlow Specification 1.3](https://opennetworking.org/wp-content/uploads/2014/10/openflow-spec-v1.3.0.pdf)


