In every layer, a packet has two disjoint sections: Header and Payload.
non-Raw socket means you can just determine Transport Layer Payload. i.e it is the OS' task to create the Transport, Network, and Data Link layer headers.
Raw socket means you can determine every section of a packet, be it header or payload. Please note that raw socket is a general word. I categorize raw socket into: Network Socket and Data-Link Socket (or alternativly L3 Socket and L2 Socket).
In L3 Socket you can set the header and payload of a packet in the network layer. For example: if a network layer protocol is IPv4, you can determine the IPv4 header and payload. Thus you can set the transport layer header/payload, ICMP header/payload, Routing Protocols header/payload, ... .
In L2 Socket you can set the header and payload of a packet in the data link layer, i.e everything in the packet. Thus you do everything done with L3 Socket + determine ARP header/payload, PPP header/payload, PPPOE header/payload, ... .
Now in programming:
- socket(AF_INET,RAW_SOCKET,...) means L3 socket , Network Layer Protocol = IPv4
- socket(AF_IPX,RAW_SOCKET,...) means L3 socket , Network Layer Protocol = IPX
- socket(AF_INET6,RAW_SOCKET,...) means L3 socket , Network Layer Protocol=IPv6
- socket(AF_PACKET,RAW_SOCKET,...) means L2 socket , Data-link Layer Protocol= Ethernet
The third parameter specify the payload protocol.