p2p wcf help

hello,
i am starting to develop a p2p application,
i want tou use the wcf, and peerchannel,
but i didn't find good samples and tutorials to get started.
Can anybody help me getting started and give me some advices.
10x
[242 byte] By [fouad] at [2008-1-2]
# 1

Hi Fouad,

please see the peerchannel blog at

http://blogs.msdn.com/peerchan/

if you have any followup questions, please post back,

hope this helps,

Ram Pamulapati.

RamPamulapati at 2007-9-13 > top of Msdn Tech,Visual Studio Orcas,Windows Communication Foundation (Indigo)...
# 2

Hi Ram,

I actually want to develop an application using p2p with wcf similar to chat application but modified one that is if i want to send the message to particular user present in the chat.Is it possible by using the peerhopcount. From the tutorials which i read on p2p technology with wcf,if i am not wrong i came to know that each message is conveyed to all the nodes in the mesh but now if i want to send the message to particular node only ,how could i do this?(that is i want to send the message to the person i select from the list of all the users in chat). Can u please suggest me some ways on how to do this using peer to peer technology.

Regards,

spshah

spshah at 2007-9-13 > top of Msdn Tech,Visual Studio Orcas,Windows Communication Foundation (Indigo)...
# 3

i think they use p2p inthis

http://blogs.msdn.com/coding4fun/archive/2006/11/06/999502.aspx

and you'll do wpf and wf as well

JDPeckham at 2007-9-13 > top of Msdn Tech,Visual Studio Orcas,Windows Communication Foundation (Indigo)...
# 4

Hi,

Please take a look at our blog posting on HopCount - http://blogs.msdn.com/peerchan/archive/2006/10/04/The-PeerHopCount-Attribute_3A00_-Controlling-Message-Distribution.aspx

This should help you out..

-Shalini.

ShaliniJoshiMSFT at 2007-9-13 > top of Msdn Tech,Visual Studio Orcas,Windows Communication Foundation (Indigo)...
# 5

Hi,

Currently, there is no "out-of-the-box" support for this when using PeerChannel.

but it is not impossible to achieve this.

First off, how are you identifying the target node? is it by their EndpointAddress? how are you obtaining that information at the source?

Once you have the EndpointAddress, you can make a direct connection to the target and send the message (there may be somethings that you need to keep in mind: address selection, NAT traversal etc,...)

Can you describe how the source is obtaining the endpoint information of the target?

thanks,

Ram Pamulapati.

RamPamulapati at 2007-9-13 > top of Msdn Tech,Visual Studio Orcas,Windows Communication Foundation (Indigo)...
# 6

Hi,

I was excited by the feature provided in P2P of WCF. and went through the basics and samples of it.

I would like to create the Data Synchronizaer module in my application which synchronizes the data with the peers on demand basis. Peer1 will initiate the Data Synchronization with Peer2 and task is ended. Will P2P concept help me in this case or am I making my module more complicated by going for P2P ?

How about using Microsoft Synchronization Service ? But still its in beta version Sad.

Is it worth writing our own Sync Agent on top of P2P channel ?

Please help me.

regards

smitha

SmithaRao at 2007-9-13 > top of Msdn Tech,Visual Studio Orcas,Windows Communication Foundation (Indigo)...
# 7

Hello Smitha,

There will be a post about this precise topic very soon up on the PeerChannel blog. Peer-to-peer technology works very well with synchronization if the application is appropriate. PeerChannel does not include a synchronization layer, but it is relatively simple to add one yourself.

Since PeerChannel messages are typically sent to all members of the mesh, synchronization will mainly consist of 2 parts:

A) Populating nodes with data when they enter/re-enter the mesh.

B) Ensuring that dropped messages/data is resent (reliability layer).

Although both parts are essential to ensure good synchronization, let me focus mainly on the first part for now. Adding a reliability layer to PeerChannel is another topic in and of itself. Here are some basic steps to create your own synchronization layer in PeerChannel:

