Demonstrate TCP 3-way handshake and closing a TCP connection using a client-server architecture.C++ Programming

Objective:

Demonstrate TCP 3-way handshake and closing a TCP connection using a client-server architecture.

Requirements:

  1. Create a C based client-server architecture using sockets
  2. The server should run on cse01.cse.unt.edu machine and the client should run on cse02.cse.unt.edu machine
  3. The client should be able to communicate with the server using TCP segments
  4. The client should be able to demonstrate a 3-way TCP handshake with the server
  5. The client should be able to demonstrate closing a TCP connection.

Procedure:

  1. Create a C-based server that can runs on cse01.cse.unt.edu and accepts single client’s request on using sockets
  2. Create a C-based client that runs on cse02.cse.unt.edu and connects to the server
  3. On the client side, create a TCP segment as shown in Figure Create a C structure with the following fields
    1. 16-bit source and destination port [Type: unsigned short int]
    2. 32-bit sequence number [Type: unsigned int]
    3. 32-bit acknowledgement number [Type: unsigned int]
  1. 4-bit data offset or header length (in multiples of 32-bit)
  2. 6-bit reserved section
  3. 6-bit flags [Type: unsigned short int for combined fields of d, e, and f]
  4. 16-bit receive window for flow control [Type: unsigned short int, set to zero]
  5. 16-bit checksum [Type: unsigned short int, computed after the header and data is populated]
  6. 16-bit urgent data pointer [Type: unsigned short int, set to zero]
  7. 32-bit Options [Type: unsigned int, set to zero]
  1. The variable length payload or the data field is assumed it to be of 0 bytes, as we are going to demonstrate opening and closing a TCP connection
  2. Find the source port, destination port, and header length and populate the corresponding fields of all the client and server TCP segments created below
  3. Demonstrate opening of a TCP connection by following the below steps. Refer to Figure
    1. Create a connection request TCP segment as follows
      1. Assign an initial client sequence number with a zero acknowledgement number
      2. Set the SYN bit to 1
  • Compute the 16-bit checksum of the entire TCP segment and populate the checksum field
  1. The server responds to the request by creating a connection granted TCP segment. Create a connection granted response as follows
    1. Assign an initial server sequence number with an acknowledgement number equal to initial client sequence number + 1
    2. Set the SYN bit and ACK bit to 1
  • Compute the 16-bit checksum of the entire TCP segment and populate the checksum field
  1. The client responds back with an acknowledgement TCP segment. Create an acknowledgement TCP segment as follows
    1. Assign a sequence number as initial client sequence number + 1 with an acknowledgement number equal to initial server sequence number + 1
    2. Set the ACK bit to 1
  • Compute the 16-bit checksum of the entire TCP segment and populate the checksum field
  1. Demonstrate closing of a TCP connection by following the below steps. Refer to Figure
    1. Create a close request TCP segment as follows
      1. Assign an initial client sequence number with a zero acknowledgement number

 

  1. Set the FIN bit to 1
  • Compute the 16-bit checksum of the entire TCP segment and populate the checksum field
  1. The server responds back with an acknowledgment TCP segment. Create an acknowledgement TCP segment as follows
    1. Assign a initial server sequence number with an acknowledgement number equal to initial client sequence number + 1
    2. Set the ACK bit to 1
  • Compute the 16-bit checksum of the entire TCP segment and populate the checksum field
  1. The server again sends another close acknowledgement TCP segment. Create the TCP segment as follows
    1. Assign an initial server sequence number with an acknowledgement number equal to initial client sequence number + 1
    2. Set the FIN bit to 1
  • Compute the 16-bit checksum of the entire TCP segment and populate the checksum field
  1. The client responds back with an acknowledgement TCP segment. Create an acknowledgement TCP segment as follows
    1. Assign a sequence number as initial client sequence number + 1 with an acknowledgement number equal to initial server sequence number + 1
    2. Set the ACK bit to 1
  • Compute the 16-bit checksum of the entire TCP segment and populate the checksum field
  1. Assume client and server has no timeout constraints
  2. Write to a file (server.out and client.out) and print to the console the TCP segments transmitted and received (on both server side and client side).
  3. An example code (cksum.c) to compute the checksum is given on

Attachments:

Instructions Files

C++ Programming Experts

expert
Dinh Hong P.
C++ Programming

20 Answers

expert
Eric Bell
C++ Programming

88 Answers

View More Experts
Disclaimer

The ready solutions purchased from Library are already used solutions. Please do not submit them directly as it may lead to plagiarism. Once paid, the solution file download link will be sent to your provided email. Please either use them for learning purpose or re-write them in your own language. In case if you haven't get the email, do let us know via chat support.

Get Free Quote!

254 Experts Online