Capturing network packets for use in userland application - TCPDUMP?

Hi,

I want to be able to capture packets from my network to use as input for a program i am writing. the program will dessimate the packet and use different parts of it so i need the packet in a usable format.  Can i do this with TCPDUMP?  I tried with  tcpdump -x -s 0 -i lo -w pkt -c 1, but the output from pkt looked like

\324\303\262\241^B^@^D^@^@^@^@^@^@^@^@^@\377^@^@^A^@^@^@\327Y\326?\254.^K^@W

etc

the full output cut & pastes like

Ôò¡

Any pointers?
dtodAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

asbharadwajCommented:
Hi
>> i need the packet in a usable format
What do u exactly have in mind?

the -w option causes tcpdump to dump the raw packets to the specified file and exit
You can directly redirect the output of tcpdump to a file and read it later on in your
program
The -v option gives you verbose output and the -vv option gives you even more verbose output

You can also read the packet information from the dump file you generated using the -w
option
inorder to do that you'll have to use the -r filename option.
Your program needs to have a good understanding of the protocol it is looking for
to make good use of the tcpdump output
you'll also have to do a lot of string processing if your program is written in C or something like that
whereas a program written in something like perl will find a lot easier for this purpose

refer the tcpdump man page for more options
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
ahoffmannCommented:
tcpdump write packets in a *usable* format. Dot.
The problem seems to be that *your* definition of usable is different to that from tcpdump.
So you first need to define, means: tell us, what a usable format is for you.
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Linux Networking

From novice to tech pro — start learning today.