| Preface |
|
xix | |
|
|
|
1 | (30) |
|
|
|
1 | (1) |
|
|
|
1 | (2) |
|
|
|
3 | (2) |
|
Application Programming Interfaces |
|
|
5 | (1) |
|
|
|
5 | (2) |
|
System Calls and Library Functions |
|
|
7 | (2) |
|
Network Implementation Overview |
|
|
9 | (1) |
|
|
|
10 | (5) |
|
Mbufs (Memory Buffers) and Output Processing |
|
|
15 | (4) |
|
|
|
19 | (3) |
|
Network Implementation Overview Revisited |
|
|
22 | (1) |
|
Interrupt Levels and Concurrency |
|
|
23 | (3) |
|
|
|
26 | (2) |
|
|
|
28 | (1) |
|
|
|
29 | (2) |
|
|
|
31 | (32) |
|
|
|
31 | (5) |
|
|
|
36 | (1) |
|
|
|
37 | (1) |
|
|
|
38 | (2) |
|
Simple Mbuf Macros and Functions |
|
|
40 | (4) |
|
m_devget and m_pullup Functions |
|
|
44 | (7) |
|
Summary of Mbuf Macros and Functions |
|
|
51 | (3) |
|
Summary of Net/3 Networking Data Structures |
|
|
54 | (2) |
|
m_copy and Cluster Reference Counts |
|
|
56 | (4) |
|
|
|
60 | (1) |
|
|
|
60 | (3) |
|
|
|
63 | (32) |
|
|
|
63 | (1) |
|
|
|
64 | (1) |
|
|
|
65 | (8) |
|
|
|
73 | (1) |
|
|
|
74 | (2) |
|
ifnet and ifaddr Specialization |
|
|
76 | (1) |
|
Network Initalization Overview |
|
|
77 | (3) |
|
|
|
80 | (2) |
|
|
|
82 | (3) |
|
|
|
85 | (1) |
|
|
|
85 | (8) |
|
|
|
93 | (1) |
|
|
|
94 | (1) |
|
|
|
95 | (32) |
|
|
|
95 | (1) |
|
|
|
96 | (2) |
|
|
|
98 | (16) |
|
|
|
114 | (11) |
|
|
|
125 | (2) |
|
Interfaces: SLIP and Loopback |
|
|
127 | (28) |
|
|
|
127 | (1) |
|
|
|
127 | (1) |
|
|
|
128 | (22) |
|
|
|
150 | (3) |
|
|
|
153 | (2) |
|
|
|
155 | (30) |
|
|
|
155 | (3) |
|
|
|
158 | (1) |
|
Interface and Address Summary |
|
|
158 | (2) |
|
|
|
160 | (1) |
|
|
|
161 | (1) |
|
|
|
161 | (16) |
|
Interface ioctl Processing |
|
|
177 | (4) |
|
Internet Utility Functions |
|
|
181 | (1) |
|
|
|
182 | (1) |
|
|
|
183 | (2) |
|
|
|
185 | (20) |
|
|
|
185 | (1) |
|
|
|
186 | (1) |
|
|
|
187 | (1) |
|
|
|
188 | (3) |
|
IP domain and protosw Structures |
|
|
191 | (5) |
|
pffindproto and pffindtype Functions |
|
|
196 | (2) |
|
|
|
198 | (1) |
|
|
|
199 | (2) |
|
|
|
201 | (3) |
|
|
|
204 | (1) |
|
|
|
205 | (42) |
|
|
|
205 | (1) |
|
|
|
206 | (4) |
|
|
|
210 | (2) |
|
Input Processing: ipintr Function |
|
|
212 | (8) |
|
Forwarding: ip_forward Function |
|
|
220 | (8) |
|
Output Processing: ip_output Function |
|
|
228 | (6) |
|
Internet Checksum: in_cksum Function |
|
|
234 | (5) |
|
setsockopt and getsockopt System Calls |
|
|
239 | (5) |
|
|
|
244 | (1) |
|
|
|
245 | (2) |
|
|
|
247 | (28) |
|
|
|
247 | (1) |
|
|
|
247 | (1) |
|
|
|
248 | (1) |
|
|
|
249 | (3) |
|
|
|
252 | (2) |
|
Source and Record Route Options |
|
|
254 | (7) |
|
|
|
261 | (4) |
|
ip_insertoptions Function |
|
|
265 | (4) |
|
|
|
269 | (3) |
|
|
|
272 | (1) |
|
|
|
272 | (3) |
|
IP Fragmentation and Reassembly |
|
|
275 | (26) |
|
|
|
275 | (2) |
|
|
|
277 | (1) |
|
|
|
278 | (4) |
|
|
|
282 | (1) |
|
|
|
283 | (3) |
|
|
|
286 | (12) |
|
|
|
298 | (2) |
|
|
|
300 | (1) |
|
ICMP: Internet Control Message Protocol |
|
|
301 | (36) |
|
|
|
301 | (4) |
|
|
|
305 | (3) |
|
|
|
308 | (1) |
|
|
|
309 | (1) |
|
Input Processing: icmp_input Function |
|
|
310 | (3) |
|
|
|
313 | (3) |
|
|
|
316 | (5) |
|
|
|
321 | (2) |
|
|
|
323 | (1) |
|
|
|
324 | (1) |
|
|
|
324 | (4) |
|
|
|
328 | (5) |
|
|
|
333 | (1) |
|
|
|
334 | (1) |
|
|
|
335 | (2) |
|
|
|
337 | (44) |
|
|
|
337 | (3) |
|
|
|
340 | (1) |
|
Ethernet Multicast Addresses |
|
|
341 | (1) |
|
|
|
342 | (2) |
|
Ethernet Multicast Reception |
|
|
344 | (1) |
|
|
|
345 | (2) |
|
|
|
347 | (1) |
|
|
|
348 | (1) |
|
|
|
348 | (3) |
|
|
|
351 | (4) |
|
Joining and IP Multicast Group |
|
|
355 | (11) |
|
Leaving an IP Multicast Group |
|
|
366 | (5) |
|
|
|
371 | (2) |
|
Multicast Input Processing: ipintr Function |
|
|
373 | (2) |
|
Multicast Output Processing: ip_output Function |
|
|
375 | (4) |
|
Performance Considerations |
|
|
379 | (1) |
|
|
|
379 | (2) |
|
IGMP: Internet Group Management Protocol |
|
|
381 | (16) |
|
|
|
381 | (1) |
|
|
|
382 | (2) |
|
|
|
384 | (1) |
|
|
|
384 | (2) |
|
Joining a Group: igmp_joingroup Function |
|
|
386 | (1) |
|
|
|
387 | (4) |
|
Input Processing: igmp_input Function |
|
|
391 | (4) |
|
Leaving a Group: igmp_leavegroup Function |
|
|
395 | (1) |
|
|
|
396 | (1) |
|
|
|
397 | (38) |
|
|
|
397 | (1) |
|
|
|
398 | (1) |
|
Multicast Output Processing Revisited |
|
|
399 | (2) |
|
|
|
401 | (3) |
|
|
|
404 | (7) |
|
|
|
411 | (5) |
|
|
|
416 | (8) |
|
Multicast Forwarding: ip_mforward Function |
|
|
424 | (9) |
|
Cleanup: ip_mrouter_done Function |
|
|
433 | (1) |
|
|
|
434 | (1) |
|
|
|
435 | (40) |
|
|
|
435 | (1) |
|
|
|
436 | (1) |
|
|
|
437 | (4) |
|
|
|
441 | (4) |
|
Processes, Descriptions, and Sockets |
|
|
445 | (2) |
|
|
|
447 | (4) |
|
getsock and sockargs Functions |
|
|
451 | (2) |
|
|
|
453 | (2) |
|
|
|
455 | (1) |
|
tsleep and wakeup Functions |
|
|
456 | (1) |
|
|
|
457 | (4) |
|
sonewconn and soisconnected Functions |
|
|
461 | (3) |
|
|
|
464 | (4) |
|
|
|
468 | (3) |
|
|
|
471 | (3) |
|
|
|
474 | (1) |
|
|
|
475 | (62) |
|
|
|
475 | (1) |
|
|
|
475 | (1) |
|
|
|
476 | (4) |
|
write, writev, sendto, and sendmsg System Calls |
|
|
480 | (3) |
|
|
|
483 | (2) |
|
|
|
485 | (4) |
|
|
|
489 | (11) |
|
read, readv, recvfrom, and recvmsg System Calls |
|
|
500 | (1) |
|
|
|
501 | (2) |
|
|
|
503 | (2) |
|
|
|
505 | (5) |
|
|
|
510 | (14) |
|
|
|
524 | (10) |
|
|
|
534 | (3) |
|
|
|
537 | (22) |
|
|
|
537 | (1) |
|
|
|
538 | (1) |
|
|
|
539 | (6) |
|
|
|
545 | (3) |
|
fcntl and ioctl System Calls |
|
|
548 | (6) |
|
|
|
554 | (1) |
|
|
|
554 | (3) |
|
|
|
557 | (2) |
|
Radix Tree Routing Tables |
|
|
559 | (42) |
|
|
|
559 | (1) |
|
|
|
560 | (9) |
|
|
|
569 | (1) |
|
|
|
570 | (3) |
|
Radix Node Data Structures |
|
|
573 | (5) |
|
|
|
578 | (3) |
|
Intialization: route_init and rtable_init Functions |
|
|
581 | (3) |
|
Initialization: rn_init and rn_inithead Functions |
|
|
584 | (3) |
|
Duplicate Keys and Mask Lists |
|
|
587 | (4) |
|
|
|
591 | (8) |
|
|
|
599 | (1) |
|
|
|
599 | (2) |
|
Routing Requests and Routing Messages |
|
|
601 | (44) |
|
|
|
601 | (1) |
|
rtalloc and rtalloc1 Functions |
|
|
601 | (3) |
|
RTFREE Macro and rtfree Function |
|
|
604 | (3) |
|
|
|
607 | (5) |
|
|
|
612 | (3) |
|
|
|
615 | (2) |
|
|
|
617 | (4) |
|
Routing Message Structures |
|
|
621 | (4) |
|
|
|
625 | (2) |
|
|
|
627 | (1) |
|
|
|
628 | (2) |
|
|
|
630 | (2) |
|
|
|
632 | (3) |
|
|
|
635 | (5) |
|
sysct1_dumpentry Function |
|
|
640 | (2) |
|
|
|
642 | (2) |
|
|
|
644 | (1) |
|
|
|
645 | (30) |
|
|
|
645 | (1) |
|
routedomain and protosw Structures |
|
|
646 | (1) |
|
|
|
647 | (1) |
|
|
|
647 | (1) |
|
|
|
648 | (12) |
|
|
|
660 | (1) |
|
|
|
661 | (1) |
|
|
|
662 | (2) |
|
|
|
664 | (2) |
|
|
|
666 | (5) |
|
raw_attach, raw_detach, and raw_disconnect Functions |
|
|
671 | (1) |
|
|
|
672 | (3) |
|
ARP: Address Resolution Protocol |
|
|
675 | (38) |
|
|
|
675 | (1) |
|
ARP and the Routing Table |
|
|
675 | (3) |
|
|
|
678 | (3) |
|
|
|
681 | (2) |
|
|
|
683 | (1) |
|
|
|
684 | (3) |
|
|
|
687 | (1) |
|
|
|
688 | (6) |
|
|
|
694 | (2) |
|
|
|
696 | (5) |
|
|
|
701 | (2) |
|
|
|
703 | (1) |
|
|
|
704 | (6) |
|
|
|
710 | (1) |
|
|
|
711 | (2) |
|
|
|
713 | (42) |
|
|
|
713 | (2) |
|
|
|
715 | (1) |
|
|
|
716 | (1) |
|
in_pcballoc and in_pcbdetach Functions |
|
|
717 | (2) |
|
Binding, Connecting, and Demultiplexing |
|
|
719 | (5) |
|
|
|
724 | (4) |
|
|
|
728 | (7) |
|
|
|
735 | (6) |
|
in_pcbdisconnect Function |
|
|
741 | (1) |
|
in_setsockaddr and in_setpeeraddr Functions |
|
|
741 | (1) |
|
in_pcbnotify, in_rtchange, and in_losing Functions |
|
|
742 | (8) |
|
Implementation Refinements |
|
|
750 | (1) |
|
|
|
751 | (4) |
|
UDP: User Datagram Protocol |
|
|
755 | (40) |
|
|
|
755 | (1) |
|
|
|
755 | (3) |
|
|
|
758 | (1) |
|
|
|
759 | (1) |
|
|
|
760 | (1) |
|
|
|
760 | (9) |
|
|
|
769 | (12) |
|
|
|
781 | (1) |
|
|
|
782 | (2) |
|
|
|
784 | (6) |
|
|
|
790 | (1) |
|
Implementation Refinements |
|
|
791 | (2) |
|
|
|
793 | (2) |
|
TCP: Transmission Control Protocol |
|
|
795 | (22) |
|
|
|
795 | (1) |
|
|
|
795 | (6) |
|
|
|
801 | (1) |
|
|
|
801 | (2) |
|
|
|
803 | (2) |
|
TCP State Transition Diagram |
|
|
805 | (2) |
|
|
|
807 | (5) |
|
|
|
812 | (3) |
|
|
|
815 | (2) |
|
|
|
817 | (34) |
|
|
|
817 | (2) |
|
|
|
819 | (2) |
|
tcp_canceltimers Function |
|
|
821 | (1) |
|
|
|
821 | (1) |
|
|
|
822 | (2) |
|
|
|
824 | (7) |
|
Retransmission Timer Calculations |
|
|
831 | (2) |
|
|
|
833 | (2) |
|
|
|
835 | (1) |
|
|
|
836 | (5) |
|
Retransmission Timeout: tcp_timers Function |
|
|
841 | (5) |
|
|
|
846 | (2) |
|
|
|
848 | (3) |
|
|
|
851 | (40) |
|
|
|
851 | (1) |
|
|
|
852 | (1) |
|
Determine if a Segment Should be Sent |
|
|
852 | (12) |
|
|
|
864 | (2) |
|
|
|
866 | (1) |
|
|
|
866 | (5) |
|
|
|
871 | (13) |
|
|
|
884 | (1) |
|
|
|
885 | (3) |
|
|
|
888 | (3) |
|
|
|
891 | (32) |
|
|
|
891 | (1) |
|
|
|
892 | (1) |
|
|
|
892 | (1) |
|
|
|
893 | (4) |
|
|
|
897 | (7) |
|
|
|
904 | (1) |
|
|
|
904 | (2) |
|
|
|
906 | (1) |
|
TCP_REASS Macro and tcp_reass Function |
|
|
906 | (10) |
|
|
|
916 | (4) |
|
|
|
920 | (3) |
|
|
|
923 | (44) |
|
|
|
923 | (2) |
|
|
|
925 | (8) |
|
|
|
933 | (1) |
|
|
|
934 | (7) |
|
TCP Input: Slow Path Processing |
|
|
941 | (1) |
|
Initiation of Passive Open, Completion of Active Open |
|
|
942 | (9) |
|
PAWS: Protection Against Wrapped Sequence Numbers |
|
|
951 | (3) |
|
Trim Segment so Data is Within Window |
|
|
954 | (6) |
|
Self-Connects and Simultaneous Opens |
|
|
960 | (3) |
|
|
|
963 | (1) |
|
|
|
963 | (2) |
|
|
|
965 | (2) |
|
|
|
967 | (40) |
|
|
|
967 | (1) |
|
|
|
967 | (1) |
|
Completion of Passive Opens and Simultaneous Opens |
|
|
967 | (3) |
|
Fast Retransmit and Fast Recovery Algorithms |
|
|
970 | (4) |
|
|
|
974 | (7) |
|
Update Window Information |
|
|
981 | (2) |
|
|
|
983 | (3) |
|
tcp_pulloutofband Function |
|
|
986 | (2) |
|
Processing of Received Data |
|
|
988 | (2) |
|
|
|
990 | (2) |
|
|
|
992 | (2) |
|
Implementation Refinements |
|
|
994 | (1) |
|
|
|
995 | (9) |
|
|
|
1004 | (3) |
|
|
|
1007 | (20) |
|
|
|
1007 | (1) |
|
|
|
1007 | (11) |
|
|
|
1018 | (1) |
|
|
|
1019 | (2) |
|
|
|
1021 | (1) |
|
|
|
1022 | (3) |
|
|
|
1025 | (2) |
|
|
|
1027 | (22) |
|
|
|
1027 | (1) |
|
|
|
1028 | (1) |
|
|
|
1029 | (3) |
|
|
|
1032 | (8) |
|
|
|
1040 | (6) |
|
|
|
1046 | (1) |
|
|
|
1047 | (2) |
|
|
|
1049 | (18) |
|
|
|
1049 | (1) |
|
|
|
1050 | (1) |
|
|
|
1051 | (2) |
|
|
|
1053 | (1) |
|
|
|
1053 | (3) |
|
|
|
1056 | (2) |
|
|
|
1058 | (5) |
|
|
|
1063 | (2) |
|
|
|
1065 | (2) |
| Epilogue |
|
1067 | (2) |
| Appendix A. Solutions to Selected Exercises |
|
1069 | (24) |
| Appendix B. Source Code Availability |
|
1093 | (4) |
| Appendix C. RFC 1122 Compliance |
|
1097 | (28) |
|
C.1 Link-Layer Requirements |
|
|
1097 | (1) |
|
|
|
1098 | (4) |
|
C.3 IP Options Requirements |
|
|
1102 | (2) |
|
C.4 IP Fragmentation and Reassembly Requirements |
|
|
1104 | (1) |
|
|
|
1105 | (5) |
|
C.6 Multicasting Requirements |
|
|
1110 | (1) |
|
|
|
1111 | (1) |
|
|
|
1111 | (2) |
|
|
|
1113 | (1) |
|
|
|
1113 | (2) |
|
|
|
1115 | (10) |
| Bibliography |
|
1125 | |
| Index |
|
1113 | |