Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to measure the TCP/IP overhead without sniffing?

I'm wondering whether there is a programmatic way to obtain a measure of the full bandwidth used when sending data through a TCP stream. Since I cannot seem to know how the network stack would divide the stream into packets, or when it sends a TCP SYN or ACK or many of the things it does in the background for you, I can only get a rough estimate for this.

The only solution I can think of is to actually sniff the interface, but I would like to think that the stack can already collect this stats for me.

This is running in Java under either Windows or Linux (of course, a portable solution would be preferred), but I can JNI-ize a C/C++ answer so that (and OS API calls) is a fine answer too. Thank you!

like image 957
Ismael C Avatar asked Feb 03 '10 16:02

Ismael C


People also ask

How much overhead does TCP IP add?

Summary. So, as demonstrated, for data payloads in excess of the common TCP payload maximum segment size (the MSS) of 1460 Bytes, the TCP over IP bandwidth overhead is approximately 2.8%.

Does TCP have overhead bytes?

At Transport Layer, 20 Bytes overhead is added by TCP for each data segment. Down at Network Layer, 20 Bytes overhead is added by IP for each TCP Segment. Once at Data Link Layer, Ethernet would add its own overhead of 26 Bytes to each Network Layer PDU (nothing but IP Packet).

What is an Internet overhead?

Data that you send across a wireless network is housed in a data envelope called a packet. Each transmission includes additional information, called overhead, that is required to route the data to the proper location.


1 Answers

[Windows specific answer]

On Windows you can consider looking at ETW (Event Tracing for Windows). In general, ETW is the technology used to provide tracing/logging information on Windows, and most Microsoft software is already instrumented with ETW providers that you can use. In your case, I think the Microsoft-Windows-TCPIP provider has information (e.g. local/remote address and port, operation, bytes sent/received, etc) that might be helpful for you.

For example, I was able to start collecting the TCPIP events to a file using the command:

logman start MyTcpipLog -p Microsoft-Windows-TCPIP -ets

And stop with

logman stop MyTcpipLog -ets

Then the MyTcipipLog.etl file can be opened using a number of different tools (e.g. xperf), but there are APIs that you can use to parse this file yourself.

If you wanted to be doing this at runtime, you can create a "real-time" ETW session to process the events as they come in.

If you're new to ETW, here's a helpful article on MSDN that I used.

like image 119
Matt Avatar answered Oct 03 '22 18:10

Matt