A Javascript Implementation of the
Binary DIS Protocol
Don McGregor, Don Brutzman, Curt Blais,
MOVES Institute
[email protected]
Javascript & Web Networking
• Javascript? That’s just a toy language,
• Not any more. Simulation applications can
be written in Javascript, and there are
significant advantages to doing so
• New Javascript networking standards
(Websockets, WebRTC) allow low latency,
high (ish) performance directly into the web
Web Networking
WebRTC (Javascript UDP)
Web Page:
Internet Explorer
Web Page:
Firefox Mobile
(Javascript TCP socket)
Web Server
Content: Javascript,
3D, images, graphing,
Maps, mash-ups
Web Networking
• Websockets allow low latency TCP sockets
between web page pages and servers in
Javascript—no polling, not wrapped in HTTP
• WebRTC can allow low latency UDP Javascript
messages directly between web pages
• Performance is not bad--~5K messages per
second to desktop clients for websockets
• It’s all unicast—no broadcast or multicast, with all
that implies
Why Do It?
• Compelling economic & system management
advantages for web-based simulation
– Distribute all applications from a central web server,
where it can be easily upgraded
– Cross-platform, including mobile
– Moves at web speed—can mash up with maps,
graphics, WebGL, Twitter, IM, …
– Scale out on cloud, low barrier to entry. Cloud-side
compute resources are effectively infinite
– How many desktop apps do you use today, vs how
many web based applications? That’s because the
economics are that compelling
What Message Format?
These are the pipes;
What format should we
send state information such as
position and orientation?
Message Format: JSON
One option is to send messages in JSON format
This is the approach taken by WebLVC
But this requires you to specify the format of the JSON
Lots of standards meetings
Message Format: DIS
• Classical Javascript wasn’t very good at
handling binary
• More modern Javascript can use
“ArrayBuffers” to manipulate binary data
• Support is good (~80% of current browsers
in the wild, will only get better as old
browsers are upgraded). See
• So why not use this to implement classic
DIS in Javascript
• Strong standards support, lots of gateway
support for HLA, TENA, AIS, other protocols
to DIS
• It’s already standardized
• DIS can be verbose and carries redundant
information compared to HLA RPR-FOM,
which is what WebLVC is based on
• Protocol issues such as heartbeat
Using Javascript DIS
// Receive and decode a message
NetworkSingleton.prototype.onMessage = function(evt)
// convert from binary to javascript object
var pduFactory = new dis.PduFactory();
var pdu = pduFactory.createPdu(;
case 1: …..
// Convert to local (or lat/lon/alt) coordinates
var localCoordinates =
// Encode DIS
var dataBuffer = new ArrayBuffer(1500);
var os = new dis.OutputStream(dataBuffer);
var trimmedData = dataBuffer.slice(0, os.currentPosition);
Performance Compared to JSON
• Binary DIS vs JSON-encoded DIS, longer bars better
• Yellow JSON DIS, red binary DIS
Performance Notes
• See, benchmark your
own browser, or create new benchmarks
• Both JSON and binary formats can be workable; depending on
Javascript engine they can even be about the same
• Browsers and Javascript engines matter a lot! JSON can be as fast as
binary on some browsers and Javascript engines (IE 11, for example)
• JSON can be faster on IE 11 than binary on Firefox
• I suspect in the long term results will converge towards the current
Safari benchmarks as Javascript engines improve
• OK performance on mobile—and it works on mobile!
• OK for a few thousand messages per second into the web page
(depending on lots of stuff) which puts about a 10% load on desktop
• In general, the simulation implementation is more likely to be an issue
than the networking overhead, particularly with 3D.
Binary Javascript DIS Vs WebLVC
• WebLVC JSON update messages have less state information and can
be parsed somewhat faster, but it’s in the same ballpark
• WebLVC can also avoid DIS heartbeats
Google Maps Example
• Application on server side listens for traditional
native UDP DIS on the local ethernet network. In
this case, AIS (real time commercial ship
locations) is being translated into DIS by JBUS
• Web page receives forwarded DIS messages via
websockets, decodes, does coordinate conversion
to lat/lon, displays icon on map. Also sends DIS
updates based on web browser geolocation
• Uses Google Maps Javascript API to implement a
real-time mapping application. Works on modern
browsers and mobile, including IOS and Android 14
Google Maps + DIS in Browser
• Free, BSD non-viral license
• open-dis-code/
– Includes server side code (to convert native UDP to websocket
transport) and client code in languages/javascript directory
• NodeJS is a scalable server-side Javascript
framework popular in Silicon Valley (used at
linkedin, twitter, ebay, etc.)
– NodeJS DIS javascript module available at
Future Work
• Open Street Map vs Google Maps to avoid proprietary
vendor dependencies, requirement to have a Google Maps
server inside classified areas
• Server side architecture for scalability: how much to put on
client vs server? How to limit traffic to the client? Inherent
unicast problems as the number of clients increase?
• Node.js transport gateways on the server side?
• Integration with voice, video in web browsers and DIS
intercom PDUs
• Integrate with <your favorite web-based application>

similar documents