Networking Forums

Networking Forums > Computer Networking > Linux Networking > libpcap problem (hdr.len vs tcpdump file size)?

Reply
Thread Tools Display Modes

libpcap problem (hdr.len vs tcpdump file size)?

 
 
D
Guest
Posts: n/a

 
      10-26-2003, 11:16 PM
Hi,

I'm trying to use libpcap to output tpcdump raw data that I've
captured in a file.
here's the info of the tcpdump file:
-rw-r--r-- 1 david david 1042 Oct 26 01:36 tcpdump.out

now, when I use my code to capture the packets in that file and
directly printing them out, the output of this code is somehow larger
than the actual dump file.
Here's my (C++) code:

-------------
#include <iostream>
#include <netinet/in.h>
#include <linux/inet.h>
#include <netinet/if_ether.h>
#include <pcap.h>
#include <fstream>



int main(){

using namespace std;
ofstream fout;
fout.open("pcaptest.out");
char errbuf[PCAP_ERRBUF_SIZE];
pcap_t *descr= pcap_open_offline("/home/david/tcpdump.out",
errbuf);
const u_char * packet;
struct pcap_pkthdr hdr;

packet = pcap_next(descr, &hdr);
while (packet){

unsigned packetSize= hdr.len;
for (unsigned i=0; i< packetSize;i++){
fout<<packet[i];
}

packet = pcap_next(descr, &hdr);

}

return 0;
}
--------------------------------

and here's the info on the output file:
-rw-r--r-- 1 david david 1508 Oct 26 01:36 pcaptest.out


How come the size of the output file does not match the actual dump
file at all? And furthermore, how come the it's larger in size?

any help/comment is appreciated.

thanks in advanced!
-D
 
Reply With Quote
 
 
 
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
File Copy Windows -> SMB Linux; File size problem Publishers Press Windows Networking 0 10-23-2008 06:05 PM
file shares not accessible via vpn because of MTU size sumGirl Windows Networking 1 03-02-2007 10:12 PM
monitoring file transfer with tcpdump Eugenio Milas Linux Networking 2 06-27-2004 10:33 PM
File transfer size. Zboing Mouflon Windows Networking 4 12-03-2003 11:12 AM
libpcap problem (hdr.len vs tcpdump file size)? D Linux Networking 3 10-30-2003 03:35 AM



1 2 3 4 5 6 7 8 9 10 11