Unix Programming - sync socket transfer speed is diferent in Linux and Solaris. why?

This is Interesting: Free IT Magazines  
Home > Archive > Unix Programming > January 2004 > sync socket transfer speed is diferent in Linux and Solaris. why?





You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

Author sync socket transfer speed is diferent in Linux and Solaris. why?
dbakorea

2004-01-23, 5:16 pm

In Socket, Sychronized Transfer.
both Solaris and Linux, result is different.

1. Server[Solaris] - Client[Linux] -> Elapsed Time: 14 sec (network)
2. Server[Solaris] - Client[Solaris] -> Elapsed Time: 9 sec (local)
3. Server[Linux] - Client[Linux] -> Elapsed Time: 4 sec (local)

I wonder why case 2 and 3 is diferent?


[server.c] - some code omitted

// Some header files..

int process_packet(int sockfd)
{
int i;
HEADER header ;
PUSH_REQ_SUBMIT push_req ;
PUSH_ACK push_ack ;

memset( &push_ack, 0x00, sizeof(push_ack) );
memcpy( push_ack.header.type, "PA", 2 );
memcpy( push_ack.status, "00", 2 );

while(1)
{
for(i=0; i<100; i++)
{
if( readn(sockfd, (char *)&header, sizeof(header)) != sizeof(header))
return -1;
if( readn(sockfd, (char *)&push_req, sizeof(push_req)) !=
sizeof(push_req)) return -1;
if( writen(sockfd, (char *)&push_ack, sizeof(push_ack)) !=
sizeof(push_ack)) return -1;
}
}
return 1;
}

int main()
{
int sockfd;
int newsockfd;
char peername[20];
int client_len;
struct sockaddr_in client_addr;
time_t now;

sockfd = makeServer(1818);

while(1)
{
client_len = sizeof(client_addr);
if( (newsockfd = accept(sockfd, (struct sockaddr *)&client_addr,
&client_len) ) < 0 )
continue;

if( getpeername(newsockfd, (struct sockaddr *)&client_addr, &client_len)
== -1 )
{
perror("getpeername()");
}
else
{
sprintf( peername,"%s", inet_ntoa(client_addr.sin_addr) );
printf("(%s) Connected!\n", peername );
}
now = time(NULL);
process_packet(newsockfd);
printf("\nElapsed Time: %ld sec\n", time(NULL) - now);
close(newsockfd);
printf("\n(%s) Disconnected!\n", peername );
}

return 1;
}


[client.c]
// header files...
int main(int argc, char **argv)
{
int sockfd;
char remoteHost[] = "xxx.yyy.zzz";
unsigned short remotePort=1818;

unsigned long i;
unsigned long smsid;
char *ptr;
int tel_division;
int push_num = 100;

JOBQUEUE_RECORD_BODY_SUBMIT submit;

PUSH_REQ_SUBMIT push_req_submit;
PUSH_ACK push_ack;
HEADER header;

// smsid´Â timeÀ¸·Î ±¸ÇÑ ÇöÀç½Ã°¢À¸·Î ó¸®ÇÏ¿© push_num°¡Áö Áõ°¡½ÃÅ´
smsid = time(NULL);
ptr = (char *)malloc(push_num * sizeof(JOBQUEUE_RECORD_BODY_SUBMIT));
for(i=0;i<push_num;i++)
{
memset( &submit, 0x00, sizeof(submit));
// code to fill submit data
memcpy( ptr + i*sizeof(JOBQUEUE_RECORD_BODY_SUBMIT), &submit,
sizeof(JOBQUEUE_RECORD_BODY_SUBMIT) );
}

memset(&header, 0x00, sizeof(header));
memcpy(header.type, "PR", 2);

sockfd = connectServer(remoteHost, remotePort);

for(i=0;i<push_num;i++)
{
memcpy(&push_req_submit, ptr + i*sizeof(JOBQUEUE_RECORD_BODY_SUBMIT),
sizeof(push_req_submit) );
writen(sockfd, (char *)&header, sizeof(header) );
writen(sockfd, (char *)&push_req_submit, sizeof(push_req_submit) );
readn(sockfd, (char *)&push_ack, sizeof(push_ack));
}
close(sockfd);

free(ptr);
return 0;
}


Casper H.S. Dik

2004-01-23, 5:17 pm

"dbakorea" <myunggyu@hotmail.com> writes:
quote:

>In Socket, Sychronized Transfer.
>both Solaris and Linux, result is different.


quote:

>1. Server[Solaris] - Client[Linux] -> Elapsed Time: 14 sec (network)
>2. Server[Solaris] - Client[Solaris] -> Elapsed Time: 9 sec (local)
>3. Server[Linux] - Client[Linux] -> Elapsed Time: 4 sec (local)


quote:

>I wonder why case 2 and 3 is diferent?




Without the full source code *and* an algorithmic description of what
you're doing it's really hard to tell; are you perhaps using a Solaris
version which has a small default window or are you being hit be the
delayed ACK interval difference?

Casper
--
Expressed in this posting are my opinions. They are in no way related
to opinions held by my employer, Sun Microsystems.
Statements on Sun products included here are not gospel and may
be fiction rather than truth.
Sponsored Links






Free braindumps | Software forum | Database administration forum

Copyright 2003 - 2008 webservertalk.com