Commit eeb16213 authored by Lluis Gifre Renom's avatar Lluis Gifre Renom
Browse files

Merge branch 'feat/hackfest3' into 'develop'

Merge 3rd hackfest material to develop

See merge request !164
parents 36233be1 e0349474
Loading
Loading
Loading
Loading

hackfest3

0 → 120000
+1 −0
Original line number Diff line number Diff line
src/tests/hackfest3/
 No newline at end of file
+41 −0
Original line number Diff line number Diff line
# Tests for P4 functionality of TeraFlowSDN

This directory contains the necessary scripts and configurations to run tests for the P4 functionality of TFS.

## Basic scripts

To run the experiments you should use the five scripts in the following order:
```
setup.sh
run_test_01_bootstrap.sh
run_test_02_create_service.sh
run_test_03_delete_service.sh
run_test_04_cleanup.sh
```

The setup script copies the necessary artifacts to the SBI service pod. It should be run just once, after a fresh install of TFS.
The bootstrap script registers the context, topology, links and, devices to TFS.
The create service scripts establishes a service between two endpoints.
The delete service script delete the aforementioned service.
Cleanup script deletes all the objects (context, topology, links, devices) from TFS.

## Objects file

The above bash scripts make use of the corresponding python scripts found under `./tests/` directory.
More important is the `./tests/Objects.py` file, which contains the definition of the Context, Topology, Devices, Links, Services. **This is the file that need changes in case of a new topology.**

Check the `./tests/Objects.py` file before running the experiment to make sure that the switches details are correct (ip address, port, etc.)

## Mininet topologies

In the `./mininet/` directory there are different mininet topology examples. The current `./tests/Objects.py` file corresponds to the `./mininet/4switch2path.py` topology. For more topologies please refer to `../p4`.

## P4 artifacts

In the `./p4/` directory there are the compiled p4 artifacts that contain the pipeline that will be pushed to the p4 switch, along with the p4-runtime definitions. 
The `./setup.sh` script copies from this directory. So if you need to change p4 program, make sure to put the compiled artifacts here.

## Latency probe

In the `./probe/` directory there is a little program which calculates latency between two hosts in mininet and sends them to the Monitoring component. For specific instructions, refer to the corresponding `./probe/README.md` file.
+14 −0
Original line number Diff line number Diff line
# Copyright 2022-2023 ETSI TeraFlowSDN - TFS OSG (https://tfs.etsi.org/)
#
# 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.
+111 −0
Original line number Diff line number Diff line
################## TFS deployment and setup #######################

###### Deployment
# To deploy TFS:
cd ~/contoller
source my_deploy.sh
./deploy.sh

###### Experiments
# To onboard the experiment
cd ~/contoller

# Setup the compiled files
./src/tests/hackfest3/setup.sh

# Register the devices
./src/tests/hackfest3/run_test_01_bootstrap.sh

# Create the service
./src/tests/hackfest3/run_test_02_create_service.sh

# Delete the service
./src/tests/hackfest3/run_test_03_delete_service.sh

# Cleanup TFS
./src/tests/hackfest3/run_test_04_cleanup.sh


########################## MININET ##################
# To get the mininet cli 
cd ~/ngsdn-tutorial
make mn-cli

#### screen
# To open a screen in mininet 
  # For client
  MN: client screen -S <name>
  
  # For server
  MN: server screen -S <name>
  
# To get out 
Press <Ctrl+A> + d
 
# To reconnect 
MN: client screen -r <name>


####################### PROBE ######################
### old probe
# agent
source tfs_runtime_env_vars.sh

cd ~/controller/src/tests/hackfest3/probe/probe-tfs

./deploy.sh
./connect_to_mininet.sh
./tfsagent

# pinger
# In mininet
cd ~/ngsdn-tutorial
make mn-cli
MN: client ./tfsping


### new probe
cd ~/controller/src/tests/hackfest3/new-probe
./copy.sh

# agent:
# import PYTHONPATH by tfs_enviromental variables
source tfs_runtime_env_vars.sh
python agent.py

# pinger
# In mininet
cd ~/ngsdn-tutorial
make mn-cli
MN: client python ping2.py 10.0.0.2

# To enter delay or packet loss
cd ~/controller/src/tests/hackfest3/new-probe
./connect_to_mininet.sh
tc qdisc add dev <switch-iface> root netem delay <x>ms
tc qdisc add dev <switch-iface> root netem loss <x>%

################ INT (interactive session 2) ###########
# build the new code
cd ~/controller/src/tests/hackfest3/int
build_p4.sh <p4-program to build>

# copy the receiver, sender and helper script to docker container
cd ~/controller/src/tests/hackfest3/int
./copy_int_helpers.sh
./connect_to_mininet.sh
./install-scapy.sh

# Run the receiver in server screen
cd ~/ngsdn-tutorial
make mn-cli
MN: server screen -S rec
  MN/Screen: python receive.py
  <Ctrl+A> + d

# Run the sender in client
MN: client python send.py 10.0.0.1 "test" 1

# Check the output in receiver
MN: server screen -r rec
  <Ctrl+A> + d
+150 −0
Original line number Diff line number Diff line
#!/bin/bash
# Copyright 2022-2023 ETSI TeraFlowSDN - TFS OSG (https://tfs.etsi.org/)
#
# 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.


