How can I read IP Datagram?

B

babakandme

How can I read IP Datagram? Should I write some Driver for that? Is
there any special book about it?
Thank you.
 
G

Gianni Mariani

How can I read IP Datagram? Should I write some Driver for that? Is
there any special book about it?
Thank you.

The is off topic and platform specific.

google for "UDP send recv socket select C++" - see what you get.

There are plenty of libraries that you can use - commonc++, austria C++,
ACE, that hide most of the platform dependant stuff.

I don't know of any standardization work for C++ with sockets, although,
that would be very very useful.
 
P

peter koch

The is off topic and platform specific.

google for "UDP send recv socket select C++" - see what you get.

There are plenty of libraries that you can use - commonc++, austria C++,
  ACE, that hide most of the platform dependant stuff.

I don't know of any standardization work for C++ with sockets, although,
that would be very very useful.


Theres boosts asio, which I guess is as close as it gets. I do not
know if it supports UDP.

/Peter
 
L

Lars Uffmann

How can I read IP Datagram? Should I write some Driver for that? Is
there any special book about it?
Thank you.

I think your best bet is the sockets library. On Linux that's (as far as
I got around to use it) the same interface as winsock on Windows Systems.

Some links that may help you:
C++ Socket library tutorial:
http://www.alhem.net/Sockets/tutorial/using.html
Beej's Guide to Network Programming:
http://beej.us/guide/bgnet/output/html/multipage/index.html

Best Regards,

Lars
 
S

szybki

I think your best bet is the sockets library. On Linux that's (as far as
I got around to use it) the same interface as winsock on Windows Systems.

Some links that may help you:
C++ Socket library tutorial:http://www.alhem.net/Sockets/tutorial/using.html
Beej's Guide to Network Programming:http://beej.us/guide/bgnet/output/html/multipage/index.html

Best Regards,

Lars

You guys talk about using transport layer mechanisms (TCP/UDP), but
babakan asked about IP (network layer) datagrams. A far as I know it
is impossible to access IP layer datagrams with socket mechanisms
directly. Not that I know how to do it other way:)
 
L

Lars Uffmann

szybki said:
You guys talk about using transport layer mechanisms (TCP/UDP), but
babakan asked about IP (network layer) datagrams.

Oops, sorry - forgive my ignorance - only just entered the topic this
year - wasn't aware that sockets was limited to the higher layers.

Thanks for pointing that out & Best Regards,

Lars
 
B

bjeremy

You guys talk about using transport layer mechanisms (TCP/UDP), but
babakan asked about IP (network layer) datagrams. A far as I know it
is impossible to access IP layer datagrams with socket mechanisms
directly. Not that I know how to do it other way:)

Raw sockets send/recv at the ip layer. You can also use a datalink
socket to read all ip packets of a particular (or all) interfaces.
Linux native sockets api is written in C. There are a lot of C++
adapters out there on the web as earlier posts mentioned. If you are
interested in IP layer packets you need an implementation that
supports raw sockets. If you are using a particular transport layer
(tcp,udp) you'll need to create a raw socket and use the ip_hdrincl,
you will probably have difficulties setting up a tcp socket this way,
unless you have a stack that does the sequencing for you, but for udp
it fairly trivial.
 
G

gpderetta

Oops, sorry - forgive my ignorance - only just entered the topic this
year - wasn't aware that sockets was limited to the higher layers.

Actually the BSD socket interface allows access to the raw packet
data, allowing arbitrary composing all kind of IP packets.
I even think that posix standardized the API. I'm not sure that there
is any C++ api that allows it. I would bet on ACE though.

HTH,
 
J

Jerry Coffin

[ ... ]
You guys talk about using transport layer mechanisms (TCP/UDP), but
babakan asked about IP (network layer) datagrams. A far as I know it
is impossible to access IP layer datagrams with socket mechanisms
directly. Not that I know how to do it other way:)

RTFM for SOCK_RAW.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
474,183
Messages
2,570,967
Members
47,517
Latest member
Andres38A1

Latest Threads

Top