forked from acouzens/open5gs
Add configuration related to memory support (#190)
This commit is contained in:
parent
c849cc802c
commit
ca742661f6
|
@ -1,3 +1,22 @@
|
|||
/*
|
||||
* Copyright (C) 2019 by Sukchan Lee <acetcom@gmail.com>
|
||||
*
|
||||
* This file is part of Open5GS.
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include "base/types.h"
|
||||
|
||||
#include "context.h"
|
||||
|
@ -15,8 +34,7 @@ int app_will_initialize(app_param_t *param)
|
|||
|
||||
context_init();
|
||||
|
||||
if (param->name)
|
||||
{
|
||||
if (param->name) {
|
||||
rv = log_pid(param->name, param->pid_path);
|
||||
if (rv != OGS_OK) return rv;
|
||||
}
|
||||
|
@ -34,13 +52,11 @@ int app_will_initialize(app_param_t *param)
|
|||
context_self()->log.path = param->log_path;
|
||||
|
||||
if (param->logfile_disabled == false &&
|
||||
context_self()->config.logger.file)
|
||||
{
|
||||
context_self()->config.logger.file) {
|
||||
if (context_self()->log.path)
|
||||
context_self()->config.logger.file = context_self()->log.path;
|
||||
|
||||
if (ogs_log_add_file(context_self()->config.logger.file) == NULL)
|
||||
{
|
||||
if (ogs_log_add_file(context_self()->config.logger.file) == NULL) {
|
||||
ogs_fatal("cannot open log file : %s",
|
||||
context_self()->config.logger.file);
|
||||
ogs_assert_if_reached();
|
||||
|
@ -49,8 +65,8 @@ int app_will_initialize(app_param_t *param)
|
|||
ogs_log_print(OGS_LOG_INFO,
|
||||
"File Logging: '%s'\n", context_self()->config.logger.file);
|
||||
}
|
||||
if (context_self()->config.logger.level)
|
||||
{
|
||||
|
||||
if (context_self()->config.logger.level) {
|
||||
if (!strcasecmp(context_self()->config.logger.level, "none"))
|
||||
context_self()->log.level = OGS_LOG_NONE;
|
||||
else if (!strcasecmp(context_self()->config.logger.level, "fatal"))
|
||||
|
@ -73,15 +89,14 @@ int app_will_initialize(app_param_t *param)
|
|||
ogs_log_print(OGS_LOG_INFO,
|
||||
"LOG-LEVEL: '%s'\n", context_self()->config.logger.level);
|
||||
}
|
||||
if (context_self()->config.logger.domain)
|
||||
{
|
||||
|
||||
if (context_self()->config.logger.domain) {
|
||||
context_self()->log.domain = context_self()->config.logger.domain;
|
||||
ogs_log_print(OGS_LOG_INFO,
|
||||
"LOG-DOMAIN: '%s'\n", context_self()->config.logger.domain);
|
||||
}
|
||||
|
||||
if (param->log_level)
|
||||
{
|
||||
if (param->log_level) {
|
||||
context_self()->log.level = param->log_level;
|
||||
context_self()->log.domain = param->log_domain;
|
||||
}
|
||||
|
@ -90,8 +105,7 @@ int app_will_initialize(app_param_t *param)
|
|||
if (rv != OGS_OK) return rv;
|
||||
|
||||
if (param->db_disabled == false &&
|
||||
context_self()->config.db_uri)
|
||||
{
|
||||
context_self()->config.db_uri) {
|
||||
/* Override configuration if DB_URI environment variable is existed */
|
||||
if (ogs_env_get("DB_URI"))
|
||||
context_self()->config.db_uri = ogs_env_get("DB_URI");
|
||||
|
@ -128,8 +142,7 @@ static int log_pid(const char *app_name, const char *pid_path)
|
|||
pid_t mypid;
|
||||
char default_pid_path[MAX_FILEPATH_LEN];
|
||||
|
||||
if (pid_path == NULL)
|
||||
{
|
||||
if (pid_path == NULL) {
|
||||
ogs_snprintf(default_pid_path, sizeof(default_pid_path),
|
||||
"%snextepc-%sd/pid", DEFAULT_RUNTIME_DIR_PATH, app_name);
|
||||
pid_path = default_pid_path;
|
||||
|
@ -137,8 +150,7 @@ static int log_pid(const char *app_name, const char *pid_path)
|
|||
|
||||
mypid = getpid();
|
||||
pid_file = fopen(pid_path, "w");
|
||||
if (!pid_file)
|
||||
{
|
||||
if (!pid_file) {
|
||||
ogs_error("CHECK PERMISSION of Installation Directory...");
|
||||
ogs_error("Cannot create PID file:`%s`", pid_path);
|
||||
ogs_assert_if_reached();
|
||||
|
|
|
@ -1,5 +1,24 @@
|
|||
#ifndef __APPLICATION_H__
|
||||
#define __APPLICATION_H__
|
||||
/*
|
||||
* Copyright (C) 2019 by Sukchan Lee <acetcom@gmail.com>
|
||||
*
|
||||
* This file is part of Open5GS.
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#ifndef APP_APPLICATION_H
|
||||
#define APP_APPLICATION_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
|
@ -31,6 +50,6 @@ int app_logger_restart(void);
|
|||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif /* __cplusplus */
|
||||
#endif
|
||||
|
||||
#endif /* __APPLICATION_H__ */
|
||||
#endif /* APP_APPLICATION_H */
|
||||
|
|
|
@ -1,3 +1,22 @@
|
|||
/*
|
||||
* Copyright (C) 2019 by Sukchan Lee <acetcom@gmail.com>
|
||||
*
|
||||
* This file is part of Open5GS.
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include <mongoc.h>
|
||||
#include <yaml.h>
|
||||
|
||||
|
@ -129,8 +148,26 @@ int context_setup_log_module()
|
|||
|
||||
static int context_prepare()
|
||||
{
|
||||
#define USRSCTP_LOCAL_UDP_PORT 9899
|
||||
#define USRSCTP_LOCAL_UDP_PORT 9899
|
||||
self.config.usrsctp.udp_port = USRSCTP_LOCAL_UDP_PORT;
|
||||
|
||||
#define MAX_NUM_OF_ENB 32 /* Num of eNodeB per MME */
|
||||
#define MAX_NUM_OF_UE 128 /* Num of UE per eNodeB */
|
||||
#define MAX_NUM_OF_SESS 4 /* Num of APN(Session) per UE */
|
||||
#define MAX_NUM_OF_BEARER 4 /* Num of Bearer per APN(Session) */
|
||||
#define MAX_NUM_OF_TUNNEL 3 /* Num of Tunnel per Bearer */
|
||||
#define MAX_NUM_OF_PF 16 /* Num of Packet Filter per Bearer */
|
||||
#define MAX_NUM_OF_PACKET_BUFFER 512 /* Num of Buffer when S1-U Deactivated */
|
||||
#define MAX_NUM_OF_PACKET_POOL 131072 /* Num of 8192-packet pool in SGW */
|
||||
self.config.max.enb = MAX_NUM_OF_ENB;
|
||||
self.config.max.ue = MAX_NUM_OF_UE;
|
||||
self.config.max.sess = MAX_NUM_OF_SESS;
|
||||
self.config.max.bearer = MAX_NUM_OF_BEARER;
|
||||
self.config.max.tunnel = MAX_NUM_OF_TUNNEL;
|
||||
self.config.max.pf = MAX_NUM_OF_PF;
|
||||
self.config.max.packet.buffer = MAX_NUM_OF_PACKET_BUFFER;
|
||||
self.config.max.packet.pool = MAX_NUM_OF_PACKET_POOL;
|
||||
|
||||
return OGS_OK;
|
||||
}
|
||||
|
||||
|
@ -143,6 +180,13 @@ static int context_validation()
|
|||
return OGS_ERROR;
|
||||
}
|
||||
|
||||
self.pool.ue = self.config.max.ue * self.config.max.enb;
|
||||
self.pool.sess = self.pool.ue * self.config.max.sess;
|
||||
self.pool.bearer = self.pool.sess * self.config.max.bearer;
|
||||
self.pool.tunnel = self.pool.bearer * self.config.max.tunnel;
|
||||
self.pool.pf = self.pool.bearer * self.config.max.pf;
|
||||
self.pool.diameter_sess = self.pool.ue * self.config.max.sess;
|
||||
|
||||
return OGS_OK;
|
||||
}
|
||||
int context_parse_config()
|
||||
|
@ -256,7 +300,50 @@ int context_parse_config()
|
|||
} else
|
||||
ogs_warn("unknown key `%s`", sctp_key);
|
||||
}
|
||||
} else if (!strcmp(root_key, "max")) {
|
||||
ogs_yaml_iter_t max_iter;
|
||||
ogs_yaml_iter_recurse(&root_iter, &max_iter);
|
||||
while (ogs_yaml_iter_next(&max_iter)) {
|
||||
const char *max_key = ogs_yaml_iter_key(&max_iter);
|
||||
ogs_assert(max_key);
|
||||
if (!strcmp(max_key, "ue")) {
|
||||
const char *v = ogs_yaml_iter_value(&max_iter);
|
||||
if (v) self.config.max.ue = atoi(v);
|
||||
} else if (!strcmp(max_key, "enb")) {
|
||||
const char *v = ogs_yaml_iter_value(&max_iter);
|
||||
if (v) self.config.max.enb = atoi(v);
|
||||
} else if (!strcmp(max_key, "sess")) {
|
||||
const char *v = ogs_yaml_iter_value(&max_iter);
|
||||
if (v) self.config.max.sess = atoi(v);
|
||||
} else if (!strcmp(max_key, "bearer")) {
|
||||
const char *v = ogs_yaml_iter_value(&max_iter);
|
||||
if (v) self.config.max.bearer = atoi(v);
|
||||
} else if (!strcmp(max_key, "tunnel")) {
|
||||
const char *v = ogs_yaml_iter_value(&max_iter);
|
||||
if (v) self.config.max.tunnel = atoi(v);
|
||||
} else if (!strcmp(max_key, "pf")) {
|
||||
const char *v = ogs_yaml_iter_value(&max_iter);
|
||||
if (v) self.config.max.pf = atoi(v);
|
||||
} else if (!strcmp(max_key, "packet")) {
|
||||
ogs_yaml_iter_t packet_iter;
|
||||
ogs_yaml_iter_recurse(&max_iter, &packet_iter);
|
||||
while (ogs_yaml_iter_next(&packet_iter)) {
|
||||
const char *packet_key = ogs_yaml_iter_key(&packet_iter);
|
||||
ogs_assert(packet_key);
|
||||
if (!strcmp(packet_key, "buffer")) {
|
||||
const char *v = ogs_yaml_iter_value(&packet_iter);
|
||||
if (v) self.config.max.packet.buffer = atoi(v);
|
||||
} else if (!strcmp(packet_key, "pool")) {
|
||||
const char *v = ogs_yaml_iter_value(&packet_iter);
|
||||
if (v) self.config.max.packet.pool = atoi(v);
|
||||
} else
|
||||
ogs_warn("unknown key `%s`", packet_key);
|
||||
}
|
||||
} else
|
||||
ogs_warn("unknown key `%s`", max_key);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
rv = context_validation();
|
||||
|
|
|
@ -1,5 +1,24 @@
|
|||
#ifndef __CONTEXT_H__
|
||||
#define __CONTEXT_H__
|
||||
/*
|
||||
* Copyright (C) 2019 by Sukchan Lee <acetcom@gmail.com>
|
||||
*
|
||||
* This file is part of Open5GS.
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#ifndef APP_CONTEXT_H
|
||||
#define APP_CONTEXT_H
|
||||
|
||||
#include "ogs-core.h"
|
||||
#include "ogs-yaml.h"
|
||||
|
@ -8,9 +27,6 @@
|
|||
extern "C" {
|
||||
#endif /* __cplusplus */
|
||||
|
||||
#define MAX_CONFIG_FILE_SIZE 2048
|
||||
#define MAX_NUM_OF_CONFIG_TOKEN 256
|
||||
|
||||
typedef struct _config_t {
|
||||
const char *path;
|
||||
void *document;
|
||||
|
@ -42,9 +58,20 @@ typedef struct _config_t {
|
|||
int udp_port;
|
||||
} usrsctp;
|
||||
|
||||
} config_t;
|
||||
struct {
|
||||
int enb;
|
||||
int ue;
|
||||
int sess;
|
||||
int bearer;
|
||||
int tunnel;
|
||||
int pf;
|
||||
struct {
|
||||
int buffer;
|
||||
int pool;
|
||||
} packet;
|
||||
} max;
|
||||
|
||||
#define MAX_DB_URI_LEN 256
|
||||
} config_t;
|
||||
|
||||
typedef struct _context_t {
|
||||
config_t config;
|
||||
|
@ -63,6 +90,15 @@ typedef struct _context_t {
|
|||
const char *domain;
|
||||
} log;
|
||||
|
||||
struct {
|
||||
int ue;
|
||||
int sess;
|
||||
int bearer;
|
||||
int tunnel;
|
||||
int pf;
|
||||
int diameter_sess;
|
||||
} pool;
|
||||
|
||||
} context_t;
|
||||
|
||||
int context_init(void);
|
||||
|
@ -80,4 +116,4 @@ int context_db_final(void);
|
|||
}
|
||||
#endif /* __cplusplus */
|
||||
|
||||
#endif /* __CONTEXT_H__ */
|
||||
#endif /* APP_CONTEXT_H */
|
||||
|
|
|
@ -60,6 +60,30 @@ parameter:
|
|||
# o usrsctp_udp_port : 9899
|
||||
sctp:
|
||||
|
||||
#
|
||||
# max:
|
||||
#
|
||||
# o Maximum Number of eNodeB per MME
|
||||
# enb: 128
|
||||
# o Maximum Number of UE per eNodeB
|
||||
# ue: 32
|
||||
# o Maximum Number of APN(Session) per UE
|
||||
# sess: 4
|
||||
# o Maximum Number of Bearer per APN(Session)
|
||||
# bearer: 4
|
||||
# o Maximum Number of Tunnel per Bearer
|
||||
# tunnel: 3
|
||||
# o Maximum Number of Packet Filter per Bearer
|
||||
# pf: 16
|
||||
#
|
||||
# o Memory of Packet Buffering
|
||||
# packet:
|
||||
# - Maximum Number of Buffer when S1-U Deactivated
|
||||
# buffer: 512
|
||||
# - Maximum Number of packet(SDU size = 8Kbytes) pool in SGW
|
||||
# pool: 131092
|
||||
max:
|
||||
|
||||
mme:
|
||||
freeDiameter: mme.conf
|
||||
|
||||
|
|
Loading…
Reference in New Issue