- Have each node will contain a record of all received chat messages. One way might be to store these messages in a Dictionary structure. The key for each entry in the Dictionary will be the unique message ID given to each message sent over the mesh. If the ordering of messages is important, you can either use a list structure, or add ordering to the hash table (I can elaborate on this if you would like).

- Determine the set of data you want to synchronize. You might want to only synchronize the last 5 minutes of data, or your application might want to synchronize a very large data over a long amount of time.

- Add synchonization messages to your message contract. For example, suppose that Node A has just joined the mesh and wishes to sync with the mesh - you could theoretically sync to the mesh in just three steps:

I) Node A sends a sync request to its immediate neighbors (SyncRequest)

II) The nodes that receive Node A's request send a sync response, containing a complete list of data to Node A

(SyncResponse)

III) Node A receives the sync responses and adds any records missing from its local data store.

This particular approach, however, might be too inefficient, since all of the node's neighbors will be sending the complete data set. Since a PeerChannel node should have close to 3 neighbors at all times, that amounts to 3x the data required. In addition, the node may already have some of data set, so sending the complete data set would be unnecessary. A slightly more advanced, 6-step algorithm would be as follows:

I) MessageIDRequest: Node A requests a list of message IDs from its neighbors

II) MessageIDResponse: Each neighbor responds with a complete list of message IDs referring to the data set you wish to synchronize

III) Node A examines the list of message IDs and generates a list of IDs corresponding to messages missing from its local data store.

IV) MessageContentRequest: Node A divides the list of missing messages among the neighbors that responded, and sends each neighbor a sync request with a list of message IDs.

V) MessageContentResponse: Each neighbor sends back the complete messages corresponding to the message IDs containing in the content request.

VI) Node A receives the responses containing the messages and adds them to its local data store

This method has two main advantages: the syncing node only receives messages it knows are missing from its local data store, and no two neighbors are required to send back the same messages, reducing duplication. For example:

- Node A joins the mesh for the first time, and has no messages.

- Node A send a MessageIDRequest to its neighbors Node B, C, and D.

- Nodes B, C, and D send back a MessageIDResponse containing the IDs of messages in the mesh: {1, 2, 3, 4, 5, 6, 7, 8, 9}

- Node A then asks each of its neighbors to send back a subset of the messages: Node B is asked to return messages 1-3, Node C is asked to return messages 4-6, and Node D is asked to return 7-9.

- All the neighbors receive the content request and send back the full messages requested of them

- Node A receives messages 1-9 and adds them to its local data store.

Below is a interface based off the PeerChat sample in the .NET 3.0 SDK. After the standard Join, Chat, Leave operations, the sync messages definitions follow.

public interface IChat

{

[OperationContract(IsOneWay = true)] // Sent when a node joins the mesh

void Join(string member);

[OperationContract(IsOneWay = true)] // Send to indicate that the node is leaving the mesh

void Leave(string member);

[OperationContract(IsOneWay = true)] // A chat message

void Chat(ChatMessage msg);

//**** SYNC OPERATIONS

//******************************

[OperationContract(IsOneWay = true)] // Requests a list of message IDs

void MessageIDRequest();

[OperationContract(IsOneWay = true)] // Responds with a list of message IDs

void MessageIDReply(List<Guid> messageIDs);

[OperationContract(IsOneWay = true)] // Requests the messages corresponding to a list of IDs

void MessageContentRequest(List<Guid> messageIDs);

[OperationContract(IsOneWay = true)] // Responds with a list of messages

void MessageContentReply(List<ChatMessage> messages);

}

Hopefully, these steps should have you well on your way to developing your own sync layer on top of PeerChannel. If you have any further questions, don't hesitate to ask!

Thanks,

Jonathan

JonathanMcPhie at 2007-9-13 > top of Msdn Tech,Visual Studio Orcas,Windows Communication Foundation (Indigo)...

Visual Studio Orcas

Site Classified