Commit 4c1b7b0d authored by yangjian's avatar yangjian

Modify amf config

parent 092befb5
...@@ -2,27 +2,28 @@ ...@@ -2,27 +2,28 @@
PLUGIN = PLUGIN =
{ {
ALGORITHM = "RR";
INTERFACES: INTERFACES:
{ {
# PLUGIN binded interface for Nudsf interface # PLUGIN binded interface for Nudsf interface
NGAP: NGAP:
{ {
INTERFACE_NAME = "eno1"; # YOUR NETWORK CONFIG HERE INTERFACE_NAME = "ens32"; # YOUR NETWORK CONFIG HERE
IPV4_ADDRESS = "read"; IPV4_ADDRESS = "read";
PORT = 38412; # YOUR NETWORK CONFIG HERE PORT = 38412; # YOUR NETWORK CONFIG HERE
PPID = 60; # YOUR NETWORK CONFIG HERE PPID = 60; # YOUR NETWORK CONFIG HERE
}; };
SBI: SBI:
{ {
INTERFACE_NAME = "eno1"; # YOUR NETWORK CONFIG HERE INTERFACE_NAME = "en32"; # YOUR NETWORK CONFIG HERE
IPV4_ADDRESS = "read"; IPV4_ADDRESS = "192.168.2.35";
PORT = 38414; # YOUR NETWORK CONFIG HERE PORT = 38414; # YOUR NETWORK CONFIG HERE
}; };
NRF: NRF:
{ {
INTERFACE_NAME = "NRF"; # YOUR NETWORK CONFIG HERE INTERFACE_NAME = "NRF"; # YOUR NETWORK CONFIG HERE
IPV4_ADDRESS = "10.112.202.24";#amf地址 IPV4_ADDRESS = "192.168.2.35";#amf地址
PORT = 8282; # YOUR NETWORK CONFIG HERE PORT = 8282; # YOUR NETWORK CONFIG HERE
}; };
}; };
......
/** /**
* Nudsf_DataRepository * Nudsf_DataRepository
* Nudsf Data Repository Service. © 2021, 3GPP Organizational Partners (ARIB, ATIS, CCSA, ETSI, TSDSI, TTA, TTC). All rights reserved. * Nudsf Data Repository Service. © 2021, 3GPP Organizational Partners (ARIB, ATIS, CCSA, ETSI, TSDSI, TTA, TTC). All rights reserved.
* *
* The version of the OpenAPI document: 1.1.0-alpha.2 * The version of the OpenAPI document: 1.1.0-alpha.2
* *
* *
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
* https://openapi-generator.tech * https://openapi-generator.tech
...@@ -43,7 +43,7 @@ using namespace org::openapitools::server::model; ...@@ -43,7 +43,7 @@ using namespace org::openapitools::server::model;
PluginApi::PluginApi(std::shared_ptr<Pistache::Rest::Router> rtr) { PluginApi::PluginApi(std::shared_ptr<Pistache::Rest::Router> rtr) {
router = rtr; router = rtr;
} }
...@@ -74,19 +74,19 @@ void PluginApi::algorithm_omf_handler(const Pistache::Rest::Request &request, Pi ...@@ -74,19 +74,19 @@ void PluginApi::algorithm_omf_handler(const Pistache::Rest::Request &request, Pi
Logger::plugin_server().debug("ip address : %s",transdata.ip_addr.c_str()); Logger::plugin_server().debug("ip address : %s",transdata.ip_addr.c_str());
Logger::plugin_server().debug("current message queue length : %d",transdata.mq_len); Logger::plugin_server().debug("current message queue length : %d",transdata.mq_len);
Logger::plugin_server().debug("current capbility : %f",transdata.cap); Logger::plugin_server().debug("current capbility : %f",transdata.cap);
if(!transdata.ip_addr.compare("10.103.239.116")){ if(!transdata.ip_addr.compare("192.168.2.35")){
msg_len[0] = transdata.mq_len; msg_len[0] = transdata.mq_len;
pro_cap[0] = (long)transdata.cap; pro_cap[0] = (long)transdata.cap;
isall[0] = true; isall[0] = true;
Logger::plugin_server().debug("capability(0) %d",pro_cap[0]); Logger::plugin_server().debug("capability(0) %d",pro_cap[0]);
} }
if(!transdata.ip_addr.compare("10.103.239.114")){ if(!transdata.ip_addr.compare("192.168.2.172")){
msg_len[1] = transdata.mq_len; msg_len[1] = transdata.mq_len;
pro_cap[1] = (long)transdata.cap; pro_cap[1] = (long)transdata.cap;
isall[1] = true; isall[1] = true;
Logger::plugin_server().debug("capability(1) %d",pro_cap[1]); Logger::plugin_server().debug("capability(1) %d",pro_cap[1]);
} }
if(!transdata.ip_addr.compare("10.103.239.112")){ if(!transdata.ip_addr.compare("192.168.2.173")){
msg_len[2] = transdata.mq_len; msg_len[2] = transdata.mq_len;
pro_cap[2] = (long)transdata.cap; pro_cap[2] = (long)transdata.cap;
isall[2] = true; isall[2] = true;
...@@ -141,8 +141,8 @@ void PluginApi::algorithm_omf_handler(const Pistache::Rest::Request &request, Pi ...@@ -141,8 +141,8 @@ void PluginApi::algorithm_omf_handler(const Pistache::Rest::Request &request, Pi
} }
if(plugin_cfg.is_omf){ if(plugin_cfg.is_omf){
for(int j=0; j<4; j++){ for(int j=0; j<4; j++){
sum += (double)(K[j]*pro_cap[0]-K[0]*pro_cap[j]); sum += (double)(K[j]*pro_cap[0]-K[0]*pro_cap[j]);
//sum += (double)(K[j]*pro_cap[0]-K[0]*pro_cap[j])/1000000; //sum += (double)(K[j]*pro_cap[0]-K[0]*pro_cap[j])/1000000;
} }
Logger::plugin_server().debug("sum = %f",sum); Logger::plugin_server().debug("sum = %f",sum);
tmp_w[0] = pro_cap[0]/sum_c + sum/N*sum_c; tmp_w[0] = pro_cap[0]/sum_c + sum/N*sum_c;
...@@ -241,7 +241,7 @@ void PluginApi::N2_trans_handler(const Pistache::Rest::Request &request, Pistach ...@@ -241,7 +241,7 @@ void PluginApi::N2_trans_handler(const Pistache::Rest::Request &request, Pistach
// Getting the path params // Getting the path params
auto assoc_id = request.param(":assoid").as<std::uint32_t>(); auto assoc_id = request.param(":assoid").as<std::uint32_t>();
auto stream = request.param(":stream").as<std::uint16_t>(); auto stream = request.param(":stream").as<std::uint16_t>();
Logger::plugin_server().info("--Put!--assoc_id = (%d), stream = (%d)",assoc_id,stream); Logger::plugin_server().info("--Put!--assoc_id = (%d), stream = (%d)",assoc_id,stream);
......
...@@ -17,8 +17,8 @@ extern std::string amf_ip; ...@@ -17,8 +17,8 @@ extern std::string amf_ip;
extern unsigned int amf_port; extern unsigned int amf_port;
extern std::map<std::string,long> ip2len; extern std::map<std::string,long> ip2len;
ofstream timestamp_plugin("/home/xgcore/plugin_timestamp.txt"); ofstream timestamp_plugin("/home/share/Unicom-NWDAF/2021-10-28/plugin_timestamp.txt");
string amf_ip_list[15] = {"10.103.239.116","10.103.239.114","10.103.239.112","10.103.238.75","10.103.239.112","10.103.238.72","10.103.239.53","10.103.239.61","10.103.239.63","10.103.238.105","10.103.238.104","10.103.238.103","10.103.238.98","10.103.238.97","10.103.238.96"}; string amf_ip_list[15] = {"192.168.2.35","192.168.2.172","192.168.2.173","192.168.2.35","10.103.239.112","10.103.238.72","10.103.239.53","10.103.239.61","10.103.239.63","10.103.238.105","10.103.238.104","10.103.238.103","10.103.238.98","10.103.238.97","10.103.238.96"};
int amf_ports[15] = {8282,8282,8282,8282,8282,8282,8282,8282,8282,8282,8282,8282,8282,8282,8282}; int amf_ports[15] = {8282,8282,8282,8282,8282,8282,8282,8282,8282,8282,8282,8282,8282,8282,8282};
int weight[15] = {1,2,3,4,5,6,7,8,9,10,11,12,13,14,15}; int weight[15] = {1,2,3,4,5,6,7,8,9,10,11,12,13,14,15};
namespace amf_application{ namespace amf_application{
...@@ -47,12 +47,32 @@ static std::size_t callback( ...@@ -47,12 +47,32 @@ static std::size_t callback(
int index = -1; int index = -1;
int random_index = 0; int random_index = 0;
int choose = 0; int choose = 0;
int num_inst = 4; int num_inst = 2;
void plugin_app::handle_receive( void plugin_app::handle_receive(
bstring payload, sctp_assoc_id_t assoc_id, sctp_stream_id_t stream, bstring payload, sctp_assoc_id_t assoc_id, sctp_stream_id_t stream,
sctp_stream_id_t instreams, sctp_stream_id_t outstreams) sctp_stream_id_t instreams, sctp_stream_id_t outstreams)
{ {
// int num_inst = 1;
//
// auto fp = popen("/home/share/Unicom-NWDAF/2021-10-28/getenv.sh","r");
//
// std::string pathvar = "";
// while (!feof(fp)) {
// pathvar.push_back(std::fgetc(fp));
// }
// pathvar.pop_back();
//
// pclose(fp);
//
// Logger::plugin_sbi().debug("\"AMF_NUMBER\" = %s",pathvar.c_str() );
// int value = atoi(pathvar.c_str());
// if(value)
// {
// num_inst = value;
// }
// Logger::plugin_sbi().debug("\"num_inst\" = %d",num_inst );
struct timeval tv1; struct timezone tz1; gettimeofday(&tv1,&tz1); long start = tv1.tv_sec*1000000 +tv1.tv_usec; struct timeval tv1; struct timezone tz1; gettimeofday(&tv1,&tz1); long start = tv1.tv_sec*1000000 +tv1.tv_usec;
Logger::plugin_sbi().debug("Begining at time %ld", start); Logger::plugin_sbi().debug("Begining at time %ld", start);
timestamp_plugin<< "time_stamp "<<start<<endl; timestamp_plugin<< "time_stamp "<<start<<endl;
...@@ -65,7 +85,7 @@ void plugin_app::handle_receive( ...@@ -65,7 +85,7 @@ void plugin_app::handle_receive(
Logger::sctp().debug( Logger::sctp().debug(
"[Assoc ID %d] Sending buffer %p of %d bytes on stream %d,ngapmsg length %d ", "[Assoc ID %d] Sending buffer %p of %d bytes on stream %d,ngapmsg length %d ",
assoc_id, bdata(payload), blength(payload), stream,ngapmsg.length()); assoc_id, bdata(payload), blength(payload), stream,ngapmsg.length());
nlohmann::json json_data = {}; nlohmann::json json_data = {};
json_data["n2_data"] = ngapmsg; json_data["n2_data"] = ngapmsg;
std::string url; std::string url;
...@@ -102,8 +122,8 @@ void plugin_app::handle_receive( ...@@ -102,8 +122,8 @@ void plugin_app::handle_receive(
if(plugin_cfg.is_rr){ if(plugin_cfg.is_rr){
Logger::plugin_sbi().debug("Algorithm RR "); Logger::plugin_sbi().debug("Algorithm RR ");
url = url =
"http://" + std::string(amf_ip_list[index % 4].c_str()) + "http://" + std::string(amf_ip_list[index % num_inst].c_str()) +
":" + std::to_string(amf_ports[index % 4]) + "/namf-comm/v1/plugin_n2/" + ":" + std::to_string(amf_ports[index % num_inst]) + "/namf-comm/v1/plugin_n2/" +
to_string (assoc_id ) + "/" + to_string (stream) ; to_string (assoc_id ) + "/" + to_string (stream) ;
} }
...@@ -136,7 +156,7 @@ void plugin_app::handle_receive( ...@@ -136,7 +156,7 @@ void plugin_app::handle_receive(
// std::string(CURL_MIME_BOUNDARY); // std::string(CURL_MIME_BOUNDARY);
// headers = curl_slist_append(headers, content_type.c_str()); // headers = curl_slist_append(headers, content_type.c_str());
headers = curl_slist_append(headers, "content-type: application/json"); headers = curl_slist_append(headers, "content-type: application/json");
headers = curl_slist_append(headers, "Expect:"); headers = curl_slist_append(headers, "Expect:");
curl_easy_setopt(curl, CURLOPT_HTTPHEADER, headers); curl_easy_setopt(curl, CURLOPT_HTTPHEADER, headers);
curl_easy_setopt(curl, CURLOPT_URL, url.c_str()); curl_easy_setopt(curl, CURLOPT_URL, url.c_str());
curl_easy_setopt(curl, CURLOPT_HTTPGET, 1); curl_easy_setopt(curl, CURLOPT_HTTPGET, 1);
...@@ -183,7 +203,7 @@ void plugin_app::handle_receive( ...@@ -183,7 +203,7 @@ void plugin_app::handle_receive(
} }
curl_global_cleanup(); curl_global_cleanup();
} }
} }
...@@ -234,5 +254,5 @@ void plugin_app::handle_receive( ...@@ -234,5 +254,5 @@ void plugin_app::handle_receive(
// curl_easy_cleanup(curl); // curl_easy_cleanup(curl);
// } // }
// curl_global_cleanup(); // curl_global_cleanup();
...@@ -116,10 +116,11 @@ int plugin_config::getip(std::string &ip, std::string &ifname) ...@@ -116,10 +116,11 @@ int plugin_config::getip(std::string &ip, std::string &ifname)
if (ioctl(sock, SIOCGIFADDR, &ifr) < 0) if (ioctl(sock, SIOCGIFADDR, &ifr) < 0)
{ {
perror("ioctl"); perror("ioctl");
return -1; return -1;
} }
memcpy(&sin, &ifr.ifr_addr, sizeof(sin)); memcpy(&sin, &ifr.ifr_addr, sizeof(sin));
//printf("ip = %s\n",inet_ntoa(sin.sin_addr)); // printf("ip = %s\n",inet_ntoa(sin.sin_addr));
//sprintf(ip, "%s", inet_ntoa(sin.sin_addr)); //sprintf(ip, "%s", inet_ntoa(sin.sin_addr));
ip = std::string(inet_ntoa(sin.sin_addr)); ip = std::string(inet_ntoa(sin.sin_addr));
return 0; return 0;
......
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