Some fixes
This commit is contained in:
parent
946295ca80
commit
07b291efd9
2 changed files with 18 additions and 10 deletions
|
@ -103,11 +103,11 @@ void measlat_stop(
|
||||||
|
|
||||||
printf("All measurements done\n");
|
printf("All measurements done\n");
|
||||||
evt_core_rm_fd(ctx, timer_fd);
|
evt_core_rm_fd(ctx, timer_fd);
|
||||||
|
if (!(mctx->connectionless && mctx->role == MEASLAT_SERVER))
|
||||||
evt_core_rm_fd(ctx, net_fd);
|
evt_core_rm_fd(ctx, net_fd);
|
||||||
if (mctx->role == MEASLAT_CLIENT) {
|
if (mctx->role == MEASLAT_CLIENT)
|
||||||
exit(EXIT_SUCCESS);
|
exit(EXIT_SUCCESS);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
int on_receive_measure_packet(struct evt_core_ctx* ctx, struct evt_core_fdinfo* fdinfo) {
|
int on_receive_measure_packet(struct evt_core_ctx* ctx, struct evt_core_fdinfo* fdinfo) {
|
||||||
struct measlat_ctx* mctx = fdinfo->cat->app_ctx;
|
struct measlat_ctx* mctx = fdinfo->cat->app_ctx;
|
||||||
|
@ -132,7 +132,7 @@ int on_receive_measure_packet(struct evt_core_ctx* ctx, struct evt_core_fdinfo*
|
||||||
// 2. Read data in our measurement object
|
// 2. Read data in our measurement object
|
||||||
if (ms->mp_nin >= mctx->mp.payload_size || strcmp(mctx->transport, "udp") == 0) ms->mp_nin = 0;
|
if (ms->mp_nin >= mctx->mp.payload_size || strcmp(mctx->transport, "udp") == 0) ms->mp_nin = 0;
|
||||||
|
|
||||||
nread = mctx->connectionless ?
|
nread = mctx->connectionless && mctx->role == MEASLAT_SERVER ?
|
||||||
recvfrom(fdinfo->fd, ms->mp_in, mctx->mp.payload_size, MSG_TRUNC, (struct sockaddr*)&mctx->addr, &mctx->addrlen) :
|
recvfrom(fdinfo->fd, ms->mp_in, mctx->mp.payload_size, MSG_TRUNC, (struct sockaddr*)&mctx->addr, &mctx->addrlen) :
|
||||||
recv(fdinfo->fd, ms->mp_in + ms->mp_nin, mctx->mp.payload_size - ms->mp_nin, 0);
|
recv(fdinfo->fd, ms->mp_in + ms->mp_nin, mctx->mp.payload_size - ms->mp_nin, 0);
|
||||||
|
|
||||||
|
@ -220,7 +220,7 @@ int on_timer(struct evt_core_ctx* ctx, struct evt_core_fdinfo* fdinfo) {
|
||||||
struct measure_packet* head = measure_generate(&mctx->mp, ms);
|
struct measure_packet* head = measure_generate(&mctx->mp, ms);
|
||||||
//printf("send(id=%ld,is_echo=%d)\n", head->counter, head->is_echo);
|
//printf("send(id=%ld,is_echo=%d)\n", head->counter, head->is_echo);
|
||||||
|
|
||||||
s = mctx->connectionless ?
|
s = mctx->connectionless && mctx->role == MEASLAT_SERVER ?
|
||||||
sendto(ms->fd, head, mctx->mp.payload_size, 0, (struct sockaddr*)&mctx->addr, mctx->addrlen) :
|
sendto(ms->fd, head, mctx->mp.payload_size, 0, (struct sockaddr*)&mctx->addr, mctx->addrlen) :
|
||||||
send(ms->fd, head, mctx->mp.payload_size, 0);
|
send(ms->fd, head, mctx->mp.payload_size, 0);
|
||||||
|
|
||||||
|
@ -351,9 +351,16 @@ void spawn_udp_client(struct evt_core_ctx* evts) {
|
||||||
struct evt_core_fdinfo* reg_fdinfo = evt_core_add_fd (evts, &fdinfo);
|
struct evt_core_fdinfo* reg_fdinfo = evt_core_add_fd (evts, &fdinfo);
|
||||||
printf("--- UDP client registered\n");
|
printf("--- UDP client registered\n");
|
||||||
|
|
||||||
|
struct sockaddr_in my_addr;
|
||||||
|
socklen_t my_addr_len = sizeof(my_addr);
|
||||||
|
getsockname(udp_sock, (struct sockaddr *) &my_addr, &my_addr_len);
|
||||||
|
uint16_t myPort = ntohs(my_addr.sin_port);
|
||||||
|
printf("client port is %u\n", myPort);
|
||||||
|
|
||||||
struct measure_state ms = {0};
|
struct measure_state ms = {0};
|
||||||
ms.fd = udp_sock;
|
ms.fd = udp_sock;
|
||||||
measure_state_init (&mctx->mp, &ms);
|
measure_state_init (&mctx->mp, &ms);
|
||||||
|
|
||||||
register_timer (evts, mctx, &ms, NULL);
|
register_timer (evts, mctx, &ms, NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -400,15 +407,16 @@ void spawn_tcp_client(struct evt_core_ctx* evts) {
|
||||||
struct evt_core_fdinfo* reg_fdinfo = evt_core_add_fd (evts, &fdinfo);
|
struct evt_core_fdinfo* reg_fdinfo = evt_core_add_fd (evts, &fdinfo);
|
||||||
printf("--- TCP client registered\n");
|
printf("--- TCP client registered\n");
|
||||||
|
|
||||||
struct measure_state ms = {0};
|
|
||||||
struct sockaddr_in my_addr;
|
struct sockaddr_in my_addr;
|
||||||
socklen_t my_addr_len = sizeof(my_addr);
|
socklen_t my_addr_len = sizeof(my_addr);
|
||||||
ms.fd = tcp_sock;
|
|
||||||
measure_state_init (&mctx->mp, &ms);
|
|
||||||
getsockname(tcp_sock, (struct sockaddr *) &my_addr, &my_addr_len);
|
getsockname(tcp_sock, (struct sockaddr *) &my_addr, &my_addr_len);
|
||||||
uint16_t myPort = ntohs(my_addr.sin_port);
|
uint16_t myPort = ntohs(my_addr.sin_port);
|
||||||
printf("client port is %u\n", myPort);
|
printf("client port is %u\n", myPort);
|
||||||
|
|
||||||
|
struct measure_state ms = {0};
|
||||||
|
ms.fd = tcp_sock;
|
||||||
|
measure_state_init (&mctx->mp, &ms);
|
||||||
|
|
||||||
register_timer (evts, mctx, &ms, NULL);
|
register_timer (evts, mctx, &ms, NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -64,10 +64,10 @@ void measure_parse(struct measure_params* mp, struct measure_state* ms) {
|
||||||
uint8_t is_vanilla = (ms->mp_in->flag & 0x40) >> 6;
|
uint8_t is_vanilla = (ms->mp_in->flag & 0x40) >> 6;
|
||||||
uint8_t link_id = ms->mp_in->flag & 0x3f;
|
uint8_t link_id = ms->mp_in->flag & 0x3f;
|
||||||
printf(
|
printf(
|
||||||
"[%s] src=%d, id=%llu, owd=%luµs, flag=%d, link=%d, vanilla=%d\n",
|
"[%s] src=%d, id=%lu, owd=%luµs, flag=%d, link=%d, vanilla=%d\n",
|
||||||
current_human_datetime(),
|
current_human_datetime(),
|
||||||
ms->fd,
|
ms->fd,
|
||||||
(unsigned long long)ms->mp_in->counter,
|
ms->mp_in->counter,
|
||||||
micro_sec,
|
micro_sec,
|
||||||
is_slow,
|
is_slow,
|
||||||
link_id,
|
link_id,
|
||||||
|
|
Loading…
Reference in a new issue