Last active
December 18, 2019 17:09
-
-
Save countingpine/aa6a35150c8ff29245ea27755cb4eeac to your computer and use it in GitHub Desktop.
TCP window calculator
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// tcpwindow.cpp : Defines the entry point for the console application. | |
// Fixed from https://blogs.technet.microsoft.com/neilcar/2004/10/26/quick-figuring-optimal-tcp-window-size/#comment-263 | |
// | |
//#include "stdafx.h" | |
#include <stdio.h> | |
#include <string.h> | |
#include <stdlib.h> | |
int main(int argc, char* argv[]) | |
{ | |
float pingRTT; | |
float bandwidth; | |
const char* pingExample = "c:\\>ping slow-msg-51\n\n\tReply from 17.54.12.19: bytes=32 time=176ms TTL=56\n\tReply from 17.54.12.19: bytes=32 time=114ms TTL=56\n\tReply from 17.54.12.19: bytes=32 time=117ms TTL=56\n\tReply from 17.54.12.19: bytes=32 time=171ms TTL=56\n"; | |
const char* pingExample2 = "\n\tPing statistics for 17.54.12.19:\n\t Packets: Sent = 4, Received = 4, Lost = 0 (0% loss),\n\tApproximate round trip times in milli-seconds:nt Minimum = 114ms, Maximum = 176ms, Average = 144ms\n\n"; | |
printf("===================================\n"); | |
printf(" The TCPWindow Size Tool\n"); | |
printf("===================================\n"); | |
printf("\n\n"); | |
printf("STEP 1: Find the RTT:\n"); | |
printf("======================\n"); | |
printf("Example: \n"); | |
printf("t"); | |
printf("%s",pingExample); | |
printf("%s",pingExample2); | |
printf("Note —> Approximate round trip times in milli-seconds:\n\t … Average = 144ms\n\n"); | |
printf("\n\n"); | |
printf("========================================================\n"); | |
printf("What is the Approximate round trip times for your issue?\n"); | |
printf("========================================================\n"); | |
printf(" Action: Type in the seconds value (if rtt was 144 then enter \".144\")\n and press ENTER\n\n"); | |
printf("RTT Value: "); | |
scanf("%f",&pingRTT); | |
printf("\n\n"); | |
printf("STEP 2: State the bandwidth:\n"); | |
printf("==============================\n"); | |
printf("Example: \n\n"); | |
printf("\t"); | |
printf("This is the WAN bandwidth. An example could be 1.44, 5, 10, 45, etc…\n"); | |
printf("\n\n"); | |
printf("=====================================================\n"); | |
printf("What is the the available bandwidth of your WAN link?\n"); | |
printf("=====================================================\n"); | |
printf(" Action: Type in the value (i.e. 1.5) and press ENTER\n\n"); | |
printf("Value: "); | |
scanf("%f",&bandwidth); | |
printf("\n\n"); | |
printf("You have specified: %f as the RTT.\n",pingRTT); | |
printf("You have specified: %f for the bandwidth.\n",bandwidth); | |
printf("\n\n"); | |
printf("STEP 3: Do the numbers:\n"); | |
printf("==============================\n"); | |
printf("Step1: ([BANDWIDTH]*1024*1024/8)bytes/second * [ROUND TRIP] = [TCP WINDOW]\n\n"); | |
printf("Step2: (%f*1024*1024/8)bytes/second * (%f) = [TCP WINDOW]\n\n",pingRTT,bandwidth); | |
int step3; | |
step3 = (pingRTT * 1024*1024/8); | |
printf("Step3: (%d) * (%f) = [TCP WINDOW]\n\n",step3,bandwidth); | |
float step4; | |
step4 = step3 * bandwidth; | |
printf("Step4: %f = [TCP WINDOW]\n\n",step4); | |
printf("Step4: TCPWindowSize = %d\n\n",int(step4)); | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment