Bridges are link-level nodes (they forward frames from one link to another to implement an extended LAN), switches are network-level nodes (they forward packets from one link to another to implement a packet-switched network), and routers are internet-level nodes(they forward datagrams from one network to another to implement an internet). Switch transmit later-2 packets(Ethernet);Router transmit IP datagrams.
Internetworking(IP)
IP network which can handle scale and heterogenity, LAN with bridges can only scale to small network.
An internetwork is a collection of networks. The router connects small networks together.
Addressing scheme, provides the way to identify all hosts in the IP. Datagram model of delivery, best effort service model to deliver datagrams.
Best effort means that the network does nothing if sth. fails, called an unreliable service.
设计思想,让router尽可能简单,不能在connection based network上进行connectionless的服务。The ability of running IP over anything is cited as its most important characteristics
Fail type:out of order, missing, more than once. The upper layer application should notice these errors.
Packets format:TOS(type of service),determine whether or not packets be placed in special queue.Thus, the maximum size of an IP datagram is 65,535 bytes. Fragmentation & reassembly is used for not supporting physical layer.
TTL: Set it too high and packets could circulate rather a lot before getting dropped. Measured in hopped way.
Protocal:upper applications at which this IP layer should be sent.(TCP/UDP).
Taking it as 16-bit words and add together using 1-coplementary and take 1 complementary.
Source addr determines destination willing to receive or reject. Destination addr allow routing in each hop.
为了便于在目标端重组,ident需要有相同的值。IP doesn’t try to recover from failed fragments, if can’t reassembly will drop all. Fragment usually happens when it receives a datagram that the router wants to forward a network which has smaller MTU than the datagrams. 尽力避免分段,失败了可能导致GC.
To identify the host, unique global address.
Global uniquness
Ethernet addr is flat, IP addr is hierarchical, by which we mean that they are made up of several parts that correspond to some sort of hierarchy in the internetwork. IP:network number + host number identifies this host in the network.IP address belong to the interface of 1 router, which then connects to all other network.
Class IP address:not flexible enough.
Don’t confuse Internet domain names with IP address:domain name such as seu.edu.cn,IP is set of number sequence.
Datagram forwarding in IP
forwarding is the process of taking a packet from an input and sending it out on the appropriate output, while routing is the process of building up the tables that allow the correct output for a packet to be determined.必须有router才能构成IP网络.
Process:whenever recieves a packets, compare the network part of this packet and the network part of itself interface. If the same, it means the destination lies in the same physical network as the interface, Thus can be directly delivered.
第一种情形,一个网络里面,直接转发。
第二种情形,发送到一个router,作为next hop再发送到下一个router consulting their forwarding table. < Network number,next router > in each entry.
为什么classless address具有scalibility?
class assignment:lack assignment efficiency.现在forwarding table only needs to contains several networking number rather than all of the nodes in the network. hierachical aggregation 减少nodes中存储的信息。信息过多影响检索性能。
Configuring each node on network with the same netmask, hosts may be on different physical network but share a single network number.每个主机配置一个IP address&&subnetmask. Bit wise AND to see if it can directly sends over the subnet.otherwise, needs to be sent to a router to forward to the destination.
Router forwarding process
转发表的Entry转变成< subnetnumber,subnetmask,nexthop >, And the packets’s detination address with subnetmask and if equals the sunetnumber, this is the right entry to use, it forwards to the next hop router indicated, until match make the transmission.
Classless addressing
CIDR==supernetting.
Longest prefixing
Use some high efficiency algorithms.
ARP(只有部分主机会学习源主机的映射)
Needs to excapsulate the IP datagram in the Ethernet packets with physical address thus can transmit in link-level.
Each host has the mapping table for map IP address to MAC Address, it should be able to learn by itself using ARP.存储在ARP cache里面,有timeout schema.
原理:网络支持广播。找不到就广播ARP请求,match的项目记录到cache里面。target的host会将请求者的IP->MAC映射保存到cache里面,含有请求者映射的host会更新表项中的entry时间,其他host则不会记录这个映射。
DHCP
Only requirement for MAC address is uniquness. IP address needs to be configurable, its number can be variable.
DHCP relies on a DHCP server that is responsible for providing configuration information to other hosts.
Allocate a range of IP address to the network, and store in the configuration info in the DHCP server, each host retrieve info using the table.
It is not really desirable to require one DHCP server on every network, because this still creates a potentially large number of servers that need to be correctly and consistently configured. Usually there is a relay agent.It only contains the address of the DHCP server. When a relay agent receives a DHCPDISCOVER message, it unicasts it to the DHCP server and awaits the response, which it will then send back to the requesting client.
process:boot hosts->DHCP discover send to broadcast address->relay agent unicast to DHCP server->DHCP response->host update lease .Address will expire after lease time. Thus need to renew lease.
Core:UDP packets which runs on IP.
ICMP(Internet control message protocal)
For example, ICMP defines error messages indicating that the destination host is unreachable (perhaps due to a link failure), that the reassembly process failed, that the TTL had reached 0, that the IP header checksum failed, and so on.
可以返回报告给source host.
ICMP redirect tells the source host there is some better route path.ping,traceroute also based on ICMP.