<div>Hello Everyone,</div><div> </div><div>I had a requirement to sniff multiple interfaces to rtp pckets. Our application is stable when we sniff single interface but when i try to sniff multiple interface from single or multiple thread each opens the pcap_t devices seperately and uses pcap_next_ex to read the packets i got packet loss in large amount. i have tried to set the timeot to different levels like from 1 to 500 nothing seems to work.. here is the code sample that process the the multiple interfaces,</div>
<div> </div><div>while(IsRunning()) <br> { <br> <br> pcap_pkthdr* header;<br> const u_char* pkt_data;<br> bool bProcess = true;</div><div> if(pcap_next_ex(m_hPcap1,&header,&pkt_data) >= 0)<br> {<br> ETHERNETHEADER* pEthernetHeader = (ETHERNETHEADER *) pkt_data;<br>
IPHEADER* pIpHeader = (IPHEADER*)((char*)pEthernetHeader + sizeof(ETHERNETHEADER));<br> u_char* ipPacketEnd = (u_char*)pIpHeader + ntohs(pIpHeader->ip_len);<br> PacketSize = (ipPacketEnd - pkt_data)+100; // winpcap padding</div>
<div> <br> u_char* pPacket = (u_char*) malloc(PacketSize);<br> memcpy(pPacket,pkt_data,PacketSize);</div><div> m_SafeQueue.Enqueue(pPacket);</div><div> }</div><div> if(pcap_next_ex(m_hPcap2,&header,&pkt_data) >= 0)<br>
{<br> ETHERNETHEADER* pEthernetHeader = (ETHERNETHEADER *) pkt_data;<br> IPHEADER* pIpHeader = (IPHEADER*)((char*)pEthernetHeader + sizeof(ETHERNETHEADER));<br> u_char* ipPacketEnd = (u_char*)pIpHeader + ntohs(pIpHeader->ip_len);<br>
PacketSize = (ipPacketEnd - pkt_data)+100; // winpcap padding</div><div> <br> u_char* pPacket = (u_char*) malloc(PacketSize);<br> memcpy(pPacket,pkt_data,PacketSize);</div><div> m_SafeQueue.Enqueue(pPacket);</div>
<div> }<br>}</div><div> </div><div> </div><div>What i am doing wrong in this? also i have seems some suggestion to use waitformultipleevents but i am not sure how to do that. any suggestions appreciated.</div>