Wireshark-dev: Re: [Wireshark-dev] Disabling idle sleep while a capture is in progress?

From: Guy Harris <guy@xxxxxxxxxxxx>
Date: Tue, 2 Jul 2019 12:30:53 -0700
On Jul 2, 2019, at 2:16 AM, Roland Knall <rknall@xxxxxxxxx> wrote:

> Is there a possibility on Windows to avoid sleep and restarts altogether? Must be, otherwise video apps would have issues, but that could be connected to the drivers right?

SetThreadExecutionState():

	https://docs.microsoft.com/en-us/windows/win32/api/winbase/nf-winbase-setthreadexecutionstate

supports "away mode":

	The ES_AWAYMODE_REQUIRED value should be used only when absolutely necessary by media applications that require the system to perform background tasks such as recording television content or streaming media to other devices while the system appears to be sleeping. Applications that do not require critical background processing or that run on portable computers should not enable away mode because it prevents the system from conserving power by entering true sleep.

	To enable away mode, an application uses both ES_AWAYMODE_REQUIRED and ES_CONTINUOUS; to disable away mode, an application calls SetThreadExecutionStatewith ES_CONTINUOUS and clears ES_AWAYMODE_REQUIRED. When away mode is enabled, any operation that would put the computer to sleep puts it in away mode instead. The computer appears to be sleeping while the system continues to perform tasks that do not require user input. Away mode does not affect the sleep idle timer; to prevent the system from entering sleep when the timer expires, an application must also set the ES_SYSTEM_REQUIRED value.

A network is a "medium" - otherwise, why would they have a "{medium, media} access control" layer? - and a network analyzer is "recording" network traffic "content", so that sounds as if it's what we should be doing.

This article from 2005:

	https://blogs.msdn.microsoft.com/david_fleischman/2005/10/21/what-does-away-mode-do-anyway/

says that "Away Mode is only offered with new PCs"; I don't know whether that means it requires particular hardware features.

I don't know whether that mode prevents sleep even when you're on battery power.

There's also "system required" mode:

	To run properly on a power-managed computer, applications such as fax servers, answering machines, backup agents, and network management applications must use both ES_SYSTEM_REQUIRED and ES_CONTINUOUS when they process events.

but I don't know whether that prevents sleeping.