20210910のLinuxに関する記事は4件です。

教養としての5GC(free5gc+UERANSIMで学ぶ5Gコアネットワーク)その4

前回まではfree5gcをInstallしテストコールを行い取得したキャプチャを詳しく見る事によって5GCとは何かをみてきました。 今回はUERANSIMというUE+gNodeBのシュミレーターをInstallしてみます。大体30分くらいかかるかと思います。 1. UERANSIM Install これまた優れたシュミレーターです。公式はこちら。 1.1 Network Diagram Host PC上にVMをもう一つ作成し以下の様な構成のネットワークを構築します。 1.2 VM Clone 今回はfree5gcで使ったVMをクローンしたVMにueransim入れてみます。 ますはVirtualBoxのメニューからVMのクローン。 ホストネームとIPアドレスを変更しrebootします。 q14537@free5gc:~$ sudo hostname ueransim [sudo] password for q14537: q14537@free5gc:~$ cat /etc/hostname free5gc q14537@free5gc:~$ sudo vi /etc/hostname q14537@free5gc:~$ cat /etc/hosts 127.0.0.1 localhost 127.0.1.1 free5gc # The following lines are desirable for IPv6 capable hosts ::1 ip6-localhost ip6-loopback fe00::0 ip6-localnet ff00::0 ip6-mcastprefix ff02::1 ip6-allnodes ff02::2 ip6-allrouters q14537@free5gc:~$ sudo vi /etc/hosts q14537@free5gc:~$ cat /etc/hosts 127.0.0.1 localhost 127.0.1.1 ueransim # The following lines are desirable for IPv6 capable hosts ::1 ip6-localhost ip6-loopback fe00::0 ip6-localnet ff00::0 ip6-mcastprefix ff02::1 ip6-allnodes ff02::2 ip6-allrouters q14537@free5gc:~$ cat /etc/hostname ueransim q14537@free5gc:~$ vi /etc/ Display all 190 possibilities? (y or n) q14537@free5gc:~$ vi /etc/ne netplan/ network/ networkd-dispatcher/ networks newt/ q14537@free5gc:~$ sudo vi /etc/netplan/00-installer-config.yaml q14537@free5gc:~$ cat /etc/netplan/00-installer-config.yaml # This is the network config written by 'subiquity' network: ethernets: enp0s3: dhcp4: true enp0s8: addresses: - 192.168.56.102/24 # gateway4: 192.168.56.1 nameservers: addresses: [] search: [] version: 2 1.3 UERANSIM Install Insatall手順はこちらの通りなのですが、そのまま実行すると以下の様にcmakeのversionが古いと怒られます。 q14537@ueransim:~$ cd UERANSIM/ q14537@ueransim:~/UERANSIM$ make rm -fr logs # Old version log files mkdir -p build rm -fr build/* # cmake -DCMAKE_BUILD_TYPE=Debug -G "CodeBlocks - Unix Makefiles" . -B cmake-build-debug cmake -DCMAKE_BUILD_TYPE=Release -G "CodeBlocks - Unix Makefiles" . -B cmake-build-release CMake Error at CMakeLists.txt:1 (cmake_minimum_required): CMake 3.17 or higher is required. You are running version 3.16.3 -- Configuring incomplete, errors occurred! make: *** [makefile:10: build] Error 1 仕方がないのでちょっとだけ時間かかりますが新しいcmakeをコンパイルします。 そのままだとまたしても以下の様にSSL Development packageがないとか怒られるので、先にSSLのパッケージをいれておきます。 -- Could NOT find OpenSSL, try to set the path to OpenSSL root folder in the system variable OPENSSL_ROOT_DIR (missing: OPENSSL_CRYPTO_LIBRARY OPENSSL_INCLUDE_DIR) CMake Error at Utilities/cmcurl/CMakeLists.txt:525 (message): Could not find OpenSSL. Install an OpenSSL development package or configure CMake with -DCMAKE_USE_OPENSSL=OFF to build without OpenSSL. sudo apt-get install libssl-dev wget https://github.com/Kitware/CMake/releases/download/v3.21.2/cmake-3.21.2.tar.gz そしてbootstrapしてmakeしてmake installします。 q14537@ueransim:~/cmake-3.21.2$ ./bootstrap q14537@ueransim:~/cmake-3.21.2$ make q14537@ueransim:~/cmake-3.21.2$ sudo make install 新しいVersionのcmakeが入ったらUERANSIMのコンパイル。うまくコンパイル出来るとbuild配下に以下のコマンドが出来上がります。 UERANSIM successfully built. q14537@ueransim:~/UERANSIM$ pwd /home/q14537/UERANSIM q14537@ueransim:~/UERANSIM$ ls build cmake-build-release CMakeLists.txt config LICENSE makefile README.md src tools q14537@ueransim:~/UERANSIM$ cd build/ q14537@ueransim:~/UERANSIM/build$ ls libdevbnd.so nr-binder nr-cli nr-gnb nr-ue 1.4 UERANSIM Configuration コンフィグの手順は公式サイトの以下に記載してあります。 free5gcとインテグするためのコンフィグファイルが用意されています。 以下gNodeB用。PLMNIDにいくつを使うか、どのAMFと接続するか等々書いてあります。 q14537@ueransim:~/UERANSIM/config$ cat free5gc-gnb.yaml mcc: '208' # Mobile Country Code value mnc: '93' # Mobile Network Code value (2 or 3 digits) nci: '0x000000010' # NR Cell Identity (36-bit) idLength: 32 # NR gNB ID length in bits [22...32] tac: 1 # Tracking Area Code linkIp: 127.0.0.1 # gNB's local IP address for Radio Link Simulation (Usually same with local IP) ngapIp: 127.0.0.1 # gNB's local IP address for N2 Interface (Usually same with local IP) gtpIp: 127.0.0.1 # gNB's local IP address for N3 Interface (Usually same with local IP) # List of AMF address information amfConfigs: - address: 127.0.0.1 port: 38412 # List of supported S-NSSAIs by this gNB slices: - sst: 0x1 sd: 0x010203 # Indicates whether or not SCTP stream number errors should be ignored. ignoreStreamIds: true 以下UE用。SUPIに何番を使うか、PLMNIDに何を設定するか、DNN(apnになってますが。。)は何を使うか等々設定できます。 q14537@ueransim:~/UERANSIM/config$ cat free5gc-ue.yaml # IMSI number of the UE. IMSI = [MCC|MNC|MSISDN] (In total 15 digits) supi: 'imsi-208930000000003' # Mobile Country Code value of HPLMN mcc: '208' # Mobile Network Code value of HPLMN (2 or 3 digits) mnc: '93' # Permanent subscription key key: '8baf473f2f8fd09487cccbd7097c6862' # Operator code (OP or OPC) of the UE op: '8e27b6af0e692e750f32667a3b14605d' # This value specifies the OP type and it can be either 'OP' or 'OPC' opType: 'OPC' # Authentication Management Field (AMF) value amf: '8000' # IMEI number of the device. It is used if no SUPI is provided imei: '356938035643803' # IMEISV number of the device. It is used if no SUPI and IMEI is provided imeiSv: '4370816125816151' # List of gNB IP addresses for Radio Link Simulation gnbSearchList: - 127.0.0.1 # UAC Access Identities Configuration uacAic: mps: false mcs: false # UAC Access Control Class uacAcc: normalClass: 0 class11: false class12: false class13: false class14: false class15: false # Initial PDU sessions to be established sessions: - type: 'IPv4' apn: 'internet' slice: sst: 0x01 sd: 0x010203 # Configured NSSAI for this UE by HPLMN configured-nssai: - sst: 0x01 sd: 0x010203 # Default Configured NSSAI for this UE default-nssai: - sst: 1 sd: 1 # Supported integrity algorithms by this UE integrity: IA1: true IA2: true IA3: true # Supported encryption algorithms by this UE ciphering: EA1: true EA2: true EA3: true # Integrity protection maximum data rate for user plane integrityMaxRate: uplink: 'full' downlink: 'full' 折角なのでPLMNIDをソフトバンク(MCC=440+MNC=20)に変更してfree5gcと接続してみましょう。 free5gc-ue.yamlの該当部分を編集します。接続先のgNodeBのアドレスも自分自身のアドレスである192.168.56.102に変更します。 q14537@ueransim:~/UERANSIM/build$ cat ../config/free5gc-ue.yaml # IMSI number of the UE. IMSI = [MCC|MNC|MSISDN] (In total 15 digits) supi: 'imsi-440200000000003' # Mobile Country Code value of HPLMN mcc: '440' # Mobile Network Code value of HPLMN (2 or 3 digits) mnc: '20' # Permanent subscription key key: '8baf473f2f8fd09487cccbd7097c6862' # Operator code (OP or OPC) of the UE op: '8e27b6af0e692e750f32667a3b14605d' # This value specifies the OP type and it can be either 'OP' or 'OPC' opType: 'OPC' # Authentication Management Field (AMF) value amf: '8000' # IMEI number of the device. It is used if no SUPI is provided imei: '356938035643803' # IMEISV number of the device. It is used if no SUPI and IMEI is provided imeiSv: '4370816125816151' # List of gNB IP addresses for Radio Link Simulation gnbSearchList: - 192.168.56.102 free5gc-gnb.yamlの方も編集します。ここで自分自身のアドレスを192.168.56.102、AMF向けのアドレスをfree5gcのVMのアドレス(192.168.56.103)に変更します。 mcc: '440' # Mobile Country Code value mnc: '20' # Mobile Network Code value (2 or 3 digits) nci: '0x000000010' # NR Cell Identity (36-bit) idLength: 32 # NR gNB ID length in bits [22...32] tac: 1 # Tracking Area Code linkIp: 192.168.56.102 # gNB's local IP address for Radio Link Simulation (Usually same with local IP) ngapIp: 192.168.56.102 # gNB's local IP address for N2 Interface (Usually same with local IP) gtpIp: 192.168.56.102 # gNB's local IP address for N3 Interface (Usually same with local IP) # List of AMF address information amfConfigs: - address: 192.168.56.103 port: 38412 これでUERANSIM側の準備は整いました。 2. free5gc側の変更 以下の様にconfigディレクトリ配下の各NFのコンフィグファイル内のPLMNIDをすべて書き換えます。 q14537@free5gc:~/free5gc/config$ egrep 'mcc|mnc' *.yaml |egrep '208|93' amfcfg.n3test.yaml: mcc: 208 # Mobile Country Code (3 digits string, digit: 0~9) amfcfg.n3test.yaml: mnc: 93 # Mobile Network Code (2 or 3 digits string, digit: 0~9) amfcfg.n3test.yaml: mcc: 208 # Mobile Country Code (3 digits string, digit: 0~9) amfcfg.n3test.yaml: mnc: 93 # Mobile Network Code (2 or 3 digits string, digit: 0~9) amfcfg.n3test.yaml: mcc: 208 # Mobile Country Code (3 digits string, digit: 0~9) amfcfg.n3test.yaml: mnc: 93 # Mobile Network Code (2 or 3 digits string, digit: 0~9) amfcfg.yaml: mcc: 208 # Mobile Country Code (3 digits string, digit: 0~9) amfcfg.yaml: mnc: 93 # Mobile Network Code (2 or 3 digits string, digit: 0~9) amfcfg.yaml: mcc: 208 # Mobile Country Code (3 digits string, digit: 0~9) amfcfg.yaml: mnc: 93 # Mobile Network Code (2 or 3 digits string, digit: 0~9) amfcfg.yaml: mcc: 208 # Mobile Country Code (3 digits string, digit: 0~9) amfcfg.yaml: mnc: 93 # Mobile Network Code (2 or 3 digits string, digit: 0~9) ausfcfg.yaml: - mcc: 208 # Mobile Country Code (3 digits string, digit: 0~9) ausfcfg.yaml: mnc: 93 # Mobile Network Code (2 or 3 digits string, digit: 0~9) nrfcfg.yaml: mcc: 208 # Mobile Country Code (3 digits string, digit: 0~9) nrfcfg.yaml: mnc: 93 # Mobile Network Code (2 or 3 digits string, digit: 0~9) nssfcfg.yaml: - mcc: 208 # Mobile Country Code (3 digits string, digit: 0~9) nssfcfg.yaml: mnc: 93 # Mobile Network Code (2 or 3 digits string, digit: 0~9) nssfcfg.yaml: mcc: 208 # Mobile Country Code (3 digits string, digit: 0~9) nssfcfg.yaml: mnc: 93 # Mobile Network Code (2 or 3 digits string, digit: 0~9) AMFに関してはgNodeBから接続してくるN2 Interfaceのアドレス(192.168.56.103)も変更します。 diff --git a/config/amfcfg.yaml b/config/amfcfg.yaml index 3fb2fa4..b6c4372 100644 --- a/config/amfcfg.yaml +++ b/config/amfcfg.yaml @@ -5,7 +5,7 @@ info: configuration: amfName: AMF # the name of this AMF ngapIpList: # the IP list of N2 interfaces on this AMF - - 127.0.0.1 + - 192.168.56.103 sbi: # Service-based interface information scheme: http # the protocol for sbi (http or https) registerIPv4: 127.0.0.18 # IP used to register to NRF @@ -20,18 +20,18 @@ configuration: servedGuamiList: # Guami (Globally Unique AMF ID) list supported by this AMF # <GUAMI> = <MCC><MNC><AMF ID> - plmnId: # Public Land Mobile Network ID, <PLMN ID> = <MCC><MNC> - mcc: 208 # Mobile Country Code (3 digits string, digit: 0~9) - mnc: 93 # Mobile Network Code (2 or 3 digits string, digit: 0~9) + mcc: 440 # Mobile Country Code (3 digits string, digit: 0~9) + mnc: 20 # Mobile Network Code (2 or 3 digits string, digit: 0~9) amfId: cafe00 # AMF identifier (3 bytes hex string, range: 000000~FFFFFF) supportTaiList: # the TAI (Tracking Area Identifier) list supported by this AMF - plmnId: # Public Land Mobile Network ID, <PLMN ID> = <MCC><MNC> - mcc: 208 # Mobile Country Code (3 digits string, digit: 0~9) - mnc: 93 # Mobile Network Code (2 or 3 digits string, digit: 0~9) + mcc: 440 # Mobile Country Code (3 digits string, digit: 0~9) + mnc: 20 # Mobile Network Code (2 or 3 digits string, digit: 0~9) tac: 1 # Tracking Area Code (uinteger, range: 0~16777215) plmnSupportList: # the PLMNs (Public land mobile network) list supported by this AMF - plmnId: # Public Land Mobile Network ID, <PLMN ID> = <MCC><MNC> - mcc: 208 # Mobile Country Code (3 digits string, digit: 0~9) - mnc: 93 # Mobile Network Code (2 or 3 digits string, digit: 0~9) + mcc: 440 # Mobile Country Code (3 digits string, digit: 0~9) + mnc: 20 # Mobile Network Code (2 or 3 digits string, digit: 0~9) snssaiList: # the S-NSSAI (Single Network Slice Selection Assistance Information) list supported by this AMF - sst: 1 # Slice/Service Type (uinteger, range: 0~255) sd: 010203 # Slice Differentiator (3 bytes hex string, range: 000000~FFFFFF) SMFもgNodeBから接続してくるUPFのN3/N4のアドレスを変更します。 diff --git a/config/smfcfg.yaml b/config/smfcfg.yaml index 586fe32..ec42f7b 100644 --- a/config/smfcfg.yaml +++ b/config/smfcfg.yaml @@ -58,7 +58,7 @@ configuration: interfaces: # Interface list for this UPF - interfaceType: N3 # the type of the interface (N3 or N9) endpoints: # the IP address of this N3/N9 interface on this UPF - - 127.0.0.8 + - 192.168.56.103 networkInstance: internet # Data Network Name (DNN) links: # the topology graph of userplane, A and B represent the two nodes of each link - A: gNB1 3. UERANSIMとfree5gcの接続 前回まではfree5gc上でtest.shを使ってコールテストを行いましたが、今回からは単独で5GC NF達を起動していきます。といっても面倒なのでrun.shというシェルスクリプトで起動していく事が出来ます。 free5gc側のVMでrun.shを実行 q14537@free5gc:~/free5gc$ ./run.sh NF達が各プロセスとして起動してます。 q14537 1170 994 0 16:04 pts/0 00:00:00 bash ./run.sh root 1171 1170 0 16:04 pts/0 00:00:00 sudo -E ./bin/free5gc-upfd root 1173 1171 0 16:04 pts/0 00:00:00 ./bin/free5gc-upfd q14537 1182 1170 0 16:04 pts/0 00:00:00 ./bin/nrf q14537 1190 1170 0 16:04 pts/0 00:00:00 ./bin/amf q14537 1200 1170 0 16:04 pts/0 00:00:00 ./bin/smf q14537 1206 1170 0 16:04 pts/0 00:00:00 ./bin/udr q14537 1215 1170 0 16:04 pts/0 00:00:00 ./bin/pcf q14537 1225 1170 0 16:04 pts/0 00:00:00 ./bin/udm q14537 1233 1170 0 16:04 pts/0 00:00:00 ./bin/nssf q14537 1241 1170 0 16:04 pts/0 00:00:00 ./bin/ausf ueransim側のVMで以下のコマンドを実行するとgNodeBとfree5gcが接続されます。 SCTPを使って192.168.56.103:38412に接続に行っている事がわかります。 q14537@ueransim:~/UERANSIM/build$ ./nr-gnb -c ../config/free5gc-gnb.yaml free5gc側でもgNodeB(192.168.56.102:39882)から接続要求が来た事が確認ができます。 Wiresharkでキャプチャを取ってみると以下の様に最初にSCTPのアソシエーションを確立(INIT,INIT_ACK,COOKIE_ECHO,COOKIE_ACKの4-way handshake)し、その後NGAPで接続要求をやりとりしているのが見えます。PLMNIDをSoftbankに変えたのでWiresharkもちゃんとSoftbankとしてデコードしてくれています。 ここまででueransim(gNodeB)とfree5gc(AMF)が接続されました。 4. UE電源ON!(Registration) ueransim側からue電源ONしてみます。 なんだかメッセージが出て「おっ!」と思うかもしれませんが、free5gc側では以下のエラーが出ます。 これはまだfree5gc側にUEの情報が登録されていないのでAUSFで認証をはじかれているのですね。なのでRegistrationが完了しません。 WiresharkでHTTP/2メッセージを見ると404 "User not found"がUDRから返ってきています。HTTPの404 Page Not Foundみたいですね。 5.最後に 今回はここまでです。UEの情報が5GC側に登録されていないと怒られてしまいました。ネットワーク側にちゃんと登録されていないSIMは勝手に使えないの仕組みはこういう事です。次回はfree5gc側でUEの情報を登録していきましょう。その5に続きます。
  • このエントリーをはてなブックマークに追加
  • Qiitaで続きを読む

