http2 & hpack #pyfes 2013-11-30

35
HTTP2.0 & HPACK based on draft-08 2013/11/30 #pyfes

Upload: jxck-

Post on 10-May-2015

1.271 views

Category:

Technology


3 download

DESCRIPTION

introduction to HTTP2 & HPACK based on http2 draft-08 hpack draft-04 at pyfes 2013.11 http://connpass.com/event/4273/

TRANSCRIPT

Page 1: HTTP2 & HPACK #pyfes 2013-11-30

HTTP2.0 & HPACKbased on draft-08

2013/11/30#pyfes

Page 2: HTTP2 & HPACK #pyfes 2013-11-30

Jack

● id: Jxck● github: Jxck● twitter: jxck_● about: http://jxck.io● blog: http://d.hatena.ne.jp/jxck● Love: music

Page 3: HTTP2 & HPACK #pyfes 2013-11-30
Page 4: HTTP2 & HPACK #pyfes 2013-11-30

spec and status

HTTP ?

Page 5: HTTP2 & HPACK #pyfes 2013-11-30

History of HTTP... HTTP/0.91996/ 5 HTTP/1.0 (RFC 1945)1997/ 1 HTTP/1.1 (RFC 2068)2009/11 SPDY/1...2011/ 9 WebSocket(RFC 6455)2012/ 8 HTTP/2.0 start2012/11 HTTP/2.0 (draft-00)...2013/ 7 HPACK (draft-00)...2013/10 HPACK (draft-04)2013/11 HTTP/2.0 (draft-08)

Page 6: HTTP2 & HPACK #pyfes 2013-11-30

motivation● Sharing Documents● Over TCP● Text Base Protocol● Stateless

version● HTTP/0.9

● HTTP/1.0

● HTTP/1.1○ Keep-Alive○ Pipelining

HTTP / 1.1

Page 7: HTTP2 & HPACK #pyfes 2013-11-30

CLIENT SERVER

Req / Res on HTTP/1.1

Text Base Protocol

GET /index.html HTTP/1.1Host: example.orgAccept: text/html

HTTP/1.1 200 OKContent-Type: text/htmlContent-Length: 35

<!DOCTYPE html><title>hello</title>

Page 8: HTTP2 & HPACK #pyfes 2013-11-30

HTTP ?● Simple

○ text base, easy scaling etc○ good for document sharing○ but Good for Now ?

● now “Web” is○ Plat Form (not only document sharing) ○ Ajax, WebSocket…○ tons of JS, CSS, Images...○ PC, Mobile, Tablet, TV, Game …

● needs○ more speed○ more efficiency○ more secure

Page 9: HTTP2 & HPACK #pyfes 2013-11-30

history and status

HTTP/2.0?

Page 10: HTTP2 & HPACK #pyfes 2013-11-30

about HTTP2

● httpbis wg at IETF from 2012● motivation

○ update HTTP/1.1● version

○ draft-00 (copy of spdy/3)○ ...○ draft-08 (2013/11/30 current)○ ...○ RFC XXXX (2014 spring? bit.ly/130oZrZ)

Page 11: HTTP2 & HPACK #pyfes 2013-11-30

SPDY or HTTP2.0 ?

SPDY/3

SPDY/4http2.0-00

http2.0-01

http2.0-08

http2.0SPDY/n ??

Page 12: HTTP2 & HPACK #pyfes 2013-11-30

specs

● working on github !○ https://github.com/http2/http2-spec

● draft○ http://tools.ietf.org/wg/httpbis/draft-ietf-httpbis-http2/

● current (2013/8/28)

○ http://tools.ietf.org/html/draft-ietf-httpbis-http2-08

● ML○ http://lists.w3.org/Archives/Public/ietf-http-wg/

○ https://www.ietf.org/mailman/listinfo/http-devops

Page 13: HTTP2 & HPACK #pyfes 2013-11-30

HTTP/2.0 draft-08

● Multiplexing (same as spdy)● Server Push (same idea as spdy)● ALPN / Upgrade● Binary Frames● HPACK

Page 14: HTTP2 & HPACK #pyfes 2013-11-30

Starting HTTP2.0 (1/2 step)

● “http://”○ Upgrade Header like websocket

● “https://”○ ALPN (application layer protocol negotiation)

○ not NPN like spdy● Known Supported

○ prior knowledge from DNS or so○ may immediately send http2.0 frame

Page 15: HTTP2 & HPACK #pyfes 2013-11-30

TLS-ALPN (Application Layer protocol negotiation)

Page 16: HTTP2 & HPACK #pyfes 2013-11-30

Starting HTTP2.0 (2/2 step)

● sending connection header○ make sure peer supports http2.0○ with Magic Octets

505249202a20485454502f322e300d0a0d0a534d0d0a0d0a

PRI * HTTP/2.0\r\n\r\nSM\r\n\r\n

invalid Method PRI

2 new linefor parser

Page 17: HTTP2 & HPACK #pyfes 2013-11-30

Frame Type

● DATA● HEADERS● PRIORITY● RST_STREAM● SETTINGS● PUSH_PROMISE● PING● GOAWAY● WINDOW_UPDATE● CONTINUATION

Page 18: HTTP2 & HPACK #pyfes 2013-11-30

HEADERS & DATA frame

CLIENT SERVER

HEADERS(stream_id=1) + END_STREAM + END_HEADERS :method = GET :scheme = https :authority = example.org :path = /index.html accept = text/html

HEADERS(stream_id=1) - END_STREAM + END_HEADERS :status = 200 content-type = text/html content-length = 35

DATA(stream_id=1) + END_STREAM

<!DOCTYPE html><title>hello</title>

