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
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
1345
1346
1347
1348
1349
1350
1351
1352
1353
1354
1355
1356
1357
1358
1359
1360
1361
1362
1363
1364
1365
1366
1367
1368
1369
1370
1371
1372
1373
1374
1375
1376
1377
1378
1379
1380
1381
1382
1383
1384
1385
1386
1387
1388
1389
1390
1391
1392
1393
1394
1395
1396
1397
1398
1399
1400
1401
1402
1403
1404
1405
1406
1407
1408
1409
1410
1411
1412
1413
1414
1415
1416
1417
1418
1419
1420
1421
1422
1423
1424
1425
1426
1427
1428
1429
1430
1431
1432
1433
1434
1435
1436
1437
1438
1439
1440
1441
1442
1443
1444
1445
1446
1447
1448
1449
1450
1451
1452
1453
1454
1455
1456
1457
1458
1459
1460
1461
1462
1463
1464
1465
1466
1467
1468
1469
1470
1471
1472
1473
1474
1475
1476
1477
1478
1479
1480
1481
1482
1483
1484
1485
1486
1487
1488
1489
1490
1491
1492
1493
1494
1495
1496
1497
1498
1499
1500
1501
1502
1503
1504
1505
1506
1507
1508
1509
1510
1511
1512
1513
1514
1515
1516
1517
1518
1519
1520
1521
1522
1523
1524
1525
1526
1527
1528
1529
1530
1531
1532
1533
1534
1535
1536
1537
1538
1539
1540
1541
1542
1543
1544
1545
1546
1547
1548
1549
1550
1551
1552
1553
1554
1555
1556
1557
1558
1559
1560
1561
1562
1563
1564
1565
1566
1567
1568
1569
1570
1571
1572
1573
1574
1575
1576
1577
1578
1579
1580
1581
1582
1583
1584
1585
1586
1587
1588
1589
1590
1591
1592
1593
1594
1595
1596
1597
1598
1599
1600
1601
1602
1603
1604
1605
1606
1607
1608
1609
1610
1611
1612
1613
1614
1615
1616
1617
1618
1619
1620
1621
1622
1623
1624
1625
1626
1627
1628
1629
1630
1631
1632
1633
1634
1635
1636
1637
1638
1639
1640
1641
1642
1643
1644
1645
1646
1647
1648
1649
1650
1651
1652
1653
1654
1655
1656
1657
1658
1659
1660
1661
1662
1663
1664
1665
1666
1667
1668
1669
1670
1671
1672
1673
1674
1675
1676
1677
1678
1679
1680
1681
1682
1683
1684
1685
1686
1687
1688
1689
1690
1691
1692
1693
1694
1695
1696
1697
1698
1699
1700
1701
1702
1703
1704
1705
1706
1707
1708
1709
1710
1711
1712
1713
1714
1715
1716
1717
1718
1719
1720
1721
1722
1723
1724
1725
1726
1727
1728
1729
1730
1731
1732
1733
1734
1735
1736
1737
1738
1739
1740
1741
1742
1743
1744
1745
1746
1747
1748
1749
1750
1751
1752
1753
1754
1755
1756
1757
1758
1759
1760
1761
1762
1763
1764
1765
1766
1767
1768
1769
1770
1771
1772
1773
1774
1775
1776
1777
1778
1779
1780
1781
1782
1783
1784
1785
1786
1787
1788
1789
1790
1791
1792
1793
1794
1795
1796
1797
1798
1799
1800
1801
1802
1803
1804
1805
1806
1807
1808
1809
1810
1811
1812
1813
1814
1815
1816
1817
1818
1819
1820
1821
1822
1823
1824
1825
1826
1827
1828
1829
1830
1831
1832
1833
1834
1835
1836
1837
1838
1839
1840
1841
1842
1843
1844
1845
1846
1847
1848
1849
1850
1851
1852
1853
1854
1855
1856
1857
1858
1859
1860
1861
1862
1863
1864
1865
1866
1867
1868
1869
1870
1871
1872
1873
1874
1875
1876
1877
1878
1879
1880
1881
1882
1883
1884
1885
1886
1887
1888
1889
1890
1891
1892
1893
1894
1895
1896
1897
1898
1899
1900
1901
1902
1903
1904
1905
1906
1907
1908
1909
1910
1911
1912
1913
1914
1915
1916
1917
1918
1919
1920
1921
1922
1923
1924
1925
1926
1927
1928
1929
1930
1931
1932
1933
1934
1935
1936
1937
1938
1939
1940
1941
1942
1943
1944
1945
1946
1947
1948
1949
1950
1951
1952
1953
1954
1955
1956
1957
1958
1959
1960
1961
1962
1963
1964
1965
1966
1967
1968
1969
1970
1971
1972
1973
1974
1975
1976
1977
1978
1979
1980
1981
1982
1983
1984
1985
1986
1987
1988
1989
1990
1991
1992
1993
1994
1995
1996
1997
1998
1999
2000
2001
2002
2003
2004
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
2025
2026
2027
2028
2029
2030
2031
2032
2033
2034
2035
2036
2037
2038
2039
2040
2041
2042
2043
2044
2045
2046
2047
2048
2049
2050
2051
2052
2053
2054
2055
2056
2057
2058
2059
2060
2061
2062
2063
2064
2065
2066
2067
2068
2069
2070
2071
2072
2073
2074
2075
2076
2077
2078
2079
2080
2081
2082
2083
2084
2085
2086
2087
2088
2089
2090
2091
2092
2093
2094
2095
2096
2097
2098
2099
2100
2101
2102
2103
2104
2105
2106
2107
2108
2109
2110
2111
2112
2113
2114
2115
2116
2117
2118
2119
2120
2121
2122
2123
2124
2125
2126
2127
2128
2129
2130
2131
2132
2133
2134
2135
2136
2137
2138
2139
2140
2141
2142
2143
2144
2145
2146
2147
2148
2149
2150
2151
2152
2153
2154
2155
2156
2157
2158
2159
2160
2161
2162
2163
2164
2165
2166
2167
2168
2169
2170
2171
2172
2173
2174
2175
2176
2177
2178
2179
2180
2181
2182
2183
2184
2185
2186
2187
2188
2189
2190
2191
2192
2193
2194
2195
2196
2197
2198
2199
2200
2201
2202
2203
2204
2205
2206
2207
2208
2209
2210
2211
2212
2213
2214
2215
2216
2217
2218
2219
2220
2221
2222
2223
2224
2225
2226
2227
2228
2229
2230
2231
2232
2233
2234
2235
2236
2237
2238
2239
2240
2241
2242
2243
2244
2245
2246
2247
2248
2249
2250
2251
2252
2253
2254
2255
2256
2257
2258
2259
2260
2261
2262
2263
2264
2265
2266
2267
2268
2269
2270
2271
2272
2273
2274
2275
2276
2277
2278
2279
2280
2281
2282
2283
2284
2285
2286
2287
2288
2289
2290
2291
2292
2293
2294
2295
2296
2297
2298
2299
2300
2301
2302
2303
2304
2305
2306
2307
2308
2309
2310
2311
2312
2313
2314
2315
2316
2317
2318
2319
2320
2321
2322
2323
2324
2325
2326
2327
2328
2329
2330
2331
2332
2333
2334
2335
2336
2337
2338
2339
2340
2341
2342
2343
2344
2345
2346
2347
2348
2349
2350
2351
2352
2353
2354
2355
2356
2357
2358
2359
2360
2361
2362
2363
2364
2365
2366
2367
2368
2369
2370
2371
2372
2373
2374
2375
2376
2377
2378
2379
2380
2381
2382
2383
2384
2385
2386
2387
2388
2389
2390
2391
2392
2393
2394
2395
2396
2397
2398
2399
2400
2401
2402
2403
2404
2405
2406
2407
2408
2409
2410
2411
2412
2413
2414
2415
2416
2417
2418
2419
2420
2421
2422
2423
2424
2425
2426
2427
2428
2429
2430
2431
2432
2433
2434
2435
2436
2437
2438
2439
2440
2441
2442
2443
2444
2445
2446
2447
2448
2449
2450
2451
2452
2453
2454
2455
2456
2457
2458
2459
2460
2461
2462
2463
2464
2465
2466
2467
2468
2469
2470
2471
2472
2473
2474
2475
2476
2477
2478
2479
2480
2481
2482
2483
2484
2485
2486
2487
2488
2489
2490
2491
2492
2493
2494
2495
2496
2497
2498
2499
2500
2501
2502
2503
2504
2505
2506
2507
2508
2509
2510
2511
2512
2513
2514
2515
2516
2517
2518
2519
2520
2521
2522
2523
2524
2525
2526
2527
2528
2529
2530
2531
2532
2533
2534
2535
2536
2537
2538
2539
2540
2541
2542
2543
2544
2545
2546
2547
2548
2549
2550
2551
2552
2553
2554
2555
2556
2557
2558
2559
2560
2561
2562
2563
2564
2565
2566
2567
2568
2569
2570
2571
2572
2573
2574
2575
2576
2577
2578
2579
2580
2581
2582
2583
2584
2585
2586
2587
2588
2589
2590
2591
2592
2593
2594
2595
2596
2597
2598
2599
2600
2601
2602
2603
2604
2605
2606
2607
2608
2609
2610
2611
2612
2613
2614
2615
2616
2617
2618
2619
2620
2621
2622
2623
2624
2625
2626
2627
2628
2629
2630
2631
2632
2633
2634
2635
2636
2637
2638
2639
2640
2641
2642
2643
2644
2645
2646
2647
2648
2649
2650
2651
2652
2653
2654
2655
2656
2657
2658
2659
2660
2661
2662
2663
2664
2665
2666
2667
2668
2669
2670
2671
2672
2673
2674
2675
2676
2677
2678
2679
2680
2681
2682
2683
2684
2685
2686
2687
2688
2689
2690
2691
2692
2693
2694
2695
2696
2697
2698
2699
2700
2701
2702
2703
2704
2705
2706
2707
2708
2709
2710
2711
2712
2713
2714
2715
2716
2717
2718
2719
2720
2721
2722
2723
2724
2725
2726
2727
2728
2729
2730
2731
2732
2733
2734
2735
2736
2737
2738
2739
2740
2741
2742
2743
2744
2745
2746
2747
2748
2749
2750
2751
2752
2753
2754
2755
2756
2757
2758
2759
2760
2761
2762
2763
2764
2765
2766
2767
2768
2769
2770
2771
2772
2773
2774
2775
2776
2777
2778
2779
2780
2781
2782
2783
2784
2785
2786
2787
2788
2789
2790
2791
2792
2793
2794
2795
2796
2797
2798
2799
2800
2801
2802
2803
2804
2805
2806
2807
2808
2809
2810
2811
2812
2813
2814
2815
2816
2817
2818
2819
2820
2821
2822
2823
2824
2825
2826
2827
2828
2829
2830
2831
2832
2833
2834
2835
2836
2837
2838
2839
2840
2841
2842
2843
2844
2845
2846
2847
2848
2849
2850
2851
2852
2853
2854
2855
2856
2857
2858
2859
2860
2861
2862
2863
2864
2865
2866
2867
2868
2869
2870
2871
2872
2873
2874
2875
2876
2877
2878
2879
2880
2881
2882
2883
2884
2885
2886
2887
2888
2889
2890
2891
2892
2893
2894
2895
2896
2897
2898
2899
2900
2901
2902
2903
2904
2905
2906
2907
2908
2909
2910
2911
2912
2913
2914
2915
2916
2917
2918
2919
2920
2921
2922
2923
2924
2925
2926
2927
2928
2929
2930
2931
2932
2933
2934
2935
2936
2937
2938
2939
2940
2941
2942
2943
2944
2945
2946
2947
2948
2949
2950
2951
2952
2953
2954
2955
2956
2957
2958
2959
2960
2961
2962
2963
2964
2965
2966
2967
2968
2969
2970
2971
2972
2973
2974
2975
2976
2977
2978
2979
2980
2981
2982
2983
2984
2985
2986
2987
2988
2989
2990
2991
2992
2993
2994
2995
2996
2997
2998
2999
3000
3001
3002
3003
3004
3005
3006
3007
3008
3009
3010
3011
3012
3013
3014
3015
3016
3017
3018
3019
3020
3021
3022
3023
3024
3025
3026
3027
3028
3029
3030
3031
3032
3033
3034
3035
3036
3037
3038
3039
3040
3041
3042
3043
3044
3045
3046
3047
3048
3049
3050
3051
3052
3053
3054
3055
3056
3057
3058
3059
3060
3061
3062
3063
3064
3065
3066
3067
3068
3069
3070
3071
3072
3073
3074
3075
3076
3077
3078
|
Network Working Group G. Finn
Request for Comments: 916 ISI
October 1984
RELIABLE ASYNCHRONOUS TRANSFER PROTOCOL (RATP)
Status of This Memo
This RFC suggests a proposed protocol for the ARPA-Internet
community, and requests discussion and suggestions for improvements.
Distribution of this memo is unlimited.
This paper proposes and specifies a protocol which allows two
programs to reliably communicate over a communication link. It
ensures that the data entering one end of the link if received
arrives at the other end intact and unaltered. The protocol, named
RATP, is designed to operate over a full duplex point-to-point
connection. It contains some features which tailor it to the RS-232
links now in common use.
Introduction
We are witnessing today an explosive growth in the small or personal
computer market. Such inexpensive computers are not normally
connected to a computer network. They are most likely stand-alone
devices. But virtually all of them have an RS-232 interface. They
also usually have a modem. This allows them to communicate over the
telephone with any other similarly equipped computer.
The telephone system is a pervasive network, but one of the
characteristics of the telephone system is the unpredictable quality
of the circuit. The standard telephone circuit is designed for voice
communication and not data communication. Voice communication
tolerates a much higher degree of 'noise' than does a data circuit,
so a voice circuit is tolerant of a much higher level of noise than
is a data circuit. Thus it is not uncommon for a byte of data
transferred over a telephone circuit to have noise inserted. For the
same reason it is also not uncommon to have spurious data bytes added
to the data stream.
The need for a method of reliably transferring data over an RS-232
point-to-point link has become severe. As the number of powerful
personal computers grows, the need for them to communicate with one
another grows as well. The new markets and new services that these
computers will eventually allow their users to access will rely
heavily upon the telephone system. Services like electronic mail,
electronic banking, ordering merchandise from home with a personal
computer, etc. As the information revolution proceeds data itself
will become a commodity. All require accuracy of the data sent or
received.
Finn [Page 1]
^L
RFC 916 October 1984
Reliable Asynchronous Transfer Protocol
1. Philosopy of Design
Many tradeoffs were made in designing this protocol. Decisions were
made by above all ensuring reliability and then by favoring
simplicity of implementation. It is hoped that this protocol is
simple enough to be implemented not only by small computers but also
by stand alone devices incorporating microcomputers which accept
commands over RS-232 lines. Sophisticated but unnecessary features
such as dynamic window management [TCP 81] were left out for
simplicity's sake. Having several packets outstanding at a time was
eliminated for the same reason, and data queued to send when a
connection is closed remotely is discarded. This eliminates two
states from the protocol implementation.
The reader may ask why define this protocol at all, there are after
all already RS-232 transport protocols in use. This is true but some
lack one or more features vitally important or are too complex. See
Appendix II for a brief survey.
- A protocol which can only transfer data in one direction is
unable to use a single RS-232 link for a full-duplex connection.
As such it cannot act as a bridge between most computer
networks. Also it is not capable of supporting any applications
requiring the two-way exchange of data. In particular it is not
a platform suitable for the creation of most higher level
applications. Unidirectional flow of data is sufficient for a
weak implementation of file transfer but insufficient for remote
terminal service, transaction oriented processing, etc.
- Some of the existing RS-232 transport protocols allow the use of
only fixed size packets or do not allow the receiver to place a
limit on the sender's packets. Where that block size is too
large for the receiving end concentrator, that concentrator is
likely to immediately invoke flow control. This results in many
dropped and damaged packets. The receiver must be able to
inform the sender at connection initiation what is the maximum
packet size it is prepared to receive.
- Some protocols have a number of features which may or may not be
implemented at each site. Examples are, several checksumming
algorithms, differing data transmission restrictions, sometimes
8-bit data, sometimes restricted ASCII subsets, etc. The
resulting requirement that all sites implement all the various
features is rarely met.
Finally, the size of this document may be imposing. The document
attempts to fully specify the behavior of the protocol. A careful
Finn [Page 2]
^L
RFC 916 October 1984
Reliable Asynchronous Transfer Protocol
exposition of the protocol's behavior under all circumstances is
necessary to answer any questions an implementor might have, to make
it possible to verify the protocol, etc. This size of this
specification should not be taken as an indication of the difficulty
of implementing it.
1.1. The Host Environment
This protocol is designed to operate on any point-to-point
communication link capable of transmitting and receiving data. It
is not necessary that the link be asynchronous. Because neither
end of a connection has control over when the other decides to
transmit, the link should be full duplex. It is expected that in
the vast majority of circumstances an asynchronous full-duplex
RS-232 link will be used.
In practice this protocol could reside anywhere from the RS-232
driver software on a microcomputer in a concentrator all the way
to the user software level. Ideally it properly resides inside
the host operating system or concentrator. It should be an option
associated with communication link which is selectable by the user
program. If reliable data transmission were of great importance
then the software would choose the option. Once the option were
chosen the initial connection handshaking would begin.
There are many cases where this protocol will not reside in a host
operating system (initially this will always be so). In addition
there are many pieces of stand-alone equipment which accept
commands over an RS-232 link. A plotter is such an example. To
have a several hour plot ruined by noise on an unreliable data
line is an all too often occurrence. The sending and receiving
sides of the protocol should be as simple as possible allowing
applications software and stand alone devices to utilize the
protocol with little penalty of time or space.
1.2. Relation to Other Protocols
The "layering" concept has become the accepted way of designing
communications protocols. Because this protocol will operate in a
point-to-point environment it comprises both the datagram and
reliable connection layers. No multi-network capability is
implied. Where a link using this protocol bridges differing
networks it is expected that other protocols like TCP will have
their packets fragmented and encapsulated inside the packets of
this protocol.
Finn [Page 3]
^L
RFC 916 October 1984
Reliable Asynchronous Transfer Protocol
2. Packet Specification
RATP transmits data over a full-duplex communication link. Data may
be transmitted in both directions over the link. A stream of data is
communicated by being broken up into 8-bit pieces called octets.
These octets are serially accumulated to form a packet. The packet
is the unit of data communicated over the link. The protocol
virtually guarantees that the data transmitted at one end, if
received, arrives unaltered and intact at the other end.
Within an octet all eight bits contain data. All eight bits must be
preserved by the link interface and associated device driver. In
many operating systems this is ensured by placing the connection into
RAW or BINARY data mode. During normal operation packets are
transmitted and acknowledged one at a time over the link in each
direction. Each packet is composed of a HEADER followed by a DATA
portion. The DATA portion may be empty.
NOTE: There are some older operating systems and devices which do
not permit 8-bit communication over an RS-232 link. Most of these
allow restricted 7-bit communication. RATP can automatically
detect this situation during connection initiation and utilizes a
special packing strategy when full 8-bit communication is not
possible. This is entirely transparent to any client software.
See Appendix I for a discussion of this case.
Finn [Page 4]
^L
RFC 916 October 1984
Reliable Asynchronous Transfer Protocol
2.1. Header Format
Byte No.
+-------------------------------+
| |
1 | Synch Leader | Hex 01
| |
+-------------------------------+
| S | A | F | R | S | A | E | S |
2 | Y | C | I | S | N | N | O | O | Control
| N | K | N | T | | | R | |
+-------------------------------+
| |
3 | Data length (0-255) |
| |
+-------------------------------+
| |
4 | Header Checksum |
| |
+-------------------------------+
Header Portion of a Packet
2.1.1. Synch Leader
RS-232 provides a self-clocking communications medium. The
wires over which data flows are often placed in 'noisy'
environments where the noise can appear as added unwanted data.
For this reason the beginning of a packet is denoted by a one
octet SYNCH pattern. This allows the receiver to discard noise
which appears on the connection prior to the reception of a
packet. The SYNCH pattern is defined to be the one octet hex
01, the ASCII Start Of Header character <SOH>.
The SYNCH pattern should ideally be unlikely to occur as the
result of noise. Differing modems, etc. have differing
responses to noise so this is hard to achieve. The pattern
chosen is thought to be a good compromise since many modems
manifest noise by setting the high order bits. Situations will
occur in which receiver is scanning for the beginning of a
packet and a spurious SYNCH pattern is seen. To detect
situations of this type a header checksum is provided (see
below).
Finn [Page 5]
^L
RFC 916 October 1984
Reliable Asynchronous Transfer Protocol
2.1.2. Control Bits
The first octet following the SYNCH pattern contains a 5-bit
field of control flags and two 1-bit sequence number fields.
The last bit is reserved and must be zero.
2.1.2.1. SYN - Synchronize Flag
Synchronize the connection. No data may be sent in a packet
which has the SYN flag set.
2.1.2.2. ACK - Acknowledge Flag
Acknowledge number is significant. Data may accompany a
packet which has this flag set as long as neither of SYN,
RST, nor FIN are also set. Once a connection has been
established this is always set.
2.1.2.3. RST - Reset Flag
Reset the connection. This is a method by which one end of
a connection can reset the other when an anomalous condition
is detected. No data may be sent in a packet which has the
RST flag set.
2.1.2.4. FIN - Finishing Flag
This indicates that no more data will be sent to the other
end of the connection. It also indicates that no more data
will be accepted. No data may be sent in a packet which has
the FIN flag set.
2.1.2.5. SN - Sequence Number
The Sequence Number associated with this packet.
2.1.2.6. AN - Acknowledge Number
If the ACK control flag is set this is the next Sequence
Number the sender of the packet is expecting to receive.
2.1.2.7. EOR - End of Record
This bit is provided as an aid for higher level protocols
which may need to fragment their packets. The Internet
protocol for example often uses packets as large as 576
octets. A packet of such size would require fragmentation
Finn [Page 6]
^L
RFC 916 October 1984
Reliable Asynchronous Transfer Protocol
when transported using this protocol. The EOR bit if set
provides information to the higher level that a record is
terminated in this packet. It is for information only and
is the responsibility of the higher level to set/clear it
when building packets to send. The interface to the
protocol must provide a method of reading/setting/clearing
this bit.
2.1.2.8. SO - Single Octet
One application thought to be of special importance is
single character transmission --- a user communicates from
the keyboard of a personal computer to another computer over
an unreliable link. Since rapid interactive response is
desirable it is expected that many of the characters typed
will be transmitted individually. To minimize the overhead
of this special case the SO control flag is provided.
The SO flag has no meaning if either the SYN, RST, or FIN
flags are set. Assume none of those flags are set, then if
the SO flag is set it indicates that a single octet of data
is contained in this packet. Since the amount of data is
known to be one octet the LENGTH field is superfluous and
itself contains the data octet. The data portion of the
packet is not transmitted.
The SO flag removes the need to transmit the data portion of
the packet in this special case. Without the SO flag seven
octets would be required of the packet, with it only four
are needed and so transmission efficiency is improved by 40
percent. The header checksum protects the single octet of
data.
2.1.3. Length
The second octet following the SYNCH pattern holds length
information. If the SYN bit is present this contains the
maximum number of data octets the receiver is allowed to
transmit in any single packet to the sender. This quantity is
called the MDL. A sender may indicate his unwillingness to
accept any data octets by specifying an MDL of zero. In this
case presumably all the data would be moving from the sender to
the receiver. Obviously if data is to be transmitted both
sides of a connection cannot have an MDL of zero.
If neither the SYN, RST, nor FIN flags are set this is an 8-bit
field called LENGTH. In this case if the SO flag bit is set
Finn [Page 7]
^L
RFC 916 October 1984
Reliable Asynchronous Transfer Protocol
then LENGTH contains a single octet of data. Otherwise it
contains the count of data octets in this packet. From zero
(0) to MDL octets of data may appear in a single packet. MDL
is limited to a maximum of 255.
2.1.4. Header Checksum
The header checksum algorithm is the 8-bit equivalent of the
16-bit data checksum detailed below. It is built and processed
in an similar manner but is eight bits wide instead of sixteen.
When sending the header checksum octet is initially cleared.
An 8-bit sum of the control, length, and header checksum octets
is formed employing end-around carry. That sum is then
complemented and stored in the header checksum octet. Upon
receipt the 8-bit end-around carry sum is formed of the same
three octets. If the sum is octal 377 the header is presumed
to be valid. In all other cases the header is assumed to be
invalid.
The reasons for providing this separate protection to the
header are discussed in the chapter dealing with error
handling. The header checksum covers the control and data
length octets. It does not include the SYNCH pattern.
2.2. Data Format
The data portion of a packet immediately follows the header if the
SO flag is not set and LENGTH > 0. It consists of LENGTH data
octets immediately followed by two data checksum octets. If
present the data portion contains LENGTH+2 octets.
Finn [Page 8]
^L
RFC 916 October 1984
Reliable Asynchronous Transfer Protocol
Data Byte No.
+-------------------------------+
1 | | High order \
+-- --+ > Word
2 | | Low order /
+-- --+
. | Data | High order \
+-- --+ > Word
. | | Low order /
+-- --+
LENGTH | | High order \
+-------------------------------+ > Word
| Imaginary padding octet 0 | Low order /
+-------------------------------+
LENGTH+1 | | High order \
+-- Data Checksum --+ > Word
LENGTH+2 | | Low order /
+-------------------------------+
Data Portion of a Packet
2.2.1. Data Checksum
The last two octets of the data portion of a packet are a data
checksum. A 16-bit checksum is used by this protocol to detect
incorrectly transmitted data. This has shown itself to be a
reliable method for detecting most categories of bit drop out
and bit insertion. While it does not guarantee the detection
of all such errors the probability of such an error going
undetected is on the order of 2**(-16).
The checksum octets follow the data to enable the sender of a
packet to compute the checksum while transmitting a packet and
the receiver to compute the checksum while receiving the
packet. Thus neither must store the packet and then process
the data for checksumming in a separate pass.
Order of Transmission
The order in which the 8-bit octets are assembled into
16-bit words, which is the low order octet and which is the
high, must be rigidly specified for the purpose of computing
16-bit checksums. We specify the big endian ordering in the
diagram above [Cohen 81].
Finn [Page 9]
^L
RFC 916 October 1984
Reliable Asynchronous Transfer Protocol
Checksum Algorithm
The checksum algorithm chosen is similar to that used by
IP/TCP protocols [IP 81] [TCP 81]. This algorithm has shown
itself to be both reliable and relatively easy to compute.
The interested reader may refer to [TCP Checksum 78] for a
more thorough discussion of its properties.
The checksum algorithm is:
SENDER
The unsigned sum of the 16-bit words of the data portion
of the packet is formed. Any overflow is added into the
lowest order bit. This sum does not include the header
portion of the packet. For the purpose of building a
packet for transmission the two octet checksum field is
zero. The sum formed is then bit complemented and
inserted into the checksum field before transmission.
If the total number of data octets is odd then the last
octet is padded to the right (low order) with zeros to
form a 16-bit word for checksum purposes. This pad octet
is not transmitted as part of the packet.
RECEIVER
The sum is computed as above but including the values
received in the checksum field. If the 16-bit sum is
octal 177777 then the data is presumed to be valid. In
all other cases the data is presumed to be invalid.
This unsigned 16-bit sum adds 16-bit quantities with any
overflow bit added into the lowest order bit of the sum. This
is called 'end around carry'. End around carry addition
provides several properties: 1) It provides full commutivity of
addition (summing in any order is equivalent), and 2) If you
apply a given rotation to each quantity before addition and
when the final total is formed apply the inverse rotation, then
the result will be equivalent to any other rotation chosen.
The latter property gives little endian machines like a PDP-11
the go ahead to pick up 16-bit quantities and add them in byte
swapped order.
Finn [Page 10]
^L
RFC 916 October 1984
Reliable Asynchronous Transfer Protocol
The PDP-11 code to calculate the checksum is:
CLR R0 ; R0 will get the checksum
; R2 contains LENGTH count
LOOP: ADD (R1)+,R0 ; Add the next 16-bit byte
ADC R0 ; Make any carry be end around
SOB R2,LOOP ; Loop over entire packet
COM R0 ; Bit complement result
2.3. Sequence Numbers
Sequence numbers work with acknowledge numbers to inform the
sender that his last data packet was received, and to inform the
receiver of the sequence number of the next data packet it expects
to see. When the ACK flag is set in a packet the AN field
contains the sequence number of the next data packet it expects
from the sender. The sender looks at the AN field and by
implication knows that the packet he just sent should have had a
sequence number of:
<AN received-1 modulo 2>
If it did have that number that packet is considered to have been
acknowledged.
Similarly, the receiver expects the next data packet it sees to
have an SN field value equal to the AN field of the last
acknowledge message it sent. If this is not the case then the
receiver assumes that it is receiving a duplicate of a data packet
it earlier acknowledged. This implies that the packet containing
the acknowledgment did not arrive and therefor the packet that
contained the acknowledgment should be retransmitted. The
duplicate data packet is discarded.
The only packets which require acknowledgment are packets
containing status flags (SYN, RST, FIN, or SO) or data. A packet
which contains only an acknowledgment, i.e. <AN=n><CTL=ACK>, does
not require a response (it contains no status flags or data).
Both the AN and SN fields are a single bit wide. Since at most
one packet is in the process of being sent/acknowledged in a
particular direction at any one time a single bit is sufficient to
provide a method of duplicate packet detection and removal of a
packet from the retransmission queue. The arithmetic to advance
these numbers is modulo 2. Thus when a data packet has been
acknowledged the sender's next sequence number will be the current
one, plus one modulo 2:
Finn [Page 11]
^L
RFC 916 October 1984
Reliable Asynchronous Transfer Protocol
<SN = SN + 1 modulo 2>
The individual acknowledgment of each packet containing data can
mislead one into thinking that side A of a connection cannot send
data to side B until it receives a packet from B. That only then
can it acknowledge B's packet and place in the acknowledging
packet some data of its own. This is not the case.
As long as its last packet sent requiring a response has been
acknowledged each side of a connection is free to send a data
packet whenever it wishes. Naturally, if one side is sending a
data packet and it also must acknowledge receipt of a data packet
from the other side, it is most efficient to combine both
functions in a single packet.
2.4. Maximum Packet Size
The maximum packet size is:
SYNCH + HEADER + Data Checksum + 255 = 261 octets
There is therefor no need to allocate more than that amount of
storage for any received packets.
Finn [Page 12]
^L
RFC 916 October 1984
Reliable Asynchronous Transfer Protocol
3. The Opening and Closing of a Connection
3.1. Opening a Connection
A "three-way handshake" is the procedure used to establish a
connection. It is normally initiated by one end of the connection
and responded to by the other. It will still work if both sides
simultaneously initiate the procedure. Experience has shown that
this strategy of opening a connection reduces the probability of
false connections to an acceptably low level.
The simplest form of the three-way handshake is illustrated in the
diagram below. The time order is line by line from top to bottom
with certain lines numbered for reference. User events are placed
in brackets as in [OPEN]. An arrow (-->) represents the direction
of flow of a packet and an ellipsis (...) indicates a packet in
transit. Side A and side B are the two ends of the connection.
An "XXX" indicates a packet which is lost or rejected. The
contents of the packet are shown on the center of each line. The
state of both connections is that caused by the departure or
arrival of the packet represented on the line. The contents of
the data portion of a packet are left out for clarity.
Side A Side B
1. CLOSED LISTEN
2. [OPEN request]
SYN-SENT -> <SN=0><CTL=SYN><MDL=n> ...
3. --> SYN-RECEIVED
... <SN=0><AN=1><CTL=SYN,ACK><MDL=m> <--
4. ESTABLISHED <--
--> <SN=1><AN=1><CTL=ACK><DATA> ...
5. --> ESTABLISHED
In line 2 above the user at side A has requested that a connection
be opened. Side A then attempts to open a connection by sending a
SYN packet to side B which is in the LISTEN state. It specifies
its initial sequence number, here zero. It places in the LENGTH
field of the header the largest number of data octets it can
consume in any one packet (MDL). The MDL is normally positive.
The action of sending this packet places A in the SYN-SENT state.
In line 3 side B has just received the SYN packet from A. This
Finn [Page 13]
^L
RFC 916 October 1984
Reliable Asynchronous Transfer Protocol
places B in the SYN-RECEIVED state. B now sends a SYN packet to A
which acknowledges the SYN it just received from A. Note that the
AN field indicates B is now expecting to hear SN=1, thus
acknowledging the SYN packet from A which used SN=0. B also
specifies in the LENGTH field the largest number of data octets it
is prepared to consume.
Side A receives the SYN packet from B which acknowledges A's
original SYN packet in line 4. This places A in the ESTABLISHED
state. Side A can now be confident that B expects to receive more
packets from A.
A is now free to send B the first DATA packet. In line 5 upon
receipt of this packet side B is placed into the ESTABLISHED
state. DATA cannot be sent until the sender is in the ESTABLISHED
state. This is because the LENGTH field is used to specify the
MDL when opening the connection.
3.2. Recovering from a Simultaneous Active OPEN
It is of course possible that both ends of a connection may choose
to perform an active OPEN simultaneously. In this case neither
end of the connection is in the LISTEN state, both send SYN
packets. A reliable bidirectional protocol must recover from this
situation. It should recover in such a manner that the connection
is successfully initiated.
Finn [Page 14]
^L
RFC 916 October 1984
Reliable Asynchronous Transfer Protocol
Side A Side B
1. CLOSED CLOSED
2. [OPEN request]
SYN-SENT --> <SN=0><CTL=SYN><MDL=n> ...
3. ... [OPEN request]
<SN=0><CTL=SYN><MDL=m> <-- SYN-SENT
4. --> SYN-RECEIVED
... <SN=0><AN=1><CTL=SYN,ACK><MDL=m> <--
5. (packet finally arrives)
SYN-RECEIVED <-- <SN=0><CTL=SYN><MDL=m>
--> <SN=0><AN=1><CTL=SYN,ACK><MDL=n> --> ESTABLISHED
... <SN=1><AN=1><CTL=ACK> <--
6. (packet finally arrives)
ESTABLISHED <-- <SN=0><AN=1><CTL=SYN,ACK><MDL=m>
--> <SN=1><AN=1><CTL=ACK> ...
During simultaneous connection both sides of the connection
cycle from the CLOSED state through SYN-SENT to SYN-RECEIVED,
and finally to ESTABLISHED.
3.3. Detecting a Half-Open Connection
Any computer may crash after a connection has been established.
After recovering from the crash it may attempt to open a new
connection. The other end must be able to detect this condition
and treat it as an error.
Finn [Page 15]
^L
RFC 916 October 1984
Reliable Asynchronous Transfer Protocol
Side A Side
1. ESTABLISHED ESTABLISHED
--> <SN=0><AN=1><CTL=ACK><DATA> ...
-->
(crashes)
2. XXX <SN=1><AN=1><CTL=ACK><DATA> <--
3. (attempts to open new connection )
--> <SN=0><CTL=SYN><MDL=m> -->
... <SN=0><AN=1><CTL=RST,ACK> <-- (abort)
CLOSED
4. <--
(connection refused)
CLOSED
3.4. Closing a Connection
Either side may choose to close an established connection. This
is accomplished by sending a packet with the FIN control bit set.
No data may appear in a FIN packet. The other end of the
connection responds by shutting down its end of the connection and
sending a FIN, ACK in response.
Side A Side B
1. ESTABLISHED ESTABLISHED
2. [CLOSE request from user]
FIN-WAIT --> <SN=0><AN=1><CTL=FIN> ...
3. --> LAST-ACK
... <SN=1><AN=1><CTL=FIN,ACK> <--
4. TIME-WAIT <--
--> <SN=1><AN=0><CTL=ACK> ...
5. --> CLOSED
6. (after 2*SRTT time passes)
CLOSED
In line 2 the user on side A of the fully opened connection has
decided to close it down by issuing a CLOSE call. No more data
Finn [Page 16]
^L
RFC 916 October 1984
Reliable Asynchronous Transfer Protocol
will be accepted for sending. If data remains unsent a message
"Warning: Unsent data remains." is communicated to the user. No
more data will be received. A packet containing a FIN but no data
is constructed and sent. Side A goes into the FIN-WAIT state.
Side B sees the FIN sent and immediately builds a FIN, ACK packet
in response. It then goes into the LAST-ACK state. The FIN, ACK
packet is received by side A and an answering ACK is immediately
sent. Side A then goes to the TIME-WAIT state. In line 5 side B
receives the final acknowledgment of its FIN, ACK packet and goes
to the CLOSED state. In line 6 after waiting to be sure its last
acknowledgment was received side A goes to the CLOSED state (SRTT
is the Smoothed Round Trip Time and is defined in section 6.3.1).
Finn [Page 17]
^L
RFC 916 October 1984
Reliable Asynchronous Transfer Protocol
4. Packet Reception
The act of receiving a packet is relatively straightforward. There
are a few points which deserve some discussion. This chapter will
discuss packet reception stage by stage in time order.
Synch Detection
The first stage in the reception of a packet is the discovery of a
SYNCH pattern. Octets are read continuously and discarded until
the SYNCH pattern is seen. Once SYNCH has been observed proceed
to the Header Reception stage.
Header Reception
The remainder of the header is three octets in length. No further
processing can continue until the complete header has been read.
Once read the header checksum test is performed. If this test
fails it is assumed that the current SYNCH pattern was the result
of a data error. Since the correct SYNCH may appear immediately
after the current one, go back to the Synch Detection stage but
treat the three octets of the header following the bad SYNCH as
new input.
If the header checksum test succeeds then proceed to the Data
Reception stage.
Data Reception
A determination of the remaining length of the packet is made. If
either of the SYN, RST, SO, or FIN flags are set then legally the
entire packet has already been read and it is considered to have
'arrived'. No data portion of a packet is present when one of
those flags is set. Otherwise the LENGTH field specifies the
remaining amount of data to read. In this case if the LENGTH
field is zero then the packet contains no data portion and it is
considered to have arrived.
We now assume that a data portion is present and LENGTH was
non-zero. Counting the data checksum LENGTH+2 octets must now be
read. Once read the data checksum test is performed. If this
test fails the entire packet is discarded, return to the Synch
Detection stage. If the test succeeds then the packet is
considered to have arrived.
Finn [Page 18]
^L
RFC 916 October 1984
Reliable Asynchronous Transfer Protocol
Once arrived the packet is released to the upper level protocol
software. In a multiprocess implementation packet reception would
now begin again at the Synch Detection stage.
Finn [Page 19]
^L
RFC 916 October 1984
Reliable Asynchronous Transfer Protocol
5. Functional Specification
A convenient model for the discussion and implementation of protocols
is that of a state machine. A connection can be thought of as
passing through a variety of states, with possible error conditions,
from its inception until it is closed. In such a model each state
represents a known point in the history of a connection. The
connection passes from state to state in response to events. These
events are caused by user calls to the protocol interface (a request
to open or close a connection, data to send, etc.), incoming packets,
and timeouts.
Information about a connection must be maintained at both ends of
that connection. Following the terminology of [TCP 81] the
information necessary to the successful operation of a connection is
called the Transmission Control Block or TCB. The user requests to
the protocol interface are OPEN, SEND, RECEIVE, ABORT, STATUS, and
CLOSE.
This chapter is broken up into three parts. First a brief
description of each protocol state will be presented. Following this
is a slightly more detailed look at the allowed transitions which
occur between states. Finally a detailed discussion of the behavior
of each state is given.
5.1. Protocol States
The states used to describe this protocol are:
LISTEN
This state represents waiting for a connection from the
other end of the link.
SYN-SENT
This represents waiting for a matching connection request
after having sent a connection request.
SYN-RECEIVED
This represents waiting for a confirming connection request
acknowledgment after having both received and sent a
connection request.
Finn [Page 20]
^L
RFC 916 October 1984
Reliable Asynchronous Transfer Protocol
ESTABLISHED
This state represents a connection fully opened at both
ends. This is the normal state for data transfer.
FIN-WAIT
In this state one is waiting for a connection termination
request from the other end of the connection and an
acknowledgment of a termination request previously sent.
LAST-ACK
This end of the connection has seen and acknowledged a
termination request from the other end. This end has
responded with a termination request of its own and is now
expecting an acknowledgment of that request.
CLOSING
This represents waiting for an acknowledgment of a
connection termination request.
TIME-WAIT
This represents waiting for enough time to pass to be sure
that the other end of the connection received the
acknowledgment of its termination request.
CLOSED
A fictional state which represents a completely terminated
connection. If either end of a connection is in this state
it will neither send nor receive data or control packets.
Finn [Page 21]
^L
RFC 916 October 1984
Reliable Asynchronous Transfer Protocol
5.2. State Transitions
This section describes events which cause the protocol to depart
from its current state. A brief mention of each state is
accompanied by a list of departure events and to which state the
protocol goes as a result of those events. Departures due to the
presence of a RST flag are not shown.
5.2.1. LISTEN
This is a request to listen for any connection from the other
end of the link. In this state, no packets are sent. The
connection may be thought of as half-open. A STATUS request
will return to the caller this information.
Arrived at from the CLOSED state in response to a passive OPEN.
In a passive OPEN no packets are sent, the interface is waiting
for the initiation of a connection from the other end of the
link. Also this state can be reached in certain cases in
response to an RST connection reset request.
Departures
- A CLOSE request is made by the user. Delete the half-open
TCB and go to the CLOSED state.
- A packet arrives with the SYN flag set. Retrieve the
sender's MDL he placed into the LENGTH field. Set AN to
be received SN+1 modulo 2. Build a response packet with
SYN, ACK set. Choose your MDL and place it into the
LENGTH octet. Choose your initial SN, place in AN. Send
this packet and go to the SYN-RECEIVED state.
5.2.2. SYN-SENT
Arrived at from the CLOSED state in response to a user's active
OPEN request.
Departures
- A CLOSE request is made by the user. Delete the TCB and
go to the CLOSED state.
- A packet arrives with the SYN flag set. Retrieve the
sender's MDL he placed into the LENGTH field. Set AN to
Finn [Page 22]
^L
RFC 916 October 1984
Reliable Asynchronous Transfer Protocol
be received SN+1 modulo 2. Build a response packet with
ACK set, place in AN. Send this packet and go to the
SYN-RECEIVED state.
- A packet arrives with the SYN, ACK flags set. Retrieve
the sender's MDL he placed into the LENGTH field. Set AN
to be received SN+1 modulo 2. Build a response packet
with ACK set. Set SN to be SN+1 modulo 2, place SN and AN
into the header. Remembering the other end's MDL, build
data portion of packet. Send this packet and go to the
ESTABLISHED state.
5.2.3. SYN-RECEIVED
Arrived at from the LISTEN and SYN-SENT states in response to
an arriving SYN packet.
Departures
- A CLOSE request is made by the user. Create a packet with
FIN set. Send it and go to the FIN-WAIT state.
- A packet arrives with the ACK flag set. This packet
acknowledges a previous SYN packet. Go to the ESTABLISHED
state. The TCB should now note the connection is fully
opened.
- A packet arrives with the FIN flag set. The other end has
decided to close the connection. Create a packet with
FIN, ACK set. Send it and go to the LAST-ACK state.
5.2.4. ESTABLISHED
This state is the normal state for a connection. Data packets
may be exchanged in both directions (MDL allowing). It is
arrived at from the SYN-RECEIVED and SYN-SENT states in
response to the completion of connection initiation.
Departures
- In response to a CLOSE request from the user. Set AN to
be most recently received SN+1 modulo 2. Build a packet
with FIN set. Set SN to be SN+1 modulo 2, place SN and AN
into the header and send the packet. Go to the FIN-WAIT
state.
- A packet containing a FIN is received. Set AN to be
Finn [Page 23]
^L
RFC 916 October 1984
Reliable Asynchronous Transfer Protocol
received SN+1 modulo 2. Build a response packet with both
FIN and ACK set. Set SN to be SN+1 modulo 2, place SN and
AN into the header. No data portion is built. Send this
packet and go to the LAST-ACK state.
5.2.5. FIN-WAIT
Arrived at from either the SYN-RECEIVED state or from the
ESTABLISHED state. In both cases the user had requested a
CLOSE of the connection and a packet with a FIN was sent.
Departures
- A FIN, ACK packet is received which acknowledges the FIN
just sent. Go to the TIME-WAIT state.
- A FIN packet is received which indicates the other end of
the connection has simultaneously decided to close. Set
AN=received SN+1 modulo 2, and SN=SN+1 modulo 2. Send a
response packet with the ACK set. Go to the CLOSING
state.
5.2.6. LAST-ACK
Arrived at from the ESTABLISHED and SYN-RECEIVED states.
Departures
- An ACK is received for the last packet sent which was a
FIN. Delete the TCB and go to the CLOSED state.
5.2.7. CLOSING
Arrived at from the FIN-WAIT state.
Departures
- An ACK is received for the last packet sent which was a
FIN. Go to the TIME-WAIT state.
5.2.8. TIME-WAIT
Arrived at from the FIN-WAIT and CLOSING states.
Finn [Page 24]
^L
RFC 916 October 1984
Reliable Asynchronous Transfer Protocol
Departures
- This states waits until 2*SRTT time has passed. It then
deletes the TCB associated with the connection and goes to
the CLOSED state.
5.2.9. CLOSED
This state can be arrived at for a number of reasons: 1) while
in the LISTEN state the user requests a CLOSE, 2) while in the
SYN-SENT state the user requests a CLOSE, 3) while in the
TIME-WAIT state the 2*SRTT time period has elapsed, and 4)
while in the LAST-ACK state an arriving packet has an ACK of
the previously sent FIN packet.
In this state no data is read or sent over the link. To leave
this state requires an outside request to open a new
connection.
Departures
- User requests an active OPEN. Create a packet with SYN
set. Choose your MDL and place it into the LENGTH octet.
Choose your initial SN. AN is immaterial. Send this
packet and go to the SYN-SENT state. The TCB for this
connection is created. The connection may be thought of
as half-open. A STATUS request will return to the caller
this information.
- User requests a passive OPEN. The TCB for this connection
is created. The connection may be thought of as
half-open. A STATUS request will return to the caller
this information. Go to the LISTEN state.
Finn [Page 25]
^L
RFC 916 October 1984
Reliable Asynchronous Transfer Protocol
5.3. State Behavior
This section discusses in detail the behavior of each state in
response to the arrival of a packet. In what follows a packet is
not considered to have arrived until it has passed a number of
tests (see the chapter entitled: Packet Reception).
The method chosen to describe state behavior is tabular. Each
state is listed opposite a sequence of named procedures to execute
whenever a packet has arrived.
STATE BEHAVIOR
=============+========================
LISTEN | A
-------------+------------------------
SYN-SENT | B
-------------+------------------------
SYN-RECEIVED | C1 D1 E F1 H1
-------------+------------------------
ESTABLISHED | C2 D2 E F2 H2 I1
-------------+------------------------
FIN-WAIT | C2 D2 E F3 H3
-------------+------------------------
LAST-ACK | C2 D3 E F3 H4
-------------+------------------------
CLOSING | C2 D3 E F3 H5
-------------+------------------------
TIME-WAIT | D3 E F3 H6
-------------+------------------------
CLOSED | G
-------------+------------------------
For example, in the ESTABLISHED state the arrival of a packet
causes procedure C2 to be executed, then D2, then E, F2, H2, and
finally I1. Any procedure may terminate the processing which
occurs or cause a state change. Note that these procedures are
executed in sequence, first C2, then D2, etc. The time ordering
cannot be mixed.
The particular actions associated with each procedure are now
described.
Finn [Page 26]
^L
RFC 916 October 1984
Reliable Asynchronous Transfer Protocol
A --------------------------------------------------------
This procedure details the behavior of the LISTEN state. First
check the packet for the RST flag. If it is set then packet is
discarded and ignored, return and continue the processing
associated with this state.
We assume now that the RST flag was not set. Check the packet
for the ACK flag. If it is set we have an illegal condition
since no connection has yet been opened. Send a RST packet
with the correct response SN value:
<SN=received AN><CTL=RST>
Return to the current state without any further processing.
We assume now that neither the RST nor the ACK flags were set.
Check the packet for a SYN flag. If it is set then an attempt
is being made to open a connection. Create a TCB for this
connection. The sender has placed its MDL in the LENGTH field,
also specified is the sender's initial SN value. Retrieve and
place them into the TCB. Note that the presence of the SO flag
is ignored since it has no meaning when either of the SYN, RST,
or FIN flags are set.
Send a SYN packet which acknowledges the SYN received. Choose
the initial SN value and the MDL for this end of the
connection:
<SN=0><AN=received SN+1 modulo 2><CTL=SYN, ACK><LENGTH=MDL>
and go to the SYN-RECEIVED state without any further
processing.
Any packet not satisfying the above tests is discarded and
ignored. Return to the current state without any further
processing.
Finn [Page 27]
^L
RFC 916 October 1984
Reliable Asynchronous Transfer Protocol
B --------------------------------------------------------
This procedure represents the behavior of the SYN-SENT state
and is entered when this end of the connection decides to
execute an active OPEN.
First, check the packet for the ACK flag. If the ACK flag is
set then check to see if the AN value was as expected. If it
was continue below. Otherwise the AN value was unexpected. If
the RST flag was set then discard the packet and return to the
current state without any further processing, else send a
reset:
<SN=received AN><CTL=RST>
Discard the packet and return to the current state without any
further processing.
At this point either the ACK flag was set and the AN value was
as expected or ACK was not set. Second, check the RST flag.
If the RST flag is set there are two cases:
1. If the ACK flag is set then discard the packet, flush the
retransmission queue, inform the user "Error: Connection
refused", delete the TCB, and go to the CLOSED state without
any further processing.
2. If the ACK flag was not set then discard the packet and
return to this state without any further processing.
At this point we assume the packet contained an ACK which was
Ok, or there was no ACK, and there was no RST. Now check the
packet for the SYN flag. If the ACK flag was set then our SYN
has been acknowledged. Store MDL received in the TCB. At this
point we are technically in the ESTABLISHED state. Send an
acknowledgment packet and any initial data which is queued to
send:
<SN=received AN><AN=received SN+1 modulo 2><CTL=ACK><DATA>
Go to the ESTABLISHED state without any further processing.
If the SYN flag was set but the ACK was not set then the other
end of the connection has executed an active open also.
Acknowledge the SYN, choose your MDL, and send:
<SN=0><AN=received SN+1 modulo 2><CTL=SYN, ACK><LENGTH=MDL>
Finn [Page 28]
^L
RFC 916 October 1984
Reliable Asynchronous Transfer Protocol
Go to the SYN-RECEIVED state without any further processing.
Any packet not satisfying the above tests is discarded and
ignored. Return to the current state without any further
processing.
C1 --------------------------------------------------------
Examine the received SN field value. If the SN value was
expected then return and continue the processing associated
with this state.
We now assume the SN value was not what was expected.
If either RST or FIN were set discard the packet and return to
the current state without any further processing.
If neither RST nor FIN flags were set it is assumed that this
packet is a duplicate of one already received. Send an ACK
back:
<SN=received AN><AN=received SN+1 modulo 2><CTL=ACK>
Discard the duplicate packet and return to the current state
without any further processing.
C2 --------------------------------------------------------
Examine the received SN field value. If the SN value was
expected then return and continue the processing associated
with this state.
We now assume the SN value was not what was expected.
If either RST or FIN were set discard the packet and return to
the current state without any further processing.
If SYN was set we assume that the other end crashed and has
attempted to open a new connection. We respond by sending a
legal reset:
<SN=received AN><AN=received SN+1 modulo 2><CTL=RST, ACK>
This will cause the other end, currently in the SYN-SENT state,
to close. Flush the retransmission queue, inform the user
"Error: Connection reset", discard the packet, delete the TCB,
and go to the CLOSED state without any further processing.
Finn [Page 29]
^L
RFC 916 October 1984
Reliable Asynchronous Transfer Protocol
If neither RST, FIN, nor SYN flags were set it is assumed that
this packet is a duplicate of one already received. Send an
ACK back:
<SN=received AN><AN=received SN+1 modulo 2><CTL=ACK>
Discard the duplicate packet and return to the current state
without any further processing.
D1 --------------------------------------------------------
The packet is examined for a RST flag. If RST is not set then
return and continue the processing associated with this state.
RST is now assumed to have been set. If the connection was
originally initiated from the LISTEN state (it was passively
opened) then flush the retransmission queue, discard the
packet, and go to the LISTEN state without any further
processing.
If instead the connection was initiated actively (came from the
SYN-SENT state) then flush the retransmission queue, inform the
user "Error: Connection refused", discard the packet, delete
the TCB, and go to the CLOSED state without any further
processing.
D2 --------------------------------------------------------
The packet is examined for a RST flag. If RST is not set then
return and continue the processing associated with this state.
RST is now assumed to have been set. Any data remaining to be
sent is flushed. The retransmission queue is flushed, the user
is informed "Error: Connection reset.", discard the packet,
delete the TCB, and go to the CLOSED state without any further
processing.
D3 --------------------------------------------------------
The packet is examined for a RST flag. If RST is not set then
return and continue the processing associated with this state.
RST is now assumed to have been set. Discard the packet,
delete the TCB, and go to the CLOSED state without any further
processing.
Finn [Page 30]
^L
RFC 916 October 1984
Reliable Asynchronous Transfer Protocol
E --------------------------------------------------------
Check the presence of the SYN flag. If the SYN flag is not set
then return and continue the processing associated with this
state.
We now assume that the SYN flag was set. The presence of a SYN
here is an error. Flush the retransmission queue, send a legal
RST packet.
If the ACK flag was set then send:
<SN=received AN><CTL=RST>
If the ACK flag was not set then send:
<SN=0><CTL=RST>
The user should receive the message "Error: Connection reset.",
then delete the TCB and go to the CLOSED state without any
further processing.
F1 --------------------------------------------------------
Check the presence of the ACK flag. If ACK is not set then
discard the packet and return without any further processing.
We now assume that the ACK flag was set. If the AN field value
was as expected then return and continue the processing
associated with this state.
We now assume that the ACK flag was set and that the AN field
value was unexpected. If the connection was originally
initiated from the LISTEN state (it was passively opened) then
flush the retransmission queue, discard the packet, and send a
legal RST packet:
<SN=received AN><CTL=RST>
Then delete the TCB and go to the LISTEN state without any
further processing.
Otherwise the connection was initiated actively (came from the
SYN-SENT state) then inform the user "Error: Connection
refused", flush the retransmission queue, discard the packet,
and send a legal RST packet:
Finn [Page 31]
^L
RFC 916 October 1984
Reliable Asynchronous Transfer Protocol
<SN=received AN><CTL=RST>
Then delete the TCB and go to the CLOSED state without any
further processing.
F2 --------------------------------------------------------
Check the presence of the ACK flag. If ACK is not set then
discard the packet and return without any further processing.
We now assume that the ACK flag was set. If the AN field value
was as expected then flush the retransmission queue and inform
the user with an "Ok" if a buffer has been entirely
acknowledged. Another packet containing data may now be sent.
Return and continue the processing associated with this state.
We now assume that the ACK flag was set and that the AN field
value was unexpected. This is assumed to indicate a duplicate
acknowledgment. It is ignored, return and continue the
processing associated with this state.
F3 --------------------------------------------------------
Check the presence of the ACK flag. If ACK is not set then
discard the packet and return without any further processing.
We now assume that the ACK flag was set. If the AN field value
was as expected then continue the processing associated with
this state.
We now assume that the ACK flag was set and that the AN field
value was unexpected. This is ignored, return and continue
with the processing associated with this state.
G --------------------------------------------------------
This procedure represents the behavior of the CLOSED state of a
connection. All incoming packets are discarded. If the packet
had the RST flag set take no action. Otherwise it is necessary
to build a RST packet. Since this end is closed the other end
of the connection has incorrect data about the state of the
connection and should be so informed.
If the ACK flag was set then send:
<SN=received AN><CTL=RST>
Finn [Page 32]
^L
RFC 916 October 1984
Reliable Asynchronous Transfer Protocol
If the ACK flag was not set then send:
<SN=0><AN=received SN+1 modulo 2><CTL=RST, ACK>
After sending the reset packet return to the current state
without any further processing.
H1 --------------------------------------------------------
Our SYN has been acknowledged. At this point we are
technically in the ESTABLISHED state. Send any initial data
which is queued to send:
<SN=received AN><AN=received SN+1 modulo 2><CTL=ACK><DATA>
Go to the ESTABLISHED state and execute procedure I1 to process
any data which might be in this packet.
Any packet not satisfying the above tests is discarded and
ignored. Return to the current state without any further
processing.
H2 --------------------------------------------------------
Check the presence of the FIN flag. If FIN is not set then
continue the processing associated with this state.
We now assume that the FIN flag was set. This means the other
end has decided to close the connection. Flush the
retransmission queue. If any data remains to be sent then
inform the user "Warning: Data left unsent." The user must
also be informed "Connection closing." An acknowledgment for
the FIN must be sent which also indicates this end is closing:
<SN=received AN><AN=received SN + 1 modulo 2><CTL=FIN, ACK>
Go to the LAST-ACK state without any further processing.
Finn [Page 33]
^L
RFC 916 October 1984
Reliable Asynchronous Transfer Protocol
H3 --------------------------------------------------------
This state represents the final behavior of the FIN-WAIT state.
If the packet did not contain a FIN we assume this packet is a
duplicate and that the other end of the connection has not seen
the FIN packet we sent earlier. Rely upon retransmission of
our earlier FIN packet to inform the other end of our desire to
close. Discard the packet and return without any further
processing.
At this point we have a packet which should contain a FIN. By
the rules of this protocol an ACK of a FIN requires a FIN, ACK
in response and no data. If the packet contains data we have
detected an illegal condition. Send a reset:
<SN=received AN><AN=received SN+1 modulo 2><CTL=RST, ACK>
Discard the packet, flush the retransmission queue, inform the
user "Error: Connection reset.", delete the TCB, and go to the
CLOSED state without any further processing.
We now assume that the FIN flag was set and no data was
contained in the packet. If the AN field value was expected
then this packet acknowledges a previously sent FIN packet.
The other end of the connection is then also assumed to be
closing and expects an acknowledgment. Send an acknowledgment
of the FIN:
<SN=received AN><AN=received SN+1 modulo 2><CTL=ACK>
Start the 2*SRTT timer associated with the TIME-WAIT state,
discard the packet, and go to the TIME-WAIT state without any
further processing.
Otherwise the AN field value was unexpected. This indicates a
simultaneous closing by both sides of the connection. Send an
acknowledgment of the FIN:
<SN=received AN><AN=received SN+1 modulo 2><CTL=ACK>
Discard the packet, and go to the CLOSING state without any
further processing.
Finn [Page 34]
^L
RFC 916 October 1984
Reliable Asynchronous Transfer Protocol
H4 --------------------------------------------------------
This state represents the final behavior of the LAST-ACK state.
If the AN field value is expected then this ACK is in response
to the FIN, ACK packet recently sent. This is the final
acknowledging message indicating both side's agreement to close
the connection. Discard the packet, flush all queues, delete
the TCB, and go to the CLOSED state without any further
processing.
Otherwise the AN field value was unexpected. Discard the
packet and remain in the current state without any further
processing.
H5 --------------------------------------------------------
This state represents the final behavior of the CLOSING state.
If the AN field value was expected then this packet
acknowledges the FIN packet recently sent. This is the final
acknowledging message indicating both side's agreement to close
the connection. Start the 2*SRTT timer associated with the
TIME-WAIT state, discard the packet, and go to the TIME-WAIT
state without any further processing.
Otherwise the AN field value was unexpected. Discard the
packet and remain in the current state without any further
processing.
H6 --------------------------------------------------------
This state represents the behavior of the TIME-WAIT state.
Check the presence of the ACK flag. If ACK is not set then
discard the packet and return without any further processing.
Check the presence of the FIN flag. If FIN is not set then
discard the packet and return without any further processing.
We now assume that the FIN flag was set. This situation
indicates that the last acknowledgment of the FIN packet sent
by the other end of the connection did not arrive. Resend the
acknowledgment:
<SN=received AN><AN=received SN+1 modulo 2><CTL=ACK>
Finn [Page 35]
^L
RFC 916 October 1984
Reliable Asynchronous Transfer Protocol
Restart the 2*SRTT timer, discard the packet, and remain in the
current state without any further processing.
I1 --------------------------------------------------------
This represents that stage of processing in the ESTABLISHED
state in which all the flag bits have been processed and only
data may remain. The packet is examined to see if it contains
data. If not the packet is now discarded, return to the
current state without any further processing.
We assume the packet contained data, that either the SO flag
was set or LENGTH is positive. That data is placed into the
user's receive buffers. As these become full the user should
be informed "Receive buffer full." An acknowledgment is sent:
<SN=received AN><AN=received SN+1 modulo 2><CTL=ACK>
If data is queued to send then it is most efficient to
'piggyback' this acknowledgment on that data packet.
The packet is now discarded, return to the ESTABLISHED state
without any further processing.
5.4. Timers
There are three timers associated with this protocol. Their
purpose will now be briefly discussed as will the actions taken
when a timer expires. The particular nature these timeouts take
and the methods by which they are set is the responsibility of the
protocol implementation.
5.4.1. User Timeout
For practical implementation reasons it is desirable to have a
user controllable timeout associated with the successful
opening of a connection, successful acknowledgment of data, and
successful closing of a connection. Consider the situations in
which a connection is so noisy that no data gets through, or a
connection is physically cut. Without an overriding timeout
these situations would result in unbounded retransmissions.
When this timeout expires the user is informed "Error:
Connection aborted due to user timeout.", all queues are
flushed, the TCB is deleted, and the CLOSED state is entered.
Finn [Page 36]
^L
RFC 916 October 1984
Reliable Asynchronous Transfer Protocol
5.4.2. Retransmission Timeout
This timer ensures that any packet sent for which the SN is
significant is acknowledged. When such a packet is sent it is
placed in a retransmission queue and the retransmission timer
is begun. If an acknowledgment has not arrived within the
timer's period then the packet is retransmitted and the timer
is restarted. If the acknowledgment does arrive in time then
the timer is stopped and the packet is removed from the
retransmission queue. The next packet with a significant SN
may now be sent.
This timeout is expected to operate in conjunction with a
counter which keeps track of the number of times a packet has
been retransmitted. Normally an upper limit is set on
retransmissions. If that limit is exceeded then the connection
is aborted. This event is similar to the user timeout. The
user is informed "Error: Connection aborted due to
retransmission failure", all queues are flushed, the TCB is
deleted, and the CLOSED state is entered.
5.4.3. TIME-WAIT Timeout
This timeout is used to catch any FIN packets which might be
retransmitted from the other end of a connection in response to
a dropped acknowledgment packet. The timeout period should be
at least as long as 2*SRTT. After this timeout expires the
other end of the connection is assumed to be closed, the TCB is
deleted, and this end enters the CLOSED state also.
Finn [Page 37]
^L
RFC 916 October 1984
Reliable Asynchronous Transfer Protocol
6. Data Error Handling
This chapter discusses in detail the types of data errors an
established connection may encounter. These are distinct from
protocol errors discussed above. In order of discussion these are:
- Framing Errors
- Missing SYNCH pattern
- Unacknowledged packets
- Bad packets
- Duplicate packets
- Outside flow control
- Packets that are too large
- Packets that are too small
6.1. Framing Errors
The RS-232 specification provides framing only for an individual
octet. Link level protocols for computer networking normally
provide framing for each packet. The SYNCH pattern provides a
boundary for the beginning of a packet. No similar pattern was
chosen to mark the end and completely frame the packet.
Any bit pattern can appear in the data portion of a packet. For
any particular pattern to reliably mark the end of a packet that
terminating pattern cannot be allowed to appear in the data. This
is usually accomplished by the sender altering any occurrence of
the terminating pattern in the data so that it is both no longer
recognizable as that pattern and also restorable upon receipt.
Both the sender and the receiver are required by this technique to
examine all the data. In the absence of a protocol chip to
perform this function, it is a source of some overhead.
6.1.1. Synthetic Framing
In the absence of framing, the end of the packet must be
synthetically determined. The start of a packet is indicated
by the SYNCH pattern. The expected end of a packet can now
only be determined by examining the LENGTH octet of the header.
It is important to know whether or not the LENGTH data can be
Finn [Page 38]
^L
RFC 916 October 1984
Reliable Asynchronous Transfer Protocol
trusted. This is accomplished by employing a one octet header
checksum to cover the first two octets following the SYNCH
pattern. If the header passes the checksum test and neither
the SYN, FIN, RST, nor SO flag bits were set then LENGTH is
trusted and the number of octets expected beyond the header is
LENGTH+2. (For those packets in which any of the above flag
bits are set the packet length is fixed and includes only a
header portion.)
If the header fails the checksum test we are in some
difficulty. The length is incorrect so it may be too small or
too large. To recover from this error do the following.
Beginning immediately after the SYNCH pattern rescan looking
for the next SYNCH pattern. Throw away all octets until a
SYNCH is seen and then attempt to reinterpret it as a packet.
The sender's retransmission timeout guarantees that a new copy
of the packet will be transmitted. This ensures that in
discarding the initial SYNCH pattern, the SYNCH pattern from
the beginning of the retransmitted packet will eventually be
seen.
6.1.2. Costs of Synthetic Framing
This framing strategy causes no overhead unless data errors
occur in the packet. This is presumed to be a low probability
occurrence. In addition it removes the overhead of both sender
and receiver passing over the data to process any termination
pattern which might appear in the data.
The worst case behavior would require a packet header to fail
its checksum, a new SYNCH pattern to appear in the next few
octets, that header failing its checksum, etc., until the SYNCH
pattern of the retransmitted packet were finally seen.
Consistently bad behavior of this type indicates an extremely
noisy communications link.
6.2. Missing SYNCH Pattern
Any valid packet must begin with the SYNCH pattern. Any receiver
must discard all input octets until the SYNCH pattern is seen.
The data which immediately follows a SYNCH pattern is interpreted
as a packet. The header checksum test is applied, then LENGTH+2
octets are read, the data checksum test is applied, etc.
Finn [Page 39]
^L
RFC 916 October 1984
Reliable Asynchronous Transfer Protocol
6.3. Unacknowledged Packets
If an ACK for a packet is not obtained within the retransmission
timeout interval that packet is retransmitted. Because
significant variability in response can be expected from either
end of a connection it is best to dynamically calculate the
retransmission timeout interval. An example of such a calculation
is provided below. The protocol will operate successfully,
although not with as high an effective transmission rate, if a
realistic upper bound time is used instead.
A realistic upper bound time depends upon the packet size and line
speed. If the baud rate of the connection is 300 or above let B
be the baud rate (for clarity assume it is the same in both
directions), let L be the MDL of the receiver, let P be the packet
processing time of the receiver. Then an Upper Bound for the
Reception Time (UBRT) is:
UBRT = L/(B/10) seconds + P seconds
and a realistic upper bound time is 2*UBRT seconds.
6.3.1. Calculation of Retransmission Timeout Interval
For the purpose of detecting retransmission time out the
protocol must have access to a clock which provides at least
single second resolution. One technique for calculating the
round trip time is:
Measure the elapsed time between sending a packet with a
particular SN and receiving an ACK with an AN which covers
that SN. The measured elapsed time is the Round Trip Time
(RTT). Next a Smoothed Round Trip Time (SRTT) is calculated
as:
SRTT = (ALPHA * SRTT) + ((1- ALPHA) * RTT)
and based upon this you compute the Retransmission Time Out
(RTO) as:
RTO = min[UBOUND, max[LBOUND, (BETA * SRTT)]]
where UBOUND is an upper bound on the timeout (e.g., 1
minute), LBOUND is a lower bound on the timeout (e.g., 1
second), ALPHA is a smoothing factor (e.g., .8 to .9), and
BETA is a delay variance factor (e.g., 1.3 to 2.0).
Finn [Page 40]
^L
RFC 916 October 1984
Reliable Asynchronous Transfer Protocol
6.4. Bad Packets
A bad packet is received when it fails either the header or data
checksum tests. When this happens the sender will retransmit the
packet after the retransmission timeout interval.
6.5. Duplicate Packets
A duplicate packet is a packet which passes the checksum tests but
for which the SN received is significant but not the expected
value. This is normally caused when the sender did not get the
ACK last sent by the receiver. This situation is diagrammed
below.
Side A Side B
ESTABLISHED ESTABLISHED
1. --> <SN=1><AN=0><CTL=ACK><DATA> ...
-->
2. XXX <SN=0><AN=0><CTL=ACK><OTHER-DATA> <--
3. (after SRTT)
--> <SN=1><AN=0><CTL=ACK><DATA> ...
4. -->
... <SN=0><AN=0><CTL=ACK><OTHER-DATA> <--
5. <--
In line 2, B's packet was lost in transit, it may have failed its
checksum tests when it reached A or its initial SYNCH pattern was
smashed, etc.. In line 3 side A comes to the decision that its
packet from line 1 was not received after SRTT time passes and
retransmits that packet.
In line 4 side B receives the packet. It detects a duplicate
because it already sent a packet acknowledging A's SN=1 (although
that packet was lost). B now discards the duplicate and
immediately retransmits its last packet to A. Side A finally
receives the retransmitted packet in line 5.
Finn [Page 41]
^L
RFC 916 October 1984
Reliable Asynchronous Transfer Protocol
6.6. Outside Flow Control
There are many large computer systems which make use of flow
control to regulate their input side of an RS-232 link. Flow
control based upon two special characters such as <Ctrl-S> (ASCII
DC3) and <Ctrl-Q> (ASCII DC1) is almost universally in use today.
So it becomes important for the protocol to be able to either:
(1) Recognize and obey the flow control of the host
computer(s), or
(2) Ignore the flow control but still guarantee reliable data
reception.
It is the latter approach which this protocol takes. This
decision was made because the number of differing flow control
characters in use would make it difficult to obey them all.
There is a particular type of flow control with which this
protocol will not operate. The ENQUIRE, ACKNOWLEDGE method of
flow control requires that the receiver of an inquiry respond
with an acknowledge before any more data will be sent to it.
This type of flow control also usually prohibits unrestricted
8-bit data transmission because the inquiry character is
forbidden as a data byte.
For the other class of flow control methods a proof is required
that data may still be reliably transmitted and received if flow
control is ignored. For the purposes of this discussion assume
<Ctrl-S> is sent when the receiving end of the connection wishes
the sender to stop transmitting. A <Ctrl-Q> is sent when the
receiver wishes the sender to resume. The choice of these
particular two characters is arbitrary. If the sender does not
immediately cease transmission upon receipt of the <Ctrl-S>,
characters may be discarded. Since this protocol chooses to
ignore the flow control characters any part of a packet may be
discarded.
More precisely stated consider X to be the receiver and Y to be
the sender. The packet sent is represented by the string abc
where a, b, and c are data segments of unspecified size. X may
receive one of:
1. abc
2. ab
3. ac
4. bc
Finn [Page 42]
^L
RFC 916 October 1984
Reliable Asynchronous Transfer Protocol
For case [1] the correct data is received and no special action
need be taken.
For cases [2], [3], and [4] we have a situation identical to data
dropped during transmission. This is handled by the same
checksum, time-out and retransmission strategy already described.
Assume Y is not now in the act of receiving a packet, then Y sees
the two characters <Ctrl-S> and <Ctrl-Q> appear as input in that
order. Y is waiting for a message to appear and so expects to see
a SYNCH pattern. If the two characters "<Ctrl-S><Ctrl-Q>" are not
part of a SYNCH pattern then they will be immediately discarded.
If Y is receiving a packet then the <Ctrl-S> and <Ctrl-Q> are seen
to be added noise characters and would be detected by the checksum
tests. The packet being received would require retransmission.
The question of which character to pick for the SYNCH pattern is
slightly muddied by the above observation. To the author's
knowledge <SOH> is rarely if ever picked for flow control. This
is part of the motivation in using it as the SYNCH pattern.
How does one guarantee that any data will actually arrive
successfully? The initial choice of maximum data counts during
connection establishment is very important. Some knowledge of
one's own operating system must be assumed. If it is known for
example, that streams of data in excess of a certain length will
often trigger flow control at the connection baud rate, then the
maximum data count should be chosen sufficiently lower that flow
control rarely will be employed. An intelligent choice of the
maximum data count will guarantee that some packets will arrive
without encountering flow control.
6.7. Packets that are too Large
Assume a packet arrives which passes its header checksum test but
whose LENGTH is larger than the MDL of the receiver. In such a
case the sender has violated the protocol or a packet has a data
error in the LENGTH octet and has passed the header checksum test.
The latter is unlikely so that we assume the former. The receiver
will abort his connection. The sender must inform the user
"Error: Connection aborted due to MDL error", and go to the CLOSED
state.
When the MDL is exceeded the receiver will transmit a legal reset:
<SN=received AN><CTL=RST>
Finn [Page 43]
^L
RFC 916 October 1984
Reliable Asynchronous Transfer Protocol
6.8. Packets that are too Small
Assume that a packet has passed its header checksum test but some
of the data octets have been dropped by the link. In such a case
the receiver's routine which reads data and builds packets is
expecting octets which do not arrive. After SRTT the sender will
retransmit this packet to the receiver. The receiver will now
have enough data to complete the packet. Almost certainly however
it will fail the data checksum test. As with any bad packet the
receiver will rescan from the octet immediately following the
SYNCH pattern for the next SYNCH pattern. In this manner the
receiver will eventually see the SYNCH pattern of the
retransmitted packet.
Finn [Page 44]
^L
RFC 916 October 1984
Reliable Asynchronous Transfer Protocol
I. Inability to Transmit/Receive 8-bit Data
There are some older operating systems and devices which do not
permit 8-bit communication over an RS-232 link. Most of these allow
restricted 7-bit communication. Where this is an unavoidable problem
both ends of the connection must have a protocol layer beneath this
protocol. This lower layer will unpack packets it sends over the
RS-232 link. It will also repack packets it receives over the RS-232
link. RATP will automatically determine whether or not full 8-bit or
restricted 7-bit communication is being used (see below).
The strategy chosen for restricted 7-bit communication is called 4/8
packing. That is, each octet to be sent will be broken up into two
4-bit nibbles. The order of transmission is the high order four bits
followed by the low order bits. Each octet to be received will be
repacked by the inverse function. The high order nibble will be
received first then the low order nibble. These two nibbles will be
reassembled into an octet.
I.1. Encoding for Transmission
For those systems which are incapable of 8-bit data transmission
over RS-232 links, there are operating systems which in addition
place special restrictions on the non-printable ASCII characters.
The encoding for 4/8 packing should restrict itself to
transmitting data only in the printable 7-bit ASCII range.
I.2. Framing an Octet
The seventh and highest order bit of a transmitted 7-bit ASCII
byte is a flag used to indicate whether the high or low order
nibble of an octet is contained in this character. This flag bit
if set implies that a new octet is being received and that this
printable ASCII character contains the high order nibble of an
octet in its four low order bits. In addition it implies the next
ASCII character received should not have its highest order bit
set.
This high order flag bit is set by adding the ASCII character "@"
(octal 100) to a data byte. Thus the first nibble of an octet is
always transmitted with "@" added to its value. The high order
nibble will be transformed into the characters "@" through letter
"O".
The lower order nibble of an octet is transmitted with zero "0"
added to its value. The low order nibble will be transformed into
Finn [Page 45]
^L
RFC 916 October 1984
Reliable Asynchronous Transfer Protocol
characters "0" through "?". When receiving 4/8 packed data, any
characters not within the range "0" through letter "O" are
discarded.
The octet whose octal value is 45 will be transmitted as two 7-bit
printable ASCII characters:
+-------------+
High order |1|0|0|0|1|0|0| First transmitted ("@" + data) = D
+-------------+
Low order |0|1|1|0|1|0|1| Second transmitted ("0" + data) = 5
+-------------+
Since data bytes may be dropped or added at any time it is
important to know always which portion of an octet is expected and
to deliver only complete octets to the higher protocol level. If
a single 7-bit character were completely dropped without being
noticed the data stream delivered to the higher level could be
shifted by an odd multiple of four bits. In the worst case this
condition could remain indefinitely and the higher level would
never receive an octet correctly. In such a case no packets would
be correctly received, leading to an unusable connection.
To avoid this problem octets are assembled using a state machine
driven by the presence of the high order flag bit. The presence
of that bit in the 7-bit printable character indicates the
beginning of a new octet. The two state machine which assembles
octets is described below. A byte received with the high order
flag bit set is called "HIGH", the byte without "LOW".
State 0
[Start state] Read a byte from the legal restricted set.
This is determined by seeing if the byte is in the legal
range "@" to the letter "O". If it was not discard the byte
and return to this state.
A HIGH byte was read. Place the four low order bits of the
byte into the four high order bits of the assembled octet
and go to state 1. Otherwise discard the byte and return to
this state.
Finn [Page 46]
^L
RFC 916 October 1984
Reliable Asynchronous Transfer Protocol
State 1
Read a byte from the legal restricted set. This is
determined by seeing if the byte is in the legal range zero
"0" to the letter "O". If it was not discard the byte and
return to this state.
If a LOW byte was read subtract zero "0" from the byte
placing the four low order bits of the result into the four
low order bits of the assembled octet. A full octet has now
been assembled. Pass the octet to the higher level and go
to state 0.
Otherwise a HIGH byte was read. Place the four low order
bits of the byte into the four high order bits of the
assembled octet and return to this state.
Utilizing this state machine to receive 4/8 packed data ensures
that the data stream delivered to the higher level will not
permanently remain shifted an odd multiple of four bits. The
restriction placed upon bytes read removes obviously bad data and
in some cases would handle uncontrolled padding or blocking
insertion.
I.3. Automatic Detection of 8-bit or 4/8 Packed Data
It is an unavoidable problem that some machines cannot handle
unrestricted 8-bit data. Since this is given, it is desirable to
be able to automatically detect whether unrestricted 8-bit or
restricted 4/8 packing is being used to transmit data on a
connection. For the purposes of this discussion those machines
capable of transmitting and receiving both unrestricted 8-bit and
4/8 packed data are called smart. Machines are called dumb if
they can only transmit and receive 4/8 packed data.
When initiating a connection there are four possible machine
configurations and they are:
1. A (smart) opens a connection to B (smart).
2. A (dumb) opens a connection to B (smart).
3. A (dumb) opens a connection to B (dumb).
4. A (smart) opens a connection to B (dumb).
Finn [Page 47]
^L
RFC 916 October 1984
Reliable Asynchronous Transfer Protocol
Each case is examined and extensions to the behavior for the
LISTEN and SYN-SENT states are provided which allow both types of
machines to initiate or receive a connection.
Cases 1 and 2: LISTEN Behavior for a Smart Machine
In these cases machine A initiates a connection to B who is
assumed to be in the LISTEN state. B must be able to passively
detect whether 8-bit or 4/8 packing is being used and respond
accordingly. The method B uses relies upon the detection of a
valid first packet. In the LISTEN state B attempts to
simultaneously treat the incoming data as if it were both
unrestricted 8-bit and 4/8 packed.
The incoming data is in effect fed to two different receiving
algorithms. The detection of a valid header will occur to one
of these algorithms before the other. If the first valid
header was read assuming unrestricted 8-bit data then any
resulting connection is assumed to use unrestricted 8-bit data
for the life of the connection. If the first valid header
assumed 4/8 packing then the resulting connection is assumed to
use 4/8 packing for the life of the connection. In the case of
the detection of illegal condition in the LISTEN state the
protocol will reply with a RST packet in kind.
Case 3: LISTEN Behavior for a Dumb Machine
In this case machine B is the recipient of a connection request
and is capable of handling only 4/8 packed data. The LISTEN
behavior for machine B assumes that all connections are 4/8
packed. It never deals with unrestricted 8-bit data. As a
result it will refuse to open a connection request from a smart
machine (see case 4 below).
Case 4: SYN-SENT Behavior for a Smart Machine
In this case machine A attempts to open a connection to machine
B. However, A has no knowledge of B's capabilities. A will
send its connection request assuming B is smart using
unrestricted 8-bit transmission. It will await a reply
assuming the response will be unrestricted 8-bit also. If B is
in fact dumb it will not return a SYN-ACK because of the
restriction imposed by case 3 above. If no connection is made
with B using 8-bit data the entire connection initiation is
restarted assuming B is dumb, 4/8 packing is used and the
response is assumed to be 4/8 packed as well.
Finn [Page 48]
^L
RFC 916 October 1984
Reliable Asynchronous Transfer Protocol
The cost of this approach is a longer time to determine whether
or not it is possible to open a connection to B. It is twice as
long. The advantages of being able to automatically adjust to
either unrestricted 8-bit or 4/8 packed data out weigh this
disadvantage. RATP will not exhibit the schizophrenic behavior
of many other asynchronous protocols when dealing with both
classes of machines.
Finn [Page 49]
^L
RFC 916 October 1984
Reliable Asynchronous Transfer Protocol
II. A Brief Survey of Some Asynchronous Link Protocols
II.1. DDCMP
DDCMP, Copyright (c) 1978 Digital Equipment Corporation [DDCMP
78], is a reliable point-to-point and multi-point transmission
protocol is used by many of that manufacturer's computers. DDCMP
does provide reliable asynchronous two way data transmission.
Some of the decisions taken in the design of DDCMP reflect its
orientation toward multi-point data links. This leads to headers
which are substantially longer than needed for two way
point-to-point communications.
DDCMP allows as many as 255 outstanding unacknowledged messages.
DDCMP does specifically mention that a particular end of a
connection may choose to limit the send queue to one outstanding
unacknowledged message. It also allows sending a stream of
outstanding unacknowledged packets. Unless all RS-232
implementations of DDCMP were limited to a single outstanding
packet, the collision with existing flow control restrictions
could lead to very low thruput. (DDCMP is assumed to have control
over the link driver. Dealing with various differing flow control
mechanisms is not a consideration.)
DDCMP uses a CRC polynomial for data protection which is difficult
to calculate for many machines without special hardware [TCP
Checksum 78]. Many Digital Equipment computers have such
hardware.
DDCMP does not provide the receiver with the ability to restrict
incoming packet size. It is true that all the higher level
protocols built on top of DDCMP could separately negotiate packet
size. But this burden would then be moved away from the link
level where it properly resides.
Generally, a full implementation of DDCMP is too complex for
consideration. If one were to implement 'part' of the protocol
then issues of compatibility with already existing implementations
on other computers are raised.
Finn [Page 50]
^L
RFC 916 October 1984
Reliable Asynchronous Transfer Protocol
II.2. MODEM Protocol
This is a protocol in common use amongst microcomputers. The
description here comes from
MODEM/XMODEM Protocol Explained by Kelly Smith, CP/M-Net
"SYSOP" January 8,1980
.... Data is sent in 128-byte sequentially numbered blocks,
with a single checksum byte appended to the end of each block.
As the receiving computer acquires the incoming data, it
performs its own checksum and upon each completion of a block,
it compares its checksum result with that of the sending
computers. If the receiving computer matches the checksum of
the sending computer, it transmits an ACK (ASCII code protocol
character for ACKNOWLEDGE (06 Hex, Control-F)) back to the
sending computer. The ACK therefore means "all's well on this
end, send some more...".
The sending computer will transmit an "initial NAK" (ASCII
protocol character for NEGATIVE ACKNOWLEDGE (15 Hex,
Control-U))...or, "that wasn't quite right, please send again".
Due to the asynchronous nature of the initial "hook-up" between
the two computers, the receiving computer will "time-out"
looking for data, and send the NAK as the "cue" for the sending
computer to begin transmission. The sending computer knows
that the receiving computer will "time-out", and uses this fact
to "get in sync"... The sending computer responds to the
"initial NAK" with a SOH (ASCII code protocol character for
START OF HEADING (01 Hex, Control-A)), sends the first block
number, sends the 1's complement of the block number, sends 128
bytes of 8 bit data, and finally a checksum, where the checksum
is calculated by summing the SOH, the block number, the block
number 1's complement, and the 128 bytes of data.
Receiving Computer:
---/NAK/------------------------/ACK/------------------
15H 06H
Sending Computer:
---/SOH/BLK#/BLK#/DATA/CSUM/---/SOH/BLK#/BLK#/DATA/etc.
01H 01H FEH 8bit 8bit 01H 02H FDH 8bit ....
Finn [Page 51]
^L
RFC 916 October 1984
Reliable Asynchronous Transfer Protocol
This process continues, with the next 128 bytes. If the block
was ACK'ed by the receiving computer, and then the next
sequential block number and its 1's complement, etc. ....
As can be seen from this partial description the MODEM protocol is
unidirectional, data can only pass from the sender to the receiver
in a stream. In order for data to flow simultaneously in the
other direction another connection over another RS-232 line would
be required.
In addition this protocol is restricted to a fixed 128 octet
packet size. Many front-end concentrators are unable to service
such large incoming packets. It has been observed many times that
the concentrator of a busy DECsystem-20 can invoke flow control on
input at 1200 baud for packets as small as 64 characters.
II.3. KERMIT System
The KERMIT system, Copyright (c) 1981 Columbia University, is a
file transfer environment developed recently. It has
implementations which run on DECsystem-20, IBM 370 VM/CMS, 8080
CP/M based systems, and the IBM PC among others.
KERMIT combines both the reliable transfer and file transfer into
a single package. Extension to other applications and higher
level protocols would be possible but the boundary between the
reliable transfer and application layers is very indistinct. It
violates the layering design strategy the Internet employs.
There is a limitation of transmission to the restricted printable
ASCII set for certain computers but not for others. This leads to
confusion. KERMIT allows both restricted ASCII and 8-bit
transmission.
The KERMIT protocol does have a method of setting MDL at
connection initiation. It is limited to a smaller maximum packet
size, 96 as opposed to 261 octets. Kermit originally used a
checksumming algorithm limited to six bits. This is considered to
provide too low a level of error detection capability for data
packets. Kermit now allows two other checksumming algorithms in
addition to the original. There must be a negotiation between
sender and receiver regarding which algorithm to use.
The KERMIT protocol does not appear to make provision for both
sides of a connection attempting an active open simultaneously.
One side must be an initial "sending Kermit" and the other a
"receiving Kermit". The code published as a KERMIT implementation
Finn [Page 52]
^L
RFC 916 October 1984
Reliable Asynchronous Transfer Protocol
guide cannot recover from simultaneous active opens, it
immediately ABORTs. This reflects a bias towards unidirectional
data flow.
The KERMIT packet type (similar to RATP control flags) specifies
whether an ACK/NAK is contained in the packet, or data, etc.
These are mutually exclusive and piggybacking an ACK on a data
packet is not possible. This can be a source of overhead. In
addition KERMIT restricts the sender to a single outstanding
unacknowledged packet as does RATP. It allocates an entire byte
to the sequence number which is unnecessary.
On the subject of error recovery, the size of a packet is
contained in the second byte of the packet and is not protected by
a header checksum. If the length field was in error due to noise
on the link, it could be longer than the correct packet size. The
code published as the KERMIT implementation guide relies upon the
detection of the <SOH> character anywhere in a packet to indicate
the beginning of a packet header. It re-SYNCHs using this
technique. This is only possible if binary data in a packet is
quoted. If full eight bit data is transmitted it does not appear
that the KERMIT protocol rescans for a new MARK (SYNCH) character
within the bad packet data just consumed. It will under these
circumstances throw away the retransmitted packet or portions
thereof. Re-SYNCHing under such conditions is problematical.
Finn [Page 53]
^L
RFC 916 October 1984
Reliable Asynchronous Transfer Protocol
REFERENCES
[Cohen 81]
Cohen, D. On Holy Wars and a Plea for Peace. IEEE Computer,
October, 1981.
[DDCMP 78]
DDCMP AA-D599A-TC edition, Digital Equipment Corporation, 1978.
Version 4.0.
[IP 81]
Postel, J. DOD Standard Internet Protocol [RFC-791] Defense
Advanced Research Projects Agency, 1981.
[TCP 81]
Postel, J. Transmission Control Protocol [RFC-793] Defense
Advanced Research Projects Agency, 1981.
[TCP Checksum 78]
Plummer, W. W. TCP Checksum Function Design. Technical Report,
Bolt Beranek and Newman, Inc., 1978.
EDITORS NOTES
This memo was prepared in essentially this form in June 1983, and set
aside. Distribution at this time is prompted by the the "Thinwire"
proposal described in RFC-914.
--jon postel
Finn [Page 54]
^L
|