Automatic Generation of Network protocol gateways David Bromberg, - - PowerPoint PPT Presentation

automatic generation of network protocol gateways
SMART_READER_LITE
LIVE PREVIEW

Automatic Generation of Network protocol gateways David Bromberg, - - PowerPoint PPT Presentation

Automatic Generation of Network protocol gateways David Bromberg, Laurent Rveillre, Julia Lawall and Gilles Muller LaBRI University of Bordeaux Ubiquitous environment 2 LaBRI Heterogeneous protocols 3 LaBRI Gateways for providing


slide-1
SLIDE 1

LaBRI – University of Bordeaux

Automatic Generation of Network protocol gateways

David Bromberg, Laurent Réveillère, Julia Lawall and Gilles Muller

slide-2
SLIDE 2

2 LaBRI

Ubiquitous environment

slide-3
SLIDE 3

3 LaBRI

Heterogeneous protocols

slide-4
SLIDE 4

4 LaBRI

Gateways for providing interoperability

Translation logic

slide-5
SLIDE 5

5 LaBRI

Huge set of interaction protocols

FTP SIMPLE IAMC RTSP HTTP STOMP SIP NNTP DAYTIME SMTP MGCP GOPHER POP IMAP CHARGEN SSIP CCSO PINT XMPP BTP SOAP 9P GTP DELTA SNMP DIS APPC AMQP ALSP STUN RTCP DAP DNS DSP TLS SSH ENRP THRIFT CFDP RTP SMB NTP RMI IIOP SLP

slide-6
SLIDE 6

6 LaBRI

Binary protocols

FTP SIMPLE IAMC RTSP HTTP STOMP SIP NNTP DAYTIME SMTP MGCP GOPHER POP IMAP CHARGEN SSIP CCSO PINT XMPP BTP SOAP 9P GTP DELTA SNMP DIS APPC AMQP ALSP STUN RTCP DAP DNS DSP TLS SSH ENRP THRIFT CFDP RTP SMB NTP RMI IIOP SLP

slide-7
SLIDE 7

7 LaBRI

Textual protocols

FTP SIMPLE IAMC RTSP HTTP STOMP SIP NNTP DAYTIME SMTP MGCP GOPHER POP IMAP CHARGEN SSIP CCSO PINT XMPP BTP SOAP 9P GTP DELTA SNMP DIS APPC AMQP ALSP STUN RTCP DAP DNS DSP TLS SSH ENRP THRIFT CFDP RTP SMB NTP RMI IIOP SLP

slide-8
SLIDE 8

8 LaBRI

XML protocols

XMPP BTP SOAP FTP SIMPLE IAMC RTSP HTTP STOMP SIP NNTP DAYTIME SMTP MGCP GOPHER POP IMAP CHARGEN SSIP CCSO PINT

slide-9
SLIDE 9

9 LaBRI

Other protocol characteristics

FTP ….. ….. RTSP HTTP ….. SMTP IMAP ….. POP

Synchronous

….. ….. ….. ….. ….. NNTP SIP SNMP

Asynchronous

FTP ….. ….. RTSP HTTP ….. SMTP IMAP ….. POP

Unicast

…. ….. ….. …. ….. ….. SLP …. ….. ….

Multicast

slide-10
SLIDE 10

10 LaBRI

Developing a gateway

 Challenging task requiring

 knowledge of the protocols involved  substantial understanding of low-level network programming

 A gateway must take into account

 the different degrees of expressiveness of the different protocols  the range of communication methods used by the protocols  the need of the various protocols to maintain state across multiple messages

slide-11
SLIDE 11

11 LaBRI

Mismatched protocol expressiveness

 One single SIP request

multiple RTSP messages

RTSP SIP to RTSP Gateway RTSP agent SIP agent SIP

slide-12
SLIDE 12

12 LaBRI

Mismatched protocol expressiveness

 RTSP requests send synchronously using separate

TCP connections

SIP responses returned asynchronously over UDP

RTSP SIP to RTSP Gateway RTSP agent SIP agent SIP

Unicast / synchronous Unicast / asynchronous

slide-13
SLIDE 13

13 LaBRI

Heterogeneous communication

 One protocol on the left

several protocols on the right

SSDP SLP to UPnP Gateway UPnP service SLP agent SLP HTTP

slide-14
SLIDE 14

14 LaBRI

Heterogeneous communication

 Different communication schemes

 Unicast / Multicast

SLP agent SLP to UPnP Gateway SLP SSDP HTTP UPnP service

slide-15
SLIDE 15

15 LaBRI

Heterogeneous communication

 Different communication schemes

 Unicast / Multicast  Synchronous / Asynchronous

SLP to UPnP Gateway SLP agent SLP SSDP HTTP

Asynchronous

UPnP service

