Jump to content

3-way Handshake

- - - - -

  • Please log in to reply
11 replies to this topic

#1
Apprentice123

Apprentice123

    Programming Expert

  • Members
  • PipPipPipPipPipPip
  • 430 posts
What would be the 3-way handshake method for a sender and addressee that exchange packets of parallel?

#2
Momerath

Momerath

    Programming Professional

  • Members
  • PipPipPipPipPip
  • 243 posts
In general a 3-way handshake is where two machines exchange three messages to establish communications. For example, this is used in the TCP protocol. Machine A sends a 'SYN' message to machine B. Machine B sends back a 'SYN-ACK' message. Machine A then responds with an 'ACK' message.

#3
Apprentice123

Apprentice123

    Programming Expert

  • Members
  • PipPipPipPipPipPip
  • 430 posts

Momerath said:

In general a 3-way handshake is where two machines exchange three messages to establish communications. For example, this is used in the TCP protocol. Machine A sends a 'SYN' message to machine B. Machine B sends back a 'SYN-ACK' message. Machine A then responds with an 'ACK' message.

OK. Thanks

#4
Apprentice123

Apprentice123

    Programming Expert

  • Members
  • PipPipPipPipPipPip
  • 430 posts
How can I implement this presentation?

#5
Momerath

Momerath

    Programming Professional

  • Members
  • PipPipPipPipPip
  • 243 posts

Apprentice123 said:

How can I implement this presentation?

That question is too vague to answer in any way other than to point to the definition of 3-way handshake.

At the least you'll need to establish a protocol for sending messages, a message format, what information you are negotiating, ... Those are just off the top of my head, I'm sure there are more.

#6
Apprentice123

Apprentice123

    Programming Expert

  • Members
  • PipPipPipPipPipPip
  • 430 posts

Momerath said:

That question is too vague to answer in any way other than to point to the definition of 3-way handshake.

At the least you'll need to establish a protocol for sending messages, a message format, what information you are negotiating, ... Those are just off the top of my head, I'm sure there are more.

I'm thinking of using the algorithm Go-Back-N. But I did not understand very well the workings of this algorithm.

#7
Apprentice123

Apprentice123

    Programming Expert

  • Members
  • PipPipPipPipPipPip
  • 430 posts
In three-way handshake we have:
(1) client-------------------> server
(2) client<------------------- server
(3) client-------------------> server

(1) client sends a packet with the flag SYN (sequence) to the server
(2) If the server accepts the packet, it sends a packet to the client with the flags SYN and ACK
(3) Upon receiving the SYN + ACK from the server, the client sends another ACK packet to the server, thus establishing the connection
Are correct ? But why is SYN and ACK (what to send ?) ?

#8
Momerath

Momerath

    Programming Professional

  • Members
  • PipPipPipPipPip
  • 243 posts
SYN and ACK are part of the TCP protocol. You can develop any protocol you like and send whatever you like. If you are doing the 3-way handshake, then you'll need a 3 step method (like the one you described).

For example, your client could send: HELLO 382839
Server responds with: HI 382839 HELLO 289593
Client responds with : HI 289593

In this case HELLO is the SYN message, and HI is the ACK message. The number following is to ensure that they are responding to the correct client/server. If the number to a HI message is not the number sent by the HELLO message, then something is wrong. See, I just made up a protocol :)

#9
Apprentice123

Apprentice123

    Programming Expert

  • Members
  • PipPipPipPipPipPip
  • 430 posts

Momerath said:

SYN and ACK are part of the TCP protocol. You can develop any protocol you like and send whatever you like. If you are doing the 3-way handshake, then you'll need a 3 step method (like the one you described).

For example, your client could send: HELLO 382839
Server responds with: HI 382839 HELLO 289593
Client responds with : HI 289593

In this case HELLO is the SYN message, and HI is the ACK message. The number following is to ensure that they are responding to the correct client/server. If the number to a HI message is not the number sent by the HELLO message, then something is wrong. See, I just made up a protocol :)

Thank you, very good explanation.
About the algorithm Go Back N, when a packet is lost, a timer is created to send the package again. This timer is pre-defined or is it the time it takes to send packets successors of the lost packet?
For Example:

P1 --------> receives P1 and send ACK1
P2 -----Lost
P3 --------> discards P3 and send ACK1
P4 --------> discards P4 and send ACK1
.
.
.
P2 -------> receives P2 and send ACK2
P3 ------->
.
.
.

The time it takes to Resubmit P2 is the time to send and discard or P3 and P4 or is a set time?

#10
Momerath

Momerath

    Programming Professional

  • Members
  • PipPipPipPipPip
  • 243 posts
You set the frame for how many packets you are going to send before you check for the ACK statements (on the server). For example, let's say you check every 4 and number 2 was lost (like your example). This results in:


[B]Server                       Client[/B]

Send P1                      Send ACK 1

Send P2                      not recieved

Send P3                      dropped

Send P4                      dropped

Check ACKs received          ....

Send P2                      Send ACK 2

Send P3                      Send ACK 3

etc

The N (of the Go-Back-N) in this case is 4, as the server will never go back more than 4.

#11
Apprentice123

Apprentice123

    Programming Expert

  • Members
  • PipPipPipPipPipPip
  • 430 posts
OK. Thank you, the Go-Back-N I understand, thanks.
I have other problem: I have to "split" messages, to create the packages and package identification header (use fragmentation for packets larger than 20 bytes, using the idea of IPv4)

What I understand about fragmentation is: accurate identification, flag and displacement.
identification
is to determine which package is fragmenting
flag is flag=1
for each segment, until the last fragment where flag=0
displacement is where data will be inserted in each fragment
I'm correct ?

And what's
"create the packages and package identification header", would be the fragmentation?



#12
Apprentice123

Apprentice123

    Programming Expert

  • Members
  • PipPipPipPipPipPip
  • 430 posts
You understand my question doubt?




1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users