Peer-To-Peer based Features in Win 7
Perhaps you watch ABC’s Extreme Makeover: Home Edition. If you do, then you may know it had a sibling show called Extreme Makeover Home Edition: How’d They Do That? It showed extra behind scenes work on how they pulled off such an amazing feat. Or maybe you are a Discovery Channel buff and find yourself watching How Its Made. If you ever wanted to know how they make common everyday items such as balloons or vegetable oil, that is the show for you. But have you ever wanted to know how your favorite Windows 7 features were made? I would like take a few moments to shed light on how two new Windows 7 features use the Microsoft Windows Peer-To-Peer network platform to provide a great end user experience. I’ll give you a brief overview of how peer-to-peer technologies solved real issues, and how you can use the features in your applications.
To start with lets reintroduce Remote Assistance. The ability to request somebody remotely to help you isn’t exactly a new feature to the windows platform. But Windows 7 has improved it by using PNRP. Windows 7 offers a new connection option called Easy Connect which is, well, an easier way to connect to your friends who can help you. Before you needed to create and email an invitation file. I always hated walking through somebody on the phone how to do that. But now when you click easy connect a series of 12 easy to read characters appears. You can read these over the phone to your expert friend helping you. The other person types them into his instance of remote assistance and the two connect like magic. Except it isn’t magic. It is PNRP. PNRP allows you to publish the endpoint of a service on the internet. In Remote Assistance’s case the service is the Remote Assistance session. The 12 characters are actually a transformed version of a PNRP Peer Name. How does PNRP work? We have published a number of papers describing the protocol in detail and it is beyond the scope of this blog to go over it all again. But simple put there is a “PNRP Cloud” on the internet which is made up of nodes participating in PNRP. When you publish your peername it gets flooded to some members of the cloud. When you search for a PNRP name you are iteratively contacting other participating PNRP nodes in the cloud to find the node that matches your search criteria. This has some tremendous advantages over DNS. For instance, when you register a PNRP name in the cloud it is locatable across the world within a few seconds! If your IP address changes your PNRP registration is also updated, so you don’t have to worry about people connecting to stale addresses. This would work great for any application that needs to connect to other nodes on the fly…especially mobile nodes. PNRP works over IPv6. Chances are you don’t have Native IPv6 at your house. But you probably do a have Teredo connectivity. Teredo is a technology that tunnels IPv6 over IPv4. But it is also great for achieving end-to-end connectivity through your home’s NAT. So by using PNRP Remote Assistance (and your application) can achieve end-to-end connectivity across the internet in seconds, without the need for a game lobby, emailing invitations, or defining custom port mapping rules on your NAT. I’m sure by now you are asking how you can get started writing PNRP enabled applications. If you are a Native Code developer check out PNRP on MSDN and our samples in the platform SDK. If you are a managed code developer check out the System.Net.PeerToPeer namespace in .NET Framework 3.5.
Now let’s look at one of the most anticipated features of Windows 7 for all you home users: HomeGroup. This really enhances the experience when you have multiple PCs in a single house. You can learn more about it here. http://windows7news.com/tag/homegroup/. What does it have to do with the Microsoft Windows Peer-To-Peer Platform? Home group uses the P2P feature called Grouping which has been around since XP sp2. Grouping is a technology that maintains a mesh of connected nodes. Each node maintains a database of records which is kept in sync with all other participating nodes. HomeGroup uses this feature to keep a set of records about resources that are available in that group, such as file shares and printers. As new PCs join the home group it joins the P2P Group, gets flooded the records for the groups, and is quickly able to be full participating member. Although P2P Grouping has the ability to run over the Internet (using IPV6 & Teredo as described above), the HomeGroup feature limits the scope to your local network. P2P Grouping also includes a security model to prevent rogue nodes from joining or getting content without permission. What are good uses for grouping? Any time you wish to synchronize application data between multiple nodes, consider grouping. Since the data is stored locally on each node retrieval time is very fast, especially for larger content which would normally need to be pulled from a server. Imagine the possibilities! To get started check out the Group Chat sample in the Windows SDK. This sample application uses grouping to create a simple chat application. Each message sent is a record in the group, so when you join the chat session you get a full history of the entire chat. It also demonstrates how grouping keeps track of group membership.
The industry as a whole tends to use the phrase “peer-to-peer” only when talking about internet scale file-sharing applications. But here we are trying to redefine it to a much broader definition and are finding uses for it in many applications such as those mentioned here. I look forward to hearing about how use peer-to-peer in your applications.