Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
O
OpenXG-SMF
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Metrics
Environments
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
OpenXG
OpenXG-SMF
Commits
b7712a1a
Commit
b7712a1a
authored
Dec 02, 2023
by
liuyu
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
edge amf->dege smf-> center amf->edge smf -> edge amf is ok
parent
297e09ea
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
63 additions
and
56 deletions
+63
-56
src/oai_smf/main.cpp
src/oai_smf/main.cpp
+2
-2
src/udp/cooudp.cpp
src/udp/cooudp.cpp
+58
-52
src/udp/cooudp.hpp
src/udp/cooudp.hpp
+3
-2
No files found.
src/oai_smf/main.cpp
View file @
b7712a1a
...
...
@@ -133,8 +133,8 @@ int main(int argc, char** argv) {
exit
(
-
EDEADLK
);
}
udp_server_coop
udp_uplink_
(
"10.103.239.31"
,
20001
);
udp_server_coop
udp_downlink_
(
"10.103.239.31"
,
20004
);
udp_server_coop
udp_uplink_
(
inet_ntoa
(
smf_cfg
.
sbi
.
addr4
)
,
20001
);
udp_server_coop
udp_downlink_
(
inet_ntoa
(
smf_cfg
.
sbi
.
addr4
)
,
20004
);
// SMF Pistache API server (HTTP1)
Pistache
::
Address
addr
(
...
...
src/udp/cooudp.cpp
View file @
b7712a1a
...
...
@@ -67,7 +67,7 @@ udp_server_coop::udp_server_coop(const char* udp_address,uint16_t udp_port_num){
cout
<<
"start create socket"
<<
endl
;
create_socket
(
udp_address
,
udp_port_num
);
cout
<<
"start receive"
<<
endl
;
start_receive
(
udp_
);
start_receive
(
udp_
,
udp_port_num
);
}
udp_server_coop
::~
udp_server_coop
(){}
...
...
@@ -91,62 +91,26 @@ int udp_server_coop::create_socket(const char* udp_address,uint16_t udp_port_num
int
r
=
bind
(
serverSocket
,(
struct
sockaddr
*
)
&
sAddr
,
sizeof
sAddr
);
if
(
-
1
==
r
)
printf
(
"绑定失败:%m
\n
"
),
close
(
serverSocket
),
exit
(
-
2
);
printf
(
"绑定成功!
\n
"
);
return
serverSocket
;
// struct sockaddr_in addr = {};
// int sd = 0;
// /*
// * Create UDP socket
// */
// if ((sd = socket(AF_INET, SOCK_DGRAM, IPPROTO_UDP)) < 0) {
// /*
// * Socket creation has failed...
// */
// printf("Socket creation failed (%s)\n", strerror(errno));
// return errno;
// }
// addr.sin_family = AF_INET;
// addr.sin_port = htons(udp_port_num);
// addr.sin_addr.s_addr = inet_addr(udp_address);
// std::string ipv4 = udp_address;
// printf(
// "Creating new listen socket on address %s and port %" PRIu16 " ",
// ipv4.c_str(), udp_port_num);
// if (bind(sd, (struct sockaddr*) &addr, sizeof(struct sockaddr_in)) < 0) {
// /*
// * Bind failed
// */
// printf(
// "Socket bind failed (%s) for address %s and port %" PRIu16 " \n",
// strerror(errno), ipv4.c_str(), udp_port_num);
// close(sd);
// return errno;
// }
return
serverSocket
;
}
void
udp_server_coop
::
start_receive
(
udp_server_coop
*
udp
){
void
udp_server_coop
::
start_receive
(
udp_server_coop
*
udp
,
uint16_t
udp_port_num
){
udp_
=
udp
;
//pthread_create(&udp_thread, NULL, udp_receiver_thread, (void*) this);
//pthread_exit(NULL);
thread_
=
std
::
thread
(
&
udp_server_coop
::
udp_read_from_socket
,
this
);
thread_
.
detach
();
printf
(
"绑定成功!5555 %d
\n
"
,
udp_port_num
);
if
(
udp_port_num
==
20001
)
{
thread_
=
std
::
thread
(
&
udp_server_coop
::
udp_read_from_socket_to_center
,
this
);
thread_
.
detach
();
}
else
{
thread_
=
std
::
thread
(
&
udp_server_coop
::
udp_read_from_socket_from_center
,
this
);
thread_
.
detach
();
}
}
// void* udp_server_coop::udp_receiver_thread(void* arg) {
// udp_server_coop* ptr = (udp_server_coop*) arg;
// //Logger::udp().info("Create pthread to receive udp message");
// ptr->udp_read_from_socket();
// }
int
udp_server_coop
::
getSocket
(){
return
serverSocket
;
}
...
...
@@ -155,7 +119,7 @@ int udp_server_coop::getPpid(){
return
ppid
;
}
int
udp_server_coop
::
udp_read_from_socket
()
{
int
udp_server_coop
::
udp_read_from_socket
_to_center
()
{
//4.通信
uint8_t
udp_recv
[
UDP_RECV_BUFFER_SIZE
];
//bstring udp_recv;
...
...
@@ -178,7 +142,7 @@ int udp_server_coop::udp_read_from_socket() {
//bytes_received = recvfrom(serverSocket, udp_recv, UDP_RECV_BUFFER_SIZE , 0, (struct sockaddr*)&r_endpoint.addr_storage, &r_endpoint.addr_storage_len);
if
(
bytes_received
>
0
){
printf
(
"smf receive udp success from amf
\n
"
);
printf
(
"smf receive udp success from
satellite
amf
\n
"
);
gettimeofday
(
&
time
,
NULL
);
// std::cout<<"receive from plugin, ms: "<<(time.tv_sec*1000 + time.tv_usec/1000)<<std::endl;
// cout<<"bytes"<<bytes_received<<endl;
...
...
@@ -187,7 +151,49 @@ int udp_server_coop::udp_read_from_socket() {
// cout<<"content:"<<udp_recv_str<<endl;
// handle_receive_udp(bytes_received,udp_recv);
printf
(
"smf send udp to center amf
\n
"
);
UdpSend
(
udp_recv
,
bytes_received
,
"10.103.238.72"
,
20003
);
UdpSend
(
udp_recv
,
bytes_received
,
"10.103.239.47"
,
20003
);
// assoc_id++;
// stream++;
//ngap_app("0",0).handle_receive(udp_recv_str,assoc_id,stream,0,0);
}
}
return
0
;
}
int
udp_server_coop
::
udp_read_from_socket_from_center
()
{
//4.通信
uint8_t
udp_recv
[
UDP_RECV_BUFFER_SIZE
];
//bstring udp_recv;
//struct sockaddr_in cAddr = {0};
//socklen_t len = sizeof(cAddr);
endpoint
r_endpoint
=
{};
//socklen_t addr_len;
int
udp_len
;
size_t
bytes_received
=
0
;
cout
<<
"start receive"
<<
endl
;
struct
timeval
time
;
while
(
1
){
r_endpoint
.
addr_storage_len
=
sizeof
(
struct
sockaddr_storage
);
//如果还需要向客户端发送东西用recvfrom
//udp精髓 向一个协议地址簇发东西
//收消息
//r = recvfrom(serverSocket,udp_recv,udp_len,0,(struct sockaddr*)&cAddr,&len);
bytes_received
=
recvfrom
(
serverSocket
,
(
void
*
)
udp_recv
,
UDP_RECV_BUFFER_SIZE
,
0
,
(
struct
sockaddr
*
)
&
r_endpoint
.
addr_storage
,
&
r_endpoint
.
addr_storage_len
);
//bytes_received = recvfrom(serverSocket, udp_recv, UDP_RECV_BUFFER_SIZE , 0, (struct sockaddr*)&r_endpoint.addr_storage, &r_endpoint.addr_storage_len);
if
(
bytes_received
>
0
){
printf
(
"smf receive udp success from center amf
\n
"
);
gettimeofday
(
&
time
,
NULL
);
// std::cout<<"receive from plugin, ms: "<<(time.tv_sec*1000 + time.tv_usec/1000)<<std::endl;
// cout<<"bytes"<<bytes_received<<endl;
// cout<<"content:"<<udp_recv<<endl;
// string udp_recv_str(&udp_recv[0],&udp_recv[strlen(udp_recv)]);
// cout<<"content:"<<udp_recv_str<<endl;
// handle_receive_udp(bytes_received,udp_recv);
printf
(
"smf send udp to satellite amf
\n
"
);
UdpSend
(
udp_recv
,
bytes_received
,
"10.103.239.31"
,
20002
);
// assoc_id++;
// stream++;
...
...
src/udp/cooudp.hpp
View file @
b7712a1a
...
...
@@ -41,10 +41,11 @@ class udp_server_coop{
udp_server_coop
(
const
char
*
address
,
uint16_t
port_num
);
virtual
~
udp_server_coop
();
int
create_socket
(
const
char
*
address
,
uint16_t
port_num
);
void
start_receive
(
udp_server_coop
*
udp
);
void
start_receive
(
udp_server_coop
*
udp
,
uint16_t
udp_port_num
);
void
handle_receive
();
static
void
*
udp_receiver_thread
(
void
*
arg
);
int
udp_read_from_socket
();
int
udp_read_from_socket_from_center
();
int
udp_read_from_socket_to_center
();
void
handle_receive_udp
(
int
r
,
uint8_t
udp_recv
[]);
int
getSocket
();
int
getPpid
();
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment