CprE 489 Assignment # 1

curvyrawrΔίκτυα και Επικοινωνίες

23 Οκτ 2013 (πριν από 3 χρόνια και 10 μήνες)

117 εμφανίσεις

Cory Farver

February 11, 2003

Page
1

of
8

CprE 489
Assignment # 1


1.)

Seven layers of the OSI reference model

1. The Physical Layer.

X.25
-

The CCITT Recommendation defining interfaces to packet
-
switched networks,. as used by many
public and private networks.

FDDI
-

Fiber Distributed Data Interfa
ce
is a

LAN standard defined by ANSI 3T9.5, specifying a 100
-
Mbps token
-
passing network using fiber
-
optic cable, with transmission distances of up to 2km. FDDI uses
dual
-
ring architecture to minimize redundancy.


2. The Data Link Layer

MAC
-

The Medium Acc
ess Control protocol

is used to provide the data link layer of the Ethernet LAN
system. The MAC protocol encapsulates a SDU (payload data) by adding a 14 byte header (Protocol
Control Information (PCI)) before the data and appending a 4
-
byte (32
-
bit) Cycli
c Redundancy Check
(CRC) after the data. The entire frame is preceded by a small idle period (the minimum inter
-
frame gap, 9.6
microsecond (µS)) and a 8 byte preamble.


ARP


The Address Resolution Protocol

is a protocol used by the Internet Protocol (IP)
network layer
protocol to map IP network addresses to the hardware addresses used by a data link protocol. The protocol
operates below the network layer as a part of the OSI link layer, and is used when IP is used over Ethernet.


3. The Network Layer

IP
-

The Internet Protocol

is a protocol which uses datagrams to communicate over a packet
-
switched
network.


ICMP
-

The Internet Control Message Protocol

is classic example of a client server application. The
ICMP server executes on all IP end system computers
and all IP intermediate systems (i.e routers). The
protocol is used to report problems with delivery of IP datagrams within an IP network. It can be sued to
show when a particular End System (ES) is not responding, when an IP network is not reachable, when

a
node is overloaded, when an error occurs in the IP header information, etc. The protocol is also frequently
used by Internet managers to verify correct operations of End Systems (ES) and to check that routers are
correctly routing packets to the specifi
ed destination address
.


4. The Transport Layer

UDP
-
The User Datagram Protocol

is a transport layer protocol defined by the US Department of Defence
(DoD) for use with the IP network layer protocol. It provides a best
-
effort datagram service to an End
Syst
em.


TCP
-

The Transmission Control Protocol
is a connection
-
oriented reliable protocol. It provides a
reliable transport service between pairs of processes executing on End Systems (ES) using the network
layer service provided by the IP protocol.


5. The
Session Layer

ASN.1
-

Abstract Syntax Notation 1

is heavily used by OSI and OSI
-
inspired protocols, including X.500,
H.323, SNMP and LDAP, defines a standard grammer used to write textual descriptions of messages. One
of several encoding rules are then use
d to construct the actual binary messages. ISO Standard X.680
defines the ASN.1 grammer. Basic Encoding Rules (BER), Canonical Encoding Rules (CER), and
Distinguished Encoding Rules (DER), are specified in ISO Standard X.690. Packed Encoding Rules (PER)
ar
e specified in ISO Standard X.691.


Netbios

-

A network communication system operating on MS/DOS PC networks.


Cory Farver

February 11, 2003

Page
2

of
8

6. The Presentation Layer

ASCII
-

Request/Reply Protocols

include FTP, HTTP, SMTP, POP, IMAP and others. They all run over
reliable stream connec
tions (TCP), and are designed to be usable by either a program or a human (usually
for testing purposes). They all feature the following common attributes:

Asymmetric client/server, ASCII
Messages, and Numeric reply codes.


EBCDIC
-

Extended Binary Coded D
ecimal Interchange Code

is IBM's 8
-
bit extension of the 4
-
bit
Binary Coded Decimal encoding of digits.


7. The Application Layer

SMTP
-

Simple Mail Transfer Protocol is a protocol

from the Internet Protocol Suite that provides
electronic mail transfer acros
s a network.


TELNET
-

TELecommunicati ons NETwork is

a protocol from the Internet Protocol suite that provides a
Virtual Terminal interface for communicating devices.



2.)


A has a 30
-
megabyte file in packets of 1 megabyte each (30 packets)

B has a 30
-
meg
abyte file in packets of 10 megabyte each (3 packets)

30
-
byte acknowledgements

