添加重传统计
All checks were successful
Build Test / build (push) Successful in 35s

This commit is contained in:
expvintl
2025-05-25 14:44:29 +08:00
parent 484988d50d
commit 542fe7f8b1
5 changed files with 21 additions and 14 deletions

View File

@ -220,12 +220,12 @@ log_ipv4(int status, int sequence)
rel_id = relativize_id(sequence, &ip_id);
else
rel_id = 0;
printf("\033[1;36m长度=%d ip=%s ttl=%d %sid%s%d ", ip_size, inet_ntoa(src),
printf("len=%d ip=%s ttl=%d %sid%s%d ", ip_size, inet_ntoa(src),
ip->ttl,
(ntohs(ip->frag_off) ? "DF " : ""),
(rel_id ? "=+" : "="), ip_id);
if (opt_verbose && !opt_quiet)
printf("tos=%x ip长度=%u\n", ip->tos, htons(ip->tot_len));
printf("tos=%x ip_len=%u\n", ip->tos, htons(ip->tot_len));
}
static void
@ -233,7 +233,7 @@ log_ipv6(int status, int sequence)
{
char tmp[1024];
printf("\033[1;35m长度=%d ip=%s ttl=%d ", ip_size, inet_ntop(opt_af, &src6, tmp, sizeof(tmp)),
printf("len=%d ip=%s ttl=%d ", ip_size, inet_ntop(opt_af, &src6, tmp, sizeof(tmp)),
ip6->hoplimit);
if (opt_verbose && !opt_quiet)
printf("tc=%x flowlabel=%u\n", (ip6->tc1 << 4) | ip6->tc2, (ip6->flowlabel1 << 16) | ip6->flowlabel2);
@ -242,8 +242,10 @@ log_ipv6(int status, int sequence)
static void
log_ip(int status, int sequence)
{
if(status == S_RECV)
printf("DUP! ");
if(status == S_RECV){
printf("[重传]DUP! ");
dup_count++;
}
if(ip->version == 4)
log_ipv4(status, sequence);
else
@ -416,7 +418,7 @@ int recv_icmp6(void *packet, size_t size)
status = rtt(&icmp_seq, 0, &ms_delay);
log_ip(status, icmp_seq);
printf("icmp_seq=%d 往返时间=%.2f 毫秒\n", icmp_seq, ms_delay);
printf("icmp_seq=%d rtt=%.2f ms\n", icmp_seq, ms_delay);
notrace = 1;
return 1;
}
@ -480,7 +482,7 @@ int recv_udp(void *packet, size_t size)
status = rtt(&sequence, ntohs(udp.uh_dport), &ms_delay);
if (!opt_quiet) {
log_ip(status, sequence);
printf("seq=%d 往返时间=%.2f 毫秒\n", sequence, ms_delay);
printf("seq=%d rtt=%.2f ms\n", sequence, ms_delay);
}
if (opt_incdport && !opt_force_incdport)
dst_port++;
@ -545,7 +547,7 @@ int recv_tcp(void *packet, size_t size)
if (flags[0] == '\0') strcat(flags, "none");
log_ip(status, sequence);
printf("源端口=%d 标志=%s seq=%d win=%d 往返时间=%.2f 毫秒\n",
printf("sport=%d flags=%s seq=%d win=%d rtt=%.2f ms\n",
ntohs(tcp.th_sport), flags, sequence,
ntohs(tcp.th_win), ms_delay);