# Packet sniffer and parser in C

DevFeed: [Packet sniffer and parser in C](<https://devfeed.tech/articles/packet-sniffer-and-parser-in-c-39611.md>)

Original publisher: [Read original article](<https://www.gauravsarma.com/posts/2019-08-11_Packet-sniffer-and-parser-in-C-c86070081c38>)

Published: 2019-08-11T00:00:00Z

Content type: tutorial

Language: en

Sources: [Gaurav Sarma's Blog](<https://devfeed.tech/sources/gaurav-sarma-s-blog.md>)

Topics: [C](<https://devfeed.tech/topics/c.md>), [Network](<https://devfeed.tech/topics/network.md>), [Parser](<https://devfeed.tech/topics/parser.md>), [Code](<https://devfeed.tech/topics/code.md>), [Ethernet](<https://devfeed.tech/topics/ethernet.md>)

Tags: [c](<https://devfeed.tech/tags/c.md>), [capture](<https://devfeed.tech/tags/capture.md>), [code](<https://devfeed.tech/tags/code.md>), [ethernet](<https://devfeed.tech/tags/ethernet.md>), [filter](<https://devfeed.tech/tags/filter.md>), [gcc](<https://devfeed.tech/tags/gcc.md>), [how-to](<https://devfeed.tech/tags/how-to.md>), [network](<https://devfeed.tech/tags/network.md>), [ssh](<https://devfeed.tech/tags/ssh.md>)

## AI overview

A tutorial on implementing a packet sniffer and parser in C using libpcap. It explains how to capture live network traffic or read pcap files, apply Berkeley Packet Filters, and parse Ethernet, IP, and TCP headers.

## Source excerpt

This post will cover a concise implementation of how to open live pcap sessions on any network device and reading the incoming packets on that interface. In the end, the post will display how to parse the packets appropriately to get the required information...