Re: Historical question

From: Robert Bonomi (bonomi_at_host122.r-bonomi.com)
Date: 06/22/05


Date: Tue, 21 Jun 2005 23:39:53 -0000

In article <slrndbfcgh.dja.mordor@fly.srk.fer.hr>,
Zeljko Vrba <mo.dor@fly.srk.fer.hr> wrote:
>I'm wondering just out of curiosity.. Why was it decided that NICs don't have
>an entry in /dev but to be configurable by ifconfig?
>
>And why don't all sockets (irrespective of domain) have some kind of a vnode
>in a (synthetic) filesystem? It would be great for debugging sometimes just
>to be able to inject data to socket by doing something like
>cat smth > /sockets/ipv4/... It doesn't even work for UNIX sockets which DO
>have a file-system inode..
>
>Another use would be for sniffing traffic by doing cat on the socket. Without
>such facility we need specialized tools like tcpdump.
>
>I'm not proposing an implementation. Just asking for the historical reason
>for this unorthogonality.

"Because." *grin*

Get ahold of the book "The Design of the BSD 4.4 Operating System", if you
want some insight into many of the design decisions.

I *don't* _know_, 'why', but I suspect that it had to do with the
scale/complexity of things to be supported.
you have to have:
   1) a destination address of some sort
   2) a protocol specification, do determing 'content' formatting,
   3) a message 'sub-type', and/or a 'port' address.

Over-and-above the 'gory details' of the physical interface layer.

contemplate the situation where a host may have multiple NICs, and you
find it requies 5 elements to uniquely identify a 'connection' just in IP
address-space.
       source IP address,
       source port,
       protocol,
       destination IP address,
       destination port

IP addresses are 32 bits each. ports are 16 bits each, and there is 8 bits
for 'protocol' identifier. This is 104 bits of 'identifier'.

Without considering 'what to do' if you want to speak something other than
IP -- e.g. DECnet, SNA, XNS, LU6.2, NetBios, etc.

(at the 'device driver' level, you've only got 'major ID', "minor ID" fields
'unit' and 'inode' to identify 'unique' items within the device.
Postulating you use 'MajorID' to indicate addressing 'family' (IP, XNS, SNA,
etc.) and 'minorID' for protocol family (e.g. for IP, UDP, TCP, ICMP, IGRP,
etc.) you have to have _at_least_ 96 bits in the 'inode', to uniquely identify
IP connection. For some of the other protocols, with larger address-spaces,
it is even worse.

_Enumerating_ that in a filesystem structure would consume *exhorbitant*
amounts of resources.

Also, by standard implementation, filesystem resources are 'shared access'
multiple users can read/write to the same file simultaneously.

'Sockets', on the other hand, are designed/implemented as 'exclusive access'.

Then there is the 'minor' question of what any of the standard filesystem
operations would "mean", when applied to a 'socket'-type connection.
What does a "rename" do? What happens if you "move" it to a different
place in the file-system hierarchy? What does a "delete" do? If you
'delete' the socket from the filesystem, _while_you_still_have_it_open_,
can somebody else create a socket with the same name -- and if so, do they
get access to the same resource, or a different one?

The theory looks nice. implementation gets *very* messy. <wry grin>



Relevant Pages

  • HEADS UP: network stack and socket hackery over the next few weeks
    ... Over the next few weeks, I'll be doing a fairly serious workworking of the socket and protocol reference models, in order to clean up a number of long-standing race conditions and provide infrastructure for significant locking optimizations for several protocols (including TCP). ...
    (freebsd-current)
  • Re: socket arguments
    ... a protocol argument of zero means unspecified. ... socket type, protocol) parameters. ... ProviderFlags: MatchesProtoZero ...
    (microsoft.public.win32.programmer.networks)
  • Re: CAsyncSocket on vista
    ... The error you are getting is WSAEAFNOSUPPORT - Address Family Not ... Perhaps when you are setting up your socket you are not initialising all ... WSAEAFNOSUPPORT Address family not supported by protocol family. ... Conversation: CAsyncSocket on vista ...
    (microsoft.public.vc.mfc)
  • Re: sosend/soreceive consistency improvements
    ... As part of cleanups, locking, and optimization work, I've been looking at ... protocol could provide substitute implementations. ... There's another side to the pluggability, however -- the socket consumers ... New references to sosend() and soreceiveperiodically ...
    (freebsd-arch)
  • Re: Multithread safety
    ... If your protocol is TCP, then yes, you need to reassemble the read results. ... Multiple threads writing to the same socket - now that is ... Washington WA 98072-8661 | WFTPD, WFTPD Pro are Windows FTP servers. ...
    (microsoft.public.win32.programmer.networks)