time of send data via net use UDP is too long

Hi Nvidia:
One frame of JPEG encoded data is repeatly and continously sended via net use UDP,the time of sending about the first 10 frames is normal(about 40ms per frame),but the time become longer and longer,the time of 300th frame is about 700ms, it is not accepted. JPEG resolution is 4096x4096.
Reference code as below,could you give me some advise, is there some problem in my codes?
Thanks! Expected your reply!
static bool
net_initialize(context_t * ctx)
int ret = 0;
ctx->sockfd = socket(AF_INET,SOCK_DGRAM,0);
if(ctx->sockfd < 0)
printf(“Create socket failed\n”);
return false;

memset( &(ctx->saddr), 0, sizeof(ctx->saddr));
ctx->saddr.sin_family = AF_INET;
ctx->saddr.sin_addr.s_addr = htonl(INADDR_ANY);
ctx->saddr.sin_port = htons(8888);

memset( &(ctx->caddr), 0, sizeof(ctx->caddr));
ctx->caddr.sin_family = AF_INET;
ctx->caddr.sin_addr.s_addr = inet_addr("");
ctx->caddr.sin_port = htons(2345);

ret = bind(ctx->sockfd, (struct sockaddr*) &(ctx->saddr), sizeof(ctx->saddr));
if(ret < 0)
	printf("Bind socket failed\n");
	return false;

return true;


send data segment:
for( int i=0;i<510;i++)
ctemp = (char )out_buf;
leftBytes = out_buf_size;
ret = sendto(ctx.sockfd,ctemp,bytesPerTime,0,(struct sockaddr
) &(ctx.caddr),len);
leftBytes -= bytesPerTime;
ctemp += bytesPerTime;
if( leftBytes < bytesPerTime && leftBytes != 0)
bytesPerTime = leftBytes;
if( leftBytes == 0 )
Notice: JPEG encoded data save in out_buf,and out_buf_size is the data length.


I would like to clarify the issue here since you are sending a jpeg. Can this slow down be observed if using UDP to send other file? Maybe simple bit stream or something else would be better.

We should check if this issue is really from TCP/UDP stack first.

Hi WayneWWW:
Thanks for your reply! It seams that I have found the reason. It is for that the prameter bytesPerTime is not recovered when one frame data been send out,so this parameter is smaller and smaller.
Thanks again!