Unverified Commit e09eae68 authored by kharade's avatar kharade

first version of usage report feature

parent 16a9e880
......@@ -78,7 +78,8 @@ SMF =
USE_LOCAL_SUBSCRIPTION_INFO = "@USE_LOCAL_SUBSCRIPTION_INFO@"; # Set to yes if SMF uses local subscription information instead of from an UDM
USE_FQDN_DNS = "@USE_FQDN_DNS@"; # Set to yes if AMF/UDM/NRF/UPF will relying on a DNS to resolve FQDN
HTTP_VERSION = @HTTP_VERSION@; # Default: 1
USE_NETWORK_INSTANCE = "@USE_NETWORK_INSTANCE@" # Set yes if network instance is to be used for given UPF
USE_NETWORK_INSTANCE = "@USE_NETWORK_INSTANCE@" # Set yes if network instance is to be used for given UPF
ENABLE_USAGE_REPORTING = "@ENABLE_USAGE_REPORTING@" # Set yes if UE USAGE REPORTING is to be done at UPF
}
AMF :
......
......@@ -5,7 +5,7 @@ set -euo pipefail
CONFIG_DIR="/openair-smf/etc"
# Default values
# (Default NWI Domain for all UPFs in OAI-Integration)
ENABLE_USAGE_REPORTING=${ENABLE_USAGE_REPORTING:-no}
USE_NETWORK_INSTANCE=${USE_NETWORK_INSTANCE:-no}
USE_LOCAL_SUBSCRIPTION_INFO=${USE_LOCAL_SUBSCRIPTION_INFO:-yes}
DOMAIN_ACCESS=${DOMAIN_ACCESS:-access.oai.org}
......
......@@ -5100,6 +5100,7 @@ class usage_report_within_pfcp_session_report_request
// std::pair<bool, pfcp::event_reporting> event_reporting;
std::pair<bool, pfcp::ethernet_traffic_information>
ethernet_traffic_information;
std::pair<bool, pfcp::enterprise_specific_t> enterprise_specific;
usage_report_within_pfcp_session_report_request()
: urr_id(),
......@@ -5117,7 +5118,8 @@ class usage_report_within_pfcp_session_report_request
usage_information(),
query_urr_reference(),
// event_reporting(),
ethernet_traffic_information() {}
ethernet_traffic_information(),
enterprise_specific() {}
usage_report_within_pfcp_session_report_request(
const usage_report_within_pfcp_session_report_request& u)
......@@ -5136,7 +5138,8 @@ class usage_report_within_pfcp_session_report_request
usage_information(u.usage_information),
query_urr_reference(u.query_urr_reference),
// event_reporting(u.event_reporting),
ethernet_traffic_information(u.ethernet_traffic_information) {}
ethernet_traffic_information(u.ethernet_traffic_information),
enterprise_specific(u.enterprise_specific) {}
// virtual ~usage_report_within_pfcp_session_report_request() {};
void set(const pfcp::urr_id_t& v) {
......@@ -5201,6 +5204,10 @@ class usage_report_within_pfcp_session_report_request
ethernet_traffic_information.first = true;
ethernet_traffic_information.second = v;
}
void set(const pfcp::enterprise_specific_t& v) {
enterprise_specific.first = true;
enterprise_specific.second = v;
}
bool get(pfcp::urr_id_t& v) const {
if (urr_id.first) {
......@@ -5300,6 +5307,13 @@ class usage_report_within_pfcp_session_report_request
}
return false;
}
bool get(pfcp::enterprise_specific_t& v) const {
if (enterprise_specific.first) {
v = enterprise_specific.second;
return true;
}
return false;
}
// bool get(pfcp::event_reporting& v) const {if (event_reporting.first) {v =
// event_reporting.second;return true;}return false;}
bool get(pfcp::ethernet_traffic_information& v) const {
......@@ -7244,15 +7258,16 @@ class pfcp_session_report_request : public pfcp_ies_container {
overload_control_information(),
additional_usage_reports_information() {}
pfcp_session_report_request(const pfcp_session_report_request& i)
: report_type(i.report_type),
downlink_data_report(i.downlink_data_report),
usage_report(i.usage_report),
error_indication_report(i.error_indication_report),
load_control_information(i.load_control_information),
overload_control_information(i.overload_control_information),
additional_usage_reports_information(
i.additional_usage_reports_information) {}
pfcp_session_report_request(const pfcp_session_report_request& i) {
report_type = i.report_type;
downlink_data_report = i.downlink_data_report;
usage_report = i.usage_report;
error_indication_report = i.error_indication_report;
load_control_information = i.load_control_information;
overload_control_information = i.overload_control_information;
additional_usage_reports_information =
i.additional_usage_reports_information;
}
const char* get_msg_name() const { return "PFCP_SESSION_REPORT_REQUEST"; };
......
......@@ -530,6 +530,14 @@ int smf_config::load(const string& config_file) {
use_nwi = false;
}
support_features.lookupValue(
SMF_CONFIG_STRING_SUPPORT_FEATURES_ENABLE_USAGE_REPORTING, opt);
if (boost::iequals(opt, "yes")) {
enable_ur = true;
} else {
enable_ur = false;
}
} catch (const SettingNotFoundException& nfex) {
Logger::smf_app().error(
"%s : %s, using defaults", nfex.what(), nfex.getPath());
......
......@@ -149,6 +149,8 @@
#define SMF_CONFIG_STRING_SUPPORT_FEATURES_SBI_HTTP_VERSION "HTTP_VERSION"
#define SMF_CONFIG_STRING_SUPPORT_FEATURES_USE_NETWORK_INSTANCE \
"USE_NETWORK_INSTANCE"
#define SMF_CONFIG_STRING_SUPPORT_FEATURES_ENABLE_USAGE_REPORTING \
"ENABLE_USAGE_REPORTING"
#define SMF_MAX_ALLOCATED_PDN_ADDRESSES 1024
......@@ -231,6 +233,7 @@ class smf_config {
bool use_fqdn_dns;
unsigned int http_version;
bool use_nwi;
bool enable_ur;
struct {
struct in_addr ipv4_addr;
......
......@@ -636,6 +636,16 @@ void smf_pdu_session::get_upf_node_id(pfcp::node_id_t& node_id) const {
pfcp::node_id_t smf_pdu_session::get_upf_node_id() const {
return upf_node_id;
}
//-----------------------------------------------------------------------------
void smf_pdu_session::set_urr_id(const uint32_t& urrId) {
urr_Id = urrId;
}
//-----------------------------------------------------------------------------
uint32_t smf_pdu_session::get_urr_id() const {
return urr_Id;
}
//-----------------------------------------------------------------------------
void smf_pdu_session::set_nwi_access(const std::string& nwiAccess) {
nwi_access = nwiAccess;
......@@ -965,7 +975,50 @@ void smf_context::handle_itti_msg(
// Usage Report
if (report_type.usar) {
// TODO
Logger::smf_app().debug("PFCP_SESSION_REPORT_REQUEST/Usage Report");
// Step 1. send N4 Data Report Ack to UPF
pfcp::usage_report_within_pfcp_session_report_request ur;
if (req->pfcp_ies.get(ur)) {
pfcp::volume_measurement_t vm;
pfcp::duration_measurement_t dm;
pfcp::ur_seqn_t seqn;
if (ur.get(vm)) {
Logger::smf_app().info("\t\t SEID -> %lld", req->seid);
if (ur.get(seqn))
Logger::smf_app().info("\t\t UR-SEQN -> %ld", seqn.ur_seqn);
if (ur.get(dm))
Logger::smf_app().info("\t\t Duration -> %ld", dm.duration);
Logger::smf_app().info("\t\t NoP Total -> %lld", vm.total_nop);
Logger::smf_app().info("\t\t Uplink -> %lld", vm.uplink_nop);
Logger::smf_app().info(
"\t\t Downlink -> %lld", vm.downlink_nop);
Logger::smf_app().info(
"\t\t Volume Total -> %lld", vm.total_volume);
Logger::smf_app().info(
"\t\t Uplink -> %lld", vm.uplink_volume);
Logger::smf_app().info(
"\t\t Downlink -> %lld", vm.downlink_volume);
}
}
std::shared_ptr<itti_n4_session_report_response> n4_report_ack =
std::make_shared<itti_n4_session_report_response>(
TASK_SMF_APP, TASK_SMF_N4);
n4_report_ack->seid = req->seid;
n4_report_ack->trxn_id = req->trxn_id;
pfcp::cause_t cause = {.cause_value = pfcp::CAUSE_VALUE_REQUEST_ACCEPTED};
n4_report_ack->pfcp_ies.set(cause);
n4_report_ack->r_endpoint = req->r_endpoint;
Logger::smf_app().info(
"Sending ITTI message %s to task TASK_SMF_N4",
n4_report_ack->get_msg_name());
int ret = itti_inst->send_msg(n4_report_ack);
if (RETURNok != ret) {
Logger::smf_app().error(
"Could not send ITTI message %s to task TASK_SMF_N4",
n4_report_ack->get_msg_name());
return;
}
}
// Error Indication Report
if (report_type.erir) {
......
......@@ -448,6 +448,20 @@ class smf_pdu_session : public std::enable_shared_from_this<smf_pdu_session> {
*/
pdu_session_type_t get_pdu_session_type() const;
/*
* Get URR_ID associated with this PDU Session
* @param void
* @return uint32_t: urrId
*/
uint32_t get_urr_id() const;
/*
* Set URR_ID associated with this PDU Session
* @param [const uint32_t&] urrId: URR_ID
* @return void
*/
void set_urr_id(const uint32_t& urrId);
/*
* Get NWI associated with this PDU Session
* @param void
......@@ -548,6 +562,9 @@ class smf_pdu_session : public std::enable_shared_from_this<smf_pdu_session> {
std::string dnn; // associated DNN
snssai_t snssai; // associated SNSSAI
uint32_t
urr_Id; // We maintain URR ID to reuse for DL PDR (session modification)
std::string nwi_access; // associated nwi_access
std::string nwi_core; // associated nwi_core
......
......@@ -691,11 +691,11 @@ void smf_n4::handle_receive_session_deletion_response(
//------------------------------------------------------------------------------
void smf_n4::handle_receive_session_report_request(
pfcp::pfcp_msg& msg, const endpoint& remote_endpoint) {
Logger::smf_n4().info("Received N4 SESSION REPORT REQUEST from an UPF");
bool error = true;
uint64_t trxn_id = 0;
pfcp_session_report_request msg_ies_container = {};
msg.to_core_type(msg_ies_container);
handle_receive_message_cb(msg, remote_endpoint, TASK_SMF_N4, error, trxn_id);
if (!error) {
std::shared_ptr<itti_n4_session_report_request> itti_msg =
......@@ -705,7 +705,8 @@ void smf_n4::handle_receive_session_report_request(
itti_msg->r_endpoint = remote_endpoint;
itti_msg->trxn_id = trxn_id;
itti_msg->seid = msg.get_seid();
int ret = itti_inst->send_msg(itti_msg);
int ret = itti_inst->send_msg(itti_msg);
if (RETURNok != ret) {
Logger::smf_n4().error(
"Could not send ITTI message %s to task TASK_SMF_APP",
......
......@@ -308,6 +308,28 @@ int session_create_sm_context_procedure::run(
create_pdr.set(far_id);
// TODO: list of Usage reporting Rule IDs
//-------------------
// IE create_urr ( Usage Reporting Rules)
//-------------------
if (smf_cfg.enable_ur) {
pfcp::urr_id_t urr_id = {};
sps->generate_urr_id(urr_id);
create_pdr.set(urr_id);
sps.get()->set_urr_id(urr_id.urr_id);
pfcp::create_urr create_urr = {};
pfcp::measurement_method_t measurement_method = {};
pfcp::measurement_period_t measurement_Period = {};
pfcp::reporting_triggers_t reporting_triggers = {};
// Hardcoded values for the moment
measurement_method.volum = 1; // Volume based usage report
measurement_Period.measurement_period = 10; // Every 10 Sec
reporting_triggers.perio = 1; // Periodic usage report
create_urr.set(urr_id);
create_urr.set(measurement_method);
create_urr.set(measurement_Period);
create_urr.set(reporting_triggers);
n4_triggered->pfcp_ies.set(create_urr);
}
// TODO: list of QoS Enforcement Rule IDs
//-------------------
......@@ -824,6 +846,12 @@ int session_update_sm_context_procedure::run(
// pdi.set(local_fteid);
pdi.set(ue_ip_address);
if (smf_cfg.enable_ur) {
pfcp::urr_id_t urr_Id = {};
urr_Id.urr_id = sps.get()->get_urr_id();
create_pdr.set(urr_Id);
}
create_pdr.set(pdr_id);
create_pdr.set(precedence);
create_pdr.set(pdi);
......@@ -891,6 +919,12 @@ int session_update_sm_context_procedure::run(
pdi.set(source_interface);
pdi.set(ue_ip_address);
if (smf_cfg.enable_ur) {
pfcp::urr_id_t urr_Id = {};
urr_Id.urr_id = sps.get()->get_urr_id();
update_pdr.set(urr_Id);
}
update_pdr.set(flow.pdr_id_dl);
update_pdr.set(precedence);
update_pdr.set(pdi);
......
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