--- Begin Message ---
Hello,
Im doing the OOP book written by Ducassse and im now stuck at the
network-simulator.
Code so far can be found here :
https://github.com/RoelofWobben/Network-simulator
Im stuck at 2 places
1) What for datatype is loopback ? Is it a string or something
else.
The book is not telling that.
2) I have to make this method/function
linksTowards: anAddress do: aBlock
"Simple flood algorithm: route via all outgoing links.
However, just loopback if the receiver node is the routing
destination."
(address destination == loopback)
ifTrue: [self send: via: loopback ];
ifFalse: [self send: via: anAddress]
but I do not have a clue what the aBlock is and if im on the right
path.
I know the solutions can be found online but then I do not learn
anything.
This is what is stated in the book :
This method has to rely on some routing
algorithm to identify which links will transmit the packet
closer to its destination. Since some routing algorithms select
more than one link, we will implement routing as an iteration method,
which evaluates the given block for each selected link.
KANetworkNode >> send: aPacket
"Send aPacket, leaving the responsibility of routing to the node."
self
linksTowards: aPacket destinationAddress
do: [ :link | self send: aPacket via: link ]
One of the simplest routing
algorithm is flooding: just send the packet via every outgoing link.
Obviously, this is a waste of bandwidth, but it works without any
knowledge of the network topology
beyond the list of outgoing links.
However, there is one case where we know how to route the packet:
if the destination address
matches the one of the current node, we can select the loopback
link. The logic of linksTowards:do:
is then: compare the packet’s
destination address with the one of the node, if it is the same,
we
execute the block using the loopback link, else we simply iterate
on the outgoing links of the receiver.
KANetworkNode >> linksTowards:
anAddress do: aBlock
"Simple flood algorithm: route via all outgoing links.
However, just loopback if the receiver node is the routing
destination."
... Your code ...
I hope someone can help me on the way or let me see which steps I
had to take to solve this on my own.
Roelof
--- End Message ---
- [Pharo-users] mentor question 1 Roelof Wobben via Pharo-users
-