Page 19: HTTP2 & HPACK #pyfes 2013-11-30

Server Push(1)

CLIENT SERVER

HTTP/1.1 200 OKContent-Type: text/htmlContent-Length: 123

{binary data}

PUSH_PROMISE (stream_id=1) + END_PUSH_PROMISE Promised-Stream-ID=2 :method = GET :scheme = https :authority = example.org :path = /a.png

HEADERS (stream_id=1) + END_STREAM + END_HEADERS :method = GET :scheme = https :authority = example.org :path = /index.html accept = text/html

PUSHRequest

Page 20: HTTP2 & HPACK #pyfes 2013-11-30

Server Push(2)

CLIENT SERVER

Browser Cache

DATA (stream_id=2) + END_STREAM {binary data}

HEADERS (stream_id=2) - END_STREAM + END_HEADERS :status = 200 :path = /a.png content-type = image/png content-length = 123

PUSHRespons

Page 21: HTTP2 & HPACK #pyfes 2013-11-30

Server Push(2)

CLIENT SERVER

HEADERS (stream_id=1) - END_STREAM + END_HEADERS :status = 200 content-type = text/html content-length = 33

DATA (stream_id=1) + END_STREAM <html> <img src=”a.png”></html>

cache hit !!

Response

Page 22: HTTP2 & HPACK #pyfes 2013-11-30

HPACK (header compression)

● HTTP Header○ Text Base○ Long Name○ Send multiple time

● SPDY compression○ CRIME

● HPACK○ send diff○ using binary

Page 23: HTTP2 & HPACK #pyfes 2013-11-30

Static Header Table

Index Header Name Header Value

1 :authority

2 :method GET

3 :method POST

4 :path /

5 :path /index.html

6 :scheme http

7 :scheme https

8 :status 200

9 :status 500

... ... ...

... ... ...

51 refresh

52 retry-after

53 server

54 set-cookie

55 strict-transport-security

56 transfer-encoding

57 user-agent

58 vary

59 via

60 www-authenticate

Page 24: HTTP2 & HPACK #pyfes 2013-11-30

Huffman Code (Request)sym MSB len hex LSB'a' ( 97) |01000 [5] 8 [5]'b' ( 98) |101111 [6] 2f [6]'c' ( 99) |01001 [5] 9 [5]'d' (100) |110000 [6] 30 [6]'e' (101) |0001 [4] 1 [4]'f' (102) |110001 [6] 31 [6]'g' (103) |110010 [6] 32 [6]'h' (104) |110011 [6] 33 [6]'i' (105) |01010 [5] a [5]'j' (106) |1110001 [7] 71 [7]'k' (107) |1110010 [7] 72 [7]'l' (108) |01011 [5] b [5]'m' (109) |110100 [6] 34 [6]'n' (110) |01100 [5] c [5]'o' (111) |01101 [5] d [5]

Page 25: HTTP2 & HPACK #pyfes 2013-11-30

Header Representation

● Indexed Header Representation● Literal Header Representation

○ Literal Header without Indexing○ Literal Header with Incremental Indexing

Page 26: HTTP2 & HPACK #pyfes 2013-11-30

HPACK example (1/2)63byte -> 16byte

1 :authority

2 :method GET

3 :method POST

4 :path /

5 :path /index.html

6 :scheme http

7 :scheme https

:method: GET:scheme: http:path: /:authority: www.example.com

Request Header

Static Table

82 ADD index 287 ADD index 786 ADD index 604 8b db6d 883e 68d1 cb12 25ba 7fADD key at index 4 value “www.example.com”

Decoded Data

Reference Set

1 :authority www.example.com

2 :path /

3 :scheme http

4 :method GET

Page 27: HTTP2 & HPACK #pyfes 2013-11-30

HPACK example (2/2)87byte -> 8byte

1 :authority

2 :method GET

3 :method POST

4 :path /

5 :path /index.html

6 :scheme http

7 :scheme https

1 cache-control no-cache

2 :authority www.example.com

3 :path /

4 :scheme http

5 :method GET

:method: GET:scheme: http:path: /:authority: www.example.comcache-control: no-cache

Request Header

Static Table

1b 86 63 65 4a 13 98 ffADD key at index 27 value “cache-control: no-cache”

Decoded Data

Reference Set

Page 28: HTTP2 & HPACK #pyfes 2013-11-30

implementations● nghttp2 C● http2-katanaC#● node-http2 node.js● Mozilla C++● http2-perl Perl● iij-http2 node.js● Akamai GhostC++● Chromium C++● Hasan's GFE C++● Twitter Java● Wireshark C● http2-go Go● http2 Haskell

see: https://github.com/http2/http2-spec/wiki/Implementations

Page 29: HTTP2 & HPACK #pyfes 2013-11-30

Tools for dev

Tools?

Page 30: HTTP2 & HPACK #pyfes 2013-11-30

Wireshark & TCP dump

Page 31: HTTP2 & HPACK #pyfes 2013-11-30

nghttp2

● C implementation library● nghttp

○ client cli tool

● nghttpd○ file server

● nghttpdx○ proxy

web frontend of nghttp2 => http2cat

Page 32: HTTP2 & HPACK #pyfes 2013-11-30

HTTP2Cat (https://jxck.io/labs/http2cat)

Page 33: HTTP2 & HPACK #pyfes 2013-11-30

books

● High Performance Browser Networking○ by Ilya Grigorik(Google)

● Translate to Japanese ?○ http://twitter.com/turky/status/406663190768914432

Page 34: HTTP2 & HPACK #pyfes 2013-11-30

anyone ?

Q & A

Page 35: HTTP2 & HPACK #pyfes 2013-11-30

thanks :)

END