北邮国院大三电商在读,全文为PPT机翻+自己理解,仅做整体复习浏览知识点熟悉定义用,不做考前突击复习重点用。有任何问题可评论指出,有需要本文pdf/docx/md/Effiesheet格式的同学请私信联系/微信联系。祝您学习愉快。

ISP示意图

ISP:Internet Service Provider 互联网服务提供商

Internet:“network of networks”

Interconnected Internet Service Providers (ISPs)

互联互联网服务供应商(ISPs)

Protocols

  • 简略定义:protocols control sending, receiving of messages

协议控制消息的发送和接收

  • 完全定义:protocols define format, order of messages sent and received among network entities, and actions taken on message transmission, receipt

协议定义了网络实体之间消息发送和接收的格式、顺序,以及在消息传输和接收时采取的操作

给了protocols的四个例子:

  • TCP (Transmission Control Protocol)
  • IP (Internet Protocol)
  • HTTP (HyperText Transfer Protocol)
  • 802.11 (WiFi standard)

Internet standards

  • RFC: Request for comments
  • IETF: Internet Engineering Task Force

Network edge

hosts: clients and servers

  • servers often in data centers
  • part of the network with the users and computers

access networks, physical

  • media: wired, wireless communication links
  • 媒体:有线、无线通信链接
    • part of network connecting edge to rest of network
    • 网络的一部分连接到网络的其余部分的边缘

network core:

  • the “middle” of the network
  • interconnected routers
  • 相互连接的路由器
  • network of networks

Network basics bits and bytes

bit 和 byte

1 bit代表一个0或1

1 byte代表8个bit,表示0到255(或-128到127)

  • 1 byte = 8 bit

Amounts of data are usually specified in bytes.

  • 1KB = 1 kilobyte = 1000 bytes = 8000bits
  • 1MB = 1 megabyte = 1 million bytes = 8 million bits
  • 1GB = 1 gigabyte = 1000 million bytes = 8000 million bits

内存用byte表示,进率是1000不是1024

BUT speeds are usually in bits per second (not bytes)

  • 1b/s (or bps) = 1 bit per second
  • 1Kb/s = 1000 bits per second
  • 1Mb/s = 1 million bits per second
  • 1Gb/s = 1000 million bits per second

传输速率用bit表示,进率是1000不是1024

MB与Mb的区别

  • B代表byte,b代表bit
  • 1MB=8Mb

⬆️这个很重要

packet

就是把很大的数据拆分成一个一个的小数据包,这个数据包就是packet,以数据包packet做单位来传输数据相对来说会快一些,而且,packet也可以检验错误。

Bandwidth

Bandwidth: Measure of how much data we can send

计算:sends packets of data

packet的长度为L,transmission rate(也就是bandwidth)为R

L(bits)/R(bits/sec)有两个含义

  • packet transmission delay
  • time needed to transmit L-bit packet into link

例题

Q:A packet of 1500B is transmitted by a network which has a bandwidth of 1Mb/s. How long does it take?

注意的点是:1500B是byte,不是bits,而bandwidth的单位是Mb/s,要进行单位换算

看到带B/b的题,第一时间要想到单位换算

A:1500B = 1500x8 bits = 12,000 bits

▪ 1Mb/s= 1,000,000 bits per second.

▪ Time = 12,000/1,000,000 sec

▪ = 0.012 sec

▪ = 12 ms

Packet-switching

  • packet-switching: hosts break application-layer messages into packets

包交换:主机将应用层消息分解成包

  • store and forward: entire packet must arrive at router before it can be transmitted on next link

存储和转发:整个数据包必须在下一个链路上传输之前到达路由器

【就是说明必须得先走完一个L/R,才能走下一个L/R】

  • end-end delay = 2L/R (assuming zero propagation delay)
  • one-hop transmission delay = L/R

例题

Q:If we count only the “transmission” delay (the time taken to send packets) what is the delay from sending a 1500byte packet from source to destination?

很明显要分着计算两段的时间然后加起来,注意单位换算

A:1,500 bytes = 1,500x8 bits = 12,000 bits

▪ 1Mb/s is 1000000bits/sec

▪ From source to router L/R = 12000/1000000 secs= 0.012 seconds or 12 ms

▪ From router to dest = 12000/2000000 seconds= 0.006 seconds or 6 ms

▪ Total end-to-end delay = 12+6ms = 18ms

Packet Switching: queueing delay, loss

  • if arrival rate (in bits) to link exceeds transmission rate of link for a period of time:
  • 如果到达链路的速率(以比特为单位)在一段时间内超过链路的传输速率:
    • packets will queue, wait to be transmitted on link
    • 数据包将排队,等待在链路上传输
    • packets can be dropped (lost) if memory (buffer) fills up
    • 如果内存(缓冲区)被填满,数据包会被丢弃(丢失)

Two key network-core functions

  • routing: determines source destination route taken by packets

  • 路由:确定报文所经过的源目的路由

    • routing algorithms 路由选择算法
  • forwarding: move packets from router’s input to appropriate router output

  • 转发:将数据包从路由器的输入移动到适当的路由器输出

【一个确定路线,一个移动】

Internet structure: network of networks

  • End systems connect to Internet via access ISPs (Internet Service Providers)
  • 终端系统通过接入ISP (Internet Service provider)连接到互联网
    • residential, company and university ISPs
    • 住宅、公司和大学isp
  • Access ISPs in turn must be interconnected.
  • 依次接入的isp必须相互连通。
    • so that any two hosts can send packets to each other
    • 这样任何两个主机都可以互相发送数据包

