blob: 59f5f584277d509b503b9082f74c97f06bff9a21 [file] [log] [blame]
Neels Hofmeyr697a6172018-08-22 17:32:21 +02001=== WHAT IS THIS?
2
3* quickly configure, launch and tear down an entire Osmocom core network on
4 your box (see net/README).
5
6This is the set of tools I wrote for myself and use every day to run and test
7the Osmocom core network. I hope this helps, and I would appreciate
8contributions of any improvements you may have!
9
10
11=== Quick Start
12
Oliver Smithb252b4a2022-02-25 12:36:53 +010013* Open config_2g3g in a text editor (original config)
14* Open a new file in a text editor (your config)
15* Copy over all lines you want to change in your config and edit them there
16* Your resulting minimal config could look like this:
Neels Hofmeyr697a6172018-08-22 17:32:21 +020017
Oliver Smithb252b4a2022-02-25 12:36:53 +010018 TERMINAL="tmux"
Neels Hofmeyr697a6172018-08-22 17:32:21 +020019
Oliver Smithb252b4a2022-02-25 12:36:53 +010020 ETH_DEV=enp0s25
Neels Hofmeyr697a6172018-08-22 17:32:21 +020021
Oliver Smithb252b4a2022-02-25 12:36:53 +010022 TO_RAN_IP="192.168.1.123"
23 TO_RAN_IU_IP="192.168.1.42"
Neels Hofmeyr697a6172018-08-22 17:32:21 +020024
Oliver Smithb252b4a2022-02-25 12:36:53 +010025 MCC=999
26 MNC=99
Neels Hofmeyr697a6172018-08-22 17:32:21 +020027
Oliver Smithb252b4a2022-02-25 12:36:53 +010028 BTS0_IPA_UNIT="1234 0"
29 BTS0_ARFCN=800
30
31* Create a network directory and generate configs:
32
33 $ mkdir my_network
34 $ cd my_network
35 $ ../fill_config.py ../config_mine ../templates
36
37* Run the network:
38
39 $ ./run.sh
40
41 This launches numerous terminals with one component running in each.
42 Logs and pcap traces are being taken automatically.
43
44* Tear down:
45
46 Hit enter in the original first terminal to tear down all programs.
47 Enter a name to save logs, otherwise all logging will be stored
48 under autolog/<timestamp>.
49
50* Regenerate configs:
51
52 Modify your config and regenerate the network configs as follows, the same
53 original config, your config and templates will be used as last time.
54
55 $ $EDITOR ../config_mine
56 $ ../fill_config.py
57
58 ('make regen' also works)
59
60
61=== Advanced usage / more examples
Neels Hofmeyr697a6172018-08-22 17:32:21 +020062
63# own templates?
Neels Hofmeyrcbdd7182019-03-04 00:39:32 +010064cp -r ../templates ../templates_mine
65$EDITOR ../templates_mine/*
66../fill_config.py ../templates_mine
67# picks up same ../config_mine from last time, and ../templates_mine from cmdline
Neels Hofmeyr697a6172018-08-22 17:32:21 +020068
69
Neels Hofmeyr5a9bf172018-08-23 15:31:44 +020070If you wanted to change to dynamic timeslots, you can:
71
72cd ..
Neels Hofmeyrcbdd7182019-03-04 00:39:32 +010073mkdir templates_dyn
74cd templates_dyn
75ln -s ../templates/* .
Neels Hofmeyr5a9bf172018-08-23 15:31:44 +020076rm ./osmo-bsc.cfg
Neels Hofmeyrcbdd7182019-03-04 00:39:32 +010077cp ../templates/osmo-bsc.cfg .
Neels Hofmeyr5a9bf172018-08-23 15:31:44 +020078sed -i 's#TCH/F#TCH/F_TCH/H_PDCH#' osmo-bsc.cfg
79
80cd ../my_network
Neels Hofmeyrcbdd7182019-03-04 00:39:32 +010081../fill_config.py ../templates_dyn
Neels Hofmeyr5a9bf172018-08-23 15:31:44 +020082
83
84If you moved your laptop to a different location, you can:
85
86cp ../config_mine ../config_foo
87$EDITOR ../config_foo # set new IP address(es)
88../fill_config.py ../config_foo
89
Neels Hofmeyr697a6172018-08-22 17:32:21 +020090
91=== Config file templates
92
93A *directory* contains template files that are filled with specific values by the
Neels Hofmeyrcbdd7182019-03-04 00:39:32 +010094fill_config.py script. See e.g. templates/.
Neels Hofmeyr697a6172018-08-22 17:32:21 +020095
Neels Hofmeyr5a9bf172018-08-23 15:31:44 +020096A *file* contains local config items as name=val pairs that are put into the
Oliver Smithb252b4a2022-02-25 12:36:53 +010097templates. It is usually a subset of config_2g3g.
Neels Hofmeyr697a6172018-08-22 17:32:21 +020098
Neels Hofmeyr57e42882018-08-23 15:19:35 +020099The fill_config.py script helps to fill the templates with the config values. Simply
100invoke fill_config.py with a dir argument (templates dir) and a file argument (specific
Oliver Smithfd7446f2018-10-22 11:59:55 +0200101config values). The dir argument can be used in the templates with ${NET_DIR},
102temporary files (sockets etc.) should be placed inside this folder.
Neels Hofmeyr697a6172018-08-22 17:32:21 +0200103
104If one or both are omitted, the script tries to re-use the most recent paths,
105they were stored in local files '.last_config' and '.last_templates'.
106
Oliver Smithb252b4a2022-02-25 12:36:53 +0100107The -o parameter of fill_config.py can be used to supply a different original
108config file than config_2g3g. If it is omitted, the path is read from a
109'.last_config_orig' file inside the network directory if present, and config_2g3g
110is used otherwise.
111
Neels Hofmeyr697a6172018-08-22 17:32:21 +0200112The result is a complete set of .cfg files that match your local machine and
113network config.
114
115
116=== Launch
117
Neels Hofmeyrcbdd7182019-03-04 00:39:32 +0100118A run.sh script template (templates/run.sh) also gets filled with specifics and
Neels Hofmeyr697a6172018-08-22 17:32:21 +0200119placed next to the .cfg files.
120
121run.sh uses sudo to start tcpdump, configure ip forwarding and masquerading
122(for the GGSN's APN tunnel required for data services).
123
124When you launch run.sh, many xterms are launched, and when hitting enter, all
125of them get destroyed again. This is obviously intended to be run on your
Oliver Smithb2a83f72022-02-25 12:49:17 +0100126desktop computer or laptop, not on a remote box.
127
128It's also possible to set TERMINAL="tmux" in your network configuration, then
129run.sh starts a tmux session and runs each Osmocom program as own tmux window
130inside that session. Switch to the first window (^B + 0) and hit enter to close
131all windows and the whole tmux session. This does work over SSH.
Neels Hofmeyr697a6172018-08-22 17:32:21 +0200132
133
Oliver Smithef92c182022-03-08 09:33:39 +0100134=== Wrap commands in gdb, valgrind, udtrace etc.
135
136During development it's useful to wrap Osmocom programs inside gdb, valgrind or
137other tools. For each program where you want to do this, copy the CMD_ line
138from config_2g3g to your config and adjust it accordingly.
139
140==== Examples: gdb, valgrind, strace
141
142CMD_MSC="LD_LIBRARY_PATH=/usr/local/lib gdb -ex run --args osmo-msc"
143CMD_MSC="valgrind osmo-msc"
144CMD_MSC="strace osmo-msc"
145
146==== Example: udtrace
147
148To use udtrace on the MNCC socket, use the following with an adjusted
149/path/to/udtrace. Explanation of the enviornment variables:
150- LD_LIBRARY_PATH allows linking to titan if udtrace was compiled with titan
151 support
152- LD_PRELOAD of libasan allows building osmo-msc with the sanitize.opts
153- the tee saves the stderr logging as well as the udtrace output to new file
154 current_log/osmo-msc.out, since udtrace will not show in osmo-msc.log
155
156CMD_MSC="LD_LIBRARY_PATH=/usr/lib/titan LD_PRELOAD=/usr/lib/x86_64-linux-gnu/libasan.so.5:/path/to/udtrace/libudtrace.so osmo-msc 2>&1 | tee -a current_log/osmo-msc.out"
157
158
Neels Hofmeyr697a6172018-08-22 17:32:21 +0200159=== Logging and pcaps
160
161The run.sh script automatically stores all configs, logs and pcap traces in
162./autolog/<timestamp> dirs. After closing the components (by hitting enter),
163you may also enter a name for the logs, after which they are stored in
164./logs/<name>. The idea is to keep all important logs with a name, and that you
165can every now and then just 'rm -rf ./autolog' to make space.
166
167
168=== 3G
169
170You may notice that the templates include nano3G.txt files. These include a
171convenient listing of commands to connect to an ip.access nano3G DMI and
172connect it to the HNBGW as configured by the templates.
173
174
175=== 2G BTS
176
Oliver Smith321a47c2022-02-21 16:25:37 +0100177You can either let osmo-dev run osmo-bts-virtual, or connect a real BTS to the
178BSC + CN started by osmo-dev.
Neels Hofmeyr697a6172018-08-22 17:32:21 +0200179
Oliver Smith321a47c2022-02-21 16:25:37 +0100180To start osmo-bts-virtual, set BTS0_RUN_IN_OSMO_DEV=1 and/or
181BTS1_RUN_IN_OSMO_DEV=1 in your copy of config_2g3g.
182
183To connect your real BTS, typically you'd need to edit only the
184/etc/osmocom/osmo-bts.cfg to match your IP address and ipa unit-id:
Neels Hofmeyr697a6172018-08-22 17:32:21 +0200185
186bts 0
Neels Hofmeyr5a9bf172018-08-23 15:31:44 +0200187 oml remote-ip 192.168.0.23
188 ipa unit-id 1234 0