Developing P2P Applications Using Windows Vista And The

Download Report

Transcript Developing P2P Applications Using Windows Vista And The

Developing P2P Applications Using Windows Vista And The Windows Communication Foundation (“Indigo”) PeerChannel Sandeep K. Singhal COM311 Product Unit Manager Microsoft Corporation COM 311

Agenda

Peer-to-Peer defined Why P2P?

How Microsoft is enabling P2P P2P application lifecycle Identify Organize Communicate Call to action

2

What Is Peer-To-Peer (P2P)?

Directly communicating PCs

One-to-one, one-to-many, many-to-many Telephony and video Chat Co-editing Gaming Data access and replication

3

Why Use P2P?

Reduce Reliance on Servers Direct Client Connections Eliminate bottlenecks, improve scalability Lower deployment costs and complexity Faster data transmission Support ad-hoc and disconnected networks P2P Systems Better resilience – no single point of failure Powerful social interactions

4

Addressing P2P Challenges

Universal connectivity IPv6 and Teredo connect most consumer NATs Hard to build P2P applications Unsafe to deploy Comprehensive developer platform supporting P2P Application Operations Well-engineered protocols, built-in security

5

P2P Application Operations

One-to-One Find peer Send invitation Create session

6

P2P Application Operations

One-to-One Find peer Send invitation Create session One-to-Many Many-to-Many Learn mesh name Join mesh

7

P2P Application Operations

One-to-One Find peer Send invitation Create session One-to-Many Many-to-Many Learn mesh name Join mesh

8

1. Find Peers

One-to-One Find peer

Send invitation Create session Locate other endpoints for P2P communication?

One-to-Many Many-to-Many

Learn mesh name Join mesh Discover others on your LAN People Near Me: signed-in people Uses WS-Discovery to find all COM319: Integrating People Near Me Into Your Applications Find peers or peer groups by name Peer Name Resolution Protocol (PNRP): Secure, server-less name resolution over the Internet or local LANs

9

Peer Name Resolution Protocol

No service signup Scalable from ad-hoc to Internet Built-in security Name records signed by public-private keys Name machines, users, or arbitrary resources Multiple names per machine Multiple endpoints per name Name records can contain a limited amount of arbitrary data

10

PNRP Resolve a name

Integrated into standard name resolution getaddrinfo(), System.net

Works with many existing applications PNRP names use *.pnrp.net domain hr = PeerPnrpResolve(“0.SandeepPictures”, NULL, &cEndpoints, &pEndpoints); PWSTR pwzHostName = NULL; HRESULT hr = PeerNameToPeerHostName(L”0.SandeepPictures”, &pwzHostName); if (SUCCEEDED(hr)) { ADDRINFO *pai, ai = {0}; ai.ai_family = AF_INET6; getaddrinfo(pwzHostName, NULL, &ai, &pai); PeerFreeData(pwzHostName); }

11

PNRP Publish a name

// The null 2nd param means the API should pick address for you, // register in all clouds, re-register if your addresses change HANDLE hReg; HRESULT hr = PeerPnrpRegister(L”0.SandeepPictures”, NULL, &hReg);

12

PNRP Enables P2P Photo Sharing

13

2. Send Invitation

One-to-One Find peer

Send invitation Create session

One-to-Many Many-to-Many

Learn mesh name Join mesh Real-time invitation to People Near Me or Contacts over Internet User message Application data (IP, port, mesh name) System listener pops invitation prompt, then launches app More details at COM319 (Integrating People Near Me Into Your Applications) on Thursday

14

3. Join Mesh

One-to-One Find peer

Send invitation Create session

One-to-Many Many-to-Many

Learn mesh name Join mesh Specify mesh name and credentials Use mesh for multi-party communication

15

How P2P Meshes Work

Identified by name Used to locate some existing members and connect to them Active members publish mesh name so others can find them Mesh self-organizes active participants Adjusts to changing membership Resilient connectivity Dynamically optimized based on traffic patterns

16

Two Flavors Of Mesh

Data replication service: Grouping Available in Windows Vista and XPSP2 Exchange messages by replicating data records Message service: Peer Channel Part of Windows Communication Foundation Share data by building synchronization and transaction services

17

Comparing Mesh Options

Service Model Security Node Discovery APIs Key Apps Grouping Replicated database among active nodes Directed connections through TCP Password Group certificates (managed by mesh) PNRP Native Group collaboration Peer Channel Message flooding with per-hop message filters Directed connections through TCP channels Password Individual certificates (managed by app.) PNRP Developer-supplied (e.g., web service) Managed Content distribution

18

Stock Quote Distribution Using The Peer Channel

19

Contracts And Messages

Channel: Message I/O Mechanism Message: Data sent to Service Service: Targets for Message Delivery Contract: Which Messages are Understood

Message Channel Transport Channel Service Contract 20

Contracts

[ServiceInterface] public interface IQuoteChange { [ServiceMethod] void PriceChange (Quote quote); } Message [Service] public class QuoteHandler : IQuoteChange { public void PriceChange(Quote quote) { // update quote display component; } } Message Channel

Channel

21

Stock Quote Distribution The message interface

[ServiceContract(Namespace="http://Microsoft.ServiceModel.Samples.PeerChannel")] [PeerBehavior] public interface IQuoteChange { [OperationContract(IsOneWay = true)] void PriceChange(string item, double change, double price); } public interface IQuoteChannel : IQuoteChange, IClientChannel { }

22

Stock Quote Distribution Sender service contract

23

Stock Quote Distribution Sender.Cs

// Create a channel factory with the configuration ChannelFactory cf = new ChannelFactory(“QuoteSenderEndpoint"); // Specify mesh password, certificate for secure connections PeerSecurityBehavior security = new PeerSecurityBehavior(); security.Password = args[0]; X509Certificate2 selfCredentials = GetCertificate(StoreName.My, StoreLocation.CurrentUser, recognizedSender, X509FindType.FindBySubjectDistinguishedName); security.SetSelfCertificate(selfCredentials); // To enable message authentication, specify validator to point to my cert security.SetMessageX509Authentication(new SenderValidator(selfCredentials)); // Finally, attach the behavior before opening the channel factory.

cf.Description.Behaviors.Add(security); // Create proxy from channel factory and open it IQuoteChannel sender = (IQuoteChannel)cf.CreateChannel(); sender.Open(); // Start sending stock quotes using this proxy sender.PriceChange(“ABCY”,-0.50, 99.50);

24

Stock Quote Distribution Receiver service contract

25

Stock Quote Distribution Receiver.Cs

Uri baseAddress = new Uri(ConfigurationManager.AppSettings["baseAddress"]); ServiceHost receiver = new ServiceHost(new QuoteReceiver(), new Uri[] { baseAddress }); // Specify mesh password, certificate for secure connections PeerSecurityBehavior security = new PeerSecurityBehavior(); security.Password = args[0]; X509Certificate2 selfCredentials = GetCertificate(StoreName.My, StoreLocation.CurrentUser, “CN=“+member, X509FindType.FindBySubjectDistinguishedName); security.SetSelfCertificate(selfCredentials); // Specify that only messages signed with identified cert should be accepted publisherCredentials = GetCertificate(StoreName.TrustedPeople, StoreLocation.CurrentUser, recognizedPublisherName, X509FindType.FindBySubjectDistinguishedName); security.SetMessageX509Authentication( new PublisherValidator(publisherCredentials)); // Add the behavior to the servicehost and open it.

receiver.Description.Behaviors.Add(security); receiver.Open();

26

Future Directions Beyond windows vista and WCF

Enhanced mesh services Replicated data, distributed agreement, voting Enhanced mesh algorithms Real-time / QoS Flexible messaging Subgroups, routing control

27

Call To Action

Look to P2P and collaboration To enhance performance To enhance resiliency Join the Windows Vista and Windows Communication Foundation beta program The peer-to-peer platform is available in both the Beta 1 and PDC builds!

28

Community Resources

At PDC: For more information, see Hands-on Lab: People Near Me Hands-on Lab: Peer Channel Talk COM319 (Integrating People Near Me Into Your Applications) on Thurs. 10am) Ask The Experts tables (Thursday) – P2P Native and Managed After PDC Feedback/Questions: [email protected]

Newsgroups microsoft.public.win32.programmer.networks

microsoft.public.platformsdk.networking

microsoft.public.platformsdk.networking.ipv6

Blogs http://blogs.msdn.com/noahh http://blogs.msdn.com/tparks Websites http://www.microsoft.com/p2p http://www.microsoft.com/ipv6

29

© 2005 Microsoft Corporation. All rights reserved.

This presentation is for informational purposes only. Microsoft makes no warranties, express or implied, in this summary.