Commit 1b7def35 authored by Harry Jiang's avatar Harry Jiang

some variables are updated

parent e02af541
No preview for this file type
......@@ -22,8 +22,8 @@ BUFFSIZE = 4096
class Client(cmd.Cmd, object):
prompt = 'HP4$ '
intro = 'HP4 Controller Client'
prompt = 'HP4PLUS$ '
intro = 'HP4PLUS Controller Client'
def __init__(self, user='admin', ip='localhost', port=33333,
debug=False, histfile=".client-history", **kwargs):
......@@ -360,7 +360,7 @@ class ChainSliceManager(SliceManager):
self.debug_print(resp)
class Administrator(Client):
prompt = 'HP4# '
prompt = 'HP4PLUS# '
def __init__(self, **kwargs):
super(Administrator, self).__init__(**kwargs)
......
......@@ -116,10 +116,10 @@ class Controller(object):
json = parameters[7]
ports = parameters[8:]
else:
json = '/home/' + getpass.getuser() + '/hp4-src/hp4/hp4.json'
hjp_check = Path('hp4controller/hp4_json_path')
json = '/home/' + getpass.getuser() + '/hp4plus/hp4/hp4.json'
hjp_check = Path('centralcontroller/hp4_json_path')
if hjp_check.is_file():
with open('hp4controller/hp4_json_path', 'r') as hjp:
with open('centralcontroller/hp4_json_path', 'r') as hjp:
json = hjp.readline()[:-1]
ports = parameters[7:]
......
from hp4controller.p4command import P4Command
from hp4controller.virtualdevice.p4rule import P4Rule
from hp4controller.errors import AddRuleError, ModRuleError, DeleteRuleError
from hp4controller.errors import MCastError, SendCommandError
from centralcontroller.p4command import P4Command
from centralcontroller.virtualdevice.p4rule import P4Rule
from centralcontroller.errors import AddRuleError, ModRuleError, DeleteRuleError
from centralcontroller.errors import MCastError, SendCommandError
from sswitch_CLI import SimpleSwitchAPI
......
from hp4controller.virtualdevice.virtualdevice import VirtualDevice
from hp4controller.virtualdevice.p4rule import P4Rule
from hp4controller.virtualdevice.interpret import Interpretation
from hp4controller.p4command import P4Command
from hp4controller.errors import AddRuleError, LoadError, VirtnetError
from centralcontroller.virtualdevice.virtualdevice import VirtualDevice
from centralcontroller.virtualdevice.p4rule import P4Rule
from centralcontroller.virtualdevice.interpret import Interpretation
from centralcontroller.p4command import P4Command
from centralcontroller.errors import AddRuleError, LoadError, VirtnetError
import copy
......
import virtualdevice
from hp4controller.p4command import P4Command
from hp4controller.errors import InterpretError
from centralcontroller.p4command import P4Command
from centralcontroller.errors import InterpretError
from p4rule import P4Rule
import json
......@@ -365,7 +365,7 @@ class Interpretation():
class InterpretationGuide():
def __init__(self, ig_path):
# key method: ~/hp4-src/p4c-hp4/controller.py::DPMUServer::parse_json
# key method: ~/hp4plus/p4c-hp4/controller.py::DPMUServer::parse_json
self.templates_match = {} # {(native_table, native_action): P4Command}
self.templates_prims = {} # {(native_table, native_action): [P4Command]}
with open(ig_path) as json_data:
......
from hp4controller.p4command import P4Command
from centralcontroller.p4command import P4Command
from p4rule import P4Rule
from interpret import Interpretation, InterpretationGuide, Interpreter
from hp4controller.compilers import p4_hp4
from hp4controller.compilers.compiler import CodeRepresentation
from centralcontroller.compilers import p4_hp4
from centralcontroller.compilers.compiler import CodeRepresentation
import re
import code
......@@ -168,7 +168,7 @@ class VirtualDevice():
"""
def interpret(self, p4command):
# key method: ~/hp4-src/p4c-hp4/controller.py::DPMUServer::translate
# key method: ~/hp4plus/p4c-hp4/controller.py::DPMUServer::translate
p4commands = []
native_table = p4command.attributes['table']
......
#!/bin/bash
python -m central-controller.clients.client $@
python -m centralcontroller.clients.client $@
......@@ -5,12 +5,12 @@ then
echo "configuring controller for cloudlab execution"
printf "#!/bin/bash\n\n" > tests/ssh_vals.sh
printf "user=$1\n" >> tests/ssh_vals.sh
echo "/opt/hp4plus/hp4/hp4.json" > central-controller/hp4_json_path
echo "/opt/hp4plus/hp4/hp4.json" > centralcontroller/hp4_json_path
if [[ $# -gt 1 ]]
then
printf "nodes=( $2 $3 $4 $5 $6 $7 $8 $9 ${10} ${11} ${12} )\n" >> tests/ssh_vals.sh
fi
else
echo "configuring controller for local (e.g., mininet) execution"
rm -f central-controller/hp4_json_path
rm -f centralcontroller/hp4_json_path
fi
#!/bin/bash
python -u -m central-controller.controller $@
python -u -m centralcontroller.controller $@
No preview for this file type
#define VIBRANT_FLAG 0x020101010101
header_type vibrant_t {
fields {
flag : 48;
hKeyIndex : 64; // choose 8
}
}
header_type ethernet_t {
fields {
dstAddr : 48;
srcAddr : 48;
etherType : 16;
}
}
header_type could_be_ipv4_t {
fields {
unused : 96;
srcAddr : 32;
dstAddr: 32;
}
}
header_type intrinsic_metadata_t {
fields {
ingress_global_timestamp : 48;
lf_field_list : 8;
mcast_grp : 16;
egress_rid : 16;
resubmit_flag : 8;
recirculate_flag : 8;
}
}
header vibrant_t vibrant;
header ethernet_t ethernet;
header could_be_ipv4_t could_be_ipv4;
metadata intrinsic_metadata_t intrinsic_metadata;
parser start {
extract(ethernet);
extract(could_be_ipv4);
return select(current(0, 48)) {
VIBRANT_FLAG : parse_vibrant;
default: ingress;
}
}
parser parse_vibrant {
extract(vibrant);
return ingress;
}
action vibrant_present() { }
action vibrant_not_present() { }
table check_vibrant {
reads {
vibrant : valid;
}
actions {
vibrant_present;
vibrant_not_present;
}
}
action a_decrypt(k1, k2, k3, k4) {
bit_xor(ethernet.dstAddr, ethernet.dstAddr, k1);
bit_xor(ethernet.srcAddr, ethernet.srcAddr, k2);
bit_xor(could_be_ipv4.dstAddr, could_be_ipv4.dstAddr, k3);
bit_xor(could_be_ipv4.srcAddr, could_be_ipv4.srcAddr, k4);
}
table decrypt {
reads {
vibrant.hKeyIndex : ternary;
}
actions {
a_decrypt;
}
}
action a_strip_vibrant() {
remove_header(vibrant);
}
table strip_vibrant {
actions {
a_strip_vibrant;
}
}
control ingress {
apply(check_vibrant) {
vibrant_present {
apply(decrypt);
apply(strip_vibrant);
}
}
}
#define VIBRANT_FLAG 0x020101010101
header_type vibrant_t {
fields {
flag : 48;
hKeyIndex : 64; // choose 8
}
}
header_type ethernet_t {
fields {
dstAddr : 48;
srcAddr : 48;
etherType : 16;
}
}
header_type could_be_ipv4_t {
fields {
unused : 96;
srcAddr : 32;
dstAddr: 32;
}
}
header_type intrinsic_metadata_t {
fields {
ingress_global_timestamp : 48;
lf_field_list : 8;
mcast_grp : 16;
egress_rid : 16;
resubmit_flag : 8;
recirculate_flag : 8;
}
}
header vibrant_t vibrant;
header ethernet_t ethernet;
header could_be_ipv4_t could_be_ipv4;
metadata intrinsic_metadata_t intrinsic_metadata;
parser start {
extract(ethernet);
extract(could_be_ipv4);
return select(current(0, 48)) {
VIBRANT_FLAG : parse_vibrant;
default: ingress;
}
}
parser parse_vibrant {
extract(vibrant);
return ingress;
}
action a_add_vibrant() {
add_header(vibrant);
modify_field(vibrant.flag, VIBRANT_FLAG);
modify_field_rng_uniform(vibrant.hKeyIndex, 0, 0xFFFFFFFFFFFFFFFF);
}
action _no_op() {
}
table check_egress {
reads {
standard_metadata.egress_spec : exact;
}
actions {
a_add_vibrant;
_no_op;
}
}
action a_encrypt(k1, k2, k3, k4) {
bit_xor(ethernet.dstAddr, ethernet.dstAddr, k1);
bit_xor(ethernet.srcAddr, ethernet.srcAddr, k2);
bit_xor(could_be_ipv4.dstAddr, could_be_ipv4.dstAddr, k3);
bit_xor(could_be_ipv4.srcAddr, could_be_ipv4.srcAddr, k4);
}
action a_mod_epoch_and_encrypt(new_epoch, k1, k2, k3, k4) {
modify_field(vibrant.hKeyIndex, new_epoch);
bit_xor(ethernet.dstAddr, ethernet.dstAddr, k1);
bit_xor(ethernet.srcAddr, ethernet.srcAddr, k2);
bit_xor(could_be_ipv4.dstAddr, could_be_ipv4.dstAddr, k3);
bit_xor(could_be_ipv4.srcAddr, could_be_ipv4.srcAddr, k4);
}
table encrypt {
reads {
vibrant.hKeyIndex : ternary;
}
actions {
a_encrypt;
a_mod_epoch_and_encrypt;
}
}
control ingress {
apply(check_egress) {
a_add_vibrant {
apply(encrypt);
}
}
}
#define VIBRANT_FLAG 0x020101010101
header_type vibrant_t {
fields {
flag : 48;
hKeyIndex : 64; // choose 8
}
}
header_type ethernet_t {
fields {
dstAddr : 48;
srcAddr : 48;
etherType : 16;
}
}
header_type ipv4_t {
fields {
version : 4;
ihl : 4;
diffserv : 8;
totalLen : 16;
identification : 16;
flags : 3;
fragOffset : 13;
ttl : 8;
protocol : 8;
hdrChecksum : 16;
srcAddr : 32;
dstAddr: 32;
}
}
// This allows us to decrypt and switch/route using temp fields so
// no need to re-encrypt before transmission, as we would have to
// if we decrypted to parsed representation fields:
header_type meta_t {
fields {
eth_dstAddr : 48;
eth_srcAddr : 48;
ipv4_dstAddr : 32;
ipv4_srcAddr : 32;
}
}
header_type intrinsic_metadata_t {
fields {
ingress_global_timestamp : 48;
lf_field_list : 8;
mcast_grp : 16;
egress_rid : 16;
resubmit_flag : 8;
recirculate_flag : 8;
}
}
header vibrant_t vibrant;
header ethernet_t ethernet;
header ipv4_t ipv4;
metadata meta_t meta;
metadata intrinsic_metadata_t intrinsic_metadata;
parser start {
extract(ethernet);
return select(ethernet.etherType) {
0x0800 : parse_ipv4;
default: ingress;
}
}
parser parse_ipv4 {
extract(ipv4);
return select(current(0, 48)) {
VIBRANT_FLAG : parse_vibrant;
default: ingress;
}
}
parser parse_vibrant {
extract(vibrant);
return ingress;
}
action vibrant_present() { }
action vibrant_not_present() { }
table check_vibrant {
reads {
vibrant : valid;
}
actions {
vibrant_present;
vibrant_not_present;
}
}
action a_decrypt(k1, k2, k3, k4) {
bit_xor(meta.eth_dstAddr, ethernet.dstAddr, k1);
bit_xor(meta.eth_srcAddr, ethernet.srcAddr, k2);
bit_xor(meta.ipv4_dstAddr, ipv4.dstAddr, k3);
bit_xor(meta.ipv4_srcAddr, ipv4.srcAddr, k4);
}
table decrypt {
reads {
vibrant.hKeyIndex : ternary;
}
actions {
a_decrypt;
}
}
action local(port) {
modify_field(standard_metadata.egress_spec, port);
}
action not_local(port) {
modify_field(standard_metadata.egress_spec, port);
}
action broadcast(mcast) {
modify_field(intrinsic_metadata.mcast_grp, mcast);
}
action _drop() {
drop();
}
table dmac {
reads {
meta.eth_dstAddr : exact;
}
actions {
local;
not_local;
broadcast;
_drop;
}
}
action a_strip_vibrant() {
modify_field(ethernet.dstAddr, meta.eth_dstAddr);
modify_field(ethernet.srcAddr, meta.eth_srcAddr);
modify_field(ipv4.dstAddr, meta.ipv4_dstAddr);
modify_field(ipv4.srcAddr, meta.ipv4_srcAddr);
remove_header(vibrant);
}
table strip_vibrant {
actions {
a_strip_vibrant;
}
}
table dmac2 {
reads {
ethernet.dstAddr : exact;
}
actions {
local;
not_local;
broadcast;
_drop;
}
}
action a_add_vibrant() {
add_header(vibrant);
modify_field(vibrant.flag, VIBRANT_FLAG);
modify_field_rng_uniform(vibrant.hKeyIndex, 0, 0xFFFFFFFFFFFFFFFF);
}
action _no_op() { }
table add_vibrant {
reads {
ipv4 : valid;
}
actions {
a_add_vibrant;
_no_op;
}
}
action a_encrypt(k1, k2, k3, k4) {
bit_xor(ethernet.dstAddr, ethernet.dstAddr, k1);
bit_xor(ethernet.srcAddr, ethernet.srcAddr, k2);
bit_xor(ipv4.dstAddr, ipv4.dstAddr, k3);
bit_xor(ipv4.srcAddr, ipv4.srcAddr, k4);
}
action a_mod_epoch_and_encrypt(new_epoch, k1, k2, k3, k4) {
modify_field(vibrant.hKeyIndex, new_epoch);
bit_xor(ethernet.dstAddr, ethernet.dstAddr, k1);
bit_xor(ethernet.srcAddr, ethernet.srcAddr, k2);
bit_xor(ipv4.dstAddr, ipv4.dstAddr, k3);
bit_xor(ipv4.srcAddr, ipv4.srcAddr, k4);
}
table encrypt {
reads {
vibrant.hKeyIndex : ternary;
}
actions {
a_encrypt;
a_mod_epoch_and_encrypt;
}
}
control ingress {
apply(check_vibrant) {
vibrant_present {
apply(decrypt);
apply(dmac) {
local {
apply(strip_vibrant);
}
}
}
vibrant_not_present {
apply(dmac2) {
not_local {
apply(add_vibrant) {
a_add_vibrant {
apply(encrypt);
}
}
}
}
}
}
}
/*
table filter_egress {
actions {
_drop;
}
}
control egress {
if(standard_metadata.egress_port == standard_metadata.ingress_port) {
apply(filter_egress);
}
}
*/
No preview for this file type
#!/bin/bash
python -m hp4controller.clients.vib_client $@
Approaches to debugging VIBRANT-CloudLab:
Next steps:
- Check for assumptions in vib_client.
- Install vib_enc vdev as passthrough, still no traffic?
- Install vib_enc only at s1 and only do h2 -> h4 pings; run tcpdump on
the three interfaces of s1, and view pcap in wireshark to see whether
traffic is being forwarded.
- If yes, repeat for s0, and s2.
- Recompile bmv2 with debugging / nano output enabled. Check nano logs on h2 -> h4 single ping.
Checked each relevant file in tests/t10/. Did not find any errors.
Controller should be using correct json for each device - a d430 version for the d430,
a pc3000 version for the others.
Mininet experiment t09 works (haven't tested that xterms automatically generate traffic as before - implemented fix in run_t09.sh to send the commands via ttyecho as we do in run_t10_cl.sh).
Collect increasingly detailed symptoms until we spot the problem.
Current status: Packets flow until the encryptors are installed. There are no evident errors thrown by encryptor installation.
We have figured out how to use tee with python: python -u forces unbuffered output so that tee will show it on stdout while writing to a file at the same time. Ran the experiment and did not detect any errors during encryptor vdev installation.
#!/bin/bash
macs=( "00:04:00:00:00:01"
"00:04:00:00:00:02"
"00:04:00:00:00:03"
"00:04:00:00:00:04"
"00:04:00:00:00:05"
"00:04:00:00:00:06")
hnames=( "node-5"
"node-6"
"node-7"
"node-8"
"node-9"
"node-10" )
ips=( "10.10.5.1/16"
"10.10.6.1/16"
"10.10.7.1/16"
"10.10.8.1/16"
"10.10.9.1/16"
"10.10.10.1/16" )
hname="$(hostname | tr "." " " | awk '{print $1}')"
for i in `seq 0 5`; do
if [ "$hname" == ${hnames[$i]} ]
then
ip=${ips[$i]}
mac=${macs[$i]}
break
fi
done
while read x
do
ipaddr="$(echo $x | awk '{print $4}')"
if [ "$ipaddr" == "$ip" ]
then
iface="$(echo $x | awk '{print $2}')"
sudo ifconfig $iface down
sudo ifconfig $iface hw ether $mac
sudo ifconfig $iface up
echo "updated MAC for $ipaddr to $mac"
break
fi
done <<< "$(ip -o -4 addr show)"
#!/bin/bash
#
# iface_setup.sh
#
# Setup a set of interfaces to be used with a model
#
# Usage:
# iface_setup iface_1 [ iface_2 ... ]
#
# The script performs the necessary setup on the interfaces to tbe used with
# a switch model. This typical setup includes the following:
# -- No protocols should be setup on the interface. This means not assigning
# any protocol addresses (neither IPv4, nor IPv6) to the interface.
# -- This will prevent the standard Linux stack from forwarding
# packets between these interfaces (especially if you can't globally
# disable IP routing)
# -- In case of IPv6, this will also prevent Linux stack from
# sending ICMPv6 router advertizement messages periodically
# -- Disable all HW acceleration on the interfaces
# -- This is critical, otherwise you will see strange behavior that
# depends on protocols, packet size and timing. For example, in
# case of TCP, HW acceleration might result in the model receiving
# one huge (e.g. 10K bytes long) TCP packet instead of 10 1K packets
# The problem is that the model will not be able to send such a long
# packet out.