lesson-05.html 18.5 KB
   1
   2
   3
   4
   5
   6
   7
   8
   9
  10
  11
  12
  13
  14
  15
  16
  17
  18
  19
  20
  21
  22
  23
  24
  25
  26
  27
  28
  29
  30
  31
  32
  33
  34
  35
  36
  37
  38
  39
  40
  41
  42
  43
  44
  45
  46
  47
  48
  49
  50
  51
  52
  53
  54
  55
  56
  57
  58
  59
  60
  61
  62
  63
  64
  65
  66
  67
  68
  69
  70
  71
  72
  73
  74
  75
  76
  77
  78
  79
  80
  81
  82
  83
  84
  85
  86
  87
  88
  89
  90
  91
  92
  93
  94
  95
  96
  97
  98
  99
 100
 101
 102
 103
 104
 105
 106
 107
 108
 109
 110
 111
 112
 113
 114
 115
 116
 117
 118
 119
 120
 121
 122
 123
 124
 125
 126
 127
 128
 129
 130
 131
 132
 133
 134
 135
 136
 137
 138
 139
 140
 141
 142
 143
 144
 145
 146
 147
 148
 149
 150
 151
 152
 153
 154
 155
 156
 157
 158
 159
 160
 161
 162
 163
 164
 165
 166
 167
 168
 169
 170
 171
 172
 173
 174
 175
 176
 177
 178
 179
 180
 181
 182
 183
 184
 185
 186
 187
 188
 189
 190
 191
 192
 193
 194
 195
 196
 197
 198
 199
 200
 201
 202
 203
 204
 205
 206
 207
 208
 209
 210
 211
 212
 213
 214
 215
 216
 217
 218
 219
 220
 221
 222
 223
 224
 225
 226
 227
 228
 229
 230
 231
 232
 233
 234
 235
 236
 237
 238
 239
 240
 241
 242
 243
 244
 245
 246
 247
 248
 249
 250
 251
 252
 253
 254
 255
 256
 257
 258
 259
 260
 261
 262
 263
 264
 265
 266
 267
 268
 269
 270
 271
 272
 273
 274
 275
 276
 277
 278
 279
 280
 281
 282
 283
 284
 285
 286
 287
 288
 289
 290
 291
 292
 293
 294
 295
 296
 297
 298
 299
 300
 301
 302
 303
 304
 305
 306
 307
 308
 309
 310
 311
 312
 313
 314
 315
 316
 317
 318
 319
 320
 321
 322
 323
 324
 325
 326
 327
 328
 329
 330
 331
 332
 333
 334
 335
 336
 337
 338
 339
 340
 341
 342
 343
 344
 345
 346
 347
 348
 349
 350
 351
 352
 353
 354
 355
 356
 357
 358
 359
 360
 361
 362
 363
 364
 365
 366
 367
 368
 369
 370
 371
 372
 373
 374
 375
 376
 377
 378
 379
 380
 381
 382
 383
 384
 385
 386
 387
 388
 389
 390
 391
 392
 393
 394
 395
 396
 397
 398
 399
 400
 401
 402
 403
 404
 405
 406
 407
 408
 409
 410
 411
 412
 413
 414
 415
 416
 417
 418
 419
 420
 421
 422
 423
 424
 425
 426
 427
 428
 429
 430
 431
 432
 433
 434
 435
 436
 437
 438
 439
 440
 441
 442
 443
 444
 445
 446
 447
 448
 449
 450
 451
 452
 453
 454
 455
 456
 457
 458
 459
 460
 461
 462
 463
 464
 465
 466
 467
 468
 469
 470
 471
 472
 473
 474
 475
 476
 477
 478
 479
 480
 481
 482
 483
 484
 485
 486
 487
 488
 489
 490
 491
 492
 493
 494
 495
 496
 497
 498
 499
 500
 501
 502
 503
 504
 505
 506
 507
 508
 509
 510
 511
 512
 513
 514
 515
 516
 517
 518
 519
 520
 521
 522
 523
 524
 525
 526
 527
 528
 529
 530
 531
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<title>Computer Networks (5)</title>
<meta name="cours-n" content="5">