结构图

【两张图意思是差不多的】

【大概了解一下,反正就是access net各自连不同的ISP,ISP之间有IXP进行交换】

  • at center: small # of well-connected large networks
  • 位于中心的是连接良好的大型网络
    • “tier-1” commercial ISPs (e.g., Level 3, Sprint, AT&T, NTT), national & international coverage
    • “一级”商业isp(例如,三级,Sprint, AT&T, NTT),全国和国际覆盖
    • content provider network (e.g., Google): private network that connects it data centers to Internet, often bypassing tier-1, regional ISPs
    • 内容提供者网络(例如谷歌):将数据中心连接到Internet的专用网络,通常绕过一级、区域性isp

Quene(排队)发生的原因

  • packet arrival rate to link (temporarily) exceeds output link capacity
  • 报文到达链路的速率(暂时)超过输出链路的容量

Four sources of packet delay

  • 核心公式:d_nodal = d_proc + d_queue + d_trans + d_pro

【这四个delay的名字要背】

  1. d_proc: nodal processing 节点处理时延
  • check bit errors 检查误码
  • determine output link 确定输出环节
  • typically less than msec 通常小于毫秒
  1. d_queue: queueing delay 排队延迟
  • time waiting at output link for transmission

输出链路等待传输的时间

  • depends on congestion level of router

取决于路由器的拥塞级别

  1. d_trans: transmission delay 传输延迟
  • d_trans = L/R

  • L: packet length (bits)

  • R: link bandwidth (bps)

【包长除以带宽】

  1. d_prop: propagation delay 传播延迟
  • d_prop = d/s
  • d: length of physical link
  • s: propagation speed (~2x10^8 m/sec)

【物理连接长度除以传播速度】

四个delay如图所示:

Packet loss

  • queue (aka buffer) preceding link in buffer has finite capacity
  • 在缓冲区中链接前面的队列(即缓冲区)具有有限的容量
  • packet arriving to full queue dropped (aka lost)
  • 到达满队列的数据包被丢弃(即丢失)
  • lost packet may be retransmitted by previous node, by source end system, or not at all
  • 丢失的数据包可能被前一个节点重传,也可能被源端系统重传,或者根本不重传

Throughput

  • throughput: rate (bits/time unit) at which bits transferred between sender/receiver
  • 吞吐量:发送方/接收方之间传输比特的速率(位/时间单位)
    • instantaneous: rate at given point in time
    • 瞬时:给定时间点的速率
    • average: rate over longer period of time
    • 平均:较长一段时间内的比率.

Throughput 的 “Bottleneck"

【R,Rs,Rc哪个最小那个就是bottleneck,即限制整体速率的最低速度,因为整体的传输速率是一致的,哪个最低就按哪个走】

Layer

  • layers: each layer implements a service
  • 层:每一层实现一个服务
    • via its own internal-layer actions
    • 通过它自己的内层动作
    • relying on services provided by layer below
    • 依靠底层提供的服务

Why layering?

【layering的优点】

dealing with complex systems:

  • explicit structure allows identification, relationship of complex system’s pieces
  • 显式结构允许识别复杂系统的各个部分
    • layered reference model for discussion
    • 分层参考模型供讨论
  • modularization eases maintenance, updating of system
  • 模块化简化了系统的维护和更新
    • change of implementation of layer’s service transparent to rest of system
    • 层服务的实现变化对系统的其他部分是透明的
    • e.g., change in gate procedure doesn’t affect rest of system
    • 例如,门程序的改变不会影响系统的其他部分

TCP/IP model

【不够具体,具体看下面的TCP/IP layer】

一共五层,从上到下依次是:

  • application: supporting network applications
  • 应用层:支持网络应用
    • FTP, SMTP, HTTP
  • transport: process-process data transfer
  • 传输层:进程-进程数据传输
    • TCP, UDP
  • network: routing of datagrams from source to destination
  • 网络层:从源到目的地的数据报路由
    • IP, routing protocols
  • link: data transfer between neighboring network elements
  • 数据链路层:相邻网元之间的数据传输
    • Ethernet, 802.111 (WiFi), PPP
  • physical: bits “on the wire”
  • 物理层:“在电线上”的比特

ISO/OSI reference model.

【不够具体,具体看下面的ISO/OSI layer】

  • ISO = International Standards Office
  • OSI = Open Systems Interconnection

一共七层,相比TCP/IP在application和transport中间多了两层:

  • presentation: allow applications to interpret meaning of data, e.g., encryption, compression, machinespecific conventions
  • 表示层:允许应用程序解释数据的含义,例如,加密,压缩,特定于机器的约定
  • session: synchronization, checkpointing, recovery of data exchange
  • 会话层:同步、检查点、恢复数据交换

ISO/OSI 和 TCP/IP 的整合与对比

背诵口诀:Please Do Not Throw Sausage + Pizza Away

每个单词首字母代表一个Layer层,从1到7

