Subject: Re: Futher clarification needed-- Un-numbered point to point. dou bt

From: "Naidu, Venkata" <[email-masked]>
Date: Fri, 7 Mar 2003 16:11:49 -0500

Kamatchi,

->  Thanks for ur inputs. But, would u think using a dedicated
-> socket for each interface is advisable?

  Now you are asking real internals. That is the trade-off
  (optimization) you have to make. Let me give some hints:

  - Performance: most of the operating system IP stacks use
    (some kind of) hashing to *find* the appropriate socket
    or fd for the incoming packets (except in few cases: Raw
    IP unicast etc). Kernel figures out Raw IP multicast, UDP
    (unicast & multicast) and TCP sockets pretty quickly using
    hashing in the order of O(1) average time. So, having lot of
    sockets won't hit the performance that much.

  - System Resources: if there are large number of interfaces
    (in the order of 4k) then, more sockets (actually fds) one
    per interface is not advisable. Why? Mostly, the fds space
    is shared by different applications (look at select call -
    one can do select fd_set on any kind of fd - file/socket
    etc). You will be wasting lot of system resource (for
    example, each socket will have send and receive buffer
    space etc etc). So, having lot of sockets is going to hit
    resource usage.

  - On the other hand, if you use shared sockets, then I can
    easily imagine that you are using IP_HDRINCL option (ie.,
    building IP header your own instead in the kernel). Then
    you must be going for a route table lookup for each and
    every packet - including multicast packets. If we assume
    that the routing table is radix/patricia tree, then there
    must be some logarithmic average time search. All the above
    processing can be avoided if you use socket per interface.

  - The best solution is, use shared sockets if you are going
    to run OSPF on large number (order of 4K) of interfaces.
    Otherwise, use one socket per interface.

->  Especially in my environment, i do have 63 un-numbred
-> pt-to-pt interfaces and only one Lan interface. And i do have
-> only one valid global IP address that too for the LAN.

   Again, whether you have one global IP address *or*
   one IP address per interface is irrelevant in the current
   context. Which IP address you are going to use as the
   source address of the packet is *not* the issue here. The
   real issue you have to solve is, "how can I send the packet
   out on the desired outgoing interface?"

->  If there is any other method to solve this problem, it would be
-> appreciable.
->
-> Btw: Ofcourse, the other method that would think is, having
-> a queue and
-> event communication between IP and OSPF. But it needs much
-> modification in
-> my stack especially at IP point of view...

   Don't complicate things. Just try to figure out how best you
   can send the packet out using all the information you have
   (including different socket options etc etc)

Venkata.