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

Update plot scripts #67

Merged
merged 2 commits into from
Oct 24, 2024
Merged
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
78 changes: 30 additions & 48 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -202,9 +202,35 @@ ue/switch-edge/%:
@# swich edge for ue
@UE_IP=$(shell docker exec ue$(@F)-debug bash -c "ip --brief address show uesimtun0|awk '{print \$$3; exit}'|cut -d"/" -f 1");\
scripts/switch.py $(BCONFIG) $$UE_IP
.PHONY: plot/policy-diff
plot/policy-diff:
@echo "[1/2] [1/6] Configuring testbed with NextMN-SRv6"
@$(MAKE) set/dataplane/nextmn-srv6
@$(MAKE) set/nb-ue/2
@$(MAKE) set/nb-edges/2
@$(MAKE) set/full-debug/false
@$(MAKE) set/log-level/info
@echo "[1/2] [2/6] Starting containers"
@$(MAKE) up
@echo "[1/2] [3/6] Adding latency on instance s0"
@docker exec s0-debug bash -c "tc qdisc add dev edge-0 root netem delay 5ms"
@sleep 2
@docker exec ue1-debug bash -c "ping -c 1 10.4.0.1 > /dev/null" # check instance is reachable
@docker exec ue2-debug bash -c "ping -c 1 10.4.0.1 > /dev/null" # check instance is reachable
@echo "[1/2] [4/6] Setting UE2 on edge 1"
@$(MAKE) ue/switch-edge/2
@echo "[1/2] [5/6] [$$(date --rfc-3339=seconds)] Starting ping from ue1 and ue2 (60s + 5s margin)"
@bash -c 'docker exec ue1-debug bash -c "ping -D -w 60 10.4.0.1 -i 0.1 > /volume/ping-policy-diff-sliceA.txt"' &
@bash -c 'docker exec ue2-debug bash -c "ping -D -w 60 10.4.0.1 -i 0.1 > /volume/ping-policy-diff-sliceB.txt"' &
@sleep 65
@echo "[1/2] [6/6] Stopping containers"
@$(MAKE) down
@echo "[2/2] Plotting data"
@scripts/plots/policy_diff.py $(BUILD_DIR)/volumes/ue1/ping-policy-diff-sliceA.txt $(BUILD_DIR)/volumes/ue2/ping-policy-diff-sliceB.txt $(BUILD_DIR)/volumes/ue1/plot-policy-diff.pdf

.PHONY: graph/latency-switch
graph/latency-switch:

.PHONY: plot/latency-switch
plot/latency-switch:
@echo "[1/3] [1/6] Configuring testbed with NextMN-SRv6"
@$(MAKE) set/dataplane/nextmn-srv6
@$(MAKE) set/nb-ue/1
Expand Down Expand Up @@ -239,49 +265,5 @@ graph/latency-switch:
@docker exec ue1-debug bash -c "ping -D -w 60 10.4.0.1 -i 0.1 > /volume/ping-ulcl.txt"
@echo "[2/3] [5/5] Stopping containers"
@$(MAKE) down
@echo "[3/3] Creating graph"
@scripts/graphs/latency_switch.py $(BUILD_DIR)/volumes/ue1/ping-sr4mec.txt $(BUILD_DIR)/volumes/ue1/ping-ulcl.txt $(BUILD_DIR)/volumes/ue1/plot.pdf

.PHONY: graph/cp-delay
graph/cp-delay:
@$(MAKE) graph/cp-delay/iter/100

.PHONY: graph/cp-delay/iter
graph/cp-delay/iter/%:
@echo "[1/4] Configuring testbed"
@$(MAKE) set/nb-ue/1
@$(MAKE) set/nb-edges/2
@$(MAKE) set/full-debug/false
@$(MAKE) set/log-level/info
@echo "[2/4] [$$(date --rfc-3339=seconds)] Setting dataplane to Free5GC"
@$(MAKE) set/dataplane/free5gc
@$(MAKE) build
@iter=1 ; while [ $$iter -le $(@F) ] ; do \
echo "[2/4] [$$iter/$(@F)] [$$(date --rfc-3339=seconds)] New Free5GC capture" ; \
success=false; while [ $$success = false ]; do \
{ $(MAKE) graph/cp-delay/f5gc-$$iter && success=true || { $(MAKE) down ; kill -s TERM "$$(cat $(BUILD_DIR)/results/pid)" && rm $(BUILD_DIR)/results/pid && rm -f $(BUILD_DIR)/results/cp-delay-f5gc-$$iter.pcapng ; } ; }; \
done ; \
iter=$$(( iter + 1)) ; \
done
@echo "[3/4] [$$(date --rfc-3339=seconds)] Setting dataplane to NextMN-SRv6"
@$(MAKE) set/dataplane/nextmn-srv6
@$(MAKE) build
@iter=1 ; while [ $$iter -le $(@F) ] ; do \
echo "[3/4] [$$iter/$(@F)] [$$(date --rfc-3339=seconds)] New NextMN-SRv6 capture" ; \
success=false; while [ $$success = false ]; do \
{ $(MAKE) graph/cp-delay/srv6-$$iter && success=true || { $(MAKE) down ; kill -s TERM "$$(cat $(BUILD_DIR)/results/pid)" && rm $(BUILD_DIR)/results/pid && rm -f $(BUILD_DIR)/results/cp-delay-srv6-$$iter.pcapng ; } ; }; \
done ; \
iter=$$(( iter + 1)) ; \
done
@echo "[4/4] Creating graph"
@scripts/graphs/cp_delay.py text $(BUILD_DIR)/results
@scripts/graphs/cp_delay.py plot $(BUILD_DIR)/results $(@F)