Layering and headers

  • Most layers of the TCP/IP model are associated with a particular type of “header” or sometimes a “header and trailer”.
  • TCP/IP模型的大多数层都与特定类型的“头”或有时是“头和尾”相关联。
  • What is a header?
    • Information separate from the data being sent that says things about that data.
    • 与被发送的数据分离的信息,说明了关于该数据的事情。
    • Which computer is it being sent to?
    • Which program on that computer must receive it?
    • How long is this data?
  • For example layer 3 (network) has a “network address” which identifies the host that should receive the data.
  • 例如,第3层(网络)有一个“网络地址”,它标识应该接收数据的主机。
  • Layer 4 (transport) has a port that identifies which program should receive it.
  • 第4层(传输)有一个端口,用来标识哪个程序应该接收它。
  • At each lower layer a new header is added incorporating the headers underneath. A layer 2 packet has a layer 2 header but includes headers from layer 3 and 4.
  • 在每个较低的层添加一个新的标题,合并下面的标题。第2层数据包有第2层报头,但包含来自第3层和第4层的报头。

Encapsulation

封装

【指的是在各个环节获得和失去header的过程】

【从上往下加header,从下往上删header】

TCP/IP layer

【从上往下说,从Layer7开始】

  • Layer 7 – Application layer – this is the data for programs you use on your computer
  • 这是您在计算机上使用的程序的数据
    • HTTP (www) data, SMTP (sent emails), FTP (file transfer) and specific formats for games, torrent etc.
  • Layer 6 – Presentation layer
    • Related to character sets and presentation of data (unused in TCP/IP or real Internet)
    • 与数据的字符集和表示有关(在TCP/IP或真实互联网中未使用)
  • Layer 5 – Session layer
    • Related to whole lifetime of connection – is the connection real time (unused in TCP/IP or real Internet)
    • 与连接的整个生命周期相关的是连接的实时时间(在TCP/IP或真实的Internet中未使用)
  • Layer 4 – Transport layer – this is for the end-to-end connection between machines.
  • 这是用于机器之间的端到端连接。
    • Information related to reliability
    • 可靠性相关信息
    • Information related to which program on machine sent/receives data.
    • 与机器上哪个程序发送/接收数据有关的信息。
  • Layer 3 – Network (Internet) layer – this is to get the data the whole journey from its start computer to its end computer (Internet, between networks)
  • 这是从起始计算机到结束计算机(互联网,网络之间)的整个过程中获取数据
    • Address of computer on internet (IP address)
    • 互联网上计算机的地址(IP地址)
    • Checksum to see if data is corrupted
    • 校验和以查看数据是否已损坏
  • Layer 2 – Data link layer – this is to get the data to nearby computers (on same local network)
  • 这是为了将数据发送到附近的计算机(在同一本地网络上)
    • Media Access Control (MAC address) specific to individual computer
    • 特定于单个计算机的媒体访问控制(MAC地址)
  • Layer 1 – Physical layer (how bits 1s and 0s are actually transmitted)
  • 比特1和比特0是如何传输的
    • Think of cables in the ground or radio waves in the air
    • 想想地面上的电缆或空中的无线电波

ISO/OSI layer

【相对来说没那么重要,但是也看一下,其实都差不多】

Devices for layers

  1. Router
  • 路由器

    • This is a layer 3 device – it reads a layer 3 address and works out which direction a packet should go.
    • 这是一个第三层设备——它读取第三层地址,并计算出数据包应该往哪个方向走。
    • It is typically more complex and adaptive than a switch.
    • 它通常比开关更加复杂和自适应。
  1. Switch
  • 开关

    • This is a layer 2 device – it reads a layer 2 address and works out which nearby computer should get a message.
    • 这是一个第二层设备——它读取第二层地址并计算出附近的哪台计算机应该得到消息。
    • Typically simpler than a router.
    • 通常比路由器简单。
  1. Repeater
  • 中继器/转发器

    • This is a layer 1 device – it strengthens or reconstructs a corrupted signal and carries on sending it.
    • 这是第1层设备——它增强或重建损坏的信号并继续发送。

先简单介绍一下Application Layer

Application Layer

【省流:你个人能在对设备上做的行为都被归于应用层,比如收发邮件】

  • This is covered in many other modules you will take.
  • This is the layer you (mostly) work with as a programmer.
  • At the application layer the “network” is abstracted away and you access a stream of data that arrives at a “socket”.
  • 在应用层,“网络”被抽象出来,你可以访问到达“套接字”的数据流。
  • It is up to you to define the format of data your application writes and receives.
  • 由您来定义应用程序写入和接收数据的格式。
  • Different applications have different formats:
    • HTTP (Hyptertext transfer protocol) world-wide web
    • FTP (File transfer protocol) moving data
    • SMTP (Send Mail transfer protocol) sending email
    • IMAP (Internet message access protocol) receiving email

Socket

  • process sends/receives messages to/from its socket
  • 进程向/从它的套接字发送/接收消息
  • socket analogous to door
  • socket类似于门
    • sending process shoves message out door
    • 发送过程将消息推到门外
    • sending process relies on transport infrastructure on other side of door to deliver message to socket at receiving process
    • 发送过程依靠门另一侧的传输基础设施在接收过程中将消息传递到套接字

Address processes

  • to receive messages, process must have identifier
  • 要接收消息,流程必须具有标识符
  • host device has unique 32-bit IP address
  • 主机设备有唯一的32位IP地址
    • Q: does IP address of host on which process runs suffice for identifying the process?
    • 问:运行进程的主机IP地址是否足以识别该进程?
    • A: no, many processes can be running on same host
    • 答:不可以,同一个主机上可以运行多个进程
  • identifier includes both IP address and port numbersassociated with process on host.
  • 标识符包括主机上与进程相关联的IP地址和端口号
    • example port numbers:
    • HTTP server: 80
    • mail server: 25

