[solved]-Attached Example Cksumc Like Please Write Paragraph Codes Compile Information Needed Need Q39060735
I have attached what the example cksum.c should like, pleasewrite a paragraph of what your codes do and compile.
This should be all the information needed, but should you needmore info. please reach out.
********* Please be sure your code can run on LINUX ENVIRONMENT***************
Instructions: Compile the programs and make sure it’s working. ii) Comment your code. Create a text file that describes the working and usage of the code. iv) Please create a zip archive of your assignment folder (text file, code, and header files) and upload the zip file. Not following the above instructions could result up to 20% deduction from your lab assignment score. vi) Late submissions will not be accepted. 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 Linux environment machine and the client should run on Linux environment 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 1. Create a C structure with the following fields a. 16-bit source and destination port [Type: unsigned short int] b. 32-bit sequence number (Type: unsigned int] C. 32-bit acknowledgement number (Type: unsigned int] d. 4-bit data offset or header length in multiples of 32-bit) e. 6-bit reserved section f. 6-bit flags [Type: unsigned short int for combined fields of d, e, and f] g. 16-bit receive window for flow control [Type: unsigned short int, set to zero] h. 16-bit checksum (Type: unsigned short int, computed after the header and data is populated] i. 16-bit urgent data pointer [Type: unsigned short int, set to zero] 1. 32-bit Options Type: unsigned int, set to zero] 4 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 5. Find the source port, destination port, and header length and populate the corresponding fields of all the client and server TCP segments created below 6 Demonstrate opening of a TCP connection by following the below steps. Refer to Figure 2. a. Create a connection request TCP segment as follows | Assign an initial client sequence number with a zero acknowledgement number i Set the SYN bit to 1 i Compute the 16-bit checksum of the entire TCP segment and populate the checksum field b. The server responds to the request by creating a connection granted TCP segment. Create a connection granted response as follows i Assian an initial server sequence number with an acknowledgement number equal to initial client sequence number + 1 i Set the SYN bit and ACK bit to 1 i Compute the 16-bit checksum of the entire TCP segment and populate the checksum field C. The client responds back with an acknowledgement TCP segment. Create an acknowledgement TCP segment as follows i Assign a sequence number as initial client sequence number + 1 with an acknowledgement number equal to initial server sequence number + 1 i Set the ACK bit to 1 i Compute the 16-bit checksum of the entire TCP segment and populate the checksum field 7. Demonstrate closing of a TCP connection by following the below steps. Refer to Figure 3. a. Create a close request TCP segment as follows i Assign an initial client sequence number with a zero acknowledgement number i Set the FIN bit to 1 i Compute the 16-bit checksum of the entire TCP segment and populate the checksum field b. The server responds back with an acknowledgment TCP segment. Create an acknowledgement TCP segment as follows i Assign a initial server sequence number with an acknowledgement number equal to initial client sequence number + 1 i Set the ACK bit to 1 i. Compute the 16-bit checksum of the entire TCP segment and populate the checksum field C. 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 i Set the FIN bit to 1 i Compute the 16-bit checksum of the entire TCP segment and populate the checksum field d. 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 i Set the ACK bit to 1 i Compute the 16-bit checksum of the entire TCP segment and populate the checksum field 8 Assume client and server has no timeout constraints 9. 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). 10. An example code (cksum.c) to compute the checksum is given on Blackboard. Deliverables: 1. Client and Server commented C code 2. A text file that describes how to compile, execute, and test the code. Also it should contain information on the structure and working of the code (32 Bits)- Source Port Destination Port Sequence Number Acknowledgment Number Window Checksum Urgent Pointer Options Padding Data Offset Reserved 22 Data Figure 1. TCP Segment Structure [Source: http://cse1.net/recaps/11-topip.html] un state server state LISTEN choose and TOPSYNC SINCENT SibtSeg> magacing SYNSNRCO ESTAS ht. See AD1: A + SYNO) and Axor SHACK this womery contain Abit, Achay+1 client o ver da ACTIV Figure 2. TCP 3-Way Handshake Source: Lecture notes) server state ESTAB dent state ESTAB client Socket.closet) FIN_WAIT_1 can no longer send butcan receivedats FINbit-1, seq=k CLOSE_WAIT Akht=1; ACKnum=x+1 can stil FIN_WAIT 2 wait for server close send dats LAST_ACK FINbit-1, seq=y TIMED_WAIT can no longer send data ACKbit= 1; ACKnum=y+1 timed wat for 2 max segmentatie CLOSED CLOSED Figure 3. Closing a TCP connection [Source: Lecture notes] #include <stdio.h> #include <string.h> struct tcp_hdr { unsigned short int src; unsigned short int des; unsigned int seq; unsigned int ack; unsigned short int hdr_flags; unsigned short int rec; unsigned short int cksum; unsigned short int ptr; unsigned int opt; int main(void) struct tcp_hdr tcp_seg: unsigned short int cksum_arr [12]; unsigned int i, sum=0, cksum; tcp_seg.src = 21334; tcp_seg.des = 2200; tcp_seg.seq = 1; tcp_seg.ack = 2; top_seg.hdr_flags = 0x2333; tcp_seg.rec = 0; tcp_seg.cksum = 0; tcp_seg.ptr = 0; tcp_seg.opt = 0; memcpy(ck sum_arr, stcp_seg, 24); //Copying 24 bytes printf(“0x804Xn”, tcp_seg.src); // Printing all values printf(“0x804Xn”, top_seg.des); printf (“0x$08Xn”, tcp_seg. seq); printf(“Ox:08Xn”, tcp_seg.ack); printf(“0x$04Xn”, tcp_seg.hdr_flags); printf(“0x804Xn”, tcp_seg.rec); printf(“0x804Xn”, tcp_seg.cksun); printf (“0x804Xn”, tcp_seg.ptr); printf(“0x$08Xn”, tcp_seg. opt); // Compute sum for (i=0; i<12;i++) sum = sum + cksum_arr[i]; // Fold once cksum = sum >> 16; sum = sum & 0x0000FFFF; sum = cks um + sum; // Fold once more cksum = sum >> 16; sum = sum & 0x0000FFFF; cksum = cksum + sum; /* XOR the sum for checksum */ printf(“Checksum Value: 0x$04Xn”, (0xFFFF^cksum)); Show transcribed image text Instructions: Compile the programs and make sure it’s working. ii) Comment your code. Create a text file that describes the working and usage of the code. iv) Please create a zip archive of your assignment folder (text file, code, and header files) and upload the zip file. Not following the above instructions could result up to 20% deduction from your lab assignment score. vi) Late submissions will not be accepted. 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 Linux environment machine and the client should run on Linux environment 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 1. Create a C structure with the following fields a. 16-bit source and destination port [Type: unsigned short int] b. 32-bit sequence number (Type: unsigned int] C. 32-bit acknowledgement number (Type: unsigned int]
d. 4-bit data offset or header length in multiples of 32-bit) e. 6-bit reserved section f. 6-bit flags [Type: unsigned short int for combined fields of d, e, and f] g. 16-bit receive window for flow control [Type: unsigned short int, set to zero] h. 16-bit checksum (Type: unsigned short int, computed after the header and data is populated] i. 16-bit urgent data pointer [Type: unsigned short int, set to zero] 1. 32-bit Options Type: unsigned int, set to zero] 4 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 5. Find the source port, destination port, and header length and populate the corresponding fields of all the client and server TCP segments created below 6 Demonstrate opening of a TCP connection by following the below steps. Refer to Figure 2. a. Create a connection request TCP segment as follows | Assign an initial client sequence number with a zero acknowledgement number i Set the SYN bit to 1 i Compute the 16-bit checksum of the entire TCP segment and populate the checksum field b. The server responds to the request by creating a connection granted TCP segment. Create a connection granted response as follows i Assian an initial server sequence number with an acknowledgement number equal to initial client sequence number + 1 i Set the SYN bit and ACK bit to 1 i Compute the 16-bit checksum of the entire TCP segment and populate the checksum field C. The client responds back with an acknowledgement TCP segment. Create an acknowledgement TCP segment as follows i Assign a sequence number as initial client sequence number + 1 with an acknowledgement number equal to initial server sequence number + 1 i Set the ACK bit to 1 i Compute the 16-bit checksum of the entire TCP segment and populate the checksum field 7. Demonstrate closing of a TCP connection by following the below steps. Refer to Figure 3. a. Create a close request TCP segment as follows i Assign an initial client sequence number with a zero acknowledgement number
i Set the FIN bit to 1 i Compute the 16-bit checksum of the entire TCP segment and populate the checksum field b. The server responds back with an acknowledgment TCP segment. Create an acknowledgement TCP segment as follows i Assign a initial server sequence number with an acknowledgement number equal to initial client sequence number + 1 i Set the ACK bit to 1 i. Compute the 16-bit checksum of the entire TCP segment and populate the checksum field C. 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 i Set the FIN bit to 1 i Compute the 16-bit checksum of the entire TCP segment and populate the checksum field d. 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 i Set the ACK bit to 1 i Compute the 16-bit checksum of the entire TCP segment and populate the checksum field 8 Assume client and server has no timeout constraints 9. 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). 10. An example code (cksum.c) to compute the checksum is given on Blackboard. Deliverables: 1. Client and Server commented C code 2. A text file that describes how to compile, execute, and test the code. Also it should contain information on the structure and working of the code
(32 Bits)- Source Port Destination Port Sequence Number Acknowledgment Number Window Checksum Urgent Pointer Options Padding Data Offset Reserved 22 Data Figure 1. TCP Segment Structure [Source: http://cse1.net/recaps/11-topip.html] un state server state LISTEN choose and TOPSYNC SINCENT SibtSeg> magacing SYNSNRCO ESTAS ht. See AD1: A + SYNO) and Axor SHACK this womery contain Abit, Achay+1 client o ver da ACTIV Figure 2. TCP 3-Way Handshake Source: Lecture notes)
server state ESTAB dent state ESTAB client Socket.closet) FIN_WAIT_1 can no longer send butcan receivedats FINbit-1, seq=k CLOSE_WAIT Akht=1; ACKnum=x+1 can stil FIN_WAIT 2 wait for server close send dats LAST_ACK FINbit-1, seq=y TIMED_WAIT can no longer send data ACKbit= 1; ACKnum=y+1 timed wat for 2 max segmentatie CLOSED CLOSED Figure 3. Closing a TCP connection [Source: Lecture notes]
#include #include struct tcp_hdr { unsigned short int src; unsigned short int des; unsigned int seq; unsigned int ack; unsigned short int hdr_flags; unsigned short int rec; unsigned short int cksum; unsigned short int ptr; unsigned int opt; int main(void) struct tcp_hdr tcp_seg: unsigned short int cksum_arr [12]; unsigned int i, sum=0, cksum; tcp_seg.src = 21334; tcp_seg.des = 2200; tcp_seg.seq = 1; tcp_seg.ack = 2; top_seg.hdr_flags = 0x2333; tcp_seg.rec = 0; tcp_seg.cksum = 0; tcp_seg.ptr = 0; tcp_seg.opt = 0; memcpy(ck sum_arr, stcp_seg, 24); //Copying 24 bytes printf(“0x804Xn”, tcp_seg.src); // Printing all values printf(“0x804Xn”, top_seg.des); printf (“0x$08Xn”, tcp_seg. seq); printf(“Ox:08Xn”, tcp_seg.ack); printf(“0x$04Xn”, tcp_seg.hdr_flags); printf(“0x804Xn”, tcp_seg.rec); printf(“0x804Xn”, tcp_seg.cksun); printf (“0x804Xn”, tcp_seg.ptr); printf(“0x$08Xn”, tcp_seg. opt); // Compute sum for (i=0; i> 16; sum = sum & 0x0000FFFF; sum = cks um + sum; // Fold once more cksum = sum >> 16; sum = sum & 0x0000FFFF; cksum = cksum + sum; /* XOR the sum for checksum */ printf(“Checksum Value: 0x$04Xn”, (0xFFFF^cksum));
Expert Answer
Answer to I have attached what the example cksum.c should like, please write a paragraph of what your codes do and compile. This s… . . .
OR