# ----- TeraFlowSDN ------------------------------------------------------------

# Set the URL of the internal MicroK8s Docker registry where the images will be uploaded to.
export TFS_REGISTRY_IMAGES="http://localhost:32000/tfs/"

# Set the list of components, separated by spaces, you want to build images for, and deploy.
export TFS_COMPONENTS="context device pathcomp service slice compute webui load_generator"

# Uncomment to activate Monitoring
export TFS_COMPONENTS="${TFS_COMPONENTS} monitoring"

# Uncomment to activate Policy Manager
export TFS_COMPONENTS="${TFS_COMPONENTS} policy"

# Uncomment to activate Automation Manager
#export TFS_COMPONENTS="${TFS_COMPONENTS} automation"

# Uncomment to activate Optical CyberSecurity
#export TFS_COMPONENTS="${TFS_COMPONENTS} dbscanserving opticalattackmitigator opticalattackdetector opticalattackmanager"

# Uncomment to activate L3 CyberSecurity
#export TFS_COMPONENTS="${TFS_COMPONENTS} l3_attackmitigator l3_centralizedattackdetector"

# Uncomment to activate TE
#export TFS_COMPONENTS="${TFS_COMPONENTS} te"

# Set the tag you want to use for your images.
export TFS_IMAGE_TAG="dev"

# Set the name of the Kubernetes namespace to deploy TFS to.
export TFS_K8S_NAMESPACE="tfs"

# Set additional manifest files to be applied after the deployment
export TFS_EXTRA_MANIFESTS="manifests/nginx_ingress_http.yaml"

# Uncomment to monitor performance of components
export TFS_EXTRA_MANIFESTS="${TFS_EXTRA_MANIFESTS} manifests/servicemonitors.yaml"

# Uncomment when deploying Optical CyberSecurity
#export TFS_EXTRA_MANIFESTS="${TFS_EXTRA_MANIFESTS} manifests/cachingservice.yaml"

# Set the new Grafana admin password
export TFS_GRAFANA_PASSWORD="admin123+"

# Disable skip-build flag to rebuild the Docker images.
export TFS_SKIP_BUILD=""


# ----- CockroachDB ------------------------------------------------------------

# Set the namespace where CockroackDB will be deployed.
export CRDB_NAMESPACE="crdb"

# Set the external port CockroackDB Postgre SQL interface will be exposed to.
export CRDB_EXT_PORT_SQL="26257"

# Set the external port CockroackDB HTTP Mgmt GUI interface will be exposed to.
export CRDB_EXT_PORT_HTTP="8081"

# Set the database username to be used by Context.
export CRDB_USERNAME="tfs"

# Set the database user's password to be used by Context.
export CRDB_PASSWORD="tfs123"

# Set the database name to be used by Context.
export CRDB_DATABASE="tfs"

# Set CockroachDB installation mode to 'single'. This option is convenient for development and testing.
# See ./deploy/all.sh or ./deploy/crdb.sh for additional details
export CRDB_DEPLOY_MODE="single"

# Disable flag for dropping database, if it exists.
export CRDB_DROP_DATABASE_IF_EXISTS="YES"

# Disable flag for re-deploying CockroachDB from scratch.
export CRDB_REDEPLOY="YES"


# ----- NATS -------------------------------------------------------------------

# Set the namespace where NATS will be deployed.
export NATS_NAMESPACE="nats"

# Set the external port NATS Client interface will be exposed to.
export NATS_EXT_PORT_CLIENT="4222"

# Set the external port NATS HTTP Mgmt GUI interface will be exposed to.
export NATS_EXT_PORT_HTTP="8222"

# Disable flag for re-deploying NATS from scratch.
export NATS_REDEPLOY="YES"


# ----- QuestDB ----------------------------------------------------------------

# Set the namespace where QuestDB will be deployed.
export QDB_NAMESPACE="qdb"

# Set the external port QuestDB Postgre SQL interface will be exposed to.
export QDB_EXT_PORT_SQL="8812"

# Set the external port QuestDB Influx Line Protocol interface will be exposed to.
export QDB_EXT_PORT_ILP="9009"

# Set the external port QuestDB HTTP Mgmt GUI interface will be exposed to.
export QDB_EXT_PORT_HTTP="9000"

# Set the database username to be used for QuestDB.
export QDB_USERNAME="admin"

# Set the database user's password to be used for QuestDB.
export QDB_PASSWORD="quest"

# Set the table name to be used by Monitoring for KPIs.
export QDB_TABLE_MONITORING_KPIS="tfs_monitoring_kpis"

# Set the table name to be used by Slice for plotting groups.
export QDB_TABLE_SLICE_GROUPS="tfs_slice_groups"

# Disable flag for dropping tables if they exist.
export QDB_DROP_TABLES_IF_EXIST=""

# Disable flag for re-deploying QuestDB from scratch.
export QDB_REDEPLOY="YES"


# ----- K8s Observability ------------------------------------------------------

# Set the external port Prometheus Mgmt HTTP GUI interface will be exposed to.
export PROM_EXT_PORT_HTTP="9090"

# Set the external port Grafana HTTP Dashboards will be exposed to.
export GRAF_EXT_PORT_HTTP="3000"
Loading