Prima parte:
Seconda parte:
Avviamo una topologia con 3 switch e 3 host
sudo mn --switch ovs,protocols=OpenFlow13 --mac --arp --topo linear,3 --controller remote

Avviamo il controller
ryu-manager ryu.app.simple_switch_13 ryu.app.ofctl_rest

Vogliamo mirrorare tutto il traffico IP tra h1 e h3 su h2. (ipoteticamente h2 è un nodo che analizza il traffico)
NB: per il traffico IP EtherType è 0x0800 (in intero 2048)
NB: possiamo sempre ispezionare EtherType, IP protocol number, etc.. usando wireshark.
Come possiamo ottenere questo comportamento? Con le REST API!
Abbiamo bisogno di 2 regole per fare il mirroring (una per ogni direzione).
Dove? In s2! → “dpid”: 2.
Soluzione:
#!/bin/bash
curl -d '{
  "dpid": 2,
  "priority": 1000,
  "match": {
    "in_port": 2
  },
  "actions": [
    {
      "type": "OUTPUT",
      "port": 1
    },
    {
      "type": "OUTPUT",
      "port": 3
    }
  ]
}' <http://localhost:8080/stats/flowentry/add>
curl -d '{
  "dpid": 2,
  "priority": 10,
  "match": {
    "in_port": 3
  },
  "actions": [
    {
      "type": "OUTPUT",
      "port": 1
    },
    {
      "type": "OUTPUT",
      "port": 2
    }
  ]
}' <http://localhost:8080/stats/flowentry/add>