LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   diffrent between SOCK_DGRAM and SOCK_RAW (https://www.linuxquestions.org/questions/linux-newbie-8/diffrent-between-sock_dgram-and-sock_raw-828971/)

faeze kalantari 08-28-2010 05:36 AM

diffrent between SOCK_DGRAM and SOCK_RAW
 
Hi
I am confused to understand the diffrence between SOCK_DGRAM and SOCK_RAW, can you help me?
1- should i call structure sockaddr_ll for both SOCK_DGRAM and SOCK_RAW?
2- what's the diffrence between these two kind of socket creation:
a) sock = socket(PF_INET , SOCK_RAW , protocol);
b) sock = socket(PF_PACKET , SOCK_RAW, protocol);

quanta 08-28-2010 08:08 AM

http://publib.boulder.ibm.com/infoce.../skt_types.htm

faeze kalantari 08-31-2010 02:42 AM

thank you for the link. but could'nt find my answer for question 1 and 2. could you help me?

hua 08-31-2010 03:52 AM

AF_INET is the normal IP family whit this you can have TCP, UDP, or raw sockets in the classic InterNet based network (IP).
AF_PACKET is the Linux-specific packet family, designed for creating link-level packets.
With an AF_PACKET socket, you can make not only IP traffic, but anything else ...

If you capture some packet with wireshark you can see several headers in the packet:

1. Frame
2. Ethernet II
3. Internet Protocol
4. Transmission Control Protocol (or UDP)

With AF_PACKET you can handle them all.
If you use SOCK_RAW you can use your own structures for UDP and TCP packet headers.(But I think that the standard structures can be used too)


All times are GMT -5. The time now is 08:59 AM.