Asynchronous Synchronous

slide-16
SLIDE 16

16 LaBRI

Session management

 Multiple SMTP messages flow within the same TCP stream

 gateways need to manage a state SMTP over TCP HTTP over UDP SMTP over TCP

Unicast sync. Unicast async. Unicast sync.

TCP Stream TCP Stream SMTP agent SMTP server

… … …

HTTP to SMTP Gateway SMTP to HTTP Gateway

slide-17
SLIDE 17

17 LaBRI

Open issue

Protocol specification & translation semantics

Code

slide-18
SLIDE 18

18 LaBRI

Our approach

Code generation Verification

High level specifications

  • Consistency checks
  • Dataflow analyses

Runtime system Translation engine

slide-19
SLIDE 19

19 LaBRI

z2z : an umbrella of DSLs

 Protocol specification language (PSL)

 How to interact with the network to send or receive messages

 Message specification language (MSL)

 Defines a view from an incoming message  Defines templates to forge new messages

 Message translation language (MTL)

 Defines a set of handlers

(one for each relevant request in the source protocol)

 C-like notation augmented with domain-specific

  • perators
slide-20
SLIDE 20

20 LaBRI

Z2Z by example

slp.psl ssdp.psl http.psl slp.msl ssdp.msl http.msl slp2upnp.mtl

slide-21
SLIDE 21

21 LaBRI

Protocol Specification (SLP)

ssdp.psl http.psl slp.msl ssdp.msl http.msl slp2upnp.mtl slp.psl

slide-22
SLIDE 22

22 LaBRI

Protocol Specification (SLP)

protocol slp { attributes { transport = udp / 427; mode = async / multicast; group = 239.255 .255 .253; } request req { response SrvReq when req.function_id == 1; … } sending response resp (request req) {

// according to RFC 2608

resp.xid = req.xid; resp.url_len = strlen(resp.url); … } flow { xid } … } slp.psl

Information about interaction with the network Requests that should be handled by the gateway Protocol-specific information that all messages must contain How to identify a transaction: Response associated to a request

slide-23
SLIDE 23

23 LaBRI slp.msl slp.psl

Message Specification (SLP)

ssdp.psl http.psl ssdp.msl http.msl slp2upnp.mtl slp.psl slp.msl

slide-24
SLIDE 24

24 LaBRI

Message Specification (SLP)

message slp { read { mandatory private int function_id; mandatory private int xid;

  • ptional public int url_count;
  • ptional public fragment list urls;
  • ptional public fragment scope;
  • ptional public fragment service_type;
  • ptional public fragment predicate;

} }

slp.msl

Message View

Interface of ad-hoc message parser

Select information useful for the gateway

slide-25
SLIDE 25

25 LaBRI slp.psl

Message Specification (SLP)

ssdp.psl http.psl ssdp.msl http.msl slp2upnp.mtl slp.msl

slide-26
SLIDE 26

26 LaBRI

Message Specification (SLP)

message slp { read { … } reponse binary template srvReply { magic =″foo″; private int16 total_len; private int16 url_len; private int16 xid private int16 lifetime; public fragment url; −−foo 02 02 00 <%total len%> 20 00 00 00 00 <%xid%> 00 02 65 6e 00 00 00 01 00 <%lifetime%> <%url len%> <%url%> 00 00 −−foo } }

slp.msl

Response Template

Similar to a message view

All field are mandatory

Private fields are filled in sending block (psl)

Public fields must be filled in MTL

Binary Template

Expressed as a sequence of hexadecimal values

Holes fields with values fields

slide-27
SLIDE 27

27 LaBRI http.msl slp.msl slp.psl

Message Specification (SSDP)

ssdp.psl http.psl ssdp.msl slp2upnp.mtl ssdp.msl slp.msl

slide-28
SLIDE 28

28 LaBRI

Message Specification (SSDP)

message ssdp { read { … } request template response Search { magic = "foo"; newline = "\r\n"; public int mx; public fragment st; −−foo M-SEARCH * HTTP/1.1 ST: <%st%> MX: <%mx%> MAN: "ssdp:discover" HOST: 239.255.255.250:1900 −−foo } }

ssdp.msl

slide-29
SLIDE 29

29 LaBRI http.msl slp.msl slp.psl

Message Translation (SLP2UPnP)

ssdp.psl http.psl ssdp.msl slp2upnp.mtl ssdp.msl slp2upnp.mtl

slide-30
SLIDE 30

30 LaBRI

Message Translation

 Defines a set of handlers

 One for each relevant request in the source protocol

 Handlers written using a C-like notation augmented with

domain-specific operators for

 Manipulating messages  Forging messages  Sending requests (target protocol)  Returning responses (source protocol)  Session managment

slide-31
SLIDE 31

31 LaBRI

Message Translation

