Browse All Articles > Using libpcap/Jpcap to capture and send packets on Solaris - Part 1
Using libpcap/Jpcap to capture and send packets on Solaris version (10/11)
Library used:
1. Libpcap (http://www.tcpdump.org) Version 1.2
2. Jpcap(http://netresearch.ics.uci.edu/kfujii/Jpcap/doc/index.html) Version 0.6
Prerequisite:
1. GCC
2. Make
Notes:
1. Verify if these software’s are installed by writing #gcc and #make at the command prompt.
2. See appendix to install these software.
Libpcap (version 1.2)
This section (Marked in italcs) can be skipped if OS is solaris 10.
In case of Solaris 11 the configuration doesn’t work properly so do the following.
1. config.h
Replace the following line
/* define if you have a cloning BPF device */
#define HAVE_CLONING_BPF 1
With
/* define if you have a cloning BPF device */
/* #undef HAVE_CLONING_BPF */
Replace the following line
/* #undef HAVE_DLPI_PASSIVE */
With
#define HAVE_DLPI_PASSIVE 1
Replace the following line
/* Define to 1 if you have the <netpacket/packet.h> header file. */
#define HAVE_NETPACKET_PACKET_H 1
With
/* Define to 1 if you have the <netpacket/packet.h> header file. */
/* #undef HAVE_NETPACKET_PACKET_H */
Replace the following line
/* Define to 1 if you have the <sys/bufmod.h> header file. */
/* #undef HAVE_SYS_BUFMOD_H */
With
/* Define to 1 if you have the <sys/bufmod.h> header file. */
#define HAVE_SYS_BUFMOD_H 1
2. MakeFile
Replace
INSTALL = /usr/bin/ginstall –c
With
INSTALL = ./install-sh -c
Replace the following lines
PSRC = pcap-bpf.c
FSRC = fad-getad.c
SSRC =
With
PSRC = pcap-dlpi.c
FSRC = fad-glifc.c
SSRC = dlpisubs.c
Specific to Solaris 11 - End
1. Write a program to capture packets for a given network interface card.
2. Write a program to broadcast packets through a given network interface card.
3. Verify packets using snoop –d <NetworkInterfaceName> command.
Common Errors:
1. Check LD_LIBRARY_PATH It should be set to where shared library is installed.
JPCap
Jpcap is a Java library for capturing and sending network packets. It internally uses libpcap/winpcap.
1. Replace the word “ifr.ifr_ifrn.ifrn_name” with “ifr.ifr_name”
2. Replace the word “ifr.ifr_ifru.ifru_hwaddr.sa_data” with “ifr.ifr_ifru.ifru_enaddr”
Compile all the programs in sample directory and verify running each of them.
Exercise:
1. Write a program to capture packets for a given network interface card using Jpcap.
2. Write a program to broadcast packets through a given network interface card using jpcap.
There were lots of questions floating around in various forums revolving around installation of libpcap / jpcap. The software is well documented for OS like Linux and windows, but no documentation for solaris and the Google was not enough so here is my attempt to provide installation guide for both libpcap and jpcap on solaris in particular.
In this article which is Part 1 is an installation guide with few exercise. In Part 2 of this article i will discuss Ethernet frame, packet capture/send over Ethernet with examples
Please feel free to ask any questions based on this article or in general issues regarding libpcap/jpcap. I would also appreciate comments by subject area experts in these software.
Have a question about something in this article?
You can receive help directly from the article author.
Sign up for a free trial to get started.
Comments (1)
Author
Commented:In this article which is Part 1 is an installation guide with few exercise. In Part 2 of this article i will discuss Ethernet frame, packet capture/send over Ethernet with examples
Please feel free to ask any questions based on this article or in general issues regarding libpcap/jpcap. I would also appreciate comments by subject area experts in these software.