From 82bde33ec7c101e11455a3a980aaf96715868f8e Mon Sep 17 00:00:00 2001 From: Antonin Bas Date: Wed, 30 Sep 2015 12:35:20 -0700 Subject: [PATCH] adde source_routing exercise --- SIGCOMM_2015/.gitignore | 13 ++ SIGCOMM_2015/env.sh | 8 ++ SIGCOMM_2015/source_routing/cleanup | 2 + SIGCOMM_2015/source_routing/commands.txt | 0 .../source_routing/p4src/source_routing.p4 | 28 ++++ SIGCOMM_2015/source_routing/receive.py | 42 ++++++ SIGCOMM_2015/source_routing/run_demo.sh | 31 +++++ SIGCOMM_2015/source_routing/send.py | 106 ++++++++++++++ SIGCOMM_2015/source_routing/solution.tar.gz | Bin 0 -> 977 bytes SIGCOMM_2015/source_routing/topo.py | 129 ++++++++++++++++++ SIGCOMM_2015/source_routing/topo.txt | 8 ++ 11 files changed, 367 insertions(+) create mode 100644 SIGCOMM_2015/.gitignore create mode 100644 SIGCOMM_2015/env.sh create mode 100755 SIGCOMM_2015/source_routing/cleanup create mode 100644 SIGCOMM_2015/source_routing/commands.txt create mode 100644 SIGCOMM_2015/source_routing/p4src/source_routing.p4 create mode 100755 SIGCOMM_2015/source_routing/receive.py create mode 100755 SIGCOMM_2015/source_routing/run_demo.sh create mode 100755 SIGCOMM_2015/source_routing/send.py create mode 100644 SIGCOMM_2015/source_routing/solution.tar.gz create mode 100644 SIGCOMM_2015/source_routing/topo.py create mode 100644 SIGCOMM_2015/source_routing/topo.txt diff --git a/SIGCOMM_2015/.gitignore b/SIGCOMM_2015/.gitignore new file mode 100644 index 0000000..b4889e1 --- /dev/null +++ b/SIGCOMM_2015/.gitignore @@ -0,0 +1,13 @@ +# Python byte code +*.pyc + +# Emacs +*~ + +# Compiled JSON +*.json + +*.pcap + +# Extracted solutions +solution/ \ No newline at end of file diff --git a/SIGCOMM_2015/env.sh b/SIGCOMM_2015/env.sh new file mode 100644 index 0000000..cc958e4 --- /dev/null +++ b/SIGCOMM_2015/env.sh @@ -0,0 +1,8 @@ +THIS_DIR=$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd ) + +# ---------------- EDIT THIS ------------------ +BMV2_PATH=$THIS_DIR/../../bmv2 +# e.g. BMV2_PATH=$THIS_DIR/../bmv2 +P4C_BM_PATH=$THIS_DIR/../../p4c-bm +# e.g P4C_BM_PATH=$THIS_DIR/../p4c-bm +# ---------------- END ------------------ diff --git a/SIGCOMM_2015/source_routing/cleanup b/SIGCOMM_2015/source_routing/cleanup new file mode 100755 index 0000000..4035587 --- /dev/null +++ b/SIGCOMM_2015/source_routing/cleanup @@ -0,0 +1,2 @@ +sudo killall simple_switch +redis-cli FLUSHDB \ No newline at end of file diff --git a/SIGCOMM_2015/source_routing/commands.txt b/SIGCOMM_2015/source_routing/commands.txt new file mode 100644 index 0000000..e69de29 diff --git a/SIGCOMM_2015/source_routing/p4src/source_routing.p4 b/SIGCOMM_2015/source_routing/p4src/source_routing.p4 new file mode 100644 index 0000000..04fcd9e --- /dev/null +++ b/SIGCOMM_2015/source_routing/p4src/source_routing.p4 @@ -0,0 +1,28 @@ +/* +Copyright 2013-present Barefoot Networks, Inc. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +parser start { + // TODO + return ingress; +} + +control ingress { + // TODO +} + +control egress { + // leave empty +} diff --git a/SIGCOMM_2015/source_routing/receive.py b/SIGCOMM_2015/source_routing/receive.py new file mode 100755 index 0000000..40fefac --- /dev/null +++ b/SIGCOMM_2015/source_routing/receive.py @@ -0,0 +1,42 @@ +#!/usr/bin/python + +# Copyright 2013-present Barefoot Networks, Inc. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +from scapy.all import sniff, sendp +from scapy.all import Packet +from scapy.all import ShortField, IntField, LongField, BitField + +import sys +import struct + +def handle_pkt(pkt): + pkt = str(pkt) + if len(pkt) < 12: return + preamble = pkt[:8] + preamble_exp = "\x00" * 8 + if preamble != preamble_exp: return + num_valid = struct.unpack("d5}?HrEfStQsrN1Ue-x_9e<0$RC82WloqlE? zCc%@*=*j%|z5c!YkNeX>3%qCM@hJZ1`Pb|wLSLcwLtL{g(jY~q(N8~@e@>yn!muXs zLn%`5;Fn*WpS=N#e}zN+rz0hUm$?PLqyLWv;{nzGa55R#{{JIzFaJtpGCQ;7-_4R4slwGbMXsCPns zR$W*mfeViFjt7`13?WNGl%Tf=^OObjDJ5O_fKt(^f`RKn+bEorqLa>o^R7`EJ zOZ)6}YF@n=