I am wondering how do all the networking dance components work: How can I program/read/write/access raw and parsed data in:
RAW sockets allow you to modify all the above. Amazing examples can be found here. As you can see you can modify all the layer, but you must do all the parsing and processing yourself. Using UDP as an example:
Layer 4 - you must either parse or create the UDP Header
Layer 3 - You must either parse or create the IP Header
Layer 2 - You must either parse or create the Ethernet Header
Layer 1 - Write to or Read from the interface you opened the socket on