Category Archives: Coding

All kinds of Programming.

Get local ip in C on linux

By | December 20, 2011

Local Ip address The local ip is the source ip in IP packets send out from a system. When the system is a part of a local area network then the local ip in most cases is something like 192.168.*.* . The network interface (eth0) is assigned an ip address of that range. However when… Read More »

Code a packet sniffer in C with winpcap

By | December 18, 2011

Winpcap Winpcap is a packet capture library for Windows used for packet sniffing and sending raw packets. Wireshark is a popular sniffer tool that uses winpcap to sniff packets. Here is a sample code which shows how winpcap can be used to sniff incoming packets on a particular interface. Code Compile The code can be… Read More »

Get ip address from hostname in C using Linux sockets

By | December 10, 2011

Socket applications often need to convert hostnames like to their corresponding ip address. This is done through dns requests. The socket api in linux provides functions like gethostbyname and getaddrinfo that can be used to perform the dns requests and get the ip address. gethostbyname The first method uses the traditional gethostbyname function to… Read More »

Code a network packet sniffer in python for Linux

By | November 29, 2011

Basic Sniffer Sniffers are programs that can capture/sniff/detect network traffic packet by packet and analyse them for various reasons. Commonly used in the field of network security. Wireshark is a very common packet sniffer/protocol analyzer. Packet sniffers can be written in python too. In this article we are going to write a few very simple… Read More »