Advanced Computer

Architectures


TCP/IP & PVM


Written by: Sadi Evren SEKER


Instructor: Esin Onbasioglu



  1. Statement of Purpose

Aim of our project is comparison between the speeds of PVM & TCP/IP protocols.


  1. Design of Project

There will be time functions to get the current time after and before packet transfer operations. So the difference between these times will give us the transfer time. Also we need to calculate the send and receive time to see the complete network time. (This is also called as ping-pong).


  1. Implementation of Project


    1. Implementation on TCP/IP


gettimeofday(&starttv, &starttz);


We got the system time so we have started to measure the operation time.


bzero(&servaddr, sizeof(servaddr));

servaddr.sin_family = AF_INET;

servaddr.sin_port = htons(3800);


Prepare the socket for transmission. (The is the initial preparation phase)


if ( (sockfd = socket(AF_INET, SOCK_STREAM, 0)) < 0){

perror("socket error");

exit(-1);

}//if


Exception handling for socket errors.



if (inet_pton(AF_INET, argv[2], &servaddr.sin_addr) <= 0){

printf("%s is not a valid address\n",argv[2]);

fflush(stdout);

exit(-1);

}//if


if (connect(sockfd, (struct sockaddr *) &servaddr, sizeof(servaddr)) < 0){

perror("Connect error ");

exit(-1);

}//if


After connection is created start transmission.


write(sockfd, "deneme", 256); //Send the name of the file

read(sockfd, l, 256);


When ping-pong is completed and an answer from remote workstation is achieved we can assume the connection is created and packet transfer is done. So we can get the system clock again to calculate communication time.


gettimeofday(&endtv, &endtz);

fark1=getdiff(endtv, starttv);


3.2. PVM implementation


It is easier to program in PVM. Socket creation and error handling is done by PVM automatically so for a programmer coding under PVM is easier.


gettimeofday(&starttv, &starttz);


Again we read the system clock to calculate transfer time.


pvm_initsend(PvmDataDefault);


initialization in pvm is this simple. Pvm_initsend solves all socket problems.


pvm_pkint(&nproc, 1, 1);

pvm_pkint(tids, nproc, 1);

pvm_pkint(&n, 1, 1);

pvm_pkfloat(data, n, 1);


These operations create the packet structure to send data. (So we send more than a simple data structure).


msgtype = 5;

pvm_mcast(tids, nproc, 0);


pvm_mcast, multi casts to the all connected workstations (this has no time loss than pvm_send still packet is send to related workstation)


pvm_recv( -1, msgtype );


pvm_recv is implemented for ping pong algorithm. So we are again sure that we have send and received the data.


gettimeofday(&endtv, &endtz);

fark1=getdiff(endtv, starttv);


Finally we get the time difference for calculating transmission time.


4. Output of the systems


All output values below are calculated in microseconds.


Time results for TCP/IP is



Time results for pvm is


5. Conclusion


As the time results shows us TCP/IP is faster than pvm. But pvm creates a secure communication channel for transmission. So both has advantages.