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
}; };
}; };
......
...@@ -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;
......
...@@ -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;
...@@ -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) ;
} }
......
...@@ -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