Changes to the Telnet Client
The telnet client has two major changes. Similar to the server, the client has a rolling byte count that keeps track of how many bytes of data it has received from the server. More importantly, however, the telnet client also has a thread that receives notification from the host operating system when the (client) machine changes power state. For the client to notify the server of changes in power state, the client must receive these changes from the host operating system. We have provided two possible implementations for this. The first implementation works on Ubuntu Linux and utilizes a script that is invoked by the host operating system's sleep and wake power management scripts. The script simply connects to each running client and passes the state change on. Our second implementation utilizes the power management API of Mac OS X. In this case, the client receives power state change notification directly from the operating system. Once the client has been made aware of a change in power state, it simply passes the notification up to the server with a gtWSLE or gtWWAK message.
When the client wakes up, it reconnects to the server and performs a two-step information exchange before normal communication resumes. As in Figure 1, the client first receives the next reconnect port number from the server. The client then sends the server its byte count, which the server uses to calculate any data discrepancies. The client then resumes normal operation. If the server determines that any data has to be resent to the client, the client receives it via normal communication channels. That is, while the data may have originally been sent by the server prior to the client going to sleep, if the client missed this data for any reason it is simply resent in the normal manner after the client wakes up.
gtelnetd in Action
Figure 4 shows gtelnetd in action. Three clients are connected to an IRC server and chatting in the same room. Chatter "Alice" stays connected to the server the entire time, chatter "Bob" is using the gtelnet client, and chatter "Charlie" is using a regular telnet client. Both Bob and Charlie are logged into a shell account from which they run their respective IRC clients. At 05:33pm, Alice sees both Bob and Charlie enter the chat room. After some initial conversation, both Bob and Charlie send their machines to sleep at 05:35pm. Alice receives a message indicating that Charlie has disconnected from the IRC server due to a dropped TCP connection to the server he is running his IRC client on. Bob, however, effectively never leaves the chat room due to his usage of the gtelnet client. When his machine goes to sleep, the gtelnetd server buffers all data that is transmitted. When Bob wakes-up his machine at 05:44pm, he sees the messages that Alice transmitted when his machine was asleep. Charlie, however, reconnects at 05:46pm and has not received any of the chatting that took place between 05:35pm and 05:46pm.
Next Steps: Spreading the Meme
The developed gtelnetd is a useable application. All source code is available at sourceforge.net/projects/gtelnet and contributions are welcome. The techniques applied in the creation of gtelnet can be used in other client/server applications. Any interactive program in which data might be generated and delivery desirable, even though a user may not wish to respond in real time, is ripe for making power-state aware. While telnet is not used often anymore, SSH is popular and implementing power-state aware functionality should be very similar to our green telnet modifications. Instant messaging applications are another set of software in which clients may want to receive messages sent while the machine sleeps.
A Lawrence Berkeley National Laboratory technical report (enduse.lbl.gov/Info/LBNL-45917b.pdf) stated that, "proper functioning of power management would achieve additional savings of 17 TWh/year." At $0.10 per kWh, this is $1.7 billion per yeara very large savings potential! Many, if not most, desktop computers have power management completely disabled due to the inconvenience it causes to users. By removing the application state's dependency on a network connection as we have done with gtelnetd, users will be less inclined to disable power management. This can result in large savings of money and also reduce the CO2 footprint of PCs.
The development of this material is based on work supported by the National Science Foundation under grant CNS-0520081. Any opinions, findings, and conclusions or recommendations expressed in this material are those of the author and do not necessarily reflects the views of the National Science Foundation (NSF). The authors thank Axel Vigo from the University of Puerto Rico, Mayaguez for his early prototypes of green client/server applications.