prog1 - CSS 432 Program 1: Basic TCP Communication...

Info iconThis preview shows pages 1–3. Sign up to view the full content.

View Full Document Right Arrow Icon
CSS 432 Program 1: Basic TCP Communication Professor: Munehiro Fukuda Due date: See the syllabus 1. Purpose This assignment exercises basic TCP communication and evaluates its performance over 1Gbps networks. You are to observe how RTT (round trip time) grows as increasing the size of data to send over 1Gbps point- to-point communication. 2. Client-Server Model In all your programming assignments through to the final project, your program will use the client-server model where a client process establishes a connection to a server, sends data or requests, and close the connection while the server sends back responses or acknowledgments to the client. 3. TCP Communication HW1 focuses on basic TCP communication between a client and a server process. To establish such communication, those processes should perform the following sequence of operations: Client 1. Use argv[0] as the C string that stores a server IP name. 2. Retrieve a hostent structure corresponding to this IP name by calling gethostname( ) . struct hostent* host = gethostbyname( argv[1] ); 3. Declare a sockaddr_in structure, zero-initialize it by calling bzero , and set its data members as follows: int port = YOUR_ID; // the last 5 digits of your student id sockaddr_in sendSockAddr; bzero( (char*)&sendSockAddr, sizeof( sendSockAddr ) ); sendSockAddr.sin_family = AF_INET; // Address Family Internet sendSockAddr.sin_addr.s_addr = inet_addr( inet_ntoa( *(struct in_addr*)*host->h_addr_list ) ); sendSockAddr.sin_port = htons( port ); 4. Open a stream-oriented socket with the Internet address family. int clientSd = socket( AF_INET, SOCK_STREAM, 0 ); 5. Set the NODELAY option. (Note this option is necessary to observe the TCP's segmentation behavior clearly in HW1. Don't use this option in the other assignments.) const int on = 1;
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
setsockopt( clientSd, IPPROTO_TCP, TCP_NODELAY, (char *)&on, sizeof( int ) ); 6. Connect this socket to the server by calling connect as passing the following arguments: the socket descriptor, the sockaddr_in structure defined above, and its data size (obtained from the sizeof function). connect( clientSd, ( sockaddr* )&sendSockAddr, sizeof( sendSockAddr ) );
Background image of page 2
Image of page 3
This is the end of the preview. Sign up to access the rest of the document.

This document was uploaded on 12/20/2009.

Page1 / 5

prog1 - CSS 432 Program 1: Basic TCP Communication...

This preview shows document pages 1 - 3. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online