Hello ,
I am writing a application to Generate mixed traffic of TCP UDP Protocol. I have written socket program which generate TCP and UDP Stream with input Parameters supplied like Packet Size, Time and number of thread.
When I run to generate alone TCP or UDP , its working fine But When i try to generate a mixed traffic it show error on Sender side by saying Connection Refused. after that Program gets Terminated.
All order of Connection are Same on Both side . Each Connection is at Different port .
Code of Sender for Mixed Traffic is as Follow . Similar Code is at Receiver Side .
Code:
case 'm':
{
if (NUM_THREADS<2)
{
printf("\n At least Two Thread are required to run\n");
exit(-1);
}
if (NUM_THREADS%2==0)
{
UDP_Thread=NUM_THREADS/2;
TCP_Thread=NUM_THREADS/2;
}
else
{
UDP_Thread=NUM_THREADS/2;
TCP_Thread=NUM_THREADS/2+1;
}
printf("\n Number of TCP Thread going to Create %d",TCP_Thread);
for (t=0;t<TCP_Thread;t++)
{
printf("\n Started Thread %d\n",t);
rc=pthread_create(&tid[t], NULL,Send_tcp,(void*)&port[t]);
if (rc)
{
printf("ERROR; return code from pthread_create() is %d\n", rc);
exit(-1);
}
printf("\n Started Sending for Port No %d",port[t]);
}
printf("\n Number of UDP Thread going to Create %d",UDP_Thread);
for (t=0;t<UDP_Thread;t++)
{
printf("\n Started Thread %d\n",TCP_Thread+t);
rc=pthread_create(&tid[t], NULL,Send_udp,(void*)&port[TCP_Thread+t]);
if (rc)
{
printf("ERROR; return code from pthread_create() is %d\n", rc);
exit(-1);
}
printf("\n Started Sending for Port No %d",port[TCP_Thread+t]);
}