a.)

Assuming that A Would send it’s fill first to B. Then when A was finished B would then send it’s file to A
.

For a

1 megabyte packet is 1M/10Mpsec = 0.1 sec

For a

10 megaby
te packet is 10M/10Mpsec = 1.0 sec

For a

30
-
byte acknowledgement is 30/10Mpsec = 0.000003 sec


Time = 30(0.1 + 0.000003 + 2*.002) + 3(1.0 + 0.000003 + 2*.002) =
6.132099 sec


b.)

For a

1 megabyte packet is 1M/10,000Mpsec = 0.0001 sec

For a

10 megabyte pac
ket is 10M/10,000Mpsec = 0.001 sec

For a

30
-
byte acknowledgement is 30/10,000Mpsec = 3x10
-
9

sec


Time = 30(.0001+ 3x10
-
9

+ 2*.01) + 3(.001 + 3x10
-
9

+ 2*.01) =
0.666000099 sec

c.)

Now A and B can send files at the same time.

For a

1 megabyte packet is 1M
/10Mpsec = 0.1 sec

For a

10 megabyte packet is 10M/10Mpsec = 1.0 sec

For a

30
-
byte acknowledgement is 30/10Mpsec = 0.000003 sec


Time = original time (with half
-
duplex)


time saved (with full
-
duplex)

Time = 6.132099


3(0.1 + .002) =
5.826099 sec






Cory Farver

February 11, 2003

Page
3

of
8

3.
)

a.)
Assuming that this picture is monochromatic or grayscale
not

color (RGB.) Then …

Bits for 32 intensity values is 5 because 2
5

= 32

Source Rate = (480*500) * 5 * 30 =
36 M bits per sec


b.)


35 dB = 3162.27766

4.6 M*LOG
2

(1 + 3162.27766) = 53485140.
61

53.5 M bits per sec

Yes it can carry the TV signal.


4.)

/*mrtt.c by Cory Farver CprE 489 Assignment # 1*/

/* A simple UDP client which measures round trip delay */

/* CprE 489: Computer Networking and Data Communications Spring 2003

Due: February 11, 2
003

This program as been tested and has received some form of return signal on the folowing for the
folowing machine names and IP numbers.






129.186.15.167


129.186.5.3


129.186.23.45


129.186.23.46


129.186.23.47




129.186.1.149


129.186.1.121


129
.186.205.246


129.186.3.78


129.186.78.13


129.186.1.21


129.186.3.4


www.lib.iastate.edu

vulcan.ee.iastate.edu

www.ee.iastate.edu

vulcan.ee.iastate.edu

www.iastate.edu

clue.ee.iastate.edu

pluto.ee.iastate.edu

www.cs.iastate.edu

webboy.cs.iastate.e
du

www.adp.iastate.edu

rs78013.adp.iastate.edu

www.public.iastate.edu

popeye.cs.iastate.edu



It has been successfully compiled and run on both Unix and Sun systems.



To compile this program you use gcc or cc as follows:




gcc
-
o mrtt mrtt.c


or


cc
file.c
-
lsocket
-
lnsl
-
o file.out



To run this program you only need to provide a machine name or IP number as follow:




./mrtt www.ee.iastate.edu


or


./ 129.186.5.3

*/


Cory Farver

February 11, 2003

Page
4

of
8




#include <stdio.h>

#include <string.h>

#include <sys/time.h>

#include <ne
tdb.h>

#include <sys/types.h>

#include <sys/socket.h>

#include <netinet/in.h>

#include <signal.h>


#define SERVER_UDP_PORT 7 /*7, 21, 22, 23, 25, or 80*/

#define MAXLEN

4096

/* maximum data length */

#define DEFLEN

64

/* default length */


long delay(str
uct timeval t1, struct timeval t2);

long pingMachine(char *host, int port, int printHost);

void toOut();


int main(int argc, char **argv)

{


int

data_size = DEFLEN, port = SERVER_UDP_PORT;


int

k, i, j, sd,server_len;


int

sendCode;


int

ppp;


int p[2];


i
nt ret[6];


long

rtt[5],rttMax,rttMin,rttAve, rttTotal;


char

*pname, *host, rbuf[MAXLEN] , sbuf[MAXLEN];


struct


hostent


*hp;


struct

sockaddr_in server, client;


struct

timeval start, end;




//scanf("%s", ppp);


//ppp = argv[2];


//printf("
-
Checkpoi
nt 1
-
\
n");


//fprintf (stderr, "%s,%s,%s,%s
\
n ppp = %s
\
n port = %d
\
n", argv[0], argv[1], argv[2],
argv[3], ppp, port);


