Monday, February 18, 2013


Yup. Harassed.

Proper stressed out.

We found a problem today. An issue with dialling into a remote device running Windows CE6.

The device is running the out-of-the-box RAS server with a custom configuration/launcher. There are some minor issues with the launcher, but mainly that's fine. Which is a massive relief! We won't have to update all of the remote devices.

No, the problem is on the server which does the dial-up. Yes, I know this architecture is backward. The server? Dialling up? WTF?

Legacy stuff - just live with it.

The dial-up server was only able to keep one connection active at once! It could dial two or more, but you could only get IP traffic through the latest connectoid to answer. A wee bit of a problem! We absolutely need to able to connect to many devices concurrently.

This is a fairly large problem waiting to get bigger and uglier. I can think of a few things that fit into that category.

Apparently, the problem lies with the routing table. Heh - go figure.

The routing table maps potential IP end points with network interfaces. Each table entry can be wide or narrow depending upon the subnet mask. Full mask - narrow address range. Empty mask - HUGE address range.

By default, the RASDial function connects to the remote device and sets up some entries in the routing table. Very helpful of it? Nope - not in this case. Pretty much just remove all the entries that were automatically added. And add your own.

If you don't manage the routing manually, then when a new connection is made, you lose traffic to all the previous ones.

All you need is a single entry that maps the new remote server IP address with a subnet of to a gateway with the same IP address. And you can do that with the 'ROUTE' command line utility.


The operating system references each network adapter with an index number. You will need this when adding a new route. It essentially routes the new traffic via that network adapter. An active RAS connectoid is classed as a network adapter.

For example.


removes the ridiculously wide default address range route for the RAS connection on


adds the route you need to map all traffic to so it gets to the RAS server (assuming network interface index 3 - the 'IF' parameter).

Finally, you should remove the route with destination ''.

Neat eh?

In code, you can do this by spawning a process with the appropriate ROUTE command line, using WMI (Win32_IP4RouteTable) or with API calls (IPHlpApi.dll).

I found the former the quickest and most reliable implementation.

So I'm not as harassed now.

[Update] One thing to be wary of. For any of these options to work, the application has to be running as administrator. If you're using the option that launches the command line utility, set the Verb member of the ProcessStartInfo structure to 'runas'. You'll find, however, that the UAC dialog keeps popping up. It is possible to force the UAC to popup just once when the program starts by changing the application manifest file. The process that you spawn can also be created without using ShellExecute which bypasses the UAC checks completely (ProcessStartInfo.UseShellExecute = false). However, I just could not get that to work at all! Maybe you'll have better luck.

No comments:

Post a Comment