ºÝºÝߣ

ºÝºÝߣShare a Scribd company logo
Sockets vs P2P
Communication on the Flash Platform
Aaron Boushley
›   Senior Developer at ZaaLabs, Ltd.
›   www.zaalabs.com
›   aaron@zaalabs.com
›   @boushley
Forms Of
Communication
›   Sockets
›   NetConnection + NetGroup
›   HTTPBased
    »   WebService (SOAP)
    »   HTTPService (REST)

›   RemoteObject (AMF)
High Level --
Sockets
›   Client-Server Architecture
›   Flash Independent
›   Requires a server of some kind
High Level -- P2P
      ›   Peer to Peer Communication
      ›   Adobe specific implementation (RTMFP)
      ›   No server required*, all clients can
          communicate




*P2P Setup requires a server or ip multicast to maintain the mesh.
Code Time...
Basic Sockets
War Games
WOPR example by Nate Beck
P2P Chat
›   Example by Tom Krcha
›   http://www.flashrealtime.com/simple-chat-p2p-netgroup-rtmfp/

›   Great demonstration of the basics of P2P
Forms Of




  The IP Stack
TCP vs UDP --
FIGHT!
          TCP                               UDP
›   Header Size: 32 Bytes        ›   Header Size: 20 Bytes

›   Guaranteed Order             ›   No Guarantee on Order

›   Guaranteed Delivery          ›   No Guarantee on Delivery

›   Uses Triple Handshake        ›   Single Packet



›   IP Header Size: IPv4 ->16 Bytes IPv6 -> 40 Bytes
Protocols
›   The RTMP Family (RTMP, RTMPT, RTMPS,
    RTMPE, RTMFP)
›   AMF (Socket#writeObject/readObject)
›   SOAP, Plain XML, JSON
›   Custom (Hopefully bit packed)
Custom
AMF

JSON


XML


SOAP
Custom Packing -

 Hex      Binary
 05      00000101
          First   Second Third
Custom Packing -
Integer


     Hex       Decimal
 00 00 04 D2    1234
Custom Packing
      Encode




      Decode
Sockets vs
›   Communication is (more) private   ›   Can function purely with Flash

›   Gets through most firewalls       ›   Broadcasts are simpler and
                                          Bandwidth Efficient
Private
Communication
›   Sockets send packets directly to recipient
›   P2P requires directing code
    »   Example
    »   http://www.flashrealtime.com/directed-routing-
        explained-flash-p2p/

›   Encryption for security over the network
    »   AS3Crypto -- https://code.google.com/p/as3crypto/
Sockets + P2P =
      <3
ZaaMulti
Questions?
http://github.com/

More Related Content

P2P vs Sockets: Communication on the Flash Platform

  • 1. Sockets vs P2P Communication on the Flash Platform
  • 2. Aaron Boushley › Senior Developer at ZaaLabs, Ltd. › www.zaalabs.com › aaron@zaalabs.com › @boushley
  • 3. Forms Of Communication › Sockets › NetConnection + NetGroup › HTTPBased » WebService (SOAP) » HTTPService (REST) › RemoteObject (AMF)
  • 4. High Level -- Sockets › Client-Server Architecture › Flash Independent › Requires a server of some kind
  • 5. High Level -- P2P › Peer to Peer Communication › Adobe specific implementation (RTMFP) › No server required*, all clients can communicate *P2P Setup requires a server or ip multicast to maintain the mesh.
  • 8. War Games WOPR example by Nate Beck
  • 9. P2P Chat › Example by Tom Krcha › http://www.flashrealtime.com/simple-chat-p2p-netgroup-rtmfp/ › Great demonstration of the basics of P2P
  • 10. Forms Of The IP Stack
  • 11. TCP vs UDP -- FIGHT! TCP UDP › Header Size: 32 Bytes › Header Size: 20 Bytes › Guaranteed Order › No Guarantee on Order › Guaranteed Delivery › No Guarantee on Delivery › Uses Triple Handshake › Single Packet › IP Header Size: IPv4 ->16 Bytes IPv6 -> 40 Bytes
  • 12. Protocols › The RTMP Family (RTMP, RTMPT, RTMPS, RTMPE, RTMFP) › AMF (Socket#writeObject/readObject) › SOAP, Plain XML, JSON › Custom (Hopefully bit packed)
  • 14. Custom Packing - Hex Binary 05 00000101 First Second Third
  • 15. Custom Packing - Integer Hex Decimal 00 00 04 D2 1234
  • 16. Custom Packing Encode Decode
  • 17. Sockets vs › Communication is (more) private › Can function purely with Flash › Gets through most firewalls › Broadcasts are simpler and Bandwidth Efficient
  • 18. Private Communication › Sockets send packets directly to recipient › P2P requires directing code » Example » http://www.flashrealtime.com/directed-routing- explained-flash-p2p/ › Encryption for security over the network » AS3Crypto -- https://code.google.com/p/as3crypto/

Editor's Notes