{"id":553,"date":"2021-05-01T10:00:34","date_gmt":"2021-05-01T09:00:34","guid":{"rendered":"https:\/\/www.labtinker.net\/?p=553"},"modified":"2021-05-01T10:00:34","modified_gmt":"2021-05-01T09:00:34","slug":"you-cant-handle-the-data","status":"publish","type":"post","link":"http:\/\/18.135.13.153\/?p=553","title":{"rendered":"You Can&#8217;t Handle the Data!"},"content":{"rendered":"\n<p class=\"wp-block-paragraph\">Wireshark is a great tool but to my mind it\u2019s only worth using when you\u2019ve exhausted other avenues: firewall or event logs, browser developer tools or even tcpdump. However, there are some occasions when it\u2019s all you have, especially if you don\u2019t have access to intermediate network or filtering devices.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">I encountered a scenario recently where it was very useful but first I&#8217;d like to do a quick refresher on tcp windows. <\/p>\n\n\n\n<p class=\"wp-block-paragraph\">In a tcp session, the initiator (SYN sender) and responder (SYN\/ACK sender) tell each other the amount of unacknowledged bytes they can accept in their buffer &#8211; otherwise known as the tcp window size.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">So, for example, in the SYN packet below, the client defines its window size as 64240 bytes.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"602\" height=\"64\" src=\"http:\/\/18.135.13.153\/wp-content\/uploads\/2021\/04\/image-1.png\" alt=\"\" class=\"wp-image-555\" srcset=\"http:\/\/18.135.13.153\/wp-content\/uploads\/2021\/04\/image-1.png 602w, http:\/\/18.135.13.153\/wp-content\/uploads\/2021\/04\/image-1-300x32.png 300w\" sizes=\"auto, (max-width: 602px) 100vw, 602px\" \/><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\">But that isn\u2019t the whole story. The windows size is defined in a 16 bit field in the tcp header giving a top value of 65536 bytes which was probably OK in the early days but not now. So this is modified by a scaling factor or shift count of up to 14 which is a power of two: so in our SYN packet we have a scaling factor of 8 which Wireshark helpfully tells us means multiply by 256 (2 to the power 8)<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"392\" height=\"100\" src=\"http:\/\/18.135.13.153\/wp-content\/uploads\/2021\/04\/image-2.png\" alt=\"\" class=\"wp-image-556\" srcset=\"http:\/\/18.135.13.153\/wp-content\/uploads\/2021\/04\/image-2.png 392w, http:\/\/18.135.13.153\/wp-content\/uploads\/2021\/04\/image-2-300x77.png 300w\" sizes=\"auto, (max-width: 392px) 100vw, 392px\" \/><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\">So our window size is 64240 X 256 = 16,445,440 Bytes \u2013 which sounds a lot better.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">In the second packet, (the SYN\/ACK), the responder comes back with a lower value<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"602\" height=\"33\" src=\"http:\/\/18.135.13.153\/wp-content\/uploads\/2021\/04\/image-3.png\" alt=\"\" class=\"wp-image-557\" srcset=\"http:\/\/18.135.13.153\/wp-content\/uploads\/2021\/04\/image-3.png 602w, http:\/\/18.135.13.153\/wp-content\/uploads\/2021\/04\/image-3-300x16.png 300w\" sizes=\"auto, (max-width: 602px) 100vw, 602px\" \/><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\">Its scaling factor is also less ambitious.<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"378\" height=\"140\" src=\"http:\/\/18.135.13.153\/wp-content\/uploads\/2021\/04\/image-4.png\" alt=\"\" class=\"wp-image-558\" srcset=\"http:\/\/18.135.13.153\/wp-content\/uploads\/2021\/04\/image-4.png 378w, http:\/\/18.135.13.153\/wp-content\/uploads\/2021\/04\/image-4-300x111.png 300w\" sizes=\"auto, (max-width: 378px) 100vw, 378px\" \/><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\">So in this example, the client&#8217;s window size is  29200 x 128 = 3,737,600<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Both sides of the tcp session have to agree to use windows scaling though, as seen above, they don\u2019t have to agree to the same values and typically most tcp connections are assymetric with a lot more data flowing one way than the other.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">In Wireshark there is a Wireshark-calculated field called &#8216;Calcuated Window size&#8217; which is contrasted below against the window size to show the multiplier effect (Wireshark has to see the SYN\/SYN ACK negotiation to give a calculated window size that\u2019s accurate. If it hasn&#8217;t will show the scaling factor as -1 (unknown))<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"247\" height=\"354\" src=\"http:\/\/18.135.13.153\/wp-content\/uploads\/2021\/04\/image-5.png\" alt=\"\" class=\"wp-image-559\" srcset=\"http:\/\/18.135.13.153\/wp-content\/uploads\/2021\/04\/image-5.png 247w, http:\/\/18.135.13.153\/wp-content\/uploads\/2021\/04\/image-5-209x300.png 209w\" sizes=\"auto, (max-width: 247px) 100vw, 247px\" \/><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\">OK, to our problem  which does not involve the hosts in the capture above.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">A package manager was failing to download a file through a proxy. I have not included the ip addresses in order to protect the innocent and because they&#8217;re not really required. In the capture excerpts below the client is coming from a high port (52206) and talking to a proxy server on port 80. The window size is accurate as there is no scaling in play.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">In the Wireshark trace the &#8216;expert info&#8217; window showed a lot &#8216;TCP Window Full&#8217;, &#8216;TCP Zero Window&#8217;, and &#8216;TCP ZeroWindowProbes&#8217; so jumping to one of these occurences:<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">(The columns from L to R are :Time since start of capture | Window size | Information)<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"258\" src=\"http:\/\/18.135.13.153\/wp-content\/uploads\/2021\/04\/image-7-1024x258.png\" alt=\"\" class=\"wp-image-561\" srcset=\"http:\/\/18.135.13.153\/wp-content\/uploads\/2021\/04\/image-7-1024x258.png 1024w, http:\/\/18.135.13.153\/wp-content\/uploads\/2021\/04\/image-7-300x76.png 300w, http:\/\/18.135.13.153\/wp-content\/uploads\/2021\/04\/image-7-768x193.png 768w, http:\/\/18.135.13.153\/wp-content\/uploads\/2021\/04\/image-7.png 1366w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\">In the first packet, Wireshark marks the packet \u2018TCP Windows Full\u2019 when it knows the packet it is sending will fill up the buffer\/tcp window of the recipient: the client. The client\u2019s window size does indeed go down to zero and stays there for a full 19 seconds before it sends an update with a new Window size (64800). saying its open for business again. <\/p>\n\n\n\n<p class=\"wp-block-paragraph\">You&#8217;ll notice during this time the proxy was sending what Wireshark marks as &#8216;TCP ZeroWindowProbes&#8217;. These are packets with a length of one, presumably sent to see if the client will acknowledge them. If the client did acknowledge them it then it&#8217;s sequence number would match the previous packet&#8217;s &#8216;next sequence&#8217; number (493101) but as you see below it stays resolutely on 493100. It will not be rushed.<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"652\" height=\"105\" src=\"http:\/\/18.135.13.153\/wp-content\/uploads\/2021\/05\/image.png\" alt=\"\" class=\"wp-image-563\" srcset=\"http:\/\/18.135.13.153\/wp-content\/uploads\/2021\/05\/image.png 652w, http:\/\/18.135.13.153\/wp-content\/uploads\/2021\/05\/image-300x48.png 300w\" sizes=\"auto, (max-width: 652px) 100vw, 652px\" \/><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\">After the tcp window update (the green packet in the first trace)  the transfer rattled along happily for a little bit longer until the following occurred&#8230;<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"602\" height=\"173\" src=\"http:\/\/18.135.13.153\/wp-content\/uploads\/2021\/05\/image-2.png\" alt=\"\" class=\"wp-image-565\" srcset=\"http:\/\/18.135.13.153\/wp-content\/uploads\/2021\/05\/image-2.png 602w, http:\/\/18.135.13.153\/wp-content\/uploads\/2021\/05\/image-2-300x86.png 300w\" sizes=\"auto, (max-width: 602px) 100vw, 602px\" \/><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\">Almost exactly the same scenario as in the first trace excerpt, except this time the client didn&#8217;t send a tcp windows update in time and the proxy (or more accurately the destination server working through the proxy) became impatient and sent a tcp reset to abort the connection.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">So, Wireshark didn&#8217;t solve the problem, but it did confirm that the network and its components were doing their job. The data was getting to the client but for some reason the client was signalling it couldn&#8217;t take any more data. There was no indication why this was the case or what the client was doing with the data but that&#8217;s not in Wireshark&#8217;s remit. And in the trace excerpt above, the red reset packet is the proxy rising to its metaphorical feet pointing at Tom Cruise and roaring, &#8216;you can&#8217;t handle the data!!&#8217;.  <\/p>\n","protected":false},"excerpt":{"rendered":"<p>Wireshark is a great tool but to my mind it\u2019s only worth using when you\u2019ve exhausted other avenues: firewall or event logs, browser developer tools or even tcpdump. However, there are some occasions when it\u2019s all you have, especially if you don\u2019t have access to intermediate network or filtering devices. I encountered a scenario recently [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[9],"tags":[],"class_list":["post-553","post","type-post","status-publish","format-standard","hentry","category-networking"],"jetpack_featured_media_url":"","_links":{"self":[{"href":"http:\/\/18.135.13.153\/index.php?rest_route=\/wp\/v2\/posts\/553","targetHints":{"allow":["GET"]}}],"collection":[{"href":"http:\/\/18.135.13.153\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/18.135.13.153\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/18.135.13.153\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/18.135.13.153\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=553"}],"version-history":[{"count":0,"href":"http:\/\/18.135.13.153\/index.php?rest_route=\/wp\/v2\/posts\/553\/revisions"}],"wp:attachment":[{"href":"http:\/\/18.135.13.153\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=553"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/18.135.13.153\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=553"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/18.135.13.153\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=553"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}