Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Project no longer uses clone3() #3

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@

*.jar
Rubbish/
*.class
desktop.ini
Code/ngsdn-tutorial/topopoly.png
Documents/*
**/log/
**/target/
**/tmp/

*.log
49 changes: 49 additions & 0 deletions Extra instructions.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
make stop
make clean
make deps
make start

make app-build
make app-reload
make netcfg

#--------------------at ONOS cli (make onos-cli)
source /config/routing_tables.txt
source /config/ua_config.txT



#--------------------at ONOS cli (make onos-cli)
#---srv6_insert.txt (go and return from h1->h2)
#--use case1: Insert the uSID routing directive to the the two end routers
srv6-insert device:r1 fcbb:bb00:8:7:2:fd00:: 2001:1:2::1
srv6-insert device:r2 fcbb:bb00:7:8:1:fd00:: 2001:1:1::1

#--use case 2 (only go from h1 to h2, on the back path the packet will vary route)
srv6-insert device:r1 fcbb:bb00:9:fa94:a:faa5:b:c fcbb:bb00:e:2:fd00:: 2001:1:2::1



#--------------------at mininet cli (make mn-cli)
h1 ping h2
h2 ping h1




#--------------------For INT
# Run the following commands in another terminal
sudo python collector_influxdb.py


# At a h1 terminal run:
python receive/receive.py

# At a h2 terminal run:
python send/send.py --ip 2001:db8::2 --l4 udp --port 443 --m INTH1 --c 1


#The generated telemetry should be visible in the grafana dashboard



12 changes: 6 additions & 6 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -35,30 +35,30 @@ deps: _docker_pull_all
start:
$(info *** Starting ONOS and Mininet (${NGSDN_TOPO_PY})... )
@mkdir -p tmp/onos
docker-compose up -d
docker compose up -d


stop:
$(info *** Stopping ONOS and Mininet...)
docker-compose down
docker compose down

restart: reset start

onos-cli:
$(info *** Connecting to the ONOS CLI... password: rocks)
$(info *** Top exit press Ctrl-D)
@ssh -o "UserKnownHostsFile=/dev/null" -o "StrictHostKeyChecking=no" -o LogLevel=ERROR -p 8101 onos@localhost
$(info *** Top exit press Ctrl-D WARNING: NON SECURE CONNECTION, ADDED -o HostKeyAlgorithms=ssh-rsa TO AVOID ERROR***)
@ssh -o "UserKnownHostsFile=/dev/null" -o "StrictHostKeyChecking=no" -o HostKeyAlgorithms=ssh-rsa -o LogLevel=ERROR -p 8101 onos@localhost

onos-log:
docker-compose logs -f onos
docker compose logs -f onos

onos-ui:
open ${onos_url}/ui

mn-cli:
$(info *** Attaching to Mininet CLI...)
$(info *** To detach press Ctrl-D (Mininet will keep running))
-@docker attach --detach-keys "ctrl-d" $(shell docker-compose ps -q mininet) || echo "*** Detached from Mininet CLI"
-@docker attach --detach-keys "ctrl-d" $(shell docker compose ps -q mininet) || echo "*** Detached from Mininet CLI"

mn-log:
docker logs -f mininet
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -365,7 +365,6 @@ public void insertRoutingRule(DeviceId routerId, Ip6Address ipv6Addr,
// Action param value.
nextHopMac.toBytes()))
.build();

flowRuleService.applyFlowRules(Utils
.buildFlowRule(routerId, appId, tableId, match, action));

Expand Down
Binary file modified mininet/host6.pyc
Binary file not shown.
15 changes: 15 additions & 0 deletions p4src/include/define.p4
Original file line number Diff line number Diff line change
Expand Up @@ -43,4 +43,19 @@ const mac_addr_t IPV6_MCAST_01 = 0x33_33_00_00_00_01;
const bit<32> NDP_FLAG_ROUTER = 0x80000000;
const bit<32> NDP_FLAG_SOLICITED = 0x40000000;
const bit<32> NDP_FLAG_OVERRIDE = 0x20000000;


