TCP IP illustrated, volume II the implementation kho tài liệu training

1.2K 393 0
TCP IP illustrated, volume II the implementation kho tài liệu training

Đang tải... (xem toàn văn)

Tài liệu hạn chế xem trước, để xem đầy đủ mời bạn chọn Tải xuống

Thông tin tài liệu

TCP/IP Illustrated The Implementation Volume W Richard Stevens Gary R Wright Addison-Wesley Professional i Addison-Wesley Professional Computing Series Brian W Kernighan, Consulting Editor Matthew H Austern, Generic Programming and the STL: Using and Extending the C++ Standard Template Library David R Butenhof, Programming with POSIX® Threads Brent Callaghan, NFS Illustrated Tom Cargill, C++ Programming Style William R Cheswick/Steven M Bellovin/Aviel D Rubin, Firewalls and Internet Security, Second Edition: Repelling the Wily Hacker David A Curry, UNIX® System Security: A Guide for Users and System Administrators Stephen C Dewhurst, C++ Gotchas: Avoiding Common Problems in Coding and Design Dan Farmer/Wietse Venema, Forensic Discovery Erich Gamma/Richard Helm/Ralph Johnson/John Vlissides, Design Patterns: Elements of Reusable ObjectOriented Software Erich Gamma/Richard Helm/Ralph Johnson/John Vlissides, Design Patterns CD: Elements of Reusable ObjectOriented Software Peter Haggar, Practical Java™ Programming Language Guide David R Hanson, C Interfaces and Implementations: Techniques for Creating Reusable Software Mark Harrison/Michael McLennan, Effective Tcl/Tk Programming: Writing Better Programs with Tcl and Tk Michi Henning/Steve Vinoski, Advanced CORBA® Programming with C++ Brian W Kernighan/Rob Pike, The Practice of Programming S Keshav, An Engineering Approach to Computer Networking: ATM Networks, the Internet, and the Telephone Network John Lakos, Large-Scale C++ Software Design Scott Meyers, Effective C++ CD: 85 Specific Ways to Improve Your Programs and Designs Scott Meyers, Effective C++, Third Edition: 55 Specific Ways to Improve Your Programs and Designs Scott Meyers, More Effective C++: 35 New Ways to Improve Your Programs and Designs Scott Meyers, Effective STL: 50 Specific Ways to Improve Your Use of the Standard Template Library Robert B Murray, C++ Strategies and Tactics David R Musser/Gillmer J Derge/Atul Saini, STL Tutorial and Reference Guide, Second Edition: C++ Programming with the Standard Template Library John K Ousterhout, Tcl and the Tk Toolkit Craig Partridge, Gigabit Networking Radia Perlman, Interconnections, Second Edition: Bridges, Routers, Switches, and Internetworking Protocols Stephen A Rago, UNIX® System V Network Programming Eric S Raymond, The Art of UNIX Programming Marc J Rochkind, Advanced UNIX Programming, Second Edition Curt Schimmel, UNIX® Systems for Modern Architectures: Symmetric Multiprocessing and Caching for Kernel Programmers W Richard Stevens, TCP/IP Illustrated, Volume 1: The Protocols W Richard Stevens, TCP/IP Illustrated, Volume 3: TCP for Transactions, HTTP, NNTP, and the UNIX® Domain Protocols W Richard Stevens/Bill Fenner/Andrew M Rudoff, UNIX Network Programming Volume 1, Third Edition: The Sockets Networking API W Richard Stevens/Stephen A Rago, Advanced Programming in the UNIX® Environment, Second Edition W Richard Stevens/Gary R Wright, TCP/IP Illustrated Volumes 1-3 Boxed Set John Viega/Gary McGraw, Building Secure Software: How to Avoid Security Problems the Right Way Gary R Wright/W Richard Stevens, TCP/IP Illustrated, Volume 2: The Implementation Ruixi Yuan/W Timothy Strayer, Virtual Private Networks: Technologies and Solutions Visit www.awprofessional.com/series/professionalcomputing for more information about these titles ii Table of Contents Copyright Preface Chapter Introduction Section 1.1 Introduction Section 1.2 Source Code Presentation Section 1.3 History Section 1.4 Application Programming Interfaces Section 1.5 Example Program Section 1.6 System Calls and Library Functions Section 1.7 Network Implementation Overview Section 1.8 Descriptors Section 1.9 Mbufs (Memory Buffers) and Output Processing Section 1.10 Input Processing Section 1.11 Network Implementation Overview Revisited Section 1.12 Interrupt Levels and Concurrency Section 1.13 Source Code Organization Section 1.14 Test Network Section 1.15 Summary Chapter Mbufs: Memory Buffers Section 2.1 Introduction Section 2.2 Code Introduction Section 2.3 Mbuf Definitions Section 2.4 mbuf Structure Section 2.5 Simple Mbuf Macros and Functions Section 2.6 m_devget and m_pullup Functions Section 2.7 Summary of Mbuf Macros and Functions Section 2.8 Summary of Net/3 Networking Data Structures Section 2.9 m_copy and Cluster Reference Counts Section 2.10 Alternatives Section 2.11 Summary Chapter Interface Layer Section 3.1 Introduction Section 3.2 Code Introduction Section 3.3 ifnet Structure Section 3.4 ifaddr Structure Section 3.5 sockaddr Structure Section 3.6 ifnet and ifaddr Specialization Section 3.7 Network Initialization Overview Section 3.8 Ethernet Initialization Section 3.9 SLIP Initialization Section 3.10 Loopback Initialization Section 3.11 if_attach Function Section 3.12 ifinit Function 3.13 Summary Chapter Interfaces: Ethernet Section 4.1 Introduction Section 4.2 Code Introduction Section 4.3 Ethernet Interface iii 1 4 13 18 21 22 25 26 27 29 29 33 34 35 37 41 48 51 53 57 57 59 59 59 61 70 72 73 75 77 80 83 83 91 93 94 94 95 98 Section 4.4 ioctl System Call Section 4.5 Summary Chapter Interfaces: SLIP and Loopback Section 5.1 Introduction Section 5.2 Code Introduction Section 5.3 SLIP Interface Section 5.4 Loopback Interface Section 5.5 Summary Chapter IP Addressing Section 6.1 Introduction Section 6.2 Code Introduction Section 6.3 Interface and Address Summary Section 6.4 sockaddr_in Structure Section 6.5 in_ifaddr Structure Section 6.6 Address Assignment Section 6.7 Interface ioctl Processing Section 6.8 Internet Utility Functions Section 6.9 ifnet Utility Functions Section 6.10 Summary Chapter Domains and Protocols Section 7.1 Introduction Section 7.2 Code Introduction Section 7.3 domain Structure Section 7.4 protosw Structure Section 7.5 IP domain and protosw Structures Section 7.6 pffindproto and pffindtype Functions Section 7.7 pfctlinput Function Section 7.8 IP Initialization Section 7.9 sysctl System Call Section 7.10 Summary Chapter IP: Internet Protocol Section 8.1 Introduction Section 8.2 Code Introduction Section 8.3 IP Packets Section 8.4 Input Processing: ipintr Function Section 8.5 Forwarding: ip_forward Function Section 8.6 Output Processing: ip_output Function Section 8.7 Internet Checksum: in_cksum Function Section 8.8 setsockopt and getsockopt System Calls Section 8.9 ip_sysctl Function Section 8.10 Summary Chapter IP Option Processing Section 9.1 Introduction Section 9.2 Code Introduction Section 9.3 Option Format Section 9.4 ip_dooptions Function Section 9.5 Record Route Option Section 9.6 Source and Record Route Options iv 115 127 128 128 128 129 149 152 153 153 155 155 157 158 159 176 179 179 180 182 182 182 183 184 187 193 194 195 197 200 202 202 203 205 208 216 224 232 236 241 242 244 244 244 245 246 249 251 Section 9.7 Timestamp Option Section 9.8 ip_insertoptions Function Section 9.9 ip_pcbopts Function Section 9.10 Limitations Section 9.11 Summary Chapter 10 IP Fragmentation and Reassembly Section 10.1 Introduction Section 10.2 Code Introduction Section 10.3 Fragmentation Section 10.4 ip_optcopy Function Section 10.5 Reassembly Section 10.6 ip_reass Function Section 10.7 ip_slowtimo Function Section 10.8 Summary Chapter 11 ICMP: Internet Control Message Protocol Section 11.1 Introduction Section 11.2 Code Introduction Section 11.3 icmp Structure Section 11.4 ICMP protosw Structure Section 11.5 Input Processing: icmp_input Function Section 11.6 Error Processing Section 11.7 Request Processing Section 11.8 Redirect Processing Section 11.9 Reply Processing Section 11.10 Output Processing Section 11.11 icmp_error Function Section 11.12 icmp_reflect Function Section 11.13 icmp_send Function Section 11.14 icmp_sysctl Function Section 11.15 Summary Chapter 12 IP Multicasting Section 12.1 Introduction Section 12.2 Code Introduction Section 12.3 Ethernet Multicast Addresses Section 12.4 ether_multi Structure Section 12.5 Ethernet Multicast Reception Section 12.6 in_multi Structure Section 12.7 ip_moptions Structure Section 12.8 Multicast Socket Options Section 12.9 Multicast TTL Values Section 12.10 ip_setmoptions Function Section 12.11 Joining an IP Multicast Group Section 12.12 Leaving an IP Multicast Group Section 12.13 ip_getmoptions Function Section 12.14 Multicast Input Processing: ipintr Function Section 12.15 Multicast Output Processing: ip_output Function Section 12.16 Performance Considerations Section 12.17 Summary Chapter 13 IGMP: Internet Group Management Protocol Section 13.1 Introduction Section 13.2 Code Introduction v 258 262 266 270 270 272 272 273 274 279 280 283 296 297 299 299 302 305 306 307 311 314 319 321 322 323 327 332 333 334 336 336 338 339 340 342 343 345 346 347 349 354 365 370 372 373 378 378 380 380 381 Section 13.3 igmp Structure Section 13.4 IGMP protosw Structure Section 13.5 Joining a Group: igmp_joingroup Function Section 13.6 igmp_fasttimo Function Section 13.7 Input Processing: igmp_input Function Section 13.8 Leaving a Group: igmp_leavegroup Function Section 13.9 Summary Chapter 14 IP Multicast Routing Section 14.1 Introduction Section 14.2 Code Introduction Section 14.3 Multicast Output Processing Revisited Section 14.4 mrouted Daemon Section 14.5 Virtual Interfaces Section 14.6 IGMP Revisited Section 14.7 Multicast Routing Section 14.8 Multicast Forwarding: ip_mforward Function Section 14.9 Cleanup: ip_mrouter_done Function Section 14.10 Summary Chapter 15 Socket Layer Section 15.1 Introduction Section 15.2 Code Introduction Section 15.3 socket Structure Section 15.4 System Calls Section 15.5 Processes, Descriptors, and Sockets Section 15.6 socket System Call Section 15.7 getsock and sockargs Functions Section 15.8 bind System Call Section 15.9 listen System Call Section 15.10 tsleep and wakeup Functions Section 15.11 accept System Call Section 15.12 sonewconn and soisconnected Functions Section 15.13 connect System call Section 15.14 shutdown System Call Section 15.15 close System Call Section 15.16 Summary Chapter 16 Socket I/O Section 16.1 Introduction Section 16.2 Code Introduction Section 16.3 Socket Buffers Section 16.4 write, writev, sendto, and sendmsg System Calls Section 16.5 sendmsg System Call Section 16.6 sendit Function Section 16.7 sosend Function Section 16.8 read, readv, recvfrom, and recvmsg System Calls Section 16.9 recvmsg System Call Section 16.10 recvit Function Section 16.11 soreceive Function Section 16.12 soreceive Code Section 16.13 select System Call Section 16.14 Summary Chapter 17 Socket Options vi 382 383 384 386 390 394 395 396 396 396 398 399 402 410 416 424 434 435 436 436 437 437 443 447 448 458 460 462 463 465 469 472 476 479 482 484 484 484 485 489 492 494 498 510 511 513 515 520 522 536 550 Section 17.1 Introduction Section 17.2 Code Introduction Section 17.3 setsockopt System Call Section 17.4 getsockopt System Call Section 17.5 fcntl and ioctl System Calls Section 17.6 getsockname System Call Section 17.7 getpeername System Call Section 17.8 Summary Chapter 18 Radix Tree Routing Tables Section 18.1 Introduction Section 18.2 Routing Table Structure Section 18.3 Routing Sockets Section 18.4 Code Introduction Section 18.5 Radix Node Data Structures Section 18.6 Routing Structures Section 18.7 Initialization: route_init and rtable_init Functions Section 18.8 Initialization: rn_init and rn_inithead Functions Section 18.9 Duplicate Keys and Mask Lists Section 18.10 rn_match Function Section 18.11 rn_search Function Section 18.12 Summary Chapter 19 Routing Requests and Routing Messages Section 19.1 Introduction Section 19.2 rtalloc and rtalloc1 Functions Section 19.3 RTFREE Macro and rtfree Function Section 19.4 rtrequest Function Section 19.5 rt_setgate Function Section 19.6 rtinit Function Section 19.7 rtredirect Function Section 19.8 Routing Message Structures Section 19.9 rt_missmsg Function Section 19.10 rt_ifmsg Function Section 19.11 rt_newaddrmsg Function Section 19.12 rt_msg1 Function Section 19.13 rt_msg2 Function Section 19.14 sysctl_rtable Function Section 19.15 sysctl_dumpentry Function Section 19.16 sysctl_iflist Function Section 19.17 Summary Chapter 20 Routing Sockets Section 20.1 Introduction Section 20.2 routedomain and protosw Structures Section 20.3 Routing Control Blocks Section 20.4 raw_init Function Section 20.5 route_output Function Section 20.6 rt_xaddrs Function Section 20.7 rt_setmetrics Function Section 20.8 raw_input Function Section 20.9 route_usrreq Function Section 20.10 raw_usrreq Function Section 20.11 raw_attach, raw_detach, and raw_disconnect Functions vii 550 551 551 557 561 567 568 570 571 571 571 580 581 584 589 592 596 599 603 610 611 613 613 613 616 618 625 628 613 635 639 641 643 645 647 651 657 659 661 663 663 663 664 665 666 681 681 682 684 686 691 Section 20.12 Summary Chapter 21 ARP: Address Resolution Protocol Section 21.1 Introduction Section 21.2 ARP and the Routing Table Section 21.3 Code Introduction Section 21.4 ARP Structures Section 21.5 arpwhohas Function Section 21.6 arprequest Function Section 21.7 arpintr Function Section 21.8 in_arpinput Function Section 21.9 ARP Timer Functions Section 21.10 arpresolve Function Section 21.11 arplookup Function Section 21.12 Proxy ARP Section 21.13 arp_rtrequest Function Section 21.14 ARP and Multicasting Section 21.15 Summary Chapter 22 Protocol Control Blocks Section 22.1 Introduction Section 22.2 Code Introduction Section 22.3 inpcb Structure Section 22.4 in_pcballoc and in_pcbdetach Functions Section 22.5 Binding, Connecting, and Demultiplexing Section 22.6 in_pcblookup Function Section 22.7 in_pcbbind Function Section 22.8 in_pcbconnect Function Section 22.9 in_pcbdisconnect Function Section 22.10 in_setsockaddr and in_setpeeraddr Functions Section 22.11 in_pcbnotify, in_rtchange, and in_losing Functions Section 22.12 Implementation Refinements Section 22.13 Summary Chapter 23 UDP: User Datagram Protocol Section 23.1 Introduction Section 23.2 Code Introduction Section 23.3 UDP protosw Structure Section 23.4 UDP Header Section 23.5 udp_init Function Section 23.6 udp_output Function Section 23.7 udp_input Function Section 23.8 udp_saveopt Function Section 23.9 udp_ctlinput Function Section 23.10 udp_usrreq Function Section 23.11 udp_sysctl Function Section 23.12 Implementation Refinements Section 23.13 Summary Chapter 24 TCP: Transmission Control Protocol Section 24.1 Introduction Section 24.2 Code Introduction Section 24.3 TCP protosw Structure Section 24.4 TCP Header Section 24.5 TCP Control Block viii 693 695 695 695 697 700 702 703 706 707 714 715 720 722 723 730 731 733 733 735 736 737 739 745 749 756 762 762 763 771 772 775 775 775 778 778 780 780 789 801 803 805 812 812 814 817 817 817 821 822 824 Section 24.6 TCP State Transition Diagram Section 24.7 TCP Sequence Numbers Section 24.8 tcp_init Function Section 24.9 Summary Chapter 25 TCP Timers Section 25.1 Introduction Section 25.2 Code Introduction Section 25.3 tcp_canceltimers Function Section 25.4 tcp_fasttimo Function Section 25.5 tcp_slowtimo Function Section 25.6 tcp_timers Function Section 25.7 Retransmission Timer Calculations Section 25.8 tcp_newtcpcb Function Section 25.9 tcp_setpersist Function Section 25.10 tcp_xmit_timer Function Section 25.11 Retransmission Timeout: tcp_timers Function Section 25.12 An RTT Example Section 25.13 Summary Chapter 26 TCP Output Section 26.1 Introduction Section 26.2 tcp_output Overview Section 26.3 Determine if a Segment Should be Sent Section 26.4 TCP Options Section 26.5 Window Scale Option Section 26.6 Timestamp Option Section 26.7 Send a Segment Section 26.8 tcp_template Function Section 26.9 tcp_respond Function Section 26.10 Summary Chapter 27 TCP Functions Section 27.1 Introduction Section 27.2 tcp_drain Function Section 27.3 tcp_drop Function Section 27.4 tcp_close Function Section 27.5 tcp_mss Function Section 27.6 tcp_ctlinput Function Section 27.7 tcp_notify Function Section 27.8 tcp_quench Function Section 27.9 TCP_REASS Macro and tcp_reass Function Section 27.10 tcp_trace Function Section 27.11 Summary Chapter 28 TCP Input Section 28.1 Introduction Section 28.2 Preliminary Processing Section 28.3 tcp_dooptions Function Section 28.4 Header Prediction Section 28.5 TCP Input: Slow Path Processing Section 28.6 Initiation of Passive Open, Completion of Active Open Section 28.7 PAWS: Protection Against Wrapped Sequence Numbers Section 28.8 Trim Segment so Data is Within Window Section 28.9 Self-Connects and Simultaneous Opens ix 826 833 828 836 837 837 838 840 840 841 843 850 852 854 856 862 868 869 871 871 871 873 885 886 887 891 907 909 912 915 915 915 915 917 921 928 929 930 931 941 946 947 949 949 958 961 967 968 978 981 988 No: Berkeley-derived implementations continue to interpret the urgent pointer as pointing just beyond the last byte of urgent data x Must support a sequence of urgent data of any length Yes, with the bug fix discussed in Exercise 26.6 x Must inform the receiving process (1) when TCP receives an urgent pointer and there was no previously pending urgent data, or (2) when the urgent pointer advances in the data stream Yes, in Figure 29.17 x Must be a way for the process to determine how much urgent data remains, or at least whether more urgent data remains to be read Yes, this is the purpose of the out-of-band mark, the SIOCATMARK ioctl TCP Options x Must be able to receive TCP options in any segment Yes x Must ignore any options not supported Yes, in Section 28.3 x Must cope with an illegal option length Yes, in Section 28.3 x Must implement both sending and receiving the MSS option Yes, a received MSS option is handled in Figure 28.10, and Figure 26.23 always sends an MSS option with a SYN x Should send an MSS option in every SYN when its receive MSS differs from 536, and may send it always Yes, as mentioned earlier, an MSS option is always sent by Net/3 with a SYN x If an MSS option is not received with a SYN, must assume a default MSS of 536 No: The default MSS is 512, not 536 This is probably a historical artifact because VAXes had a physical page size of 512 bytes and trailer protocols working only with data that is a multiple of 512 x Must calculate the "effective send MSS." Yes, in Section 27.5 1149 TCP Checksums x Must generate a TCP checksum in outgoing segments and must verify received checksums Yes, TCP checksums are always calculated and verified Initial Sequence Number Selection x Must use the specified clock-driven selection from RFC 793 No: RFC 793 specifies a clock that changes by 125,000 every half-second, whereas the Net/3 ISN (the global variable tcp_iss) is incremented by 64,000 every half-second, about onehalf the specified rate Opening Connections x Must support simultaneous open attempts Yes, although Berkeley-derived systems prior to 4.4BSD did not support this, as described in Section 28.9 x Must keep track of whether it reached the SYN_RCVD state from the LISTEN or SYN_SENT states Yes, same result, different technique The purpose of this requirement is to allow a passive open that receives an RST to return to the LISTEN state (as shown in Figure 24.15), but force an active open that ends up in SYN_RCVD and then receives an RST to be aborted This is described following Figure 28.36 x A passive open must not affect previously created connections Yes x Must allow a listening socket with a given local port at the same time that another socket with the same local port is in the SYN_SENT or SYN_RCVD state Yes: The stated purpose of this requirement is to allow a given application to accept multiple connection attempts at about the same time This is done in Berkeley-derived implementations by cloning new connections from the socket in the LISTEN state when the incoming SYN arrives x Must ask IP to select a local IP address to be used as the source IP address when the source IP address is not specified by the process performing an active open on a multihomed host Yes, done by in_pcbconnect x Must continue to use the same source IP address for all segments sent on a connection Yes: Once in_pcbconnect selects the source address, it doesn’t change x Must not allow an active open for a broadcast or multicast foreign address 1150 Yes and no: TCP will not send segments to a broadcast address because the call to ip_output in Figure 26.32 does not specify the SO_BROADCAST option Net/3, however, allows connection attempts to multicast addresses x Must ignore incoming SYNs with an invalid source address Yes: The code in Figure 28.16 checks for these invalid source addresses Closing Connections x Should allow an RST to contain data No: The RST processing in Figure 28.36 ends up jumping to drop, which skips the processing of any segment data in Figure 29.22 x Must inform process whether other end closed the connection normally (e.g., sent a FIN) or aborted the connection with an RST Yes: The read system calls return (end-of-file) when the FIN is processed, but —1 with an error of ECONNRESET when an RST is received x May implement a half-close Yes: The process calls shutdown with a second argument of to send a FIN The process can still read from the connection x If the process completely closes a connection (i.e., not a half-close) and received data is still pending in TCP, or if new data arrives after the close, TCP should send an RST to indicate data was lost No and yes: If a process calls close and unread data is in the socket’s receive buffer, an RST is not sent But if data arrives after a socket is closed, an RST is returned to the sender x Must linger in TIME_WAIT state for twice the MSL Yes, although the Net/3 MSL of 30 seconds is much smaller than the RFC 793 recommended value of minutes x May accept a new SYN from a peer to reopen a connection directly from the TIME_WAIT state Yes, as shown in Figure 28.29 Retransmissions x Must implement Van Jacobson’s slow start and congestion avoidance Yes x May reuse the same IP identifier field when a retransmission is identical to the original packet 1151 No: The IP identifier is assigned by ip_output from the global variable ip_id, which increments each time an IP datagram is sent It is not assigned by TCP x Must implement Jacobson’s algorithm for calculating the RTO and Karn’s algorithm for selecting the RTT measurements Yes, but realize that when RFC 1323 timestamps are present, the retransmission ambiguity problem is gone, obviating half of Karn’s algorithm, as we discussed with Figure 29.6 x Must include an exponential backoff for successive RTO values Yes, as described with Figure 25.22 x Retransmission of SYN segments should use the same algorithm as data segments Yes, as shown in Figure 25.15 x Should initialize estimation parameters to calculate an initial RTO of seconds No: The initial value of t_rxtcur calculated by tcp_newtcpcb is seconds This is also seen in Figure 25.15 x Should have a lower bound on the RTO measured in fractions of a second and an upper bound of twice the MSL No: The lower bound is second and the upper bound is 64 seconds (Figure 25.3) Generating ACKs x Should queue out-of-order segments Yes, done by tcp_reass x Must process all queued segments before sending any ACKs Yes, but only for in-order segments ipintr calls tcp_input for each queued datagram that is a TCP segment For in-order segments, tcp_input schedules a delayed ACK and returns to ipintr If there are additional TCP segments on IP’s input queue, tcp_input is called by ipintr for each one Only when ipintr finds no more IP datagrams on its input queue and returns can tcp_fasttimo be called to generate a delayed ACK This ACK will contain the highest acknowledgment number in all the segments processed by tcp_input The problem is with out-of-order segments: tcp_input calls tcp_output itself, before returning to ipintr, to generate the ACK for the out-of-order segment If there are additional segments on IP’s input queue that would have made the out-of-order segment be in order, they are processed after the immediate ACK is sent x May generate an immediate ACK for an out-of-order segment Yes, this is needed for the fast retransmit and fast recovery algorithms (Section 29.4) x Should implement delayed ACKs and the delay must be less than 0.5 seconds 1152 Yes: The TF_DELACK flag is checked by the tcp_fasttimo function every 200 ms x Should send an ACK for at least every second segment Yes, the code in Figure 26.9 generates an ACK for every second segment We also discussed that this happens only if the process receiving the data reads the data as it arrives, since the calls to tcp_output that cause every other segment to be acknowledged are driven by the PRU_RCVD request x Must include silly window syndrome avoidance in the receiver Yes, as seen in Figure 26.29 Sending Data x The TTL value for TCP segments must be configurable Yes: The TTL is initialized to 64 (IPDEFTTL) by tcp_newtcpcb, but can then be changed by a process using the IP_TTL socket option x Must include sender silly window syndrome avoidance Yes, in Figure 26.8 x Should implement the Nagle algorithm Yes, in Figure 26.8 x Must allow a process to disable the Nagle algorithm on a given connection Yes, with the TCP_NODELAY socket option Connection Failures x Must pass negative advice to IP when the number of retransmissions for a given segment exceeds some value R1 Yes: The value of R1 is 4, and in Figure 25.26, when the number of retransmissions exceeds 4, in_losing is called x Must close a connection when the number of retransmissions for a given segment exceeds some value R2 Yes: The value of R2 is 12 (Figure 25.26) x Must allow process to set the value of R2 No: The value 12 is hardcoded in Figure 25.26 x Should inform the process when R1 is reached and before R2 is reached No 1153 x Should default R1 to at least retransmissions and R2 to at least 100 seconds Yes: R1 is retransmissions, and with a minimum RTO of second, the tcp_backoff array (Section 25.9) guarantees a minimum value of R2 of over 500 seconds x Must handle SYN retransmissions in the same general way as data retransmissions Yes, but R1 is normally not reached for the retransmission of a SYN (Figure 25.15) x Must set R2 to at least minutes for a SYN No: R2 for a SYN is limited to 75 seconds by the connection-establishment timer (Figure 25.15) Keepalive Packets x May provide keepalives Yes, they are provided x Must allow process to turn keepalives on or off, and must default to off Yes: Default is off and process must turn them on with the SO_KEEPALIVE socket option x Must send keepalives only when connection is idle for a given period Yes x Must allow the keepalive interval to be configurable and must default to no less than hours No and yes: The idle time before sending keepalive probes is not easily configurable, but it defaults to hours If the default idle time is changed (by changing the global variable tcp_keepidle), it affects all users of the keepalive option on the host it cannot be configured on a per-connection basis as many users would like x Must not interpret the failure to respond to any given probe as a dead connection Yes: Nine probes are sent before the connection is considered dead IP Options x Must ignore received IP options it doesn’t understand Yes: This is done by the IP layer x May support the timestamp and record route options in received segments No: Net/3 only reflects these options for ICMP packets that are reflected back to the sender (icmp_reflect) tcp_input discards any received IP options by calling ip_stripoptions in Figure 28.2 1154 x Must allow process to specify a source route when a connection is actively opened, and this route must take precedence over a source route received for this connection Yes: The source route is specified with the IP_OPTIONS socket option tcp_input never looks at a received source route when the connection is actively opened x Must save a received source route in a connection that is passively opened and use the return route for all segments sent on this connection If a different source route arrives in a later segment, the later route should override the earlier one Yes and no: Figure 28.7 calls ip_srcroute, but only when the SYN arrives for a listening socket If a different source route arrives later, it is not used Receiving ICMP Messages from IP x Receipt of an ICMP source quench should trigger slow start Yes: The function tcp_quench is called by tcp_ctlinput x Receipt of a network unreachable, host unreachable, or source route failed must not cause TCP to abort the connection and the process should be informed Yes and no: As described following Figure 27.12, Net/3 now completely ignores host unreachable and network unreachable errors for an established connection x Receipt of a protocol unreachable, port unreachable, or fragmentation required and DF bit set should abort an existing connection No: tcp_notify records these ICMP errors in t_softerror, which is reported to the process if the connection is eventually dropped x Should handle time exceeded and parameter problem errors the same as required previously for network and host unreachable Yes: ICMP parameter problem errors are just recorded in t_softerror by tcp_notify ICMP time exceeded errors are ignored by tcp_ctlinput Neither type of ICMP error causes the connection to be aborted Application Programming Interface x Must be a method for reporting soft errors to the process, normally in an asynchronous fashion No: Soft errors are returned to the process if the connection is aborted x Must allow process to specify TOS for segments sent on a connection Should let application change this during a connection’s lifetime Yes to both, with the IP_TOS socket option x May pass most recently received TOS to process 1155 No: There is no way to this with the sockets API Calling getsockopt for IP_TOS returns only the current value being sent; it does not return the most recently received value x May implement a "flush" call No: TCP sends the data from the process as quickly as it can x Must allow process to specify local IP address before either an active open or a passive open Yes: This is done by calling bind before either connect or accept 1156 Bibliography All the RFCs are available at no charge through electronic mail or by using anonymous FTP across the Internet as described in Appendix B Whenever the authors were able to locate an electronic copy of papers and reports referenced in this bibliography, its URL (Uniform Resource Locator, Appendix B) is included Almquist, P 1992 "Type of Service in the Internet Protocol Suite," RFC 1349, 28 pages (July) Almquist, P., and Kastenholz, F J 1994 "Towards Requirements for IP Routers," RFC 1716, 186 pages (Nov.) This RFC is an intermediate step to replace RFC 1009 [Braden and Postel 1987] Auerbach, K 1994 "Max IP Packet Length and MTU," Message-ID , Usenet, comp.protocols.tcp-ip Newsgroup (July) Boggs, D R 1982 "Internet Broadcasting," Xerox PARC CSL-83-3, Stanford University, Palo Alto, Calif (Jan.) Braden, R T., ed 1989a "Requirements for Internet Hosts Com munication Layers," RFC 1122, 116 pages (Oct.) The first half of the Host Requirements RFC This half covers the link layer, IP, TCP, and UDP Braden, R T., ed 1989b "Requirements for Internet Hosts A pplication and Support," RFC 1123, 98 pages (Oct.) The second half of the Host Requirements RFC This half covers Telnet, FTP, TFTP, SMTP, and the DNS Braden, R T 1989c "Perspective on the Host Requirements RFCs," RFC 1127, 20 pages (Oct.) An informal summary of the discussions and conclusions of the IETF working group that developed the Host Requirements RFC Braden, R T 1992 "TIME-WAIT Assassination Hazards in TCP," RFC 1337, 11 pages (May) Shows how the receipt of an RST while in the TIME_WAIT state can lead to problems Braden, R T 1993 "TCP Extensions for High Performance: An Update," Internet Draft, 10 pages (June) This is an update to RFC 1323 [Jacobson, Braden, and Borman 1992] http://www.noao.edu/~rstevens/tcplw-extensions.txt Braden, R T 1994 "T/TCP TCP Ext ensions for Transactions, Functional Specification," RFC 1644, 38 pages (July) Braden, R T., Borman, D A., and Partridge, C 1988 "Computing the Internet Checksum," RFC 1071, 24 pages (Sept.) Provides techniques and algorithms for calculating the checksum used by IP, ICMP, IGMP, UDP, and TCP Braden, R T., and Postel, J B 1987 "Requirements for Internet Gateways," RFC 1009, 55 pages (June) The equivalent of the Host Requirements RFC for routers This RFC is being replaced by RFC 1716 [Almquist and Kastenholz 1994] 1157 Brakmo, L S., O’Malley, S W., and Peterson, L L 1994 "TCP Vegas: New Techniques for Congestion Detection and Avoidance," Computer Communication Review, vol 24, no 4, pp 24—35 (Oct.) Describes modifications to the 4.3BSD Reno TCP implementation to improve throughput and reduce retransmissions ftp://ftp.cs.arizona.edu/xkernel/Papers/vegas.ps Carlson, J 1993 "Re: Bug in Many Versions of TCP," Message-ID , Usenet, comp.protocols.tcp-ip Newsgroup (July) Casner, S., 1993 "Frequently Asked Questions (FAQ) on the Multicast Backbone (MBONE)," (May) ftp://ftp.isi.edu/mbone/faq.txt Cheswick, W R., and Bellovin, S M 1994 "Firewalls and Internet Security: Repelling the Wily Hacker" Addison-Wesley, Reading, Mass Describes how to set up and administer a firewall gateway and the security issues involved Clark, D D 1982 "Modularity and Efficiency in Protocol Implementation," RFC 817, 26 pages (July) Comer, D E., and Lin, J C 1994 "TCP Buffering and Performance Over an ATM Network," Purdue Technical Report CSD-TR 94-026, Purdue University, West Lafayette, Ind (Mar.) ftp://gwen.cs.purdue.edu/pub/lin/TCP.atm.ps.Z Comer, D E., and Stevens, D L 1993 "Internetworking with TCP/IP: Vol III: Client–Server Programming and Applications, BSD Socket Version." Prentice-Hall, Englewood Cliffs, N.J Croft, W., and Gilmore, J 1985 "Bootstrap Protocol (BOOTP)," RFC 951, 12 pages (Sept.) Crowcroft, J., Wakeman, I., Wang, Z., and Sirovica, D 1992 "Is Layering Harmful?," IEEE Network, vol 6, no 1, pp 20—24 (Jan.) The seven missing figures from this paper appear in the next issue, vol 6, no (March) Dalton, C., Watson, G., Banks, D., Calamvokis, C., Edwards, A., and Lumley, J 1993 "Afterburner," IEEE Network, vol 7, no 4, pp 36—43 (July) Describes how to speed up TCP by reducing the number of data copies performed, and a specialpurpose interface card that supports this design Deering, S E 1989 "Host Extensions for IP Multicasting," RFC 1112, 17 pages (Aug.) The specification of IP multicasting and IGMP Deering, S E., ed 1991a "ICMP Router Discovery Messages," RFC 1256, 19 pages (Sept.) Deering, S E 1991b "Multicast Routing in a Datagram Internetwork," STAN-CS-92-1415, Stanford University, Palo Alto, Calif (Dec.) ftp://gregorio.stanford.edu/vmtp-ip/sdthesis.part1.ps.Z Deering, S E., and Cheriton, D P 1990 "Multicast Routing in Datagram Internetworks and Extended LANs," ACM Transactions on Computer Systems, vol 8, no 2, pp 85—110 (May) Proposes extensions to common routing techniques to support multicasting Deering, S E., Estrin, D., Farinacci, D., Jacobson, V., Liu, C., and Wei, L 1994 "An Architecture for Wide-Area Multicast Routing," Computer Communication Review, vol 24, no 4, pp 126—135 (Oct.) Droms, R 1993 "Dynamic Host Configuration Protocol," RFC 1541, 39 pages (Oct.) 1158 Finlayson, R., Mann, T., Mogul, J C., and Theimer, M 1984 "A Reverse Address Resolution Protocol," RFC 903, pages (June) Floyd, S 1994 Private Communication Forgie, J 1979 "ST A Proposed Internet Stream Protocol," IEN 119, MIT Lincoln Laboratory (Sept.) Fuller, V., Li, T., Yu, J Y., and Varadhan, K 1993 "Classless Inter-Domain Routing (CIDR): An Address Assignment and Aggregation Strategy," RFC 1519, 24 pages (Sept.) Hornig, C 1984 "Standard for the Transmission of IP Datagrams over Ethernet Networks," RFC 894, pages (Apr.) Hutchinson, N C., and Peterson, L L 1991 "The x-Kernel: An Architecture for Implementing Network Protocols," IEEE Transactions on Software Engineering, vol 17, no 1, pp 64—76 (Jan.) ftp://ftp.cs.arizona.edu/xkernel/Papers/architecture.ps Itano, W M., and Ramsey, N F 1993 "Accurate Measurement of Time," Scientific American, vol 269, p 56 (July) Overview of historical and current methods for accurate timekeeping Includes a short discussion of international time scales including International Atomic Time (TAI) and Coordinated Universal Time (UTC) Jacobson, V 1988a "Some Interim Notes on the BSD Network Speedup," Message-ID , Usenet, comp.protocols.tcp-ip Newsgroup (July) Jacobson, V 1988b "Congestion Avoidance and Control," Computer Communication Review, vol 18, no 4, pp 314—329 (Aug.) A classic paper describing the slow start and congestion avoidance algorithms for TCP ftp://ftp.ee.lbl.gov/papers/congavoid.ps.Z Jacobson, V 1990a "Compressing TCP/IP Headers for Low-Speed Serial Links," RFC 1144, 43 pages (Feb.) Describes CSLIP, a version of SLIP with the TCP and IP headers compressed Jacobson, V 1990b "4BSD TCP Header Prediction," Computer Communication Review, vol 20, no 2, pp 13—15 (Apr.) Jacobson, V 1990c "Modified TCP Congestion Avoidance Algorithm," April 30, 1990, end2endinterest mailing list (Apr.) Describes the fast retransmit and fast recovery algorithms ftp://ftp.isi.edu/end2end/end2end-interest-1990.mail Jacobson, V 1990d "Berkeley TCP Evolution from 4.3-Tahoe to 4.3-Reno," Proceedings of the Eighteenth Internet Engineering Task Force, University of British Columbia, Vancouver, B.C p 365 (Sept.) Jacobson, V 1993 "Some Design Issues for High-Speed Networks," Networkshop '9, Melbourne, Australia (Nov.) A set of 21 overheads ftp://ftp.ee.lbl.gov/talks/vj-nws93-1.ps.Z Jacobson, V., and Braden, R T 1988 "TCP Extensions for Long-Delay Paths," RFC 1072, 16 pages (Oct.) 1159 Describes the selective acknowledgment option for TCP, which was removed from the later RFC 1323, and the echo options, which were replaced with the timestamp option in RFC 1323 Jacobson, V., Braden, R T., and Borman, D A 1992 "TCP Extensions for High Performance," RFC 1323, 37 pages (May) Describes the window scale option, the timestamp option, and the PAWS algorithm, along with the reasons these modifications are needed [Braden 1993] updates this RFC Jain, R., and Routhier, S A 1986 "Packet Trains: Measurements and a New Model for Computer Network Traffic," IEEE Journal on Selected Areas in Communications, vol 4, pp 1162—1167 Karels, M J., and McKusick, M K 1986 "Network Performance and Management with 4.3BSD and IP/TCP," Proceedings of the 1986 Summer USENIX Conference, Atlanta, Ga pp 182—188 Describes the changes made from 4.2BSD to 4.3BSD with regard to TCP/IP Karn, P., and Partridge, C 1987 "Improving Round-Trip Time Estimates in Reliable Transport Protocols," Computer Communication Review, vol 17, no 5, pp 2—7 (Aug.) Details of Karn’s algorithm to handle the retransmission timeout for segments that have been retransmitted ftp://sics.se/users/craig/karn-partridge.ps Kay, J., and Pasquale, J 1993 "The Importance of Non-Data Touching Processing Overheads in TCP/IP," Computer Communication Review, vol 23, no 4, pp 259—268 (Sept.) Kent, C A., and Mogul, J C 1987 "Fragmentation Considered Harmful," Computer Communication Review, vol 17, no 5, pp 390—401 (Aug.) Kernighan, B W., and Plauger, P J 1976 "Software Tools" Addison-Wesley, Reading, Mass Krol, E 1994 "The Whole Internet, Second Edition" O’Reilly & Associates, Sebastopol, Calif An introduction into the Internet, common Internet applications, and various resources available on the Internet Krol, E., and Hoffman, E 1993 "FYI on ‘What is the Internet?’," RFC 1462, 11 pages (May) Lanciani, D 1993 "Re: Bug in Many Versions of TCP," Message-ID , Usenet, comp.protocols.tcp-ip Newsgroup (July) Leffler, S J., McKusick, M K., Karels, M J., and Quarterman, J S 1989 The Design and Implementation of the 4.3BSD UNIX Operating System Addison-Wesley, Reading, Mass An entire book on the 4.3BSD Unix system This book describes the Tahoe release of 4.3BSD Lynch, D C 1993 "Historical Perspective," in Internet System Handbook, eds D C Lynch and M T Rose, pp 3—14 Addison-Wesley, Reading, Mass A historical overview of the Internet and its precursor, the ARPANET Mallory, T., and Kullberg, A 1990 "Incremental Updating of the Internet Checksum," RFC 1141, pages (Jan.) This RFC is updated by RFC 1624 [Rijsinghani 1994] Mano, M M 1993 Computer System Architecture, Third Edition Prentice-Hall, Englewood Cliffs, N.J McCanne, S., and Jacobson, V 1993 "The BSD Packet Filter: A New Architecture for User-Level Packet Capture," Proceedings of the 1993 Winter USENIX Conference, pp 259—269, San Diego, Calif 1160 A detailed description of the BSD Packet Filter (BPF) and comparisons with Sun’s Network Interface Tap (NIT) ftp://ftp.ee.lbl.gov/papers/bpf-usenix93.ps.Z McCloghrie, K., and Farinacci, D 1994a "Internet Group Management Protocol MIB," Internet Draft, 12 pages (Jul.) McCloghrie, K., and Farinacci, D 1994b "IP Multicast Routing MIB," Internet Draft, 15 pages (Jul) McCloghrie, K., and Rose, M T 1991 "Management Information Base for Network Management of TCP/IP-based Internets: MIB-II," RFC 1213 (Mar.) McGregor, G 1992 "PPP Internet Protocol Control Protocol (IPCP)," RFC 1332, 12 pages (May) McKenney, P E., and Dove, K F 1992 "Efficient Demultiplexing of Incoming TCP Packets," Computer Communication Review, vol 22, no 4, pp 269—279 (Oct.) Mogul, J C 1991 "Network Locality at the Scale of Processes," Computer Communication Review, vol 21, no 4, pp 273—284 (Sept.) Mogul, J C 1993 "IP Network Performance," in Internet System Handbook, eds D C Lynch and M T Rose, pp 575—675 Addison-Wesley, Reading, Mass Covers numerous topics in the Internet protocols that are candidates for tuning to obtain optimal performance Mogul, J C., and Deering, S E 1990 "Path MTU Discovery," RFC 1191, 19 pages (Apr.) Mogul, J C., and Postel, J B 1985 "Internet Standard Subnetting Procedure," RFC 950, 18 pages (Aug.) Moy, J 1994 "Multicast Extensions to OSPF," RFC 1584, 102 pages (Mar.) Olivier, G 1994 "What is the Diameter of the Internet?," Message-ID , Usenet, comp.unix.wizards Newsgroup (Jan.) Partridge, C 1987 "Implementing the Reliable Data Protocol (RDP)," Proceedings of the 1987 Summer USENIX Conference, pp 367—379, Phoenix, Ariz Partridge, C 1993 "Jacobson on TCP in 30 Instructions," Message-ID , Usenet, comp.protocols.tcp-ip Newsgroup (Sept.) Describes a research implementation of TCP/IP being developed by Van Jacobson that reduces TCP receive packet processing down to 30 instructions on a RISC system http://www.noao.edu/~rstevens/vanj.93sep07.txt Partridge, C., and Hinden, R 1990 "Version of the Reliable Data Protocol (RDP)," RFC 1151, pages (Apr.) Partridge, C., Mendez, T., and Milliken, W 1993 "Host Anycasting Service," RFC 1546, pages (Nov.) Partridge, C., and Pink, S 1993 "A Faster UDP," IEEE/ACM Transactions on Networking, vol 1, no 4, pp 429—440 (Aug.) Describes implementation improvements to the Berkeley sources to speed up UDP performance about 30% 1161 Paxson, V 1994 Private Communication Perlman, R 1992 "Interconnections: Bridges and Routers." Addison-Wesley, Reading, Mass Piscitello, D M., and Chapin, A L 1993 Open Systems Networking: TCP/IP and OSI AddisonWesley, Reading, Mass Plummer, D C 1982 "An Ethernet Address Resolution Protocol," RFC 826, 10 pages (Nov.) Postel, J B., ed 1981a "Internet Protocol," RFC 791, 45 pages (Sept.) Postel, J B 1981b "Internet Control Message Protocol," RFC 792, 21 pages (Sept.) Postel, J B., ed 1981c "Transmission Control Protocol," RFC 793, 85 pages (Sept.) Postel, J B 1981d "Service Mappings," RFC 795, pages (Sept.) Postel, J B., and Reynolds, J K 1988 "Standard for the Transmission of IP Datagrams over IEEE 802 Networks," RFC 1042, 15 pages (Apr.) Rago, S A 1993 "UNIX System V Network Programming." Addison-Wesley, Reading, Mass Reynolds, J K., and Postel, J B 1994 "Assigned Numbers," RFC 1700, 230 pages (Oct.) Rijsinghani, A 1994 "Computation of the Internet Checksum via Incremental Update," RFC 1624, pages (May) An update to RFC 1141 [Mallory and Kullberg 1990] Romkey, J L 1988 "A Nonstandard for Transmission of IP Datagrams Over Serial Lines: SLIP," RFC 1055, pages (June) Rose, M T 1990 "The Open Book: A Practical Perspective on OSI." Prentice-Hall, Englewood Cliffs, N.J Salus, P H 1994 "A Quarter Century of Unix." Addison-Wesley, Reading, Mass Sedgewick, R 1990 "Algorithms in C." Addison-Wesley, Reading, Mass Simpson, W A 1993 "The Point-to-Point Protocol (PPP)," RFC 1548, 53 pages (Dec.) Sklower, K 1991 "A Tree-Based Packet Routing Table for Berkeley Unix," Proceedings of the 1991 Winter USENIX Conference, pp 93—99, Dallas, Tex Stallings, W 1987 "Handbook of Computer-Communications Standards, Volume 2: Local Network Standards." Macmillan, New York Stallings, W 1993 "Networking Standards: A Guide to OSI, ISDN, LAN, and MAN Standards." Addison-Wesley, Reading, Mass Stevens, W R 1990 "UNIX Network Programming." Prentice-Hall, Englewood Cliffs, N.J Stevens, W R 1992 "Advanced Programming in the UNIX Environment." Addison-Wesley, Reading, Mass 1162 Stevens, W R 1994 "TCP/IP Illustrated, Volume 1: The Protocols." Addison-Wesley, Reading, Mass The first volume in this series, which provides a complete introduction to the Internet protocols Tanenbaum, A S 1989 "Computer Networks, Second Edition." Prentice-Hall, Englewood Cliffs, N.J Topolcic, C 1990 "Experimental Stream Protocol, Version (SY-II)," RFC 1190, 148 pages (Oct.) Torek, C 1992 "Re: A Problem in Bind System Call," Message-ID , Usenet, comp.unix.internals Newsgroup (Nov.) Waitzman, D., Partridge, C., and Deering, S E 1988 "Distance Vector Multicast Routing Protocol," RFC 1075, 24 pages (Nov.) 1163 ... insque 292 ip_ ctloutput 241 ip_ deq 292 ip_ dooptions 251 ip_ drain 299 ip_ enq 292 ip_ forward 222 ip_ freef 299 ip_ getmoptions 372 ip_ init 200 ip_ insertoptions 266 ipintr 213 ip_ mforward 426 ip_ mloopback... 898 tcp_ newtcpcb 833 tcp_ notify 905 tcp_ output 853 tcp_ pulloutofband 986 tcp_ quench 906 tcp_ rcvseqinit 946 TCP_ REASS 908 tcp_ reass 911 tcp_ respond 886 TCP_ REXMTVAL 840 tcp_ sendseqinit 946 tcp_ setpersist... 638 tcp_ attach 1019 xxix tcp_ canceltimers 821 tcp_ close 895 tcp_ ctlinput 904 tcp_ ctloutput 1022 tcp_ disconnect 1020 tcp_ dooptions 933 tcp_ drop 893 tcp_ fasttimo 821 tcp_ init 812 tcp_ input 926 tcp_ mss

Ngày đăng: 17/11/2019, 08:32

Từ khóa liên quan

Mục lục

  • Table of Contents

  • Copyright

  • Preface

  • Chapter 1. Introduction

    • Section 1.1. Introduction

    • Section 1.2. Source Code Presentation

    • Section 1.3. History

    • Section 1.4. Application Programming Interfaces

    • Section 1.5. Example Program

    • Section 1.6. System Calls and Library Functions

    • Section 1.7. Network Implementation Overview

    • Section 1.8. Descriptors

    • Section 1.9. Mbufs (Memory Buffers) and Output Processing

    • Section 1.10. Input Processing

    • Section 1.11. Network Implementation Overview Revisited

    • Section 1.12. Interrupt Levels and Concurrency

    • Section 1.13. Source Code Organization

    • Section 1.14. Test Network

    • Section 1.15. Summary

    • Chapter 2. Mbufs: Memory Buffers

      • Section 2.1. Introduction

      • Section 2.2. Code Introduction

Tài liệu cùng người dùng

  • Đang cập nhật ...

Tài liệu liên quan