Hello!
I’m writing a program for a computer with multiple NICs.
The program sends tcp data on the network, but not using
the TCP/IP stack (it sends it directly to the MAC layer).
For this reason, I have a simple driver that gets a pointer
to a buffer, and sends it on the network (the buffer is the
packet + Ethernet header).
The problem is that for computers with multiple NICs,
each NIC is connected to another network, and I should
determine through which NIC the data will be sent.
In Win2000, I have the GetBestRoute() function.
The problem is on WinNT 4.0 – the function doesn’t exist there!
Does anybody know HOW GetBestRoute() works (NOT WHAT it does,
but HOW it is done internally)?
Any ideas on how I can write something similar in NT4?
thanks you ever so much,
PS: I’ve asked this question before, but I got answers that were
copied from the MSDN, stating what GetBestRoute does, and not HOW…
Barak Mandelovich xxxxx@mercury.co.il
Mercury Interactive ltd. 19 Shabazi St.
Yehud, 56100
Israel
> In Win2000, I have the GetBestRoute() function.
The problem is on WinNT 4.0 – the function doesn’t exist there!
Does anybody know HOW GetBestRoute() works (NOT WHAT it does,
but HOW it is done internally)?
I just read the documentation for that function, although I’ve never used
it. All it does is walk through the routing table, which you can look at
via the “route print” command. (You can also get it programatically with
one of the RAS/RRAS functions, but I forget which; it should be easy to find
in the SDK.)
Walking through the routing table is fairly easy, and involves comparing the
number of matched bits of your destination IP address with each of the
entries in the routing table (after being ANDed with the network mask).
Routing is really just bit matching, amazingly enough. You can find this
process in any TCP/IP book (of which the “bible” is TCP/IP Illustrated,
Volume 1 by Stevens). Or just ask any IP person to talk you through an
example.
It’s probably around 50 lines of code to duplicate that function.