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("