Friday 31 July 2020

Understanding TCP Sequence and Acknowledgment Numbers

If you're reading this, odds are that you're already familiar with TCP's infamous "three-way handshake," or "SYN, SYN/ACK, ACK." Unfortunately, that's where TCP education ends for many networkers. Despite its age, TCP is a relatively complex protocol and well worth knowing intimately.his article aims to help you become more comfortable examining TCP sequence and acknowledgement numbers in the Wireshark packet analyzer.

The example capture contains a single HTTP request to a web server, in which the client web browser requests a single image file, and the server returns an HTTP/1.1 200 (OK) response which includes the file requested. You can right-click on any of the TCP packets within this capture and select Follow TCP Stream to open the raw contents of the TCP stream in a separate window for inspection. Traffic from the client is shown in red, and traffic from the server in blue.

follow_tcp_stream.png

The Three-Way Handshake

TCP utilizes a number of flags, or 1-bit boolean fields, in its header to control the state of a connection. The three we're most interested in here are:

  • SYN - (Synchronize) Initiates a connection
  • FIN - (Final) Cleanly terminates a connection
  • ACK - Acknowledges received data

As we'll see, a packet can have multiple flags set.

Select packet #1 in Wireshark and expand the TCP layer analysis in the middle pane, and further expand the "Flags" field within the TCP header. Here we can see all of the TCP flags broken down. Note that the SYN flag is on (set to 1).

tcp_syn.png

Now do the same for packet #2. Notice that it has two flags set: ACK to acknowledge the receipt of the client's SYN packet, and SYN to indicate that the server also wishes to establish a TCP connection.

tcp_synack.png

Packet #3, from the client, has only the ACK flag set. These three packets complete the initial TCP three-way handshake.

Sequence and Acknowledgment Numbers

The client on either side of a TCP session maintains a 32-bit sequence number it uses to keep track of how much data it has sent. This sequence number is included on each transmitted packet, and acknowledged by the opposite host as an acknowledgement number to inform the sending host that the transmitted data was received successfully.

When a host initiates a TCP session, its initial sequence number is effectively random; it may be any value between 0 and 4,294,967,295, inclusive. However, protocol analyzers like Wireshark will typically display relative sequence and acknowledgement numbers in place of the actual values. These numbers are relative to the initial sequence number of that stream. This is handy, as it is much easier to keep track of relatively small, predictable numbers rather than the actual numbers sent on the wire.

For example, the initial relative sequence number shown in packet #1 is 0 (naturally), while the ASCII decode in the third pane shows that the actual sequence number is 0xf61c6cbe, or 4129057982 decimal.

relative_sequence_numbers.png

The display of relative sequence numbers can optionally be disabled by navigating to Edit > Preferences... and un-checking Relative sequence numbers and window scaling under TCP protocol preferences. However, be aware that the remainder of this article will reference relative sequence and acknowledgement numbers only.

To better understand how sequence and acknowledgement numbers are used throughout the duration of a TCP session, we can utilize Wireshark's built-in flow graphing ability. Navigate to Statistics > Flow Graph..., select TCP flow and click OK. Wireshark automatically builds a graphical summary of the TCP flow.

tcp_flow.png

Each row represents a single TCP packet. The left column indicates the direction of the packet, TCP ports, segment length, and the flag(s) set. The column at right lists the relative sequence and acknowledgement numbers in decimal. Selecting a row in this column also highlights the corresponding packet in the main window.

We can use this flow graph to better understand how sequence and acknowledgement numbers work.

Packet #1

Each side of a TCP session starts out with a (relative) sequence number of zero. Likewise, the acknowledgement number is also zero, as there is not yet a complementary side of the conversation to acknowledge.

(Note: The version of Wireshark used for this demonstration, 1.2.7, shows the acknowledgement number as an apparently random number. This believed to be a software bug; the initial acknowledgement number of a session should always be zero, as you can see from inspecting the hex dump of the packet.)

Packet #2

The server responds to the client with a sequence number of zero, as this is its first packet in this TCP session, and a relative acknowledgement number of 1. The acknowledgement number is set to 1 to indicate the receipt of the client's SYN flag in packet #1.

