您的位置:首页 > 其它

!!!Chapter 5 The Network Layer

2014-01-07 23:31 579 查看
网络层涉及
分组从源端-〉目的端
处理端到端数据传输的最低层

数据链路层涉及
数据帧从导线的一端到另一端

5.1 Network Layer Design Issues

Services the network layer provides to the transport layer:

The services should be independent of the router technology
The transport layer should be shielded from the number, type, and topology of the routers present
The network addresses made available to the transport layer should use a uniform plan, even across LANs and WANs.

5.6 The Network Layer In the Internet

Communication in the Internet works as follows. The transport layer takes data streams and breaks them up so that they may be sent as IP packets. In theory, packets can be up to 64 KB each, but in practice they are usually not more than 1500 bytes (so they
fit in one Ethernet frame). IP routers forward each packet through the Internet, along a path from one router to the next, until the destination is reached. At the destination, the network layer hands the data to the transport layer, which gives it to the
receiving process. When all the pieces finally get to the destination machine, they are reassembled by the network layer into the original datagram. This datagram is then handed to the transport layer.

5.6.1 The IP Version 4 Protocol

An IPv4 datagram consists of a header part and a body or payload part. The header has a 20-byte fixed part and a variable-length optional part.

The bits are transmitted from left to right and top to bottom, with the high-order bit of the Version field going first.



The Version field keeps track of which version of the protocol the datagram belongs to.

The Total length includes everything in the datagram—both header and data. The maximum length is 65,535 bytes.

The Identification field is needed to allow the destination host to determine which packet a newly arrived fragment belongs to. All the fragments of a packet contain the same Identification value.

DF stands for Don’t Fragment.By marking the datagram with the DF bit, the sender knows it will either arrive in one piece, or an error message will be returned to the sender.

MF stands for More Fragments. All fragments except the last one have this bit set. It is needed to know when all fragments of a datagram have arrived.

The Fragment offset tells where in the current packet this fragment belongs. All fragments except the last one in a datagram must be a multiple of 8 bytes, the elementary fragment unit. Since 13 bits are
provided, there is a maximum of 8192 fragments per datagram, supporting a maximum packet length up to the limit of the Total length field. Working together, the Identification, MF, and Fragment offset fields are used to implement fragmentation

The TtL (Time to live) field is a counter used to limit packet lifetimes. When it hits zero, the packet is discarded and a warning packet is sent back to the source host.

The Protocol field tells it which transport process to give the packet to. TCP is one possibility, but so are UDP and some others. The numbering of protocols is global across the entire Internet.

Since the header carries vital information such as addresses, it rates its own checksum for protection, theHeader checksum.

The Options field was designed to provide an escape to allow subsequent versions of the protocol to include information not present in the original design, to permit experimenters to try out new ideas,
and to avoid allocating header bits to information that is rarely needed.

5.6.2 IP Addresses

A defining feature of IPv4 is its 32-bit addresses. Every host and router on the Internet has an IP address that can be used in the Source address and Destination address fields of IP packets. It is important to note that an IP address does not actually
refer to a host. It really refers to a network interface, so if a host is on two networks, it must have two IP addresses. However, in practice, most hosts are on one network and thus have one IP address. In contrast, routers have multiple interfaces and thus
multiple IP addresses.

Prefix:

IP addresses are hierarchical, unlike Ethernet addresses. Each 32-bit address is comprised of a variable-lengthnetwork portion in the top bits and ahost portion in the bottom bits. The network portion has the same value
for all hosts on a single network, such as an Ethernet LAN. This means that a network corresponds to a contiguous block of IP address space. This block is called aprefix.

Since the prefix length cannot be inferred from the IP address alone, routing protocols must carry the prefixes to routers. Sometimes prefixes are simply described by their length, as in a ‘‘/16’’ which is pronounced ‘‘slash 16.’’ The length of the prefix
corresponds to a binary mask of 1s in the network portion. When written out this way, it is called a subnet mask. It can be ANDed with the IP address to extract only the network portion.



+ The key advantage of prefixes is that routers can forward packets based on only the network portion of the address, as long as each of the networks has a unique address block.

- the IP address of a host depends on where it is located in the network. An Ethernet address can be used anywhere in the world, but every IP address belongs to a specific network

- the hierarchy is wasteful of addresses unless it is carefully managed

subnet:             P 444



How to distribute package:   P 445

5.6.3 IP Version 6



The Version field is always 6 for IPv6 (and 4 for IPv4).

The Differentiated services field (originally called Traffic class) is used to distinguish the class of service for packets with different real-time delivery requirements.

The Payload length field tells how many bytes follow the 40-byte header of Fig. 5-56. The name was changed from the IPv4 Total length field because the meaning was changed slightly: the 40 header bytes
are no longer counted as part of the length (as they used to be). This change means the payload can now be 65,535 bytes instead of a mere 65,515 bytes.

The Next header tells which of the (currently) six extension headers, if any, follow this one.

The Hop limit field is used to keep packets from living forever.

IP Address

A new notation has been devised for writing 16-byte addresses. They are written as eight groups of four hexadecimal digits with colons between the groups, like this:

8000:0000:0000:0000:0123:4567:89AB:CDEF

Since many addresses will have many zeros inside them, three optimizations have been authorized
4000
. First, leading zeros within a group can be omitted, so 0123 can be written as 123. Second, one or more groups of 16 zero bits can be replaced by a pair of colons.
Thus, the above address now becomes

8000::123:4567:89AB:CDEF

Finally, IPv4 addresses can be written as a pair of colons and an old dotted decimal number, for example:

::192.31.20.46
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: