• Updated 2023-07-12: Hello, Guest! Welcome back, and be sure to check out this follow-up post about our outage a week or so ago.

WakeonLan (wol) on Classic MacOS

beachycove

Well-known member
Silly question, and it's not mission-critical, but there is a method in my madness:

Is it possible to send out a wol packet on a LAN using something like MacPerl, MacTerminal, or even the Communications module in ClarisWorks?

I have read online that it is possible to develop a wol application in MPW, but I have no experience of those mysteries and would prefer to deal with something closer to my comfort zone if possible.

 

Gorgonops

Moderator
Staff member
I've never used Macperl, but doing a quick Google seems to imply that it should be doable to send a WOL magic packet with it if it offers a working version of the Socket module. (There are lots if fairly short examples of WOL scripts in regular Perl floating around.)

 

TylerEss

Well-known member
I could swear that about 10 years ago I had a MacOS program that sent WoL magic packets. I didn't write it myself, it was freeware or something like the same.

Wish I remembered what it was called.

 

beachycove

Well-known member
Well, after further digging I came across a couple of pieces of information:

1. this from a Macworld discussion post:

"The port you send to is entirely irrelevant. You could send it on another IP protocol such as ICMP that doesn't have ports at all, or on MS or Apple's old systems (NetBEUI/AppleTalk) or even plain raw Ethernet. All that's required is that the network card see a certain sequence of bytes on the wire.

It's common to use UDP port 9 because this is the "Discard" port from the early days of IP. Using this means WOL won't interfere with anything else you might have running. However, using some other port might be handy if it's already opened to allow another service to run. TCP port 80 would be a good example - anyone who runs a Web server would be able to use WOL on 80 without any further configuration."

2. and this (available from any number of sources) contains an example of the "sequence of bytes" in question at the bottom — the numbers repeated 16 times being the target MAC address of the ethernet card. In this case UDP port 7 appears to have been used. Looks simple enough:

magic-packet.png

 

Gorgonops

Moderator
Staff member
"It's common to use UDP port 9 because this is the "Discard" port from the early days of IP. Using this means WOL won't interfere with anything else you might have running. However, using some other port might be handy if it's already opened to allow another service to run. TCP port 80 would be a good example - anyone who runs a Web server would be able to use WOL on 80 without any further configuration."
So here's the deal: WOL *is* a very dumb protocol. It basically leaves the MAC transceiver on the Ethernet card stuck on in promiscuous mode looking for a packet which contains the correct sequence of bytes. If you were running with an Ethernet hub, not a switch (any Ethernet "hub" made after 2004 or so will almost certainly actually be a switch), then in principle you could wake a sleeping machine by, for instance, transferring a .BMP image file that has the correct byte sequence imbedded in it (as a pattern of colored lines) from one other machine to another over any protocol that doesn't encrypt or otherwise modify the packet payload. The key here is, however, is you'd have to be using a *HUB* instead of a switch because otherwise the ARP tracking hardware in the switch will channel the data payload between *just* the machines involved in the transfer so the sleeping machine will never see it.

When set for WOL the card is *not* running a TCP/IP stack and does not answer ARP requests so unless you are running on a completely dumb hub the only reliable way to generate a packet which will be seen by the sleeping machine is to send one to the broadcast address of the network. Setting the broadcast flag on the packet will instruct the ethernet switch to repeat said packet to every port and the only (commonly used) protocols which support broadcast are ICMP and UDP. Therefore there is no straightforward way to send a WOL packet with, say, a Telnet program since TCP by definition isn't a broadcast protocol.

Since a WOL packet is indeed so very simple it's fairly trivial to write a program to generate one but you probably *will* need a program unless you have access to some classic Mac program that lets you do some fairly obscure things, like generate ICMP ping packets with custom payloads.

 

TylerEss

Well-known member
...unless you have access to some classic Mac program that lets you do some fairly obscure things, like generate ICMP ping packets with custom payloads.
MacPing actually *does* let one specify the payload of ICMP ping packets. Sounds like we might have a winner!

Anybody want to try it?

 

beachycove

Well-known member
Thanks for that detailed response, Gorgonops. It confirms what I had rather less clearly surmised. What I did not know was the bit about embedding the sequence in something like an image file. I had thought maybe a plain plain ascii text file might be worth trying....

Hubs R Us on my old AppleTalk network, so we're good to go on that score.

I now think that what I am actually going to try to do in idle moments over the next little while is to get it working on a Newton. This will be probably be using NTK and associated Newton programming tools, which used to cost thousands but are now freeware. Yep. I have concocted the idea of using an eMate (I have three lying around) as a WOL appliance fronting a sort of gateway internet presence, doing what is necessary by referring on to blogspot, and perhaps some professional material hosted by my employer, and also making the home network accessible (to me) from anywhere. The Newton will be serving a basic webpage using NPDS, and the WOL script will run as an SSI. That's the plan, anyway. If successful, I'll release the script into the NPDS wild for others to use.

Since I can actally run my eMate from a small solar panel not much bigger than a couple of playing cards, AND charge the battery at the same time, this particular "Apple Server Solution" will be a good deal cheaper than running a dual G4 or possibly a dual G5 home server 24/7. This gives a whole new sense to the eMate as the Green Machine.

