commit 98f7d612d5f05f77951deae4a9afd9f8107b7be9 Author: Yi-Ting Shih Date: Mon Sep 15 23:58:18 2025 +0800 Init: lab2 done diff --git a/docs/main.pdf b/docs/main.pdf new file mode 100644 index 0000000..77d7a93 Binary files /dev/null and b/docs/main.pdf differ diff --git a/docs/main.typ b/docs/main.typ new file mode 100644 index 0000000..c770b5f --- /dev/null +++ b/docs/main.typ @@ -0,0 +1,58 @@ +#import "template/module.typ": * + +#show: default.with( + title: "SDN - Lab 2", + authors: (( + name: "Yi-Ting Shih (111550013)", + affiliation: "National Yang Ming Chaio Tung University", + email: "ytshih@cs.nycu.edu.tw", + ),), +) + += Part 1: Answer Questions + +1. How many distinct OpenFlow headers with type "OFPT_FLOW_MOD" and command "OFPFC_ADD" are there among all the packets? + +There are 6 distinct OpenFlow headers. + +2. Following question 1, what are the match fields, and what are the corresponding actions? + +#table(columns: 3, + [Match fields], [actions], [Timeout values], + [ETH_TYPE=LLDP], [output port=controller], [0], + [ETH_TYPE=ARP], [output port=controller], [0], + [ETH_TYPE=BDDP], [output port=controller], [0], + [ETH_TYPE=IPv4], [output port=controller], [0], + [IN_PORT=1, ETH_DST=0a:01:ca:16:e6:f2, ETH_SRC=16:e8:32:bf:62:44], [output port=2], [0], + [IN_PORT=2, ETH_DST=16:e8:32:bf:62:44, ETH_SRC=0a:01:ca:16:e6:f2], [output port=1], [0], +) + +3. What are the Idle Timeout values for all flow rules on s1 in the GUI? + +10 + += Part 2: Install Flow Rules + +> arping +#image("part2-1.png", width: 350pt) + +> ping +#image("part2-2.png", width: 350pt) + += Part 3: Trace ReactiveForwarding + +[C] - Control Plane +[D] - Data Plane + +- [D] h1 send ARP request with broadcast. +- [C] s1 sends the ARP request with packet-in to ONOS controller. +- [C] Controller choose to flood the ARP request and send packet-out. +- [D] s1 floods the ARP request. +- [D] h2 replies h1 with ARP reply. +- [C] s1 sends the ARP request with packet-in to ONOS controller. +- [C] Controller choose to send the ARP reply to h1 and send packet-out. +- [D] s1 sends the ARP reply to h1. +- [D] h1 sends ICMP echo request to h2. +- [C] s1 sends ICMP echo request with packet-in to ONOS controller. +- [C] Controller install rules for ICMP traffic. +- [D] s1 forwards the ICMP packet to h2. diff --git a/docs/part2-1.png b/docs/part2-1.png new file mode 100644 index 0000000..77d357c Binary files /dev/null and b/docs/part2-1.png differ diff --git a/docs/part2-2.png b/docs/part2-2.png new file mode 100644 index 0000000..7d2cf61 Binary files /dev/null and b/docs/part2-2.png differ diff --git a/docs/template/functions/code.typ b/docs/template/functions/code.typ new file mode 100644 index 0000000..3e23800 --- /dev/null +++ b/docs/template/functions/code.typ @@ -0,0 +1 @@ +#let code = raw.with(block: true) diff --git a/docs/template/module.typ b/docs/template/module.typ new file mode 100644 index 0000000..38011a3 --- /dev/null +++ b/docs/template/module.typ @@ -0,0 +1,79 @@ +#import "functions/code.typ": code + +#let default( + title: "This is a title", + authors: (( + name: "Yi-Ting Shih", + affiliation: "National Yang Ming Chiao Tung University", + email: "ytshih@it.cs.nycu.edu.tw", + ),), + content, +) = { + // Content default + set page( + paper: "a4", + margin: (x: 1.8cm, y: 1.5cm), + header: align(right, title), + numbering: "1", + ) + set text( + font: "Libertinus serif", + size: 10pt, + ) + set par( + leading: 0.6em, + ) + + // Heading default + show heading: set text( + font: "Noto sans", + ) + + // Section title default + show heading.where(level: 1): set heading( + numbering: "1." + ) + + // Raw default + show raw: set text( + font: "Consolas", + size: 8pt, + ) + // Code section default + show raw.where(block: true): self => { + block( + fill: luma(240), + inset: 8pt, + radius: 2pt, + self + ) + } + + { // Title + set align(center) + set text( + size: 20pt, + weight: "bold", + ) + pad(y: 10pt, title) + } + + { // author + set align(center) + set text( + size: 10pt, + ) + let count = authors.len() + let ncols = calc.min(count, 3) + grid( + columns: (1fr,) * ncols, + row-gutter: 24pt, + ..authors.map(author => [ + #author.name \ + #author.affiliation \ + #link("mailto:" + author.email) + ]), + ) + } + content +} diff --git a/project2_111550013/part2/flows_s1-1_111550013.json b/project2_111550013/part2/flows_s1-1_111550013.json new file mode 100644 index 0000000..0c0c4eb --- /dev/null +++ b/project2_111550013/part2/flows_s1-1_111550013.json @@ -0,0 +1,22 @@ +{ + "priority": 40001, + "timeout": 0, + "isPermanent": true, + "deviceId": "of:0000000000000001", + "treatment": { + "instructions": [ + { + "type": "OUTPUT", + "port": "ALL" + } + ] + }, + "selector": { + "criteria": [ + { + "type": "ETH_TYPE", + "ethType": "0x0806" + } + ] + } +} diff --git a/project2_111550013/part2/flows_s1-2_111550013.json b/project2_111550013/part2/flows_s1-2_111550013.json new file mode 100644 index 0000000..a9134aa --- /dev/null +++ b/project2_111550013/part2/flows_s1-2_111550013.json @@ -0,0 +1,26 @@ +{ + "priority": 40001, + "timeout": 0, + "isPermanent": true, + "deviceId": "of:0000000000000001", + "treatment": { + "instructions": [ + { + "type": "OUTPUT", + "port": "1" + } + ] + }, + "selector": { + "criteria": [ + { + "type": "ETH_TYPE", + "ethType": "0x0800" + }, + { + "type": "IPV4_DST", + "ip": "10.0.0.1/32" + } + ] + } +} diff --git a/project2_111550013/part2/flows_s1-3_111550013.json b/project2_111550013/part2/flows_s1-3_111550013.json new file mode 100644 index 0000000..39461b1 --- /dev/null +++ b/project2_111550013/part2/flows_s1-3_111550013.json @@ -0,0 +1,26 @@ +{ + "priority": 40001, + "timeout": 0, + "isPermanent": true, + "deviceId": "of:0000000000000001", + "treatment": { + "instructions": [ + { + "type": "OUTPUT", + "port": "2" + } + ] + }, + "selector": { + "criteria": [ + { + "type": "ETH_TYPE", + "ethType": "0x0800" + }, + { + "type": "IPV4_DST", + "ip": "10.0.0.2/32" + } + ] + } +} diff --git a/project2_111550013/project2_111550013.pdf b/project2_111550013/project2_111550013.pdf new file mode 100644 index 0000000..77d7a93 Binary files /dev/null and b/project2_111550013/project2_111550013.pdf differ diff --git a/project2_111550013/project2_111550013.zip b/project2_111550013/project2_111550013.zip new file mode 100644 index 0000000..d878cd5 Binary files /dev/null and b/project2_111550013/project2_111550013.zip differ diff --git a/run.sh b/run.sh new file mode 100755 index 0000000..1a947e7 --- /dev/null +++ b/run.sh @@ -0,0 +1,14 @@ +#!/usr/bin/env -S bash + +files=( + 'project2_111550013/part2/flows_s1-1_111550013.json' + 'project2_111550013/part2/flows_s1-2_111550013.json' + 'project2_111550013/part2/flows_s1-3_111550013.json' +) + +for file in "${files[@]}"; do + curl -u onos:rocks -X POST \ + -H 'Content-Type: application/json' \ + --json "@$file" \ + 'http://localhost:8181/onos/v1/flows/of:0000000000000001' +done