TCP/IP Illustrated学习笔记(2)

接着上回的内容,IP首部里有首部检验和字段,它是根据IP首部计算的检验和码,不对后面的数据段进行计算,实际上如果后面跟着是TCP报文或者是UDP报文,其相应的TCP首部或者UDP首部都有其首部与数据的检验和,其中TCP的检验和是必须的,UDP的为可选。其基本方法就是对其的每16bit进行反码求和,如果接收方发现检验和错误,IP就丢弃收到的数据报,但不产生ICMP差错报文,由上层的TCP与UDP发现与重传。

PS:检验和字段只是对每个16bit反码求和,所以如果源地址与目的地址的值互换的话,检验和的结果还是不变。

IP的路由选择:

1、搜索路由表,寻找与目的地址完全匹配的表目

2、寻找与目的网络号相匹配的条目

3.寻找标为“default”的表目。如果找到,则把数据报发送给该条目指定的下一个路由器

如果上面步骤都没有成功,那么该数据报不被传送,如果不能传送的数据报来自本机,则产生一个 “主机不可达” 或 “网络不可达”的错误。

图一

上图为SUN主机的路由表

Flags中:U代表可用的路由

  G代表其为一个间接路由,没有设置这个位代表直接相连

 H代表目的地址是一个完整的主机地址,若没设置这个位则代表其为网络地址

图二

上图:bsdi主机发送数据报给sun主机(当然先通过DNS域名解析系统将主机名映射为IP地址),bsdi通过搜索自己的路由表发现目的地址与自己在同一个网络内,它就向以太网上的每个主机广播一个ARP请求(点对点链路不适用ARP),要IP地址为目的地址的主机发送一份ARP应答,告诉发送端自己的硬件地址(ARP应答),然后才可以建立连接,发送数据

PS:如若bsdi主机与sun主机频繁通信,则在bsdi和sun的ARP缓冲中都有对方48bit的硬件地址,其是ARP高效运行的关键

图三bsdi发送数据到ftp.uu.net(IP:192.48.96.9)

上图:1、首先bsdi查看自己的路由表发现没有对应的主机地址或网络地址,则只能使用默认路由,即SUN主机

2、数据到达SUN后,sun发现自己的地址与最终目的IP不同,其又被设置为具有路由功能,所以其对数据进行转发,根据图一发现其默认的路由为netb140.252.1.183(通过标志位发现其为一个间接相连的路由及网络地址)

3、netb把数据传送给gateway,它们执行与sun相同的路由步骤,gateway则把数据送出到外网中

PS:直接路由与间接路由的区别:

直接路由如图二:bsdi其发送的目的地址与链路层地址是一样的

间接路由如图三:bsdi其发送的目的地址与链路层地址不一样


这篇就这样吧,下回关于ICMP时间戳、ping程序与traceroute程序以及ifconfig与netstat

