The dragon’s lair

Asking machines to identify themselves with ASCII control characters.

Background

I am fascinated by old technology, obsolete standards, and historical computing practices. Recently, while working on an ASCII signature for my email, I was looking at the table of all ASCII codepoints. What piqued my interest was the control characters—non-printable characters that carry functional or semantic meaning. I knew some of them (CR, LF), but most looked completely unfamiliar. After reading through some of them, I stumbled on what is in my opinion the most interesting one: WRU (“who are you?”) at codepoint 5, also known as ENQ (enquiry). According to wiki:

In[1]: StringSplit[WikipediaData["Enquiry character"],"\n\n"][[1]]  

Out[1]: In computer communications, enquiry is a transmission-control character that  
requests a response from the receiving station with which a connection has been set up.   
It represents a signal intended to trigger a response at the receiving end, to see  
whether it is still present. The response, an answer-back code to the terminal that  
transmitted the WRU (who are you) signal, may include station identification,  
the type of equipment in service, and the status of the remote station.  

Fascinating! The control character is a digital “hail” that’s asking the machine to identify and provide information about itself. Sadly, I also read that no modern machine or server responds to WRU requests. Following the old “trust but verify” adage, I decided to “hail” my work printer by sending it a WRU byte. In Wolfram Language, we can get ASCII characters with FromCharacterCode with the actual codepoint as an argument, so we want the following:

In[2]:(* Connect to the specified IP address and port *)
  socket=SocketConnect["10.10.162.48:9100"];
  (* Hail *)
  BinaryWrite[socket,FromCharacterCode[5]];
  (* Close the socket connection *)
  Close[socket];

The printer did not identify itself, but it beeped! However, that beep was an error sound that gets produced by every non-printable character, not just WRU. It seems to be my printer’s way of saying “I can’t print this”, rather than an identification. It is still fun to send WRU and hear the beep though.

If you want to harass your own printers with random bytes, you’ll need to find their local IP address. There are a few ways of finding that, but the easiest is just looking at the settings on the printer. Port 9100 is typically open on HP printers and used to receive printing jobs, but you scan open ports like this (using nmap on a zsh shell on macOS):

nmap -p 1-10000 10.10.162.48

This will give you a list of ports that the address is listening on.

Writing our own handler for WRU characters

Even though no modern hardware responds to WRU specifically, ASCII codepoint 5 is still valid, accessible and sendable by all machines, so nothing is stopping us from acknowledging it in our applications and responding to it. Below is a quick example of an APIFunction that performs a simple task: it shortens the URL that is passed to it. Since an APIFunction is technically just a server endpoint that waits for input, we can catch WRU bytes and respond to them in a custom way. Here is how we can do it.

In[3]: urlShortener=APIFunction[
	{"input"->"String"},
	If[#input===FromCharacterCode[5],
	  "I am a helpful API function that shortens the URLs you give me! 
	   I am running on " <> $MachineName <> " which is running a " 
		 <> $ProcessorType <> " CPU with " <>ToString[$ProcessorCount] <> " cores!",
	URLShorten[#input]
	] &
]; 

With APIFunctions, we typically want to deploy them to cloud so we can access them from any browser.

In[4]: CloudDeploy[urlShortener,"urlShortener",Permissions->"Public"]  

Out[4]: CloudObject["https://www.wolframcloud.com/obj/dimitark/urlShortener"]  

And with our WRU (note: we are using %05, which is the common browser way of passing URL-encoded characters).

In[5]: URLRead["https://www.wolframcloud.com/obj/dimitark/urlShortener?input=%05","Body"]

Out[5]: "I am a helpful API function that shortens the URLs you give me! 
  I am running on wolframcloud-prd-cmp-4j-7 which is running a x86-64 CPU with 2 cores!"

Awesome, our API function now correctly recognizes WRU characters and identifies itself! You can also test it for yourself -> https://www.wolframcloud.com/obj/dimitark/urlShortener?input=%05

Conclusion

While not particularly useful, tinkering with old ASCII codepoints is rather fun. Do you have/know of any modern machines that respond to WRU control characters? Will you be implementing WRU responses in your applications as a real identification mechanism or (more likely) as an easter egg? What other old standards or conventions do you know that might have cool applications as well?