SlideShare a Scribd company logo
TCP Performance
For Mobile Applications
     Vladimir Kirillov
        @darkproger
Networking Stack
Application


 Session


Transport



 Network

Data Link
Application     HTTP


 Session        TLS


Transport       TCP



 Network         IP

              WiFi Edge
Data Link
               3G LTE
Application     HTTP        NSURLConnection


 Session        TLS             OpenSSL


Transport       TCP           SOCK_STREAM



 Network         IP             kernel

              WiFi Edge
Data Link                      hardware
               3G LTE

   Level      Protocol    API / Implementation
HTTP        NSURLConnection      ptrace


  TLS             OpenSSL          socket
                                            dtrace
                                    API

  TCP           SOCK_STREAM



   IP             kernel           bpf(4)

WiFi Edge
                 hardware
 3G LTE

Protocol    API / Implementation    Introspection
capturing iPhone traffic

    % udid=$(system_profiler               SPUSBDataType              
                | awk '/iPhone/{go=1} /Serial/ {if (go) print $3; go=0}')
276cb9530201bcehelloworldcd55560ed015d00

%   rvictl     -s $udid
Starting device 276cb9530201bcehelloworldcd55560ed015d00
[SUCCEEDED]
% ifconfig rvi0
rvi0: flags=3005<UP,DEBUG,LINK0,LINK1> mtu 0
tcpdump -i lo0 -w t.pcap -s0 &
nc -l 5000 &
echo hello | nc localhost 5000
kill %1
# tcpdump -r t.pcap -nnvv -tttt -K 'tcp port 5000'

2012-11-24 12:23:35.511134   IP6   (hlim 64, next-header TCP (6) payload length: 44) ::1.51734 > ::1.5000: Flags [  S ], seq 453038127, win
65535, options [mss 16324,nop,wscale 4,nop,nop,TS val 303407352 ecr 0,sackOK,eol], length 0

2012-11-24 12:23:35.511175   IP6    (hlim 64, next-header TCP (6) payload length: 20) ::1.5000 > ::1.51734: Flags [ R .], seq 0, ack 453038128,
win 0, length 0

2012-11-24 12:23:35.511226   IP   (tos 0x0, ttl 64, id 8400, offset 0, flags [DF], proto TCP (6), length 64)

                                              S
    127.0.0.1.51735 > 127.0.0.1.5000: Flags [ ], seq 2527137802, win 65535, options [mss 16344,nop,wscale 4,nop,nop,TS val 303407352 ecr
0,sackOK,eol], length 0
2012-11-24 12:23:35.511276 IP (tos 0x0, ttl 64, id 58311, offset 0, flags [DF], proto TCP (6), length 64)

    127.0.0.1.5000 > 127.0.0.1.51735: Flags   S
                                              [ .], seq 494520280, ack 2527137803, win 65535, options [mss 16344,nop,wscale 4,nop,nop,TS val
303407352 ecr 303407352,sackOK,eol], length   0
2012-11-24 12:23:35.511287 IP (tos 0x0, ttl   64, id 47796, offset 0, flags [DF], proto TCP (6), length 52)
    127.0.0.1.51735 > 127.0.0.1.5000: Flags   [.], seq 1, ack 1, win 9186, options [nop,nop,TS val 303407352 ecr 303407352], length 0
2012-11-24 12:23:35.511298 IP (tos 0x0, ttl   64, id 52186, offset 0, flags [DF], proto TCP (6), length 52)
    127.0.0.1.5000 > 127.0.0.1.51735: Flags   [.], seq 1, ack 1, win 9186, options [nop,nop,TS val 303407352 ecr 303407352], length 0
2012-11-24 12:23:35.511332 IP (tos 0x0, ttl   64, id 31417, offset 0, flags [DF], proto TCP (6), length 58)

 127.0.0.1.51735 > 127.0.0.1.5000: Flags [P   .], seq 1:7, ack 1, win 9186, options [nop,nop,TS val 303407352 ecr 303407352], length 6
2012-11-24 12:23:35.511351 IP (tos 0x0, ttl   64, id 29060, offset 0, flags [DF], proto TCP (6), length 52)
    127.0.0.1.51735 > 127.0.0.1.5000: Flags   [F.], seq 7, ack 1, win 9186, options [nop,nop,TS val 303407352 ecr 303407352], length 0
2012-11-24 12:23:35.511354 IP (tos 0x0, ttl   64, id 4019, offset 0, flags [DF], proto TCP (6), length 52)
    127.0.0.1.5000 > 127.0.0.1.51735: Flags   [.], seq 1, ack 7, win 9186, options [nop,nop,TS val 303407352 ecr 303407352], length 0
2012-11-24 12:23:35.511367 IP (tos 0x0, ttl   64, id 20879, offset 0, flags [DF], proto TCP (6), length 52)
    127.0.0.1.5000 > 127.0.0.1.51735: Flags   [.], seq 1, ack 8, win 9186, options [nop,nop,TS val 303407352 ecr 303407352], length 0

     17 packets captured
2012-11-24 12:23:35.511378 IP (tos 0x0, ttl   64, id 59633, offset 0, flags [DF], proto TCP (6), length 52)
    127.0.0.1.51735 > 127.0.0.1.5000: Flags   [F.], seq 7, ack 1, win 9186, options [nop,nop,TS val 303407352 ecr 303407352], length 0
2012-11-24 12:23:35.511388 IP (tos 0x0, ttl   64, id 56794, offset 0, flags [DF], proto TCP (6), length 52)
    127.0.0.1.5000 > 127.0.0.1.51735: Flags   [F.], seq 1, ack 8, win 9186, options [nop,nop,TS val 303407352 ecr 303407352], length 0
# tcpdump -r t.pcap -nnvv -tttt -K 'tcp port 5000'

2012-11-24 12:23:35.511134   IP6   (hlim 64, next-header TCP (6) payload length: 44) ::1.51734 > ::1.5000: Flags [  S ], seq 453038127, win
65535, options [mss 16324,nop,wscale 4,nop,nop,TS val 303407352 ecr 0,sackOK,eol], length 0

2012-11-24 12:23:35.511175   IP6    (hlim 64, next-header TCP (6) payload length: 20) ::1.5000 > ::1.51734: Flags [ R .], seq 0, ack 453038128,
win 0, length 0

2012-11-24 12:23:35.511226   IP   (tos 0x0, ttl 64, id 8400, offset 0, flags [DF], proto TCP (6), length 64)

                                              S
    127.0.0.1.51735 > 127.0.0.1.5000: Flags [ ], seq 2527137802, win 65535, options [mss 16344,nop,wscale 4,nop,nop,TS val 303407352 ecr
0,sackOK,eol], length 0
2012-11-24 12:23:35.511276 IP (tos 0x0, ttl 64, id 58311, offset 0, flags [DF], proto TCP (6), length 64)

    127.0.0.1.5000 > 127.0.0.1.51735: Flags   S
                                              [ .], seq 494520280, ack 2527137803, win 65535, options [mss 16344,nop,wscale 4,nop,nop,TS val
303407352 ecr 303407352,sackOK,eol], length   0
2012-11-24 12:23:35.511287 IP (tos 0x0, ttl   64, id 47796, offset 0, flags [DF], proto TCP (6), length 52)
    127.0.0.1.51735 > 127.0.0.1.5000: Flags   [.], seq 1, ack 1, win 9186, options [nop,nop,TS val 303407352 ecr 303407352], length 0
2012-11-24 12:23:35.511298 IP (tos 0x0, ttl   64, id 52186, offset 0, flags [DF], proto TCP (6), length 52)
    127.0.0.1.5000 > 127.0.0.1.51735: Flags   [.], seq 1, ack 1, win 9186, options [nop,nop,TS val 303407352 ecr 303407352], length 0
