P2P Revisited

So I want to start kicking the P2P SDK around again. However, most of my work to date is on my busted laptop that I am still waiting to get fixed. Rather than reinvent the wheel, I started looking at wrapping two other relevant SDKs: IP Helper and Internet Connection Sharing & Firewall. IP Helper allows access to the network configuration of the local computer (including IPv6 settings). ICS/F allows you to programmatically manage XP’s NAT and firewall functionallity (including the IPv6 firewall). Both are relevant to P2P due to the management of IPv6.

I’m not sure why these systems have a custom API instead of just using WMI, but they do. So I’m looking to wrap them either in managed code or WMI (which is then available to managed code via System.Management).

UPDATE: MSFT just published a document about the new Windows Firewall in XP SP2. One of the big new features is the ability to configure the firewall at the global scope., though you can still specify connection settings which override the global settings. SP2 also includes the IPv6 firewall that is a part of the Advanced Networking Pack (which may mean that the P2P infrastructure is baked into SP2). I’m sure this will imply changes to the ICF API.

UPDATE 2: I finally got my laptop back today, and I found my previous P2P work. I hope to kick some code around over the holidays.

Links relevant to P2P

My contact on the P2P team just gave me two more important links for the construction of IPv6 based P2P apps. The first is IP Helper, a library included with XP that “enables the retrieval and modification of network configuration settings for the local computer”. I had never seen that library before, but it’s full of useful methods like GetAdaptersInfo and GetAdaptersAddresses. I want to be able to retrieve the IPv6 address of my NICs directly, so this is the library I need. Anyone out there wrapped it in managed code yet? I was hoping to do this part with WMI, but the IPv6 info doesn’t seem to be exposed via WMI.

The other relevant link is the IPv6 Internet Connection Firewall SDK, which “contains all the software required to configure the IPv6 Internet Connection Firewall”. I assume that means that I can open relevant ports to enable P2P communication. As I wrote yesterday, the issue I’m having with GraphChat is likely related to the IPv6 Firewall configuration. I’d like to include in my P2P managed library the ability to manage the IPv6 Firewall.

P2P Problems Solved

Someone from the P2P team internally saw my blog and set me a list of commands to execute and send back to him to help troubleshoot my problem. One of those commands was “net start pnrpsvc”. Aha! I hadn’t realized that the WinXP Adv. Networking Pack installed any services. Turns out it installs four, including the “Peer Name Resolution Protocol” service (i.e. pnrpsvc). What’s odd is that now that I’ve started it manually once, it seems to autostart on demand now. I can resolve addresses, as well as ping the seed server. GraphChat doesn’t work yet, but I think that’s because the IPv6 firewall only has two ports open by default – PNRP (UDP 3540) and Grouping (TCP 3587). The GraphChat sample uses a dynamically chosen port, which would be blocked.

So now that I’m back on track, I’ve got the PNRP namespace provider API wrapped in Managed C++. I can register, unregister, resolve and enumerate PNRP clouds from managed code. I’ve also got a first pass of the Identity Manager API and a skeleton of the Graphing API done. I’ll post code when I have a managed GraphChat sample working.

More on P2P Problems

I discovered a FAQ for the WinXP Advanced Networking Pack Among other FAQ’s (including “What is a F.A.Q.?”) are “What is a PNRP seed server?” and “How do I know if I can contact the Microsoft hosted PNRP seed server?”. A seed server is a bootstrap for a PNRP “cloud”. PNRP is supposed to be serverless, but there has to be some way for the system to be bootstrapped. MSFT runs a seed server at a well known address (well known to the P2P system, since no one told me). To see if you can reach said seed server, you can run “netsh p2p pnrp diag ping seed”. If the number is one or greater, all is good. In my case, that command raises Error 0x800706d9: “There are no more endpoints available from the endpoint mapper”. I’m not sure what that means, but I’m guessing that explains why I can’t resolve PNRP names.

Problems with P2P SDK

Has anybody gotten the P2P SDK to work? I’ve been playing with it, working on ideas for wrapping it in managed code. I’ve actually got classes wrapping the Identity Manager and PNRP Namespace APIs as well as a start on the Graphing API. Due to the nature of the SDK, I’ve been writing in Managed C++. While tricky and not as much fun as writing C#, MC++ is pretty cool. Wrapping the P2P SDK with MC++ has been much easier than I expected. Except for one problem – I can’t seem to get PNRP to work. Even the GraphChat demo doesn’t work for me.

PNRP stands for the Peer Name Resolution Protocol. It is supposed to be a serverless DNS system. It allows me to register a peer name for later look up and resolution. I can register and unregister a peer name and endpoint. It even throws and exception if I attempt unregister without registering first, so something must be happening. But I can’t resolve the peer name to an address. And it’s not just my code (which is copied near verbatim from the help files), the sample GraphChat app doesn’t seem to work either. I’m attempting to register in the default “global” cloud as is the GraphChat sample, but no luck.

Just chatted Scoble on this – since he was so excited when we released it. As a fellow evangelist, he is willing to put me in touch with the powers-that-P2P. However, I’d appreciate hearing any other “war stories” out there.