I know it would be trivial to do with php and Apache, but where's the fun in that?

 

beachycove

Well-known member
But MacPing sounds promising too! Never heard of it, but will give it a gander.

EDIT:

That would indeed do the trick, it seems from the manual, p. 28. You just write in the custom packet and direct it to the subnet/broadcast address of your router, or indeed send it out on ethertalk as Gorgonops explains. The application is also scriptable, so it could be called from a System 7-9 webserver through an AppleScript CGI.

I am kind of pumped about the Newton option, but if my Newton idea does not work, I'll know where to turn next.

 

olePigeon

Well-known member
Heh. Back in the dial up days, you could send an modem ATDT hangup command over MacPing and cause the target machine to freeze. I hated it.

 

dougg3

Well-known member
I wrote a utility for OS X to send Wake on LAN packets (WakeOnMac) quite a while ago. I know that info isn't any help for classic Macs, but I can confirm that my code does exactly what's described in this thread (send a broadcast UDP packet with those contents on any port), and it has plenty of success stories spread throughout forums on the internet :)

Heh. Back in the dial up days, you could send an modem ATDT hangup command over MacPing and cause the target machine to freeze. I hated it.
That reminds me of my dialup days back when I was into IRC. The lucky bastards who had broadband at the time could do some kind of a CTCP PING or something (it's been a while, can't remember exactly what it was) involving the string "+++" which promptly caused my modem to drop its connection. Those were the days...

Don't even get me started on the evil crap I did to classmates in the computer lab in middle school using AppleScript and (I think) program linking...(oh man, those were my stupid years)

 

dougg3

Well-known member
You mean like so you can wake a computer over the internet? I'm pretty sure a router on the internet at some point is going to drop the broadcast packet. It looks like the feature to look out for is called subnet directed broadcasts. It sends a "normal" packet until it arrives at the destination router, at which point the router turns it back into a broadcast packet. So if a destination router supports that feature, you might be able to wake computers behind it.

 

Gorgonops

Moderator
Staff member
I'm pretty sure no inexpensive commercial home router is going to support recieving subnet directed broadcasts from the Internet, since doing so would offer a trivial vector for allowing DoS attacks. (I imagine most if not all ISPs filter such things at a higher level anyway.) Also, 99.99995% of the time someone with a home network is going to be using RFC1918 addresses with NAT internally instead of public IPs, so from outside on the internet even if you could send a directed broadcast as far as the front door of the router the RFC1918 network on the inside where it has to be ultimately converted into a true broadcast packet is going to be unroutable.

I do... have to say I'm a little confused about what you're attempting. Is it that you want to send a WOL packet from somewhere on the internet to your sleeping machine at home directly, or did you want to have the Newton sitting awake inside your network and listening for the wake signal through your router (presumably listening on some TCP port forwarded through and aliased to your public IP), which upon reciept would itself send the wake packet to the sleeping server? If it's the latter a Newton is probably going to be a "challenging" platform to set up to do what you want.

 

markyb86

Well-known member
To do it over the internet into a home, the only way I can think to do so would be to remote into another computer in the home, and then use that machine to send the packet.

 

beachycove

Well-known member
The question about the broadcast address looks like a blind alley. I'll forget about that side of things.

The Newton will be on my Lan. It would run a very basic website, referring to other sites with which I am associated. It might run some of the NPDS stuff, we'll see (e.g. it has a Notes and Calendar server). For wol, I would connect to the index.html webpage it serves, navigate to another page most likely, and click on a button/link to send out the wol packet. The button/link would call the requisite script.

There is actually a boilerplate newtonscript for sending out a custom UDP packet in the programming documentation, so that part of it is easy. NPDS also has a scripting feature built in, and uses plain newtonscript too.

 

Dennis Nedry

Well-known member
I'm not sure on this, but you may have luck doing a wake-on-lan through a VPN connection. If you have a router running dd-wrt in the target location, it should at least be possible to talk to the router through VPN (which would be on all the time) and have it send a wake-on-lan.

My Power Mac G4 MDD would always wake up, every time, when I plugged in a certain transformer and if the wake-on-lan setting was enabled. I don't know what the deal was with that. It was very strange.

 

beachycove

Well-known member
Well, I have been working on my eMate webserver, after a short hiatus caused by a missing pcmcia dongle, and I still have great hopes for WoL functionality.

This is the first time I have tried this on a Newton, and I discover that NPDS is surprisingly complete as an html server, as long as you are content with text. I plan at the moment to make the site look a little like a blog, and avoid most of the usual NPDS modules -- who, after all, wants their dates and contacts online? Some of the ready-made modules are quite possibly a source of NPDS instability (e.g., the Calendar server appeared to want to go no later than 2008, so I wonder if there is some issue surrounding the date bug and/or patch, which I have on my Newtons). I have turned all that unnecessary stuff off by freezing the packages. Custom html, complete with CSS, still seems to serve just fine. It is not fast, but then, I did not expect it to be.

Scripting (via NewtonScript) is built in, and tackling this will be the next step after I get the html the way I want. NewtonScript is very powerful, so I may be some time....

I will provide a link in due course. Think Green!

 
Top