2012-11-24 12:23:35.511332 IP (tos 0x0, ttl   64, id 31417, offset 0, flags [DF], proto TCP (6), length 58)

 127.0.0.1.51735 > 127.0.0.1.5000: Flags [P                                                                 length 6
                                              .], seq 1:7, ack 1, win 9186, options [nop,nop,TS val 303407352 ecr 303407352],
2012-11-24 12:23:35.511351 IP (tos 0x0, ttl   64, id 29060, offset 0, flags [DF], proto TCP (6), length 52)
    127.0.0.1.51735 > 127.0.0.1.5000: Flags
2012-11-24 12:23:35.511354 IP (tos 0x0, ttl
    127.0.0.1.5000 > 127.0.0.1.51735: Flags
                                              64, id 4019, offset 0, flags [DF], proto TCP (6), length 52)       ^^
                                              [F.], seq 7, ack 1, win 9186, options [nop,nop,TS val 303407352 ecr 303407352], length 0

                                              [.], seq 1, ack 7, win 9186, options [nop,nop,TS val 303407352 ecr 303407352], length 0
2012-11-24 12:23:35.511367 IP (tos 0x0, ttl
    127.0.0.1.5000 > 127.0.0.1.51735: Flags                                                      % stat -f %z t.pcap
                                              64, id 20879, offset 0, flags [DF], proto TCP (6), length 52)
                                              [.], seq 1, ack 8, win 9186, options [nop,nop,TS val 303407352 ecr 303407352], length 0

     17 packets captured                                                                         1306
2012-11-24 12:23:35.511378 IP (tos 0x0, ttl   64, id 59633, offset 0, flags [DF], proto TCP (6), length 52)
    127.0.0.1.51735 > 127.0.0.1.5000: Flags   [F.], seq 7, ack 1, win 9186, options [nop,nop,TS val 303407352 ecr 303407352], length 0
2012-11-24 12:23:35.511388 IP (tos 0x0, ttl   64, id 56794, offset 0, flags [DF], proto TCP (6), length 52)
    127.0.0.1.5000 > 127.0.0.1.51735: Flags   [F.], seq 1, ack 8, win 9186, options [nop,nop,TS val 303407352 ecr 303407352], length 0
% tcptrace t.pcap
17 packets seen, 17 TCP packets traced
elapsed wallclock time: 0:00:00.001344, 12648 pkts/sec analyzed
trace file elapsed time: 0:00:00.000305
TCP connection info:

1: localhost:52132 - localhost:5000 (a2b)   1> 1<   (reset)
2: localhost:52133 - localhost:5000 (c2d)   8> 7<   (complete)   (reset)
% tcptrace -o2 -l t.pcap
...

      adv wind scale:          4            adv wind scale:          4
      req sack:                Y            req sack:                Y

      sacks sent:              0            sacks sent:              0
      urgent data pkts:        0 pkts       urgent data pkts:        0 pkts
      urgent data bytes:       0 bytes      urgent data bytes:       0 bytes

      mss requested:          16344 bytes   mss   requested:     16344   bytes
      max segm size:           6 bytes      max   segm size:         0   bytes
      min segm size:           6 bytes      min   segm size:         0   bytes
      avg segm size:           5 bytes      avg   segm size:         0   bytes

      max win adv:146976 bytes              max win adv:         146976 bytes

      min win adv:146976 bytes              min win adv:         146976 bytes

      zero win adv: 0 times                 zero win adv:             0 times
      avg win adv:         146976 bytes     avg win adv:         122480 bytes

      initial window:6 bytes                initial window:          0 bytes
      initial window:          1 pkts       initial window:          0 pkts
      ttl stream length:       6 bytes      ttl stream length:       1 bytes

      missed data:             0   bytes    missed data:             1   bytes
      truncated data:          0   bytes    truncated data:          0   bytes
      truncated packets:       0   pkts     truncated packets:       0   pkts
      data xmit time:      0.000   secs     data xmit time:      0.000   secs
      idletime max:          0.1   ms       idletime max:          0.0   ms
      throughput:          27027   Bps      throughput:              0   Bps
endpoint       endpoint
  SO_RCVBUF   SO_SNDBUF


  SO_SNDBUF   SO_RCVBUF
endpoint                   endpoint
  SO_RCVBUF   SEG         SO_SNDBUF


  SO_SNDBUF         SEG   SO_RCVBUF
2 * LATENCY = RTT


endpoint        LATENCY                 endpoint
  SO_RCVBUF   SEG                   SO_SNDBUF

                       BANDWIDTH
  SO_SNDBUF               SEG       SO_RCVBUF
• Time from one endpoint to another
          • Each connection spans multiple links
           • edge
           • ethernet
Latency    • fiber
           • wifi
          • latency = sum (lat foreach link)
          • RTT = 2 * latency
• Number of bytes a link can handle
Bandwidth   • bw = min (bw foreach link)
Bandwidth
    Delay   BDP = RTT * BANDWIDTH

  Product
client                           server
 SO_RCVBUF   receiver window   SO_SNDBUF


 SO_SNDBUF   sender window     SO_RCVBUF
client                                       server
 SO_RCVBUF   SEG   receiver window   SEG   SO_SNDBUF


 SO_SNDBUF         sender window
                     SEG     SEG           SO_RCVBUF
client                                          server
 SO_RCVBUF   SEG   receiver window
                   SEG  SEG  SEG SEG    SEG   SO_SNDBUF


 SO_SNDBUF   SEG   receiver windowSEG
                     sender window
                   SEG SEG
                         SEG SEG SEG    SEG   SO_RCVBUF
TCP    • stateful
          • ordered
   byte   • reliable
stream    • managed
HTTP
 paired

has state
            TLS
no state
            TCP

            IP
% openssl s_client -
      showcerts -connect
      google.com:443
      CONNECTED(00000003)
      depth=1 /C=US/O=Google Inc/CN=Google Internet Authority
      verify error:num=20:unable to get local issuer certificate


TLS
      verify return:0
      ---
      Certificate chain
       0 s:/C=US/ST=California/L=Mountain View/O=Google Inc/
      CN=*.google.com
          i:/C=US/O=Google Inc/CN=Google Internet Authority
      ...
       1 s:/C=US/O=Google Inc/CN=Google Internet Authority
          i:/C=US/O=Equifax/OU=Equifax Secure Certificate Authority
      ...
      SSL handshake has read 2388 bytes and written 316 bytes
% openssl s_client -showcerts -
      connect ciklum.com:443
      CONNECTED(00000003)

                                                    ciklum.net
      depth=0 /C=UA/OU=Domain Control Validated/CN=*.
      verify error:num=20:unable to get local issuer certificate
      verify return:1                                              lol :)
      depth=0 /C=UA/OU=Domain Control Validated/CN=*.ciklum.net
      verify error:num=27:certificate not trusted
      verify return:1


TLS   depth=0 /C=UA/OU=Domain Control Validated/CN=*.ciklum.net
      verify error:num=21:unable to verify the first certificate
      verify return:1
      ---
      Certificate chain
       0 s:/C=UA/OU=Domain Control Validated/CN=*.ciklum.net
            i:/O=AlphaSSL/CN=AlphaSSL CA - G2
      ...
      Server certificate
      subject=/C=UA/OU=Domain Control Validated/CN=*.ciklum.net
      issuer=/O=AlphaSSL/CN=AlphaSSL CA - G2


      SSL handshake has read 1854 bytes and written 328 bytes
HTTP       1 RTT
      TLS       3 RTTs
      TCP       1 RTT
       IP

It takes 4 RTTs to serve a HTTPS request
HTTP       1 RTT
 TLS      3 RTTs
 TCP      1 RTT
 IP

It takes 4 RTTs to serve a HTTPS request
TCP Reliability
client                                             server
 SO_RCVBUF   SEG       receiver window
                       SEG  SEG  SEG SEG   SEG   SO_SNDBUF

                   A     A         A         A
 SO_SNDBUF         C   receiver window
                        sender window
                         C SEG     SEG
                                   C         C SO_RCVBUF
                   K     K         K         K