//port = (int)*ppp;



//fprintf (stderr, "%s,%s,%s,%s
\
n ppp = %d
\
n port = %d
\
n", argv[0], argv[1], argv[2],
argv[3], ppp, port);



/*C
heck and grabs machine name or IP address number from input */


pname = argv[0];


argc
--
;


argv++;


if (argc > 0 && (strcmp(*argv, "
-
s") == 0))


{



if (
--
argc > 0 && (data_size = atoi(*++argv)))



{




argc
--
;




argv++;



}



else



{




fprintf (stderr,

"Usage: %s [
-
s datasize] host [port]
\
n", pname);




exit(1);



}


}



//fprintf (stderr, "Usage: %s [
-
s datasize] host [port]
\
n", pname);


//printf("
-
Checkpoint 2
-
\
n");



if (argc > 0)


{



host = *argv;



if (
--
argc > 0) port = atoi(*++argv);


}

Cory Farver

February 11, 2003

Page
5

of
8


else


{



fprintf (stderr, "Usage: %s [
-
s data_size] host [port]
\
n", pname);



exit(1);


}



//printf("
-
Checkpoint 3
-
\
n");


//printf(" host
-
%s
-
\
n", host);



//int p[2];


//int ret;









/*This program has the ability to check many different


ports but only

checks port 7 this is because I was


told by the TA that that was the only port that I


really need to check, also because there was not


a machine that I found that I could get a response


from that I could not get to on port 7. In other


words i
f for every machine that I pinged and got


a repsonce I could do it on port 7. */




//pipe(p);

/*

ret[0] = fork();



if (ret[0] > 0)


{



//write(p[1], msg, MSGSIZE);



wait(0);



port = 80;




//printf("Checking Port
-
%d
-
\
n", port);


}


else


{



re
t[1] = fork();




if (ret[1] > 0)



{




//write(p[1], msg, MSGSIZE);




wait(0);




port = 25;





//printf("Checking Port
-
%d
-
\
n", port);



}



else



{




ret[2] = fork()//printf("Checking Port
-
%d
-
\
n",;




if (ret[2] > 0)




{





//write(p[1], msg, MS
GSIZE);





wait(0);





port = 23;





}




else




{





ret[3] = fork();





if (ret[3] > 0)





{






//write(p[1], msg, MSGSIZE);






wait(0);






port = 22;







//printf("Checking Port
-
%d
-
\
n", port);





}





else





{






ret[4] = fork();






if (ret[4] > 0)






{

Cory Farver

February 11, 2003

Page
6

of
8







//write(p[1], msg, MSGSIZE);







wait(0);







port = 21;








//printf("Checking Port
-
%d
-
\
n", port);






}






else






{







port = 7;






}






}





}



}


}


printf("Checking Port %d
\
n", port);





*/



si
gnal(SIGALRM,toOut);

/*sets time out signal*/


alarm(10);


/*starts time out alarm timer for 10 sec*/



rtt[0] = pingMachine(host,port,1);


rttMax=rtt[0];


rttMin=rtt[0];


rttTotal=rtt[0];



/*loop 5 times for rttMax, rttMin, rttAve times*/


for(k=1;k<5;
k++)


{



rtt[k]=pingMachine(host, port,0);



rttTotal +=rtt[k];



if(rtt[k] > rttMax) rttMax =rtt[k];



if(rtt[k] < rttMin) rttMin =rtt[k];


}



//printf ("Round
-
trip time on port %d
\
n", port);



printf ("
\
n
\
tRound
-
Trip Times in Microseconds
\
n");





pr
intf("
\
t
\
t Max = %ld
\
n
\
t
\
t Min = %ld
\
n
\
t
\
t Ave = %ld
\
n", rttMax, rttMin,
rttTotal/5);


printf("
\
t
---------------------------------
\
n
\
n");



return(0);


}


long pingMachine(char *host, int port, int printHost)

{



int

data_size = DEFLEN;


int

i, j,

sd,server_len;


int

sendCode, connectCode;


long

returntime;


char

rbuf[MAXLEN] , sbuf[MAXLEN];


struct


hostent


*hp;


struct

sockaddr_in server, client;


struct

timeval start, end;



/* Create a datagram socket */


if ((sd = socket(AF_INET, SOCK_DGRAM
, 0)) ==
-
1)


{



fprintf(stderr, "Can't create a socket
\
n");



exit(1);


}


//printf("
-
Checkpoint 4
-
\
n");

/* Store server's information */

Cory Farver

February 11, 2003

Page
7

of
8


bzero((char *)&server, sizeof(server));


server.sin_family = AF_INET;


server.sin_port = htons(port);


if ((hp = ge
thostbyname(host)) == NULL)


{




fprintf (stderr,"Can't get server's IP address
\
n");



exit(1);


}


bcopy ( hp
-
>h_addr, (char *)&server.sin_addr, hp
-
>h_length);



if(printHost > 0)


{



printf("
\
t_________________________________");



printf("
\
n
\
tHost Nam
e =
\
t %s
\
n", (char *) hp
-
>h_name);



printf("
\
tHost IP =
\
t %s
\
n", inet_ntoa(server.sin_addr));



//printf("
\
tPort =
\
t %d
\
n", port);



//printHost = 1;


}



//printf("
-
Checkpoint 5
-
\
n");


//printf(" hp
-
%s
-
\
n", hp
-
>h_addr);



/* Bind local addre
ss to the socket */


bzero((char *)&client, sizeof(client));


client.sin_family = AF_INET;


client.sin_port = htons(0);


client.sin_addr.s_addr = htonl(INADDR_ANY);


if (bind(sd, (struct sockaddr *)&client, sizeof(client)) ==
-
1)


{



fprintf(stderr, "Can'
t bind name to socket
\
n");



exit(1);


}


if (data_size > MAXLEN)


{



fprintf(stderr, "Data is too big
\
n");



exit(1);


}


/* data is a, b, c, , z, a, b, */


for (i = 0; i < data_size; i++)


{



j = (i < 26) ? i : i % 26;



sbuf[i] = 'a' + j;


}



gettime
ofday(&start, NULL); /* start delay measure */



//Data is corruptedprintf("
-
Checkpoint 6
-
\
n");


/* transmit data */


server_len = sizeof(server);



//int connect(int sockfd, const struct sockaddr *serv_addr, socklen_t addrlen);


//int sendto(int s, const
void *msg, size_t len, int flags, const struct sockaddr *to,
socklen_t tolen);




if (connect(sd, (struct sockaddr *)&server, server_len) > 0)


{


printf("sendto error
\
n");



return 0;


}


//printf ("ConnectCode = %d
\
n", connectCode);



sendCode = send(sd,

sbuf, data_size, 0);


//sendCode = sendto(sd, sbuf, data_size, 0, (struct sockaddr *)&server, server_len);


if (sendCode ==
-
1)


{



fprintf(stderr, "sendto error
\
n");



exit(1);


}

Cory Farver

February 11, 2003

Page
8

of
8


//printf("
-
sendCode = %d
-
\
n", sendCode);



//printf("
-
Checkpoint 7
-
\
n")
;


/* receive data */


//printf("Data is corrupted
\
n");


if (recvfrom(sd, rbuf, MAXLEN, 0, (struct sockaddr *)&server, &server_len) < 0)


//if (recv(sd, rbuf, MAXLEN, 0) < 0)


{


//

fprintf(stderr, "recvfrom error
\
n");



//exit(1);


}



gettimeofday(&end,
NULL); /* end delay measure */


returntime = delay(start, end);


//printf ("Round
-
trip delay = %ld microseconds on port %d
\
n", returntime, port);



if (strncmp(sbuf, rbuf, data_size) != 0)


{//printf("Data is corrupted
\
n");


}





if( printHost > 0)


{ pri
ntf("
\
tPort =
\
t %d
\
n", port);



if (strncmp(sbuf, rbuf, data_size) != 0)



{




//printf("
\
tData is received but corrupted
\
n");



}




}




//printf("
\
t printHost =
\
t %d
\
n", printHost);



close(sd);


return(returntime);

}




/*

Compute the dela
y between tl and t2 in microseconds*/



long delay (struct timeval t1, struct timeval t2)


{



long d;




//printf("T1 = %ld
\
n", t1);



//printf("T2 = %ld
\
n", t2);




d = (t2.tv_sec
-

t1.tv_sec) * 1000000;



d += ((t2.tv_usec
-

t1.tv_usec));



//d += ((t2.
tv_usec
-

t1.tv_usec + 500) / 1000);



return(d);


}




void toOut()

{

/* to much time with no responce*/



printf("
\
n
\
t
\
t Time Out
\
n");


exit(0); /*exit program*/

}