Re: Networks and wireless etc

Tech-Archive recommends: Repair Windows Errors & Optimize Windows Performance



"Eugene Gershnik" <gershnik@xxxxxxxxxxx> wrote in message
news:OVg$0N3eFHA.3280@xxxxxxxxxxxxxxxxxxxxxxx
> Alun Jones [MSFT] wrote:
>> "Eugene Gershnik" <gershnik@xxxxxxxxxxx> wrote in message
>> news:etrta3CeFHA.2688@xxxxxxxxxxxxxxxxxxxxxxx
>>> Simon Jefferies wrote:
>>>> Hello,
>>>>
>>>> Please can you tell me if I'm doing this right or not?
>>>>
>>>> I'm trying to get winsock to use the relevant network adapter to
>>>> connect to an IP address. I have enumerated the list of devices and
>>>> have e.g. network card, wireless network and loopback (using the
>>>> GetAdaptersAddresses() WIN32 function). Do I simply use the SOCKADDR
>>>> structure?
>>>
>>> bind() to a sepcific local address before connecting.
>>
>> Binding will not directly affect which NIC is chosen to route outgoing
>> traffic.
>>
>> Changing the information in the routing table will do that. Binding
>> is only an association between an IP network interface and a socket;
>> while that IP network interface is associated with a NIC, the NIC
>> that is chosen to send a packet out on depends on the _destination_
>> of that packet.
>
> So what interface is SYN-ACK going to come from? That is are you saying
> that I can bind to 127.0.0.1 and have packets delivered to me that arrived
> on 192.168.2.1? The way I see it you need *both* to bind correctly and
> have a workable routing table.

Here's a routing table entry that shows what happens for 127.0.0.1:

127.0.0.0 255.0.0.0 127.0.0.1 127.0.0.1 1

Note that the metric is "1". No other entry in the routing table has a
lower entry, so _all_ packets destined for 127.*.*.* (or 127/8 if you prefer
CIDR format) will go through the NIC associated with interface 127.0.0.1.

If you bind a socket to a particular IP address, that will be the source
address indicated in outgoing packets on that socket, and must be the
destination address on incoming packets for that socket. However, outgoing
packets will go out whichever NIC is the "closest" (by metric) and "most
exact match" for network destination in the routing table, regardless of the
source address.

127.0.0.1 is a bad example, because you should never receive packets from
outside destined for that address. But, example or not, it still follows
the same rules. A better question to match your concern is "if I bind to IP
address 10.0.0.1, which is an address of a real NIC on my machine, and send
to 127.0.0.1, will there be any network traffic generated?" Clearly, the
answer is "no - the destination address is internal, so no network traffic
will be generated".

Alun.
~~~~
--
Software Design Engineer, Internet Information Server (FTP)
This posting is provided "AS IS" with no warranties, and confers no rights.


.



Relevant Pages

  • Re: 6.x, 4.x ipfw/dummynet pf/altq - network performance issues
    ... to kill a 6.x box doing routing. ... >> Send a flood of 60 byte syn packets with the tcp sack option thru ... If you block the packets on the box via ipfw it's fine, ... > I'm not a network guru, and haven't done much in the way of ...
    (freebsd-performance)
  • Re: all traffic goes via eth0.. why?
    ... which 7 are all posted as the same network. ... This is completely useless and ... Only one will be used to send out packets, ... Kernel IP routing table ...
    (alt.os.linux.suse)
  • ip routing
    ... i have a problem with ip routing! ... that each packet received on Tux1/eth1 will also be ... received packets came from a different network and therefore the replies ...
    (Linux-Kernel)
  • Re: ip routing
    ... "Routing" means to send network packets from one network to another ... send packets that it receives on one network connection to its other ...
    (microsoft.public.windowsxp.network_web)
  • Re: BIND 9 on a dynamic ip address
    ... Andrew P. wrote: ... All I am looking to do is to use bind for hosts in my network ... configuring a DNS server ...
    (freebsd-questions)