AirPort        router        router
client       Express                                  server
 SO_RCVBUF    SEG       receiver window
                        SEG  SEG  SEG SEG     SEG   SO_SNDBUF

                    A     A         A           A
 SO_SNDBUF          C   receiver window
                         sender window
                          C SEG     SEG
                                    C           C SO_RCVBUF
                    K     K         K           K
                                 router
AirPort          router         router
client       Express                                     server
 SO_RCVBUF    SEG        receiver window
                         SEG  SEG  SEG SEG       SEG   SO_SNDBUF

                    A      A         A             A
 SO_SNDBUF          C    receiver window
                          sender window
                           C SEG     SEG
                                     C             C SO_RCVBUF
                    K      K         K             K
                                    router



                        retransmit on timeout
TCP Congestion Control
client                                        server
    SEG     SEG    SEG receiver
      SEG
SO_RCVBUF
 SEG SEG SEG SEG
                           SEG    windowSEG
                                  SEG         SO_SNDBUF

SO_SNDBUF             sender window           SO_RCVBUF
AirPort        router        router
client       Express                                  server
 SO_RCVBUF    SEG       receiver window
                        SEG  SEG  SEG SEG     SEG   SO_SNDBUF

                    A     A                     A
 SO_SNDBUF          C   receiver window
                         sender window
                          C                     C SO_RCVBUF
                    K     K                     K

                               overloaded
                                 router

         ^^^ What congestion control is actually designed for
AirPort    router        router
client                       Express                              server
             S   S   S   S
 SO_RCVBUF   E   E   E   E    SEG   receiver window
                                    SEG  SEG  SEG SEG     SEG   SO_SNDBUF
             G   G   G   G
                                A    A         A            A
 SO_SNDBUF                      C   sender window
                              receiverSEG
                                     C  window C
                                               SEG          C SO_RCVBUF
                                K    K         K            K
                                             router



   ^^^ What actually happens on mobile devices
• Nagle algorithm
              while (1)
                 write(fd, “5”, 1);
    TCP       (telnet syndrom)
Artifacts
            Delayed ACK
            http://www.stuartcheshire.org/
            papers/NagleDelayedAck/
TCP     •SO_OOBINLINE
Artifacts   •TCP URG
API Issues
Async NSURLConnection
API Issues   UIScrollView
             CFRunLoopAddCommonMode
client                               server
             SEG     SEG
      SEG
       SEG     SEG
         SO_RCVBUF
SO_RCVBUF SEG SEG SEG SEG
        SEG                 receiver window   SO_SNDBUF

        SO_SNDBUF           sender window     SO_RCVBUF
More • Additive Increase
Congestion • Multiplicative Decrease
  Control • Slow Start
• setsockopt(2)
              • adjust window size
              • socket buffer sizes
              • TCP_NODELAY
iOS / Unix    • etc
             •getsockopt(2)
              • monitoring
             • low-latency responding to socket events
              • do not let the buffer stay full
• Responsive UI
          • Bad example: Instagram
Speedup   • Bad example:VK
           • best UI
           • worst reliability
• TCP Fast Open
           • Linux 3.6
           • HAProxy
          • TCP/NC
Speedup    • TCP and math (maths)
           • http://dspace.mit.edu/openaccess-
             disseminate/1721.1/58796
          • TCP Westwood+
• TLS False Start
          • TLS NPN
Speedup    • Next Protocol Negotiation
          • HTTP Pipelining
          • SPDY
kthxbai
    @darkproger
http://kirillov.im

More Related Content

What's hot

Debugging Ruby
Debugging RubyDebugging Ruby
Debugging Ruby
Aman Gupta
 
The Art of JVM Profiling
The Art of JVM ProfilingThe Art of JVM Profiling
The Art of JVM Profiling
Andrei Pangin
 
Java и Linux — особенности эксплуатации / Алексей Рагозин (Дойче Банк)
Java и Linux — особенности эксплуатации / Алексей Рагозин (Дойче Банк)Java и Linux — особенности эксплуатации / Алексей Рагозин (Дойче Банк)
Java и Linux — особенности эксплуатации / Алексей Рагозин (Дойче Банк)
Ontico
 
Ceph Day SF 2015 - Big Data Applications and Tuning in Ceph
Ceph Day SF 2015 - Big Data Applications and Tuning in Ceph Ceph Day SF 2015 - Big Data Applications and Tuning in Ceph
Ceph Day SF 2015 - Big Data Applications and Tuning in Ceph
Ceph Community
 
Geth important commands
Geth important commandsGeth important commands
Geth important commands
NexThoughts Technologies
 
Down to Stack Traces, up from Heap Dumps
Down to Stack Traces, up from Heap DumpsDown to Stack Traces, up from Heap Dumps
Down to Stack Traces, up from Heap Dumps
Andrei Pangin
 
Data Wars: The Bloody Enterprise strikes back
Data Wars: The Bloody Enterprise strikes backData Wars: The Bloody Enterprise strikes back
Data Wars: The Bloody Enterprise strikes back
Victor_Cr
 
Sourcefire Vulnerability Research Team Labs
Sourcefire Vulnerability Research Team LabsSourcefire Vulnerability Research Team Labs
Sourcefire Vulnerability Research Team Labs
losalamos
 
Distributed systems at ok.ru #rigadevday
Distributed systems at ok.ru #rigadevdayDistributed systems at ok.ru #rigadevday
Distributed systems at ok.ru #rigadevday
odnoklassniki.ru
 
ikh331-06-distributed-programming
ikh331-06-distributed-programmingikh331-06-distributed-programming
ikh331-06-distributed-programmingAnung Ariwibowo
 
A New Framework for Detection
A New Framework for DetectionA New Framework for Detection
A New Framework for Detection
Sourcefire VRT
 
How to Avoid Common Mistakes When Using Reactor Netty
How to Avoid Common Mistakes When Using Reactor NettyHow to Avoid Common Mistakes When Using Reactor Netty
How to Avoid Common Mistakes When Using Reactor Netty
VMware Tanzu
 
STANDARD CELL LIBRARY DESIGN
STANDARD CELL LIBRARY DESIGNSTANDARD CELL LIBRARY DESIGN
STANDARD CELL LIBRARY DESIGN
Ilango Jeyasubramanian
 
The Ring programming language version 1.10 book - Part 81 of 212
The Ring programming language version 1.10 book - Part 81 of 212The Ring programming language version 1.10 book - Part 81 of 212
The Ring programming language version 1.10 book - Part 81 of 212
Mahmoud Samir Fayed
 
Cs423 raw sockets_bw
Cs423 raw sockets_bwCs423 raw sockets_bw
Cs423 raw sockets_bw
jktjpc
 
Scale17x buffer overflows
Scale17x buffer overflowsScale17x buffer overflows
Scale17x buffer overflows
johseg
 
Socket Programming
Socket ProgrammingSocket Programming
Socket Programming
Sivadon Chaisiri
 
Efficient Programs
Efficient ProgramsEfficient Programs
Efficient Programs
Gabriel Grill
 
Blockchain Cryptography for Developers (Nakov @ BlockWorld 2018, San Jose)
Blockchain Cryptography for Developers (Nakov @ BlockWorld 2018, San Jose)Blockchain Cryptography for Developers (Nakov @ BlockWorld 2018, San Jose)
Blockchain Cryptography for Developers (Nakov @ BlockWorld 2018, San Jose)
Svetlin Nakov
 

What's hot (20)

Debugging Ruby
Debugging RubyDebugging Ruby
Debugging Ruby
 
The Art of JVM Profiling
The Art of JVM ProfilingThe Art of JVM Profiling
The Art of JVM Profiling
 
Java и Linux — особенности эксплуатации / Алексей Рагозин (Дойче Банк)
Java и Linux — особенности эксплуатации / Алексей Рагозин (Дойче Банк)Java и Linux — особенности эксплуатации / Алексей Рагозин (Дойче Банк)
Java и Linux — особенности эксплуатации / Алексей Рагозин (Дойче Банк)
 