slp response SrvReq (slp request s) { }

Slp2upnp.mtl

SrvReq Handler

Parametrized by a view of the request

Information in the view extracted using structure field access notation

slide-32
SLIDE 32

32 LaBRI

Message Translation

slp response SrvReq (slp request s) { ssdp response res_ssdp; ssdp message search_ssdp; http response res_http; search_ssdp = Search(mx= 3, st="upnp:rootdevice")); }

Slp2upnp.mtl

New messages forged by invoking a template (Search)

Public fields must be initialized before sending the message

slide-33
SLIDE 33

33 LaBRI

Message Translation

slp response SrvReq (slp request s) { ssdp response res_ssdp; ssdp message search_ssdp; http response res_http; search_ssdp = Search(mx= 3, st="upnp:rootdevice")); res_ssdp = send(search_ssdp); }

Slp2upnp.mtl

Sending a request (multicast send)

Execution pauses until a response is received

Semantic preserved regardless of the sync/async properties

slide-34
SLIDE 34

34 LaBRI

Message Translation

slp response SrvReq (slp request s) { ssdp response res_ssdp; ssdp message search_ssdp; http response res_http; search_ssdp = Search(mx= 3, st="upnp:rootdevice")); res_ssdp = send(search_ssdp); }

Slp2upnp.mtl

Receiving a ssdp response (unicast response)

Execution resumed

slide-35
SLIDE 35

35 LaBRI

Message Translation

slp response SrvReq (slp request s) { ssdp response res_ssdp; ssdp message search_ssdp; http response res_http; search_ssdp = Search(mx= 3, st="upnp:rootdevice")); res_ssdp = send(search_ssdp); res_http = send(Get(path = res_ssdp.location_path, ip = res_ssdp.location_ip, port = res_ssdp.location_port)); }

Slp2upnp.mtl

Sending a request (unicast send)

HTTP Get message generated and sent

Response received synchronously (no continuation)

slide-36
SLIDE 36

36 LaBRI

Message Translation

slp response SrvReq (slp request s) { ssdp response res_ssdp; ssdp message search_ssdp; http response res_http; search_ssdp = Search(mx= 3, st="upnp:rootdevice")); res_ssdp = send(search_ssdp); res_http = send(Get(path =res_ssdp.location_path, ip = res_ssdp.location_ip, port = res_ssdp.location_port)); return srvReply(url=res_http.URLBase); }

Slp2upnp.mtl

Sending a reply (unicast send)

SrvReply message generated and sent

slide-37
SLIDE 37

37 LaBRI

Managment of asynchronous send

… resp1 = send(req1); … if (expr) { … resp2 = send(req2); … } else { … resp3 = send(req3); … } …

 Handler code

 sequential function with C-like syntax and semantics  Send operation treats as function call returning a value

 Asynchronous target protocol

Send does not return a value  Save the current state  Save information about the rest of the handler (continuation)  Handler restarted at the current point when a response become availables

 Handler split in many continuations

slide-38
SLIDE 38

38 LaBRI

Implementation (current status)

 z2z runtime system

7,500 lines of C code

 Domain-specific middleware for gateway construction

 Offers high-level operations

» Management of active connections (incoming/outgoing) » Dispatch of requests to appropriate handlers » Management of continuations for asynchronous communications » Message creation (efficient template management) » Management of sessions (save/restore of session states)

 Parameterized by the information of each protocol

» Communication scheme » Message information to identify transaction/session

slide-39
SLIDE 39

39 LaBRI

Implementation (current status)

 Z2z compiler

11,000 lines of OCaml code

 Verifications

 Consistency checks

» Inter-module dependencies

 Dataflow analyses

» Check that values are well-defined when they are used (MT)  Code generation

 Generates C code  Send operation as split point  Variables and asynchronous sends  Dynamic memory management (reference counts)

slide-40
SLIDE 40

40 LaBRI

Evaluation

 2 case studies

 SIP/RTSP gateway  SLP/UPnP gateway

 3 kinds of evaluation

 Size of specifications  Response time  Dynamic memory consumption at runtime

slide-41
SLIDE 41

41 LaBRI

SLP/UPnP SIP/RTSP

Evaluation SIP/RTSP, Size of Specifications

Memory consumption Response time Line of code

