The other_sleep Function

The function other_sleep was called often throughout the Worm's main loop. Although the name of the function seems to be fairly descriptive, other_sleep actually had a number of tasks to perform. It was this function that was in charge of detecting other worms in the system. (Thus it was the effective failure of this function that caused crowds of worms to swarm systems. This will be discussed in a moment.)

The function other_sleep was called with an integer as its argument. It would then check the global variable other_fd. If this variable was negative, it would simply wait the amount of time specified by its argument, and then pick up where it left off.

Otherwise, the Worm would listen for the presence of other worms on the network it was infesting.
If the Worm detected a signal that was possibly another Worm, the Worms would exchange two pre-specified "magic numbers" to verify that it is, indeed, connected to another worm. If it was, the listening Worm would transmit a random number to the other Worm. If the random number produced was odd, the pleasequit global variable in the listening Worm was set. Otherwise, the pleasequit variable of the other Worm was set.

In any case, after the specified amount of time, the other_sleep function would return control to where it was called.

The pleasequit variable was the indicator that the Worm was supposed to quit at the end of its next cycle of doit. However, this still means that the Worm must finish up everything that it was doing before it will even consider quitting. In addition, Morris programmed in a catch that the Worm would only quit if it had already:

This was one of a number of flaws involving other_sleep that led to the flooding of systems with a number of worms. There are other cases which would cause other_sleep to fail to detect other Worms:

If several Worms infected a clean machine at once, all of them would attempt to look for listening worms. None would succeed. All of them would attempt to become listeners. Only one of these would succeed. The rest of the Worms would become immortal. (Worm immortality will be described in just a bit.)
If several Worms started at once in the presence of a running Worm, and the running Worm looses in the decision as to which process quits, all the new Worms would, by default, win and continue with their tasks.
If a machine is heavily loaded (which happened quite a bit under the influence of the Worm) it could cause too much lag time to occur between the exchange of "magic numbers" between two Worms. Both Worms will then assume that they had received a false signal, and continue as normal.

Finally, in what was probably meant as an effort to make it difficult to eliminate the Worms simply by making a global variable called pleasequit on the network and perpetually setting it to make the worms quit, Morris designed it so that, on a random chance, a certain percentage of Worms would never listen for other Worms, and thus never have to worry about what its pleasequit variable is. Morris chose to make this percentage of Worms 1 in 7. If Morris was actually trying to make the worm innocuous, as he claims, this choice was off by a factor of about 10,000. With 1 in every 7 worms never dying, it is small wonder that systems were overloaded as quickly as they were.
(you will need to backtrack to where you were before, as there are a number of routines that call other_sleep)

Return to the main Worm page.