Introduction This book describes the TCP/IP protocol suite, but from a different perspective than other texts on TCP/IP. Instead of just describing the protocols and what they do, we'll use a popular diagnostic tool to watch the protocols in action. Seeing how the protocols operate in varying circumstances provides a greater understanding of how they work and why certain design decisions were made. It also provides a look into the implementation of the protocols, without having to wade through thousands of lines of source code. When networking protocols were being developed in the 1960s through the 1980s, expensive, dedicated hardware was required to see the packets going "across the wire." Extreme familiarity with the protocols was also required to comprehend the packets displayed by the hardware. Functionality of the hardware analyzers was limited to that built in by the hardware designers. Today this has changed dramatically with the ability of the ubiquitous workstation to monitor a local area network Mogul 1990. Just attach a workstation to your network, run some publicly available software (described in Appendix A), and watch what goes by on the wire. While many people consider this a tool to be used for diagnosing network problems, it is also a powerful tool for understanding how the network protocols operate, which is the goal of this book. This book is intended for anyone wishing to understand how the TCP/IP protocols operate: programmers writing network applications, system administrators responsible for maintaining computer systems and networks utilizing TCP/IP, and users who deal with TCP/IP applications on a daily basis. Organization of the Book We take a bottom-up approach to the TCP/IP protocol suite. After providing a basic introduction to TCP/IP in Chapter 1, we will start at the link layer in Chapter 2 and work our way up the protocol stack. This provides the required background for later chapters for readers who aren't familiar with TCP/IP or networking in general. This book also uses a functional approach instead of following a strict bottom-to-top order. For example, Chapter 3 describes the IP layer and the IP header. But there are numerous fields in the IP header that are best described in the context of an application that uses or is affected by a particular field. Fragmentation, for example, is best understood in terms of UDP (Chapter 11), the protocol often affected by it. The time-to-live field is fully described when we look at the Traceroute program in Chapter 8, because this field is the basis for the operation of the program. Similarly, many features of ICMP are described in the later chapters, in terms of how a particular ICMP message is used by a protocol or an application. We also don't want to save all the good stuff until the end, so we describe TCP/IP applications as soon as we have the foundation to understand them. Ping and Traceroute are described after IP and ICMP have been discussed. The applications built on UDP (multicasting, the DNS, TFTP, and BOOTP) are described after UDP has been examined. The TCP applications, however, along with network management, must be saved until the end, after we've thoroughly described TCP. This text focuses on how these applications use the TCP/IP protocols. We do not provide all the details on running these applications. Readers This book is self-contained and assumes no specific knowledge of networking or TCP/IP. Numerous references are provided for readers interested in additional details on specific topics. This book can be used in many ways. It can be used as a self-study reference and covered from start to finish by someone interested in all the details on the TCP/IP protocol suite. Readers with some TCP/IP background might want to skip ahead and start with Chapter 7, and then focus on the specific chapters in which they're interested. Exercises are provided at the end of the chapters, and most solutions are in Appendix D. This is to maximize the usefulness of the text as a self-study reference. When used as part of a one- or two-semester course in computer networking, the focus should be on IP (Chapters 3 and 9), UDP (Chapter 11), and TCP (Chapters 17-24), along with some of the application chapters. Many forward and backward references are provided throughout the text, along with a thorough index, to allow individual chapters to be studied by themselves. A list of all the acronyms used throughout the text, along with the compound term for the acronym, appears on the inside back covers. If you have access to a network you are encouraged to obtain the software used in this book (Appendix F) and experiment on your own. Hands-on experimentation with the protocols will provide the greatest knowledge (and make it more fun). Systems Used for Testing Every example in the book was run on an actual network and the resulting output saved in a file for inclusion in the text. Figure 1.11 (p. 18) shows a diagram of the different hosts, routers, and networks that are used. (This figure is also duplicated on the inside front cover for easy reference while reading the book.) This collection of networks is simple enough that the topology doesn't confuse the examples, and with four systems acting as routers, we can see the error messages generated by routers. Most of the systems have a name that indicates the type of software being used: bsdi, svr4, sun, solaris, aix, slip, and so on. In this way we can identify the type of software that we're dealing with by looking at the system name in the printed output. A wide range of different operating systems and TCP/IP implementations are used: BSD/386 Version 1.0 from Berkeley Software Design, Inc., on the hosts named bsdi and slip. This system is derived from the BSD Networking Software, Release 2.0. (We show the lineage of the various BSD releases in Figure 1.10 on p. 17.) Unix System V/386 Release 4.0 Version 2.0 from U.H. Corporation, on the host named svr4. This is vanilla SVR4 and contains the standard implementation of TCP/IP from Lachman Associates used with most versions of SVR4. SunOS 4.1.3 from Sun Microsystems, on the host named sun. The SunOS 4.1.x systems are probably the most widely used TCP/IP implementations. The TCP/IP code is derived from 4.2BSD and 4.3BSD. Solaris 2.2 from Sun Microsystems, on the host named solaris. The Solaris 2.x systems have a different implementation of TCP/IP from the earlier SunOS 4.1.x systems, and from SVR4. (This operating system is really SunOS 5.2, but is commonly called Solaris 2.2.) AIX 3.2.2 from IBM on the host named aix. The TCP/IP implementation is based on the 4.3BSD Reno release. 4.4BSD from the Computer Systems Research Group at the University of California at Berkeley, on the host vangogh.cs.berkeley.edu. This system has the latest release of TCP/IP from Berkeley. (This system isn't shown in the figure on the inside front cover, but is reachable across the Internet.) Although these are all Unix systems, TCP/IP is operating system independent, and is available on almost every popular non-Unix system. Most of this text also applies to these non-Unix implementations, although some programs (such as Traceroute) may not be provided on all systems. Typographical Conventions When we display interactive input and output we'll show our typed input in a bold font, and the computer output like this. Comments are added in italics. Also, we always include the name of the system as part of the shell prompt (bsdi in this example) to show on which host the command was run. Throughout the text we'll use indented, parenthetical notes such as this to describe historical points or implementation details. We sometimes refer to the complete description of a command in the Unix manual as in ifconfig(8). This notation, the name of the command followed by a number in parentheses, is the normal way of referring to Unix commands. The number in parentheses is the section number in the Unix manual of the "manual page" for the command, where additional information can be located. Unfortunately not all Unix systems organize their manuals the same, with regard to the section numbers used for various groupings of commands. We'll use the BSD-style section numbers (which is the same for BSD-derived systems such as SunOS 4.1.3), but your manuals may be organized differently. Acknowledgments Although the author's name is the only one to appear on the cover, the combined effort of many people is required to produce a quality text book. First and foremost is the author's family, who put up with the long and weird hours that go into writing a book. Thank you once again, Sally, Bill, Ellen, and David. The consulting editor, Brian Kernighan, is undoubtedly the best in the busin...
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值