graph/cp-delay/%:
@mkdir build/results -p
@tshark -i any -f sctp -w $(BUILD_DIR)/results/cp-delay-$(@F).pcapng & echo "$$!" > $(BUILD_DIR)/results/pid
@$(MAKE) up
@sleep 5
@docker exec ue1-debug bash -c "ping 10.4.0.1 -c1"
@$(MAKE) down
@kill -s TERM "$$(cat $(BUILD_DIR)/results/pid)" && rm $(BUILD_DIR)/results/pid
@echo "[3/3] Plotting data"
@scripts/plots/latency_switch.py $(BUILD_DIR)/volumes/ue1/ping-sr4mec.txt $(BUILD_DIR)/volumes/ue1/ping-ulcl.txt $(BUILD_DIR)/volumes/ue1/plot-latency-switch.pdf
5 changes: 1 addition & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ The following Debian's packages are required (or their equivalent on your distri
- `make`
- `acl`
- `openssl`
- `python3-matplotlib`

>[!NOTE]
> If you intend to use Free5GC’s UPF (with `make set/dataplane/free5gc`),
Expand All @@ -22,10 +23,6 @@ The following Debian's packages are required (or their equivalent on your distri
> Please note that you need to have Linux headers installed on the host to be able to install the module
> (for example, the package `linux-headers-amd64` on Debian if you are on an amd64 architecture).

The following Debian's packages are required for `make graph` subcommands only:
- `python3-matplotlib`
- `tshark`

### Usage
> [!IMPORTANT]
> Make sure to enable IPv6.
Expand Down
83 changes: 0 additions & 83 deletions scripts/graphs/cp_delay.py

This file was deleted.

File renamed without changes.
56 changes: 56 additions & 0 deletions scripts/plots/policy_diff.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
#!/usr/bin/env python3
'''Create plot for policy diff scenario'''
# Copyright 2024 Louis Royer. All rights reserved.
# Use of this source code is governed by a MIT-style license that can be
# found in the LICENSE file.
# SPDX-License-Identifier: MIT

import argparse
import pathlib
import matplotlib.pyplot as plt

def plot(arguments: argparse.Namespace):
'''Write plot'''
res = []
with open(arguments.slicea, 'r', encoding='utf8') as ping:
res.append({'tsp': [], 'pqt': []})
for i, line in enumerate(ping):
if 'time=' in line:
res[0]['tsp'].append(float (line.split('[')[1].split('] ')[0]))
res[0]['pqt'].append(float(line.split('time=' )[1].split(' ms' )[0]))
with open(arguments.sliceb, 'r', encoding='utf8') as ping:
res.append({'tsp': [], 'pqt': []})
for i, line in enumerate(ping):
if 'time=' in line:
res[1]['tsp'].append(float (line.split('[')[1].split('] ')[0]))
res[1]['pqt'].append(float(line.split('time=' )[1].split(' ms' )[0]))
first = min(res[0]['tsp'][0], res[1]['tsp'][0])
for i, timestamp in enumerate(res[0]['tsp']):
res[0]['tsp'][i] = timestamp - first
for i, timestamp in enumerate(res[1]['tsp']):
res[1]['tsp'][i] = timestamp - first
_, axplt = plt.subplots()
axplt.set_xlabel('Time (s)')
axplt.set_ylabel('RTT (ms)')
axplt.plot(res[0]['tsp'], res[0]['pqt'], color='tab:red', label='Slice A')
axplt.plot(res[1]['tsp'], res[1]['pqt'], color='tab:blue', label='Slice B')
axplt.autoscale_view()
axplt.legend()
plt.savefig(arguments.output)
print(f'plot saved in {arguments.output}')

if __name__ == '__main__':
parser = argparse.ArgumentParser(
prog='policy_diff',
description='Convert ping result into plot'
)
parser.set_defaults(func=plot)
parser.add_argument('slicea', type=pathlib.Path,
help='ping result file')
parser.add_argument('sliceb', type=pathlib.Path,
help='ping result file')
parser.add_argument('output', type=pathlib.Path,
help='output file')

args = parser.parse_args()
args.func(args)
2 changes: 1 addition & 1 deletion templates/compose.yaml.j2
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ services:
ran: # automatic allocation by docker compose

#~ if config["topology"]["nb_ue"] > 1
{{ container_s(name='ue2', image='louisroyer/ueransim-ue', enable_ipv6=True, debug='always', iface_tun=True, cap_net_admin=True, init=True) }}
{{ container_s(name='ue2', image='louisroyer/ueransim-ue', enable_ipv6=True, debug='always', debug_volume=True, iface_tun=True, cap_net_admin=True, init=True) }}
depends_on:
amf:
condition: service_started
Expand Down
Loading