d2jsp
Log InRegister
d2jsp Forums > Off-Topic > General Chat > Homework Help > Tcp 3-way Handshake
Add Reply New Topic New Poll
Member
Posts: 70,469
Joined: May 15 2007
Gold: 2,385.00
Apr 24 2013 10:25am
2 Simulate TCP 3-Way Handshake


Write two Perl scripts which are using TCP sockets to communicate and simulate the TCP 3-way handshake.
The name of the client script should be tcp-client.pl and the server tcp-server.pl.
1. The scripts should calculate a random Initial Sequence Number (ISN) according to the speci cations (32
bits unsigned integer).
2. When the maximum sequence or acknowledgement number is reached, it should should be able to handle
it by wrapping around to 0.
3. They should exchange a simulated SYN, SYN+ACK and ACK with the expected sequence and acknowl-
edgement numbers based on the ISN's.
First you should start the server, then you should connect to it with the client you wrote and get an output
like this:


tcp-client.pl output
1 $ ./tcp-client.pl
2 Connected to server at 127.0.0.1:11000
3 SYN Sent: SEQ=4122339374 (Expected ACK to Receive Next: 4122339375)
4 SYN,ACK received from server: SEQ=3093316905,ACK=4122339375 (Got Expected ACK: 4122339375)
5 ACK Sent: ACK=3093316906
6
7 TCP 3-Way Handshake Simulation Succeeded. Connection Established.
tcp-server.pl output
1 $ ./tcp-server.pl
2 TCP server is waiting for client connections on port 11000...
3 Got connection from: 127.0.0.1:57075
4 SYN received from client: 4122339374
25 SYN,ACK Sent: SEQ=3093316905,ACK=4122339375 (Expected ACK to Receive Next: 3093316906)
6 ACK received from client: 3093316906 (Got Expected ACK: 3093316906)
7
8 TCP 3-Way Handshake Simulation Succeeded. Connection Established.
Go Back To Homework Help Topic List
Add Reply New Topic New Poll