diff --git a/5gc_oam/.viminfo b/5gc_oam/.viminfo new file mode 100644 index 0000000..1abbf1a --- /dev/null +++ b/5gc_oam/.viminfo @@ -0,0 +1,282 @@ +# This viminfo file was generated by Vim 8.0. +# You may edit it if you're careful! + +# Viminfo version +|1,4 + +# Value of 'encoding' when this file was written +*encoding=utf-8 + + +# hlsearch on (H) or off (h): +~h +# Last Search Pattern: +~MSle0~/prin + +# Command Line History (newest to oldest): +:wq +|2,0,1594837366,,"wq" + +# Search String History (newest to oldest): +?/prin +|2,1,1594837356,47,"prin" +?/pir +|2,1,1594836269,47,"pir" + +# Expression History (newest to oldest): + +# Input Line History (newest to oldest): + +# Debug Line History (newest to oldest): + +# Registers: +"0 LINE 0 + prinf("keyI->", keyI) +|3,0,0,1,1,0,1594836934," prinf(\"keyI->\", keyI)" +""1 LINE 0 + print("3keyI->", keyI) +|3,1,1,1,1,0,1594837364," print(\"3keyI->\", keyI)" +"2 LINE 0 + print("3key->", key) +|3,0,2,1,1,0,1594837364," print(\"3key->\", key)" +"3 LINE 0 + print("1keyI->", keyI) +|3,0,3,1,1,0,1594837359," print(\"1keyI->\", keyI)" +"4 LINE 0 + print("1key->", key) +|3,0,4,1,1,0,1594837359," print(\"1key->\", key)" +"5 LINE 0 + print("2keyI->", keyI) +|3,0,5,1,1,0,1594837357," print(\"2keyI->\", keyI)" +"6 LINE 0 + print("2key->", key) +|3,0,6,1,1,0,1594837357," print(\"2key->\", key)" +"7 LINE 0 + +|3,0,7,1,1,0,1594836932," " +"8 LINE 0 + return True +|3,0,8,1,1,0,1594836882," return True" +"9 LINE 0 + if ('op' == key or 'opc' == key): +|3,0,9,1,1,0,1594836881," if ('op' == key or 'opc' == key):" +"- CHAR 0 + f +|3,0,36,0,1,0,1594836986,"f" + +# File marks: +'0 119 16 ~/configReadWrite.py +|4,48,119,16,1594837366,"~/configReadWrite.py" +'1 112 39 ~/configReadWrite.py +|4,49,112,39,1594837268,"~/configReadWrite.py" +'2 114 39 ~/configReadWrite.py +|4,50,114,39,1594837268,"~/configReadWrite.py" +'3 113 27 ~/configReadWrite.py +|4,51,113,27,1594837142,"~/configReadWrite.py" +'4 112 27 ~/configReadWrite.py +|4,52,112,27,1594837142,"~/configReadWrite.py" +'5 115 27 ~/configReadWrite.py +|4,53,115,27,1594837142,"~/configReadWrite.py" +'6 114 27 ~/configReadWrite.py +|4,54,114,27,1594837142,"~/configReadWrite.py" +'7 99 12 ~/configReadWrite.py +|4,55,99,12,1594837003,"~/configReadWrite.py" +'8 99 12 ~/configReadWrite.py +|4,56,99,12,1594837003,"~/configReadWrite.py" +'9 99 12 ~/configReadWrite.py +|4,57,99,12,1594837003,"~/configReadWrite.py" + +# Jumplist (newest first): +-' 119 16 ~/configReadWrite.py +|4,39,119,16,1594837366,"~/configReadWrite.py" +-' 112 39 ~/configReadWrite.py +|4,39,112,39,1594837356,"~/configReadWrite.py" +-' 114 39 ~/configReadWrite.py +|4,39,114,39,1594837268,"~/configReadWrite.py" +-' 113 27 ~/configReadWrite.py +|4,39,113,27,1594837204,"~/configReadWrite.py" +-' 115 27 ~/configReadWrite.py +|4,39,115,27,1594837204,"~/configReadWrite.py" +-' 114 27 ~/configReadWrite.py +|4,39,114,27,1594837142,"~/configReadWrite.py" +-' 99 12 ~/configReadWrite.py +|4,39,99,12,1594837067,"~/configReadWrite.py" +-' 100 12 ~/configReadWrite.py +|4,39,100,12,1594837067,"~/configReadWrite.py" +-' 100 12 ~/configReadWrite.py +|4,39,100,12,1594837067,"~/configReadWrite.py" +-' 100 12 ~/configReadWrite.py +|4,39,100,12,1594837003,"~/configReadWrite.py" +-' 118 15 ~/configReadWrite.py +|4,39,118,15,1594836982,"~/configReadWrite.py" +-' 117 15 ~/configReadWrite.py +|4,39,117,15,1594836982,"~/configReadWrite.py" +-' 124 15 ~/configReadWrite.py +|4,39,124,15,1594836982,"~/configReadWrite.py" +-' 122 15 ~/configReadWrite.py +|4,39,122,15,1594836982,"~/configReadWrite.py" +-' 123 15 ~/configReadWrite.py +|4,39,123,15,1594836982,"~/configReadWrite.py" +-' 121 15 ~/configReadWrite.py +|4,39,121,15,1594836982,"~/configReadWrite.py" +-' 121 15 ~/configReadWrite.py +|4,39,121,15,1594836941,"~/configReadWrite.py" +-' 100 27 ~/configReadWrite.py +|4,39,100,27,1594836790,"~/configReadWrite.py" +-' 100 27 ~/configReadWrite.py +|4,39,100,27,1594836777,"~/configReadWrite.py" +-' 93 4 ~/configReadWrite.py +|4,39,93,4,1594836742,"~/configReadWrite.py" +-' 93 4 ~/configReadWrite.py +|4,39,93,4,1594836742,"~/configReadWrite.py" +-' 93 4 ~/configReadWrite.py +|4,39,93,4,1594836742,"~/configReadWrite.py" +-' 93 4 ~/configReadWrite.py +|4,39,93,4,1594836742,"~/configReadWrite.py" +-' 93 4 ~/configReadWrite.py +|4,39,93,4,1594836742,"~/configReadWrite.py" +-' 93 4 ~/configReadWrite.py +|4,39,93,4,1594836742,"~/configReadWrite.py" +-' 93 4 ~/configReadWrite.py +|4,39,93,4,1594836708,"~/configReadWrite.py" +-' 105 16 ~/configReadWrite.py +|4,39,105,16,1594836462,"~/configReadWrite.py" +-' 103 16 ~/configReadWrite.py +|4,39,103,16,1594836462,"~/configReadWrite.py" +-' 107 16 ~/configReadWrite.py +|4,39,107,16,1594836462,"~/configReadWrite.py" +-' 105 16 ~/configReadWrite.py +|4,39,105,16,1594836462,"~/configReadWrite.py" +-' 107 16 ~/configReadWrite.py +|4,39,107,16,1594836462,"~/configReadWrite.py" +-' 105 16 ~/configReadWrite.py +|4,39,105,16,1594836462,"~/configReadWrite.py" +-' 107 16 ~/configReadWrite.py +|4,39,107,16,1594836462,"~/configReadWrite.py" +-' 105 16 ~/configReadWrite.py +|4,39,105,16,1594836462,"~/configReadWrite.py" +-' 107 16 ~/configReadWrite.py +|4,39,107,16,1594836462,"~/configReadWrite.py" +-' 105 16 ~/configReadWrite.py +|4,39,105,16,1594836462,"~/configReadWrite.py" +-' 107 16 ~/configReadWrite.py +|4,39,107,16,1594836462,"~/configReadWrite.py" +-' 105 16 ~/configReadWrite.py +|4,39,105,16,1594836462,"~/configReadWrite.py" +-' 108 16 ~/configReadWrite.py +|4,39,108,16,1594836398,"~/configReadWrite.py" +-' 106 16 ~/configReadWrite.py +|4,39,106,16,1594836398,"~/configReadWrite.py" +-' 110 16 ~/configReadWrite.py +|4,39,110,16,1594836398,"~/configReadWrite.py" +-' 108 16 ~/configReadWrite.py +|4,39,108,16,1594836398,"~/configReadWrite.py" +-' 110 16 ~/configReadWrite.py +|4,39,110,16,1594836398,"~/configReadWrite.py" +-' 108 16 ~/configReadWrite.py +|4,39,108,16,1594836398,"~/configReadWrite.py" +-' 110 16 ~/configReadWrite.py +|4,39,110,16,1594836398,"~/configReadWrite.py" +-' 108 16 ~/configReadWrite.py +|4,39,108,16,1594836398,"~/configReadWrite.py" +-' 110 16 ~/configReadWrite.py +|4,39,110,16,1594836398,"~/configReadWrite.py" +-' 108 16 ~/configReadWrite.py +|4,39,108,16,1594836398,"~/configReadWrite.py" +-' 110 16 ~/configReadWrite.py +|4,39,110,16,1594836398,"~/configReadWrite.py" +-' 108 16 ~/configReadWrite.py +|4,39,108,16,1594836398,"~/configReadWrite.py" +-' 104 18 ~/configReadWrite.py +|4,39,104,18,1594836274,"~/configReadWrite.py" +-' 107 18 ~/configReadWrite.py +|4,39,107,18,1594836274,"~/configReadWrite.py" +-' 102 18 ~/configReadWrite.py +|4,39,102,18,1594836274,"~/configReadWrite.py" +-' 106 18 ~/configReadWrite.py +|4,39,106,18,1594836274,"~/configReadWrite.py" +-' 109 18 ~/configReadWrite.py +|4,39,109,18,1594836274,"~/configReadWrite.py" +-' 104 18 ~/configReadWrite.py +|4,39,104,18,1594836274,"~/configReadWrite.py" +-' 106 18 ~/configReadWrite.py +|4,39,106,18,1594836274,"~/configReadWrite.py" +-' 109 18 ~/configReadWrite.py +|4,39,109,18,1594836274,"~/configReadWrite.py" +-' 104 18 ~/configReadWrite.py +|4,39,104,18,1594836274,"~/configReadWrite.py" +-' 106 18 ~/configReadWrite.py +|4,39,106,18,1594836274,"~/configReadWrite.py" +-' 109 18 ~/configReadWrite.py +|4,39,109,18,1594836274,"~/configReadWrite.py" +-' 104 18 ~/configReadWrite.py +|4,39,104,18,1594836274,"~/configReadWrite.py" +-' 106 18 ~/configReadWrite.py +|4,39,106,18,1594836274,"~/configReadWrite.py" +-' 109 18 ~/configReadWrite.py +|4,39,109,18,1594836274,"~/configReadWrite.py" +-' 104 18 ~/configReadWrite.py +|4,39,104,18,1594836274,"~/configReadWrite.py" +-' 106 18 ~/configReadWrite.py +|4,39,106,18,1594836274,"~/configReadWrite.py" +-' 109 18 ~/configReadWrite.py +|4,39,109,18,1594836274,"~/configReadWrite.py" +-' 104 18 ~/configReadWrite.py +|4,39,104,18,1594836274,"~/configReadWrite.py" +-' 107 18 ~/configReadWrite.py +|4,39,107,18,1594836274,"~/configReadWrite.py" +-' 1 0 ~/configReadWrite.py +|4,39,1,0,1594836269,"~/configReadWrite.py" +-' 1 0 ~/configReadWrite.py +|4,39,1,0,1594836269,"~/configReadWrite.py" +-' 1 0 ~/configReadWrite.py +|4,39,1,0,1594836269,"~/configReadWrite.py" +-' 1 0 ~/configReadWrite.py +|4,39,1,0,1594836269,"~/configReadWrite.py" +-' 1 0 ~/configReadWrite.py +|4,39,1,0,1594836269,"~/configReadWrite.py" +-' 1 0 ~/configReadWrite.py +|4,39,1,0,1594836269,"~/configReadWrite.py" +-' 1 0 ~/configReadWrite.py +|4,39,1,0,1594836269,"~/configReadWrite.py" +-' 1 0 ~/configReadWrite.py +|4,39,1,0,1594836269,"~/configReadWrite.py" +-' 1 0 ~/configReadWrite.py +|4,39,1,0,1594836269,"~/configReadWrite.py" + +# History of marks within files (newest to oldest): + +> ~/configReadWrite.py + * 1594837365 0 + " 119 16 + ^ 112 40 + . 119 0 + + 105 18 + + 99 8 + + 105 0 + + 110 33 + + 114 48 + + 114 30 + + 99 0 + + 93 0 + + 99 25 + + 99 27 + + 114 0 + + 116 11 + + 119 15 + + 119 10 + + 119 9 + + 119 0 + + 119 15 + + 119 20 + + 116 16 + + 99 12 + + 99 15 + + 116 19 + + 119 23 + + 111 47 + + 113 27 + + 112 39 + + 116 0 + + 99 0 + + 119 0 diff --git a/5gc_oam/README.md b/5gc_oam/README.md new file mode 100644 index 0000000..bc86d41 --- /dev/null +++ b/5gc_oam/README.md @@ -0,0 +1,2 @@ +# 5GC_OAM + diff --git a/5gc_oam/__init__.py b/5gc_oam/__init__.py new file mode 100644 index 0000000..1427b91 --- /dev/null +++ b/5gc_oam/__init__.py @@ -0,0 +1,66 @@ +from flask import Flask, request, render_template, redirect, url_for +import io, libconf +import configReadWrite, dockerCommand + +app = Flask(__name__) + +layout = '' +config = '' +containers = '' + +with io.open('conf/all.conf') as f: + config = libconf.load(f) + +with io.open('conf/param.conf') as f: + layout = libconf.load(f) + +with io.open('conf/component.conf') as f: + containers = libconf.load(f) + configReadWrite.syncNfAddr(config, containers) + +def modifyAllStatus(status): + global containers + + for key in containers: + modifyStatus(key, status) + +def modifyStatus(target, status): + global containers + + if 'stop' == status: + dockerCommand.rmContainer(containers, target) + else: + dockerCommand.runContainer(containers, target) + + containers[target]['status'] = status + +@app.route('/oam/edit', methods=['GET', 'POST']) +def confpage(): + if 'POST' == request.method: + configReadWrite.storeConfig(layout=layout, config=config, data=request.form) + configReadWrite.writeConfig(config, 'conf/all.conf') + configReadWrite.genNfConf(config, containers) + + return redirect(url_for('homepage')) + return render_template("editConfig.html", layout=layout, config=config) + +@app.route('/oam/container', methods=['POST']) +def containerpage(): + if 'POST' == request.method: + for key, value in request.form.items(): + if 'all' == key: + modifyAllStatus(value) + else: + modifyStatus(key, value) + return redirect(url_for('homepage')) + +@app.route('/oam/', methods=['GET']) +def homepage(): + return render_template("showConfig.html", layout=layout, config=config, containers=containers) + +@app.route('/oam/test', methods=['GET']) +def test(): + return render_template("test.html") + +if __name__ == "__main__": + app.run() diff --git a/5gc_oam/__pycache__/configReadWrite.cpython-36.pyc b/5gc_oam/__pycache__/configReadWrite.cpython-36.pyc new file mode 100644 index 0000000..dd38cb8 Binary files /dev/null and b/5gc_oam/__pycache__/configReadWrite.cpython-36.pyc differ diff --git a/5gc_oam/__pycache__/dockerCommand.cpython-36.pyc b/5gc_oam/__pycache__/dockerCommand.cpython-36.pyc new file mode 100644 index 0000000..adc56ac Binary files /dev/null and b/5gc_oam/__pycache__/dockerCommand.cpython-36.pyc differ diff --git a/5gc_oam/conf/Quagga.conf b/5gc_oam/conf/Quagga.conf new file mode 100644 index 0000000..7ab4032 --- /dev/null +++ b/5gc_oam/conf/Quagga.conf @@ -0,0 +1,21 @@ +! +hostname Router +!password zebra +!enable password zebra +! +! Interface's description. +! +!interface lo +! description test of desc. +! +!interface sit0 +! multicast + +! +! Static default route sample. +! +!ip route 0.0.0.0/0 203.181.89.241 +! + +!log file zebra.log + diff --git a/5gc_oam/conf/all.conf b/5gc_oam/conf/all.conf new file mode 100644 index 0000000..c17250c --- /dev/null +++ b/5gc_oam/conf/all.conf @@ -0,0 +1,117 @@ +NF_Address = +{ + AMF_Address = "192.168.44.5"; + SMF_Address = "192.168.44.6"; + UPF_Address = "192.168.44.8"; + PCF_Address = "192.168.44.7"; +}; +CN_Info = +{ + PLMN = "466.66"; + SliceList = + ( + { + Sst = 1; + Sd = 273; + }, + { + Sst = 2; + Sd = 273; + }, + { + Sst = 3; + Sd = 273; + }, + { + Sst = 4; + Sd = 273; + } + ); + AMF_Info = + { + AMF_Name = "default.iii.org.tw"; + AMF_Region_ID = 168; + AMF_Set_ID = 6; + AMF_Pointer = 48; + }; + DataNetwork = + { + DNN = "Internet"; + UPF_N6_NIC_NAME = ""; + }; +}; +UE_INFO = +( + { + imsi = "466.66.6100000001"; + key = + { + k = "00010203.04050607.08090a0b.0c0d0e0f"; + opc = "63bfa50e.e6523365.ff14c1f4.5f88737d"; + }; + }, + { + imsi = "466.66.6100000003"; + key = + { + k = "00010203.04050607.08090a0b.0c0d0e02"; + op = "cdc202d5.123e20f6.2b6d676a.22222222"; + }; + }, + { + imsi = "466.66.6100000004"; + key = + { + k = "00010203.04050607.08090a0b.0c0d0e03"; + opc = "cdc202d5.123e20f6.2b6d676a.33333333"; + }; + }, + { + imsi = "466.66.6100000005"; + key = + { + k = "00010203.04050607.08090a0b.0c0d0e04"; + opc = "cdc202d5.123e20f6.2b6d676a.44444444"; + }; + }, + { + imsi = "466.66.6100000006"; + key = + { + k = "00010203.04050607.08090a0b.0c0d0e0f"; + op = "cdc202d5.123e20f6.2b6d676a.c72cb318"; + }; + }, + { + imsi = "466.66.6100000007"; + key = + { + k = "00010203.04050607.08090a0b.0c0d0e0f"; + op = "cdc202d5.123e20f6.2b6d676a.c72cb318"; + }; + }, + { + imsi = "466.66.6100000008"; + key = + { + k = "00010203.04050607.08090a0b.0c0d0e0f"; + op = "cdc202d5.123e20f6.2b6d676a.c72cb318"; + }; + }, + { + imsi = "466.66.6100000009"; + key = + { + k = "00010203.04050607.08090a0b.0c0d0e0f"; + op = "cdc202d5.123e20f6.2b6d676a.c72cb318"; + }; + }, + { + imsi = "466.66.6100000010"; + key = + { + k = "00010203.04050607.08090a0b.0c0d0e0f"; + op = "cdc202d5.123e20f6.2b6d676a.c72cb318"; + }; + } +); diff --git a/5gc_oam/conf/amf.conf b/5gc_oam/conf/amf.conf new file mode 100644 index 0000000..ed8080a --- /dev/null +++ b/5gc_oam/conf/amf.conf @@ -0,0 +1,108 @@ +PLMN_SupportList = +( + { + PLMN = "466.66"; + SliceList = + ( + { + Sst = 1; + Sd = 273; + }, + { + Sst = 2; + Sd = 273; + }, + { + Sst = 3; + Sd = 273; + }, + { + Sst = 4; + Sd = 273; + } + ); + } +); +AMF_Name = "default.iii.org.tw"; +AMF_Region_ID = 168; +AMF_Set_ID = 6; +AMF_Pointer = 48; +AMF_SBI_Address = "192.168.44.5"; +AMF_N2_Address = "192.168.44.5"; +AMF_N2HO_Address = "192.168.44.5"; +SMF_SBI_Address = "192.168.44.6"; +UeKeyList = +( + { + imsi = "466.66.6100000001"; + key = + { + k = "00010203.04050607.08090a0b.0c0d0e0f"; + opc = "63bfa50e.e6523365.ff14c1f4.5f88737d"; + }; + }, + { + imsi = "466.66.6100000003"; + key = + { + k = "00010203.04050607.08090a0b.0c0d0e02"; + op = "cdc202d5.123e20f6.2b6d676a.22222222"; + }; + }, + { + imsi = "466.66.6100000004"; + key = + { + k = "00010203.04050607.08090a0b.0c0d0e03"; + opc = "cdc202d5.123e20f6.2b6d676a.33333333"; + }; + }, + { + imsi = "466.66.6100000005"; + key = + { + k = "00010203.04050607.08090a0b.0c0d0e04"; + opc = "cdc202d5.123e20f6.2b6d676a.44444444"; + }; + }, + { + imsi = "466.66.6100000006"; + key = + { + k = "00010203.04050607.08090a0b.0c0d0e0f"; + op = "cdc202d5.123e20f6.2b6d676a.c72cb318"; + }; + }, + { + imsi = "466.66.6100000007"; + key = + { + k = "00010203.04050607.08090a0b.0c0d0e0f"; + op = "cdc202d5.123e20f6.2b6d676a.c72cb318"; + }; + }, + { + imsi = "466.66.6100000008"; + key = + { + k = "00010203.04050607.08090a0b.0c0d0e0f"; + op = "cdc202d5.123e20f6.2b6d676a.c72cb318"; + }; + }, + { + imsi = "466.66.6100000009"; + key = + { + k = "00010203.04050607.08090a0b.0c0d0e0f"; + op = "cdc202d5.123e20f6.2b6d676a.c72cb318"; + }; + }, + { + imsi = "466.66.6100000010"; + key = + { + k = "00010203.04050607.08090a0b.0c0d0e0f"; + op = "cdc202d5.123e20f6.2b6d676a.c72cb318"; + }; + } +); diff --git a/5gc_oam/conf/component.conf b/5gc_oam/conf/component.conf new file mode 100644 index 0000000..9543f34 --- /dev/null +++ b/5gc_oam/conf/component.conf @@ -0,0 +1,28 @@ +AMF = +{ + Image = "iii5gc/iiiamf:1.0.1"; + Name = "iiiAMF"; + Ip = "192.168.44.5"; + status = "stop"; +}; +SMF = +{ + Image = "iii5gc/iiismf:1.0.1"; + Name = "iiiSMF"; + Ip = "192.168.44.6"; + status = "stop"; +}; +PCF = +{ + Image = "iii5gc/iiipcf:1.0.1"; + Name = "iiiPCF"; + Ip = "192.168.44.7"; + status = "stop"; +}; +UPF = +{ + Image = "iii5gc/iiiupf:1.0.1"; + Name = "iiiUPF"; + Ip = "192.168.44.8"; + status = "stop"; +}; diff --git a/5gc_oam/conf/dhcpd.conf b/5gc_oam/conf/dhcpd.conf new file mode 100644 index 0000000..f227722 --- /dev/null +++ b/5gc_oam/conf/dhcpd.conf @@ -0,0 +1,26 @@ +# +# Create by CLI +# +# 6 days +default-lease-time 51840; +# 9 days +max-lease-time 77760; +option domain-name "iii.org.tw"; +option broadcast-address 10.10.255.255; +option routers 10.10.0.1; +option domain-name-servers 168.95.1.1; +ddns-update-style none; + +group { + + subnet 10.10.0.0 netmask 255.255.0.0 { + range 10.10.0.3 10.10.200.254; + } + +# Sequans White + host ss1 { + hardware ethernet 00:1B:11:C9:D5:0C; + fixed-address 10.10.0.2; + } +} + diff --git a/5gc_oam/conf/param.conf b/5gc_oam/conf/param.conf new file mode 100644 index 0000000..17a0e7c --- /dev/null +++ b/5gc_oam/conf/param.conf @@ -0,0 +1,310 @@ +/* Parameter Discription */ + +NF_Address = + { title = "Network Function IP Address"; + type = "group" + data = + { AMF_Address = + { title = "AMF IP Address"; + default = "192.168.6.240"; + validate = + { + format = + { pattern = "^(?:(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.){3}(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)$"; + msg = "IP格式錯誤, 例如:192.168.6.240"; + }; + }; + }; + SMF_Address = + { title = "SMF IP Address"; + default = "192.168.6.241"; + validate = + { + format = + { pattern = "^(?:(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.){3}(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)$"; + msg = "IP格式錯誤, 例如:192.168.6.241"; + }; + }; + }; + PCF_Address = + { title = "PCF IP Address"; + default = "192.168.6.242"; + validate = + { + format = + { pattern = "^(?:(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.){3}(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)$"; + msg = "IP格式錯誤, 例如:192.168.6.242"; + }; + }; + }; + UPF_Address = + { title = "UPF IP Address"; + default = "192.168.6.243"; + validate = + { + format = + { pattern = "^(?:(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.){3}(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)$"; + msg = "IP格式錯誤, 例如:192.168.6.243"; + }; + }; + }; +// UPF_N6_Address = +// { title = "UPF N6 IP Address"; +// default = "192.168.7.48"; +// validate = +// { equality = +// { attribute = "UPF_Address"; +// msg = "UPF N6 IP cannot equals to UPF IP"; +// comparator = "function(v1, v2) { return v2 != v1; }"; +// }; +// format = +// { pattern = "^(?:(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.){3}(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)$"; +// msg = "IP格式錯誤, 例如:192.168.7.48"; +// }; +// }; +// }; + }; + }; + +CN_Info = + { title = "Core Network Information"; + type = "group"; + data = + { PLMN = + { title = "PLMN"; + default = "466.66"; + discription = "PLMN xxx.xxx or xxx.xx"; + validate = + { //length = + // { min = 6; + // max = 7; + // msg = "PLMN長度需大於6小於7"; + // }; + format = + { pattern = "[0-9]{3}\.[0-9]{2,3}"; + msg = "PLMN 格式為 xxx.xxx or xxx.xx, 例如:466.66"; + }; + }; + }; + SliceList = + { title = "Network Slice Setting"; + type = "group"; + list = "true"; + data = + { Sst = + { title = "Slice/Service Type"; + default = 1; + type = "num"; + enumKeyVal = + { eMBB = 1; + URLLC = 2; + MIoT = 3; + V2X = 4; + }; + }; + Sd = + { title = "Slice Differentiator"; + default = 0; + type = "num"; + validate = + { numericality = + { onlyInteger = true; + greaterThanOrEqualTo = 0; + lessThanOrEqualTo = 16777215; + notInteger = "必須是整數"; + notGreaterThanOrEqualTo = "必須大於等於0"; + notLessThanOrEqualTo = "必須小於等於16777215"; + }; + }; + }; + }; + }; + AMF_Info = + { title = "AMF Infomation"; + type = "group"; + data = + { AMF_Name = + { title = "AMF Name"; + default = "default.iii.org.tw"; + }; + AMF_Region_ID = + { title = "AMF Region ID"; + default = 168; + type = "num"; + validate = + { numericality = + { onlyInteger = true; + greaterThanOrEqualTo = 0; + lessThanOrEqualTo = 255; + notInteger = "必須是整數"; + notGreaterThanOrEqualTo = "必須大於等於0"; + notLessThanOrEqualTo = "必須小於等於255"; + }; + }; + }; + AMF_Set_ID = + { title = "AMF Set ID"; + default = 6; + type = "num"; + validate = + { numericality = + { onlyInteger = true; + greaterThanOrEqualTo = 0; + lessThanOrEqualTo = 1024; + notInteger = "必須是整數"; + notGreaterThanOrEqualTo = "必須大於等於0"; + notLessThanOrEqualTo = "必須小於等於1024"; + }; + }; + }; + AMF_Pointer = + { title = "AMF Pointer"; + default = 48; + type = "num"; + validate = + { numericality = + { onlyInteger = true; + greaterThanOrEqualTo = 0; + lessThanOrEqualTo = 64; + notInteger = "必須是整數"; + notGreaterThanOrEqualTo = "必須大於等於0"; + notLessThanOrEqualTo = "必須小於等於64"; + }; + }; + }; + }; + }; + DataNetwork = + { title = "Data Network Setting"; + type = "group"; + data = + { DNN = + { title = "Data Network Name (DNN)"; + default = "Internet"; + }; + //UPF_N6_NIC_NAME = + // { title = "UPF N6 Interface Network Device Name"; + // default = "eth1"; + // validate = + // { length = + // { min = 1; + // max = 15; + // msg = "長度不得大於15"; + // }; + // }; + // }; + //dhcp = + // { title = "DHCP setting"; + // type = "group"; + // data = + // { subnet = + // { title = "Subnet"; + // default = "10.10.0.0"; + // validate = + // { + // format = + // { pattern = "^(?:(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.){3}(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)$"; + // msg = "IP格式錯誤, 例如:10.10.0.0"; + // }; + // }; + // }; + // netmask = + // { title = "Subnet Mask"; + // default = "255.255.0.0"; + // validate = + // { + // format = + // { pattern = "^(?:(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.){3}(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)$"; + // msg = "IP格式錯誤, 例如:255.255.0.0"; + // }; + // }; + // }; + // dns = + // { title = "Domain Name Server"; + // default = "168.95.1.1"; + // validate = + // { + // format = + // { pattern = "^(?:(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.){3}(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)$"; + // msg = "IP格式錯誤, 例如:255.255.0.0"; + // }; + // }; + // }; + // }; + // }; + }; + }; + }; + }; + +UE_INFO = + { title = "UE Information"; + type = "group"; + list = "true"; + data = + { imsi = + { title = "UE IMSI"; + default = "466.66.6100000001"; + validate = + { equality = + { attribute = "PLMN"; + msg = "PLMN must the same"; + comparator = "function(v1, v2) { return v2 == v1.substring(0, v2.length); }"; + }; + length = + { is = 17; + msg = "IMSI Length 為 17, 例如:466.66.6100000001"; + }; + }; + }; + key = + { title = "UE Key"; + type = "group"; + data = + { k = + { title = "K"; + default = "00010203.04050607.08090a0b.0c0d0e0f"; + validate = + { length = + { is = 35; + msg = "Length 需為 35, 例如:00010203.04050607.08090a0b.0c0d0e0f"; + }; + format = + { pattern = "^([0-9a-fA-F]{8}\.){3}([0-9a-fA-F]{8})$"; + msg = "格式錯誤, 例如:00010203.04050607.08090a0b.0c0d0e0f"; + }; + }; + }; + op = + { title = "OP"; + default = "cdc202d5.123e20f6.2b6d676a.c72cb318"; + validate = + { length = + { is = 35; + msg = "Length 需為 35, 例如:cdc202d5.123e20f6.2b6d676a.c72cb318"; + }; + format = + { pattern = "^([0-9a-fA-F]{8}\.){3}([0-9a-fA-F]{8})$"; + msg = "格式錯誤, 例如:cdc202d5.123e20f6.2b6d676a.c72cb318"; + }; + }; + }; + opc = + { title = "OPC"; + default = "63bfa50e.e6523365.ff14c1f4.5f88737d"; + validate = + { length = + { is = 35; + msg = "Length 需為 35, 例如:63bfa50e.e6523365.ff14c1f4.5f88737d"; + }; + format = + { pattern = "^([0-9a-fA-F]{8}\.){3}([0-9a-fA-F]{8})$"; + msg = "格式錯誤, 例如:63bfa50e.e6523365.ff14c1f4.5f88737d"; + }; + }; + }; + }; + }; + }; + }; + diff --git a/5gc_oam/conf/pcf.conf b/5gc_oam/conf/pcf.conf new file mode 100644 index 0000000..26e0b0d --- /dev/null +++ b/5gc_oam/conf/pcf.conf @@ -0,0 +1,33 @@ +PLMN = "466.66"; +PCF_SBI_Address = "192.168.44.7"; +SMF_SBI_Address = "192.168.44.6"; +UeList = +( + { + imsi = "466.66.6100000001"; + }, + { + imsi = "466.66.6100000003"; + }, + { + imsi = "466.66.6100000004"; + }, + { + imsi = "466.66.6100000005"; + }, + { + imsi = "466.66.6100000006"; + }, + { + imsi = "466.66.6100000007"; + }, + { + imsi = "466.66.6100000008"; + }, + { + imsi = "466.66.6100000009"; + }, + { + imsi = "466.66.6100000010"; + } +); diff --git a/5gc_oam/conf/smf.conf b/5gc_oam/conf/smf.conf new file mode 100644 index 0000000..96f574c --- /dev/null +++ b/5gc_oam/conf/smf.conf @@ -0,0 +1,41 @@ +PLMN = "466.66"; +DNN = "Internet"; +AMF_SBI_Address = "192.168.44.5"; +SMF_SBI_Address = "192.168.44.6"; +SMF_N4_Address = "192.168.44.6"; +PCF_SBI_Address = "192.168.44.7"; +UPF_N3_Address = "192.168.44.8"; +UPF_N4_Address = "192.168.44.8"; +IUPF_N3_Address = "192.168.44.8"; +IUPF_N4_Address = "192.168.44.8"; +IUPF_N9_Address = "192.168.44.8"; +UeList = +( + { + imsi = "466.66.6100000001"; + }, + { + imsi = "466.66.6100000003"; + }, + { + imsi = "466.66.6100000004"; + }, + { + imsi = "466.66.6100000005"; + }, + { + imsi = "466.66.6100000006"; + }, + { + imsi = "466.66.6100000007"; + }, + { + imsi = "466.66.6100000008"; + }, + { + imsi = "466.66.6100000009"; + }, + { + imsi = "466.66.6100000010"; + } +); diff --git a/5gc_oam/conf/upf.conf b/5gc_oam/conf/upf.conf new file mode 100644 index 0000000..489e4fa --- /dev/null +++ b/5gc_oam/conf/upf.conf @@ -0,0 +1,5 @@ +SMF_N4_Address = "192.168.44.6"; +UPF_N3_Address = "192.168.44.8"; +UPF_N4_Address = "192.168.44.8"; +UPF_N6_Address = "10.254.254.6"; +UPF_N6_NIC_NAME = "eth1"; diff --git a/5gc_oam/configReadWrite.py b/5gc_oam/configReadWrite.py new file mode 100644 index 0000000..e093e6c --- /dev/null +++ b/5gc_oam/configReadWrite.py @@ -0,0 +1,141 @@ +import os +import io, libconf + +def writeConfig(data, filePath): + with io.open(filePath, 'w') as f: + libconf.dump(data, f) + +def genNfConf(config, containers): + genAmfConf(config) + genSmfConf(config) + genPcfConf(config) + genUpfConf(config) + syncNfAddr(config, containers) + writeConfig(containers, 'conf/component.conf') + +def genUpfConf(config): + upfConfig = {} + + upfConfig['SMF_N4_Address'] = config['NF_Address']['SMF_Address'] + upfConfig['UPF_N3_Address'] = config['NF_Address']['UPF_Address'] + upfConfig['UPF_N4_Address'] = config['NF_Address']['UPF_Address'] + upfConfig['UPF_N6_Address'] = "10.254.254.6" + + upfConfig['UPF_N6_NIC_NAME'] = "eth1" + + writeConfig(upfConfig, 'conf/upf.conf') + +def genPcfConf(config): + pcfConfig = {} + + pcfConfig['PLMN'] = config['CN_Info']['PLMN'] + + pcfConfig['PCF_SBI_Address'] = config['NF_Address']['PCF_Address'] + pcfConfig['SMF_SBI_Address'] = config['NF_Address']['SMF_Address'] + + pcfConfig['UeList'] = list() + for ue in config['UE_INFO']: + pcfConfig['UeList'].append({'imsi':ue['imsi']}) + pcfConfig['UeList'] = tuple(pcfConfig['UeList']) + + writeConfig(pcfConfig, 'conf/pcf.conf') + +def genSmfConf(config): + smfConfig = {} + + smfConfig['PLMN'] = config['CN_Info']['PLMN'] + smfConfig['DNN'] = config['CN_Info']['DataNetwork']['DNN'] + + smfConfig['AMF_SBI_Address'] = config['NF_Address']['AMF_Address'] + smfConfig['SMF_SBI_Address'] = config['NF_Address']['SMF_Address'] + smfConfig['SMF_N4_Address'] = config['NF_Address']['SMF_Address'] + smfConfig['PCF_SBI_Address'] = config['NF_Address']['PCF_Address'] + smfConfig['UPF_N3_Address'] = config['NF_Address']['UPF_Address'] + smfConfig['UPF_N4_Address'] = config['NF_Address']['UPF_Address'] + smfConfig['IUPF_N3_Address'] = config['NF_Address']['UPF_Address'] + smfConfig['IUPF_N4_Address'] = config['NF_Address']['UPF_Address'] + smfConfig['IUPF_N9_Address'] = config['NF_Address']['UPF_Address'] + + smfConfig['UeList'] = list() + for ue in config['UE_INFO']: + smfConfig['UeList'].append({'imsi':ue['imsi']}) + smfConfig['UeList'] = tuple(smfConfig['UeList']) + + writeConfig(smfConfig, 'conf/smf.conf') + +def genAmfConf(config): + amfConfig = {} + plmnConfig = {} + + plmnConfig['PLMN'] = config['CN_Info']['PLMN'] + plmnConfig['SliceList'] = config['CN_Info']['SliceList'] + + amfConfig['PLMN_SupportList'] = list() + amfConfig['PLMN_SupportList'].append(plmnConfig) + amfConfig['PLMN_SupportList'] = tuple(amfConfig['PLMN_SupportList']) + + amfConfig['AMF_Name'] = config['CN_Info']['AMF_Info']['AMF_Name'] + amfConfig['AMF_Region_ID'] = config['CN_Info']['AMF_Info']['AMF_Region_ID'] + amfConfig['AMF_Set_ID'] = config['CN_Info']['AMF_Info']['AMF_Set_ID'] + amfConfig['AMF_Pointer'] = config['CN_Info']['AMF_Info']['AMF_Pointer'] + + amfConfig['AMF_SBI_Address'] = config['NF_Address']['AMF_Address'] + amfConfig['AMF_N2_Address'] = config['NF_Address']['AMF_Address'] + amfConfig['AMF_N2HO_Address'] = config['NF_Address']['AMF_Address'] + + amfConfig['SMF_SBI_Address'] = config['NF_Address']['SMF_Address'] + + amfConfig['UeKeyList'] = config['UE_INFO'] + + writeConfig(amfConfig, 'conf/amf.conf') + +def storeConfig(layout, config, data, index=0, postfix=''): + for key in layout: + keyI = key + postfix + + if (0 != index): + keyI = keyI + str(index) + + if ('type' in layout[key]) and ('group' == layout[key]['type']): + if ('list' in layout[key]) and ('true' == layout[key]['list']): + config[key] = list(config[key]) + storeListConfig(key, layout[key]['data'], config[key], data) + config[key] = tuple(config[key]) + else: + if (('' != postfix) or ('key' == key)): + storeConfig(layout[key]['data'], config[key], data, postfix=keyI) + else: + storeConfig(layout[key]['data'], config[key], data) + else: + if (keyI not in data): + if ('op'==key) or ('opc'==key): + config.pop(key, None) + continue + return False + + if ('type' in layout[key]) and ('num' == layout[key]['type']): + config[key] = int(data.get(keyI)) + else: + config[key] = data.get(keyI) + + return True + +def storeListConfig(key, layout, config, data): + rmAry = [] + length = len(config) + + for i in range(length, int(data[key + 'MaxLen'])): + config.append(config[0].copy()) + + for i in range(len(config)): + if (False == storeConfig(layout, config[i], data, i+1)): + rmAry.append(config[i]) + + for rmItem in rmAry: + config.remove(rmItem) + +def syncNfAddr(config, containers): + containers['AMF']['Ip'] = config['NF_Address']['AMF_Address'] + containers['SMF']['Ip'] = config['NF_Address']['SMF_Address'] + containers['UPF']['Ip'] = config['NF_Address']['UPF_Address'] + containers['PCF']['Ip'] = config['NF_Address']['PCF_Address'] diff --git a/5gc_oam/docker/buildImage.sh b/5gc_oam/docker/buildImage.sh new file mode 100755 index 0000000..8eeb28f --- /dev/null +++ b/5gc_oam/docker/buildImage.sh @@ -0,0 +1,53 @@ +#! /bin/bash + +FOLDER="" +NAME="" +VERSION="latest" + +buildImage() +{ + if [ "$NAME" = "" ] + then + exit + fi + + if [ "$FOLDER" != "" ] && [ -d $FOLDER ] + then + cd $FOLDER && \ + docker build -t="iii/$NAME:$VERSION" . + else + echo "Folder is mandatory argument!!" + usage + fi +} + +usage() +{ + echo "usage: ./buildImage.sh [-n name] [-v version] [-f folder] [-l list]" +} + +while [ "$1" != "" ]; do + case $1 in + -n | --name ) shift + NAME=$1 + ;; + -v | --version ) shift + VERSION=$1 + ;; + -f | --folder ) shift + FOLDER=$1 + FOLDER=`cd $FOLDER; pwd` + ;; + -h | --help ) usage + exit + ;; + -l | --list ) docker images + exit + ;; + * ) usage + exit 1 + esac + shift +done + +buildImage diff --git a/5gc_oam/docker/oamBuildEnv/Dockerfile b/5gc_oam/docker/oamBuildEnv/Dockerfile new file mode 100644 index 0000000..772c54d --- /dev/null +++ b/5gc_oam/docker/oamBuildEnv/Dockerfile @@ -0,0 +1,64 @@ +FROM ubuntu:18.04 +# VOLUME /tmp +# MAINTAINER Chihshin + +ENV TINI_VERSION v0.19.0 +ADD https://github.com/krallin/tini/releases/download/${TINI_VERSION}/tini /tini +RUN chmod +x /tini +ENTRYPOINT ["/tini", "-s", "--"] + +#Essential Tool +RUN apt-get update -y && \ + apt-get -f install -y \ + sudo \ + git \ + gawk \ + tmux \ + openssh-server \ + locales \ + net-tools \ + nginx \ + psmisc \ + iputils-ping \ + tcpdump \ + vim && \ + locale-gen en_US.UTF-8 +# snmp snmpd snmp-mibs-downloader + +#init LANG +ENV LANG en_US.UTF-8 +ENV LANGUAGE en_US.UTF-8 +ENV LC_ALL en_US.UTF-8 + +#init ssh server run environment +RUN mkdir /var/run/sshd +RUN sed 's@session\s*required\s*pam_loginuid.so@session optional pam_loginuid.so@g' -i /etc/pam.d/sshd + +#init nginx environment +COPY ./oam/sites-available/default /etc/nginx/sites-available/ +COPY ./oam/index.html /var/www/. +RUN nginx -c /etc/nginx/nginx.conf + +#Required Lib +RUN apt-get update -y && \ + apt-get -f install -y \ + zsh \ + python3-pip && \ + pip3 install flask libconf + +#add user iii +RUN useradd -ms /usr/bin/zsh iii +RUN sudo adduser iii sudo +RUN echo 'iii:iii123@' | sudo chpasswd +# no passwd for iii +RUN echo 'iii ALL=(ALL:ALL) NOPASSWD:ALL' >> /etc/sudoers + +# boy, dev, copy my zsh to home of iii, (COPY can chown, or owner is root) +COPY --chown=iii ./oh-my-zsh /home/iii/.oh-my-zsh +COPY --chown=iii ./zshrc /home/iii/.zshrc + +#switch path to /home/iii +USER iii +WORKDIR /home/iii + +CMD [ "/bin/bash", "-ce", "sudo -E /home/iii/runOAM.sh && ping localhost"] diff --git a/5gc_oam/docker/oamBuildEnv/oam/index.html b/5gc_oam/docker/oamBuildEnv/oam/index.html new file mode 100644 index 0000000..1df08d0 --- /dev/null +++ b/5gc_oam/docker/oamBuildEnv/oam/index.html @@ -0,0 +1,8 @@ + +
+`s get reset. However, we also reset the\n// bottom margin to use `rem` units instead of `em`.\np {\n margin-top: 0;\n margin-bottom: $paragraph-margin-bottom;\n}\n\n// Abbreviations\n//\n// 1. Duplicate behavior to the data-* attribute for our tooltip plugin\n// 2. Add the correct text decoration in Chrome, Edge, IE, Opera, and Safari.\n// 3. Add explicit cursor to indicate changed behavior.\n// 4. Remove the bottom border in Firefox 39-.\n// 5. Prevent the text-decoration to be skipped.\n\nabbr[title],\nabbr[data-original-title] { // 1\n text-decoration: underline; // 2\n text-decoration: underline dotted; // 2\n cursor: help; // 3\n border-bottom: 0; // 4\n text-decoration-skip-ink: none; // 5\n}\n\naddress {\n margin-bottom: 1rem;\n font-style: normal;\n line-height: inherit;\n}\n\nol,\nul,\ndl {\n margin-top: 0;\n margin-bottom: 1rem;\n}\n\nol ol,\nul ul,\nol ul,\nul ol {\n margin-bottom: 0;\n}\n\ndt {\n font-weight: $dt-font-weight;\n}\n\ndd {\n margin-bottom: .5rem;\n margin-left: 0; // Undo browser default\n}\n\nblockquote {\n margin: 0 0 1rem;\n}\n\nb,\nstrong {\n font-weight: $font-weight-bolder; // Add the correct font weight in Chrome, Edge, and Safari\n}\n\nsmall {\n @include font-size(80%); // Add the correct font size in all browsers\n}\n\n//\n// Prevent `sub` and `sup` elements from affecting the line height in\n// all browsers.\n//\n\nsub,\nsup {\n position: relative;\n @include font-size(75%);\n line-height: 0;\n vertical-align: baseline;\n}\n\nsub { bottom: -.25em; }\nsup { top: -.5em; }\n\n\n//\n// Links\n//\n\na {\n color: $link-color;\n text-decoration: $link-decoration;\n background-color: transparent; // Remove the gray background on active links in IE 10.\n\n @include hover() {\n color: $link-hover-color;\n text-decoration: $link-hover-decoration;\n }\n}\n\n// And undo these styles for placeholder links/named anchors (without href).\n// It would be more straightforward to just use a[href] in previous block, but that\n// causes specificity issues in many other styles that are too complex to fix.\n// See https://github.com/twbs/bootstrap/issues/19402\n\na:not([href]) {\n color: inherit;\n text-decoration: none;\n\n @include hover() {\n color: inherit;\n text-decoration: none;\n }\n}\n\n\n//\n// Code\n//\n\npre,\ncode,\nkbd,\nsamp {\n font-family: $font-family-monospace;\n @include font-size(1em); // Correct the odd `em` font sizing in all browsers.\n}\n\npre {\n // Remove browser default top margin\n margin-top: 0;\n // Reset browser default of `1em` to use `rem`s\n margin-bottom: 1rem;\n // Don't allow content to break outside\n overflow: auto;\n // Disable auto-hiding scrollbar in IE & legacy Edge to avoid overlap,\n // making it impossible to interact with the content\n -ms-overflow-style: scrollbar;\n}\n\n\n//\n// Figures\n//\n\nfigure {\n // Apply a consistent margin strategy (matches our type styles).\n margin: 0 0 1rem;\n}\n\n\n//\n// Images and content\n//\n\nimg {\n vertical-align: middle;\n border-style: none; // Remove the border on images inside links in IE 10-.\n}\n\nsvg {\n // Workaround for the SVG overflow bug in IE10/11 is still required.\n // See https://github.com/twbs/bootstrap/issues/26878\n overflow: hidden;\n vertical-align: middle;\n}\n\n\n//\n// Tables\n//\n\ntable {\n border-collapse: collapse; // Prevent double borders\n}\n\ncaption {\n padding-top: $table-cell-padding;\n padding-bottom: $table-cell-padding;\n color: $table-caption-color;\n text-align: left;\n caption-side: bottom;\n}\n\nth {\n // Matches default `