Commit fa3dd1c5 authored by Tien-Thinh Nguyen's avatar Tien-Thinh Nguyen

Merge branch 'ngap_sm_v1.0' into develop

parents 93aba0b4 4c2cfe07
......@@ -28,7 +28,17 @@ openair-cn5g-smf
├── utils: Common utilities.  
└── udp : UDP server implementation.
# OAI-SMF
# OAI-SMF testbed: network topology
AMF (eno1:amf 172.16.1.102)-----------------SBI interfaces-----------------(eno1:udm 172.16.1.103) UDM
|
|
(eno1:smf 172.16.1.101)
SMF
(eno1:sn4 172.16.2.101)
|
|
(eno1:sn4 172.16.2.102)
gNB (172.16.3.101)---(eno1:s1u 172.16.3.102)UPF/SPGW-U (SGI: eno1)----------------------------DNN
## Download source code from Gitlab
git clone https://gitlab.eurecom.fr/oai/oai-cn5g-smf/
......@@ -54,7 +64,8 @@ cd /openair-cn-cups/build/scripts
./build_spgwu -I -f
./build_spgwu -c -V -b Debug -j
cp /oai-cn5g-smf/src/test/upf/spgwu_conf.sh .
#configure SPGWU using an example configure file (spgw_u.conf)
cd /oai-cn5g-smf/src/test/upf/
./spgwu_conf.sh
sudo spgwu -c /usr/local/etc/oai/spgw_u.conf -o
......@@ -64,7 +75,7 @@ mkdir build
cd build
cmake ..
make
./udm-server
sudo ./udm-server
## Build and launch AMF server
cd /oai-cn5g-smf/src/test/amf
......@@ -72,7 +83,7 @@ mkdir build
cd build
cmake ..
make
./amf-api-server
sudo ./amf-server
## Build and launch AMF client
cd /oai-cn5g-smf/src/test/amf_client
......
......@@ -2,7 +2,9 @@
sudo ifconfig eno1:smf 172.16.1.101 up # SMF
sudo ifconfig eno1:amf 172.16.1.102 up # AMF
sudo ifconfig eno1:udm 172.16.1.103 up # UDM
sudo ifconfig eno1:upf 172.16.1.104 up # UPF
sudo ifconfig eno1:sn4 172.16.2.101 up # SMF N4 interface
sudo ifconfig eno1:un4 172.16.2.102 up # UPF N4 interface
INSTANCE=1
PREFIX='/usr/local/etc/oai'
......@@ -14,19 +16,20 @@ declare -A SMF_CONF
SMF_CONF[@INSTANCE@]=$INSTANCE
SMF_CONF[@PREFIX@]=$PREFIX
SMF_CONF[@PID_DIRECTORY@]='/var/run'
SMF_CONF[@SMF_INTERFACE_NAME_FOR_N4@]='eno1:smf'
SMF_CONF[@SMF_INTERFACE_NAME_FOR_N11@]='eno1:smf'
SMF_CONF[@SMF_INTERFACE_IPV4_ADDRESS_FOR_N11@]='172.16.1.101'
SMF_CONF[@SMF_INTERFACE_PORT_FOR_N11@]='80'
SMF_CONF[@SMF_INTERFACE_NAME_FOR_N4@]='eno1:sn4'
SMF_CONF[@SMF_INTERFACE_NAME_FOR_SBI@]='eno1:smf'
SMF_CONF[@SMF_INTERFACE_IPV4_ADDRESS_FOR_SBI@]='172.16.1.101'
SMF_CONF[@SMF_INTERFACE_PORT_FOR_SBI@]='80'
SMF_CONF[@UDM_IPV4_ADDRESS@]='172.16.1.103'
SMF_CONF[@UDM_PORT@]='8383'
SMF_CONF[@UDM_PORT@]='80'
SMF_CONF[@AMF_IPV4_ADDRESS@]='172.16.1.102'
SMF_CONF[@AMF_PORT@]='8282'
SMF_CONF[@AMF_PORT@]='80'
SMF_CONF[@UPF_IPV4_ADDRESS@]='172.16.1.104'
SMF_CONF[@UPF_IPV4_ADDRESS@]='172.16.2.102'
SMF_CONF[@DEFAULT_DNS_IPV4_ADDRESS@]='8.8.8.8'
SMF_CONF[@DEFAULT_DNS_SEC_IPV4_ADDRESS@]='4.4.4.4'
......
......@@ -23,28 +23,6 @@ SMF =
INSTANCE = @INSTANCE@; # 0 is the default
PID_DIRECTORY = "@PID_DIRECTORY@"; # /var/run is the default
#ITTI_TASKS :
#{
#ITTI_TIMER_SCHED_PARAMS :
#{
#CPU_ID = 1;
#SCHED_POLICY = "SCHED_FIFO"; # Values in { SCHED_OTHER, SCHED_IDLE, SCHED_BATCH, SCHED_FIFO, SCHED_RR }
#SCHED_PRIORITY = 85;
#};
#SMF_APP_SCHED_PARAMS :
#{
#CPU_ID = 1;
#SCHED_POLICY = "SCHED_FIFO"; # Values in { SCHED_OTHER, SCHED_IDLE, SCHED_BATCH, SCHED_FIFO, SCHED_RR }
#SCHED_PRIORITY = 84;
#};
#ASYNC_CMD_SCHED_PARAMS :
#{
#CPU_ID = 1;
#SCHED_POLICY = "SCHED_FIFO"; # Values in { SCHED_OTHER, SCHED_IDLE, SCHED_BATCH, SCHED_FIFO, SCHED_RR }
#SCHED_PRIORITY = 84;
#};
#};
INTERFACES :
{
N4 :
......@@ -54,16 +32,16 @@ SMF =
IPV4_ADDRESS = "read"; # STRING, CIDR or "read" to let app read interface configured IP address
};
N11 :
SBI :
{
# SMF binded interface for N11 communication (AMF)
INTERFACE_NAME = "@SMF_INTERFACE_NAME_FOR_N11@"; # STRING, interface name
#IPV4_ADDRESS = "@SMF_INTERFACE_IPV4_ADDRESS_FOR_N11@"; # STRING, CIDR or "read" to let app read interface configured IP address
# SMF binded interface for SBI interface (e.g., communication with AMF, UDM)
INTERFACE_NAME = "@SMF_INTERFACE_NAME_FOR_SBI@"; # STRING, interface name
#IPV4_ADDRESS = "@SMF_INTERFACE_IPV4_ADDRESS_FOR_SBI@"; # STRING, CIDR or "read" to let app read interface configured IP address
IPV4_ADDRESS = "read";
PORT = @SMF_INTERFACE_PORT_FOR_N11@
PORT = @SMF_INTERFACE_PORT_FOR_SBI@ #Normally we don't need this (default port 80)
};
TEST_UPF :
TEST_UPF : #for BUPT test only!
{
# P-GW binded interface for SX communication
IS_TEST = "0"; # 0: no test,1:test
......@@ -120,12 +98,12 @@ SMF =
AMF :
{
IPV4_ADDRESS="@AMF_IPV4_ADDRESS@";
PORT = @AMF_PORT@;
PORT = @AMF_PORT@; #should be removed (default: 80)
};
UDM :
{
IPV4_ADDRESS="@UDM_IPV4_ADDRESS@";
PORT = @UDM_PORT@;
PORT = @UDM_PORT@; #should be removed (default 80)
};
UPF_LIST = (
......
......@@ -207,4 +207,7 @@ static const std::vector<std::string> multipart_related_content_part_e2str = {
"NGAP"
};
#define NAMF_COMMUNICATION_N1N2_MESSAGE_TRANSFER_URL "/namf-comm/v2/ue-contexts/{}/n1-n2-messages" //may get from configuration file
#define NUDM_SDM_GET_SM_DATA_URL "/nudm-sdm/v2/{}/sm-data" //may get from configuration file
#endif
This diff is collapsed.
#ifndef NG_PDU_DOWNLINK_RAN_STATUS_TRANSFER_H_
#define NG_PDU_DOWNLINK_RAN_STATUS_TRANSFER_H_
int make_NGAP_PduDownlinkRanStatusTransfer(const char *inputBuf, const char *outputBuf);
#endif
#include "ng_pdu_handover_cancel.h"
#include "Ngap_NGAP-PDU.h"
#include "Ngap_ProtocolIE-Field.h"
#include "Ngap_ProcedureCode.h"
#include "Ngap_InitiatingMessage.h"
#include "Ngap_HandoverCancel.h"
#include "Ngap_CauseRadioNetwork.h"
#include "Ngap_DirectForwardingPathAvailability.h"
#include "common_defs.h"
#include "common_types.h"
#include "../common/ngap/ngap_common.h"
#include "INTEGER.h"
#include "asn_SEQUENCE_OF.h"
#include "OCTET_STRING.h"
#define BUF_LEN 1024
Ngap_HandoverCancelIEs_t *make_handover_cancel_RAN_UE_NGAP_ID(uint32_t rAN_UE_NGAP_ID)
{
Ngap_HandoverCancelIEs_t *ie;
ie = calloc(1, sizeof(Ngap_HandoverCancelIEs_t));
ie->id = Ngap_ProtocolIE_ID_id_RAN_UE_NGAP_ID;
ie->criticality = Ngap_Criticality_reject;
ie->value.present = Ngap_HandoverCancelIEs__value_PR_RAN_UE_NGAP_ID;
ie->value.choice.RAN_UE_NGAP_ID = rAN_UE_NGAP_ID ;
printf("RAN_UE_NGAP_ID:0x%x\n",ie->value.choice.RAN_UE_NGAP_ID);
return ie;
}
Ngap_HandoverCancelIEs_t *make_handover_cancel_AMF_UE_NGAP_ID(uint64_t amf_UE_NGAP_ID)
{
Ngap_HandoverCancelIEs_t *ie = NULL;
ie = calloc(1, sizeof(Ngap_HandoverCancelIEs_t));
ie->id = Ngap_ProtocolIE_ID_id_AMF_UE_NGAP_ID;
ie->criticality = Ngap_Criticality_reject;
ie->value.present = Ngap_HandoverCancelIEs__value_PR_AMF_UE_NGAP_ID;
asn_ulong2INTEGER(&ie->value.choice.AMF_UE_NGAP_ID, amf_UE_NGAP_ID & AMF_UE_NGAP_ID_MASK_);
printf("AMF_UE_NGAP_ID:0x%x\n",ie->value.choice.AMF_UE_NGAP_ID);
return ie;
}
Ngap_HandoverCancelIEs_t *make_handover_cancel_CauseRadioNetwork(const long radioNetwork)
{
Ngap_HandoverCancelIEs_t *ie = NULL;
ie = calloc(1, sizeof(Ngap_HandoverCancelIEs_t));
ie->id = Ngap_ProtocolIE_ID_id_Cause;
ie->criticality = Ngap_Criticality_ignore;
ie->value.present = Ngap_HandoverCancelIEs__value_PR_Cause;
ie->value.choice.Cause.present = Ngap_Cause_PR_radioNetwork;
ie->value.choice.Cause.choice.radioNetwork = radioNetwork;
printf("radioNetwork:0x%x\n",ie->value.choice.Cause.choice.radioNetwork);
return ie;
}
void add_pdu_handover_cancel_ie(Ngap_HandoverCancel_t *ngapPDUHandoverCancel, Ngap_HandoverCancelIEs_t *ie) {
int ret;
ret = ASN_SEQUENCE_ADD(&ngapPDUHandoverCancel->protocolIEs.list, ie);
if ( ret != 0 ) {
fprintf(stderr, "Failed to add ie\n");
return ;
}
return ;
}
Ngap_NGAP_PDU_t * ngap_generate_ng_handover_cancel(const char *inputBuf)
{
Ngap_NGAP_PDU_t * pdu = NULL;
pdu = calloc(1, sizeof(Ngap_NGAP_PDU_t));
pdu->present = Ngap_NGAP_PDU_PR_initiatingMessage;
pdu->choice.initiatingMessage = calloc(1, sizeof(Ngap_InitiatingMessage_t));
pdu->choice.initiatingMessage->procedureCode = Ngap_ProcedureCode_id_HandoverCancel;
pdu->choice.initiatingMessage->criticality = Ngap_Criticality_reject;
pdu->choice.initiatingMessage->value.present = Ngap_InitiatingMessage__value_PR_HandoverCancel;
Ngap_HandoverCancel_t *ngapHandoverCancel= NULL;
ngapHandoverCancel = &pdu->choice.initiatingMessage->value.choice.HandoverCancel;
Ngap_HandoverCancelIEs_t *ie = NULL;
//Ngap_AMF_UE_NGAP_ID_t
uint64_t amf_ue_ngap_id = 0x80;
ie = make_handover_cancel_AMF_UE_NGAP_ID(amf_ue_ngap_id);
add_pdu_handover_cancel_ie(ngapHandoverCancel, ie);
//Ngap_AMF_UE_NGAP_ID_t
uint32_t ran_ue_ngap_id = 0x81;
ie = make_handover_cancel_RAN_UE_NGAP_ID(ran_ue_ngap_id);
add_pdu_handover_cancel_ie(ngapHandoverCancel, ie);
//Cause:CauseRadioNetwork
ie = make_handover_cancel_CauseRadioNetwork(Ngap_CauseRadioNetwork_unspecified);
add_pdu_handover_cancel_ie(ngapHandoverCancel, ie);
return pdu;
}
int
ngap_amf_handle_ng_pdu_handover_cancel(
const sctp_assoc_id_t assoc_id,
const sctp_stream_id_t stream,
Ngap_NGAP_PDU_t *pdu){
int rc = RETURNok;
#if 0
gnb_description_t * gnb_association = NULL;
//gnb_description_t * gnb_ref = NULL;
uint32_t gnb_id = 0;
char *gnb_name = NULL;
int gnb_name_size = 0;
int ta_ret = 0;
uint32_t max_gnb_connected = 0;
int i = 0;
#endif
int i = 0;
Ngap_HandoverCancel_t *container = NULL;
Ngap_HandoverCancelIEs_t *ie = NULL;
Ngap_HandoverCancelIEs_t *ie_gnb_name = NULL;
unsigned long amf_ue_ngap_id = 0;
uint32_t ran_ue_ngap_id = 0;
uint32_t radioNetwork = 0;
uint32_t DirectForwardingPathAvailability = 0;
DevAssert (pdu != NULL);
//OAILOG_INFO(LOG_NGAP,"----------------------- DECODED NG SETUP REQUEST NGAP MSG --------------------------\n");
//asn_fprint(stdout, &asn_DEF_Ngap_NGAP_PDU, pdu);
//OAILOG_INFO(LOG_NGAP,"----------------------- DECODED NG SETUP REQUEST NGAP MSG --------------------------\n");
container = &pdu->choice.initiatingMessage->value.choice.HandoverCancel;
//AMF_UE_NGAP_ID
NGAP_FIND_PROTOCOLIE_BY_ID(Ngap_HandoverCancelIEs_t, ie, container, Ngap_ProtocolIE_ID_id_AMF_UE_NGAP_ID, false);
if (ie)
{
asn_INTEGER2ulong(&ie->value.choice.AMF_UE_NGAP_ID, &amf_ue_ngap_id);
printf("amf_ue_ngap_id, 0x%x\n", amf_ue_ngap_id);
}
//Ngap_AMF_UE_NGAP_ID_t
NGAP_FIND_PROTOCOLIE_BY_ID(Ngap_HandoverCancelIEs_t, ie, container, Ngap_ProtocolIE_ID_id_RAN_UE_NGAP_ID, false);
if (ie)
{
ran_ue_ngap_id = ie->value.choice.RAN_UE_NGAP_ID;
printf("ran_ue_ngap_id, 0x%x\n", ran_ue_ngap_id);
}
//cause
NGAP_FIND_PROTOCOLIE_BY_ID(Ngap_HandoverCancelIEs_t, ie, container, Ngap_ProtocolIE_ID_id_Cause, false);
if (ie)
{
switch(ie->value.choice.Cause.present)
{
case Ngap_Cause_PR_radioNetwork:
{
radioNetwork = ie->value.choice.Cause.choice.radioNetwork ;
printf("radioNetwork, 0x%x\n", radioNetwork);
}
break;
case Ngap_Cause_PR_transport:
{
}
break;
case Ngap_Cause_PR_nas:
{
}
break;
case Ngap_Cause_PR_protocol:
{
}
break;
case Ngap_Cause_PR_misc:
{
}
break;
default:
printf("don't know cause type:%d\n", ie->value.choice.Cause.present);
break;
}
}
}
int make_NGAP_PduHandOverCancel(const char *inputBuf, const char *OutputBuf)
{
printf("pdu session hand over cancel, start--------------------\n\n");
int ret = 0;
int rc = RETURNok;
const sctp_assoc_id_t assoc_id = 0;
const sctp_stream_id_t stream = 0;
Ngap_NGAP_PDU_t message = {0};
//wys: 1024 ?
size_t buffer_size = 1024;
void *buffer = calloc(1,buffer_size);
asn_enc_rval_t er;
Ngap_NGAP_PDU_t * pdu = ngap_generate_ng_handover_cancel(inputBuf);
if(!pdu)
goto ERROR;
asn_fprint(stderr, &asn_DEF_Ngap_NGAP_PDU, pdu);
ret = check_NGAP_pdu_constraints(pdu);
if(ret < 0)
{
printf("ng hand over cancel Constraint validation failed\n");
rc = RETURNerror;
goto ERROR;
}
//encode
er = aper_encode_to_buffer(&asn_DEF_Ngap_NGAP_PDU, NULL, pdu, buffer, buffer_size);
if(er.encoded < 0)
{
printf("ng hand over cancel encode failed,er.encoded:%d\n",er.encoded);
rc = RETURNerror;
goto ERROR;
}
bstring msgBuf = blk2bstr(buffer, er.encoded);
//decode
ngap_amf_decode_pdu(&message, msgBuf);
ngap_amf_handle_ng_pdu_handover_cancel(0,0, &message);
//Free pdu
ASN_STRUCT_FREE(asn_DEF_Ngap_NGAP_PDU, pdu);
if(buffer)
{
free(buffer);
buffer = NULL;
}
printf("pdu session hand over cancel, finish--------------------\n\n");
return rc;
ERROR:
//Free pdu
if(pdu)
ASN_STRUCT_FREE(asn_DEF_Ngap_NGAP_PDU, pdu);
if(buffer)
{
free(buffer);
buffer = NULL;
}
return rc;
}
#ifndef NG_PDU_HANDOVER_CANCEL_H_
#define NG_PDU_HANDOVER_CANCEL_H_
int make_NGAP_PduHandOverCancel(const char *inputBuf, const char *outputBuf);
#endif
This diff is collapsed.
#ifndef NG_PDU_HANDOVER_CANCEL_ACKNOWLEDGE_H_
#define NG_PDU_HANDOVER_CANCEL_ACKNOWLEDGE_H_
int make_NGAP_PduHandOverCancelAck(const char *inputBuf, const char *outputBuf);
#endif
This diff is collapsed.
#ifndef NG_PDU_HANDOVER_COMMAND_H_
#define NG_PDU_HANDOVER_COMMAND_H_
int make_NGAP_PduHandOverCommand(const char *inputBuf, const char *outputBuf);
#endif
This diff is collapsed.
#ifndef NG_PDU_HANDOVER_FAILURE_H_
#define NG_PDU_HANDOVER_FAILURE_H_
int make_NGAP_PduHandOver_Failure(const char *inputBuf, const char *outputBuf);
#endif
This diff is collapsed.
#ifndef NG_PDU_HANDOVER_NOTIFY_H_
#define NG_PDU_HANDOVER_NOTIFY_H_
int make_NGAP_PduHandOver_Notify(const char *inputBuf, const char *outputBuf);
#endif
This diff is collapsed.
#ifndef NG_PDU_HANDOVER_PREPARATION_FAILURE_H_
#define NG_PDU_HANDOVER_PREPARATION_FAILURE_H_
int make_NGAP_PduHandOverPreFailure(const char *inputBuf, const char *outputBuf);
#endif
This diff is collapsed.
#ifndef NG_PDU_HANDOVER_REQUEST_H_
#define NG_PDU_HANDOVER_REQUEST_H_
int make_NGAP_PduHandOverRequest(const char *inputBuf, const char *outputBuf);
#endif
This diff is collapsed.
#ifndef NG_PDU_HANDOVER_REQUEST_ACKNOWLEDGE_H_
#define NG_PDU_HANDOVER_REQUEST_ACKNOWLEDGE_H_
int make_NGAP_PduHandOver_Req_Ack(const char *inputBuf, const char *outputBuf);
#endif
This diff is collapsed.
#ifndef NG_PDU_HANDOVER_REQUIRED_H_
#define NG_PDU_HANDOVER_REQUIRED_H_
int make_NGAP_PduHandOverRequired(const char *inputBuf, const char *outputBuf);
#endif
This diff is collapsed.
#ifndef NG_PDU_PATH_SWITCH_REQUEST_H_
#define NG_PDU_PATH_SWITCH_REQUEST_H_
int make_NGAP_PduPathSwitchRequest(const char *inputBuf, const char *OutputBuf);
#endif
This diff is collapsed.
#ifndef NG_PDU_PATH_SWITCH_REQUEST_ACKNOWLEDGE_H_
#define NG_PDU_PATH_SWITCH_REQUEST_ACKNOWLEDGE_H_
int make_NGAP_PduPathSwitchRequestAck(const char *inputBuf, const char *outputBuf);
#endif
This diff is collapsed.
#ifndef NG_PDU_PATH_SWITCH_REQUEST_FAILURE_H_
#define NG_PDU_PATH_SWITCH_REQUEST_FAILURE_H_
int make_NGAP_PduPathSwitchRequestFailure(const char *inputBuf, const char *outputBuf);
#endif
This diff is collapsed.
#ifndef NG_PDU_SESSOIN_RESOURCE_MODIFY_CONFIRM_H_
#define NG_PDU_SESSOIN_RESOURCE_MODIFY_CONFIRM_H_
int make_NGAP_PduSessionResourceModifyConfirm(const char *inputBuf, const char *outputBuf);
#endif
#ifndef NG_PDU_SESSOIN_RESOURCE_MODIFY_INDICATION_H_
#define NG_PDU_SESSOIN_RESOURCE_MODIFY_INDICATION_H_
int make_NGAP_PduSessionResourceModifyIndication(const char *inputBuf, const char *outputBuf);
#endif
This diff is collapsed.
#ifndef NG_PDU_SESSOIN_RESOURCE_MODIFY_REQUEST_H_
#define NG_PDU_SESSOIN_RESOURCE_MODIFY_REQUEST_H_
int make_NGAP_PduSessionResourceModifyRequest(const char *inputBuf, const char *outputBuf);
#endif
This diff is collapsed.
#ifndef NG_PDU_SESSOIN_RESOURCE_MODIFY_RESPONSE_H_
#define NG_PDU_SESSOIN_RESOURCE_MODIFY_RESPONSE_H_
int make_NGAP_PduSessionResourceModifyResponse(const char *inputBuf, const char *outputBuf);
#endif
This diff is collapsed.
#ifndef NG_PDU_SESSOIN_RESOURCE_NOTIFY_H_
#define NG_PDU_SESSOIN_RESOURCE_NOTIFY_H_
int make_NGAP_PduSessionResourceNotify(const char *inputBuf, const char *outputBuf);
#endif
This diff is collapsed.
#ifndef NG_PDU_SESSOIN_RESOURCE_RELEASE_COMMAND_H_
#define NG_PDU_SESSOIN_RESOURCE_RELEASE_COMMAND_H_
int make_NGAP_PduSessionResourceReleaseCommand(const char *inputBuf, const char *outputBuf);
#endif
#ifndef NG_PDU_SESSOIN_RESOURCE_RELEASE_RESPONSE_H_
#define NG_PDU_SESSOIN_RESOURCE_RELEASE_RESPONSE_H_
int make_NGAP_PduSessionResourceReleaseResponse(const char *inputBuf, const char *outputBuf);
#endif
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment