<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML xmlns="http://www.w3.org/TR/REC-html40" xmlns:v =
"urn:schemas-microsoft-com:vml" xmlns:o =
"urn:schemas-microsoft-com:office:office" xmlns:w =
"urn:schemas-microsoft-com:office:word" xmlns:m =
"http://schemas.microsoft.com/office/2004/12/omml"><HEAD>
<META http-equiv=Content-Type content="text/html; charset=iso-8859-1">
<META content="MSHTML 6.00.6000.16825" name=GENERATOR>
<STYLE>@font-face {
        font-family: Calibri;
}
@font-face {
        font-family: Tahoma;
}
@page Section1 {size: 612.0pt 792.0pt; margin: 72.0pt 72.0pt 72.0pt 72.0pt; }
P.MsoNormal {
        FONT-SIZE: 11pt; MARGIN: 0cm 0cm 0pt; FONT-FAMILY: "Calibri","sans-serif"
}
LI.MsoNormal {
        FONT-SIZE: 11pt; MARGIN: 0cm 0cm 0pt; FONT-FAMILY: "Calibri","sans-serif"
}
DIV.MsoNormal {
        FONT-SIZE: 11pt; MARGIN: 0cm 0cm 0pt; FONT-FAMILY: "Calibri","sans-serif"
}
A:link {
        COLOR: blue; TEXT-DECORATION: underline; mso-style-priority: 99
}
SPAN.MsoHyperlink {
        COLOR: blue; TEXT-DECORATION: underline; mso-style-priority: 99
}
A:visited {
        COLOR: purple; TEXT-DECORATION: underline; mso-style-priority: 99
}
SPAN.MsoHyperlinkFollowed {
        COLOR: purple; TEXT-DECORATION: underline; mso-style-priority: 99
}
P.MsoAcetate {
        FONT-SIZE: 8pt; MARGIN: 0cm 0cm 0pt; FONT-FAMILY: "Tahoma","sans-serif"; mso-style-priority: 99; mso-style-link: "Balloon Text Char"
}
LI.MsoAcetate {
        FONT-SIZE: 8pt; MARGIN: 0cm 0cm 0pt; FONT-FAMILY: "Tahoma","sans-serif"; mso-style-priority: 99; mso-style-link: "Balloon Text Char"
}
DIV.MsoAcetate {
        FONT-SIZE: 8pt; MARGIN: 0cm 0cm 0pt; FONT-FAMILY: "Tahoma","sans-serif"; mso-style-priority: 99; mso-style-link: "Balloon Text Char"
}
SPAN.EmailStyle17 {
        COLOR: windowtext; FONT-FAMILY: "Calibri","sans-serif"; mso-style-type: personal-compose
}
SPAN.BalloonTextChar {
        FONT-FAMILY: "Tahoma","sans-serif"; mso-style-priority: 99; mso-style-link: "Balloon Text"; mso-style-name: "Balloon Text Char"
}
.MsoChpDefault {
        mso-style-type: export-only
}
DIV.Section1 {
        page: Section1
}
</STYLE>
<!--[if gte mso 9]><xml>
<o:shapedefaults v:ext="edit" spidmax="1026" />
</xml><![endif]--><!--[if gte mso 9]><xml>
<o:shapelayout v:ext="edit">
<o:idmap v:ext="edit" data="1" />
</o:shapelayout></xml><![endif]--></HEAD>
<BODY lang=EN-US vLink=purple link=blue bgColor=#ffffff>
<DIV><FONT size=2></FONT> </DIV>
<BLOCKQUOTE
style="PADDING-RIGHT: 0px; PADDING-LEFT: 5px; MARGIN-LEFT: 5px; BORDER-LEFT: #000000 2px solid; MARGIN-RIGHT: 0px">
<DIV style="FONT: 10pt arial">----- Original Message ----- </DIV>
<DIV
style="BACKGROUND: #e4e4e4; FONT: 10pt arial; font-color: black"><B>From:</B>
<A title=jhunter@aptcodecs.com href="mailto:jhunter@aptcodecs.com">James
Hunter</A> </DIV>
<DIV style="FONT: 10pt arial"><B>To:</B> <A title=winpcap-users@winpcap.org
href="mailto:winpcap-users@winpcap.org">winpcap-users@winpcap.org</A> </DIV>
<DIV style="FONT: 10pt arial"><B>Sent:</B> Tuesday, May 19, 2009 8:33 AM</DIV>
<DIV style="FONT: 10pt arial"><B>Subject:</B> [Winpcap-users] pcap_loop
callback timing problem..</DIV>
<DIV><BR></DIV>
<DIV class=Section1>
<P class=MsoNormal>Hi,<o:p></o:p></P>
<P class=MsoNormal><o:p> </o:p></P>
<P class=MsoNormal>I`m creating an application that can sniff packets from a
network interface real-time, whilst repeating only certain packets to a
different network interface.<o:p></o:p></P>
<P class=MsoNormal><o:p> </o:p></P>
<P class=MsoNormal>I have found that the callback is being called multiple
times in a burst style, rather than as packets arrive. If the network sends
packets every 100ms, I will receive 10 callbacks immediately after each other
– with each burst of 10 callbacks spaced about a second apart..<o:p></o:p></P>
<P class=MsoNormal><o:p> </o:p></P></DIV></BLOCKQUOTE>
<P class=MsoNormal><o:p><FONT face="Courier New" size=2>This is the default
behavior of WinPcap. WinPcap is a capture engine, so it favors efficiency and
performance over low latency in receiving packets. Basically packets are stored
in the kernel and brought to user mode in batches, checking these 2
conditions</FONT></o:p></P>
<P class=MsoNormal><o:p><FONT face="Courier New" size=2>1. a timeout occurs (the
timeout that you set in pcap_openlive)</FONT></o:p></P>
<P class=MsoNormal><o:p><FONT face="Courier New" size=2>2. at least mintocopy
bytes are present in the kernel buffer (by default it's 16k if you use
pcap_openlive)</FONT></o:p></P>
<P class=MsoNormal><o:p><FONT face="Courier New" size=2>(whatever happens
first).</FONT></o:p></P>
<P class=MsoNormal><o:p><FONT face="Courier New" size=2></FONT></o:p> </P>
<P class=MsoNormal><o:p><FONT face="Courier New" size=2>You can lower this
latency by playing with mintocopy (use pcap_setmintocopy to change it) or with
the timeout, remembering that the lower those values are, the lower the latency
in receiving packets is, *obviously* with a performance hit.</FONT></o:p></P>
<P class=MsoNormal><o:p><FONT face="Courier New" size=2></FONT></o:p> </P>
<P class=MsoNormal><o:p><FONT face="Courier New" size=2>Hope it
helps</FONT></o:p></P>
<P class=MsoNormal><o:p><FONT face="Courier New" size=2>GV</FONT></o:p></P>
<BLOCKQUOTE
style="PADDING-RIGHT: 0px; PADDING-LEFT: 5px; MARGIN-LEFT: 5px; BORDER-LEFT: #000000 2px solid; MARGIN-RIGHT: 0px">
<P class=MsoNormal><o:p><FONT face="Courier New"
size=2></FONT></o:p> </P>
<P class=MsoNormal>This is causing problems at the far end which expects a
constant flow of packets, is there anything I can do get the callback to
trigger as and when packets arrive?<o:p></o:p></P>
<P class=MsoNormal><o:p> </o:p></P>
<P class=MsoNormal>Regards,<o:p></o:p></P>
<P class=MsoNormal><o:p> </o:p></P>
<P class=MsoNormal>James<o:p></o:p></P>
<P class=MsoNormal><o:p> </o:p></P>
<P>
<HR>
<P></P>_______________________________________________<BR>Winpcap-users
mailing
list<BR>Winpcap-users@winpcap.org<BR>https://www.winpcap.org/mailman/listinfo/winpcap-users<BR></BLOCKQUOTE></BODY></HTML>