Notice that the acknowledgement number has been increased by 1 although no payload data has yet been sent by the client. This is because the presence of the SYN or FIN flag in a received packet triggers an increase of 1 in the sequence. (This does not interfere with the accounting of payload data, because packets with the SYN or FIN flag set do not carry a payload.)

Packet #3

Like in packet #2, the client responds to the server's sequence number of zero with an acknowledgement number of 1. The client includes its own sequence number of 1 (incremented from zero because of the SYN).

At this point, the sequence number for both hosts is 1. This initial increment of 1 on both hosts' sequence numbers occurs during the establishment of all TCP sessions.

Packet #4

This is the first packet in the stream which carries an actual payload (specifically, the client's HTTP request). The sequence number is left at 1, since no data has been transmitted since the last packet in this stream. The acknowledgement number is also left at 1, since no data has been received from the server, either.

Note that this packet's payload is 725 bytes in length.

Packet #5

This packet is sent by the server solely to acknowledge the data sent by the client in packet #4 while upper layers process the HTTP request. Notice that the acknowledgement number has increased by 725 (the length of the payload in packet #4) to 726; e.g., "I have received 726 bytes so far." The server's sequence number remains at 1.

Packet #6

This packet marks the beginning of the server's HTTP response. Its sequence number is still 1, since none of its packets prior to this one have carried a payload. This packet carries a payload of 1448 bytes.

Packet #7

The sequence number of the client has been increased to 726 because of the last packet it sent. Having received 1448 bytes of data from the server, the client increases its acknowledgement number from 1 to 1449.

For the majority of the capture, we will see this cycle repeat. The client's sequence number will remain steady at 726, because it has no data to transmit beyond the initial 725 byte request. The server's sequence number, in contrast, continues to grow as it sends more segments of the HTTP response.

Tear-down

Packet #38

After acknowledging the last segment of data from the server, the client processes the HTTP response as a whole and decides no further communication is needed. Packet #38 is sent by the client with the FIN flag set. Its acknowledgement number remains the same as in the prior packet (#37).

Packet #39

The server acknowledges the client's desire to terminate the connection by increasing the acknowledgement number by one (similar to what was done in packet #2 to acknowledge the SYN flag) and setting the FIN flag as well.

Packet #40

The client sends its final sequence number of 727, and acknowledges the server's FIN packet by incrementing the acknowledgement number by 1 to 22952.

At this point, both hosts have terminated the session and can release the software resources dedicated to its maintenance.

Friday 18 September 2015

Mixed Shero shayari

Pilane Se Pehle Batado Zara Sa
Badi Tadaf Hoti Hai Pine Se Pehle
Nirali Aada Hai Mere Sakiya Ki
Girata Bahot Hai Uthane Se Pehle..

-----------------------------------------
In Nafrat Ki Divaro Ko Todega Kon
Agar Digaj Nahi Karenge To Pehl Karega Kon
Is Duniya Mein Bahot Raste Hai Chalne Ki Liye
Agar To Sach Ke Raste Na Chala to Tujhe Yaad Karega Kon
Har Azadi Se Pehle Marna Padta Hai
Agar To Marne Se Dar Gya To Tujhe Azad Karvavega Kon ...

------------------------------------------------------------------
Humne Socha Ke Hum Hi Chahte Hai Un Ko
Magar Unko Chahne Walo Ka Karva Nikla
Dil Ne Kaha Shikayat Kar Us Khuda Se
Magar Unke Chahne Walo Me Khuda Bhi Nikla--

--------------------------------------------------------------------------------
Zindgi ki Trishala abhi baki thi
Umeed ki chader ja chuki  thi
Zindgi ke safar me sab kuch dikha diya tha
Abhi sapno ki udan baki thi
Zindgi ke kasm kass me aysa fhasa ek parenda tha
Ab dekhi ki ek umed Jise le kr wo udd gaya
------------------------------------------------------

raah mein kaante ek do nahi hote
raah kaanton se bhari hoti hai
manzil us raah ke akhiri chor par khadi hoti hai
jahan har kadam par milti ek nayi chouti hai
dekh use jinke hounsle dagmagaate hain
ve manzil ko bhula kaanton mein ulajh jaate hain
jinki nigaah manzil par hoti hai
ve kaanton pe hi chalkar manzil ko paate hain



Monday 15 June 2015

real meaning of love

hello
I am totally confused to get real meaning of love. A lot  of questions are wondering in my mind that  what is love . is lust a love ?, is infatuation a love ?  After a long search i got treasure hunt about love,


                   Love is a complex perplexity that has been defined by countless people; yet, no one
has ever been close in grasping its true nature. One may turn to his/her dictionary to look for the meaning; however, even the dictionary cannot define this exactly.We then ask, how will we know if we’re already in love if we, ourselves, cannot even identify it? It is an intricate question; indeed, we often confuse love with various feelings like lust and infatuation.Back in our Elementary days, we had our own crushes and immediately thought that it was love; hence, the catchphrase “I am in love with you” and the ever-popular “love at first sight.” People carry the belief until they grow up.  They are being blinded by this sad thing. What they don’t know is that it’s not love; in fact, it is called Infatuation. We know it’s infatuation since Infatuation is distinguished by a lack of trust, loyalty, commitment, and reciprocity; in addition, there is the presence of the obsessor and the apple of the eye, which of course may or may not be attainable. For kids, there’s infatuation; however, for young adults and adults alike, there is lust. Lust, also known as lechery, is an impure act that involves one’s desire of the “flesh” of another. Lust is prevalent in teenagers and adults alike. Whenever they see an attractive person, they feel infatuated and afterward, think of unclean thoughts involving them and the concerned person. What is sad about this is that once their desires have been met, they grow tired and eventually leave their partners. What really is love then? Is it safe to say that love is anything that doesn’t fall under infatuation and lust? Love is definitely a deeper feeling; on the contrary, infatuation and lust are simply feelings that are too shallow. Love is simply too complex to be talked out; subsequently, many people still end up being perplexed  by love. This makes love a very special feeling; uniquely, it gives one an experience that no other feeling could give and that includes lust and infatuation. When everything is said and done, we can all say that love is indeed a wonderfuL feeling which can be talked about for a very long time.

              According to ancient greek theory of love which is broken down into several different thinghs as it is in most culture .for instances in indian budhism there is no word for love ,there is another word compassion  for being happy for another person's happiness , for being friendly towards all beings toward loving kindness being peaceble toward all being ..there are different words for that.we  talk a whole lot about love in our society we rarely actually explain what it  mean for ?.love is relationship between lover and beloved. Now greek like to talk about eros and agape as two different kinds of love.Eros is loved based on desire we think immediately of sexual desire. On other agape is love based on caring rather than on desire.you see something in the beloved that is worth desiring.psychologist offer point out that the clove of new born infant  for it mother is entirely eros here  source of comfort , source of relief from hunger  and here is source of warmth. Agape mean th that i want to give to you because i care about you. part of my happiness is seeing your happy that's agape it does not means that eros is bad and agape is good.The ancient  greek thought that is ideal situation was to have eros and agape in balance with each other.you have thinghs that enchance my life and i desire them and i have thinghs what i want to give to you because i care about you and vice and versa. For greek having eros and agape in balance was that's desire relationship if you maintain that over time known as philia (often translated as friendship ). Real friends freely give to each other and freely receive from each other.
 AGAPE WITHOUT EROS IS ARROGANCE .EROS WITHOUT AGAPE IS EXPLOITATION

Saturday 6 June 2015

Abecedarian's foot on blog

Hello
I m just very much excited to get acquainted with blog. It arises same feeling in me when baby get something new then he wants to touch and play with that ,  just feels jovial and blissful after experiencing  that moreover its like  when a boy gets new girlfriend likewise today,  i met mine too which  is  certainly this ineludible blog . I can express my sorrow, pain and lots of  happy moments of my life.It is awfully hovering in my mind what i  gonna write in my first felicitous blog....just thinking of a long journey....mind  continously entangling with deep endless thoughts.It is  evoking intuition which usually i left with question mark  and i never again bother to  think about that but now a days i just put on it in order to get heap of my innovative thoughts which gonna help me in moulding   my bright future. this is my  new journey with blog,i want to play and dance with it, just wanting to get drown into profound sea of  blog.
I  always wanted to be curious and intuitive child in my life who will never fear in taking decisions.Thats i am able to share.. i  hope you like it..later i will come with more interesting treasure hunt..ta-ta for now..

                         “Children see magic because they look for it.”