I am reading tcp packets from a tcp connection using the following code:<br><br>//start the capture<br> while((res = pcap_next_ex( fp, &header, &pkt_data)) >= 0)<br> {<br><br> if(res == 0)<br> /* Timeout elapsed */
<br> continue;<br> /* Print the packet */<br> // 0 to 53 character seems to have packet information not the data<br> for (i=54; i < header->caplen ; i++)<br> {<br> fprintf(dumpfile,"%c", pkt_data[i]);
<br> }<br> fflush(dumpfile); <br> }<br><br><br>///<br><br>every thing works OK. but it seems that this code sometime receive packets in different order. I mean two packet got swap! (1st packet come second and the 2nd packet come first).
<br>but when i am running this code, at the same time i am running another software (smartSniff) which can print the packet data in correct order..<br><br>So i am wondering is there any way to determine the correct packet order from tcp header information?
<br><br>Thanks.<br><br>