<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	
	>
<channel>
	<title>
	Comments on: How to code a Packet Sniffer in C with Libpcap on Linux	</title>
	<atom:link href="https://www.binarytides.com/packet-sniffer-code-c-libpcap-linux-sockets/feed/" rel="self" type="application/rss+xml" />
	<link>https://www.binarytides.com/packet-sniffer-code-c-libpcap-linux-sockets/</link>
	<description>News, Technology, Entertainment and more</description>
	<lastBuildDate>Fri, 18 Dec 2020 12:54:18 +0000</lastBuildDate>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	<generator>https://wordpress.org/?v=6.8.2</generator>
	<item>
		<title>
		By: Arash		</title>
		<link>https://www.binarytides.com/packet-sniffer-code-c-libpcap-linux-sockets/comment-page-1/#comment-301672</link>

		<dc:creator><![CDATA[Arash]]></dc:creator>
		<pubDate>Fri, 18 Dec 2020 12:54:18 +0000</pubDate>
		<guid isPermaLink="false">http://www.binarytides.com/blog/?p=49#comment-301672</guid>

					<description><![CDATA[Hi
I&#039;m using this code but the Source Port is not correct !
For example if I request to http server , the destination port is correct and it&#039;s 80 but the source port is wrong 
I checked it by wireshark
please help !]]></description>
			<content:encoded><![CDATA[<p>Hi<br />
I&#8217;m using this code but the Source Port is not correct !<br />
For example if I request to http server , the destination port is correct and it&#8217;s 80 but the source port is wrong<br />
I checked it by wireshark<br />
please help !</p>
]]></content:encoded>
		
			</item>
		<item>
		<title>
		By: utsav patel		</title>
		<link>https://www.binarytides.com/packet-sniffer-code-c-libpcap-linux-sockets/comment-page-1/#comment-156068</link>

		<dc:creator><![CDATA[utsav patel]]></dc:creator>
		<pubDate>Tue, 06 Mar 2018 17:29:51 +0000</pubDate>
		<guid isPermaLink="false">http://www.binarytides.com/blog/?p=49#comment-156068</guid>

					<description><![CDATA[it&#039;s give me an error like this &quot;Couldn&#039;t open device any : any: socket: Invalid argument&quot; plz help me]]></description>
			<content:encoded><![CDATA[<p>it&#8217;s give me an error like this &#8220;Couldn&#8217;t open device any : any: socket: Invalid argument&#8221; plz help me</p>
]]></content:encoded>
		
			</item>
		<item>
		<title>
		By: Juan Mamani		</title>
		<link>https://www.binarytides.com/packet-sniffer-code-c-libpcap-linux-sockets/comment-page-1/#comment-154438</link>

		<dc:creator><![CDATA[Juan Mamani]]></dc:creator>
		<pubDate>Thu, 08 Feb 2018 19:30:56 +0000</pubDate>
		<guid isPermaLink="false">http://www.binarytides.com/blog/?p=49#comment-154438</guid>

					<description><![CDATA[Again!  You did it man!
Really Thanks!  I tested on Debian an is working.  But previous installation of libcap  for Debian.

All rocks!]]></description>
			<content:encoded><![CDATA[<p>Again!  You did it man!<br />
Really Thanks!  I tested on Debian an is working.  But previous installation of libcap  for Debian.</p>
<p>All rocks!</p>
]]></content:encoded>
		
			</item>
		<item>
		<title>
		By: Farhan		</title>
		<link>https://www.binarytides.com/packet-sniffer-code-c-libpcap-linux-sockets/comment-page-1/#comment-135627</link>

		<dc:creator><![CDATA[Farhan]]></dc:creator>
		<pubDate>Mon, 16 Oct 2017 14:54:04 +0000</pubDate>
		<guid isPermaLink="false">http://www.binarytides.com/blog/?p=49#comment-135627</guid>

					<description><![CDATA[hi 
I want to capture only incoming packets, can you help me how to do that.]]></description>
			<content:encoded><![CDATA[<p>hi<br />
I want to capture only incoming packets, can you help me how to do that.</p>
]]></content:encoded>
		
			</item>
		<item>
		<title>
		By: fleur		</title>
		<link>https://www.binarytides.com/packet-sniffer-code-c-libpcap-linux-sockets/comment-page-1/#comment-107539</link>

		<dc:creator><![CDATA[fleur]]></dc:creator>
		<pubDate>Tue, 28 Feb 2017 22:56:48 +0000</pubDate>
		<guid isPermaLink="false">http://www.binarytides.com/blog/?p=49#comment-107539</guid>

					<description><![CDATA[In reply to &lt;a href=&quot;https://www.binarytides.com/packet-sniffer-code-c-libpcap-linux-sockets/comment-page-1/#comment-65669&quot;&gt;Silver Moon&lt;/a&gt;.

void ProcessPacket(unsigned char* buffer, int size)
{
 //Get the IP Header part of this packet , excluding the ethernet header
 struct iphdr *iph = (struct iphdr*)(buffer + sizeof(struct ethhdr));
 ++total;
 switch (iph-&#062;protocol) //Check the Protocol and do accordingly...
 {
 case 1: //ICMP Protocol
 ++icmp;
 print_icmp_packet( buffer , size);
 break;

 case 2: //IGMP Protocol
 ++igmp;
 break;

 case 6: //TCP Protocol
 ++tcp;
 print_tcp_packet(buffer , size);
 break;

 case 17: //UDP Protocol
 ++udp;
 print_udp_packet(buffer , size);
 break;

 default: //Some Other Protocol like ARP etc.
 ++others;
 break;
 }
 printf(&quot;TCP : %d UDP : %d ICMP : %d IGMP : %d Others : %d
Total : %d\r&quot;, tcp , udp , icmp , igmp , others , total);
}]]></description>
			<content:encoded><![CDATA[<p>In reply to <a href="https://www.binarytides.com/packet-sniffer-code-c-libpcap-linux-sockets/comment-page-1/#comment-65669">Silver Moon</a>.</p>
<p>void ProcessPacket(unsigned char* buffer, int size)<br />
{<br />
 //Get the IP Header part of this packet , excluding the ethernet header<br />
 struct iphdr *iph = (struct iphdr*)(buffer + sizeof(struct ethhdr));<br />
 ++total;<br />
 switch (iph-&gt;protocol) //Check the Protocol and do accordingly&#8230;<br />
 {<br />
 case 1: //ICMP Protocol<br />
 ++icmp;<br />
 print_icmp_packet( buffer , size);<br />
 break;</p>
<p> case 2: //IGMP Protocol<br />
 ++igmp;<br />
 break;</p>
<p> case 6: //TCP Protocol<br />
 ++tcp;<br />
 print_tcp_packet(buffer , size);<br />
 break;</p>
<p> case 17: //UDP Protocol<br />
 ++udp;<br />
 print_udp_packet(buffer , size);<br />
 break;</p>
<p> default: //Some Other Protocol like ARP etc.<br />
 ++others;<br />
 break;<br />
 }<br />
 printf(&#8220;TCP : %d UDP : %d ICMP : %d IGMP : %d Others : %d<br />
Total : %d\r&#8221;, tcp , udp , icmp , igmp , others , total);<br />
}</p>
]]></content:encoded>
		
			</item>
		<item>
		<title>
		By: Will		</title>
		<link>https://www.binarytides.com/packet-sniffer-code-c-libpcap-linux-sockets/comment-page-1/#comment-94382</link>

		<dc:creator><![CDATA[Will]]></dc:creator>
		<pubDate>Wed, 21 Sep 2016 08:13:20 +0000</pubDate>
		<guid isPermaLink="false">http://www.binarytides.com/blog/?p=49#comment-94382</guid>

					<description><![CDATA[This code was very useful.
how can I dump the captured traffic in a pcap/pcap-ng file?]]></description>
			<content:encoded><![CDATA[<p>This code was very useful.<br />
how can I dump the captured traffic in a pcap/pcap-ng file?</p>
]]></content:encoded>
		
			</item>
		<item>
		<title>
		By: Huong Phan		</title>
		<link>https://www.binarytides.com/packet-sniffer-code-c-libpcap-linux-sockets/comment-page-1/#comment-90705</link>

		<dc:creator><![CDATA[Huong Phan]]></dc:creator>
		<pubDate>Fri, 05 Aug 2016 09:34:50 +0000</pubDate>
		<guid isPermaLink="false">http://www.binarytides.com/blog/?p=49#comment-90705</guid>

					<description><![CDATA[Thank for your help. It&#039;s very useful :)]]></description>
			<content:encoded><![CDATA[<p>Thank for your help. It&#8217;s very useful :)</p>
]]></content:encoded>
		
			</item>
		<item>
		<title>
		By: dima rabadi		</title>
		<link>https://www.binarytides.com/packet-sniffer-code-c-libpcap-linux-sockets/comment-page-1/#comment-67602</link>

		<dc:creator><![CDATA[dima rabadi]]></dc:creator>
		<pubDate>Mon, 24 Nov 2014 13:34:00 +0000</pubDate>
		<guid isPermaLink="false">http://www.binarytides.com/blog/?p=49#comment-67602</guid>

					<description><![CDATA[Hey, Thank you its really very helpful 
But, why I can not capture the NTP packets, even it use UDP socket ??!
Any help please ?]]></description>
			<content:encoded><![CDATA[<p>Hey, Thank you its really very helpful<br />
But, why I can not capture the NTP packets, even it use UDP socket ??!<br />
Any help please ?</p>
]]></content:encoded>
		
			</item>
		<item>
		<title>
		By: Anonymous		</title>
		<link>https://www.binarytides.com/packet-sniffer-code-c-libpcap-linux-sockets/comment-page-1/#comment-67327</link>

		<dc:creator><![CDATA[Anonymous]]></dc:creator>
		<pubDate>Thu, 21 Aug 2014 18:51:00 +0000</pubDate>
		<guid isPermaLink="false">http://www.binarytides.com/blog/?p=49#comment-67327</guid>

					<description><![CDATA[Hi ! 
I&#039;m on MacOS, and I got so many errors while compiling the program. Do someone tried to compile on MacOs? Do libraries need to be installed?
Thanks]]></description>
			<content:encoded><![CDATA[<p>Hi !<br />
I&#8217;m on MacOS, and I got so many errors while compiling the program. Do someone tried to compile on MacOs? Do libraries need to be installed?<br />
Thanks</p>
]]></content:encoded>
		
			</item>
		<item>
		<title>
		By: Farzam		</title>
		<link>https://www.binarytides.com/packet-sniffer-code-c-libpcap-linux-sockets/comment-page-1/#comment-66182</link>

		<dc:creator><![CDATA[Farzam]]></dc:creator>
		<pubDate>Sat, 24 May 2014 05:25:00 +0000</pubDate>
		<guid isPermaLink="false">http://www.binarytides.com/blog/?p=49#comment-66182</guid>

					<description><![CDATA[How can i open the log file ? im simply getting the number of packets only]]></description>
			<content:encoded><![CDATA[<p>How can i open the log file ? im simply getting the number of packets only</p>
]]></content:encoded>
		
			</item>
		<item>
		<title>
		By: Dawit Girmai		</title>
		<link>https://www.binarytides.com/packet-sniffer-code-c-libpcap-linux-sockets/comment-page-1/#comment-65842</link>

		<dc:creator><![CDATA[Dawit Girmai]]></dc:creator>
		<pubDate>Thu, 21 Nov 2013 11:37:00 +0000</pubDate>
		<guid isPermaLink="false">http://www.binarytides.com/blog/?p=49#comment-65842</guid>

					<description><![CDATA[In reply to &lt;a href=&quot;https://www.binarytides.com/packet-sniffer-code-c-libpcap-linux-sockets/comment-page-1/#comment-65841&quot;&gt;Dawit Girmai&lt;/a&gt;.

in the above picture we have two parts 1). (the portion highlighted with blue) the http header that ends with rn rn and   2). raw html file; so how can we capture only http file ( &quot;.....&quot;) without the http header file? thank you in advance!]]></description>
			<content:encoded><![CDATA[<p>In reply to <a href="https://www.binarytides.com/packet-sniffer-code-c-libpcap-linux-sockets/comment-page-1/#comment-65841">Dawit Girmai</a>.</p>
<p>in the above picture we have two parts 1). (the portion highlighted with blue) the http header that ends with rn rn and   2). raw html file; so how can we capture only http file ( &#8220;&#8230;..&#8221;) without the http header file? thank you in advance!</p>
]]></content:encoded>
		
			</item>
		<item>
		<title>
		By: Dawit Girmai		</title>
		<link>https://www.binarytides.com/packet-sniffer-code-c-libpcap-linux-sockets/comment-page-1/#comment-65841</link>

		<dc:creator><![CDATA[Dawit Girmai]]></dc:creator>
		<pubDate>Thu, 21 Nov 2013 08:17:00 +0000</pubDate>
		<guid isPermaLink="false">http://www.binarytides.com/blog/?p=49#comment-65841</guid>

					<description><![CDATA[Hello Silvermoon,
your post is really helpful, i thank you for ur help and what if i want to grap/capture only http file(only the raw .... thing) without the header file...?]]></description>
			<content:encoded><![CDATA[<p>Hello Silvermoon,<br />
your post is really helpful, i thank you for ur help and what if i want to grap/capture only http file(only the raw &#8230;. thing) without the header file&#8230;?</p>
]]></content:encoded>
		
			</item>
		<item>
		<title>
		By: Silver Moon		</title>
		<link>https://www.binarytides.com/packet-sniffer-code-c-libpcap-linux-sockets/comment-page-1/#comment-65725</link>

		<dc:creator><![CDATA[Silver Moon]]></dc:creator>
		<pubDate>Mon, 23 Sep 2013 04:36:00 +0000</pubDate>
		<guid isPermaLink="false">http://www.binarytides.com/blog/?p=49#comment-65725</guid>

					<description><![CDATA[In reply to &lt;a href=&quot;https://www.binarytides.com/packet-sniffer-code-c-libpcap-linux-sockets/comment-page-1/#comment-65724&quot;&gt;Bystander&lt;/a&gt;.

search google for something like ip header protocol number

The list of protocols and their corresponding numbers can be found at this page
http://www.iana.org/assignments/protocol-numbers/protocol-numbers.xhtml]]></description>
			<content:encoded><![CDATA[<p>In reply to <a href="https://www.binarytides.com/packet-sniffer-code-c-libpcap-linux-sockets/comment-page-1/#comment-65724">Bystander</a>.</p>
<p>search google for something like ip header protocol number</p>
<p>The list of protocols and their corresponding numbers can be found at this page<br />
<a href="http://www.iana.org/assignments/protocol-numbers/protocol-numbers.xhtml" rel="nofollow ugc">http://www.iana.org/assignments/protocol-numbers/protocol-numbers.xhtml</a></p>
]]></content:encoded>
		
			</item>
		<item>
		<title>
		By: Bystander		</title>
		<link>https://www.binarytides.com/packet-sniffer-code-c-libpcap-linux-sockets/comment-page-1/#comment-65724</link>

		<dc:creator><![CDATA[Bystander]]></dc:creator>
		<pubDate>Sun, 22 Sep 2013 21:14:00 +0000</pubDate>
		<guid isPermaLink="false">http://www.binarytides.com/blog/?p=49#comment-65724</guid>

					<description><![CDATA[I&#039;m curious, I&#039;ve been looking all over the net but to no avail. How did you know what the values of iphdr-&#062;protocol were? I&#039;m trying to find a list of some sort for me to further document what protocols  were being tracked but I can&#039;t seem to find anything.]]></description>
			<content:encoded><![CDATA[<p>I&#8217;m curious, I&#8217;ve been looking all over the net but to no avail. How did you know what the values of iphdr-&gt;protocol were? I&#8217;m trying to find a list of some sort for me to further document what protocols  were being tracked but I can&#8217;t seem to find anything.</p>
]]></content:encoded>
		
			</item>
		<item>
		<title>
		By: Chirag Modi		</title>
		<link>https://www.binarytides.com/packet-sniffer-code-c-libpcap-linux-sockets/comment-page-1/#comment-65670</link>

		<dc:creator><![CDATA[Chirag Modi]]></dc:creator>
		<pubDate>Wed, 21 Aug 2013 11:21:00 +0000</pubDate>
		<guid isPermaLink="false">http://www.binarytides.com/blog/?p=49#comment-65670</guid>

					<description><![CDATA[In reply to &lt;a href=&quot;https://www.binarytides.com/packet-sniffer-code-c-libpcap-linux-sockets/comment-page-1/#comment-65669&quot;&gt;Silver Moon&lt;/a&gt;.

Thanks for reply...]]></description>
			<content:encoded><![CDATA[<p>In reply to <a href="https://www.binarytides.com/packet-sniffer-code-c-libpcap-linux-sockets/comment-page-1/#comment-65669">Silver Moon</a>.</p>
<p>Thanks for reply&#8230;</p>
]]></content:encoded>
		
			</item>
		<item>
		<title>
		By: Silver Moon		</title>
		<link>https://www.binarytides.com/packet-sniffer-code-c-libpcap-linux-sockets/comment-page-1/#comment-65669</link>

		<dc:creator><![CDATA[Silver Moon]]></dc:creator>
		<pubDate>Wed, 21 Aug 2013 11:12:00 +0000</pubDate>
		<guid isPermaLink="false">http://www.binarytides.com/blog/?p=49#comment-65669</guid>

					<description><![CDATA[In reply to &lt;a href=&quot;https://www.binarytides.com/packet-sniffer-code-c-libpcap-linux-sockets/comment-page-1/#comment-65668&quot;&gt;Chirag Modi&lt;/a&gt;.

try to sniff the pseudo device &quot;any&quot;. it should sniff on all available interfaces.]]></description>
			<content:encoded><![CDATA[<p>In reply to <a href="https://www.binarytides.com/packet-sniffer-code-c-libpcap-linux-sockets/comment-page-1/#comment-65668">Chirag Modi</a>.</p>
<p>try to sniff the pseudo device &#8220;any&#8221;. it should sniff on all available interfaces.</p>
]]></content:encoded>
		
			</item>
		<item>
		<title>
		By: Chirag Modi		</title>
		<link>https://www.binarytides.com/packet-sniffer-code-c-libpcap-linux-sockets/comment-page-1/#comment-65668</link>

		<dc:creator><![CDATA[Chirag Modi]]></dc:creator>
		<pubDate>Wed, 21 Aug 2013 11:01:00 +0000</pubDate>
		<guid isPermaLink="false">http://www.binarytides.com/blog/?p=49#comment-65668</guid>

					<description><![CDATA[Dear,


I want to sniff network packets from multiple interfaces (e.g. eth0, VMnet, eth1 etc) at a time. For this purpose, this code (in current form) will not work. Is there any solution? or what modifications are needed in this code to do the same?


Please help me.]]></description>
			<content:encoded><![CDATA[<p>Dear,</p>
<p>I want to sniff network packets from multiple interfaces (e.g. eth0, VMnet, eth1 etc) at a time. For this purpose, this code (in current form) will not work. Is there any solution? or what modifications are needed in this code to do the same?</p>
<p>Please help me.</p>
]]></content:encoded>
		
			</item>
		<item>
		<title>
		By: Silver Moon		</title>
		<link>https://www.binarytides.com/packet-sniffer-code-c-libpcap-linux-sockets/comment-page-1/#comment-65079</link>

		<dc:creator><![CDATA[Silver Moon]]></dc:creator>
		<pubDate>Fri, 26 Apr 2013 13:15:00 +0000</pubDate>
		<guid isPermaLink="false">http://www.binarytides.com/blog/?p=49#comment-65079</guid>

					<description><![CDATA[In reply to &lt;a href=&quot;https://www.binarytides.com/packet-sniffer-code-c-libpcap-linux-sockets/comment-page-1/#comment-58667&quot;&gt;Jing Kang&lt;/a&gt;.

thanks for pointing it out.]]></description>
			<content:encoded><![CDATA[<p>In reply to <a href="https://www.binarytides.com/packet-sniffer-code-c-libpcap-linux-sockets/comment-page-1/#comment-58667">Jing Kang</a>.</p>
<p>thanks for pointing it out.</p>
]]></content:encoded>
		
			</item>
		<item>
		<title>
		By: Silver Moon		</title>
		<link>https://www.binarytides.com/packet-sniffer-code-c-libpcap-linux-sockets/comment-page-1/#comment-65078</link>

		<dc:creator><![CDATA[Silver Moon]]></dc:creator>
		<pubDate>Fri, 26 Apr 2013 13:14:00 +0000</pubDate>
		<guid isPermaLink="false">http://www.binarytides.com/blog/?p=49#comment-65078</guid>

					<description><![CDATA[In reply to &lt;a href=&quot;https://www.binarytides.com/packet-sniffer-code-c-libpcap-linux-sockets/comment-page-1/#comment-65077&quot;&gt;lonely-i&lt;/a&gt;.

can you first try to sniff using wireshark ?
does wireshark show the ipv6 packets ?]]></description>
			<content:encoded><![CDATA[<p>In reply to <a href="https://www.binarytides.com/packet-sniffer-code-c-libpcap-linux-sockets/comment-page-1/#comment-65077">lonely-i</a>.</p>
<p>can you first try to sniff using wireshark ?<br />
does wireshark show the ipv6 packets ?</p>
]]></content:encoded>
		
			</item>
		<item>
		<title>
		By: lonely-i		</title>
		<link>https://www.binarytides.com/packet-sniffer-code-c-libpcap-linux-sockets/comment-page-1/#comment-65077</link>

		<dc:creator><![CDATA[lonely-i]]></dc:creator>
		<pubDate>Fri, 26 Apr 2013 10:06:00 +0000</pubDate>
		<guid isPermaLink="false">http://www.binarytides.com/blog/?p=49#comment-65077</guid>

					<description><![CDATA[Hi Silver Moon. I&#039;m programming a simple sinario with 2 nodes trying to connect via a gateway. node 1 sends a an IPv6 UDP socket to node 2, but gateway has to capture the socket and verifies its data before forwarding it. I tried to use your code but I cant&#039; see my socket as I send it :( Any help please??]]></description>
			<content:encoded><![CDATA[<p>Hi Silver Moon. I&#8217;m programming a simple sinario with 2 nodes trying to connect via a gateway. node 1 sends a an IPv6 UDP socket to node 2, but gateway has to capture the socket and verifies its data before forwarding it. I tried to use your code but I cant&#8217; see my socket as I send it :( Any help please??</p>
]]></content:encoded>
		
			</item>
	</channel>
</rss>