Ceph Day SF 2015 - Big Data Applications and Tuning in Ceph
Ceph Day SF 2015 - Big Data Applications and Tuning in Ceph Ceph Day SF 2015 - Big Data Applications and Tuning in Ceph
Ceph Day SF 2015 - Big Data Applications and Tuning in Ceph
 
Geth important commands
Geth important commandsGeth important commands
Geth important commands
 
Down to Stack Traces, up from Heap Dumps
Down to Stack Traces, up from Heap DumpsDown to Stack Traces, up from Heap Dumps
Down to Stack Traces, up from Heap Dumps
 
Data Wars: The Bloody Enterprise strikes back
Data Wars: The Bloody Enterprise strikes backData Wars: The Bloody Enterprise strikes back
Data Wars: The Bloody Enterprise strikes back
 
Sourcefire Vulnerability Research Team Labs
Sourcefire Vulnerability Research Team LabsSourcefire Vulnerability Research Team Labs
Sourcefire Vulnerability Research Team Labs
 
Distributed systems at ok.ru #rigadevday
Distributed systems at ok.ru #rigadevdayDistributed systems at ok.ru #rigadevday
Distributed systems at ok.ru #rigadevday
 
20141105 asfws-norx-slides
20141105 asfws-norx-slides20141105 asfws-norx-slides
20141105 asfws-norx-slides
 
ikh331-06-distributed-programming
ikh331-06-distributed-programmingikh331-06-distributed-programming
ikh331-06-distributed-programming
 
A New Framework for Detection
A New Framework for DetectionA New Framework for Detection
A New Framework for Detection
 
How to Avoid Common Mistakes When Using Reactor Netty
How to Avoid Common Mistakes When Using Reactor NettyHow to Avoid Common Mistakes When Using Reactor Netty
How to Avoid Common Mistakes When Using Reactor Netty
 
STANDARD CELL LIBRARY DESIGN
STANDARD CELL LIBRARY DESIGNSTANDARD CELL LIBRARY DESIGN
STANDARD CELL LIBRARY DESIGN
 
The Ring programming language version 1.10 book - Part 81 of 212
The Ring programming language version 1.10 book - Part 81 of 212The Ring programming language version 1.10 book - Part 81 of 212
The Ring programming language version 1.10 book - Part 81 of 212
 
Cs423 raw sockets_bw
Cs423 raw sockets_bwCs423 raw sockets_bw
Cs423 raw sockets_bw
 
Scale17x buffer overflows
Scale17x buffer overflowsScale17x buffer overflows
Scale17x buffer overflows
 
Socket Programming
Socket ProgrammingSocket Programming
Socket Programming
 
Efficient Programs
Efficient ProgramsEfficient Programs
Efficient Programs
 
Blockchain Cryptography for Developers (Nakov @ BlockWorld 2018, San Jose)
Blockchain Cryptography for Developers (Nakov @ BlockWorld 2018, San Jose)Blockchain Cryptography for Developers (Nakov @ BlockWorld 2018, San Jose)
Blockchain Cryptography for Developers (Nakov @ BlockWorld 2018, San Jose)
 

Viewers also liked

C10 transport protocols
C10 transport protocolsC10 transport protocols
C10 transport protocolsRio Nguyen
 
Mobile transport layer - traditional TCP
Mobile transport layer - traditional TCPMobile transport layer - traditional TCP
Mobile transport layer - traditional TCP
Vishal Tandel
 
Mobile transport layer
 Mobile transport layer Mobile transport layer
Mobile transport layer
SonaliAjankar
 
Mobile computing : Indirect TCP
Mobile computing : Indirect TCPMobile computing : Indirect TCP
Mobile computing : Indirect TCP
Sushant Kushwaha
 
Mobile Database
Mobile DatabaseMobile Database
Mobile Database
Thanh Le
 
Mobile database security threats
Mobile database security threatsMobile database security threats
Mobile database security threatsAkhil Kumar
 
Mobile computing-tcp data flow control
Mobile computing-tcp data flow controlMobile computing-tcp data flow control
Mobile computing-tcp data flow control
Sushant Kushwaha
 
Mobile Database ,alrazgi
Mobile Database ,alrazgiMobile Database ,alrazgi
Mobile Database ,alrazgi
alrazgi
 
Mobile dbms
Mobile dbmsMobile dbms
Mobile dbmsTech_MX
 

Viewers also liked (9)

C10 transport protocols
C10 transport protocolsC10 transport protocols
C10 transport protocols
 
Mobile transport layer - traditional TCP
Mobile transport layer - traditional TCPMobile transport layer - traditional TCP
Mobile transport layer - traditional TCP
 
Mobile transport layer
 Mobile transport layer Mobile transport layer
Mobile transport layer
 
Mobile computing : Indirect TCP
Mobile computing : Indirect TCPMobile computing : Indirect TCP
Mobile computing : Indirect TCP
 
Mobile Database
Mobile DatabaseMobile Database
Mobile Database
 
Mobile database security threats
Mobile database security threatsMobile database security threats
Mobile database security threats
 
Mobile computing-tcp data flow control
Mobile computing-tcp data flow controlMobile computing-tcp data flow control
Mobile computing-tcp data flow control
 
Mobile Database ,alrazgi
Mobile Database ,alrazgiMobile Database ,alrazgi
Mobile Database ,alrazgi
 
Mobile dbms
Mobile dbmsMobile dbms
Mobile dbms
 

Similar to Владимир Кириллов-TCP-Performance for-Mobile-Applications

Intro to Packet Analysis - pfSense Hangout May 2014
Intro to Packet Analysis - pfSense Hangout May 2014Intro to Packet Analysis - pfSense Hangout May 2014
Intro to Packet Analysis - pfSense Hangout May 2014
Netgate
 
Пример отчета по анализу вредоносного кода TeslaCrypt, подготовленного Cisco ...
Пример отчета по анализу вредоносного кода TeslaCrypt, подготовленного Cisco ...Пример отчета по анализу вредоносного кода TeslaCrypt, подготовленного Cisco ...
Пример отчета по анализу вредоносного кода TeslaCrypt, подготовленного Cisco ...
Cisco Russia
 
Csw2016 wheeler barksdale-gruskovnjak-execute_mypacket
Csw2016 wheeler barksdale-gruskovnjak-execute_mypacketCsw2016 wheeler barksdale-gruskovnjak-execute_mypacket
Csw2016 wheeler barksdale-gruskovnjak-execute_mypacket
CanSecWest
 
How deep is your buffer – Demystifying buffers and application performance
How deep is your buffer – Demystifying buffers and application performanceHow deep is your buffer – Demystifying buffers and application performance
How deep is your buffer – Demystifying buffers and application performance
Cumulus Networks
 
I understand
I understandI understand
I understandsamaria1
 
Performance tweaks and tools for Linux (Joe Damato)
Performance tweaks and tools for Linux (Joe Damato)Performance tweaks and tools for Linux (Joe Damato)
Performance tweaks and tools for Linux (Joe Damato)Ontico
 
How to Speak Intel DPDK KNI for Web Services.
How to Speak Intel DPDK KNI for Web Services.How to Speak Intel DPDK KNI for Web Services.
How to Speak Intel DPDK KNI for Web Services.
Naoto MATSUMOTO
 
Cram
CramCram
Nodejs性能分析优化和分布式设计探讨
Nodejs性能分析优化和分布式设计探讨Nodejs性能分析优化和分布式设计探讨
Nodejs性能分析优化和分布式设计探讨
flyinweb
 
Day2
Day2Day2
Day2
Jai4uk
 
Quic illustrated
Quic illustratedQuic illustrated
Quic illustrated
Alexander Krizhanovsky
 
Analysis of Compromised Linux Server
Analysis of Compromised Linux ServerAnalysis of Compromised Linux Server
Analysis of Compromised Linux Server
anandvaidya
 
