Commit caff3e57 authored by root's avatar root

1st commit

parents
#CellID|LocationIP|Netmask|Access switch name|default route|enb's name
#00011d70|192.168.10.1|255.255.0.0|access1|192.168.0.0/16|enb1|192.168.4.90
#00011d80|192.169.10.1|255.255.0.0|access2|192.169.0.0/16|enb2|192.168.4.91
#00011d90|192.170.10.1|255.255.0.0|access3|192.170.0.0/16|enb3|192.168.4.92
#MME version:
4568|192.168.10.1|255.255.0.0|access2|192.168.0.0/16|enb2|192.168.4.91
4569|192.169.10.1|255.255.0.0|access3|192.169.0.0/16|enb3|192.168.4.92
#4569|192.170.10.1|255.255.0.0|access3|192.170.0.0/16|enb3|192.168.4.92
1792|192.171.10.1|255.255.0.0|access1|192.171.0.0/16|penb1|192.168.4.100
001011234567890|001011234560306
1,001011234567899,192.168.7.10
2,001011234567890,192.168.7.10
3,001011234567891,192.168.7.10
4,001011234560306,192.168.7.10
SCRIPTS:
= demo_init.sh: initialize ovs and switches. Also start the SDN controller (MC.py)
= demo_restart.sh: restart mme, enbs, client, flush entries, and start the MC.py. The OAI eNodeB needs to be run manually.
STEPS:
= Need to change Nexus5's IMSI in demo_init.sh script. Nexus5's IMSI = 001011234560<PhantomNet UE'ID - 1>. Eg, UE4 --> IMSI=001011234560303
= Then demo_init.sh.
Opened windows:
- Window 1: alice, penb1 (Nexus 5), penb2, sgw (MC), sgw (MF), epc (HSS)
- Window 2: enb1, enb2 (for HO).
- Wireshark on sgw running.
1. Start OVS switches, eNBs, MF, MC: ./demo_init.sh
2. Demo steps:
- Demo 1: Attach Nexus 5: in penb1
/usr/local/src/airinterface/openairinterface5g/SCRIPTS/run_lte_softmodem.sh
Ping server:
adb shell
ping 192.168.7.10
- Demo 2: Attach Alice: in Alice:
mm.connect_l3 LTE
Nexus 5 pings Alice.
adb shell
ping <Alice's IP>
- Demo 3: Alice S1HO:
Nexus 5 pings Alice.
in eNB2/3:
1. enb3—>enb2: enodeb.utah_intra_lte_handover 001011234567890 01 4568 192.168.3.31
2. enb2—>enb3: enodeb.utah_intra_lte_handover 001011234567890 01 4569 192.168.3.32
<Continous ping flow>
3. Trouble shooting:
a. Attach reject after attach request Nexus 5:
Solution: In EPC node,
/proj/PhantomNet/binh/openepc/code/script/multiple_UEs/load_1_client.sh 001011234567899 491234567899 400
Flush mme.
Reconnect Nexus 5.
#!/bin/sh
source ../simeca_constants.sh
#
#Start components for ATT-demo.
#Run this on MF (MME) node.
#
echo "==========Starting OVS switches .... ==========="
cd $START_SCRIPTS
bash $START_SCRIPTS/start_switches.sh access1,access2,access3 tor,hsw1
echo "==========Adding IMSIs to HSS database .... ============"
ssh -o StrictHostKeyChecking=no epc.$domain -t -t "cd $HSS_PROVISION && sudo ./load_clients.sh 1 3"
ssh -o StrictHostKeyChecking=no epc.$domain -t -t "cd $HSS_PROVISION && sudo ./load_1_client.sh 001011234567899 491234567899 100"
ssh -o StrictHostKeyChecking=no epc.$domain -t -t "cd $HSS_PROVISION && sudo ./load_1_client.sh $NEXUS_IMSI $NEXUS_MISDN 200"
sudo bash -c 'echo "001011234567890|$NEXUS_IMSI" > $CONF_PATH/P2P_ATTACH.data' #for P2P HO
sudo bash -c 'echo "1,001011234567899,192.168.7.10" > $CONF_PATH/SERVER.data'
sudo bash -c 'echo "2,001011234567890,192.168.7.10" >> $CONF_PATH/SERVER.data'
sudo bash -c 'echo "3,001011234567891,192.168.7.10" >> $CONF_PATH/SERVER.data'
sudo bash -c 'echo "4,$NEXUS_IMSI,192.168.7.10" >> $CONF_PATH/SERVER.data'
echo "==========Starting eNBs and MF .... ============"
cd $EPC
bash $EPC/restart_epc.sh
echo "==========Starting MC .... ============"
cd $MC_PATH
sudo pip install MySQL-python
ryu-manager MC.py
#!/bin/bash
source ../simeca_constants.sh
#
#Start components for ATT-demo.
#Run this on MF (MME) node.
#
echo "==========Starting eNBs and MF .... ============"
cd $SIMECA_PATH
bash $SIMECA_PATH/restart_epc.sh
echo "==========Starting MC .... ============"
cd $MC_PATH
ps ax | grep MC | awk '{system("sudo kill "$1)}'
ryu-manager MC.py
#!/bin/bash
hn=$(hostname) ;
sudo sed -i "s/.*127.0.0.1.*/127.0.0.1 localhost loghost $hn/" /etc/hosts
put this folder in /usr/local/src/
#!/usr/bin/perl -w
BEGIN {
require "/etc/emulab/paths.pm";
import emulabpaths;
}
use libsetup;
my $FINDIF = "$BINDIR/findif";
# lans that this node is a member of.
#
my %ifmap = ();
my @ifconfigs = ();
if (getifconfig(\@ifconfigs) != 0) {
warn "Could not fetch Emulab interfaces configuration!";
return undef;
}
foreach my $ifconfig (@ifconfigs) {
my $ip = $ifconfig->{IPADDR};
my $mac = $ifconfig->{MAC};
my $lan = $ifconfig->{LAN};
next unless $mac && $lan;
#print "Debug: checking interface: $mac/$ip/$lan\n"
my $iface = `$FINDIF -m $mac`;
chomp $iface;
if ($? != 0 || !$iface) {
warn "Emulab's findif tool failed for ip address: $ip\n";
next;
}
print "$lan -> $iface -> $ip -> $mac\n";
}
#!/bin/bash
ovs-ofctl dump-ports-desc br0
#!/bin/bash
ps fax|grep "wharf -f" | grep "$1.xml"| awk '{}{print $0; system("kill -9 " $1);}'
ps fax|grep wpa_supplicant | awk '{}{print $0; system("kill -9 " $1);}'
#/bin/sh
source ../simeca_constants.sh
domain=$(hostname | awk -F'.' '{print $2"."$3"."$4"."$5}')
ssh -o StrictHostKeyChecking=no sgw.$domain -t -t "cd $EPC; sudo $EPC/start_mme.sh; echo mme.flush | nc -q 1 -u 192.168.254.80 10000" || {
echo "Could not restart mme!"
exit 1
}
echo mme.flush | nc -q 1 -u 192.168.254.80 10000
i=1
for e in enb2 enb3
do
let enb_offset=90+$i
ssh -o StrictHostKeyChecking=no $e.$domain -t -t "cd $EPC; sudo $EPC/start_enb.sh; echo enodeb.flush | nc -q 1 -u 192.168.254.$enb_offset 10000" || {
echo "Could not restart $e!"
exit 1
}
let i+=1
done
#Local client
ssh -o StrictHostKeyChecking=no client1.$domain -t -t "cd $EPC; sudo $EPC/start_mm.sh" || {
echo "Could not restart mm client $client!"
exit 1
}
#Restart client manually, need to enable this later
#for client in client1
#do
# ssh -o StrictHostKeyChecking=no $client.$domain "sudo /proj/PhantomNet/binh/openepc-att-demo/code/script/start.sh mm /opt/OpenEPC/etc/mm.xml" || {
# echo "Could not restart mm client $client!"
# exit 1
# }
#done
#!/bin/bash
source ../simeca_constants.sh
if [ $(whoami) != "root" ]; then
echo "This must be run as root"
exit 1
fi
if [ $# -lt 2 ]; then
echo "Usage: <service to start, eg, mme> <xml file path, eg, /opt/OpenEPC/etc/mme.xml>"
exit 1;
fi
cd $EPC
sudo $EPC/kill.sh
sudo /opt/OpenEPC/bin/$1.kill.sh
OFFSET_CELLID=4566
OFFSET_IP=29
OFFSET_MGN_IP=89
enb_name=$(hostname | cut -d"." -f1)
i=$((${#enb_name}-1))
enb=${enb_name:0:3}
enb_id=$(echo "${enb_name:$i:1}")
let cellid=$OFFSET_CELLID+$enb_id
let ip=$OFFSET_IP+$enb_id
let mgn_ip=$OFFSET_MGN_IP+$enb_id
an_lte_ip="192.168.3.$ip"
mgn="192.168.254.$mgn_ip"
imsi="001011234567890"
client_name=$(hostname | cut -d"." -f1)
case $client_name in
alice)
imsi="001011234567890"
c_name="Alice"
;;
bob)
imsi="001011234567891"
c_name="Bob"
;;
charlie)
imsi="001011234567892"
c_name="Charlie"
;;
*)
echo "Client name unknown!"
;;
esac
sudo cp $SIMECA_PATH/enodeb-ip-template.xml /opt/OpenEPC/etc/enodeb-ip.xml
sudo cp $SIMECA_PATH/mme.xml /opt/OpenEPC/etc/
sudo cp $SIMECA_PATH/mm.xml /opt/OpenEPC/etc/
sudo cp $SIMECA_PATH/mm_network.xml /opt/OpenEPC/etc/
net_c=$($SIMECA_PATH/get_interface_map.pl | grep an-lte | awk '{print $3}' )
if [ "$enb" == "enb" ]; then
sudo ifconfig $net_c $an_lte_ip
fi
#net_c_ip=$(/proj/PhantomNet/binh/openepc/code/script/iot-controller-no-tunel/get_interface_map.pl | grep an-lte | awk '{print $5}' )
net_c_ip=$an_lte_ip
net_d=$($SIMECA_PATH/get_interface_map.pl | grep net-d | awk '{print $3}' )
net_d_ip=$($SIMECA_PATH/get_interface_map.pl | grep net-d | awk '{print $5}' )
sudo sed -i "s/NET_C_IP/$net_c_ip/g" /opt/OpenEPC/etc/enodeb-ip.xml
sudo sed -i "s/NET_C/$net_c/g" /opt/OpenEPC/etc/enodeb-ip.xml
sudo sed -i "s/NET_D_IP/$net_d_ip/g" /opt/OpenEPC/etc/enodeb-ip.xml
sudo sed -i "s/NET_D/$net_d/g" /opt/OpenEPC/etc/enodeb-ip.xml
sudo sed -i "s/CELLID/$cellid/g" /opt/OpenEPC/etc/enodeb-ip.xml
sudo sed -i "s/eNodeB/$enb_name/g" /opt/OpenEPC/etc/enodeb-ip.xml
sudo sed -i "s/MGN/$mgn/g" /opt/OpenEPC/etc/enodeb-ip.xml
sudo sed -i "s/net_c/$net_c/g" /opt/OpenEPC/etc/mm.xml
sudo sed -i "s/001011234567890/$imsi/g" /opt/OpenEPC/etc/mm.xml
sudo sed -i "s/Alice/$c_name/g" /opt/OpenEPC/etc/mm.xml
cd $SIMECA_EPC/wharf_rel5
screen -S $1 -L -d -m -h 10000 /bin/bash -c "./wharf -f $2"
screen -wipe
exit 0
#!/bin/bash
source ../simeca_constants.sh
if [ $(whoami) != "root" ]; then
echo "This must be run as root"
exit 1
fi
cd $EPC
sudo /opt/OpenEPC/bin/enodeb.kill.sh
OFFSET_CELLID=4566
OFFSET_IP=29
OFFSET_MGN_IP=89
enb_name=$(hostname | cut -d"." -f1)
i=$((${#enb_name}-1))
enb=${enb_name:0:3}
enb_id=$(echo "${enb_name:$i:1}")
let cellid=$OFFSET_CELLID+$enb_id
let ip=$OFFSET_IP+$enb_id
let mgn_ip=$OFFSET_MGN_IP+$enb_id
an_lte_ip="192.168.3.$ip"
mgn="192.168.254.$mgn_ip"
sudo cp $XML/enodeb-ip-template.xml /opt/OpenEPC/etc/enodeb-ip.xml
net_c=$($START_SCRIPTS/get_interface_map.pl | grep an-lte | awk '{print $3}' )
if [ "$enb" == "enb" ]; then
sudo ifconfig $net_c $an_lte_ip
fi
net_c_ip=$an_lte_ip
net_d=$($START_SCRIPTS/get_interface_map.pl | grep net-d | awk '{print $3}' )
net_d_ip=$($START_SCRIPTS/get_interface_map.pl | grep net-d | awk '{print $5}' )
sudo sed -i "s/NET_C_IP/$net_c_ip/g" /opt/OpenEPC/etc/enodeb-ip.xml
sudo sed -i "s/NET_C/$net_c/g" /opt/OpenEPC/etc/enodeb-ip.xml
sudo sed -i "s/NET_D_IP/$net_d_ip/g" /opt/OpenEPC/etc/enodeb-ip.xml
sudo sed -i "s/NET_D/$net_d/g" /opt/OpenEPC/etc/enodeb-ip.xml
sudo sed -i "s/CELLID/$cellid/g" /opt/OpenEPC/etc/enodeb-ip.xml
sudo sed -i "s/eNodeB/$enb_name/g" /opt/OpenEPC/etc/enodeb-ip.xml
sudo sed -i "s/MGN/$mgn/g" /opt/OpenEPC/etc/enodeb-ip.xml
cd $SIMECA_EPC/wharf_rel5
screen -S enode -L -d -m -h 10000 /bin/bash -c "./wharf -f /opt/OpenEPC/etc/enodeb-ip.xml"
screen -wipe
exit 0
#!/bin/bash
source ../simeca_constants.sh
if [ $(whoami) != "root" ]; then
echo "This must be run as root"
exit 1
fi
cd $EPC
sudo /opt/OpenEPC/bin/mm.kill.sh
imsi="001011234567890"
client_name=$(hostname | cut -d"." -f1)
case $client_name in
alice)
imsi="001011234567890"
c_name="Alice"
;;
bob)
imsi="001011234567891"
c_name="Bob"
;;
charlie)
imsi="001011234567892"
c_name="Charlie"
;;
*)
echo "Client name unknown!"
;;
esac
sudo cp $XML/mm.xml /opt/OpenEPC/etc/
sudo cp $XML/mm_network.xml /opt/OpenEPC/etc/
net_c=$($START_SCRIPTS/get_interface_map.pl | grep an-lte | awk '{print $3}' )
sudo sed -i "s/net_c/$net_c/g" /opt/OpenEPC/etc/mm.xml
sudo sed -i "s/001011234567890/$imsi/g" /opt/OpenEPC/etc/mm.xml
sudo sed -i "s/Alice/$c_name/g" /opt/OpenEPC/etc/mm.xml
cd $SIMECA_EPC/wharf_rel5
screen -S mm -L -d -m -h 10000 /bin/bash -c "./wharf -f /opt/OpenEPC/etc/mm.xml"
screen -wipe
exit 0
#!/bin/bash
source ../simeca_constants.sh
if [ $(whoami) != "root" ]; then
echo "This must be run as root"
exit 1
fi
cd $EPC
sudo /opt/OpenEPC/bin/mme.kill.sh
sudo cp $XML/mme.xml /opt/OpenEPC/etc/
cd $SIMECA_EPC/wharf_rel5
screen -S mme -L -d -m -h 10000 /bin/bash -c "./wharf -f /opt/OpenEPC/etc/mme.xml"
screen -wipe
exit 0
import random
import subprocess
from subprocess import call
import os
import sys
START_IMSI=1234567890
NUM_ENB=3
CLOUD_SERVER_LIST=['192.168.7.10']
NUM_OF_CLIENT_SERVER=100 #how many servers are clients
def generate_sql(starting_id, number_of_entries, sql_file_name):
output = open(sql_file_name, "w")
imsi_file_1 = open("/tmp/IMSI_1.data","w")
imsi_file_2 = open("/tmp/IMSI_2.data","w")
imsi_file_3 = open("/tmp/IMSI_3.data","w")
imsi_server_file_1 = open("/tmp/SERVER_IMSI_1.data","w")
imsi_server_file_2 = open("/tmp/SERVER_IMSI_2.data","w")
imsi_server_file_3 = open("/tmp/SERVER_IMSI_3.data","w")
#imsi_file.write("starting_id=%d, #_of_entries=%d, sql_file=%s\n"%(starting_id, number_of_entries, sql_file_name))
ID = starting_id;
imsi_list = {}
imsi_file = imsi_file_1
imsi_server_file = imsi_server_file_1
cnt = 0
group = 0
ue_per_enb = number_of_entries/NUM_ENB
for i in range(0,number_of_entries):
if cnt==ue_per_enb:
group += 1
cnt = 0
if group == 1:
imsi_file = imsi_file_2
imsi_server_file = imsi_server_file_2
if group == 2:
imsi_server_file = imsi_server_file_3
imsi_file = imsi_file_3
ID += 1;
#imsi = "00101%d"%random.randint(1000000000,9999999999)
imsi = "00101%d"%(START_IMSI+i)
#while (imsi in imsi_list):
# imsi = "00101%d"%random.randint(1000000000,9999999999)
imsi_list[imsi] = 1
#imsi = "001011234567899"
server_index=random.randint(0,len(CLOUD_SERVER_LIST)-1)
imsi_file.write(str(ID)+","+imsi+","+CLOUD_SERVER_LIST[server_index]+"\n")
is_server_p = random.randint(0,ue_per_enb)
if is_server_p < NUM_OF_CLIENT_SERVER/NUM_ENB:
imsi_server_file.write(str(ID)+","+imsi+"\n")
cnt+=1
output.write("/* ---------%s--------- */\n"%imsi)
output.write("insert into imsu set id=%s, name='auto%s', id_capabilities_set=1;\n\n"%(ID,imsi))
output.write("insert into imsi set id=%s, id_imsu=%s, identity='%s',\n\
odb_barring=0, mme_address='', mme_realm='', sgsn_address='',\n\
sgsn_realm='', msc_address='', msc_realm='', apn_oi_replacement='',\n\
id_qos_profile_default=1, ics_indicator=1, network_access_mode=2,\n\
id_apn_configuration_profile=1, amf=0x8000,op='\\0\\0\\0\\0\\0\\0\\0\\0\\0\\0\\0\\0\\0\\0\\0\\0', non_3gpp_status=0;\n\n"%(ID, ID,imsi))
output.write("insert into imsi_allowed_apn set id_imsi=%s, id_apn_configuration_profile=1,priority=10;\n\n"%(ID))
output.write("insert into imsi_apn set id_imsi=%s, id_apn_configuration_profile=1,\n\
id_apn_configuration=4, ipv4='', ipv6='',\n\
pgw_identity='pgw.epc.mnc001.mcc001.3gppnetwork.org',\n\
pgw_realm='epc.mnc001.mcc001.3gppnetwork.org',\n\
pgw_ipv4='192.168.1.10', pgw_ipv6='fc00:1234:1::10', is_static_pgw=1;\n\n"%ID)
output.write("insert into imsi_visited_network set id_imsi=%s, id_visited_network=1;\n\n"%ID)
print "Done generating %d IMSI, sql file is %s, IMSI file is IMSI_1/2/3.data" % (number_of_entries, sql_file_name)
#returnval = execute_cmd("./load_clients.sh %s"%sql_file_name)
#returnval = call(["./load_clients.sh %s"%sql_file_name], shell=True)
#if (returnval>=0):
# print "Done adding %d imsis to the hss database. Sql file is %s" % (number_of_entries, sql_file_name)
#else:
# print "Error! Can't add imsis to hss database, sql file is %s" % sql_file_name
#labels = []
#values = []
#labels,values,types = read_file("imsu.data")
#create_sql_line("imsu", labels, values, types, "imsu.sql")
if __name__ == "__main__":
if (len(sys.argv) != 4):
print "Usage: <starting ID, eg, 100> <number of IMSI entries> <sql file name, eg, load_clients.sql>"
sys.exit(1)
else:
generate_sql(int(sys.argv[1]), int(sys.argv[2]), sys.argv[3])
sys.exit(0)
#!/bin/sh
if [ $# -lt 3 ]; then
echo "Usage: <IMSI, eg, 001011234567899> <MSISDN, eg,491234567899> <ID, eg, 12>"
exit 1
fi
IMSI=$1
MSISDN=$2
ID=$3
SQL_FILE=ue$IMSI-tmp.sql
echo "/*-------HSS database generated for IMSI $IMSI, MSISDN $MSISDN, ID $ID------*/" > $SQL_FILE
echo "delete from imsu where id=$ID;" >> $SQL_FILE
echo "delete from imsi where id=$ID;" >> $SQL_FILE
echo "delete from imsi_allowed_apn where id_imsi=$ID;" >> $SQL_FILE
echo "delete from imsi_apn where id_imsi=$ID;" >> $SQL_FILE
echo "delete from imsi_msisdn where id=$ID;" >> $SQL_FILE
echo "delete from imsi_visited_network where id_imsi=$ID;" >> $SQL_FILE
echo "delete from impu_visited_network where id=$ID;" >> $SQL_FILE
echo "delete from impi where id=$ID;" >> $SQL_FILE
echo "delete from impu where id=$ID;" >> $SQL_FILE
echo "delete from msisdn where id=$ID;" >> $SQL_FILE
echo "" >> $SQL_FILE
echo "insert into imsu set id=$ID, name='auto$IMSI', id_capabilities_set=1, id_preferred_scscf_set=1;" >> $SQL_FILE
echo "" >> $SQL_FILE
echo "insert into impu_visited_network set id=$ID, id_impu=$ID, id_visited_network=1;" >> $SQL_FILE
echo "" >> $SQL_FILE
echo "insert into imsi set id=$ID, id_imsu=$ID, identity='$IMSI',
odb_barring=0, mme_address='', mme_realm='', sgsn_address='',
sgsn_realm='', msc_address='', msc_realm='', apn_oi_replacement='',
id_qos_profile_default=2, ics_indicator=1, network_access_mode=2,
id_apn_configuration_profile=1,k=0x00112233445566778899aabbccddeeff,amf=0x8000,
op=0x01020304050607080910111213141516,non_3gpp_status=0;" >> $SQL_FILE
# /* op=0x01020304050607080910111213141516, sqn='000000002368',non_3gpp_status=0;" >> $SQL_FILE*/
echo "" >> $SQL_FILE
echo "insert into imsi_allowed_apn set id=$ID, id_imsi=$ID, id_apn_configuration_profile=1,priority=10;" >> $SQL_FILE
echo "" >> $SQL_FILE
echo "insert into imsi_apn set id_imsi=$ID, id_apn_configuration_profile=1,
id_apn_configuration=4, ipv4='', ipv6='',
pgw_identity='pgw.epc.mnc001.mcc001.3gppnetwork.org',
pgw_realm='epc.mnc001.mcc001.3gppnetwork.org',
pgw_ipv4='192.168.1.10', pgw_ipv6='fc00:1234:1::10', is_static_pgw=1;" >> $SQL_FILE
echo "" >> $SQL_FILE
echo "insert into imsi_msisdn set id=$ID, id_imsi=$ID,id_msisdn=$ID;" >> $SQL_FILE
echo "insert into imsi_visited_network set id_imsi=$ID, id_visited_network=1;" >> $SQL_FILE
echo "" >> $SQL_FILE
echo "insert into impi set id=$ID, id_imsu=$ID, identity='auto$IMSI@openepc.test',auth_scheme=71,
default_auth_scheme=1, k=0x00112233445566778899aabbccddeeff, amf=0x0000,
op=0x01020304050607080910111213141516, zh_uicc_type=0,
zh_key_life_time=3600, zh_default_auth_scheme=1;" >> $SQL_FILE
# op=0x01020304050607080910111213141516, sqn='000000000021', zh_uicc_type=0,
echo "" >> $SQL_FILE
echo "insert into impu set id=$ID, identity='sip:auto00101234567899@openepc.test',type=0,
barring=0, user_state=0, id_sp=0, id_implicit_set=1, id_charging_info=6,
psi_activation=0, can_register=1;" >> $SQL_FILE
echo "" >> $SQL_FILE
echo "insert into msisdn set id=$ID,identity=$MSISDN;" >> $SQL_FILE
echo "[INFO:] Generated HSS database entries for IMSI $IMSI, output is $SQL_FILE"
echo "[INFO:] Loading HSS database ... "
mysql -u hss -pheslo hss_db_chess < $SQL_FILE || {
echo "[Error:] Can't insert to database!"
exit 1
}
echo "[INFO:] Successfully insert HSS databse for IMSI $IMSI!"
#!/bin/sh
if [ $# -lt 4 ]; then
echo "Usage: <IMSI, eg, 001011234567899> <MSISDN, eg,491234567899> <ID, eg, 12> <SQN number>"
exit 1
fi
IMSI=$1
MSISDN=$2
ID=$3
sqn=$4
SQL_FILE=ue$IMSI-tmp.sql
echo "/*-------HSS database generated for IMSI $IMSI, MSISDN $MSISDN, ID $ID------*/" > $SQL_FILE
echo "delete from imsu where id=$ID;" >> $SQL_FILE
echo "delete from imsi where id=$ID;" >> $SQL_FILE
echo "delete from imsi_allowed_apn where id_imsi=$ID;" >> $SQL_FILE
echo "delete from imsi_apn where id_imsi=$ID;" >> $SQL_FILE
echo "delete from imsi_msisdn where id=$ID;" >> $SQL_FILE
echo "delete from imsi_visited_network where id_imsi=$ID;" >> $SQL_FILE
echo "delete from impu_visited_network where id=$ID;" >> $SQL_FILE
echo "delete from impi where id=$ID;" >> $SQL_FILE
echo "delete from impu where id=$ID;" >> $SQL_FILE
echo "delete from msisdn where id=$ID;" >> $SQL_FILE
echo "" >> $SQL_FILE
echo "insert into imsu set id=$ID, name='auto$IMSI', id_capabilities_set=1, id_preferred_scscf_set=1;" >> $SQL_FILE
echo "" >> $SQL_FILE
echo "insert into impu_visited_network set id=$ID, id_impu=$ID, id_visited_network=1;" >> $SQL_FILE
echo "" >> $SQL_FILE
echo "insert into imsi set id=$ID, id_imsu=$ID, identity='$IMSI',
odb_barring=0, mme_address='', mme_realm='', sgsn_address='',
sgsn_realm='', msc_address='', msc_realm='', apn_oi_replacement='',
id_qos_profile_default=2, ics_indicator=1, network_access_mode=2,
id_apn_configuration_profile=1,k=0x00112233445566778899aabbccddeeff,amf=0x8000,
op=0x01020304050607080910111213141516,sqn=$sqn,non_3gpp_status=0;" >> $SQL_FILE
# /* op=0x01020304050607080910111213141516, sqn='000000002368',non_3gpp_status=0;" >> $SQL_FILE*/
echo "" >> $SQL_FILE
echo "insert into imsi_allowed_apn set id=$ID, id_imsi=$ID, id_apn_configuration_profile=1,priority=10;" >> $SQL_FILE
echo "" >> $SQL_FILE
echo "insert into imsi_apn set id_imsi=$ID, id_apn_configuration_profile=1,
id_apn_configuration=4, ipv4='', ipv6='',
pgw_identity='pgw.epc.mnc001.mcc001.3gppnetwork.org',
pgw_realm='epc.mnc001.mcc001.3gppnetwork.org',
pgw_ipv4='192.168.1.10', pgw_ipv6='fc00:1234:1::10', is_static_pgw=1;" >> $SQL_FILE
echo "" >> $SQL_FILE
echo "insert into imsi_msisdn set id=$ID, id_imsi=$ID,id_msisdn=$ID;" >> $SQL_FILE
echo "insert into imsi_visited_network set id_imsi=$ID, id_visited_network=1;" >> $SQL_FILE
echo "" >> $SQL_FILE
echo "insert into impi set id=$ID, id_imsu=$ID, identity='auto$IMSI@openepc.test',auth_scheme=71,
default_auth_scheme=1, k=0x00112233445566778899aabbccddeeff, amf=0x0000,
op=0x01020304050607080910111213141516, zh_uicc_type=0,
zh_key_life_time=3600, zh_default_auth_scheme=1;" >> $SQL_FILE
# op=0x01020304050607080910111213141516, sqn='000000000021', zh_uicc_type=0,
echo "" >> $SQL_FILE
echo "insert into impu set id=$ID, identity='sip:auto00101234567899@openepc.test',type=0,
barring=0, user_state=0, id_sp=0, id_implicit_set=1, id_charging_info=6,
psi_activation=0, can_register=1;" >> $SQL_FILE
echo "" >> $SQL_FILE
echo "insert into msisdn set id=$ID,identity=$MSISDN;" >> $SQL_FILE
echo "Generated HSS database entries for IMSI $IMSI, output is $SQL_FILE"
echo "Loading HSS database ... "
mysql -u hss -pheslo hss_db_chess < $SQL_FILE || {
echo "[Error:] Can't insert to database!"
exit 1
}
rm $SQL_FILE
echo "Successfully insert HSS databse for IMSI $IMSI!"
\ No newline at end of file
#!/bin/sh
if [ $# -lt 4 ]; then
echo "Usage: <IMSI, eg, 001011234567899> <MSISDN, eg,491234567899> <ID, eg, 12> <SQN number>"
exit 1
fi
IMSI=$1
MSISDN=$2
ID=$3
sqn=$4
SQL_FILE=ue$IMSI-tmp.sql
echo "/*-------HSS database generated for IMSI $IMSI, MSISDN $MSISDN, ID $ID------*/" > $SQL_FILE
echo "delete from imsu where id=$ID;" >> $SQL_FILE
echo "delete from imsi where id=$ID;" >> $SQL_FILE
echo "delete from imsi_allowed_apn where id_imsi=$ID;" >> $SQL_FILE
echo "delete from imsi_apn where id_imsi=$ID;" >> $SQL_FILE
echo "delete from imsi_msisdn where id=$ID;" >> $SQL_FILE
echo "delete from imsi_visited_network where id_imsi=$ID;" >> $SQL_FILE
echo "delete from impu_visited_network where id=$ID;" >> $SQL_FILE
echo "delete from impi where id=$ID;" >> $SQL_FILE
echo "delete from impu where id=$ID;" >> $SQL_FILE
echo "delete from msisdn where id=$ID;" >> $SQL_FILE
echo "" >> $SQL_FILE
echo "insert into imsu set id=$ID, name='auto$IMSI', id_capabilities_set=1, id_preferred_scscf_set=1;" >> $SQL_FILE
echo "" >> $SQL_FILE
echo "insert into impu_visited_network set id=$ID, id_impu=$ID, id_visited_network=1;" >> $SQL_FILE
echo "" >> $SQL_FILE
echo "insert into imsi set id=$ID, id_imsu=$ID, identity='$IMSI',
odb_barring=0, mme_address='', mme_realm='', sgsn_address='',
sgsn_realm='', msc_address='', msc_realm='', apn_oi_replacement='',
id_qos_profile_default=2, ics_indicator=1, network_access_mode=2,
id_apn_configuration_profile=1,k=0x00112233445566778899aabbccddeeff,amf=0x8000,
op=0x01020304050607080910111213141516,sqn=$sqn,non_3gpp_status=0;" >> $SQL_FILE