<meta name="author" content="Rémi Emonet">
<meta name="venue" content="DWA M1 WI/MLDM">
<meta name="date" content="2017">
<meta name="affiliation" content="Université Jean Monnet − Laboratoire Hubert Curien">
<style type="text/css">
.inlineimages img {display: inline !important; }
.slide .above {position:absolute; left: 20px; top: 20px; width: 760px; height: 460px; text-align:center;}
.above {z-index: 100 !important;}
tt {border: 1px solid #DDD;}
</style>

<!--
<script src="deck.js/extensions/includedeck/load.js"></script>
<script src="extensions/slides-dev.js"></script>
-->
<script src="extensions/deck-packed.js"></script>
<script src="extensions/slides.js"></script>
<script>go()</script>
</head>

<body>

<div class="deck-container">

<div class="deck-loading-splash" style="background: black; color: chartreuse;"><span class="vcenter" style="font-size: 30px; font-family: Arial; ">Please wait, while our marmots are preparing the hot chocolate…</span></div>

<section class="smart">

# @chunk: chunks/title.md

# @chunk: chunks/objectives.md

<!-- PART 3 -->
## Computer Networks <span>{var-cours-n}</span>: Plan {#plan overview}
@SVG: media/stack-index.svg 100px 400px {svg floatright appTrans margin-left-minus-100}

- Goal: transport layer {shaded}
- understand its main roles and mechanisms
- understand the how TCP (and UDP) are implemented
- Overview
- Transport layer: context and services (role) {it1}
// see how it fits between application and network
- Multiplexing and demultiplexing {it3}
- UDP {it4}
- Reliable communications, please! {it5}
- Pipelining: principle and algos {it6}
- Implementation of TCP {it7}
- Online timeout estimation {it8}
- Congestion: principle and algos {it9}
- TCP: optimality? equity? {it10}
# @copy:#plan




<!-- transport services -->
# @copy:#plan: %+class:inred: .it1

## Transport Layer: an abstraction on top of the network
@SVG: media/part3/internet-trans-to-trans.svg 350px 500px {svg floatright}

- Process to process comm.
- for the applications
- @anim: #mask-core + #mask-border | #stacks | #arrows
- Role: source{slide}
- gets messages from the app.
- split it in *segments*
- sends segments using the “network” layer
- Role: destination{slide}
- receives segments
- re-assemble them in a message
- transmits the message to the application
- Different protocols{slide}
- UDP: minimal, packets
- TCP: connection, streams

## Distinction between transport and network layers
- Transport layer
- communication (logical) between processes
- built on the network layer
- Network layer{slide}
- communication between hosts
- still a logical communication
- Analogies: sending (snail) mail{slide}
- situation: exchanges between 2 schools
- 10 young children in school A, 10 in school B
- teachers handle the mails
- host == school{slide}
- process == child{slide}
- application message == letter{slide}
- transport layer == teachers(ses){slide}
- network layer == post service{slide}

## Services of the transport layer <br/> (in Internet)
- TCP protocol{slide}
- in-order and reliable transmission
- flow and congestion control
- connections establishment
- UDP protocol{slide}
- unreliable, un-ordered
- minimal transport layer over sur IP
- Missing services in both TCP and UDP {slide}
- bandwidth guarantees
- latency guarantees (delay)
- security


<!-- Mux/Demux -->
# @copy:#plan: %+class:inred: .it3
## Multiplexing and Demultiplexing
- General principle (electronics)
- have multiple signals in a sigle wire
- generally, in sequence (time) {slide}
- Current case {slide}
- have multiple …
- … communications between processes (transport layer)
- … inside a single host communication (network layer)
- multiplexing/demultiplexing{slide}
- @anim: .floatleft

@svg: media/part3/multiplexer.svg 200px 100px {floatleft}

@svg: media/part3/demultiplexer.svg 200px 100px {floatleft}

<img class="floatright slide" src="media/part3/mux-demux.gif" style="width:400px" >


## Multiplexing with TCP and UDP: ports
@SVG: media/part3/segment-structure-ports.svg 250px 500px {floatright withmargin}
- Network layer
- messages: IP <i>datagram</i>
- IP addresses
- source (host)
- destination (host)
- each <i>datagram</i> contains a segment
- Transport layer{slide}
- message: TCP/UDP segment
- ports (+ IP)
// in particular, the destination IP
- redirects a segment to the proper socket

## What is the biggest port number? {question bottom}
@SVG: media/part3/segment-structure-ports.svg 250px 500px {floatright withmargin}
- Ports are numbered from 1 to $N$
- How much is $N$?




## What could identify a socket in UDP?<br/> (for demultiplexing) {question bottom}
- Demultiplexing
- the transport layer
- … redirects segments
- … to the proper sockets

## Demultiplexing for <br/> Connection-less Situations (UDP)
- Used information {slide}
- destination IP address (network)
- destination port (UDP)
- When a host receives a UDP segment {slide}
- it reads the destination port
- it redirect the segment to the UDP socket having this number
- Consequence {slide}
- segments having the same destination port
- … are sent to the same socket
- … whatever the source
- (cf Java program)
- UDP == demultiplexing based on local port number{slide}


## What could identify a socket in TCP?<br/> (for demultiplexing) {question}

## Demultiplexing with Connections (TCP) // have to distinguish clients, each with a socket
- Used information {slide}
- destination IP address (network)
- source IP address, source port and destination port (TCP)
- When a host receives a TCP segment {slide}
- it reads the destination port
- il reads the source IP address
- il reads the source port
- it redirect the segment to the corresponding TCP socket
- Consequence{slide}
- each client (source) is distinguishable
- one socket per client
- demultiplexing provided by TCP
- TCP == demultiplexing based on the client <br/> (local-port / remote-port / remote-IP){slide}






<!-- UDP -->
# @copy:#plan: %+class:inred: .it4


## UDP: User Datagram Protocol [RFC 768]
- Minimal transport protocol {slide}
- best-effort protocol
- packets can be lost
- packets can be received in a different order
- datagram == message from the network layer // even though Java calls it UDPDatagram
- adds error detection
- Connection-less {slide}
- no hand-shaking (no initialization overhead)
- independents packets
- Reliable transfer with UDP?{slide}
- to implement yourself
- … by the applications
- Advantages of UDP{slide}
- simple, lower latency (no connection), smaller packets
// easy to implement, less resources too
- used for: DNS, SNMP (routers), streaming


## UDP: header format for UDP segments

@SVG: media/part3/segment-structure-udp.svg 250px 500px {floatright withmargin}

- Total: 8 bytes
- Source port (16 bits) and destination port (16 bits)
- Size
- total size of the segment
- including the header
- Checksum
- for error detection (altered bits, ...)
- the emitter
- computes the checksum
// based on the packet "content"
- inserts the header
- the receiver
- extracts the checksum value from the segment
- validates that it agrees with the rest of the segment


## Computing a Checksum
<pre style="font-size: 18px">
<span> value 1: 1 1 1 0 0 1 1 0 0 1 1 0 0 1 1 0</span>
<span> value 2: 1 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1</span>
<span class="somme"> sum: <span class="retenue">1</span> 1 0 1 1 1 0 1 1 1 0 1 1 1 <span class="impactretenue">0 1 1</span></span>
<span class="sommewrap"> 1 0 1 1 1 0 1 1 1 0 1 1 1 <span class="impactretenue">1 0 0</span></span>

<span class="checksum">checksum: <span style="color: #009">0 1 0 0 0 1 0 0 0 1 0 0 0 0 1 1</span></span>
</pre>
- View the data as a set of 16-bit numbers
- Successive sums {somme}
- Circular carry (fr: *retenue*) propagation {sommewrap}
- One's complement sum (bits inversion){checksum}
- @anim: .somme
- @anim: %+class:inred: .impactretenue, .retenue
- @anim: .sommewrap
- @anim: .checksum
- UDP: computed on datagram + pseudo-header (IPs+length+…) {slide} // some zeros, and the protocol ID, all from the IP packet





<!-- RELIABLE COMMUNICATIONS (big) -->
# @copy:#plan: %+class:inred: .it5

## Reliable Communication: principle

@SVG: media/part3/communication-fiable.svg 800px 500px {ok}

- @anim: %dur:1 + %viewbox:#zfar + + %dur:
- @anim: .ok
- @anim: %viewbox:#zup | #data1 | #data2 | #transport_fiable | -#transport_fiable + #reseau_nonfiable | #transport_intermediate

## For a reliable communication <br/> what do we need? {question}
// checksum, paquet number, ack, nack?, timeout


## Key Points for a Reliable Communication {libyli}
- Error detection: checksum
- Packet loss detection: acknowledgment, ACK
- Loss compensation: timeout, resending after a delay
- Double reception detection: sequence number
// also for re-ordering
- Error signaling? negative ACK?

## In case of a detected error (wrong checksum) <br/> in a message (or ACK), <br/>what should the protocol do?{dense question}
// negative ACK or ACK of the previous packet as a sign of negative ACK

## Protocol Description: interfaces // particular case to simplify (asymmetric)
- Interface
- emitter {slide}
- appSend(data): called by the application layer
- netSend(pckt): call to the network layer
- netReceive(pckt): callback from the network layer{bidi}
- receiver{slide}
- appDeliver(data): call to the application layer
- netReceive(pckt): callback from the network layer
- netSend(pckt): call to the network layer {bidi}
- @anim: .bidi +
- @anim: %dur:1 + %viewbox:#zup + -#transport_fiable + %dur:
- @anim: .ok

@SVG: media/part3/communication-fiable.svg 800px 240px {ok}


## Protocol Description: emitter side
- State 1 (initial)
- when <tt>appSend(data)</tt>
// pre-split if needed
- prepare <tt>pckt</tt> (header, checksum, number etc)
- store the number as <tt>expected</tt>
- <tt>netSend(pckt)</tt>
- starts a *timer*
- switch to State 2
- State 2 (waiting ACK){slide}
- when <tt>appSend(data)</tt>, buffer it or reject it{slide}
- when <tt>netReceive(pckt)</tt>{slide}
- if <tt>correct(pckt) ∧ isAck(pckt, expected)</tt>
- stop the timer
- switch to State 1
- else: nothing
- on timeout (timer event){slide}
- resend <tt>pckt</tt>
- restart a timer

## Protocol Description: receiver side
- State 1 (initial, waiting for packet <tt>next</tt>)
- when <tt>netReceive(pckt)</tt>
- if <tt>correct(pckt) ∧ isNum(pckt, next)</tt>{slide}
- <tt>appDeliver(getData(pckt))</tt>
- create <i><tt>ackPckt</tt></i> with the number and checksum
- <tt>netSend(<i>ackPckt</i>)</tt>
- <tt>next++</tt>
- else{slide}
- <tt>netSend(<i>ackPckt</i>)</tt> (the previous ACK)
// acts as a negative ACK
// ¬ ∨


## Reliable Protocols: examples
@SVG: media/part3/protocole-fiable-ex1.svg 400px 500px {svg1 floatleft}

@SVG: media/part3/protocole-fiable-ex2.svg 400px 500px {svg2 floatleft}
- @anim: .svg1 |#a1 |#a2 |#a3 |#a4 |#a5 |#a6
- @anim: .svg2 |#b1 |#b2 |#b3 |#b4

## Reliable Protocols: examples
@SVG: media/part3/protocole-fiable-ex3.svg 400px 500px {svg3 floatleft}

@SVG: media/part3/protocole-fiable-ex5.svg 400px 500px {svg5 floatleft}
- @anim: .svg3 |#c1 |#c2 |#c3 |#c4 |#c5 |#c6
- @anim: .svg5 |#e1 |#e2 |#e3 |#e4 |#e5

## Reliable Protocols: examples
@SVG: media/part3/protocole-fiable-ex4.svg 400px 500px {svg4 floatleft}
- @anim: .svg4 |#d1 |#d2 |#d3 |#d4 |#d5 |#d6 |#d7


## Can we do better <br/>in terms of network usage?{question bottom}
@SVG: media/part3/protocole-fiable-ex1.svg 400px 400px {svg1 floatleft}

@SVG: media/part3/protocole-fiable-ex2.svg 400px 400px {svg2 floatleft}


## How to better use the network <br/> when sending multiple packets and acks?
@SVG: media/part3/pipelining-world.svg 800px 500px {svg1 floatleft}
- @anim: #slow | #fast



<!-- PIPELINING -->
# @copy:#plan: %+class:inred: .it6


## Pipelining Motivation
@SVG: media/part3/protocole-pipeline-no.svg 300px 400px {svg floatright}

- Case study
- 1 Gbps link
- 15 ms propagation
- 10 kbits packet
- Computations{slide}
- $d_{\text{trans}} = \frac{L}{R} = \frac{10 \;\text{kbits}}{1\; \text{Gb}\; s^{-1}} = 10 \mu s${dtrans}
- $d_{\text{prop}} = 15 ms${dprop}
- Link usage:  $U = \frac{d_{\text{trans}}}{d_{\text{trans}}+RTT}$ <span class="util2">$U = \frac{d_{\text{trans}}}{d_{\text{trans}}+2\cdot d_{\text{prop}}}$</span><span class="util3">$ = \frac{10}{30010} = 0.000333222$</span> {util}
- @anim: #p1 |#dtrans + .dtrans |#dprop1 + .dprop |#ack1 + #dprop2 |#rtt |.util |.util2 |.util3 |#recack1 + #n2

## Pipelining Usefulness
@SVG: media/part3/protocole-pipeline-yes.svg 800px 500px {svg}
- @anim: #sp1 |#ack1 |#rtt | -#ack1 + #sp2 |#sp3 |#ack1 |#rc1 |#ack2 |#rc2 |#ack3 |#rc3

## Pipelining Usefulness
@SVG: media/part3/protocole-pipeline-no.svg 250px 200px {svg floatright sans}

@SVG: media/part3/protocole-pipeline-yes.svg 300px 350px {svg floatright pipelineyes clearright}

- Ex:
- 1 Gbps, $t_{\text{prop}} = 15 ms$, 10 kbits packets
- Without pipelining{sans}
- $U = \frac{d_{\text{trans}}}{d_{\text{trans}}+RTT} = 0.00033$
<br/> 
- With 3-packet pipelining {pak3}
- $U = \frac{3\; d_{\text{trans}}}{d_{\text{trans}}+RTT}$ <br/> 
- $U = \frac{30}{30010} = 0.000997$ {numerical}
- <br/> {no}
- link use is 3 times bigger {times}
- NB: diagram is not exact {nb}
- @anim: .sans | .pipelineyes | .pak3 | .numerical |.times |.nb


## Pipelining: two principales approaches {libyli}
- Go-back-N
- the emitter
- can have $N$ packets in the pipeline
- the receiver{slide}
- sends cumulative acks only
- do not send the ack if a packet is missing
- the emitter{slide}
- has a time based on the oldest packet
- re-sends all packets in case of timeout
- Selective Repeat
- the emitter can have $N$ packets in the pipeline
- the receiver acknowledges each packet separately
- the emitter keeps a timer for each packet{slide}

## Go-back-N: principle
@svg: media/part3/go-back-n-win.svg 700px 300px {gbn centered}

- @anim: #packets |#legend |#win |#basearrow |#next
- Emitter {em}
- allows up to N consecutive non-ack'd packets
- <tt>ack(i)</tt> means: all packets up to <tt>i</tt> arrived
// we can then continue
- timer
- based on the oldest packet (<tt>base</tt>)
- on timeout: sends all packets starting from <tt>base</tt>
- Receiver{rec}
- <tt>expect</tt>: number of the next expected packet
// NB: not identical to "next" in the emitter side
- drops all packets except the number <tt>expect</tt> (no buffering)
// very simple, no memory, supposes order is almost ok
- always a ack for the last packet properly received (<tt>expect-1</tt>)
- @anim: .em
- @anim: %attr:.gbn: height:150px
- @anim: .rec

## Go-back-N: example {dense}
@svg: media/part3/go-back-n-sequence.svg 700px 550px {gbn centered}

- @anim: #s1 |#s2 |#s3 |#s4 |#a1 |#s5 |#a2 |#s6 |#a2bis |#a2ignore |#a2ter |#a2qua |#timeout |#resend

## Selective-Repeat: principle
@svg: media/part3/selective-repeat-win.svg 700px 300px {gbn centered}

- Emitter {em}
- window of size N
- <tt>ack(i)</tt> means: packet <tt>i</tt> arrived
- a timer, for each packet (independently)
- on timeout: re-sends the corresponding packet
- Receiver{rec}
- it's own window of size N
- ack for each packet (even if some are missing before)
- buffering of packets that arrived out-of-order
// in out-of-order case and also in case of loss
- @anim: #packets |#legend |#win |#basearrow |#next |#packets2 |#guides |#base2 + #win2 |#legend2
- @anim: .em
- @anim: %attr:.gbn: height:200px
- @anim: .rec

## <i>Selective Repeat</i>: example
@svg: media/part3/selective-repeat-sequence.svg 700px 520px {gbn centered}

- @anim: #s1 |#s2 |#s3 |#s4 |#a1 |#s5 |#a2 |#s6 |#a4 |#rcva4 |#a5 |#a6 |#rcva56 |#timeout |#s3bis |#a3 |#rcva3 |#then


## Can we do the same without ack? {question}
// I would say: not really


## Key Points {#kp key deck-status-fake-end}
- {note-area}



</section>


<p class="deck-status" data-progress-size=": spe.top(10, 585) ; bottom: slide.top" style="z-index: 0; color: #339; background: #EEE;"> <span class="deck-status-current"></span> / <span class="deck-status-total"></span><span class="var-author">will be replaced by the author</span><span class="var-title">will be replaced by the title</span></p>

<a data-progress-size=": spe.top(15, 555); height: 45*designRatio; left: slide.right - 70*designRatio; width: 70*designRatio" class="ccby" href="http://en.wikipedia.org/wiki/Creative_Commons_license" title="This work is under CC-BY licence." target="_blank"></a>

<a class="ujm" data-progress-size=": spe.top(15, 525); height: 65*designRatio; left: slide.left; width: 130*designRatio" target="_blank"></a> <!-- shown only if with-ujm is set on the container -->

</div>
<!-- clicky Cla -->
<script type="text/javascript">
var clicky_site_ids = clicky_site_ids || [];
clicky_site_ids.push(100779706);
(function() {
var s = document.createElement('script');
s.type = 'text/javascript';
s.async = true;
s.src = '//static.getclicky.com/js';
( document.getElementsByTagName('head')[0] || document.getElementsByTagName('body')[0] ).appendChild( s );
})();
</script>
<noscript><p><img alt="Clicky" width="1" height="1" src="//in.getclicky.com/100779706ns.gif" /></p></noscript>


<!-- Histats.com START (aync)-->
<script type="text/javascript">var _Hasync= _Hasync|| [];
_Hasync.push(['Histats.start', '1,2767123,4,0,0,0,00010000']);
_Hasync.push(['Histats.fasi', '1']);
_Hasync.push(['Histats.track_hits', '']);
(function() {
var hs = document.createElement('script'); hs.type = 'text/javascript'; hs.async = true;
hs.src = ('http://s10.histats.com/js15_as.js');
(document.getElementsByTagName('head')[0] || document.getElementsByTagName('body')[0]).appendChild(hs);
})();</script>
<noscript><a href="http://www.histats.com" target="_blank"><img src="http://sstatic1.histats.com/0.gif?2767123&101" alt="javascript hit counter" border="0"></a></noscript>
<!-- Histats.com END -->
</body>
</html>