320 likes | 840 Views
Peer-to-Peer Programming with .NET 3.5. Dean Fiala Very Practical Software vpsw.com. What We’ll Cover. Windows Peer-to-Peer Overview System.Net.PeerToPeer Namespace Tour Hot Peer-to-Peer Action (demo) Peek at other .NET Peer-to-Peer technologies. First Pier-to-Pier Network.
E N D
Peer-to-Peer Programming with .NET 3.5 Dean Fiala Very Practical Software vpsw.com
What We’ll Cover • Windows Peer-to-Peer Overview • System.Net.PeerToPeer Namespace Tour • Hot Peer-to-Peer Action (demo) • Peek at other .NET Peer-to-Peer technologies
Overview of Peer-To-Peer Networking • Simply a collection of peers • Peers act as both clients and servers • Pure P2P -- No central server required (DNS-less) • Hybrid P2P – server used to helped find peers • Based on IPv6 (allows every device on the network to have a unique address)
Uses of P2P • File Sharing • Collaboration • Chatting • Distributed Processing
P2P Cloud • Simply a collection of peers within a defined network scope • Peer can belong to multiple clouds • Sometimes known as a Mesh Network
Cloud Scope Global all peers on the Internet Link Localall peers on the local subnet
Cloud Status Virtual Not yet initialized Synchronizing Still initializing (bootstrapping) Active Ready to go Alone Ready to go – but not connected to any other system
Peer Name • Defined as Authority.Classifer • Authority.FriendlyName • For unsecured names, Authority = 0ex: 0.Fredo • For secured names, Authority = SHA1 Hash of the PeerName ex: 259ef61ae2a6703fed18544a268204adba477735.Sonny
Peer Name Resolution Protocol • PNRP • Secret sauce – allows peers to find each other without servers • Real time – no caching like DNS • Resolves Peer Names, which define Endpoints for communication
Peer Resolution In Cache? AskClosest Peer Find Peer No In Cache? Send to RequestingPeer In Cache? Ask NextClosest Peer Yes No AskSuggested Yes CloserPeer? Ask This One No Sorry In Cache?
PNRP v1 vs PNRP v2 • NOT COMPATIBLE • PNRP v1 (XP SP2 or lower) • Recursive search • PNRP v2 (Vista, XP SP3) • Iterative search • v2 patch available for XP SP2, http://support.microsoft.com/kb/920342KILLS v1 dependent apps
Useful Tools • NETSH – Command Line utility to diagnose or set up a computer’s networking configuration • Teredo – Tunneling Technology allows IPv6 traffic over IPv4 networks
Useful NETSH Commands • p2p pnrp cloud show names – shows names of registered peers • p2p pnrp cloud show list – shows status of clouds • p2p pnrp peer add registration – quickly add a peer to clouds for testing purposes
Peer To Peer in .NET • First available in .NET 3.5 • Classes live in the System.Net.PeerToPeer namespace • Two purposes: • Registering peers in clouds • Resolving peers in clouds
System Requirements • Vista • XP SP2, SP3 • XP SP1 and the Advanced Networking Pack for Windows XP • Server 2008
Services Required • Peer Name Resolution Protocol • Peer Network Identity Manager • SSDP – Simple Service Discovery Protocol
Endpoint PeerNameRecord 0.Somename Registering A Peer PeerName +
Creating a PeerName • (string, PeerNameType) constructor creates fully qualified PeerName in format Authority.Classifier • Type = Unsecured creates 0.{FriendlyName} • Type = Secured creates {Hash}.{FriendlyName}
What’s an Endpoint? • An Internet Protocol address and port • Can be IPv4 or IPv6 • Implemented as System.Net.IPEndPoint
Why Define Endpoints? • No way to find out from .NET classes what the Registered end point is if UseAutoEndpointSelection = true
How To Get A Cloud • Cloud.GetAvailableClouds() returns a collection of available clouds for the peer • Should return: • One Global Cloud • Plus one LinkLocal cloud for each active network adapter
PeerNameRecord 0.Somename Resolving A Peer Resolver PeerName
PeerNameRecord • Information about a peer within a given cloud fe80::3044:488f:11b2:c2d4%10 PeerNameRecord 0.Somename Some Comment Some Data (up to 4K)
Hot Peer-To-Peer Action • Another P2P Chat Application!
Net.PeerToPeer.Collaboration • Only available in Vista • Not in Server 2008 either • Framework to handle: • Discovery • Notification • Invitations • Contact Lists • Groups • Beaucoup event hooks available
Exciting Collaboration Classes • PeerCollaboration: duh, need to use this to access almost everything else • ContactManager: access to contacts in an address book • PeerApplication: an application that be shared • PeerPresence: shows the status of a peer
WCF Peer Channel • Built-in goodies for creating p2p applications • Handles most of the plumbing • Has PeerNodes, PeerMeshes and uses the PNRP Resolver • Good starting point for p2p apps not tied to Vista • Same requirements as using the PeerToPeer namespace
What We Covered • Peer-to-Peer Overview • Tour of the System.Net.PeerToPeer Namespace • Hot Peer-to-Peer Action (demo) • Peek at other .NET Peer-to-Peer technologies
Resources • Good Overview: http://msdn.microsoft.com/en-us/library/cc297274.aspx • PNRP v2 Update for XP: http://support.microsoft.com/default.aspx/kb/920342 • P2P Blog: http://blogs.msdn.com/p2p/default.aspx • NETSH: http://technet2.microsoft.com/windowsserver/en/library/61427fbd-de1f-4c8a-b613-321f7a3cca6a1033.mspx?mfr=true • WCF PeerChannel: http://msdn.microsoft.com/en-us/library/ms731061.aspx
Contact Info & Shameless Plug • Email: dfiala@vpsw.com or dfiala@gmail.com • Blog: www.vpsw.com/blogbaby meets the Second Wednesday of every monthwww.rocknug.org