Docsity

Sockets Programming Assignment 2 - Computer Networks I | CS 3251, Assignments of Computer Systems Networking and Telecommunications

Toggle sidebar
bg1
CS 3251 - Computer Networks I
Sockets Programming Assignment 2
Assigned: June 12, 2006
Due: July 12, 2006
Expand upon project 1 to write an Internet traffic program used to test out network
connections. You should do this assignment both for TCP and for UDP. This description
will only be for TCP, the same description applies to UDP except fork should not be used
for UDP). The client sends TCP datagrams to a server that receives them and generates
statistics about the received datagrams. The client program tcpgen should be run with the
following command line:
Command Line: tcp_gen -D -i <ia> -s <pk_m> -v <pk_v> -p <d_port> -a <addr>
D Run in Debug Mode
<ia> Interarrival Time (default= 0.03 sec)
<pk_m> Packet Size Mean (default=1024, MAX=1460)
<pk_v> Packet Size Variance (default=700)
<d_port> Destination Port Number
<addr> Dest IP Address
Example usage: ./tcp_gen -D -p 5000 -a 127.0.0.1
The server tcpsink should be run with the following command line:
Command Line: tcp_sink -D -p <port>
D Run in Debug Mode
p Port number to listen
Example usage: ./tcp_sink -D -p 5000 &
When run in debug mode, the client should print out the datagram size and the time
between transmission of the datagrams.
When the server is run in debug mode, it too should print out that same information on
the received segments.
The client program should run generating internet traffic until the user types control c
(use signals). The control c should cause the client to send a special combination of data
to the server and then the client should print out some statistics on the totals of what was
sent, and exit. An example special data value may be for example hexadecimal zz. If you
make it so that all data transmitted is set to something other than hex aa, then accidental
hex aa should not occur. The statistics should include:
IA Time requested
Pk Size Mean requested
Pk Size Variance requested
Number of datagrams actually sent
Total Time generator was run
Total number of bytes sent
1
pf3
pf4
pf5

Partial preview of the text

Download Sockets Programming Assignment 2 - Computer Networks I | CS 3251 and more Assignments Computer Systems Networking and Telecommunications in PDF only on Docsity!

CS 3251 - Computer Networks I

Sockets Programming Assignment 2

Assigned: June 12, 2006

Due: July 12, 2006

Expand upon project 1 to write an Internet traffic program used to test out network

connections. You should do this assignment both for TCP and for UDP. This description

will only be for TCP, the same description applies to UDP except fork should not be used

for UDP). The client sends TCP datagrams to a server that receives them and generates

statistics about the received datagrams. The client program tcpgen should be run with the

following command line:

Command Line: tcp_gen -D -i -s <pk_m> -v <pk_v> -p <d_port> -a D Run in Debug Mode Interarrival Time (default= 0.03 sec) <pk_m> Packet Size Mean (default=1024, MAX=1460) <pk_v> Packet Size Variance (default=700) <d_port> Destination Port Number Dest IP Address Example usage: ./tcp_gen -D -p 5000 -a 127.0.0.

The server tcpsink should be run with the following command line:

Command Line: tcp_sink -D -p D Run in Debug Mode p Port number to listen Example usage: ./tcp_sink -D -p 5000 &

When run in debug mode, the client should print out the datagram size and the time

between transmission of the datagrams.

When the server is run in debug mode, it too should print out that same information on

the received segments.

The client program should run generating internet traffic until the user types control c

(use signals). The control c should cause the client to send a special combination of data

to the server and then the client should print out some statistics on the totals of what was

sent, and exit. An example special data value may be for example hexadecimal zz. If you

make it so that all data transmitted is set to something other than hex aa, then accidental

hex aa should not occur. The statistics should include:

IA Time requested Pk Size Mean requested Pk Size Variance requested Number of datagrams actually sent Total Time generator was run Total number of bytes sent

Total Mbits per second sent Resulting Average IA Time Resulting Average transmitted datagram Size

The server should continue to run until it receives the special characters in the data. Upon

receipt of those special characters, the server should printout some statistics on the

received data, and then terminate the connection with the client and reset itself to be

ready to accept another client connection. The statistics that should be printed to the

screen:

Number of datagrams received Total Time sink was run Total number of bytes received Total Mbits per second received Resulting Average IA Time received Resulting Average received datagram Size

The server does need to be able to accept multiple simultaneous connections from

multiple clients (use fork).

Notes:

You are implementing two complete, separate versions. A client and server using TCP

and another client and server using UDP. Your final submission should include 4 separate

executables. For simplicity in grading, let's call them tcpgen, tcpsink, udpgen and

udpsink

Your TCP and UDP versions will share much of the same code. Your programs are to be

written in standard C (not C++) and should run on the GTL Linux systems. Make sure

that you do sufficient error handling such that a user can't crash your server. For instance,

what will you do if a user provides invalid input? You must test your program and

convince me it works! Provide me with a sample output in a file (you can use cut-and-

paste) that shows all of your functions working.

Turn in Instructions:

You will turn in your well-documented source code, a README file and sample output

file called Sample.txt. The README file must contain:

Your Name and email address

Class number, date and assignment title

Names and descriptions of all files submitted

Detailed instructions for compiling and running your client and server programs

including a Makefile. Comments in your program will be graded! Document!!!

By 11:55 PM on the due date, you must submit your program files online.

Use the UNIX "tar" command to create an archive of your complete set of files, naming

your .tar archive file "p1_firstname_lastname.tar": (e.g. tar cvf p1_george_burdell.tar

Email your submission as an attachment to the account [email protected]. Use the

subject line "[cs3251] Program 2".

#endif

dist_gen.c

#include "dist_gen.h" #include <stdio.h> double dist_gen (int type, double mean, double variance) { double r1, r2, gaussian, std_dev, expo; switch (type) { case NORMAL: std_dev = sqrt(variance); r1 = rand()/(RAND_MAX+1.0); r2 = rand()/(RAND_MAX+1.0); gaussian = sqrt(-2log(r1))cos(2Pir2); return (mean+gaussianstd_dev); case EXPONENTIAL: r1 = rand()/(RAND_MAX+1.0); expo = -meanlog(r1); return expo; default: printf ("This distribution type is not supported\n"); exit(1); } }

dist_gen.h

#ifndef _dist_gen_h

#define _dist_gen_h

#include <stdlib.h>

#include <math.h>

#define NORMAL 1

#define EXPONENTIAL 2

#define Pi 3.

/* Prototype Declaration */

double dist_gen(int, double, double);

#endif /* _dist_gen_h */