Disruptive IP Networking with Intel DPDK on Linux
Disruptive IP Networking with Intel DPDK on LinuxDisruptive IP Networking with Intel DPDK on Linux
Disruptive IP Networking with Intel DPDK on Linux
Naoto MATSUMOTO
 
Technical Overview of QUIC
Technical  Overview of QUICTechnical  Overview of QUIC
Technical Overview of QUIC
shigeki_ohtsu
 
A Brief Introduction of TiDB (Percona Live)
A Brief Introduction of TiDB (Percona Live)A Brief Introduction of TiDB (Percona Live)
A Brief Introduction of TiDB (Percona Live)
PingCAP
 
Troubleshooting tips and tricks for Oracle Database Oct 2020
Troubleshooting tips and tricks for Oracle Database Oct 2020Troubleshooting tips and tricks for Oracle Database Oct 2020
Troubleshooting tips and tricks for Oracle Database Oct 2020
Sandesh Rao
 
Analyse OpenLDAP logs with ELK
Analyse OpenLDAP logs with ELKAnalyse OpenLDAP logs with ELK
Analyse OpenLDAP logs with ELK
Clément OUDOT
 
Wireshark TCP Trace
Wireshark TCP Trace Wireshark TCP Trace
Wireshark TCP Trace
Paras
 
Maximizing SQL Reviews and Tuning with pt-query-digest
Maximizing SQL Reviews and Tuning with pt-query-digestMaximizing SQL Reviews and Tuning with pt-query-digest
Maximizing SQL Reviews and Tuning with pt-query-digest
Pythian
 

Similar to Владимир Кириллов-TCP-Performance for-Mobile-Applications (20)

Intro to Packet Analysis - pfSense Hangout May 2014
Intro to Packet Analysis - pfSense Hangout May 2014Intro to Packet Analysis - pfSense Hangout May 2014
Intro to Packet Analysis - pfSense Hangout May 2014
 
Пример отчета по анализу вредоносного кода TeslaCrypt, подготовленного Cisco ...
Пример отчета по анализу вредоносного кода TeslaCrypt, подготовленного Cisco ...Пример отчета по анализу вредоносного кода TeslaCrypt, подготовленного Cisco ...
Пример отчета по анализу вредоносного кода TeslaCrypt, подготовленного Cisco ...
 
04-TracerouteEmDetalhes_GTER36
04-TracerouteEmDetalhes_GTER3604-TracerouteEmDetalhes_GTER36
04-TracerouteEmDetalhes_GTER36
 
Csw2016 wheeler barksdale-gruskovnjak-execute_mypacket
Csw2016 wheeler barksdale-gruskovnjak-execute_mypacketCsw2016 wheeler barksdale-gruskovnjak-execute_mypacket
Csw2016 wheeler barksdale-gruskovnjak-execute_mypacket
 
How deep is your buffer – Demystifying buffers and application performance
How deep is your buffer – Demystifying buffers and application performanceHow deep is your buffer – Demystifying buffers and application performance
How deep is your buffer – Demystifying buffers and application performance
 
I understand
I understandI understand
I understand
 
Performance tweaks and tools for Linux (Joe Damato)
Performance tweaks and tools for Linux (Joe Damato)Performance tweaks and tools for Linux (Joe Damato)
Performance tweaks and tools for Linux (Joe Damato)
 
How to Speak Intel DPDK KNI for Web Services.
How to Speak Intel DPDK KNI for Web Services.How to Speak Intel DPDK KNI for Web Services.
How to Speak Intel DPDK KNI for Web Services.
 
Cram
CramCram
Cram
 
Nodejs性能分析优化和分布式设计探讨
Nodejs性能分析优化和分布式设计探讨Nodejs性能分析优化和分布式设计探讨
Nodejs性能分析优化和分布式设计探讨
 
Day2
Day2Day2
Day2
 
Quic illustrated
Quic illustratedQuic illustrated
Quic illustrated
 
Analysis of Compromised Linux Server
Analysis of Compromised Linux ServerAnalysis of Compromised Linux Server
Analysis of Compromised Linux Server
 
Disruptive IP Networking with Intel DPDK on Linux
Disruptive IP Networking with Intel DPDK on LinuxDisruptive IP Networking with Intel DPDK on Linux
Disruptive IP Networking with Intel DPDK on Linux
 
Technical Overview of QUIC
Technical  Overview of QUICTechnical  Overview of QUIC
Technical Overview of QUIC
 
A Brief Introduction of TiDB (Percona Live)
A Brief Introduction of TiDB (Percona Live)A Brief Introduction of TiDB (Percona Live)
A Brief Introduction of TiDB (Percona Live)
 
Troubleshooting tips and tricks for Oracle Database Oct 2020
Troubleshooting tips and tricks for Oracle Database Oct 2020Troubleshooting tips and tricks for Oracle Database Oct 2020
Troubleshooting tips and tricks for Oracle Database Oct 2020
 
Analyse OpenLDAP logs with ELK
Analyse OpenLDAP logs with ELKAnalyse OpenLDAP logs with ELK
Analyse OpenLDAP logs with ELK
 
Wireshark TCP Trace
Wireshark TCP Trace Wireshark TCP Trace
Wireshark TCP Trace
 
Maximizing SQL Reviews and Tuning with pt-query-digest
Maximizing SQL Reviews and Tuning with pt-query-digestMaximizing SQL Reviews and Tuning with pt-query-digest
Maximizing SQL Reviews and Tuning with pt-query-digest
 

More from UA Mobile

Денис Лебедев-Управление зависимостями с помощью CocoaPods
Денис Лебедев-Управление зависимостями с помощью CocoaPodsДенис Лебедев-Управление зависимостями с помощью CocoaPods
Денис Лебедев-Управление зависимостями с помощью CocoaPodsUA Mobile
 
Дмитрий Малеев-Мобильная Геймификация или как вырабатывать-привычки
Дмитрий Малеев-Мобильная Геймификация или как вырабатывать-привычкиДмитрий Малеев-Мобильная Геймификация или как вырабатывать-привычки
Дмитрий Малеев-Мобильная Геймификация или как вырабатывать-привычкиUA Mobile
 
Александр Терещук - Memory Analyzer Tool and memory optimization tips in Android
Александр Терещук - Memory Analyzer Tool and memory optimization tips in AndroidАлександр Терещук - Memory Analyzer Tool and memory optimization tips in Android
Александр Терещук - Memory Analyzer Tool and memory optimization tips in AndroidUA Mobile
 
Максим Щеглов - Google Cloud Messaging for Android
Максим Щеглов - Google Cloud Messaging for AndroidМаксим Щеглов - Google Cloud Messaging for Android
Максим Щеглов - Google Cloud Messaging for AndroidUA Mobile
 
Александр Додатко - Работа с датами в ObjectiveC и SQLite
Александр Додатко - Работа с датами в ObjectiveC и SQLiteАлександр Додатко - Работа с датами в ObjectiveC и SQLite
Александр Додатко - Работа с датами в ObjectiveC и SQLiteUA Mobile
 
Сергей Арнаут - Stream yourself with Android
Сергей Арнаут - Stream yourself with AndroidСергей Арнаут - Stream yourself with Android
Сергей Арнаут - Stream yourself with AndroidUA Mobile
 
Михаил Галушко - Разработка WinRT приложений для Windows 8: реальный опыт
Михаил Галушко -  Разработка WinRT приложений для Windows 8: реальный опытМихаил Галушко -  Разработка WinRT приложений для Windows 8: реальный опыт
Михаил Галушко - Разработка WinRT приложений для Windows 8: реальный опытUA Mobile
 
Дмитрий Вовк - Learn iOS Game Optimization. Ultimate Guide
Дмитрий Вовк - Learn iOS Game Optimization. Ultimate GuideДмитрий Вовк - Learn iOS Game Optimization. Ultimate Guide
Дмитрий Вовк - Learn iOS Game Optimization. Ultimate GuideUA Mobile
 