4 different addresses in TCP/IP

  • Physical address Layer 2

    • Also known as the link address, is the address of a node as defined by its LAN or WAN
    • 也称为链接地址,是由LAN或WAN定义的节点地址
  • Logical address Layer 3 (32-bit , IPv4 128-bit IPv6)
    • Logical (IP) addresses are for universal communications that are independent of underlying physical networks
    • 逻辑(IP)地址用于独立于底层物理网络的通用通信
  • Port address Layer 4 (16-bit)
    • Port addresses differentiate different processes
    • 端口地址区分不同的进程
  • Application-specific address Layer 7
    • Some applications have user-friendly addresses that are designed for that specific application, such as email address, URL.
    • 有些应用程序具有针对该特定应用程序设计的用户友好的地址,如电子邮件地址、URL

App-layer protocol defines

【应用层协议的作用(定义了什么)】

  • types of messages exchanged
  • 交换的消息类型
    • e.g., request, response
  • message syntax:
  • 信息句法
    • what fields in messages & how fields are delineated
    • 消息中的哪些字段 & 字段是如何划分的
  • message semantics
  • 消息传递语义
    • meaning of information in fields
    • 字段中信息的含义
  • rules for when and how processes send & respond to messages
  • 流程何时以及如何发送和响应消息的规则
  • open protocols:
  • 开放协议
    • defined in RFCs (request for comments)
  • allows for interoperability
  • 允许互操作性
    • e.g., HTTP (web), SMTP (email)
  • proprietary protocols:
  • 私有协议
    • e.g., Skype

再简单介绍一下Session and Presentation Layer

Session and Presentation Layers

【看看就行,让你选什么行为在哪个Layer的时候大概知道就行,例题里只提到了粗体的两块,不过应该也就这两块,考不了别的】

  • Theoretical only – not implemented in the Internet
  • 只是理论上的,没有在互联网上实现(现行的TCP/IP协议是没有的,被统一归在了应用层)
  • Session Layer (layer 5):
    • Takes care of a connection between two hosts for the lifetime of that connection
    • 在两个主机之间的连接的生命周期内负责该连接
    • Authentication + authorisation (who is the user, what can they do)
    • 身份验证+授权(谁是用户,他们可以做什么)
    • In working Internet this is at the application layer.
    • 在工作Internet中,这是在应用层。
  • Presentation Layer (layer 6):
    • Translates data for an application.
    • 为应用程序转换数据。
    • For example takes care of detail of character set used to encode string of characters.
    • 例如,关注用于编码字符串的字符集的细节。
    • In working Internet this is at the application layer.
    • 在工作Internet中,这是在应用层。

下面进入Transport Layer部分

Transport services and protocols

  • provide logical communication between app processes running on different hosts
  • 不同主机上运行的应用程序进程之间提供逻辑通信
  • 【注意,是进程之间,这个定义有点模糊,如果不明白的话可以看下一个标题下的比喻】
  • transport protocols run in end systems
  • 传输协议在终端系统中运行
    • send side: breaks app messages into segments, passes to network layer.
    • 发送端:将应用程序消息分成段,传递到网络层
    • rcv side: reassembles segments into messages, passes to app layer
    • 接收端:将片段重新组装成消息,传递给应用程序层
  • more than one transport protocol available to apps
  • 多个传输协议可用于应用程序
    • Internet: TCP and UDP

Transport vs. network layer

  • network layer: logical communication between hosts
  • 网络层:主机之间的逻辑通信
  • transport layer:logical communication between processes
  • 传输层:进程之间的逻辑通信
    • relies on, enhances, network layer services
    • 依托、增强、网络层服务

【注意进程和主机的区别】

一个形象的比喻

  • 12 kids in Ann’s house sending letters to 12 children in Bill’s house:

    • hosts = houses
    • processes = children
    • app messages = letters in envelopes
    • transport protocol = Ann and Bill who give letter to correct child
    • network-layer protocol = postal service

【network layer将 “letter”,也就是message投递到他们家(host),然后transport layer才将每个letter给到对应的children(process),虽然说Transport layer给的定义是在不同主机间,但是实际完成不同主机间传递信息的是Network layer,负责主机内部投递的才是Transport layer】

Internet transport-layer protocols

  • reliable, in-order delivery (TCP)
  • 可靠的按顺序传输(TCP)
    • congestion control
    • 拥塞控制
    • flow control
    • 流控制
    • connection setup
    • 建立连接
  • unreliable, unordered delivery: UDP
  • 不可靠的,无序的传输:UDP
    • no-frills extension of “best-effort” IP
    • “尽最大努力”的IP的只满足最基本需要的扩展
  • services not available:
  • 不可提供的服务:
    • delay guarantees
    • 时延保证
    • bandwidth guarantees
    • 带宽保证

Multiplexing/demultiplexing

