Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Extract socket TCP informations with struct tcp_info

26 views
Skip to first unread message

younes korbi

unread,
Mar 3, 2023, 5:11:46 AM3/3/23
to
I am currently working on extracting TCP information such as cwnd size, RTT, and retransmission rate. I have created a function in the client socket to achieve this. The function sends data and measures the TCP information. It also writes the information to files for further analysis.


void send_data(int sock, char buffer[], FILE *rate, FILE *cwnd, FILE *rtt) {
int sent_bytes, total_sent_bytes = 0;
double cwnd_size;
struct tcp_info info;
socklen_t len = sizeof(info);
time_t start, end, last = time(NULL); // last: temps de la dernière mesure
start = time(NULL);

while (total_sent_bytes < DATA_SIZE) {
sent_bytes = send(sock, buffer, BUFFER_SIZE, 0);
if (sent_bytes < 0) {
perror("send() failed");
exit(EXIT_FAILURE);
}

end = time(NULL);
total_sent_bytes += sent_bytes;

if (difftime(end, last) == 1.0) { // si une seconde s'est écoulée
if (getsockopt(sock, SOL_TCP, TCP_INFO, &info, &len) == -1) {
perror("getsockopt");
exit(1);
}

cwnd_size = (info.tcpi_snd_cwnd * info.tcpi_snd_mss) / 1024;

fprintf(cwnd, "%ld,%f\n", end-start, cwnd_size);

fprintf(rtt, "%ld,%u\n", end-start, info.tcpi_rtt);

last = end; // mise à jour du temps de la dernière mesure
}
}
}



However, I am still confused about the unit of RTT (milliseconds or microseconds) as the results of RTT are larger than the ping results. I would also like to extract information about BBR such as BDP. Can someone guide me on how to extract this information?
0 new messages