# Piattaforme e Software per la rete - lezione 17 #### Giacomo Verticale ###### 31 May 2016 # Esercizio OpenFlow __Switch__ Prio | Match | Action --- | --- | --- 0 | * | out controller 1 | eth_dst=MAC3 | out 3 2 | eth_type=IPv4 ip_dst=IP 3 | out __Packets__ - h1 ping h2 - h1 ping h3 - h2 apre conn TCP verso h3 __Hyp: tabelle ARP giá piene__ - h2 -> s1 MAC2, MAC3, IPv4(0x0800), IP2, IP3, TCP(6) Il pacchetto viene ricevuto dal controllore che controlla sulla tabella, il pacchetto fa match sulla terza riga perché ha prioritá piú alta. - s1 -> h3 ... - h3 -> s1 MAC3, MAC2, IPv4, IP3, IP2, TCP, 80, 123, SYN ACK - s1 -> C packet_in (...) / c -> s1 packet_out (...), action out flood. - s1 -> h1, h2... # Esercizio 2 OpenFlow __Topologia__ h2,h1 - s1 - s2 - h3,h4 __Event OFP Switch Features__ ``` match su * actions = [output su controller] priority = 0 FLOW MOD(datapath, priority, match, ...) ``` Datapath é sinonimo di switch, anche se uno switch puó contenere piú datapath e agire come piú switch in uno solo. Questo é un table miss perché fa match su ogni cosa e ha prioritá 0 ``` match su eth_dst="FF:FF:....:FF" actions = [output su flood] FLOW MOD(datapath, priority=1, ...) ``` __Event OFP Packet In__ Questa funzione serve a recuperare i metadati come la porta in ingresso. Se il match non venisse trovato, alla variabile viene assegnato `none` ``` in_port = msg.match ['in_port'] pkt = packet.Packet(data = msg data) if len(pkt.protocols)>=2 and is instance (pkt.protocols[1], IPv4): if datapath.id == 1 and pkt_ipv4.dst == '10.0.0.3': match = OFPMatch(eth_src = eth.src, eth_dst=eth.dst, eth_type = IPv4, ip_dst = '10.0.0.3') actions = [ OFPAction.SetField(ip_dst='10.0.0.2'), OFPAction Output(2) ] FLOWMOD(match, priority=1, ...) else packet_out(FLOOD) ``` La porta in ingresso serve per effettuare il flooding di un pacchetto proveniente dal controllore, senza rimandarlo nella porta di ingresso. - da h1 ad h3 pacchetto UDP 53 - da h3 ad h2 apertura di connessione TCP/80 __Tabella s1__ 0 | * | controller --- | --- | --- 1 | eth_dst=FF:FF...:FF | output FLOOD __Tabella s2__ 0 | * | controller --- | --- | --- 1 | eth_dst=FF:FF...:FF | output FLOOD ARP prepopolata - h1 -> s1: MAC1, MAC3, IPv4, IP1, IP3, UDP, 1234, 53 - s1 -> C: packet_in(...) - C -> s1:flow_mod (match(eth_src=MAC1, eth_dst=MAC3, eth_type=IPv4, ip_dst='10.0.0.3'), priority=1, actions (set_field(ip.dst='10.0.0.2'), output(2)))