You can download the Intel Peer-to-Peer Accelerator Kit at the companion site for this book: http://www.prosetech.com. This site will also post any update links for the Intel Peer-to-Peer Accelerator Kit if they become available. (Unfortunately, at the time of this writing, the Intel Peer-to-Peer Accelerator Kit is no longer available on the Microsoft-supported http://www.gotdotnet.comsite).
The Intel Peer-to-Peer Accelerator Kit download is in the form of a ZIP file with two setup applications. One allows you to install the peer-to-peer name server (used for discovery), while the other includes the Peer-to-Peer Accelerator Kit, which includes the required assemblies, documentation, and optionally, several sample applications and the source code for the toolkit (see Figure 13-4).
Tip |
Intel also provides white papers and a rudimentary peer-to-peer case study at http://www.intel.com/ids/p2p. |
The peer-to-peer name server installs the discovery web service and discovery database. It can only be installed on a server version of Windows, such as Windows 2000 Server or Windows Server 2003. However, if you want to test on a single computer, you only need to install the Peer-to-Peer Accelerator Kit.
The Peer-to-Peer Accelerator Kit setup installs files into the [InstallDir]\Intel\ P2P\v1.0 directory. (By default, the root installation directory is C:\Program Files.) In this path are the following subdirectories:
Bin contains the compiled Intel Peer-to-Peer Accelerator Kit assemblies, which you'll need to reference in your peer-to-peer applications.
Config contains two files that define machine-specific configuration settings, such as peer service.
Docs contains a white paper specification and an HTML Help file that acts as a basic namespace reference. This namespace reference only includes the subset of the Peer-to-Peer Accelerator Kit classes that you'll need to use directly.
Samples contains several sample applications. Some of these have associate Visual Studio .NET project files, but most simply include the source code. All samples are in C# syntax.
Src includes the complete source C# code for the toolkit, organized by namespace. You can use this to learn about the operation of the toolkit or integrate some of its techniques into your own code. Some of the code, such as the code that's required to implement SSL secure channels, is unmanaged C++ code.
The core namespaces and classes are as follows:
Intel.Peer.Messaging includes the PeerChannel class, which works with Remoting and the peer service to allow peer-to-peer communication.
Intel.Peer.Security.CertificateManagement includes the PeerCertificate Management utility class, which contains a small set of methods that can be used to create, remove, and check for peer certificates and key pairs.
Intel.Peer.File.FileCopy includes the PeerFileCopy and PeerFileURI Collection classes, which allow you to easily integrate file-transfer functionality into your peer-to-peer applications.
Intel.Peer.Messaging.Utility includes the PeerWebRequestUtility class, which allows you to use peer-to-peer communication with the WebRequest class. We won't consider this approach in this chapter.
You won't need to perform any additional configuration to test the Intel Peer-to-Peer Accelerator Kit. The peer service is automatically installed and configured to run on startup as part of the installation process. However, when testing peer-to-peer applications in distributed environments, you'll have to specify the discovery service to use and optionally configure a relay service.
Both of these details are configured by editing the Intel.Peer.Common. Dameon.config XML configuration file, which is found in the InstallDir]\Intel\ P2P\v1.0\Config directory.
Here's the basic outline of the configuration file sections:
<?xml version="1.0" encoding="utf-8" ?> <PeerConfiguration> <!-- Entry for the ListenerPort and LoggingLevel --> <!-- Entry for the Listener --> <!-- Entry for the Peer Name System --> <!-- Entry for the Secure Listener --> <!-- Entry for the Relay --> <!-- Entry for Tunnel --> <!-- Entry for Port Mapped data --> <!-- Entry for Store and Forward service --> <!-- Entry for FileCopyService --> </PeerConfiguration>
The first section allows you to configure the port that the peer service uses to listen for incoming requests. You can also configure the client certificate to use when creating secure sessions as well as a proxy address and port.
<Messaging LoggingLevel="0"> <ListenerPort>8080</ListenerPort> <ClientCertificate>C:\Program Files\Intel\P2P\v1.0\data\Security\Client.cer </ClientCertificate> <HttpProxyHost></HttpProxyHost> <HttpProxyPort>1</HttpProxyPort> </Messaging>
You can also set a logging level from 0 to 5, where 0 indicates no logging and 5 indicates the maximum number of log messages. The log messages are written to a Windows event log named PeerServices.
The secure listener entry configures the server certificate as well as the port to use for SSL communication.
<Module Name="SecureListener" Assembly="...Intel.Peer.Messaging.Services.dll" TypeName="Intel.Peer.Security.SecureListener.SecureListenerInitializer" Load="true" Essential="true"> <ListenerPort>8443</ListenerPort> <ServerCertificate> <Name>MyCert</Name> </ServerCertificate> </Module>
The peer-name system entry is where you configure the discovery service. You can use the <Cache> element to configure how many peer entries will be retained in local memory or on disk. The peer name system entry also specifies the <URL> element with the HTTP path to the .asmx web service that performs the discovery. The server name is the only part of this URL that you should need to modify, because the discovery service is installed by default as peernameservice.asmx in a virtual directory named peernameservice.
<Module Name="PeerNameSystem" Assembly="...Intel.Peer.Messaging.Services.dll" TypeName="Intel.Peer.Messaging.NameService.PeerNameSystem" Load="true" Essential="true"> <DataStore Assembly="...Intel.Peer.Messaging.Services.dll" TypeName="Intel.Peer.Messaging.NameService.PnsXmlStore"> <Cache> <OnDisk> <MaxEntries>1000</MaxEntries> <Path>C:\Program Files\Intel\P2P\v1.0\Data\NameServiceCache</Path> </OnDisk> <InMemory> <MaxEntries>100</MaxEntries> </InMemory> </Cache> </DataStore> <ServerInformation> <URL>http://{server_name}/peernameservice/peernameservice.asmx</URL> </ServerInformation> </Module>
Optionally, you can specify several server URLs. In this case, the peer will pass its information to every server whenever an update is performed. On lookup calls the peer will try the servers in order until a response is returned.
In addition, you can also configure the store-and-forward entry to configure how much space is allocated for messages (in megabytes) that are queued for attempted retransmission. You can set where they should be stored, how often delivery should be reattempted (in seconds), and the maximum life span a message is allowed to have (in days). The defaults allocate 10 MB of space, retry message delivery every ten minutes, and allow stored messages to last a full week on the peer.
<Module Name="StoreAndForward" Assembly="...Intel.Peer.Messaging.Services.dll" TypeName="Intel.Peer.Messaging.StoreAndForward.PeerStoreAndForwardService" Load="true" Essential="true"> <StorageSpace>10</StorageSpace> <StoragePath>C:\Program Files\Intel\P2P\v1.0\Data\StoreForward</StoragePath> <MaxLive>7</MaxLive> <DeliveryInterval>600</DeliveryInterval> </Module>
Finally, the relay and tunnel elements allow you to set up firewall traversal solutions. The relay element allows you to configure a peer to act as a relay server (or "super peer") that takes additional responsibility for transmitting messages between peers that could not otherwise communicate, as shown in Figure 13-5.
In Figure 13-5, Peer A is unable to open a connection to Peer B. However, it can contain the relay server hosted by Peer C. If Peer B is also using Peer C, all communication can be routed through subconnections in Peer C. These are called tunneled connections, and they use the BEEP Protocol.
This is how it works, step-by-step:
During startup, the listener on Peer A makes a connection to the relay service on Peer C and opens a channel using BEEP. It identifies itself to the relay using its peer name.
The relay returns one or two new URLs that can be used to contact Peer B through the relay on Peer C. These URLs are also returned by the tunnel to the peer service on Peer B.
When a message is sent through the relay service, it examines the path, determines which peer it's for, and then opens a channel on the peer's tunnel and relays the data.
The relay continues to operate this way until the tunneling connection from the peer is closed or lost.
To configure a peer to act as a relay server, specify a port to use for receiving requests and one for tunneling connections. You must also modify the <Module> tag and set Load to true (which isn't the default).
<Module Name="Relay" Assembly="...Intel.Peer.Messaging.Services.dll" TypeName="Intel.Peer.Messaging.NetworkConnectivity.RelayService.Configuration. RelayInitializer" Load="true" Essential="false"> <TunnelIdPath>C:\Program Files\Intel\P2P\v1.0\Data\TunnelIDs.ser</TunnelIdPath> <RelayPort>100</RelayPort> <TunnelPort>200</TunnelPort> <UsesBEEPTunnel>true</UsesBEEPTunnel> <HttpCallPorts>1024..1054</HttpCallPorts> </Module>
Once you have a relay server, you can make use of it in other peers by configuring the tunnel entry. Once again, you must set Load to true. You must also set the tunnel endpoint to the host name where the relay service is running.
<Module Name="Tunnel" Assembly="...Intel.Peer.Messaging.Services.dll" TypeName="Intel.Peer.Messaging.NetworkConnectivity.Tunnel.Configuration. TunnelInitializer" Load="true" Essential="false"> <TunnelEndpoint>{relay_host_name}:200</TunnelEndpoint> <BEEPUsage> <UsesBEEPTunnel>true</UsesBEEPTunnel> <BEEPProxy> <Endpoint>{beepproxy_host_name:port}</Endpoint> <EndPoint>{second_beep_proxy_host_name:port}</EndPoint> </BEEPProxy> </BEEPUsage> </Module>
Clearly, the manual configuration steps that are involved make this a less-than-perfect solution. Other firewall traversal mechanisms are defined in the Intel Peer-to-Peer Accelerator Kit architecture specification but not implemented.