This is a local implentation of the NEF emulator proposed by EVOLVED-5G.
Host prerequisites: docker
, docker-compose 1.29.2
, build-essential
*, jq
**
After cloning the repository, there are 4 more steps to do. For convinience, we have created a Makefile
that contains a command for each step + several common docker-compose
tasks which you may find handy in the future.
- create your local
.env
file - build the container images
- run the containers
- add some test data (optional)
cd NEF_emulator
# 1.
make prepare-dev-env
# 2.
make build
# 3.
make up
# 4.
make db-init
* π‘ Info: To use the
make
command you need toapt install build-essential
first. In case you don't want to proceed with this installation, you can head over to theMakefile
and copy/paste the shell commands that are being used for every step.
** π‘ Info: The shell script used at step 4 (for adding test data) uses
jq
which is a lightweight and flexible command-line JSON processor. You can install it withapt install jq
Host prerequisites: docker
, docker registry
*, kubernetes cluster
, helm
After cloning the repository, there are more X steps to do. For convinience, we have created a bash script run-helm.sh
that automatically builds the docker images, pushes them to the docker registry, and installs the helm chart.
./run-helm.sh -n <namespace> -r <release-name> -d <docker-registry>
docker run -d -p 5000:5000 --name registry registry:2.7
* π‘ Info: The default docker registry used in the helm values is a local docker registry created using
docker run -d -p 5000:5000 --name registry registry:2.7
.
After the containers are up and running:
- access and start playing with the Swager UI at: localhost:8888/nef/docs
- login to the admin dashboard at: localhost:8888/login
- Default credentials:
admin@my-email.com
/pass
- they can be found/changed inside your
.env
file
- Default credentials:
For more in-depth details about the initial NEF emulator configuration, please visit the original repository medianetlab/NEF_emulator.
5GASP guidelines and extensions
A key part of enmpowering the idea-to-market process in 5G Network Applications (NetApps) is to prove their 5G readinees. In 5GASP we propose the use of NEF to test the interaction between NetApps and 5G functionalies. We have tested and extended some capabilities from the NEF emulator prposed by the EVOLVED-5G project. Some quick guidelines for a local deployment are described next:
Super user credentials
- Username = admin@my-email.com
- Password = pass
curl --location --request POST 'http://{url}/api/v1/login/access-token' \
--header 'Accept: application/json' \
--header 'Content-Type: application/x-www-form-urlencoded' \
--data-raw 'grant_type=&username=admin%40my-email.com&password=pass&scope=&client_id=&client_secret='
please replace {url}
with the address where the NEF emulator is running. If the request is successful, you will get an access_token
and a token_type
.
curl --location --request POST 'http://{url}/api/v1/login/test-token' \
--header 'Accept: application/json' \
--header 'Content-Type: application/x-www-form-urlencoded' \
--header 'Authorization: Bearer {access_token}'
replace access_token
with the value obtained in the previous step. If the request is successfull, details about the user will be returned.
curl --location --request GET 'http://{url}/api/v1/UEs/{supi}' \
--header 'Accept: application/json' \
--header 'Authorization: Bearer {access_token}'
Replace supi
with the UE ID from the emulator.
curl --location --request GET 'http://{url}api/v1/UEs/{supi}/serving_cell' \
--header 'Accept: application/json' \
--header 'Authorization: Bearer {token}'
Replace supi
with the UE ID from the emulator.
Based on Haversine formula that determines the great-circle distance between two points on a sphere given their longitudes and latitudes.
curl --location --request GET 'http://{url}api/v1/UEs/{supi}/distances' \
--header 'Accept: application/json' \
--header 'Authorization: Bearer {token}'
Replace supi
with the UE ID from the emulator.
Based on the formula:
curl --location --request GET 'http://{url}api/v1/UEs/{supi}/path_losses' \
--header 'Accept: application/json' \
--header 'Authorization: Bearer {token}'
Replace supi
with the UE ID from the emulator.
Based on the simplified formula:
curl --location --request GET 'http://{url}api/v1/UEs/{supi}/rsrps' \
--header 'Accept: application/json' \
--header 'Authorization: Bearer {token}'
Replace supi
with the UE ID from the emulator.
Below, you may find different options for establishing a bi-directional communication over HTTP between the NetApp and the NEF_emulator (for example to be used for callbacks
).
If you develop your NetApp directly on the host, for example a Flask
app running on port 9999
:
- you will be able to connect to the NEF_emulator at:
http://localhost:8888
- the NEF_emulator will not be able to connect to
http://localhost:9999
because "localhost" for a container is itself, not the host. - to overcome the above problem, Docker provides
host.docker.internal
- the NEF_emulator will be able to connect to
http://host.docker.internal:9999
- β make sure you bind your NetApp on
0.0.0.0:[port]
and not only on127.0.0.1:[port]
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β HOST β
β β
β βββββββββββββββββββββββββββββββββ β
β NetApp β docker-compose network β β
β β βββββββββββββββββββββββββββββββββ€ β
β β β NEF_emulator containers β β
β β β live here β β
β β βββ :80 ββββββββββββββ :5050 ββββ β
β β β β β
β β β β β
βββββββ :9999 βββββββββββββ :8888 βββββββββββββ :5050 βββββββββββ
β β
ββ< communication >ββ
If you develop your NetApp as a container, the easiest way to establish a bi-directional communication would be to attach
it to the pre-existing bridge network that the NEF_emulator containers use:
- this bridge network is automatically created whenever you
docker-compose up
a project, in our case that would probably be named asnef_emulator_default
- Docker will provide automatic DNS resolution between these containers names
- your NetApp will be able to connect to the NEF_emulator at
http://backend
- the NEF_emulator will be able to connect to your NetApp at
http://your_netapp_container_name:9999
- β make sure you use the container ports directly, not the
published
ones - β make sure you first
docker-compose up
the NEF_emulator and thenattach
your NetApp container - more details at Docker docs: Use bridge networks and Networking in Compose
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β HOST β
β β
β βββββββββββββββββββββββββββββββββββββββββββββββββββββ β
β β docker-compose network β β
β βββββββββββββββββββββββββββββββββββββββββββββββββββββ€ β
β β β β
β β NetApp NEF_emulator containers β β
β β also lives here live here β β
β β β β
β ββββ :9999 ββββββββββββ :80 ββββββββββββββ :5050 ββββ β
β β β β β
β ββ< communication >ββ€ β β
β β β β β
β β β β β
βββββββ :9999 βββββββββββββ :8888 βββββββββββββ :5050 βββββββββββ
Three possible ways to achieve the above approach:
-
with docker, try the
--net=...
option and provide the bridge name that you want toattach
to:docker container run --net=nef_emulator_default ...
-
with docker-compose, try adding the bridge as an external network, something like:
services: .... netapp: .... networks: - nef_emulator_default networks: nef_emulator_default: external: true
-
with docker network connect, try adding your container to the bridge network:
docker network connect BRIDGE_NAME NETAPP_NAME