Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Socket programming at low level

Tags:

c

unix

sockets

I am unable to understand or grasp rather; what it means to program at a lower layer in socket programming. I am used to working with tcp/udp/file system sockets. These are all wrapped around their own protocol specifications ... which as i understand would make it working at the application layer in the stack.

In the project i am on , i have seen some files which are "named" LinkLayer, TransportLayer... but i don't see any more calls other than standard socket calls....send /recv/ seletct...

Does the fact you are setting a socket options mean you are programming at a lower level ? Is it just restricted to it? Or are there other API's which grant you access at the representation in kernel ?

like image 497
Ricko M Avatar asked Aug 19 '10 12:08

Ricko M


People also ask

Which socket is used for lower level communication?

Available only to individuals with root user authority, a raw socket allows an application direct access to lower-level communication protocols.

What is socket level programming?

Socket programming shows how to use socket APIs to establish communication links between remote and local processes. The processes that use a socket can reside on the same system or different systems on different networks. Sockets are useful for both stand-alone and network applications.

Is socket programming still used?

Most current network programming is done either using sockets directly, or using various other layers on top of sockets.

What is low level networking?

At the lowest level, the network protocol is handled by BSOCK packets which contain a lot of information about the status of the network connection: who is at the other end, etc. Each basic Bacula network read or write actually consists of two low level network read/writes.


2 Answers

Typically this refers to using SOCK_RAW sockets, which requires you to assemble your own packet headers, calculate checksums, etc. You still use send/recv/etc. but now you are responsible for making sure every bit is in the right place.

You can use SOCK_RAW sockets to implement protocols other than TCP or UDP, or to do things with the Internet protocols that higher-level interfaces don't accommodate (like tweaking the TTL of your packets to implement something like traceroute).

like image 196
Kaelin Colclasure Avatar answered Oct 05 '22 13:10

Kaelin Colclasure


This usually means working on a lower OSI-Layer, for example, not directly sending TCP-streams or UDP-packets, but crafting own IP or even Ethernet packets or other low-layer protocols which would - in normal case - be handled by the operating system.

This can be done done via specific socket options which enable you to receive or send data on any layer, even layer 2 (Data Link).

like image 39
Emiswelt Avatar answered Oct 05 '22 13:10

Emiswelt