//transition from clone3()
const bit<32> BMV2_V1MODEL_INSTANCE_TYPE_NORMAL = 0;
const bit<32> BMV2_V1MODEL_INSTANCE_TYPE_INGRESS_CLONE = 1;
const bit<32> BMV2_V1MODEL_INSTANCE_TYPE_EGRESS_CLONE = 2;
const bit<32> BMV2_V1MODEL_INSTANCE_TYPE_COALESCED = 3;
const bit<32> BMV2_V1MODEL_INSTANCE_TYPE_RECIRC = 4;
const bit<32> BMV2_V1MODEL_INSTANCE_TYPE_REPLICATION = 5;
const bit<32> BMV2_V1MODEL_INSTANCE_TYPE_RESUBMIT = 6;





#endif
13 changes: 12 additions & 1 deletion p4src/include/header.p4
Original file line number Diff line number Diff line change
Expand Up @@ -135,8 +135,16 @@ header ndp_option_t {
bit<48> value;
}

const bit<8> CLONE_FL_clone3 = 3;
struct preserving_metadata_CPU_t {
@field_list(CLONE_FL_clone3)
bit<9> ingress_port;
@field_list(CLONE_FL_clone3)
bit<9> egress_port;
}

//Custom metadata definition
struct local_metadata_t {
struct local_metadata_t {
bool is_multicast;
bool skip_l2;
bool xconnect;
Expand All @@ -147,8 +155,11 @@ struct local_metadata_t {
l4_port_t l4_src_port;
l4_port_t l4_dst_port;
bool ipv4_update;
preserving_metadata_CPU_t perserv_CPU_meta; //to migrate from clone3() to clone_preserving() in the clone_to_CPU scenario
}



struct parsed_headers_t {
ethernet_t ethernet;
ipv6_t ipv6;
Expand Down
49 changes: 36 additions & 13 deletions p4src/main.p4
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,14 @@
#include <core.p4>
#include <v1model.p4>


#include "include/header.p4"
#include "include/parser.p4"
#include "include/checksum.p4"

#define CPU_CLONE_SESSION_ID 99
#define UN_BLOCK_MASK 0xffffffff000000000000000000000000


control IngressPipeImpl (inout parsed_headers_t hdr,
inout local_metadata_t local_metadata,
Expand Down Expand Up @@ -86,7 +87,7 @@ control IngressPipeImpl (inout parsed_headers_t hdr,
}

// TODO: implement ecmp with ipv6.src+ipv6.dst+ipv6.flow_label
action_selector(HashAlgorithm.crc16, 32w64, 32w10) ip6_ecmp_selector;
//action_selector(HashAlgorithm.crc16, 32w64, 32w10) ip6_ecmp_selector;
direct_counter(CounterType.packets_and_bytes) routing_v6_counter;
table routing_v6 {
key = {
Expand All @@ -100,7 +101,7 @@ control IngressPipeImpl (inout parsed_headers_t hdr,
set_next_hop;
}
counters = routing_v6_counter;
implementation = ip6_ecmp_selector;
//implementation = ip6_ecmp_selector;
}

// TODO calc checksum
Expand Down Expand Up @@ -389,7 +390,10 @@ control IngressPipeImpl (inout parsed_headers_t hdr,
*/

action clone_to_cpu() {
clone3(CloneType.I2E, CPU_CLONE_SESSION_ID, standard_metadata);
//clone3(CloneType.I2E, CPU_CLONE_SESSION_ID, standard_metadata); //DEPRACTED need OG project compiler
local_metadata.perserv_CPU_meta.ingress_port = standard_metadata.ingress_port;
local_metadata.perserv_CPU_meta.egress_port = CPU_PORT; //the packet only gets the egress right before egress, so we use CPU_PORT value
clone_preserving_field_list(CloneType.I2E, CPU_CLONE_SESSION_ID, CLONE_FL_clone3);
}

direct_counter(CounterType.packets_and_bytes) acl_counter;
Expand Down Expand Up @@ -464,7 +468,7 @@ control IngressPipeImpl (inout parsed_headers_t hdr,
multicast.apply();
}
}

acl.apply();

}
Expand All @@ -474,14 +478,33 @@ control EgressPipeImpl (inout parsed_headers_t hdr,
inout local_metadata_t local_metadata,
inout standard_metadata_t standard_metadata) {
apply {
if (standard_metadata.egress_port == CPU_PORT) {
hdr.packet_in.setValid();
hdr.packet_in.ingress_port = standard_metadata.ingress_port;
}

if (local_metadata.is_multicast == true
&& standard_metadata.ingress_port == standard_metadata.egress_port) {
mark_to_drop(standard_metadata);
if (standard_metadata.instance_type == BMV2_V1MODEL_INSTANCE_TYPE_INGRESS_CLONE) {
// write code here that works the same was as the original, except it uses
// only metadata field values that you have explicitly preserved.
if (local_metadata.perserv_CPU_meta.egress_port == CPU_PORT) { //packets for the controller, being a cloned packet we look at the struct
hdr.packet_in.setValid();
hdr.packet_in.ingress_port = local_metadata.perserv_CPU_meta.ingress_port;
}
if (local_metadata.is_multicast == true && local_metadata.perserv_CPU_meta.ingress_port == local_metadata.perserv_CPU_meta.egress_port) {
mark_to_drop(standard_metadata);
}
} else if ((standard_metadata.instance_type == BMV2_V1MODEL_INSTANCE_TYPE_NORMAL) || (standard_metadata.instance_type == BMV2_V1MODEL_INSTANCE_TYPE_REPLICATION)) {
// Put a copy of the original egress code here, which seems to have been
// written assuming that all standard_metadata fields were preserved, which
// should be the case for NORMAL packets.
if (standard_metadata.egress_port == CPU_PORT) {
hdr.packet_in.setValid();
hdr.packet_in.ingress_port = standard_metadata.ingress_port;
}
if (local_metadata.is_multicast == true && standard_metadata.ingress_port == standard_metadata.egress_port) {
mark_to_drop(standard_metadata);
}
} else {
// Not clear to me whether you need any further branches to handle other
// cases of the value of instance_type, but if. you want to be cautious
// I would put a log_msg() extern call here that prints a special message
// you can easily 'grep' for in the log files to see if this ever happens.
log_msg("Unexpected instance_type in EgressPipeImpl: ", { standard_metadata.instance_type });
}
}
}
Expand Down
4 changes: 2 additions & 2 deletions util/docker/Makefile.vars
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
ONOS_IMG := onosproject/onos:2.2.2
P4RT_SH_IMG := p4lang/p4runtime-sh:latest
P4C_IMG := opennetworking/p4c:stable
P4C_IMG := p4lang/p4c:1.2.4.5
STRATUM_BMV2_IMG := opennetworking/ngsdn-tutorial:stratum_bmv2
MVN_IMG := opennetworking/ngsdn-tutorial:mvn
GNMI_CLI_IMG := bocon/gnmi-cli:latest
Expand All @@ -9,7 +9,7 @@ SSHPASS_IMG := ictu/sshpass

ONOS_SHA := sha256:438815ab20300cd7a31702b7dea635152c4c4b5b2fed9b14970bd2939a139d2a
P4RT_SH_SHA := sha256:6ae50afb5bde620acb9473ce6cd7b990ff6cc63fe4113cf5584c8e38fe42176c
P4C_SHA := sha256:8f9d27a6edf446c3801db621359fec5de993ebdebc6844d8b1292e369be5dfea
P4C_SHA := sha256:c57157460bbe8829a9c30246bf4e60e348b0768fd6fab63c0491012b788733d3
STRATUM_BMV2_SHA := sha256:f31faa5e83abbb2d9cf39d28b3578f6e113225641337ec7d16d867b0667524ef
MVN_SHA := sha256:d85eb93ac909a90f49b16b33cb872620f9b4f640e7a6451859aec704b21f9243
GNMI_CLI_SHA := sha256:6f1590c35e71c07406539d0e1e288e87e1e520ef58de25293441c3b9c81dffc0
Expand Down