hi:
- testing environment:2。 Network port:9G and 2G switch mac2mac。
- A72 -> 9G -> 2G ->MCU(TDA4 R5), udp packet, len 400, 400hz。In about 5 minutes, A72 will hang up, A72 will stop printing, and there is no abnormal printout。A72and MCU cannot ping。MCU serial port printing is normal。
- The packet becomes smaller, the frequency increases, the result the same as (2)
- Reduce the frequency and packet size, you can run longer, but eventually hang up;
A72 log(no abnormal printout):
test programe:
#include <stdio.h> #include <stdlib.h> #include <string.h> #include <stdbool.h> #include <time.h> #include <unistd.h> #include <pthread.h> #include <signal.h> #include <fcntl.h> #include <sys/types.h> #include <sys/socket.h> #include <netinet/in.h> #include <string.h> #include <errno.h> #define CONF_FILE_PATH "Config.ini" typedef struct { int dstport; int sockfd; int port; }wm_t; typedef struct { unsigned long cnt; struct timespec tx; }header_t; static wm_t s_wm_info[100]; static int s_socket_fd[10] = {-1}; static void vti_pf_gettm(struct timespec *tm) { struct timespec ts = {0}; clock_gettime(CLOCK_REALTIME, &ts); tm->tv_sec = ts.tv_sec; tm->tv_nsec = ts.tv_nsec; return ; } static void *thread_func(void *arg){ wm_t *p = (wm_t *)arg; int counter = 0; int ret; unsigned long lost = 0; unsigned long last_cnt = 0; char buf[1500]; socklen_t len; int count; struct sockaddr_in clent_addr; int server_fd = p->sockfd; if (server_fd < 0){ printf("error sockfd %d\n", server_fd); return ; } while(1) { memset(buf, 0, sizeof(buf)); len = sizeof(clent_addr); count = recvfrom(server_fd, buf, 1500, 0, (struct sockaddr*)&clent_addr, &len); //recvfrom是拥塞函数,没有数据就一直拥塞 if(count == -1) { printf("recieve data fail!\n"); continue; } header_t *k = (header_t *)buf; unsigned char v = k->cnt - last_cnt; if (v > 1){ //TODO pub lost samples lost += (v - 1); } struct timespec rx; vti_pf_gettm(&rx); unsigned long delay = (rx.tv_sec % 100 ) * 1000000 + rx.tv_nsec / 1000 - ((k->tx.tv_sec % 100)*1000000 + k->tx.tv_nsec / 1000); if(k->cnt % 100 == 0) printf("port :%d lost %lu delay us: %lu \n", p->port, lost, delay); } } static void *thread_func_tx(void *arg){ unsigned long counter = 0; int client_fd; char buf[1500]; struct sockaddr_in ser_addr; wm_t *p = (wm_t *)arg; client_fd = p->sockfd; if(client_fd < 0) { printf("socket error!\n"); return ; } memset(&ser_addr, 0, sizeof(ser_addr)); ser_addr.sin_family = AF_INET; ser_addr.sin_addr.s_addr = inet_addr("192.168.1.4"); ser_addr.sin_port = htons(p->dstport); //注意网络序转换 while(1){ memset(buf, 0, sizeof(buf)); header_t *v = (header_t *)buf; v->cnt = counter; vti_pf_gettm(&v->tx); int rc = sendto(client_fd, buf, 400, 0, (struct sockaddr *)&ser_addr, sizeof(struct sockaddr)); if (rc < 0){ printf("send error %d\n", errno); continue; } counter++; usleep(3000); } } int main(int argc, const char **argv){ int server_fd, ret; struct sockaddr_in ser_addr; pthread_t sync_process; pthread_t sync_process1; int i = 0; for(i = 0; i < 3; i++){ s_wm_info[i].port = 5000 + i; s_wm_info[i].dstport = 5000 + i; server_fd = socket(AF_INET, SOCK_DGRAM, 0); if(server_fd < 0) { printf("create socket fail!\n"); return -1; } memset(&ser_addr, 0, sizeof(ser_addr)); ser_addr.sin_family = AF_INET; ser_addr.sin_addr.s_addr = htonl(INADDR_ANY); ser_addr.sin_port = htons(s_wm_info[i].port); ret = bind(server_fd, (struct sockaddr*)&ser_addr, sizeof(ser_addr)); if(ret < 0) { printf("socket bind fail!\n"); return -1; } s_wm_info[i].sockfd = server_fd; } for (i = 0; i < 3; i++){ printf("[udp] port:%d socketfd:%d\n", s_wm_info[i].port, s_wm_info[i].sockfd); if (pthread_create(&sync_process, NULL/*&s_thread_attr*/, thread_func, &s_wm_info[i]) != 0){ printf("thread create failed!\n"); return 0; } if (pthread_create(&sync_process1, NULL/*&s_thread_attr*/, thread_func_tx, &s_wm_info[i]) != 0){ printf("thread create failed!\n"); return 0; } } while(1){ usleep(100000); } }
pelase give us some advise,thanks!