Networking by Example!        Noury Bouraqadihttp://car.mines-douai.fr/noury  "Deep Into Smalltalk" Spring School     8 ma...
2                   Agenda•  Networking Basics  –  Sockets and protocols  –  Client vs. Server  –  Hands-on with SocketStr...
3 Software                          Software                 NeworkProcess                              Process           ...
4   Device A                          Device B Software                              Software                   NeworkProc...
5                Device Z Software                          Software                 NeworkProcess                        ...
6                 2 Main                Transport                Protocols          TCP               UDPTransmission     ...
7                  2 Main                 Transport                 Protocols          TCP                UDP•  Connected ...
8Focus                 SSH    POP                 TCP         SMTP          HTTP         FTP
9    Connection     Handling     ProcessServer                 Client A                 Communication                   Pr...
10    Connection     Handling     ProcessServer                   Client A   Communication   Communication     Process    ...
11    Connection     Handling     ProcessServer             Client B                   Communication                     P...
12    Connection     Handling     ProcessServer             Client B   Communication   Communication     Process         P...
13    Connection     Handling     Process       Client C                   Communication                     ProcessServer...
14    Connection     Handling     Process       Client C   Communication   Communication     Process         ProcessServer...
15  Client Socket So cketS tream!1.  Connect to a server2.  Send a String3.  Receive a String4.  Close
16         Server for Tests            Serve                            Unix!echo "Smalltalk" | nc –lk 12345    Multiple  ...
17|stream|stream := SocketStream   openConnectionToHostNamed: localhost   port: 12345.[   stream sendCommand: Pharo’.   Tr...
18Simplest Possible Server1.  Listen on some port2.  Accept 1 single client connection3.  Send a String4.  Receive a Strin...
19          Client for Tests              Host                               Unix!echo "Smalltalk" | nc localhost 12345   ...
20connectionSock := Socket newTCP.[  connectionSock listenOn: 12345 backlogSize: 10.  interactSock := connectionSock      ...
21                                      Tw itterLuc: I’m struggling with the robots----------Noury: Which robots? WifiBots...
22         Multi-threaded             Server                             1 process                          for connection...
23         Multi-threaded                              fork             Server                             1 process      ...
24Socket   10110101   Socket  1                   2         Network
25        Copying an object !10@34                         10@34                              110101 1011Socket        101...
26    ReferenceStreamstreamed           Represen                      tationOf: 1                                 0@34
27Classes should be  on both sides
28Remote messaging     Network
29proxy               dispatcherSocket                Socket  1      10110101       2         Network
30                                     id3                               id1proxy                    dispatcher id1Socket ...
31 RemoteTranscript
32                      Code          Proxy    Deployment                      Message(De-)Serializing   passing control  ...
33           Proxy                        Message                     passing controldoesNotUnderstand:
34               ReferenceStream                   unStream: aString(De-)Serializing   MessagesstreamedRepresentationOf: a...
35What           OCEANNext?          New Socket                 LibraryDistributed-  Objects    (rST)
a Clean, PortableNetworking Library
Current network library                               ByteArray TCP+              IPv4UDP+…              +IPv6          So...
OCEAN Library             Socket   networkLibrary                 NetworkLibraryProxyFactory   socketID                   ...
OCEAN Library Lates t                               ers io n             Socket           v   networkLibrary              ...
OCEAN for Pharo 1.3             ALL                             Primitives ! Image   Socket         Plugin         Library...
OCEAN for Pharo 1.4?                                PosixImage         Socket                               Library       ...
OCEAN + FFI + Posix     350     300     250     200                              Oceanms     150                          ...
GeneralizationImage      Library   Library   Library              A         B         ZVM                    FFI      Smal...
44
Upcoming SlideShare
Loading in …5
×

Pharo Networking by Example

3,269 views

Published on

Invited Speaker at the first "Deep into Smalltalk" spring school. 7-11 march 2011. The pdf of this slides is also available onlie at: http://car.mines-douai.fr/noury/docs/deepIntoSmalltalk2011

Published in: Technology
0 Comments
3 Likes
Statistics
Notes
  • Be the first to comment

No Downloads
Views
Total views
3,269
On SlideShare
0
From Embeds
0
Number of Embeds
5
Actions
Shares
0
Downloads
38
Comments
0
Likes
3
Embeds 0
No embeds

No notes for slide

Pharo Networking by Example

  1. 1. Networking by Example! Noury Bouraqadihttp://car.mines-douai.fr/noury "Deep Into Smalltalk" Spring School 8 march 2011 - Lille, France
  2. 2. 2 Agenda•  Networking Basics –  Sockets and protocols –  Client vs. Server –  Hands-on with SocketStream•  Serving –  Connection vs. communication –  Hands-on Concurrency!•  Complex interactions –  Exchanging objects over a network –  Remote messaging Hands-on
  3. 3. 3 Software Software NeworkProcess Process Soc ke oc ket t S Bi-directional communication
  4. 4. 4 Device A Device B Software Software NeworkProcess Process Soc ke oc ket t S
  5. 5. 5 Device Z Software Software NeworkProcess Process Soc ke oc ket t S
  6. 6. 6 2 Main Transport Protocols TCP UDPTransmission User Control Datagram Protocol Protocol
  7. 7. 7 2 Main Transport Protocols TCP UDP•  Connected •  Connection free •  Reliable •  Unreliable •  Streams •  Limited size
  8. 8. 8Focus SSH POP TCP SMTP HTTP FTP
  9. 9. 9 Connection Handling ProcessServer Client A Communication Process
  10. 10. 10 Connection Handling ProcessServer Client A Communication Communication Process Process
  11. 11. 11 Connection Handling ProcessServer Client B Communication Process Client A Communication Communication Process Process
  12. 12. 12 Connection Handling ProcessServer Client B Communication Communication Process Process Client A Communication Communication Process Process
  13. 13. 13 Connection Handling Process Client C Communication ProcessServer Client B Communication Communication Process Process Client A Communication Communication Process Process
  14. 14. 14 Connection Handling Process Client C Communication Communication Process ProcessServer Client B Communication Communication Process Process Client A Communication Communication Process Process
  15. 15. 15 Client Socket So cketS tream!1.  Connect to a server2.  Send a String3.  Receive a String4.  Close
  16. 16. 16 Server for Tests Serve Unix!echo "Smalltalk" | nc –lk 12345 Multiple Port connections number
  17. 17. 17|stream|stream := SocketStream openConnectionToHostNamed: localhost port: 12345.[ stream sendCommand: Pharo’. Transcript cr; show: (stream nextLineLf).] ensure: [ stream close]
  18. 18. 18Simplest Possible Server1.  Listen on some port2.  Accept 1 single client connection3.  Send a String4.  Receive a String5.  Close
  19. 19. 19 Client for Tests Host Unix!echo "Smalltalk" | nc localhost 12345 Port number
  20. 20. 20connectionSock := Socket newTCP.[ connectionSock listenOn: 12345 backlogSize: 10. interactSock := connectionSock waitForAcceptFor: 30. stream := SocketStream on: interactSock. stream sendCommand: Pharo Server!’. Transcript cr; show: stream nextLineLf.] ensure: [ connectionSock closeAndDestroy. stream close.]
  21. 21. 21 Tw itterLuc: I’m struggling with the robots----------Noury: Which robots? WifiBots orRobulabs?---------- likeLuc: I need to setup the internal board ofRobulab #2----------
  22. 22. 22 Multi-threaded Server 1 process for connections 1 processfor each client Sycnrhonization is needed
  23. 23. 23 Multi-threaded fork Server 1 process for connections 1 processfor each client Mutex Sycnrhonization is needed critical:
  24. 24. 24Socket 10110101 Socket 1 2 Network
  25. 25. 25 Copying an object !10@34 10@34 110101 1011Socket 10110101 Socket 1 2 Network
  26. 26. 26 ReferenceStreamstreamed Represen tationOf: 1 0@34
  27. 27. 27Classes should be on both sides
  28. 28. 28Remote messaging Network
  29. 29. 29proxy dispatcherSocket Socket 1 10110101 2 Network
  30. 30. 30 id3 id1proxy dispatcher id1Socket Socket 1 10110101 2 Network
  31. 31. 31 RemoteTranscript
  32. 32. 32 Code Proxy Deployment Message(De-)Serializing passing control Messages Argument Garbage passing Collection? by reference
  33. 33. 33 Proxy Message passing controldoesNotUnderstand:
  34. 34. 34 ReferenceStream unStream: aString(De-)Serializing MessagesstreamedRepresentationOf: anObject
  35. 35. 35What OCEANNext? New Socket LibraryDistributed- Objects (rST)
  36. 36. a Clean, PortableNetworking Library
  37. 37. Current network library ByteArray TCP+ IPv4UDP+… +IPv6 Socket SocketAdress irty! HTTPSocket SocksSocket D 0% t ested
  38. 38. OCEAN Library Socket networkLibrary NetworkLibraryProxyFactory socketID WindowsLibrary MacOSLibraryTcpSocket UdpSocket LinuxLibraryOOP 100% tested NetworkingPlugin WrapperLibrary
  39. 39. OCEAN Library Lates t ers io n Socket v networkLibrary NetworkLibraryProxyFactory socketID WindowsLibrary MacOSLibraryTcpSocket UdpSocket LinuxLibrary 100% PharoOOP 1.3 tested NetworkingPlugin WrapperLibrary
  40. 40. OCEAN for Pharo 1.3 ALL Primitives ! Image Socket Plugin Library Wrapper VM Socket Plugin OS Network API
  41. 41. OCEAN for Pharo 1.4? PosixImage Socket Library Library WrapperVM Smalltalk FFI OOP IDE PluginOS Posix Library
  42. 42. OCEAN + FFI + Posix 350 300 250 200 Oceanms 150 OldSocket 100 50 0 Receive 10MB Send 10MB
  43. 43. GeneralizationImage Library Library Library A B ZVM FFI Smaller VMOther OS API α API β API ψ
  44. 44. 44

×