1 / 17

A Javascript Implementation of the Binary DIS Protocol

A Javascript Implementation of the Binary DIS Protocol. Don McGregor, Don Brutzman , Curt Blais , MOVES Institute. mcgredo@nps.edu. Javascript & Web Networking. Javascript ? That’s just a toy language, right?

bao
Download Presentation

A Javascript Implementation of the Binary DIS Protocol

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. A Javascript Implementation of the Binary DIS Protocol Don McGregor, Don Brutzman, Curt Blais, MOVES Institute mcgredo@nps.edu

  2. Javascript & Web Networking Javascript? That’s just a toy language, right? 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 page

  3. Web Networking WebRTC (Javascript UDP) Web Page: Internet Explorer Web Page: Firefox Mobile Websocket (Javascript TCP socket) Web Server Content: Javascript, 3D, images, graphing, Maps, mash-ups

  4. 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 Javascriptmessages 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

  5. 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

  6. What Message Format? These are the pipes; What format should we send state information such as position and orientation? 6

  7. 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

  8. 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 http://caniuse.com So why not use this to implement classic IEEE-1278.1?

  9. 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

  10. Using Javascript DIS // Receive and decode a message NetworkSingleton.prototype.onMessage= function(evt) { // convert from binary to javascript object varpduFactory = new dis.PduFactory(); varpdu = pduFactory.createPdu(evt.data); switch(pdu.pduType) { case 1: ….. // Convert to local (or lat/lon/alt) coordinates varlocalCoordinates = rangeCoordinates.ECEFtoENU(espdu.entityLocation.x, espdu.entityLocation.y, espdu.entityLocation.z); // Encode DIS vardataBuffer = new ArrayBuffer(1500); varos = new dis.OutputStream(dataBuffer); espdu.encodeToBinaryDIS(os); vartrimmedData = dataBuffer.slice(0, os.currentPosition); websocketConnection.send(trimmedData);

  11. Performance Compared to JSON Binary DIS vs JSON-encoded DIS, longer bars better Yellow JSON DIS, red binary DIS

  12. Performance Notes See http://jsperf.com/javascript-dis-native-vs-json/2, 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 CPU In general, the simulation implementation is more likely to be an issue than the networking overhead, particularly with 3D.

  13. Binary Javascript DIS VsWebLVC WebLVCJSON 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 http://jsperf.com/javascript-dis/13

  14. 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 IOSand Android

  15. Google Maps + DIS in Browser

  16. Availability • Free, BSD non-viral license • https://svn.code.sf.net/p/open-dis/code/ 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 https://www.npmjs.org/package/open-dis

  17. 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.jstransport gateways on the server side? Integration with voice, video in web browsers and DIS intercom PDUs Integrate with <your favorite web-based application>

More Related