This module monitors Zwift UDP traffic on port 3022 and TCP traffic on port 3023 (both contains protobuf payloads) and emits events for
- player state updates (incomingPlayerState and outgoingPlayerState)
- ride ons (incomingPlayerGaveRideOn)
- chat messages (incomingPlayerSentMessage)
- player entered world (incomingPlayerEnteredWorld)
On Windows this requires Npcap installed with WinPcap API compatibility. On other systems, libpcap should be installed.
The fork by jeroni is published as @zwfthcks/zwift-packet-monitor on NPM.
npm install @zwfthcks/zwift-packet-monitor
Alternatively, install with npm from GitHub
npm install https://github.com/jeroni7100/zwift-packet-monitor
or download/clone from GitHub and install directly from your local copy, for example like this if the copy resides in a sibling folder to your project:
npm install ../zwift-packet-monitor
The original version by wiedmann can be installed from NPM:
npm install zwift-packet-monitor
(Assumes installation from NPM)
const ZwiftPacketMonitor = require('@zwfthcks/zwift-packet-monitor')
// interface is cap interface name (can be device name or IP address)
const monitor = new ZwiftPacketMonitor(interface)
monitor.on('outgoingPlayerState', (playerState, serverWorldTime) => {
console.log(playerState)
})
monitor.on('incomingPlayerState', (playerState, serverWorldTime) => {
console.log(playerState)
})
// The Zwift server sends states in batches. This event is emitted at the end of each incoming batch
monitor.on('endOfBatch', () => {
console.log('end of batch')
})
monitor.start()
Npcap https://nmap.org/npcap/
Uses preprocessor.js (https://www.npmjs.com/package/preprocessor) via npx to build ZwiftPacketMonitor.js from ZwiftPacketMonitorSource.js
Build with
npm run preprocess