Input specification Parser z2z gateway (size in (KB) (lines of z2z code) (lines of C code) Generated modules Runtime systeme Total PS MS MT SIP/ RTSP SIP 24 118 102 168 72 80 1 5 2 RTSP 20 104 210 SDP 12 83

slide-42
SLIDE 42

42 LaBRI

Evaluation SIP/RTSP, Response Time

Line of code Memory consumption Response time

Native Service Access SIP < -> SIP RTSP < -> RTSP Time (ms) 351 701 Z2 Z SIP < -> RTSP 9 8 6

 No overhead

Z2Z response time less than the sum of the native response times

SLP/UPnP SIP/RTSP

slide-43
SLIDE 43

43 LaBRI

Evaluation SIP/RTSP, Memory Consumption

Line of code Response time Memory consumption

2 4 6 8 10 12 14

Memory consumption (KB) Time

SLP/UPnP SIP/RTSP

slide-44
SLIDE 44

44 LaBRI

Evaluation SIP/RTSP, Memory Consumption

Line of code Response time Memory consumption

2 4 6 8 10 12 14

Memory consumption (KB) Time Idle time

SLP/UPnP SIP/RTSP

slide-45
SLIDE 45

45 LaBRI

Evaluation SIP/RTSP, Memory Consumption

Line of code Response time Memory consumption

2 4 6 8 10 12 14

Memory consumption (KB) Time Peak time

SLP/UPnP SIP/RTSP

slide-46
SLIDE 46

46 LaBRI

Evaluation SLP/UPnP, Size of Specifications

SIP/RTSP SLP/UPnP Memory consumption Response time Line of code

I nput specification Parser z2 z gatew ay ( size in ( KB)

(lines of z2z code) (lines of C code) Generated modules Runtime systeme Total PS MS MT

SLP/ UPnP

SLP 12 21 5 166 44 80 124 SSDP 6 31 223 HTTP 9 43 178

slide-47
SLIDE 47

47 LaBRI

Evaluation SLP/UPnP, Size of Specifications

Memory consumption Response time Line of code

Complete z2z specification is around 100 lines of code

I nput specification Parser z2 z gatew ay ( size in ( KB)

(lines of z2z code) (lines of C code) Generated modules Runtime systeme Total PS MS MT

SLP/ UPnP

SLP 12 21 5 166 44 80 124 SSDP 6 31 223 HTTP 9 43 178

SIP/RTSP SLP/UPnP

slide-48
SLIDE 48

48 LaBRI

Evaluation SLP/UPnP, Size of Specifications

Memory consumption Response time Line of code

I nput specification Parser z2 z gatew ay ( size in ( KB)

(lines of z2z code) (lines of C code) Generated modules Runtime systeme Total PS MS MT

SLP/ UPnP

SLP 12 21 5 166 44 80 124 SSDP 6 31 223 HTTP 9 43 178

SIP/RTSP SLP/UPnP

slide-49
SLIDE 49

49 LaBRI

Evaluation SLP/UPnP, Size of Specifications

Memory consumption Response time Line of code

I nput specification Parser z2 z gatew ay ( size in ( KB)

(lines of z2z code) (lines of C code) Generated modules Runtime systeme Total PS MS MT

SLP/ UPnP

SLP 12 21 5 166 44 80 124 SSDP 6 31 223 HTTP 9 43 178

SIP/RTSP SLP/UPnP

slide-50
SLIDE 50

50 LaBRI

Evaluation SLP/UPnP, Response Time

Line of code Memory consumption Response time

Native Service Access SLP < -> SLP UPnP < -> UPnP Time 2 ms 58 ms Z2 Z SLP < -> UPnP 78 ms

SIP/RTSP SLP/UPnP

slide-51
SLIDE 51

51 LaBRI

Evaluation SLP/UPnP, Response Time

Line of code Memory consumption Response time

Native Service Access SLP < -> SLP UPnP < -> UPnP Time 2 ms 58 ms Z2 Z SLP < -> UPnP 78 ms

  • Z2Z response time little bit higher

Polling to check incomming asynchronous responses Not a one-to-one mapping SIP/RTSP SLP/UPnP

slide-52
SLIDE 52

53 LaBRI

Evaluation SLP/UPnP, Memory Consumption

Result 3

Line of code Response time Memory consumption

2 4 6 8 10 12

Memory consumption (KB)

Time

SIP/RTSP SLP/UPnP

slide-53
SLIDE 53

54 LaBRI

Evaluation SLP/UPnP, Memory Consumption

Result 3

Line of code Response time Memory consumption

2 4 6 8 10 12

Memory consumption (KB)

Time

Idle time

SIP/RTSP SLP/UPnP

slide-54
SLIDE 54

55 LaBRI

Evaluation SLP/UPnP, Memory Consumption

Result 3

Line of code Response time Memory consumption

2 4 6 8 10 12

Memory consumption (KB)

Time

Peak time

SIP/RTSP SLP/UPnP

slide-55
SLIDE 55

56 LaBRI

Conclusion / Perspectives

 A generative language-based approach

 Simplify gateway construction  Hide low-level networking code  Check correctness properties  Produce efficient code

 Extend z2z approach to take into account

 Error recovery

» Handle failures among the participants of the interaction

 Timeout  Try and catch semantic