You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Running the test will open a debugger as the one shown in Figure *@debugger*. We get object but their textual representation is too generic to really help us.
246
+
Running the test will open a debugger as the one shown in Figure *@debugger*. We get object but their textual representation is too generic to really help us.
247
247
248
248
+Navigating specific objects having a generic presentation.>file://figures/debugger.png|width=100|label=debugger+
249
249
@@ -331,7 +331,7 @@ KANetworkLink >> initialize
331
331
KANetworkLink >> emit: aPacket
332
332
"Packets are not transmitted right away, but stored.
333
333
Transmission is explicitly triggered later, by sending #transmit:."
@@ -391,7 +391,7 @@ Figure *@Api2* shows that the API of our classes is getting richer than before.
391
391
On a real network, when a node wants to send a packet to itself, it does not need any connection to do so.
392
392
In real-world networking stacks, loopback routing shortcuts the lower networking layers; however, this is finer detail than we are modeling here.
393
393
394
-
Still, we want to model the fact that the loopback link is a little special, so each node will store its own loopback link, separately from the outgoing links. We start to define a test.
394
+
Still, we want to model the fact that the loopback link is a little special, so each node will store its own loopback link, separately from the outgoing links. We start to define a test.
395
395
396
396
[[[language=smalltalk
397
397
KANetworkEntitiesTest >> testLoopback
@@ -484,7 +484,7 @@ KANetworkTest >> setUp
484
484
self buildNetwork
485
485
]]]
486
486
487
-
Before anything else, let's write a test that will pass once we've made progress; we want to access network nodes given only their addresses. Here we check that we get a hub node based on its address:
487
+
Before anything else, let's write a test that will pass once we've made progress; we want to access network nodes given only their addresses. Here we check that we get a hub node based on its address:
488
488
489
489
[[[language=smalltalk
490
490
KANetworkTest >> testNetworkFindsNodesByAddress
@@ -507,7 +507,7 @@ KANetworkTest >> buildNetwork
507
507
net := KANetwork new.
508
508
hub := KANetworkNode withAddress: #hub.
509
509
#(mac pc1 pc2 prn)
510
-
do: [ :addr |
510
+
do: [ :addr |
511
511
| node |
512
512
node := KANetworkNode withAddress: addr.
513
513
net connect: node to: hub ].
@@ -540,7 +540,7 @@ KANetwork >> makeLinkFrom: aNode to: anotherNode
540
540
]]]
541
541
542
542
543
-
We add a low level method ==add:== to add a node in a network.
543
+
We add a low level method ==add:== to add a node in a network.
544
544
545
545
[[[language=smalltalk
546
546
KANetwork >> add: aNode
@@ -645,7 +645,7 @@ KANetwork >> linkFrom: sourceAddress to: destinationAddress
645
645
... Your code ...
646
646
]]]
647
647
648
-
!!!! Final check.
648
+
!!!! Final check.
649
649
As a final check, let's try some of the previous tests, first on the isolated ==alone== node, showing that loopback works even without a network connection:
Now we define the class ==KANetworkHub== that will be the recipient of hub specific behavior.
765
+
Now we define the class ==KANetworkHub== that will be the recipient of hub specific behavior.
766
766
767
767
[[[language=smalltalk
768
768
KANetworkNode subclass: #KANetworkHub
@@ -785,15 +785,15 @@ Now we can use a proper hub in our test, replacing the relevant line in ==KANetw
785
785
]]]
786
786
787
787
788
-
You have now a nice basis for network simulation. In the following we will present some possible extensions.
788
+
You have now a nice basis for network simulation. In the following we will present some possible extensions.
789
789
790
790
791
791
!!! Other examples of specialized nodes
792
792
In this section we will present some extensions of the core to support different scenarios. We will propose some tasks to make sure that the extensions are fully working. In addition in this section we do not define tests and we strongly encourage you to start to write tests. At the moment of the book you should be ready to write your own tests and see their values to improve your development process. So take this opportunity to practice.
793
793
794
794
!!!! Workstations counting received packets
795
795
796
-
We would like to know how many packets specific nodes are receiving.
796
+
We would like to know how many packets specific nodes are receiving.
797
797
In particular when a workstation consumes a packet, it simply increments a packet counter.
0 commit comments