Павел Юрийчук - Разработка приложений под мобильные браузеры
Павел Юрийчук - Разработка приложений под мобильные браузерыПавел Юрийчук - Разработка приложений под мобильные браузеры
Павел Юрийчук - Разработка приложений под мобильные браузерыUA Mobile
 
Вадим Розов- Разработка под Blackberry. Подводные грабли
Вадим Розов- Разработка под Blackberry. Подводные граблиВадим Розов- Разработка под Blackberry. Подводные грабли
Вадим Розов- Разработка под Blackberry. Подводные граблиUA Mobile
 
Олег Апостол - Плюсы и минусы различных тач-платформ глазами веб-разработчика
Олег Апостол - Плюсы и минусы различных тач-платформ глазами веб-разработчикаОлег Апостол - Плюсы и минусы различных тач-платформ глазами веб-разработчика
Олег Апостол - Плюсы и минусы различных тач-платформ глазами веб-разработчикаUA Mobile
 
Евгений Галкин-Рекламные возможности Google для продвижения мобильных приложений
Евгений Галкин-Рекламные возможности Google для продвижения мобильных приложенийЕвгений Галкин-Рекламные возможности Google для продвижения мобильных приложений
Евгений Галкин-Рекламные возможности Google для продвижения мобильных приложенийUA Mobile
 
Алексей Лельчук - От аутсорсинга к продуктам: трансформация компании и ментал...
Алексей Лельчук - От аутсорсинга к продуктам: трансформация компании и ментал...Алексей Лельчук - От аутсорсинга к продуктам: трансформация компании и ментал...
Алексей Лельчук - От аутсорсинга к продуктам: трансформация компании и ментал...UA Mobile
 
Tdd objective c
Tdd objective cTdd objective c
Tdd objective cUA Mobile
 
Mobile automation uamobile
Mobile automation uamobileMobile automation uamobile
Mobile automation uamobileUA Mobile
 

More from UA Mobile (15)

Денис Лебедев-Управление зависимостями с помощью CocoaPods
Денис Лебедев-Управление зависимостями с помощью CocoaPodsДенис Лебедев-Управление зависимостями с помощью CocoaPods
Денис Лебедев-Управление зависимостями с помощью CocoaPods
 
Дмитрий Малеев-Мобильная Геймификация или как вырабатывать-привычки
Дмитрий Малеев-Мобильная Геймификация или как вырабатывать-привычкиДмитрий Малеев-Мобильная Геймификация или как вырабатывать-привычки
Дмитрий Малеев-Мобильная Геймификация или как вырабатывать-привычки
 
Александр Терещук - Memory Analyzer Tool and memory optimization tips in Android
Александр Терещук - Memory Analyzer Tool and memory optimization tips in AndroidАлександр Терещук - Memory Analyzer Tool and memory optimization tips in Android
Александр Терещук - Memory Analyzer Tool and memory optimization tips in Android
 
Максим Щеглов - Google Cloud Messaging for Android
Максим Щеглов - Google Cloud Messaging for AndroidМаксим Щеглов - Google Cloud Messaging for Android
Максим Щеглов - Google Cloud Messaging for Android
 
Александр Додатко - Работа с датами в ObjectiveC и SQLite
Александр Додатко - Работа с датами в ObjectiveC и SQLiteАлександр Додатко - Работа с датами в ObjectiveC и SQLite
Александр Додатко - Работа с датами в ObjectiveC и SQLite
 
Сергей Арнаут - Stream yourself with Android
Сергей Арнаут - Stream yourself with AndroidСергей Арнаут - Stream yourself with Android
Сергей Арнаут - Stream yourself with Android
 
Михаил Галушко - Разработка WinRT приложений для Windows 8: реальный опыт
Михаил Галушко -  Разработка WinRT приложений для Windows 8: реальный опытМихаил Галушко -  Разработка WinRT приложений для Windows 8: реальный опыт
Михаил Галушко - Разработка WinRT приложений для Windows 8: реальный опыт
 
Дмитрий Вовк - Learn iOS Game Optimization. Ultimate Guide
Дмитрий Вовк - Learn iOS Game Optimization. Ultimate GuideДмитрий Вовк - Learn iOS Game Optimization. Ultimate Guide
Дмитрий Вовк - Learn iOS Game Optimization. Ultimate Guide
 
Павел Юрийчук - Разработка приложений под мобильные браузеры
Павел Юрийчук - Разработка приложений под мобильные браузерыПавел Юрийчук - Разработка приложений под мобильные браузеры
Павел Юрийчук - Разработка приложений под мобильные браузеры
 
Вадим Розов- Разработка под Blackberry. Подводные грабли
Вадим Розов- Разработка под Blackberry. Подводные граблиВадим Розов- Разработка под Blackberry. Подводные грабли
Вадим Розов- Разработка под Blackberry. Подводные грабли
 
Олег Апостол - Плюсы и минусы различных тач-платформ глазами веб-разработчика
Олег Апостол - Плюсы и минусы различных тач-платформ глазами веб-разработчикаОлег Апостол - Плюсы и минусы различных тач-платформ глазами веб-разработчика
Олег Апостол - Плюсы и минусы различных тач-платформ глазами веб-разработчика
 
Евгений Галкин-Рекламные возможности Google для продвижения мобильных приложений
Евгений Галкин-Рекламные возможности Google для продвижения мобильных приложенийЕвгений Галкин-Рекламные возможности Google для продвижения мобильных приложений
Евгений Галкин-Рекламные возможности Google для продвижения мобильных приложений
 
Алексей Лельчук - От аутсорсинга к продуктам: трансформация компании и ментал...
Алексей Лельчук - От аутсорсинга к продуктам: трансформация компании и ментал...Алексей Лельчук - От аутсорсинга к продуктам: трансформация компании и ментал...
Алексей Лельчук - От аутсорсинга к продуктам: трансформация компании и ментал...
 
Tdd objective c
Tdd objective cTdd objective c
Tdd objective c
 
Mobile automation uamobile
Mobile automation uamobileMobile automation uamobile
Mobile automation uamobile
 

