Skip to main content

Bidirectional Pipes

6 replies [Last post]
gounis4
Offline
Joined: 2006-02-15
Points: 0

Hello.
I am new on JXTA and I use it to implement a P2P sharing system which is my thesis.
Say that one peer "A" knows peer's "B" ID but "B" doesn't know A's ID. "A" wants from "B" some data. Which is the simplest way "A" to retrieve the data of "B" while incoming connections are always blind? I tried this with JXTABidiPipe but I prefer async connection notifications, something that JXTAServerPipe doesn't support. Isn't another way rather than transformating JXTAServerPipe?
Thank you in advance...

Reply viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
ae6rt
Offline
Joined: 2005-10-25
Points: 0

I see.

You might consider embedding the sending peer's ID in the Message in the PipeMsgEvent event passed into the pipeMsgEvent(PipeMsgEvent event) callback. Then filter on the peer ID of interest. Iow, your application must do this filtering, without help from the platform.

One might also consider a scheme whereby B is the only peer on the network who actually knows the PipeID to which A is bound. I realize this depends on your app, but it may be an option.

There may be a better solution to your problem, one the platform itself affords. But I can't think of one :-)
hth

gounis4
Offline
Joined: 2006-02-15
Points: 0

I really appreciate for your rensponses...
I had some ideas too...

--------Schema 1:The Confusing Peers------------
Step (1):Peer A creates an output pipe and sends to Peer
B(who has already create an input pipe for every
peer in my system)its ID.
Step (2):Peer A creates an input pipe.
Step (3)Peer B's pipe listener grabs Peer A's ID and then
Peer B create an output pipe and send his data to
Peer A, once he knows Peer A's ID.
Step (4):Peer A's pipe listener grabs Peer's B data.
[u]Conclusion[/u]:I have implemented this scenario and it is very
confusing especially in debbuging.

--------Schema 2:The Tricky Peers------------
Every peer creates an output pipe which is bound to a pipeID equal to peer's ID (is it possible?).
If Peer A wants to receive from known Peer B,then creates an input pipe which is bound in a pipeID that is equal to peer B's ID.
[u]Conclusion:[/u]I don't know if it is possible to implement this scenario and I don't know what the rensponse time will be.

Among mine and your ideas,what do you believe for the response times in a system with many peers?

ae6rt
Offline
Joined: 2005-10-25
Points: 0

You might have problems in very large networks with Scheme 1, whereby B is creating input pipes of the same number of peers on the network. Depends on how many peers you expect to develop, but for anything over a dozen or so, I'd be wary.

Your idea to essentially create a map from PeerID to associated PipeID is interesting. If you can guarantee that the map produces a one to one correspondence between the two, then you could be onto something. If you examine the API for net.jxta.id.IDFactory, which you will need, you will notice the provision for a "seed" value when creating new PipeIDs. The seed would be the PeerID in some form. This would presumably be your mapping hook.

Mapping PeerIDs to PipeIDs is slightly elaborate, to my mind. But your requirements should be your guide.

No matter if you implement your messaging over pipes or over the more primitive resolver service, you will need a listener with callbacks. If you already know which peer will be talking to which peer (A to B, e.g.) you might consider spending some time in this lower-level portion of the solution space.

ae6rt
Offline
Joined: 2005-10-25
Points: 0

Chapter Five of Wilson's book is good reading while solving your problem.

http://www.brendonwilson.com/projects/jxta-book/

I'll say again that the quality of the writing is good enough to offset the 2002 copyright. You can easily enough pick up what changes have occurred in the API since then by just reading the Javadocs when you get that 'unknown symbol' from the compiler.

gounis4
Offline
Joined: 2006-02-15
Points: 0

I use the PipeService to send and receive messages.
Say that my P2P system constists of many peers and let peer A creates an input pipe bound to a specific adv and registers a listener.
The problem is that peer A cannot take data at a random time from a specific known peer B, because pipeService.createInputPipe() method cannot take the B's PeerID as an argument.
Only peers that [u]send[/u] messages can send them to [u]specific known peers[/u].
How is it possible for a peer that want to [u]receive[/u] messages, to receive them from a [u]specific known peer[/u].

ae6rt
Offline
Joined: 2005-10-25
Points: 0

I'm not sure how passive you expect B to be in this scenario, but B has to do *something* to get messages from A up B's stack. That something is listen for messages of some sort. Based on the description of your needs, I suggest you investigate

net.jxta.impl.protocol.ResolverQuery
net.jxta.protocol.ResolverQueryMsg
net.jxta.protocol.ResolverResponseMsg
net.jxta.resolver.QueryHandler
net.jxta.resolver.ResolverService;

and surrounding topics. You probably know this, but even with this low level messaging scheme, B is still going to have to be programmed to respond to A at the application layer.

hth