Skip to content

Commit

Permalink
Merge pull request #28 from nextmn/issue24
Browse files Browse the repository at this point in the history
Ability to use Free5GC's UPF (via config.yaml)
  • Loading branch information
louisroyer authored Jul 9, 2024
2 parents 7a608a4 + ee5c2fa commit 510d538
Show file tree
Hide file tree
Showing 3 changed files with 123 additions and 53 deletions.
32 changes: 27 additions & 5 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,9 @@

PROFILES = --profile debug
PROJECT_DIRECTORY = --project-directory build
MAKE = make --no-print-directory

.PHONY: default u d t j e t l lf test clean build
.PHONY: default u d t j e t l lf clean build setf5gc setnextmn test testf5gc testnextmn
build: build/compose.yaml

clean:
Expand All @@ -17,22 +18,43 @@ build/compose.yaml: templates/compose.yaml.j2 scripts/jinja/customize.py config.
@mkdir -p build
@j2 --customize scripts/jinja/customize.py -o build/compose.yaml templates/compose.yaml.j2 config.yaml

test: build
test:
@echo [1/2] Running tests for Free5GC config
@$(MAKE) clean
@$(MAKE) testf5gc
@echo [2/2] Running tests for NextMN config
@$(MAKE) clean
@$(MAKE) testnextmn

testnextmn: setnextmn build
@echo Running yamllint
@yamllint build config.yaml
@echo Running docker compose config
@docker compose $(PROJECT_DIRECTORY) config >/dev/null
testf5gc: setf5gc build
@echo Running yamllint
@yamllint build config.yaml
@echo Running docker compose config
@docker compose $(PROJECT_DIRECTORY) config >/dev/null

setf5gc:
@echo Set use_free5gc_upf to true
@sed -i 's/use_free5gc_upf: false/use_free5gc_upf: true/g' config.yaml
setnextmn:
@echo Set use_free5gc_upf to false
@sed -i 's/use_free5gc_upf: true/use_free5gc_upf: false/g' config.yaml

j: build

