diff --git a/.vscode/settings.json b/.vscode/settings.json index 994c0a2..c0959a1 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -90,7 +90,11 @@ "strstream": "cpp", "typeindex": "cpp", "csignal": "cpp", - "gtpu.h": "c" + "gtpu.h": "c", + "charconv": "cpp", + "csetjmp": "cpp", + "cuchar": "cpp", + "scoped_allocator": "cpp" }, "git.ignoreLimitWarning": true, diff --git a/README.md b/README.md index 782e37b..dcf1658 100644 --- a/README.md +++ b/README.md @@ -138,7 +138,35 @@ The instructions here is still missing. If you need to know how to test, contact ## :rocket: Benchmark -Check the [Jupyter notebook](notebook.ipynb). +Test environment: + +drawing + +Step: +1. Run Trex Traffic Generator +1. Run HTTP API + upf-bpf +1. Configure interfaces (/configure) +1. Create PFCP Session context (/createSession) +1. Generate the traffic (pkt size = 64B) +1. Collects metrics (CPU load, ipackets, opacket, throughput) + +> :memo: Postman files are available: [Uplink](tests/api/requests_body/gtp-postman-colletion.json) and [Downlink](tests/api/requests_body/udp-postman-colletion.json). You will find the json message used by the tests. + +The flows are generate using [Trex Field Engine](https://trex-tgn.cisco.com/trex/doc/cp_stl_docs/api/field_engine.html). Check the implementation [here](tests/trex/test_cases/run.py). + + +drawing + +Downlink | Uplink +---|--- +drawing| drawing +drawing| drawing + +Check the [Jupyter notebook](notebook.ipynb) to how the graphics are generated. + +> :memo: For more graphics, check [this](tests/reports/img) folder. + + ## Tree diff --git a/img/screenshot-tmux.png b/img/screenshot-tmux.png new file mode 100644 index 0000000..182f1fd --- /dev/null +++ b/img/screenshot-tmux.png @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:58cf356f572de998834ef1e8d86cd22dac0bf67cb94affb0cc57eb4e82bc1308 +size 1177037 diff --git a/src/SessionManager.cpp b/src/SessionManager.cpp index 705dea0..5dcab24 100644 --- a/src/SessionManager.cpp +++ b/src/SessionManager.cpp @@ -89,7 +89,7 @@ void SessionManager::addPDR(uint64_t seid, std::shared_ptr throw std::runtime_error("Source interface not supported"); } - // TODO navarrothiago - Check if it make sense, because we have a UL and DL PDR. + // TODO navarrothiago - REMOVED IT. pSessionProgram->getPDRMap()->update(pdr.pdr_id.rule_id, pdr, BPF_ANY); } diff --git a/tests/README.md b/tests/README.md deleted file mode 100644 index fe845de..0000000 --- a/tests/README.md +++ /dev/null @@ -1,12 +0,0 @@ -# Testing - -![setup-for-GPDU-debug-issue-2-upf-bpf](https://user-images.githubusercontent.com/42647168/86470179-4486cc80-bd11-11ea-8f55-fee848b12e11.png) - -- Open terminal in `Linux #0` -- Configure veth pairs with `make config-veth-pair` in `Linux #0` -- Install the spdlog library with `make setup` -- Build, load and run program with `make run` in `Linux #0` -- Login remote Scapy `ssh -X navarro@192.168.15.7 "cd /work/mestrado/scapy/; sudo -S ./run_scapy"` -- Generate GTP G-PDU using [Scapy](https://github.com/secdev/scapy) with `gtpu-traffic-generator.py` in `Linux #1` -- Open other terminal tab in `Linux #0` -- Check logs: `sudo cat /sys/kernel/debug/tracing/trace | grep "GPDU"` in `Linux #0` \ No newline at end of file diff --git a/tests/api/requests_body/configure.json b/tests/api/requests_body/configure.json deleted file mode 100644 index 0bc4da9..0000000 --- a/tests/api/requests_body/configure.json +++ /dev/null @@ -1,4 +0,0 @@ -{ - "udpInterface": "enp3s0f0", - "gtpInterface": "enp3s0f1" -} \ No newline at end of file diff --git a/tests/api/requests_body/gtp-postman-colletion.json b/tests/api/requests_body/gtp-postman-colletion.json new file mode 100644 index 0000000..4b951cd --- /dev/null +++ b/tests/api/requests_body/gtp-postman-colletion.json @@ -0,0 +1,96 @@ +{ + "info": { + "_postman_id": "88c048a5-db33-4523-a1ce-4be71282b681", + "name": "eBPF Remote GTP", + "schema": "https://schema.getpostman.com/json/collection/v2.1.0/collection.json" + }, + "item": [ + { + "name": "Configuration", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "POST", + "header": [], + "body": { + "mode": "raw", + "raw": "{\n \"udpInterface\": \"enp3s0f1\",\n \"gtpInterface\": \"enp3s0f0\"\n}" + }, + "url": { + "raw": "http://localhost:1234/configure", + "protocol": "http", + "host": [ + "localhost" + ], + "port": "1234", + "path": [ + "configure" + ] + } + }, + "response": [] + }, + { + "name": "Session", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "POST", + "header": [], + "body": { + "mode": "raw", + "raw": "{\n \"seid\": 1,\n \"pdrs\": [\n {\n \"pdrId\": 20,\n \"farId\": 200,\n \"outerHeaderRemoval\": \"OUTER_HEADER_REMOVAL_UDP_IPV4\",\n \"pdi\": {\n \"teid\": 100,\n \"sourceInterface\": \"INTERFACE_VALUE_CORE\",\n \"ueIPAddress\": \"10.1.3.27\"\n }\n },\n {\n \"pdrId\": 10,\n \"farId\": 100,\n \"outerHeaderRemoval\": \"OUTER_HEADER_REMOVAL_GTPU_UDP_IPV4\",\n \"pdi\": {\n \"teid\": 100,\n \"sourceInterface\": \"INTERFACE_VALUE_ACCESS\",\n \"ueIPAddress\": \"10.1.3.27\"\n }\n }\n ],\n \"fars\": [\n {\n \"farId\": 200,\n \"forwardingParameters\": {\n \"outerHeaderCreation\": {\n \"outerHeaderCreationDescription\": \"OUTER_HEADER_CREATION_GTPU_UDP_IPV4\",\n \"ipv4Address\": \"10.1.3.27\",\n \"portNumber\": 1234\n },\n \"destinationInterface\": \"INTERFACE_VALUE_ACCESS\"\n }\n },\n {\n \"farId\": 100,\n \"forwardingParameters\": {\n \"outerHeaderCreation\": {\n \"outerHeaderCreationDescription\": \"OUTER_HEADER_CREATION_UDP_IPV4\",\n \"ipv4Address\": \"10.1.3.27\",\n \"portNumber\": 1234\n },\n \"destinationInterface\": \"INTERFACE_VALUE_CORE\"\n }\n }\n ],\n \"arpTable\": [\n {\n \"ip\": \"10.1.2.27\",\n \"mac\": \"90:e2:ba:27:fd:3c\"\n },\n {\n \"ip\": \"10.1.3.27\",\n \"mac\": \"90:e2:ba:27:fd:3d\"\n }\n ]\n}" + }, + "url": { + "raw": "http://localhost:1234/createSession", + "protocol": "http", + "host": [ + "localhost" + ], + "port": "1234", + "path": [ + "createSession" + ] + } + }, + "response": [] + }, + { + "name": "Test Connection", + "request": { + "method": "GET", + "header": [], + "url": { + "raw": "http://localhost:1234/hi", + "protocol": "http", + "host": [ + "localhost" + ], + "port": "1234", + "path": [ + "hi" + ] + } + }, + "response": [] + } + ] +} \ No newline at end of file diff --git a/tests/api/requests_body/pfcp_session.json b/tests/api/requests_body/pfcp_session.json deleted file mode 100644 index 94d3502..0000000 --- a/tests/api/requests_body/pfcp_session.json +++ /dev/null @@ -1,59 +0,0 @@ -{ - "seid": 1, - "pdrs": [ - { - "pdrId": 20, - "farId": 200, - "outerHeaderRemoval": "OUTER_HEADER_REMOVAL_UDP_IPV4", - "pdi": { - "teid": 100, - "sourceInterface": "INTERFACE_VALUE_CORE", - "ueIPAddress": "10.1.3.27" - } - }, - { - "pdrId": 10, - "farId": 100, - "outerHeaderRemoval": "OUTER_HEADER_REMOVAL_GTPU_UDP_IPV4", - "pdi": { - "teid": 100, - "sourceInterface": "INTERFACE_VALUE_ACCESS", - "ueIPAddress": "10.1.3.27" - } - } - ], - "fars": [ - { - "farId": 200, - "forwardingParameters": { - "outerHeaderCreation": { - "outerHeaderCreationDescription": "OUTER_HEADER_CREATION_GTPU_UDP_IPV4", - "ipv4Address": "10.1.3.27", - "portNumber": 1234 - }, - "destinationInterface": "INTERFACE_VALUE_ACCESS" - } - }, - { - "farId": 100, - "forwardingParameters": { - "outerHeaderCreation": { - "outerHeaderCreationDescription": "OUTER_HEADER_CREATION_UDP_IPV4", - "ipv4Address": "10.1.3.27", - "portNumber": 1234 - }, - "destinationInterface": "INTERFACE_VALUE_CORE" - } - } - ], - "arpTable": [ - { - "ip": "10.1.2.27", - "mac": "90:e2:ba:27:fd:3c" - }, - { - "ip": "10.1.3.27", - "mac": "90:e2:ba:27:fd:3d" - } - ] -} \ No newline at end of file diff --git a/tests/api/requests_body/udp-postman-colletion.json b/tests/api/requests_body/udp-postman-colletion.json new file mode 100644 index 0000000..54094b7 --- /dev/null +++ b/tests/api/requests_body/udp-postman-colletion.json @@ -0,0 +1,96 @@ +{ + "info": { + "_postman_id": "7f7bdcd4-2df1-490e-a11c-82cfee8d6d17", + "name": "eBPF Remote UDP", + "schema": "https://schema.getpostman.com/json/collection/v2.1.0/collection.json" + }, + "item": [ + { + "name": "Test Connection", + "request": { + "method": "GET", + "header": [], + "url": { + "raw": "http://localhost:1234/hi", + "protocol": "http", + "host": [ + "localhost" + ], + "port": "1234", + "path": [ + "hi" + ] + } + }, + "response": [] + }, + { + "name": "Configuration", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "POST", + "header": [], + "body": { + "mode": "raw", + "raw": "{\n \"udpInterface\": \"enp3s0f0\",\n \"gtpInterface\": \"enp3s0f1\"\n}" + }, + "url": { + "raw": "http://localhost:1234/configure", + "protocol": "http", + "host": [ + "localhost" + ], + "port": "1234", + "path": [ + "configure" + ] + } + }, + "response": [] + }, + { + "name": "Session", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "POST", + "header": [], + "body": { + "mode": "raw", + "raw": "{\n \"seid\": 1,\n \"pdrs\": [\n {\n \"pdrId\": 20,\n \"farId\": 200,\n \"outerHeaderRemoval\": \"OUTER_HEADER_REMOVAL_UDP_IPV4\",\n \"pdi\": {\n \"teid\": 100,\n \"sourceInterface\": \"INTERFACE_VALUE_CORE\",\n \"ueIPAddress\": \"10.1.3.27\"\n }\n },\n {\n \"pdrId\": 10,\n \"farId\": 100,\n \"outerHeaderRemoval\": \"OUTER_HEADER_REMOVAL_GTPU_UDP_IPV4\",\n \"pdi\": {\n \"teid\": 100,\n \"sourceInterface\": \"INTERFACE_VALUE_ACCESS\",\n \"ueIPAddress\": \"10.1.3.27\"\n }\n }\n ],\n \"fars\": [\n {\n \"farId\": 200,\n \"forwardingParameters\": {\n \"outerHeaderCreation\": {\n \"outerHeaderCreationDescription\": \"OUTER_HEADER_CREATION_GTPU_UDP_IPV4\",\n \"ipv4Address\": \"10.1.3.27\",\n \"portNumber\": 1234\n },\n \"destinationInterface\": \"INTERFACE_VALUE_ACCESS\"\n }\n },\n {\n \"farId\": 100,\n \"forwardingParameters\": {\n \"outerHeaderCreation\": {\n \"outerHeaderCreationDescription\": \"OUTER_HEADER_CREATION_UDP_IPV4\",\n \"ipv4Address\": \"10.1.3.27\",\n \"portNumber\": 1234\n },\n \"destinationInterface\": \"INTERFACE_VALUE_CORE\"\n }\n }\n ],\n \"arpTable\": [\n {\n \"ip\": \"10.1.2.27\",\n \"mac\": \"90:e2:ba:27:fd:3c\"\n },\n {\n \"ip\": \"10.1.3.27\",\n \"mac\": \"90:e2:ba:27:fd:3d\"\n }\n ]\n}" + }, + "url": { + "raw": "http://localhost:1234/createSession", + "protocol": "http", + "host": [ + "localhost" + ], + "port": "1234", + "path": [ + "createSession" + ] + } + }, + "response": [] + } + ] +} \ No newline at end of file diff --git a/tests/reports/README.md b/tests/reports/README.md index 69432f9..fe82bc4 100644 --- a/tests/reports/README.md +++ b/tests/reports/README.md @@ -2,5 +2,5 @@ Report generated by running: ``` export PYTHONPATH='/workspaces/tests/trex/trex_client/interactive/' -./tests/trex/test_cases/udp_downlink.py -m -p -f +./tests/trex/test_cases/run.py -m -p -f ``` diff --git a/tests/trex/test_cases/udp_downlink.py b/tests/trex/test_cases/run.py similarity index 100% rename from tests/trex/test_cases/udp_downlink.py rename to tests/trex/test_cases/run.py diff --git a/tests/trex/test_cases/udp_downlink_2_stream.py b/tests/trex/test_cases/run_2_stream.py similarity index 100% rename from tests/trex/test_cases/udp_downlink_2_stream.py rename to tests/trex/test_cases/run_2_stream.py