【初心者エンジニア Presents】 よく使うLinuxコマンドメモ

目次 1. はじめに 2. 基本系 2.1. pwd 2.2. cd 2.3. ls 2.4. mkdir 2.5. cat 2.6. find 2.7. cp 2.8. mv 2.9. rm 2.10. ln 2.11. more 2.12. touch 3. 管理系 3.1. who 3.2. chmod 3.3. chown 3.4. chgrp 3.5. umask 3.6. su 4. 特徴的系 4.1. | 『パイプライン』 4.2. <, >, >> 『リダイレクト』 4.3. grep 4.4. sort 4.5. cut 4.6. tee 5. おわりに 1. はじめに こんにちは、初心者エンジニアです。 働く中でLinuxのコマンドがわからなくなり、調べてしまうことが多々あるため、メモとしてまとめることにしました。 テスト環境ということで、基本rootで行ってます。 オプション等はまた別の機会に... 2. 基本系 2.1. pwd カレントディレクトリを表示 Command # pwd /root 2.2. cd ディレクトリの変更 Command # cd /tmp # pwd /tmp 2.3. ls ディレクトリにあるファイル等を表示 Command # ls / bin dev home lib64 mnt proc run srv tmp var boot etc lib media opt root sbin sys usr 2.4. mkdir ディレクトリの作成 Command # mkdir test # ls -F test/ 2.5. cat ファイルの表示&連結 Command # cat test1 This is a pen. 2.6. find ファイル等の検索 Command # find ./test1 ./test1 2.7. cp ファイル等のコピー Command # mkdir /tmp/testdir # cp test1 /tmp/testdir # ls /tmp/testdir test1 2.8. mv ファイル等の移動&名前変更 Command # mv /tmp/testdir/test1 /tmp/testdir/test2 # ls /tmp/testdir test2 # mv /tmp/testdir/test2 /root # ls /root test1 test2 2.9. rm ファイル等の消去 Command # rm test2 rm: remove rehular file 'test2'? y # ls test1 2.10. ln ファイル等のリンクを作成 Command # pwd /tmp/testdir # ln -s /root/test1 testfile # ls -l lrwxrwxrwx 1 root root 11 xxxxxxxxx testfile -> /root/test1 2.11. more ファイルを画面ごとに表示 Command # more test1 2.12. touch ファイルのタイムスタンプを更新&無のファイル作成 Command # touch test2 # ls test1 test2 3. 管理系 3.1. who ログインしているユーザーを表示 Command # who root tty1 xxxxxxxxx 3.2. chmod ファイル等の権限変更 Command # ls -l -rw-r--r-- 1 root root 15 xxxxxxxxx test1 # chmod 755 test1 # ls -l -rwxr-xr-x 1 root root 15 xxxxxxxxx test1 3.3. chown ファイル等の所有者&グループ変更 Command # ls -l -rwxr-xr-x 1 root root 15 xxxxxxxxx test1 # chown user1 test1 # ls -l -rwxr-xr-x 1 user1 root 15 xxxxxxxxx test1 3.4. chgrp ファイル等のグループ変更 Command # ls -l -rwxr-xr-x 1 user1 root 15 xxxxxxxxx test1 # chgrp user1 test1 # ls -l -rwxr-xr-x 1 user1 user1 15 xxxxxxxxx test1 3.5. umask ファイル等を作成した時のデフォルト権限の確認&変更 Command # umask 0022 # umask 077 # umask 0077 3.6. su 別ユーザーでコマンド実行 Command # whoami user1 # cat /tmp/testdir/testfile cat: /tmp/testdir/testfile: Permission denied # su Password: # whoami root # cat /tmp/testdir/testfile This is a pen. 4. 特徴的系 4.1. | 『パイプライン』 コマンドを組み合わせる Command # ls test1 test2 # ls | grep test1 test1 4.2. <, >, >> 『リダイレクト』 別のコマンドやファイルに入力、出力を移行 Command # ls test1 test2 # ls > test3 # ls test1 test2 test3 # cat test3 test1 test2 test3 4.3. grep 絞り込み Command # cat test3 | grep test2 test2 4.4. sort 並び替え Command # cat test3 test1 test2 test3 # sort -r test3 test3 test2 test1 4.5. cut 切り取り Command # cat test1 This is a pen. #cut -c 3-7 test1 is is 4.6. tee 標準出力とファイル出力を行う Command # sort -r test3 | tee test4 test3 test2 test1 # ls test1 test2 test3 test4 5. おわりに 個人的な感想ですが、ここ数ヶ月ですっかりLinuxに魅了されました。 コマンドのボキャブラリーが増えたら、記事更新か別記事にまとめたいと思います。
  • このエントリーをはてなブックマークに追加
  • Qiitaで続きを読む