多路传输/多路分解

  • Multiplexing (Mux):

    • Combining several streams of data into a single stream.
    • 将多个数据流组合为单个数据流。
    • Example – your phone is browsing the web, refreshing your email, connecting to wechat at the same time. All these connections are sent over the same link.
    • 例如,你的手机正在浏览网页,刷新邮件,同时连接微信。所有这些连接都通过同一个链接发送。
  • Demultipliexing (Demux)

    • The opposite process. A stream of data is separated out into its individual components.
    • 相反的过程。数据流被分离成独立的组成部分。
    • The stream of packets the phone received is split up and sent to the appropriate program for web, email, wechat.
    • 手机接收到的信息流被分割并发送到web、email、微信的适当程序。

从整体传输的角度看Mux和Demux

  • multiplexing at sender:

    • handle data from multiple sockets, add transport header (later used for demultiplexing)
    • 处理来自多个套接字的数据,添加传输头(稍后用于多路分离)
  • demultiplexing at receiver:
    • use header info to deliver received segments to correct socket
    • 使用头信息将收到的段发送到正确的套接字

将主机间交付扩展到进程间交付,通过复用和分用实现。
复用:发送方传输层将套接字标识置于报文段中,交给网络层。
分用:接收方传输层根据报文段中的套接字标识,将报文段交付到正确的套接字。

【来源:传输层2 — 传输层复用和分用_llurran的博客-CSDN博客】

How demultiplexing works

  • host receives IP datagrams
  • 主机接收IP数据报
    • each datagram has source IP address, destination IP address
    • 每个数据报都有源IP地址、目的IP地址
    • each datagram carries one transport-layer segment
    • 每个数据报携带一个传输层段
    • each segment has source, destination port number
    • 每个段都有源端口号,目的端口号(各16 bits)
  • host uses IP addresses & port numbers to direct segment to appropriate socket
  • 主机使用IP地址和端口号将段定向到适当的套接字

TCP/UDP segment format

Connectionless demux

很简单,直接看图:

Connection-oriented demux

  • TCP socket identified by 4-tuple:

    • source IP address
    • source port number
    • dest IP address
    • dest port number

【这四个很重要,这四个值定义了两个socket和他们的连接,整体叫做TCP socket(此处理解存疑,反正记住TCP socket是这四个值定义的就行)】

  • demux: receiver uses all four values to direct segment to appropriate socket
  • Demux:接收器使用所有四个值将段直接指向适当的套接字
  • server host may support many simultaneous TCP sockets:
  • 服务器主机可能同时支持多个TCP套接字:
    • each socket identified by its own 4-tuple
    • 每个套接字都由自己的4元组标识
  • web servers have different sockets for each connecting client
  • Web服务器对于每个连接的客户机都有不同的套接字
    • non-persistent HTTP will have different socket for each request
    • 非持久HTTP对于每个请求都有不同的套接字

【补充:对于Connectionless demux和Connection-oriented demux这两者谁更好,谁效率更高是不一定的,需要看情况】

举例来说

Q:为什么传到P4,P5,P6各自的socket的dest port都是80?

A:因为他们都是传到一个统一的中间socket(port:80),再由80这里Demux到P4,P5,P6的socket

  • 像P4这样一个server有多个socket接受信息的,叫做threaded server(多线程服务器)

