• Extract socket TCP informations with struct tcp_info

    From younes korbi@21:1/5 to All on Fri Mar 3 02:11:45 2023
    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?

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)