Владимир Кириллов-TCP-Performance for-Mobile-Applications

  • 1. TCP Performance For Mobile Applications Vladimir Kirillov @darkproger
  • 4. Application HTTP Session TLS Transport TCP Network IP WiFi Edge Data Link 3G LTE
  • 5. Application HTTP NSURLConnection Session TLS OpenSSL Transport TCP SOCK_STREAM Network IP kernel WiFi Edge Data Link hardware 3G LTE Level Protocol API / Implementation
  • 6. HTTP NSURLConnection ptrace TLS OpenSSL socket dtrace API TCP SOCK_STREAM IP kernel bpf(4) WiFi Edge hardware 3G LTE Protocol API / Implementation Introspection
  • 7. capturing iPhone traffic % udid=$(system_profiler SPUSBDataType | awk '/iPhone/{go=1} /Serial/ {if (go) print $3; go=0}') 276cb9530201bcehelloworldcd55560ed015d00 % rvictl -s $udid Starting device 276cb9530201bcehelloworldcd55560ed015d00 [SUCCEEDED] % ifconfig rvi0 rvi0: flags=3005<UP,DEBUG,LINK0,LINK1> mtu 0
  • 8. tcpdump -i lo0 -w t.pcap -s0 & nc -l 5000 & echo hello | nc localhost 5000 kill %1
  • 9. # tcpdump -r t.pcap -nnvv -tttt -K 'tcp port 5000' 2012-11-24 12:23:35.511134 IP6 (hlim 64, next-header TCP (6) payload length: 44) ::1.51734 > ::1.5000: Flags [ S ], seq 453038127, win 65535, options [mss 16324,nop,wscale 4,nop,nop,TS val 303407352 ecr 0,sackOK,eol], length 0 2012-11-24 12:23:35.511175 IP6 (hlim 64, next-header TCP (6) payload length: 20) ::1.5000 > ::1.51734: Flags [ R .], seq 0, ack 453038128, win 0, length 0 2012-11-24 12:23:35.511226 IP (tos 0x0, ttl 64, id 8400, offset 0, flags [DF], proto TCP (6), length 64) S 127.0.0.1.51735 > 127.0.0.1.5000: Flags [ ], seq 2527137802, win 65535, options [mss 16344,nop,wscale 4,nop,nop,TS val 303407352 ecr 0,sackOK,eol], length 0 2012-11-24 12:23:35.511276 IP (tos 0x0, ttl 64, id 58311, offset 0, flags [DF], proto TCP (6), length 64) 127.0.0.1.5000 > 127.0.0.1.51735: Flags S [ .], seq 494520280, ack 2527137803, win 65535, options [mss 16344,nop,wscale 4,nop,nop,TS val 303407352 ecr 303407352,sackOK,eol], length 0 2012-11-24 12:23:35.511287 IP (tos 0x0, ttl 64, id 47796, offset 0, flags [DF], proto TCP (6), length 52) 127.0.0.1.51735 > 127.0.0.1.5000: Flags [.], seq 1, ack 1, win 9186, options [nop,nop,TS val 303407352 ecr 303407352], length 0 2012-11-24 12:23:35.511298 IP (tos 0x0, ttl 64, id 52186, offset 0, flags [DF], proto TCP (6), length 52) 127.0.0.1.5000 > 127.0.0.1.51735: Flags [.], seq 1, ack 1, win 9186, options [nop,nop,TS val 303407352 ecr 303407352], length 0 2012-11-24 12:23:35.511332 IP (tos 0x0, ttl 64, id 31417, offset 0, flags [DF], proto TCP (6), length 58) 127.0.0.1.51735 > 127.0.0.1.5000: Flags [P .], seq 1:7, ack 1, win 9186, options [nop,nop,TS val 303407352 ecr 303407352], length 6 2012-11-24 12:23:35.511351 IP (tos 0x0, ttl 64, id 29060, offset 0, flags [DF], proto TCP (6), length 52) 127.0.0.1.51735 > 127.0.0.1.5000: Flags [F.], seq 7, ack 1, win 9186, options [nop,nop,TS val 303407352 ecr 303407352], length 0 2012-11-24 12:23:35.511354 IP (tos 0x0, ttl 64, id 4019, offset 0, flags [DF], proto TCP (6), length 52) 127.0.0.1.5000 > 127.0.0.1.51735: Flags [.], seq 1, ack 7, win 9186, options [nop,nop,TS val 303407352 ecr 303407352], length 0 2012-11-24 12:23:35.511367 IP (tos 0x0, ttl 64, id 20879, offset 0, flags [DF], proto TCP (6), length 52) 127.0.0.1.5000 > 127.0.0.1.51735: Flags [.], seq 1, ack 8, win 9186, options [nop,nop,TS val 303407352 ecr 303407352], length 0 17 packets captured 2012-11-24 12:23:35.511378 IP (tos 0x0, ttl 64, id 59633, offset 0, flags [DF], proto TCP (6), length 52) 127.0.0.1.51735 > 127.0.0.1.5000: Flags [F.], seq 7, ack 1, win 9186, options [nop,nop,TS val 303407352 ecr 303407352], length 0 2012-11-24 12:23:35.511388 IP (tos 0x0, ttl 64, id 56794, offset 0, flags [DF], proto TCP (6), length 52) 127.0.0.1.5000 > 127.0.0.1.51735: Flags [F.], seq 1, ack 8, win 9186, options [nop,nop,TS val 303407352 ecr 303407352], length 0
  • 10. # tcpdump -r t.pcap -nnvv -tttt -K 'tcp port 5000' 2012-11-24 12:23:35.511134 IP6 (hlim 64, next-header TCP (6) payload length: 44) ::1.51734 > ::1.5000: Flags [ S ], seq 453038127, win 65535, options [mss 16324,nop,wscale 4,nop,nop,TS val 303407352 ecr 0,sackOK,eol], length 0 2012-11-24 12:23:35.511175 IP6 (hlim 64, next-header TCP (6) payload length: 20) ::1.5000 > ::1.51734: Flags [ R .], seq 0, ack 453038128, win 0, length 0 2012-11-24 12:23:35.511226 IP (tos 0x0, ttl 64, id 8400, offset 0, flags [DF], proto TCP (6), length 64) S 127.0.0.1.51735 > 127.0.0.1.5000: Flags [ ], seq 2527137802, win 65535, options [mss 16344,nop,wscale 4,nop,nop,TS val 303407352 ecr 0,sackOK,eol], length 0 2012-11-24 12:23:35.511276 IP (tos 0x0, ttl 64, id 58311, offset 0, flags [DF], proto TCP (6), length 64) 127.0.0.1.5000 > 127.0.0.1.51735: Flags S [ .], seq 494520280, ack 2527137803, win 65535, options [mss 16344,nop,wscale 4,nop,nop,TS val 303407352 ecr 303407352,sackOK,eol], length 0 2012-11-24 12:23:35.511287 IP (tos 0x0, ttl 64, id 47796, offset 0, flags [DF], proto TCP (6), length 52) 127.0.0.1.51735 > 127.0.0.1.5000: Flags [.], seq 1, ack 1, win 9186, options [nop,nop,TS val 303407352 ecr 303407352], length 0 2012-11-24 12:23:35.511298 IP (tos 0x0, ttl 64, id 52186, offset 0, flags [DF], proto TCP (6), length 52) 127.0.0.1.5000 > 127.0.0.1.51735: Flags [.], seq 1, ack 1, win 9186, options [nop,nop,TS val 303407352 ecr 303407352], length 0 2012-11-24 12:23:35.511332 IP (tos 0x0, ttl 64, id 31417, offset 0, flags [DF], proto TCP (6), length 58) 127.0.0.1.51735 > 127.0.0.1.5000: Flags [P length 6 .], seq 1:7, ack 1, win 9186, options [nop,nop,TS val 303407352 ecr 303407352], 2012-11-24 12:23:35.511351 IP (tos 0x0, ttl 64, id 29060, offset 0, flags [DF], proto TCP (6), length 52) 127.0.0.1.51735 > 127.0.0.1.5000: Flags 2012-11-24 12:23:35.511354 IP (tos 0x0, ttl 127.0.0.1.5000 > 127.0.0.1.51735: Flags 64, id 4019, offset 0, flags [DF], proto TCP (6), length 52) ^^ [F.], seq 7, ack 1, win 9186, options [nop,nop,TS val 303407352 ecr 303407352], length 0 [.], seq 1, ack 7, win 9186, options [nop,nop,TS val 303407352 ecr 303407352], length 0 2012-11-24 12:23:35.511367 IP (tos 0x0, ttl 127.0.0.1.5000 > 127.0.0.1.51735: Flags % stat -f %z t.pcap 64, id 20879, offset 0, flags [DF], proto TCP (6), length 52) [.], seq 1, ack 8, win 9186, options [nop,nop,TS val 303407352 ecr 303407352], length 0 17 packets captured 1306 2012-11-24 12:23:35.511378 IP (tos 0x0, ttl 64, id 59633, offset 0, flags [DF], proto TCP (6), length 52) 127.0.0.1.51735 > 127.0.0.1.5000: Flags [F.], seq 7, ack 1, win 9186, options [nop,nop,TS val 303407352 ecr 303407352], length 0 2012-11-24 12:23:35.511388 IP (tos 0x0, ttl 64, id 56794, offset 0, flags [DF], proto TCP (6), length 52) 127.0.0.1.5000 > 127.0.0.1.51735: Flags [F.], seq 1, ack 8, win 9186, options [nop,nop,TS val 303407352 ecr 303407352], length 0
  • 11. % tcptrace t.pcap 17 packets seen, 17 TCP packets traced elapsed wallclock time: 0:00:00.001344, 12648 pkts/sec analyzed trace file elapsed time: 0:00:00.000305 TCP connection info: 1: localhost:52132 - localhost:5000 (a2b) 1> 1< (reset) 2: localhost:52133 - localhost:5000 (c2d) 8> 7< (complete) (reset)
  • 12. % tcptrace -o2 -l t.pcap ... adv wind scale: 4 adv wind scale: 4 req sack: Y req sack: Y sacks sent: 0 sacks sent: 0 urgent data pkts: 0 pkts urgent data pkts: 0 pkts urgent data bytes: 0 bytes urgent data bytes: 0 bytes mss requested: 16344 bytes mss requested: 16344 bytes max segm size: 6 bytes max segm size: 0 bytes min segm size: 6 bytes min segm size: 0 bytes avg segm size: 5 bytes avg segm size: 0 bytes max win adv:146976 bytes max win adv: 146976 bytes min win adv:146976 bytes min win adv: 146976 bytes zero win adv: 0 times zero win adv: 0 times avg win adv: 146976 bytes avg win adv: 122480 bytes initial window:6 bytes initial window: 0 bytes initial window: 1 pkts initial window: 0 pkts ttl stream length: 6 bytes ttl stream length: 1 bytes missed data: 0 bytes missed data: 1 bytes truncated data: 0 bytes truncated data: 0 bytes truncated packets: 0 pkts truncated packets: 0 pkts data xmit time: 0.000 secs data xmit time: 0.000 secs idletime max: 0.1 ms idletime max: 0.0 ms throughput: 27027 Bps throughput: 0 Bps
  • 13. endpoint endpoint SO_RCVBUF SO_SNDBUF SO_SNDBUF SO_RCVBUF
  • 14. endpoint endpoint SO_RCVBUF SEG SO_SNDBUF SO_SNDBUF SEG SO_RCVBUF
  • 15. 2 * LATENCY = RTT endpoint LATENCY endpoint SO_RCVBUF SEG SO_SNDBUF BANDWIDTH SO_SNDBUF SEG SO_RCVBUF
  • 16. • Time from one endpoint to another • Each connection spans multiple links • edge • ethernet Latency • fiber • wifi • latency = sum (lat foreach link) • RTT = 2 * latency
  • 17. • Number of bytes a link can handle Bandwidth • bw = min (bw foreach link)
  • 18. Bandwidth Delay BDP = RTT * BANDWIDTH Product
  • 19. client server SO_RCVBUF receiver window SO_SNDBUF SO_SNDBUF sender window SO_RCVBUF
  • 20. client server SO_RCVBUF SEG receiver window SEG SO_SNDBUF SO_SNDBUF sender window SEG SEG SO_RCVBUF
  • 21. client server SO_RCVBUF SEG receiver window SEG SEG SEG SEG SEG SO_SNDBUF SO_SNDBUF SEG receiver windowSEG sender window SEG SEG SEG SEG SEG SEG SO_RCVBUF
  • 22. TCP • stateful • ordered byte • reliable stream • managed
  • 23. HTTP paired has state TLS no state TCP IP
  • 24. % openssl s_client - showcerts -connect google.com:443 CONNECTED(00000003) depth=1 /C=US/O=Google Inc/CN=Google Internet Authority verify error:num=20:unable to get local issuer certificate TLS verify return:0 --- Certificate chain 0 s:/C=US/ST=California/L=Mountain View/O=Google Inc/ CN=*.google.com i:/C=US/O=Google Inc/CN=Google Internet Authority ... 1 s:/C=US/O=Google Inc/CN=Google Internet Authority i:/C=US/O=Equifax/OU=Equifax Secure Certificate Authority ... SSL handshake has read 2388 bytes and written 316 bytes
  • 25. % openssl s_client -showcerts - connect ciklum.com:443 CONNECTED(00000003) ciklum.net depth=0 /C=UA/OU=Domain Control Validated/CN=*. verify error:num=20:unable to get local issuer certificate verify return:1 lol :) depth=0 /C=UA/OU=Domain Control Validated/CN=*.ciklum.net verify error:num=27:certificate not trusted verify return:1 TLS depth=0 /C=UA/OU=Domain Control Validated/CN=*.ciklum.net verify error:num=21:unable to verify the first certificate verify return:1 --- Certificate chain 0 s:/C=UA/OU=Domain Control Validated/CN=*.ciklum.net i:/O=AlphaSSL/CN=AlphaSSL CA - G2 ... Server certificate subject=/C=UA/OU=Domain Control Validated/CN=*.ciklum.net issuer=/O=AlphaSSL/CN=AlphaSSL CA - G2 SSL handshake has read 1854 bytes and written 328 bytes
  • 26. HTTP 1 RTT TLS 3 RTTs TCP 1 RTT IP It takes 4 RTTs to serve a HTTPS request
  • 27. HTTP 1 RTT TLS 3 RTTs TCP 1 RTT IP It takes 4 RTTs to serve a HTTPS request
  • 29. client server SO_RCVBUF SEG receiver window SEG SEG SEG SEG SEG SO_SNDBUF A A A A SO_SNDBUF C receiver window sender window C SEG SEG C C SO_RCVBUF K K K K
  • 30. AirPort router router client Express server SO_RCVBUF SEG receiver window SEG SEG SEG SEG SEG SO_SNDBUF A A A A SO_SNDBUF C receiver window sender window C SEG SEG C C SO_RCVBUF K K K K router
  • 31. AirPort router router client Express server SO_RCVBUF SEG receiver window SEG SEG SEG SEG SEG SO_SNDBUF A A A A SO_SNDBUF C receiver window sender window C SEG SEG C C SO_RCVBUF K K K K router retransmit on timeout
  • 33. client server SEG SEG SEG receiver SEG SO_RCVBUF SEG SEG SEG SEG SEG windowSEG SEG SO_SNDBUF SO_SNDBUF sender window SO_RCVBUF
  • 34. AirPort router router client Express server SO_RCVBUF SEG receiver window SEG SEG SEG SEG SEG SO_SNDBUF A A A SO_SNDBUF C receiver window sender window C C SO_RCVBUF K K K overloaded router ^^^ What congestion control is actually designed for
  • 35. AirPort router router client Express server S S S S SO_RCVBUF E E E E SEG receiver window SEG SEG SEG SEG SEG SO_SNDBUF G G G G A A A A SO_SNDBUF C sender window receiverSEG C window C SEG C SO_RCVBUF K K K K router ^^^ What actually happens on mobile devices
  • 36. • Nagle algorithm while (1) write(fd, “5”, 1); TCP (telnet syndrom) Artifacts Delayed ACK http://www.stuartcheshire.org/ papers/NagleDelayedAck/
  • 37. TCP •SO_OOBINLINE Artifacts •TCP URG
  • 39. Async NSURLConnection API Issues UIScrollView CFRunLoopAddCommonMode
  • 40. client server SEG SEG SEG SEG SEG SO_RCVBUF SO_RCVBUF SEG SEG SEG SEG SEG receiver window SO_SNDBUF SO_SNDBUF sender window SO_RCVBUF
  • 41. More • Additive Increase Congestion • Multiplicative Decrease Control • Slow Start
  • 42.
  • 43. • setsockopt(2) • adjust window size • socket buffer sizes • TCP_NODELAY iOS / Unix • etc •getsockopt(2) • monitoring • low-latency responding to socket events • do not let the buffer stay full
  • 44. • Responsive UI • Bad example: Instagram Speedup • Bad example:VK • best UI • worst reliability
  • 45. • TCP Fast Open • Linux 3.6 • HAProxy • TCP/NC Speedup • TCP and math (maths) • http://dspace.mit.edu/openaccess- disseminate/1721.1/58796 • TCP Westwood+
  • 46. • TLS False Start • TLS NPN Speedup • Next Protocol Negotiation • HTTP Pipelining • SPDY
  • 47. kthxbai @darkproger http://kirillov.im