Typical port numbers for applications

  • Port 80: Standard HTTP (Hypertext Transfer Protocol – browse the web
  • 端口80:标准HTTP(超文本传输协议-浏览网页
  • Port 22: ssh (secure shell) log in from remote computer
  • 端口22:ssh(安全shell)从远程计算机登录
  • Port 25: SMTP (simple mail transfer protocol) – send mail via this host
  • 端口25:SMTP(简单邮件传输协议)—通过此主机发送邮件
  • Port 143: IMAP (Internet Message Access Protocol) – read your email
  • 端口143:IMAP(互联网消息访问协议)-阅读您的电子邮件
  • Port 443: HTTPS (secure HTTP) browse the web securely
  • 端口443:HTTPS(安全HTTP)安全浏览网页
  • These are just conventions, you could change them if you so wished on your own host.
  • 这些只是约定,如果您愿意,您可以在自己的主机上更改它们。

UDP:User Datagram Protocol

UDP:用户数据报协议

  • Simplest usable Internet transport protocol
  • 最简单可用的因特网传输协议
  • “best effort” service, UDP segments may be:
  • “尽最大努力”的服务,UDP段可能会:
    • lost
    • delivered out-of-order to app
  • connectionless:
    • no “handshaking” between UDP sender, receiver (can send immediately without asking first)
    • UDP发送方和接收方之间没有“握手”(可以立即发送,无需事先询问)
    • each UDP packet handled independently of others
    • 每个UDP包都独立处理
  • UDP use:
    • streaming multimedia apps (loss tolerant, rate sensitive)
    • 流媒体应用程序(容错、速率敏感)
    • DNS
    • 域名服务器(Domain Name System)
    • SNMP
    • 简单网络管理协议(Simple Network Management Protocol)
  • reliable transfer over UDP:
  • 可靠的UDP传输:
    • add reliability at application layer
    • 在应用层增加可靠性
    • application-specific error recovery!
    • 应用程序特定的错误恢复!

UDP segment format of header

  • why is there a UDP?

    • no connection establishment (which can add delay)
    • 没有建立连接(这会增加延迟)
    • simple: no connection state at sender, receiver
    • 简单:发送方、接收方没有连接状态
    • no congestion control: UDP can blast away as fast as desired
    • 没有拥塞控制:UDP可以以期望的速度爆炸

UDP length

  • header的长度,最小为64bits(8bytes)

UDP checksum

  • Goal: detect “errors” (e.g., flipped bits – 0 becomes 1 or 1 becomes 0) in transmitted segment

  • 目标:检测传输段中的“错误”(例如,翻转位- 0变为1或1变为0)

  • sender:

    • treat segment contents, including header fields, as sequence of 16-bit integers
    • 将段内容(包括报头字段)视为16位整数序列
    • checksum: addition (one’s complement sum) of segment contents
    • 校验和:段内容的相加(补和)
    • sender puts checksum value into UDP checksum field
    • 发送方将校验和值放入UDP校验和字段
  • receiver:

    • compute checksum of received segment
    • 计算接收段的校验和
    • check if computed checksum equals checksum field value:
    • 检查计算的校验和是否等于校验和字段值:
      • NO - error detected
      • YES - no error detected.

首先发送方要计算checksum

  • 将段的内容看作16bits的整数
  • 校验和计算:计算所有整数的和,进位加到和的后面,将得到的值按位取反,得到校验和
  • 发送方把checksum放入header的校验和字段里面

接着,当接收方收到后,验证的思路是

  • 计算所收到的段的校验和
  • 把它和校验和字段进行对比
  • 不相等即发现了错误,相等并不代表一定没有错误

相等只代表我们没有检测出错误,但其实可能有错误,比如有2个位发生翻转的情况就检测不出来。

e.g.

【来源:UDP checksum校验和 - 知乎 (zhihu.com)】

UDP Encapsulation/decapsulation

UDP封装/解封装

Principles of reliable data transfer

  • characteristics of unreliable channel will determine complexity of reliable data transfer protocol (rdt)
  • 不可靠通道的特性决定了可靠数据传输协议(rdt)的复杂性。

【左图为我们提供的服务,右图为实际上左图的reliable channel的结构】

  • rdt_send(): called from above, (e.g., by app.). Passed data to deliver to receiver upper layer
  • 从上面调用(例如,通过应用程序)。将数据传递给接收上层
  • udt_send(): called by rdt,to transfer packet over unreliable channel to receiver
  • 由rdt调用,通过不可靠的通道将包传输到接收器
  • rdt_rcv(): called when packet arrives on rcv-side of channel
  • 当数据包到达rcv端通道时调用
  • deliver_data(): called by rdt to deliver data to upper
  • 由rdt调用,向上层传送数据

【注意箭头方向。udt_send()和rdt_rcv是双向的,剩下两个是单向的】

rdt_send:应用层将数据交付给可靠传输协议(rdt)以发送给对方
udt_send:被rdt调用,在不可靠的信道上向接收方传输数据
rdt_rcv:当数据包到达接收方信道时被调用
deliver_data:向上层应用交付数据

rdt_send和deliver_data 是单向的,应用层发送和接收到的都是正确的
udt_send和rdt_rcv 是双向的,说明在不可靠的信道通道进行数据传输,需要双向的控制消息流动
【来源:可靠数据传输原理_blueheart丶的博客-CSDN博客】

Finite State Machine

有限状态机

  • A finite state machine shows how a system works with states and transitions between them.
  • 有限状态机展示了系统如何处理状态和状态之间的转换。
    • Consider a coin operated turnstile – we put in a coin, it allows us in.

    • 考虑一个投币式旋转门——我们投入硬币,它就允许我们进去。

    • It has two states “locked” “unlocked”.

    • 它有两种状态“锁定”和“未锁定”。

    • It has two events “push” and “insert coin”

    • 它有两个事件“推币”和“投币”

    • 【一个类比,但是后面的图都是这样圆圈+箭头的形式,要明白这样的图代表什么意思】

在介绍各个版本前的rdt之前要知道的事情

  • consider only unidirectional data transfer
  • 只考虑单向数据传输
    • but control info will flow on both directions!
    • 但是控制信息会双向流动!
  • use finite state machines (FSM) to specify sender, receiver
  • 使用有限状态机(FSM)来指定发送方、接收方

【看懂这个图非常重要!!!!要了解每个箭头上的横线上面和下面各指什么】

rdt1.0: reliable transfer over a reliable channel

Rdt1.0:通过可靠通道进行可靠传输

  • underlying channel perfectly reliable
  • 底层通道完全可靠
    • no bit errors
    • 无误码
    • no loss of packets
    • 包不丢失
  • separate FSMs for sender, receiver:
  • 发送方、接收方的独立FSMs:
    • sender sends data into underlying channel
    • 发送方将数据发送到底层通道
    • receiver reads data from underlying channel
    • 接收器从底层通道读取数据

【绝对理想情况,即信道可靠不会丢失不会出错】

rdt2.0: channel with bit errors

Rdt2.0:有误码的通道

  • We drop the assumption that the channel has no errors.

  • 我们放弃信道没有错误的假设。

  • Now the channel could have bit errors.

  • 现在信道可能有比特错误。

  • We need to be able to detect and recover from errors in transmission.

  • 我们需要能够检测并从传输错误中恢复。

  • underlying channel may flip bits in packet

  • 底层信道可以翻转包中的位

    • checksum to detect bit errors
    • 用校验和来检测误码
  • the question: how to recover from errors:

    • acknowledgements (ACKs): receiver explicitly tells sender that pkt received OK
    • 确认(ACKs):接收方显式地告诉发送方pkt已收到OK
    • negative acknowledgements (NAKs): receiver explicitly tells sender that pkt had errors
    • 负确认(NAKs):接收方显式地告诉发送方pkt有错误
    • sender retransmits pkt on receipt of NAK
    • 发送方在收到NAK后重新传输pkt
    • 【以上三点就是rdt2.0的原理】
  • new mechanisms in rdt2.0 (beyond rdt1.0):

    • error detection
    • 错误检测
    • feedback: control msgs (ACK,NAK) from receiver to sender
    • 反馈:控制信息 (ACK,NAK)从接收端到发送端

rdt2.0的FSM

【红色sender上面那个倒的三角代表无任何动作,等待上层协议】

正常的无错误的rdt2.0过程

【先思考正常的rdt2.0过程,sender send pkt,然后receiver发现正确,给sender反馈ACK,然后sender收到ACK,知道没问题了,就上传。想明白了之后看图】

出现错误的rdt2.0过程

【先思考出现错误的rdt2.0过程,sender send pkt,然后receiver发现错误,给sender反馈NAK,sender收到NAK,知道有问题,重新发送pkt,直到发送了正确的pkt,sender收到ACK,知道没问题了,就上传。想明白了之后看图】

rdt2.0的致命缺陷

  • what happens if ACK/NAK corrupted?

  • 如果ACK/NAK损坏了会发生什么?

    • sender doesn’t know what happened at receiver!
    • 发送方不知道接收方发生了什么!
    • can’t just retransmit: possible duplicate
    • 不能只是重传:可能的重复
  • handling duplicates:

  • 处理重复:

    • sender retransmits current pkt if ACK/NAK corrupted
    • 如果ACK/NAK损坏,发送方重新传输当前的pkt
    • sender adds sequence number (seq) to each pkt
    • 发送方将序列号(seq)添加到每个PKT
    • receiver discards (doesn’t deliver up) duplicate pkt
    • 接收器丢弃(不交付)重复的PKT
  • stop and wait: sender sends one packet, then waits for receiver response

  • 停止与等待:发送方发送一个报文,然后等待接收方响应

rdt2.1

  • rdt2.1相较于rdt2.0,防止了回传ACK,NAK的时候出现问题

sender

receiver

发送方获得来自上层的数据后,封包(编号为0)发送至接收方,接收方接收到分组后:
1、如果没有损坏,回送ACK分组,并等待编号为1的分组
2、如果损坏,回送NAK分组,并继续等待编号为0的分组

发送方接收到回送分组后:
1、如果没有损坏,且为ACK分组,无任何动作,等待上层协议
2、如果没有损坏,且为NAK分组,重发编号为0的分组
3、如果损坏,无论是ACK还是NAK,重发编号为0的分组

接收方收到分组后(接收方不知道自己的ACK或NAK分组在传输过程中是否损坏):
1、如果没有损坏,且为编号1的分组,回送ACK分组,且等待编号为0分组(循环)
2、如果没有损坏,且为编号0的分组,回送ACK分组,且等待编号为1分组
3、如果损坏,回送NAK分组,等待编号为0分组

为什么会出现重复的分组?假如发送方无误的将分组0发送给了接收方,接收方也发送ACK分组准备接收分组1,但是ACK分组却在传输过程中损坏了,这会导致发送方重发分组0,而不是分组1。

【来源:rdt2.1与rdt2.2_陌养的博客-CSDN博客】

rdt2.2

  • rdt2.1的简化版本

【这个图是相较rdt2.0的图修改的部分】

rdt2.2与2.1的区别就在于去掉了NAK,而在ACK分组中显式指出分组编号:
发送方获得来自上层的数据后,封包(编号为0)发送至接收方,接收方接收到分组后:
1、如果没有损坏,回送ACK0分组,并等待编号为1的分组
2、如果损坏,回送ACK1分组,并继续等待编号为0的分组
发送方接收到回送分组后:
1、如果没有损坏,且为ACK0分组,无任何动作,等待上层协议
2、如果没有损坏,且为ACK1分组,重发编号为0的分组
3、如果损坏,无论是ACK1还是ACK0,重发编号为0的分组
接收方收到分组后(接收方不知道自己的ACK分组在传输过程中是否损坏):
1、如果没有损坏,且为编号1的分组,回送ACK1分组,且等待编号为0分组(循环)
2、如果没有损坏,且为编号0的分组,回送ACK0分组,且等待编号为1分组
3、如果损坏,回送ACK1分组,等待编号为0分组

【来源:rdt2.1与rdt2.2_陌养的博客-CSDN博客】

rdt3.0: channels with errors and loss

  • sender waits “reasonable” amount of time for ACK
  • 发送方为ACK等待“合理的”时间
  • retransmits if no ACK received in this time
  • 如果在此时间内没有收到ACK,则重新发送
  • if pkt (or ACK) just delayed (not lost):
  • 如果pkt(或ACK)只是延迟(而不是丢失):
    • retransmission will be duplicate, but seq. #’s already handles this
    • 重传将是重复的,但是seq #已经处理了这个
    • receiver must specify seq # of pkt being ACKed
    • 接收方需在ACK中显式告知所确认的分组
  • requires countdown time
  • 需要倒计时时间

rdt3.0 sender

在rdt2.2基础上加了个计时器

rdt3.0的各种情况

【来源:rdt1.0,rdt2.0,rdt2.1,rdt2.2,rdt3.0_侠客岛的含笑的博客-CSDN博客】

【北邮国院大三上】互联网协议_Internet Protocol_PART A相关推荐

  1. 【北邮国院大三上】互联网协议_Internet Protocol_PART B

    北邮国院大三电商在读,全文为PPT机翻+自己理解,仅做整体复习浏览知识点熟悉定义用,不做考前突击复习重点用.有任何问题可评论指出,有需要本文pdf/docx/md/Effiesheet格式的同学请私信 ...

  2. 【北邮国院大三上】电子商务法(e-commerce law)知识点整理——Banking Lawe-Payment

    北邮国院大三电商在读,随课程进行整理知识点.仅整理PPT和相关法条中相对重要的知识点,个人认为相对不重要的细小的知识点不列在其中.如有错误请指出.转载请注明出处,祝您学习愉快. Why are leg ...

  3. 【北邮国院大三上】电子商务法(e-commerce law)知识点整理——e-transaction_Part2_BUPTWeek8

    北邮国院大三电商在读,随课程进行整理知识点.仅整理PPT和相关法条中相对重要的知识点,个人认为相对不重要的细小的知识点不列在其中.如有错误请指出.转载请注明出处,祝您学习愉快. 在进入主题之前,先讲了 ...

  4. 【北邮国院大三上】大三上高编/互联网协议/电信系统笔记

    考前时间太匆忙+

  5. 【北邮国院大三下】Cybersecurity Law 网络安全法 Week1【更新Topic4, 5】

    北邮国院大三电商在读,随课程进行整理知识点.仅整理PPT中相对重要的知识点,内容驳杂并不做期末突击复习用.个人认为相对不重要的细小的知识点不列在其中.如有错误请指出.转载请注明出处,祝您学习愉快. 编 ...

  6. 【北邮国院大三下】Cybersecurity Law 网络安全法 Week3

    北邮国院大三电商在读,随课程进行整理知识点.仅整理PPT中相对重要的知识点,内容驳杂并不做期末突击复习用.个人认为相对不重要的细小的知识点不列在其中.如有错误请指出.转载请注明出处,祝您学习愉快. 编 ...

  7. 【北邮国院大三下】Logistics and Supply Chain Management 物流与供应链管理 Week1

    北邮国院大三电商在读,随课程进行整理知识点.仅整理PPT中相对重要的知识点,内容驳杂并不做期末突击复习用.个人认为相对不重要的细小的知识点不列在其中.如有错误请指出.转载请注明出处,祝您学习愉快. 编 ...

  8. 【北邮国院大三下】Software Engineering 软件工程 Week1

    北邮国院大三电商在读,随课程进行整理知识点.仅整理PPT中相对重要的知识点,内容驳杂并不做期末突击复习用.个人认为相对不重要的细小的知识点不列在其中.如有错误请指出.转载请注明出处,祝您学习愉快. 编 ...

  9. 【北邮国院大三下】Intellectual Property Law 知识产权基础 Week1

    北邮国院大三电商在读,随课程进行整理知识点.仅整理PPT和相关法条中相对重要的知识点,个人认为相对不重要的细小的知识点不列在其中.如有错误请指出.转载请注明出处,祝您学习愉快. 编辑软件为Effie, ...

最新文章

  1. 微信小游戏开发(9)- 分包加载
  2. java高级----Java动态代理的原理
  3. 【正则】匹配html标签里的内容,不含标签
  4. rosserial_java_ros系统下通过pyserial模块实现串口通讯(Python)
  5. 【程序员薪资】2021年04月新鲜出炉,看看你拖后腿了吗?
  6. 数据结构学习笔记:利用Python列表实现栈结构
  7. Kubernetes[3]-Server
  8. 初探Oracle--Oracle查询操作
  9. 数据类型以及数据类型的转换---防止忘记
  10. vuex mapstate_Vuex从使用到原理解析
  11. 初始化栈的代码_限定性数据结构-栈
  12. 【ArcGIS|空间分析】图像纠正
  13. 阶段3 3.SpringMVC·_02.参数绑定及自定义类型转换_1 请求参数绑定入门
  14. 新商机:“百亿帝国”全健、华林彻底倒下,保健行业遭重创,直销业被重新定义
  15. 彻底弄明白Gradle相关配置
  16. vmware 克隆虚拟机的关键步骤
  17. javascript解数独LeetCod-37
  18. win10wifi开关自动弹回_win10系统wlan打开又关闭的解决方法
  19. Newman基本使用
  20. 100位中国人存款7.8万亿!100位是程序员?遍身萝绮者不是养蚕人

热门文章

  1. win10如何更改计算机用户名,怎么更改账户用户名,教你win10系统更改账户用户名称教程...
  2. 在64位计算机上安装MapGuide Studio 2010
  3. HDOJ 5100 Chessboard 构造
  4. Java什么是面向对象和面向对象特性
  5. 利用STM32F103最小系统做C2接口离线烧录器
  6. 北斗时钟服务器(GPS卫星同步时钟)应用电子政务系统
  7. 转载_利用虚拟机VMWARE安装并配置Debian Linux系统的总结
  8. html左侧导航栏点击下拉菜单,HTML+CSS实现下拉菜单
  9. 【Linux】软件安装、仓库搭建、服务器配置
  10. 练习-编写求阶乘函数