Re: [Pharo-users] mentor question 1
On Sat, Apr 25, 2020, 11:46 Roelof Wobben via Pharo-users < pharo-users@lists.pharo.org> wrote:
Op 25-4-2020 om 20:17 schreef Roelof Wobben:
Op 25-4-2020 om 20:04 schreef tbrunz:
1. 'loopback' is a node, just like 'source' and 'destination'. A network is a mesh of 'nodes' joined by 'links'. Your Pharo program represents one of those nodes: It is the 'loopback' node.
oke, so I can do : loopback := KNetworkNode new.
2. The block in the #linksTowards:do: method is the action to take on a packet, depending on whether its destination is "you" (loopback), or something else.
The flood algorithm is the simplest algorithm: "If the destination is not me, send the packet to everyone else (except the one who sent it to me)."
and that part I still do not see. I "fail" to see what the block exactly is.
However, there is the possibility of loops in the network, so a slightly better algorithm is to check "have I seen this packet before?" and if the answer is "yes", then drop it; otherwise send it via my links. This will prevent endless packet sending loops in your network.
-t
-- Sent from: http://forum.world.st/Pharo-Smalltalk-Users-f1310670.html
Oke,
Did some thinking and see how things are working if the loopback is not used :
linksTowards: anAddress do: aBlock "Simple flood algorithm: route via all outgoing links. However, just loopback if the receiver node is the routing destination."
address = anAddress ifTrue: [ ] ifFalse: [ outgoingLinks do: aBlock ]
but still I "fail" to see what need to be done when the loopback is used with the block.
It's not clear to me if a link is an actual object in your model. I'll respond as if it is. aBlock is the work you want done on the destination node. So, the question is how you get it there. You iterate through the outgoingLinks and ask the link to deliver the block to the destination node. In "blasting", each node sends it on through its own outgoingLinks, until it eventually reaches the destination node. The destination node evaluates aBlock, probably supplying itself as an argument to the block. In the case of a loopback, the node itself seems to be the one intended to evaluate aBlock. (I don't know the problem description, so that may not be entirely correct.)
Roelof
Hi Richard, I looked the repo; he's defined 3 classes: one for packets, one for nodes, and one for links. So yes, he instantiates links. Likely each node has a collection of links (each of which leads to another node in the network). The application is to simulate a network by modeling it in ST, so that means generating packets, each with a destination node (where nodes have addresses), and simulating how the packets flow through the network to get from their source nodes to their destination nodes. I hadn't though about sending the blocks to the nodes via the packets, but that *is* a cool concept... And entirely do-able in Pharo. However, if the exercise is to make a simple network model that runs to simulate network operation, I doubt that's what they're looking for, though (since it's not what you typically do in a packet network). I think they just want you to model the packet-handling behavior, and that's what the block is for. (I may be wrong.) -Ted -- Sent from: http://forum.world.st/Pharo-Smalltalk-Users-f1310670.html
On Sat, Apr 25, 2020, 15:50 tbrunz <wild.ideas@gmail.com> wrote:
Hi Richard,
I looked the repo; he's defined 3 classes: one for packets, one for nodes, and one for links. So yes, he instantiates links. Likely each node has a collection of links (each of which leads to another node in the network). The application is to simulate a network by modeling it in ST, so that means generating packets, each with a destination node (where nodes have addresses), and simulating how the packets flow through the network to get from their source nodes to their destination nodes.
I hadn't though about sending the blocks to the nodes via the packets, but that *is* a cool concept... And entirely do-able in Pharo. However, if the exercise is to make a simple network model that runs to simulate network operation, I doubt that's what they're looking for, though (since it's not what you typically do in a packet network). I think they just want you to model the packet-handling behavior, and that's what the block is for. (I may be wrong.)
Thanks, Ted. That makes sense. I agree the problem is almost certainly not about sending blocks. Silly of me, really. I didn't see anything in this thread that explained the block. I could imagine that a link object knows how to deliver a packet to the node and the node object knows how to receive the packet. (Or something like that)
-Ted
-- Sent from: http://forum.world.st/Pharo-Smalltalk-Users-f1310670.html
Richard, I don't think it was silly. I'm sitting here thinking to myself, "Wow, that's creative... Pharo being Pharo, you can write applications that can send *blocks* between nodes, not just *data*..." The concept of sending behaviors as well as data opens up some interesting and powerful possibilities for applications! (Yet another way ST is superior to other languages.) -Ted -- Sent from: http://forum.world.st/Pharo-Smalltalk-Users-f1310670.html
On Sat, Apr 25, 2020, 16:17 tbrunz <wild.ideas@gmail.com> wrote:
Richard,
I don't think it was silly. I'm sitting here thinking to myself, "Wow, that's creative... Pharo being Pharo, you can write applications that can send *blocks* between nodes, not just *data*..."
I understand. I meant that in the world this exercise models (separate compute nodes connected by a network), the single god-like Pharo application doesn't exist and sending blocks is harder. (Although, GemStone/S does make it simple, at least if all the nodes are connected to the GemStone/S database.)
The concept of sending behaviors as well as data opens up some interesting and powerful possibilities for applications! (Yet another way ST is superior to other languages.)
Absolutely! It took a long time to *really* internalize the idea of everything is an object. Once I grokked that, it became easy to think that way all the time.
-Ted
-- Sent from: http://forum.world.st/Pharo-Smalltalk-Users-f1310670.html
participants (2)
-
Richard Sargent -
tbrunz