Introduction to Computer Networking
1.1 A day in the life of an application
Common communication model of networked applications: a bidirectional, reliable byte stream
- client-server model: World Wide Web(using HTTP)
- peer-to-peer model: BitTorrent
- skype: rendezvous or relay server
1.2 The 4 layer Internet model
Link: packet is called frame
Network: packet is called datagram, 如果使用Internet,network层必须使用IP
Transport: packet is called segment
Application
每一层只和对应的层交流,通过调用对下一层的API来利用下一层的服务,socket就是应用层对运输层的API
a packet has two types of fields: header fields and a payload field. The payload is typically a packet from the layer above.
a hop is a link between two routers
1.3 The IP Service Model
IP提供哪些服务?
基本服务:
- Datagram: 接受来自Transport层的segment作为datagram的data,将datagram作为Link层的data传给Link层
- Unreliable: 不保证按照顺序、一定到达、duplicate packet,而且发生这些错误也不会报告
- Best-effort
- Connectionless: 每个datagram之间是独立的,互相不知道的;IP service model doesn’t contain a flow state that records the whole communication (it only cares about destination) in its network
更多服务:
- 防止loop,通过datagram header中的time to live(TTL)阻止
- 如果Link层允许的packet大小小于datagram的,router可以fragment datagram
- 减小送错datagram的几率,通过datagram header中的checksum
- 允许新的IP版本:ipv4,ipv6
- 允许向datagram header中添加新的field从而添加新的feature
为什么如此设计IP?
- end-to-end principle:能在end host上加的feature,就不在network中加
- reliable和unreliable的服务都可以建在Network层上
- IP可以建在任何Link层上:IP makes very few assumptions about the link layer below
- 简单的IP快速、便宜,可以用dedicated hardware实现
1.4 A Day in the Life of a Packet
传输packet的过程:
Network layer is responsible for delivering packets to computers
Transport layer is responsible for delivering packets to applications
Tools
Wireshark
traceroute -w 1 网址
-w 1
指明wait for reply的timeout为1sTraceroute is a software program that displays the connection (path) through the Internet between this traceroute server and the location you enter above. The Internet path between the two locations has many routers, computers and other devices along it which help move your information. Each device along this path looks at your request and then sends it off to the next device until it reaches its destination. The Traceroute program shows the amount of time each device on the route takes to do three things: (1) receive the traceroute request (ICMP), (2) process that request and (3) send it back. Traceroute performs this test three times on each device (each device is called a “hop”).