Peer Name Resolution Protocol Sample

The Peer Name Resolution Protocol (PNRP) Sample Application demonstrates the use of a subset of the Peer-to-Peer APIs centered around the Peer Name Resolution Protocol.

 

While using this application, one caveat to keep in mind is that you cannot resolve a name that is registered within the same process.

 

Platforms supported

·         Windows Vista (except Starter Edition)

·         Windows 7

 

To Build:

·         In an SDK command shell, navigate to the directory containing this sample and run "nmake"; or

·         Launch the .sln file in Visual Studio .NET

 

 

To Run:

·         Type pnrp.exe (located in the Vista_DEBUG or WIN7_[ARCH]_DEBUG folder in the directory containing the sample)

·         Follow the menu options.  To get started, try executing the following scenarios:

1. Register an address

a)    Launch the PNRP application on a computer with global IPV6 connectivity.

b)    Select Option 1 to register a peer name.

c)    Select to use default addresses and then to register in all clouds.

d)    Optionally, enter some free text for the comment and payload.

e)    Select “no” when prompted if this is to be a secured peer name

f)     Enter in a text string when prompted for the classifier. e.g. "pnrpsampletest".

g)    IMPORTANT: Leave the application running while completing the next scenarios.  The names you registered will be deleted once the application is closed.

2. Resolve an address using the PNRP sample

a)    After running the above scenario and leaving the application running, launch a second instance of the PNRP application on the same computer.

b)    Select Option 2 to resolve a peer name

c)    Select to resolve from all clouds.

d)    Select “no” when prompted for a synchronous resolve.

e)    Enter in the peer name to resolve.  The peer name you should resolve is “0.<the string registered in scenario 1>”, e.g. "0.pnrpsampletest". The “0.” is prefixed to the name because it was registered as an unsecured peer name.

f)    Since you registered in all clouds and also resolved in all clouds, two resolution results returned - one for the global cloud and one for your link local cloud. More than two results returns if your computer has more than one network connection, meaning that there is more than one link local cloud.  Since you registered using default addresses, the link local cloud resolution returns your link-local IPv6 address while the global cloud resolution returns your global addresses, likely an IPv6 global address and also an IPv4 global address.

g)     Repeat the resolution scenario using a separate computer that is on the same IPv6 subnet and then a computer connected elsewhere in the IPv6 Internet.

3. View the DNS encoded name

a)    Launch the PNRP application on a computer with global IPV6 connectivity.

a)    Select the 'Show DNS encoded name' option.

a)    Enter a Peer Name (for example, 0.pnrpsampletest, registered from Step 1).

a)    Observe the DNS encoded name (for example, pnrpsampletest.pnrp.net). The DNS encoded name allows PNRP names to be used in ANY application that calls GetAddrInfo to perform name resolution (and that is just about every application). If the name is registered, try using the DNS encoded form of the name in ping or Internet Explorer.

4. Resolve an address using ping

a)    Open a command prompt (on a Vista or Windows 7 computer)

b)    Type “ping <the string registered in scenario 1>.pnrp.net” (for example, "ping pnrpsampletest.pnrp.net").

c)    "pnrp.net" is a reserved domain name in Windows Vista and Windows 7 and the lookup will be performed through PNRP rather than DNS.

d)    You should see that ping successfully resolves the IP address you registered and pings your computer

e)    This works with any application that performs name resolution using GetAddressInfo (or any higher level API that in turn uses GetAddressInfo).  This effectively means almost any application!  If you have a web server running on the machine that registered the name open Internet Explorer and browse to the website using the PNRP name rather than the DNS name!