Commit eb544724 authored by gauthier's avatar gauthier

Merge remote-tracking branch 'origin/develop' into github-oai-develop

parents 62a701a3 79655dbd
...@@ -310,5 +310,5 @@ if(${SGW_AUTOTEST}) ...@@ -310,5 +310,5 @@ if(${SGW_AUTOTEST})
SET(GTPV1U_LIB GTPV1U) SET(GTPV1U_LIB GTPV1U)
endif(${SGW_AUTOTEST}) endif(${SGW_AUTOTEST})
target_link_libraries (spgwc ${ASAN} -Wl,--start-group CN_UTILS SGWC PGWC ${GTPV1U_LIB} GTPV2C PFCP 3GPP_COMMON_TYPES -Wl,--end-group pthread m rt config++ event boost_system ) target_link_libraries (spgwc ${ASAN} -Wl,--start-group CN_UTILS SGWC PGWC ${GTPV1U_LIB} GTPV2C PFCP 3GPP_COMMON_TYPES gflags glog dl double-conversion folly -Wl,--end-group pthread m rt config++ event boost_system )
This diff is collapsed.
/*
* Licensed to the OpenAirInterface (OAI) Software Alliance under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The OpenAirInterface Software Alliance licenses this file to You under
* the OAI Public License, Version 1.1 (the "License"); you may not use this file
* except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.openairinterface.org/?page_id=698
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*-------------------------------------------------------------------------------
* For more information about the OpenAirInterface (OAI) Software Alliance:
* contact@openairinterface.org
*/
/*! \file pgw_pfcp_association.hpp
\author Lionel GAUTHIER
\date 2019
\email: lionel.gauthier@eurecom.fr
*/
#ifndef FILE_PGW_PFCP_ASSOCIATION_HPP_SEEN
#define FILE_PGW_PFCP_ASSOCIATION_HPP_SEEN
#include "3gpp_29.244.h"
#include "itti.hpp"
#include <folly/AtomicHashMap.h>
#include <vector>
namespace oai::cn::nf::pgwc {
#define PFCP_ASSOCIATION_HEARTBEAT_INTERVAL_SEC 10
#define PFCP_ASSOCIATION_HEARTBEAT_MAX_RETRIES 2
class pfcp_association {
public:
oai::cn::core::pfcp::node_id_t node_id;
std::size_t hash_node_id;
oai::cn::core::pfcp::recovery_time_stamp_t recovery_time_stamp;
std::pair<bool,oai::cn::core::pfcp::up_function_features_s> function_features;
//
mutable std::mutex m_sessions;
std::set<oai::cn::core::pfcp::fseid_t> sessions;
//
oai::cn::core::itti::timer_id_t timer_heartbeat;
int num_retries_timer_heartbeat;
uint64_t trxn_id_heartbeat;
oai::cn::core::itti::timer_id_t timer_association;
explicit pfcp_association(const oai::cn::core::pfcp::node_id_t& node_id) :
node_id(node_id), recovery_time_stamp(), function_features(), m_sessions(), sessions() {
hash_node_id = std::hash<oai::cn::core::pfcp::node_id_t>{}(node_id);
timer_heartbeat = ITTI_INVALID_TIMER_ID;
num_retries_timer_heartbeat = 0;
trxn_id_heartbeat = 0;
}
pfcp_association(const oai::cn::core::pfcp::node_id_t& node_id, oai::cn::core::pfcp::recovery_time_stamp_t& recovery_time_stamp) :
node_id(node_id), recovery_time_stamp(recovery_time_stamp), function_features(), m_sessions(), sessions() {
hash_node_id = std::hash<oai::cn::core::pfcp::node_id_t>{}(node_id);
timer_heartbeat = ITTI_INVALID_TIMER_ID;
num_retries_timer_heartbeat = 0;
trxn_id_heartbeat = 0;
}
pfcp_association(const oai::cn::core::pfcp::node_id_t& ni, oai::cn::core::pfcp::recovery_time_stamp_t& rts, oai::cn::core::pfcp::up_function_features_s& uff):
node_id(ni), recovery_time_stamp(rts), m_sessions(), sessions() {
hash_node_id = std::hash<oai::cn::core::pfcp::node_id_t>{}(node_id);
function_features.first = true;
function_features.second = uff;
timer_heartbeat = ITTI_INVALID_TIMER_ID;
num_retries_timer_heartbeat = 0;
trxn_id_heartbeat = 0;
timer_association = {};
}
pfcp_association(pfcp_association const & p): node_id(p.node_id),
hash_node_id(p.hash_node_id),
recovery_time_stamp(p.recovery_time_stamp),
function_features(p.function_features),
timer_heartbeat(p.timer_heartbeat),
num_retries_timer_heartbeat(p.num_retries_timer_heartbeat),
trxn_id_heartbeat(p.trxn_id_heartbeat),
timer_association(0) {}
void notify_add_session(const oai::cn::core::pfcp::fseid_t& cp_fseid);
bool has_session(const oai::cn::core::pfcp::fseid_t& cp_fseid);
void notify_del_session(const oai::cn::core::pfcp::fseid_t& cp_fseid);
//void del_sessions();
void restore_sx_sessions();
void set(const oai::cn::core::pfcp::up_function_features_s& ff) {function_features.first = true; function_features.second = ff;};
};
enum node_selection_criteria_e {
NODE_SELECTION_CRITERIA_BEST_MAX_HEARBEAT_RTT = 0,
NODE_SELECTION_CRITERIA_MIN_PFCP_SESSIONS = 1,
NODE_SELECTION_CRITERIA_MIN_UP_TIME = 2,
NODE_SELECTION_CRITERIA_MAX_AVAILABLE_BW = 3,
NODE_SELECTION_CRITERIA_NONE = 4
};
#define PFCP_MAX_ASSOCIATIONS 16
class pfcp_associations {
private:
std::vector<std::shared_ptr<pfcp_association>> pending_associations;
folly::AtomicHashMap<int32_t, std::shared_ptr<pfcp_association>> associations;
pfcp_associations() : associations(PFCP_MAX_ASSOCIATIONS), pending_associations() {};
void trigger_heartbeat_request_procedure(std::shared_ptr<pfcp_association>& s);
public:
static pfcp_associations& get_instance()
{
static pfcp_associations instance;
return instance;
}
pfcp_associations(pfcp_associations const&) = delete;
void operator=(pfcp_associations const&) = delete;
bool add_association(oai::cn::core::pfcp::node_id_t& node_id, oai::cn::core::pfcp::recovery_time_stamp_t& recovery_time_stamp, bool& restore_sx_sessions);
bool add_association(oai::cn::core::pfcp::node_id_t& node_id, oai::cn::core::pfcp::recovery_time_stamp_t& recovery_time_stamp, oai::cn::core::pfcp::up_function_features_s& function_features, bool& restore_sx_sessions);
bool get_association(const oai::cn::core::pfcp::node_id_t& node_id, std::shared_ptr<pfcp_association>& sa) const;
bool get_association(const oai::cn::core::pfcp::fseid_t& cp_fseid, std::shared_ptr<pfcp_association>& sa) const;
void notify_add_session(const oai::cn::core::pfcp::node_id_t& node_id, const oai::cn::core::pfcp::fseid_t& cp_fseid);
void notify_del_session(const oai::cn::core::pfcp::fseid_t& cp_fseid);
void restore_sx_sessions(const oai::cn::core::pfcp::node_id_t& node_id);
void initiate_heartbeat_request(oai::cn::core::itti::timer_id_t timer_id, uint64_t arg2_user);
void timeout_heartbeat_request(oai::cn::core::itti::timer_id_t timer_id, uint64_t arg2_user);
void handle_receive_heartbeat_response(const uint64_t trxn_id);
bool select_up_node(oai::cn::core::pfcp::node_id_t& node_id, const int node_selection_criteria);
};
}
#endif /* FILE_PGW_PFCP_ASSOCIATION_HPP_SEEN */
This diff is collapsed.
...@@ -87,7 +87,7 @@ bool pfcp_associations::add_association(oai::cn::core::pfcp::node_id_t& node_id, ...@@ -87,7 +87,7 @@ bool pfcp_associations::add_association(oai::cn::core::pfcp::node_id_t& node_id,
return false; return false;
} }
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
bool pfcp_associations::add_association(oai::cn::core::pfcp::node_id_t& node_id, oai::cn::core::pfcp::recovery_time_stamp_t& recovery_time_stamp, oai::cn::core::pfcp::cp_function_features_t& bool pfcp_associations::add_association(oai::cn::core::pfcp::node_id_t& node_id, oai::cn::core::pfcp::recovery_time_stamp_t& recovery_time_stamp, oai::cn::core::pfcp::cp_function_features_s&
function_features) function_features)
{ {
std::shared_ptr<pfcp_association> sa = {}; std::shared_ptr<pfcp_association> sa = {};
......
...@@ -44,7 +44,7 @@ namespace oai::cn::nf::spgwu { ...@@ -44,7 +44,7 @@ namespace oai::cn::nf::spgwu {
oai::cn::core::pfcp::node_id_t node_id; oai::cn::core::pfcp::node_id_t node_id;
std::size_t hash_node_id; std::size_t hash_node_id;
oai::cn::core::pfcp::recovery_time_stamp_t recovery_time_stamp; oai::cn::core::pfcp::recovery_time_stamp_t recovery_time_stamp;
std::pair<bool,oai::cn::core::pfcp::cp_function_features_t> function_features; std::pair<bool,oai::cn::core::pfcp::cp_function_features_s> function_features;
// //
mutable std::mutex m_sessions; mutable std::mutex m_sessions;
std::set<oai::cn::core::pfcp::fseid_t> sessions; std::set<oai::cn::core::pfcp::fseid_t> sessions;
...@@ -69,7 +69,7 @@ namespace oai::cn::nf::spgwu { ...@@ -69,7 +69,7 @@ namespace oai::cn::nf::spgwu {
num_retries_timer_heartbeat = 0; num_retries_timer_heartbeat = 0;
trxn_id_heartbeat = 0; trxn_id_heartbeat = 0;
} }
pfcp_association(const oai::cn::core::pfcp::node_id_t& ni, oai::cn::core::pfcp::recovery_time_stamp_t& rts, oai::cn::core::pfcp::cp_function_features_t& uff): pfcp_association(const oai::cn::core::pfcp::node_id_t& ni, oai::cn::core::pfcp::recovery_time_stamp_t& rts, oai::cn::core::pfcp::cp_function_features_s& uff):
node_id(ni), recovery_time_stamp(rts), m_sessions(), sessions() { node_id(ni), recovery_time_stamp(rts), m_sessions(), sessions() {
hash_node_id = std::hash<oai::cn::core::pfcp::node_id_t>{}(node_id); hash_node_id = std::hash<oai::cn::core::pfcp::node_id_t>{}(node_id);
function_features.first = true; function_features.first = true;
...@@ -77,6 +77,7 @@ namespace oai::cn::nf::spgwu { ...@@ -77,6 +77,7 @@ namespace oai::cn::nf::spgwu {
timer_heartbeat = ITTI_INVALID_TIMER_ID; timer_heartbeat = ITTI_INVALID_TIMER_ID;
num_retries_timer_heartbeat = 0; num_retries_timer_heartbeat = 0;
trxn_id_heartbeat = 0; trxn_id_heartbeat = 0;
timer_association = {};
} }
// pfcp_association(pfcp_association const & p) // pfcp_association(pfcp_association const & p)
// { // {
...@@ -94,7 +95,7 @@ namespace oai::cn::nf::spgwu { ...@@ -94,7 +95,7 @@ namespace oai::cn::nf::spgwu {
bool has_session(const oai::cn::core::pfcp::fseid_t& cp_fseid); bool has_session(const oai::cn::core::pfcp::fseid_t& cp_fseid);
void notify_del_session(const oai::cn::core::pfcp::fseid_t& cp_fseid); void notify_del_session(const oai::cn::core::pfcp::fseid_t& cp_fseid);
void del_sessions(); void del_sessions();
void set(const oai::cn::core::pfcp::cp_function_features_t& ff) {function_features.first = true; function_features.second = ff;}; void set(const oai::cn::core::pfcp::cp_function_features_s& ff) {function_features.first = true; function_features.second = ff;};
}; };
#define PFCP_MAX_ASSOCIATIONS 16 #define PFCP_MAX_ASSOCIATIONS 16
...@@ -119,7 +120,7 @@ namespace oai::cn::nf::spgwu { ...@@ -119,7 +120,7 @@ namespace oai::cn::nf::spgwu {
void operator=(pfcp_associations const&) = delete; void operator=(pfcp_associations const&) = delete;
bool add_association(oai::cn::core::pfcp::node_id_t& node_id, oai::cn::core::pfcp::recovery_time_stamp_t& recovery_time_stamp); bool add_association(oai::cn::core::pfcp::node_id_t& node_id, oai::cn::core::pfcp::recovery_time_stamp_t& recovery_time_stamp);
bool add_association(oai::cn::core::pfcp::node_id_t& node_id, oai::cn::core::pfcp::recovery_time_stamp_t& recovery_time_stamp, oai::cn::core::pfcp::cp_function_features_t& function_features); bool add_association(oai::cn::core::pfcp::node_id_t& node_id, oai::cn::core::pfcp::recovery_time_stamp_t& recovery_time_stamp, oai::cn::core::pfcp::cp_function_features_s& function_features);
bool get_association(const oai::cn::core::pfcp::node_id_t& node_id, std::shared_ptr<pfcp_association>& sa) const; bool get_association(const oai::cn::core::pfcp::node_id_t& node_id, std::shared_ptr<pfcp_association>& sa) const;
bool get_association(const oai::cn::core::pfcp::fseid_t& cp_fseid, std::shared_ptr<pfcp_association>& sa) const; bool get_association(const oai::cn::core::pfcp::fseid_t& cp_fseid, std::shared_ptr<pfcp_association>& sa) const;
...@@ -127,6 +128,9 @@ namespace oai::cn::nf::spgwu { ...@@ -127,6 +128,9 @@ namespace oai::cn::nf::spgwu {
void notify_del_session(const oai::cn::core::pfcp::fseid_t& cp_fseid); void notify_del_session(const oai::cn::core::pfcp::fseid_t& cp_fseid);
bool add_peer_candidate_node(const oai::cn::core::pfcp::node_id_t& node_id); bool add_peer_candidate_node(const oai::cn::core::pfcp::node_id_t& node_id);
void restore_sx_sessions(const oai::cn::core::pfcp::node_id_t& node_id);
void initiate_heartbeat_request(oai::cn::core::itti::timer_id_t timer_id, uint64_t arg2_user); void initiate_heartbeat_request(oai::cn::core::itti::timer_id_t timer_id, uint64_t arg2_user);
void timeout_heartbeat_request(oai::cn::core::itti::timer_id_t timer_id, uint64_t arg2_user); void timeout_heartbeat_request(oai::cn::core::itti::timer_id_t timer_id, uint64_t arg2_user);
......
...@@ -50,7 +50,7 @@ private: ...@@ -50,7 +50,7 @@ private:
std::thread thread; std::thread thread;
uint64_t recovery_time_stamp; //timestamp in seconds uint64_t recovery_time_stamp; //timestamp in seconds
core::pfcp::up_function_features_t up_function_features; core::pfcp::up_function_features_s up_function_features;
void start_association(const core::pfcp::node_id_t& node_id); void start_association(const core::pfcp::node_id_t& node_id);
......
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