Preface |
|
xix | |
Chapter 1 Introduction |
|
1 | (30) |
|
|
1 | (1) |
|
1.2 Source Code Presentation |
|
|
1 | (2) |
|
|
3 | (2) |
|
1.4 Application Programming Interfaces |
|
|
5 | (1) |
|
|
5 | (2) |
|
1.6 System Calls and Library Functions |
|
|
7 | (2) |
|
1.7 Network Implementation Overview |
|
|
9 | (1) |
|
|
10 | (5) |
|
1.9 Mbufs (Memory Buffers) and Output Processing |
|
|
15 | (4) |
|
|
19 | (3) |
|
1.11 Network Implementation Overview Revisited |
|
|
22 | (1) |
|
1.12 Interrupt Levels and Concurrency |
|
|
23 | (3) |
|
1.13 Source Code Organization |
|
|
26 | (2) |
|
|
28 | (1) |
|
|
29 | (2) |
Chapter 2 Mbufs: Memory Buffers |
|
31 | (32) |
|
|
31 | (5) |
|
|
36 | (1) |
|
|
37 | (1) |
|
|
38 | (2) |
|
2.5 Simple Mbuf Macros and Functions |
|
|
40 | (4) |
|
2.6 m_devget and mpullup Functions |
|
|
44 | (7) |
|
2.7 Summary of Mbuf Macros and Functions |
|
|
51 | (3) |
|
2.8 Summary of Net/3 Networking Data Structures |
|
|
54 | (2) |
|
2.9 m_copy and Cluster Reference Counts |
|
|
56 | (4) |
|
|
60 | (1) |
|
|
60 | (3) |
Chapter 3 Interface Layer |
|
63 | (32) |
|
|
63 | (1) |
|
|
64 | (1) |
|
|
65 | (8) |
|
|
73 | (1) |
|
|
74 | (2) |
|
3.6 ifnet and ifaddr Specialization |
|
|
76 | (1) |
|
3.7 Network Initialization Overview |
|
|
77 | (3) |
|
3.8 Ethernet Initialization |
|
|
80 | (2) |
|
|
82 | (3) |
|
3.10 Loopback Initialization |
|
|
85 | (1) |
|
|
85 | (8) |
|
|
93 | (1) |
|
|
94 | (1) |
Chapter 4 Interfaces: Ethernet |
|
95 | (32) |
|
|
95 | (1) |
|
|
96 | (2) |
|
|
98 | (16) |
|
|
114 | (11) |
|
|
125 | (2) |
Chapter 5 Interfaces: SLIP and Loopback |
|
127 | (28) |
|
|
127 | (1) |
|
|
127 | (1) |
|
|
128 | (22) |
|
|
150 | (3) |
|
|
153 | (2) |
Chapter 6 IP Addressing |
|
155 | (30) |
|
|
155 | (3) |
|
|
158 | (1) |
|
6.3 Interface and Address Summary |
|
|
158 | (2) |
|
6.4 sockaddr_in Structure |
|
|
160 | (1) |
|
|
161 | (1) |
|
|
161 | (16) |
|
6.7 Interface ioctl Processing |
|
|
177 | (4) |
|
6.8 Internet Utility Functions |
|
|
181 | (1) |
|
6.9 ifnet Utility Functions |
|
|
182 | (1) |
|
|
183 | (2) |
Chapter 7 Domains and Protocols |
|
185 | (20) |
|
|
185 | (1) |
|
|
186 | (1) |
|
|
187 | (1) |
|
|
188 | (3) |
|
7.5 IP domain and protosw Structures |
|
|
191 | (5) |
|
7.6 pffindproto and pffindtype Functions |
|
|
196 | (2) |
|
|
198 | (1) |
|
|
199 | (2) |
|
|
201 | (3) |
|
|
204 | (1) |
Chapter 8 IP: Internet Protocol |
|
205 | (42) |
|
|
205 | (1) |
|
|
206 | (4) |
|
|
210 | (2) |
|
8.4 Input Processing: ipintr Function |
|
|
212 | (8) |
|
8.5 Forwarding: ip_forward Function |
|
|
220 | (8) |
|
8.6 Output Processing: ip_output Function |
|
|
228 | (6) |
|
8.7 Internet Checksum: in_cksum Function |
|
|
234 | (5) |
|
8.8 setsockopt and getsockopt System Calls |
|
|
239 | (5) |
|
|
244 | (1) |
|
|
245 | (2) |
Chapter 9 IP Option Processing |
|
247 | (28) |
|
|
247 | (1) |
|
|
247 | (1) |
|
|
248 | (1) |
|
9.4 ip_dooptions Function |
|
|
249 | (3) |
|
|
252 | (2) |
|
9.6 Source and Record Route Options |
|
|
254 | (7) |
|
|
261 | (4) |
|
9.8 ip_insertoptions Function |
|
|
265 | (4) |
|
|
269 | (3) |
|
|
272 | (1) |
|
|
272 | (3) |
Chapter 10 IP Fragmentation and Reassembly |
|
275 | (26) |
|
|
275 | (2) |
|
|
277 | (1) |
|
|
278 | (4) |
|
|
282 | (1) |
|
|
283 | (3) |
|
|
286 | (12) |
|
10.7 ip_slowtimo Function |
|
|
298 | (2) |
|
|
300 | (1) |
Chapter 11 ICMP: Internet Control Message Protocol |
|
301 | (36) |
|
|
301 | (4) |
|
|
305 | (3) |
|
|
308 | (1) |
|
11.4 ICMP protosw Structure |
|
|
309 | (1) |
|
11.5 Input Processing: icmp_input Function |
|
|
310 | (3) |
|
|
313 | (3) |
|
|
316 | (5) |
|
|
321 | (2) |
|
|
323 | (1) |
|
|
324 | (1) |
|
11.11 icmp_error Function |
|
|
324 | (4) |
|
11.12 icmp_reflect Function |
|
|
328 | (5) |
|
|
333 | (1) |
|
11.14 icmp_sysctl Function |
|
|
334 | (1) |
|
|
335 | (2) |
Chapter 12 IP Multicasting |
|
337 | (44) |
|
|
337 | (3) |
|
|
340 | (1) |
|
12.3 Ethernet Multicast Addresses |
|
|
341 | (1) |
|
12.4 ether_multi Structure |
|
|
342 | (2) |
|
12.5 Ethernet Multicast Reception |
|
|
344 | (1) |
|
|
345 | (2) |
|
12.7 ip_moptions Structure |
|
|
347 | (1) |
|
12.8 Multicast Socket Options |
|
|
348 | (1) |
|
12.9 Multicast TTL Values |
|
|
348 | (3) |
|
12.10 ip_setmopt ions Function |
|
|
351 | (4) |
|
12.11 Joining an IP Multicast Group |
|
|
355 | (11) |
|
12.12 Leaving an IP Multicast Group |
|
|
366 | (5) |
|
12.13 ip_getmoptions Function |
|
|
371 | (2) |
|
12.14 Multicast Input Processing: ipintr Function |
|
|
373 | (2) |
|
12.15 Multicast Output Processing: ip_output Function |
|
|
375 | (4) |
|
12.16 Performance Considerations |
|
|
379 | (1) |
|
|
379 | (2) |
Chapter 13 IGMP: Internet Group Management Protocol |
|
381 | (16) |
|
|
381 | (1) |
|
|
382 | (2) |
|
|
384 | (1) |
|
13.4 IGMP protosw Structure |
|
|
384 | (2) |
|
13.5 Joining a Group: igmp_j oingroup Function |
|
|
386 | (1) |
|
13.6 igmp_fasttimo Function |
|
|
387 | (4) |
|
13.7 Input Processing: igmp_input Function |
|
|
391 | (4) |
|
13.8 Leaving a Group: igmp_leavegroup Function |
|
|
395 | (1) |
|
|
396 | (1) |
Chapter 14 IP Multicast Routing |
|
397 | (38) |
|
|
397 | (1) |
|
|
398 | (1) |
|
14.3 Multicast Output Processing Revisited |
|
|
399 | (2) |
|
|
401 | (3) |
|
|
404 | (7) |
|
|
411 | (5) |
|
|
416 | (8) |
|
14.8 Multicast Forwarding: ip_mforward Function |
|
|
424 | (9) |
|
14.9 Cleanup: ip_mrouter_done Function |
|
|
433 | (1) |
|
|
434 | (1) |
Chapter 15 Socket Layer |
|
435 | (40) |
|
|
435 | (1) |
|
|
436 | (1) |
|
|
437 | (4) |
|
|
441 | (4) |
|
15.5 Processes, Descriptors, and Sockets |
|
|
445 | (2) |
|
|
447 | (4) |
|
15.7 getsock and sockargs Functions |
|
|
451 | (2) |
|
|
453 | (2) |
|
|
455 | (1) |
|
15.10 tsleep and wakeup Functions |
|
|
456 | (1) |
|
|
457 | (4) |
|
15.12 sonewconn and soisconnected Functions |
|
|
461 | (3) |
|
15.13 connect System call |
|
|
464 | (4) |
|
15.14 shutdown System Call |
|
|
468 | (3) |
|
|
471 | (3) |
|
|
474 | (1) |
Chapter 16 Socket I/O |
|
475 | (62) |
|
|
475 | (1) |
|
|
475 | (1) |
|
|
476 | (4) |
|
16.4 write, writev, sendto, and sendmsg System Calls |
|
|
480 | (3) |
|
|
483 | (2) |
|
|
485 | (4) |
|
|
489 | (11) |
|
16.8 read, ready, recvfrom, and recvmsg System Calls |
|
|
500 | (1) |
|
|
501 | (2) |
|
|
503 | (2) |
|
|
505 | (5) |
|
|
510 | (14) |
|
|
524 | (10) |
|
|
534 | (3) |
Chapter 17 Socket Options |
|
537 | (22) |
|
|
537 | (1) |
|
|
538 | (1) |
|
17.3 setsockopt System Call |
|
|
539 | (6) |
|
17.4 getsockopt System Call |
|
|
545 | (3) |
|
17.5 fcntl and ioctl System Calls |
|
|
548 | (6) |
|
17.6 getsockname System Call |
|
|
554 | (1) |
|
17.7 getpeername System Call |
|
|
554 | (3) |
|
|
557 | (2) |
Chapter 18 Radix Tree Routing Tables |
|
559 | (42) |
|
|
559 | (1) |
|
18.2 Routing Table Structure |
|
|
560 | (9) |
|
|
569 | (1) |
|
|
570 | (3) |
|
18.5 Radix Node Data Structures |
|
|
573 | (5) |
|
|
578 | (3) |
|
18.7 Initialization: route_init and rtable_init Functions |
|
|
581 | (3) |
|
18.8 Initialization: rn_init and rn_inithead Functions |
|
|
584 | (3) |
|
18.9 Duplicate Keys and Mask Lists |
|
|
587 | (4) |
|
|
591 | (8) |
|
|
599 | (1) |
|
|
599 | (2) |
Chapter 19 Routing Requests and Routing Messages |
|
601 | (44) |
|
|
601 | (1) |
|
19.2 rtalloc and rtallocl Functions |
|
|
601 | (3) |
|
19.3 RTFREE Macro and rtfree Function |
|
|
604 | (3) |
|
|
607 | (5) |
|
|
612 | (3) |
|
|
615 | (2) |
|
|
617 | (4) |
|
19.8 Routing Message Structures |
|
|
621 | (4) |
|
|
625 | (2) |
|
|
627 | (1) |
|
19.11 rt_newaddrmsg Function |
|
|
628 | (2) |
|
|
630 | (2) |
|
|
632 | (3) |
|
19.14 sysctl_rtable Function |
|
|
635 | (5) |
|
19.15 sysctl_dumpentry Function |
|
|
640 | (2) |
|
19.16 sysctl_iflist Function |
|
|
642 | (2) |
|
|
644 | (1) |
Chapter 20 Routing Sockets |
|
645 | (30) |
|
|
645 | (1) |
|
20.2 routedomain and protosw Structures |
|
|
646 | (1) |
|
20.3 Routing Control Blocks |
|
|
647 | (1) |
|
|
647 | (1) |
|
20.5 route_output Function |
|
|
648 | (12) |
|
|
660 | (1) |
|
20.7 rt_setmetrics Function |
|
|
661 | (1) |
|
|
662 | (2) |
|
20.9 route_usrreq Function |
|
|
664 | (2) |
|
20.10 raw_usrreq Function |
|
|
666 | (5) |
|
20.11 raw_attach, raw_detach, and raw_disconnect Functions |
|
|
671 | (1) |
|
|
672 | (3) |
Chapter 21 ARP: Address Resolution Protocol |
|
675 | (38) |
|
|
675 | (1) |
|
21.2 ARP and the Routing Table |
|
|
675 | (3) |
|
|
678 | (3) |
|
|
681 | (2) |
|
|
683 | (1) |
|
|
684 | (3) |
|
|
687 | (1) |
|
21.8 in_arpinput Function |
|
|
688 | (6) |
|
|
694 | (2) |
|
21.10 arpresolve Function |
|
|
696 | (5) |
|
|
701 | (2) |
|
|
703 | (1) |
|
21.13 arp_rtrequest Function |
|
|
704 | (6) |
|
21.14 ARP and Multicasting |
|
|
710 | (1) |
|
|
711 | (2) |
Chapter 22 Protocol Control Blocks |
|
713 | (42) |
|
|
713 | (2) |
|
|
715 | (1) |
|
|
716 | (1) |
|
22.4 in_pcballoc and inpcbdetach Functions |
|
|
717 | (2) |
|
22.5 Binding, Connecting, and Demultiplexing |
|
|
719 | (5) |
|
22.6 in_pcblookup Function |
|
|
724 | (4) |
|
|
728 | (7) |
|
22.8 in_pcbconnect Function |
|
|
735 | (6) |
|
22.9 in_pcbdisconnect Function |
|
|
741 | (1) |
|
22.10 in_setsockaddr and in_setpeeraddr Functions |
|
|
741 | (1) |
|
22.11 in_pcbnotify, in_rtchange, and in_losing Functions |
|
|
742 | (8) |
|
22.12 Implementation Refinements |
|
|
750 | (1) |
|
|
751 | (4) |
Chapter 23 UDP: User Datagram Protocol |
|
755 | (40) |
|
|
755 | (1) |
|
|
755 | (3) |
|
23.3 UDP protosw Structure |
|
|
758 | (1) |
|
|
759 | (1) |
|
|
760 | (1) |
|
|
760 | (9) |
|
|
769 | (12) |
|
23.8 udp_saveopt Function |
|
|
781 | (1) |
|
23.9 udp_ctlinput Function |
|
|
782 | (2) |
|
23.10 udp_usrreq Function |
|
|
784 | (6) |
|
23.11 udp_sysctl Function |
|
|
790 | (1) |
|
23.12 Implementation Refinements |
|
|
791 | (2) |
|
|
793 | (2) |
Chapter 24 TCP: Transmission Control Protocol |
|
795 | (22) |
|
|
795 | (1) |
|
|
795 | (6) |
|
24.3 TCP protosw Structure |
|
|
801 | (1) |
|
|
801 | (2) |
|
|
803 | (2) |
|
24.6 TCP State Transition Diagram |
|
|
805 | (2) |
|
24.7 TCP Sequence Numbers |
|
|
807 | (5) |
|
|
812 | (3) |
|
|
815 | (2) |
Chapter 25 TCP Timers |
|
817 | (34) |
|
|
817 | (2) |
|
|
819 | (2) |
|
25.3 tcp_canceltimers Function |
|
|
821 | (1) |
|
25.4 tcp_f asttimo Function |
|
|
821 | (1) |
|
25.5 tcp_slowtimo Function |
|
|
822 | (2) |
|
|
824 | (7) |
|
25.7 Retransmission Timer Calculations |
|
|
831 | (2) |
|
25.8 tcp_newtcpcb Function |
|
|
833 | (2) |
|
25.9 tcp_setpersist Function |
|
|
835 | (1) |
|
25.10 tcp_xmit_timer Function |
|
|
836 | (5) |
|
25.11 Retransmission Timeout: tcp_timers Function |
|
|
841 | (5) |
|
|
846 | (2) |
|
|
848 | (3) |
Chapter 26 TCP Output |
|
851 | (40) |
|
|
851 | (1) |
|
|
852 | (1) |
|
26.3 Determine if a Segment Should be Sent |
|
|
852 | (12) |
|
|
864 | (2) |
|
|
866 | (1) |
|
|
866 | (5) |
|
|
871 | (13) |
|
26.8 tcp_template Function |
|
|
884 | (1) |
|
26.9 tcp_respond Function |
|
|
885 | (3) |
|
|
888 | (3) |
Chapter 27 TCP Functions |
|
891 | (32) |
|
|
891 | (1) |
|
|
892 | (1) |
|
|
892 | (1) |
|
|
893 | (4) |
|
|
897 | (7) |
|
27.6 tcp_ctlinput Function |
|
|
904 | (1) |
|
|
904 | (2) |
|
|
906 | (1) |
|
27.9 TCP_REASS Macro and tcp_reass Function |
|
|
906 | (10) |
|
|
916 | (4) |
|
|
920 | (3) |
Chapter 28 TCP Input |
|
923 | (44) |
|
|
923 | (2) |
|
28.2 Preliminary Processing |
|
|
925 | (8) |
|
28.3 tcp_dooptions Function |
|
|
933 | (1) |
|
|
934 | (7) |
|
28.5 TCP Input: Slow Path Processing |
|
|
941 | (1) |
|
28.6 Initiation of Passive Open, Completion of Active Open |
|
|
942 | (9) |
|
28.7 PAWS: Protection Against Wrapped Sequence Numbers |
|
|
951 | (3) |
|
28.8 Trim Segment so Data is Within Window |
|
|
954 | (6) |
|
28.9 Self-Connects and Simultaneous Opens |
|
|
960 | (3) |
|
|
963 | (1) |
|
|
963 | (2) |
|
|
965 | (2) |
Chapter 29 TCP Input (Continued) |
|
967 | (40) |
|
|
967 | (1) |
|
29.2 ACK Processing Overview |
|
|
967 | (1) |
|
29.3 Completion of Passive Opens and Simultaneous Opens |
|
|
967 | (3) |
|
29.4 Fast Retransmit and Fast Recovery Algorithms |
|
|
970 | (4) |
|
|
974 | (7) |
|
29.6 Update Window Information |
|
|
981 | (2) |
|
29.7 Urgent Mode Processing |
|
|
983 | (3) |
|
29.8 tcp_pulloutofband Function |
|
|
986 | (2) |
|
29.9 Processing of Received Data |
|
|
988 | (2) |
|
|
990 | (2) |
|
|
992 | (2) |
|
29.12 Implementation Refinements |
|
|
994 | (1) |
|
|
995 | (9) |
|
|
1004 | (3) |
Chapter 30 TCP User Requests |
|
1007 | (20) |
|
|
1007 | (1) |
|
|
1007 | (11) |
|
|
1018 | (1) |
|
30.4 tcp_disconnect Function |
|
|
1019 | (2) |
|
30.5 tcp_usrclosed Function |
|
|
1021 | (1) |
|
30.6 tcp_ctloutput Function |
|
|
1022 | (3) |
|
|
1025 | (2) |
Chapter 31 BPF: BSD Packet Filter |
|
1027 | (22) |
|
|
1027 | (1) |
|
|
1028 | (1) |
|
|
1029 | (3) |
|
|
1032 | (14) |
|
|
t1040 | |
|
|
1046 | (1) |
|
|
1047 | (2) |
Chapter 32 Raw IP |
|
1049 | (18) |
|
|
1049 | (1) |
|
|
1050 | (1) |
|
32.3 Raw IP protosw Structure |
|
|
1051 | (2) |
|
|
1053 | (1) |
|
|
1053 | (3) |
|
|
1056 | (2) |
|
|
1058 | (5) |
|
32.8 rip_ctloutput Function |
|
|
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 | (8) |
Index |
|
1133 | |