Page 1 of 10 Hard Potato Routing Algorithm: Experimental Study using Mesh Simulation in Java Suyog Deshpande Student ID: 901-01-0484 University of Maryland Baltimore County Baltimore, Maryland suyog1@umbc.edu Abstract We present an experimental verification of the Hard Potato Routing algorithm for a 15 x 15 mesh. The authors of “Hard Potato Routing” [1] claim to provide a novel approach to routing of packets in n x n mesh network. They make use of some new techniques to propose their algorithm. However, most of their work is theoretical, and rests on probability. We verify their algorithm and see if the theoretical analysis does hold true, and also show whether the probabilities mentioned by authors apply in a real 15x15 mesh network that we simulate. 1.0 Introduction “Hard Potato Routing” [1] paper is taken from the proceedings of the thirty-second annual ACM symposium on Theory of computing May 21 - 23, 2000, Portland, OR USA. The authors of the paper present the first hot-potato routing algorithm for the n x n mesh whose running time on any "hard" (i.e. Ω(n))"many-to-one" batch routing problem which is, with high probability, within a polylogarithmic factor of optimal. For any instance I of a batch routing problem, there exists a well-known lower bound LBI based on maxim path length and maximum congestion. If LBI is Ω (n), the hard-potato routing algorithm solves I with high probability in time O (LBILog3n). Jay Patel Student ID: xxx-xx-0859 University of Maryland Baltimore County Baltimore, Maryland jay2@umbc.edu The Section 1 will introduce the paper “Hard Potato Routing” [1] and give the related work. Section 2 will deal with the preliminaries of setting up the simulation and the assumptions made. In Section 3 we give high-level psuedocode for the algorithm. We describe the results obtained experimentally in Section 4 with graphs and Section 5 has the necessary calculations. We conclude in Section 6 with open problems in the simulation. 1.1 Background A hot-potato (or deflection) routing algorithm is a packet routing algorithm in which nodes have no buffers to store packets in transit: any packet that arrives at a node other than its destination must immediately be forwarded to another node. The network we consider here is the twodimensional n × n mesh, one of the simplest networks for multiprocessor architectures. The nodes in the network are synchronized, namely, time is discrete and in each time step a node receives packets from its adjacent nodes, then takes routing decisions, and then forwards the packets to the adjacent nodes according to the routing decisions. At each time step a node is allowed to send at most one packet per link. Page 2 of 10 become excited, increasing its priority over nonexcited packets. An excited packet attempts to converge on its target by choosing a logarithmic number of random intermediate destinations (see Figures 2 and 4) in a sequence of squares of decreasing size. As we will show in the simulation, a packet during its multi-bend path has a good chance not to be interrupted by other high-priority packets, and therefore, to successfully reach its destination. Figure1. Packets with destinations in a region, Mansour and Patt-Shamir [2] have noted that there is a trivial lower bound for problems of this kind. If a packet's source and destination are separated by distance d, then no routing algorithm can deliver that packet in fewer than d steps. The maximum such distance a packet must traverse in a routing problem I, is called the distance lower bound, denoted DI. Consider now the case where s packets have their destinations inside some region of the network and these packets originate from outside the region (see Figure 1). All these packets must enter the region. If the region has z incoming links in its perimeter, then at each time step at most z packets can enter the region, and thus, no routing algorithm can deliver those s packets in fewer than s/z steps. The maximum value of this ratio, taken over all the regions in the network, for a problem instance I yields the bandwidth lower bound, denoted WI. The lower bound for I, which we denote by LBI is just Ω(DI + WI). The Hard Potato Routing algorithm is distributed: each node makes routing decisions based on its local state, independently of the other nodes. Moreover, nodes know nothing about the initial distribution of destinations (including the values of DI, WI, and LBI) . At the heart of this algorithm is a new technique based on multi-bend paths, a departure from the paths using a constant number of bends used in most other hot-potato algorithms. Each time a packet is deflected (unable to advance toward its destination), it may, with a certain probability, 1.2 Related Work Hot potato routing was first proposed by Baran [3]. For mesh-like networks, there are many hotpotato algorithms tuned for the batch permutation and random destination routing problems [4; 5]. In the more general setting of arbitrary many-to-one batch routing problems, Ben-Dor et al. [6] provide a simple algorithm for the 2-dimensional n x n mesh with O(n k) steps, where k is the total number of packets to be routed. Similarly, Ben-Aroya et al. [4] give an algorithm that finishes in DI + 2(k - 1) steps in the two-dimensional mesh. 2. Preliminaries We chose to do the programming of the simulator in Java due to its object oriented nature and robustness of the programming language. In the paper “Hard Potato Routing”[1] the authors have only given a theoretical description of the algorithm. To simulate it we first had to understand the data structures like links and nodes involved in it. Proper designing is important to correct implementation of code. So we list the main points to keep in mind while creating the program code: A two dimensional (NxN) mesh nodes are synchronized time consideration is discrete, i.e.: at one point there is only one transition from each node. Page 3 of 10 In each step a node receives a packets from adjacent nodes and based on the packets makes the Routing decisions, passes the packet depending on the decision, and passes only packet per link. Each node ( except at the edge of the mesh) is connected to adjacent nodes by bi-directional links. The following are the various structure we will need and their properties: 2.1 Mesh Structure: We are given an n x n mesh of nodes. We denote a node v with its coordinates ( x, y ),0= < x, y< n, where x is a column and y a row. The lower-left comer of the mesh is the node(0, 0) and the upper-right comer (n - 1, n - 1). Each node(except at the edge of the mesh) is connected to its four adjacent nodes by bidirectional links, denoted up, down, left and right. We denote the distance between nodes v = (x, y) and v' =( x ' , y') as dist(v, v') and is the quantity dist(v, v’) = |x – x’| + |y – y’| of v is the z × z square whose lower leftmost node is v ‘ = ( x + z -1, y + z -1), as shown in Figure 2. The horizontal band-z of v is the rectangle: [(x + 2z - 1,y + z - 1 ) , ( n - 1 , y + 2 z - 1)]. The vertical band-z of v is the rectangle: [ ( x + z - 1, y + 2z -1), ( x + 2z - 1 , n - 1)]. For the simulation purposes we will consider a mesh structure on 15 x 15. 2.2 Packet structure: Has two parts, namely the MESSAGE and the HEADER part of the message. The HEADER part can contain an integer number. The header defines the state of the packet as to be NORMAL = 0, EXCITED = 1 or RUNNING = 2. Packet Properties: A packet in normal state will try to take the preferred link to the destination the packet will always chose the shortest route possible to the destination. If the normal packet is not able to take the preferred link , then it makes a DEFLECTION. Once deflected, the packet reaches another node and changes its state to EXCITED state. Figure 2: The squares and bands of a node Take a node v = (x, y) and a number z = 2 k, where k =0 , . . . , lg(n) - 1. Consider the submesh that is up and right from v. The square-z Figure 3: a deflected packet becomes excited In the EXCITED state, the packet becomes with a little higher priority, and goes on a preferred link. If the EXCITED packet reaches the next Page 4 of 10 preferred link, then it immediately changes its state to RUNNING state. From then on the RUNNING state will have the highest priority and will reach the destination using all the preferred links. All the other packets with lesser priority will not get that path. N N N N N Figure 5: Node Structure Figure 4: A successful running path However, if the EXCITED path for some reason say collision or deflection is not able to get the preferred link, the it changes its state back to NORMAL state and proceeds like a normal packet. Also, if the RUNNING packet too for some reason is not able to get the preferred link, then it too changes its state back to NORMAL state and proceeds as a normal packet only. 2.3 Node Structure: Each node (except at edge of node) is connected to adjacent node by bidirectional links. The UP, DOWN, LEFT and RIGHT links would be followed by the packet to go to the next node such that it comes closer to the destination node. Figure 3 and 4 shows examples of packet movement. 2.4 Assumptions Made Following assumptions are made to simplify the implementation of the algorithm: When two packets having the same state try to get the same preferred link then the simulated packet will not get the preferred link. The mesh structure will be 15x15. We needed to decide on the size of the mesh and we selected 15 as it is big enough to simulate a real network mesh yet small enough to keep the experimental complexity with in our limits of time and practical implementation. Only one packet is simulated at a time and some other nodes will be blocked to simulate actual conditions when many packets will be moving in the mesh. Links have uniform cost of 1. Nodes are separated by uniform distance Page 5 of 10 3. Algorithm In the paper “Hard Potato Routing” [1], the authors have given a theoretical description of the algorithm. This is a greedy algorithm as the packet will decide on the preferred link to be followed considering only the surrounding nodes. Thus it will be a choice that looks best at that time. This may not necessarily help the packet reach the node . We define sourceNode as the source node , currentNode as the node at which the packet is present for the current time event and destNode as the destination node. state is the current state of the packet (0=normal, 1=excited, 2=running).Link is either up, down, left or right depending on the preferred link obtained for a node. currentNode = sourceNode Algorithm: do till currentNode != destNode { if state is normal obtain link for the shortest path to destination if state is excited or running obtain preferred link to destination if link obtained is taken by other packet && state of other packet is higher then change state of packet and redo Algorithm else update currentNode and redo Algorithm } The above code just tries to show the very basic logic being implemented in the simulator. The algorithm will terminate when the currentNode will become equal to destNode. Actual implementation[7] is more complex then shown here. The running time of the algorithm will depend on the number of time events needed by the packet to reach destination. The space storage will include all the nodes along with up to four links per node. 4. Experimental Results We will now give the results that we have obtained. In the next Section 5 of calculation we compare them with the theoretical proofs given in the paper “Hard Potato Routing”[1]. 4.1 Experimental Setup Using java gave us the advantage of platform independence. We could thus compile our code on any machine and then run the simulations on other machine depending on which was free. Also visual simulation in java is easier to do than in any other language. For the actual coding part we used Microsoft Visual J++ 6.0. 4.1 Time and Space complexity. We show the time and space complexity of this routing algorithm here. We tested the time complexity for a true many to one batch routing instance. Each instance of the test was calculated for 3 times to give us a average values. The instances which we took were sending 6,10,20,40,50,70,80,90,100,117 and 150 random nodes heading towards a single destination. The graphs for the time complexity and the space complexity are as shown below: Page 6 of 10 Time complexity: Space Complexity: Space analysis 300 31300 250 31200 space in Bytes Time taken in steps Time Analysis 200 150 100 31100 31000 30900 30800 30700 50 30600 0 30500 6 10 20 40 50 70 80 90 100 117 150 Number of packets Figure 6: Time Complexity Graph 6 20 50 80 100 150 Num ber of packets Figure 7: Space Complexity Graph The time taken was measured in number of steps taken to reach the destination. One of the assumptions here is that time is discrete and at each time event, packet can go only one step. Also, we assumed that this time constant be one second. Thus 300 steps means 300 seconds. The importance of steps is explained further ahead. As we see in the space complexity diagram, the space required by the algorithm also goes on increasing steadily. Though the graph does not show a appreciable change in values of the space, this is because of the number of packets tested. The graph will show this behavior even for greater number of nodes tested. Also according to lemma 5.16, for any batch problem instance, with high probability (1-1/n) all packets reach their destination nodes in at most O(mln3n) steps. The calculation by taking m and n as 15 gives us 297.89 steps. 4.3 Probabilistic calculations verifications- our interest. From the time analysis graph above we noticed that the observation hold true. While the 6 packets finished in 32 steps, 117 packets took 273 steps to reach their destination. 150 packets took 291 steps to reach the destination. All these steps were well within the bounds that the authors mention above. Thus it is proved that O(mln3n) steps bound does hold true. and The authors claim in lemma 5.16 that with a high probability of (1- 1/n) the packets will reach their destination. In our experimental results we tried to verify the same. We noticed some discrepancy in the high probability which the authors define and the results we obtained. The authors claim of (1-1/n) for mesh size of 15x15 gives us a success rate of 93% ( substitute n=15) in the equation. However, we did not notice these figures. Page 7 of 10 (1-1/n) probability verification 100 % success 80 60 40 20 0 6 10 20 40 50 70 80 90 100 117 150 no of packets tested Figure 8: Probability Verification Graph We tested the algorithm for 6,10,20,40,50,70,80,90,100,117,150 packets in a many to on batch system, wherein all the packets were headed to the same destination. For each run of the algorithm, we simulated the case 3 times to get an average. The probability plot for this experiment is as shown above. Interesting Results: We noticed some interesting results when we performed this experiment. Though the authors give us a success rate of 93%, we didn’t see it in our tests. We got success rate of 100% for 6 packets, but it was well below the claimed success rate for 117 packets with 68% and 150 packets with 56%. However we do believe that for a mesh of much larger sizes, the success rate will improve. The improvement will be seen as the packets further away and ‘right’ of the destination node have a much greater chance of making it to the destination. This is explained in detail in the next section as a special case for 117 nodes. 4.4 Special case with 117 packets. Here we tried to find out that given a mesh with some packets heading towards a destination, how many would actually reach there. To do this, we implemented author’s idea. That is we launched adversary packets in the path of the normal packets to deflect them. This was done in the simulator by making the nodes occupied, and setting their priorities to normal, excited or running in advance. Also, we make a assumption here that for every packet that we chose to run, the adversaries were already there to stop the packets at that time instant. Also, to simplify our analysis, we chose as many as 117 arbitrary nodes as adversary packets, situated across the mesh evenly. Also, to simplify things further, we further assumed that our test packets would be one of the adversary packets only; hence thereby avoiding the complexity of the analysis. A few interesting results were seen while simulating the algorithm. The packets in the middle portion of the 15 x 15 mesh had higher probability of making it to the destination successfully. Also, packets in the first vertical band almost never made it to the destination, while those in horizontal bands made it successfully. The probability of packets far away from the destination is more than the ones near them. As seen from the graph, we see that as the destination (N1103) gets further away from the nodes belonging to N0010 or N0100 lines, the probability of those packets making it to destination was also less. Out of the 117 packets tested, 79 successfully made it to the destination. It was interesting to note that even though packet might be nearer to destination did not mean that it would reach the destination quicker. This was noticed for all the cases we tested. That is this behavior was observed specifically for 40,50,70,80,90,100,117,150 packets setup Page 8 of 10 density of packets reaching destination 79/117 reach destination. their journey successfully. However, using hard potato routing, 10 out of 11 packets reached their destination successfully. Here too we see that hard-potato routing algorithm performs better than a naïve algorithm 2.5 2 1.5 Series1 1 For simplicity sake we leave out the rest of the calculations we performed. We noticed that the hard potato routing algorithm does perform better than a naïve shortest path algorithm. 0.5 5.0 Theoretical Calculations n1308 n1110 n0907 n0711 n0514 n0401 0 n0000 time taken in steps 3 points ( nodes) dest:1301 Figure 8 Graph showing Density of Packets Reaching Destination 4.5 Comparing with naïve algorithm. Here we chose to demonstrate how this algorithm works better than a normal shortest path algorithm. We chose to compare this algorithm with shortest path algorithm for simplicity sake. In a shortest path algorithm, each packet tries to get to destination in the shortest possible way. If there is a collision between 2 packets, then one of the packets is lost. We conducted 2 sets of experiments. In the first experiment we chose to target 6 packets to a single destination. Using the naïve algorithm, we noticed that we lost 3 out of 6 packets due to collisions. However, using the hard potato routing algorithm we found that all 6 packets reached their destination successfully. The hard potato algorithm gives us a rise of 50% efficiency in this case. In the second experiment, we chose to have multiple destinations with multiple sources. This time we had 2 destinations, with 6 packets headed to first destination and 5 packets headed to second destination. Using naïve algorithm, we found that out of 11 packets, only 7 made There are several lemmas which have been given by the authors of the papers. We find values for a few of the lemmas given and present some insights into same. 5.1 lemma 5.2 calculation of ‘m’ The value of ‘m’ as given by the authors is as shown below: m >= dest(S)/n Where dest(S) is maximum number of the packets that can be routed (225 in our case) and n is 15. Hence m is m = 225/15 = 15. So there can be at the most maximum m destination packets in the submesh. The parameter ‘m’ is defined as the maximum number so that no k x k square has more than mk destination packets. In this case it is 15. 5.2 lemma 5.14: If a packet ‘phi’ is deflected x times, then it will reach its destination in at-most 2x + 2n – 2 steps. This was verified by doing the results. A packet deflected 2 times took less than 32 steps to reach the destination. In fact all the packets make it within this result only. Similarly a packet deflected 4 times took less than 36 steps Page 9 of 10 to reach the destination. This was observed for the cases tested. 5.3 Constants used in the calculations 1. c= 24e = 24*2.72 = 65.28 2. c’ = 3*24clg2 e = 4700 3. t0 = c’mln3n + 2n = 1410030 4. t1 = 3c’mln3n = 4230000. m and n values remain same as 15. This is clear from lemma 5.2 proved above. These constants were used to derive different formulas presented in the original paper. Using these values, the authors come to a final probability of ( 1-1/n) and the bounds O(mln3n) steps. 6.0 Summary and Future scope of the results. We successfully show an implementation of a hard-potato routing algorithm experimentally and verify the same with author’s theoretical calculations. Though there is a disparity of results when considering large number of packets, given the algorithm nature, we are sure that that the efficiency of the algorithm increases for mesh of large size. As noticed, mesh with very large size might also have a success rate of 100%. Also this algorithm shows significant improvement over a naïve shortest path algorithm we compared with. The gains of more than 50% in efficiency, leads us to believe that the lower bounds that the authors mentioned can be attained for a large size mesh. 5.4 Scope of the results. It is to be noted that the probability of getting a success of 93% is when we consider a mesh of 15 x 15 network. It is immediately apparent that for larger sizes of mesh, this probability of success might increase. In fact for a very large mesh networks, the success rate might be as good as nearer to 100%. However, there might be some disparity between this result and actual result by experimental results. As the density graph shows, we showed that nodes further and right from destination had great chance of making it to destination. Hence in a very large network, this also means that more number of packets will make it to destination, thereby increasing the success rate. Also, we perform the experimental results for a relatively smaller size of network than the authors aim to consider. We chose a small network because of the simplicity. . Future work on the project may include verifying the algorithm on a very large n x n mesh. Also, it remains to be seen if this algorithm works as efficiently on a real network without unit distances between nodes and equal costs of the links. The authors themselves pose question on the validity of algorithm over networks of dissimilar topological sizes and very large size networks like internet. We successfully show the algorithm on a 15x15 network and further work could include modification of the simulator to test the algorithm on dissimilar networks and verify if the algorithm holds. Page 10 of 10 References [1] C Busch, M Herlihy and R Wattenhofer. Hard Potato Routing. In the proceedings of the thirty-second annual ACM symposium on Theory of computing , pages 278-285, May 21 23, 2000, Portland, OR USA. [2] Y. Mansour and B. Patt-Shamir. Many to one packet routing on grids. In the proceedings of the twenty-seventh annual ACM symposium on Theory of computing. Pages 258-267 [3] P. Baran. On distributed communications networks. IEEE Transactions on communications. Pages 1-9,1964 [4] C Busch, M Herlihy and R Wattenhofer. Randomized greedy hot-potato routing. In proceedings of the eleventh annual ACM-SIAM Symposium on Discrete Algorithms. Pages 458466, Jan. 2000 [5] U. Feige and P. Raghavan. Exact analysis of hot-potato routing. In IEEE, editor, Proceedings of the 33rd Annual Symposium on Foundations of Computer Science. Pages 553-562 [6] A. Ben-Dor, S. Halevi, and A.Schuster. Potential function analysis of greedy hot-potato routing. Theory of Computing systems. Pages 31(1):41-61 [7] S. Deshpande and J. Patel. Source code of Hard Potato Routing Simulation. Available on the web at http://userpages.umbc.edu/~suyog1