Gravio 4でSlackにホスト名を埋め込んだメッセージを送信する

GravioでSlackにメッセージを送信するときなどにHubKitの入っているホスト名を埋め込みたいことがある。 そういうときは環境変数を取得する関数 Env() をマッピングで使うとよい。 使用環境 Windows HubKit * Windows 10 21H1 * Gravio HubKit v4.3.0-5831 Linux HubKit * Raspberry Pi 4 Model B w/8GB RAM * Ubuntu Server 20.04.2 LTS * Gravio HubKit v4.3.0-6807 Gravio Studio * Gravio Studio v4.3.4198.0 Windowsの場合 Slackに"COMPUTERNAME"の値を埋め込んでメッセージを送信。 cp.Text = "このメッセージは " + Env("COMPUTERNAME") + " から送信されています" Linux、Gravio Hubの場合 Slackに"HOSTNAME"の値を埋め込んでメッセージを送信。 cp.Text = "このメッセージは " + Env("HOSTNAME") + " から送信されています" 参考 Gravio Gravio関数/環境変数 Pre Mappings / Post Mappingsでの式の記述の仕方
  • このエントリーをはてなブックマークに追加
  • Qiitaで続きを読む

Cコンパイラの名前をneo-c2にしました

なんとなく。version 1.0.0としました。 pcreを使ったライブラリは復活させました。 エディッタのほうもvinに変更。 あとはエディッタのvinのほうでneo-c2のメソッド名の補完や関数名の補完を入れたいと思います。 それで終わりですかね
  • このエントリーをはてなブックマークに追加
  • Qiitaで続きを読む