pull: build/*
pull: build
@echo Pulling Docker images
@docker compose $(PROFILES) $(PROJECT_DIRECTORY) pull

u: build/*
u: build
@# set containers up
@docker compose $(PROFILES) $(PROJECT_DIRECTORY) up -d

u-fg: build/*
u-fg: build
@# set containers up in foreground
@docker compose $(PROFILES) $(PROJECT_DIRECTORY) up

Expand Down
2 changes: 2 additions & 0 deletions config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
# Use of this source code is governed by a MIT-style license that can be
# found in the LICENSE file.
# SPDX-License-Identifier: MIT
use_free5gc_upf: false # Use Free5GC UPFs instead of NextMN SRv6
nb_ue: 1
subnets:
ran:
gnb1:
Expand Down
142 changes: 94 additions & 48 deletions templates/compose.yaml.j2
Original file line number Diff line number Diff line change
Expand Up @@ -25,25 +25,27 @@ services:
networks:
ran: # automatic allocation by docker compose

{{ container_s(name='ue2', image='louisroyer/ueransim-ue', ipv6=True, debug=True, iface_tun=True, cap_net_admin=True, init=True) | comment }}
# environment:
# MSISDN: "0000000002"
# GNBS: |-
# - "{{ ipv6('gnb2', 'ran') }}"
# CONFIGURED_NSSAI: |-
# - sst: 1
# sd: 000001
# DEFAULT_NSSAI: |-
# - sst: 1
# sd: 000001
# SESSIONS: |-
# - type: "IPv4"
# apn: "srv6"
# slice:
# sst: 1
# sd: 000001
# networks:
# ran: # automatic allocation by docker compose
#~ if nb_ue > 1
{{ container_s(name='ue2', image='louisroyer/ueransim-ue', ipv6=True, debug=True, iface_tun=True, cap_net_admin=True, init=True) }}
environment:
MSISDN: "0000000002"
GNBS: |-
- "{{ ipv6('gnb2', 'ran') }}"
CONFIGURED_NSSAI: |-
- sst: 1
sd: 000001
DEFAULT_NSSAI: |-
- sst: 1
sd: 000001
SESSIONS: |-
- type: "IPv4"
apn: "srv6"
slice:
sst: 1
sd: 000001
networks:
ran: # automatic allocation by docker compose
#~ endif

{{ container_s(name='gnb1', image='louisroyer/ueransim-gnb', ipv6=True, restart='always', iface_tun=True, cap_net_admin=True, debug=True) }}
depends_on:
Expand Down Expand Up @@ -75,35 +77,37 @@ services:
dataplane:
ipv4_address: "{{ ipv4('gnb1', 'dataplane') }}"

{{ container_s(name='gnb2', image='louisroyer/ueransim-gnb', ipv6=True, restart='always', iface_tun=True, cap_net_admin=True, debug=True) |comment}}
# depends_on:
# amf:
# condition: service_started
# environment:
# NCI: 000000002
# RLS_IP: "{{ ipv6('gnb2', 'ran') }}"
# N2_IP: "{{ ipv4('gnb2', 'control') }}"
# N3_IP: "{{ ipv4('gnb2', 'dataplane') }}"
# SUPPORTED_NSSAIS: |-
# - sst: 1
# sd: 000001
# MCC: "001"
# MNC: "01"
# ID_LEN: 32
# TAC: 1
# AMF_CONFIGS: |-
# - address: "{{ ipv4('amf', 'control') }}"
# port: 38412
# ROUTES_INIT: |-
# - add {{ ipv4('srgw0', 'srgw0') }} via {{ ipv4('srgw0', 'dataplane') }}
# networks:
# ran:
# ipv4_address: "{{ ipv4('gnb2', 'ran') }}"
# ipv6_address: "{{ ipv6('gnb2', 'ran') }}"
# control:
# ipv4_address: "{{ ipv4('gnb2', 'control') }}"
# dataplane:
# ipv4_address: "{{ ipv4('gnb2', 'dataplane') }}"
#~ if nb_ue > 1
{{ container_s(name='gnb2', image='louisroyer/ueransim-gnb', ipv6=True, restart='always', iface_tun=True, cap_net_admin=True, debug=True) }}
depends_on:
amf:
condition: service_started
environment:
NCI: 000000002
RLS_IP: "{{ ipv6('gnb2', 'ran') }}"
N2_IP: "{{ ipv4('gnb2', 'control') }}"
N3_IP: "{{ ipv4('gnb2', 'dataplane') }}"
SUPPORTED_NSSAIS: |-
- sst: 1
sd: 000001
MCC: "001"
MNC: "01"
ID_LEN: 32
TAC: 1
AMF_CONFIGS: |-
- address: "{{ ipv4('amf', 'control') }}"
port: 38412
ROUTES_INIT: |-
- add {{ ipv4('srgw0', 'srgw0') }} via {{ ipv4('srgw0', 'dataplane') }}
networks:
ran:
ipv4_address: "{{ ipv4('gnb2', 'ran') }}"
ipv6_address: "{{ ipv6('gnb2', 'ran') }}"
control:
ipv4_address: "{{ ipv4('gnb2', 'control') }}"
dataplane:
ipv4_address: "{{ ipv4('gnb2', 'dataplane') }}"
#~ endif

{{ container_s(name='amf', image='louisroyer/dev-free5gc-amf', restart='always') }}
depends_on:
Expand Down Expand Up @@ -362,6 +366,7 @@ services:
sbi:
ipv4_address: "{{ ipv4('nssf', 'sbi') }}"

#~ if not use_free5gc_upf
{{ container_s(name='r0', image='louisroyer/dev-nextmn-srv6', restart='always', srv6=True, debug=True) }}
depends_on:
srv6-ctrl:
Expand Down Expand Up @@ -420,7 +425,9 @@ services:
POSTGRES_PASSWORD_FILE: /run/secrets/r0_db_password
networks:
nextmndb:
#~ endif

#~ if not use_free5gc_upf
{{ container_s(name='r1', image='louisroyer/dev-nextmn-srv6', restart='always', srv6=True, debug=True ) }}
depends_on:
srv6-ctrl:
Expand Down Expand Up @@ -479,7 +486,9 @@ services:
POSTGRES_PASSWORD_FILE: /run/secrets/r1_db_password
networks:
nextmndb:
#~ endif

#~ if not use_free5gc_upf
{{ container_s(name='rr', image='louisroyer/dev-nextmn-srv6', restart='always', srv6=True, debug=True ) }}
depends_on:
srv6-ctrl:
Expand Down Expand Up @@ -529,7 +538,9 @@ services:
POSTGRES_PASSWORD_FILE: /run/secrets/rr_db_password
networks:
nextmndb:
#~ endif

#~ if not use_free5gc_upf
{{ container_s(name='srgw0', image='louisroyer/dev-nextmn-srv6', restart='always', srv6=True, debug=True ) }}
depends_on:
srv6-ctrl:
Expand Down Expand Up @@ -587,7 +598,9 @@ services:
POSTGRES_PASSWORD_FILE: /run/secrets/srgw0_db_password
networks:
nextmndb:
#~ endif

#~ if not use_free5gc_upf
{{ container_s(name='srv6-ctrl', image='louisroyer/dev-nextmn-srv6-ctrl', restart='always') }}
environment:
DEBUG: "true"
Expand All @@ -598,6 +611,7 @@ services:
control:
ipv4_address: "{{ ipv4('srv6-ctrl', 'control') }}"
ipv6_address: "{{ ipv6('srv6-ctrl', 'control') }}"
#~ endif

{{ container_setup_s(name='s0') }}
environment:
Expand Down Expand Up @@ -643,6 +657,37 @@ services:
edge:
ipv4_address: "{{ ipv4('s1', 'edge') }}"

#~ if use_free5gc_upf
{{ container_s(name='upf', image='louisroyer/dev-free5gc-upf', restart='always', cap_net_admin=true) }}
environment:
DEBUG: "true"
N4: "{{ ipv4('srv6-ctrl', 'control') }}"
IF_LIST: |-
- addr: "{{ ipv4('srgw0', 'srgw0') }}"
type: N3
DNN_LIST: |-
- dnn: srv6
cidr: {{ ipv4_subnet('slice0') }}
ROUTES_INIT: |-
- add {{ ipv4('s', 'service') }} via {{ ipv4('s1', 'edge') }}
PRE_INIT_HOOK: "ip"
PRE_INIT_HOOK_0: "addr"
PRE_INIT_HOOK_1: "add"
PRE_INIT_HOOK_2: "{{ ipv4('srgw0', 'srgw0') }}"
PRE_INIT_HOOK_3: "dev"
PRE_INIT_HOOK_4: "dataplane-0"
networks:
control:
ipv4_address: "{{ ipv4('srv6-ctrl', 'control') }}"
ipv6_address: "{{ ipv6('srv6-ctrl', 'control') }}"
dataplane:
ipv4_address: "{{ ipv4('srgw0', 'dataplane') }}"
ipv6_address: "{{ ipv6('srgw0', 'dataplane') }}"
edge:
ipv4_address: "{{ ipv4('r0', 'edge') }}"
#~ endif

#~ if not use_free5gc_upf
secrets:
rr_db_password:
file: "{{ secret('rr_db_password.txt') }}"
Expand All @@ -652,6 +697,7 @@ secrets:
file: "{{ secret('r1_db_password.txt') }}"
srgw0_db_password:
file: "{{ secret('srgw0_db_password.txt') }}"
#~ endif

networks:
ran:
Expand Down

0 comments on commit 510d538

Please sign in to comment.