更新于 

CS3311 计算机网络

王道烤盐

ch1 计网体系结构

计算机网络概述

  • 组成部分
  • 工作方式
    • 边缘部分
      • 用户直接使用
      • C/S
        • client-server
          • * B/S: brower-server
      • P2P
    • 核心部分
  • 功能组成
    • 通信子网
    • 资源子网
  • 性能指标
    • 速率,带宽,吞吐量
    • 时延
      • 发送/传输~,传播~,排队~,处理~
      • 时延带宽积 -> 容量
      • RTT 往返时延
        • 发送方发送 -> 发送方接收到确认
    • 利用率

体系结构&参考模型

计算机网络的各层及其协议的集合

  • 7层OSI模型(法定标准)


  • 4层TCP/IP模型 (事实标准)

ch2 应用层

  • Application architecture

    • Client-server
    • P2P
    • hybrid of client-server and P2P
      • Skype: centralized server to find address of remote party, then client-client connection
  • Sockets:进程与计算机网络之间的接口

  • transport service 一些指标

    • data loss
    • delay
    • throughput
    • security
  • Internet transport services

    • TCP
      • connection-oriented: 需要先建立连接
      • reliable transport
      • flow control: 发送的消息不会overwhelm接收方(对于接收方)
      • congestion control: 控制网络不会拥堵(对于网络)
    • UDP
      • use packet-switch
      • unreliable data transfer
  • Process identifier = IP address + port number

DNS

  • DNS (Domain Name System): map www.sjtu.edu.cn —> 202.120.2.119
    • distributed, hierarchical database
    • root name servers
    • TLD (top-level domains)
    • Local name server: Client needs to be configured with local name server manually or via DHCP.
      • 找到DNS name的方法:iterated query
    • 先local DNS server,然后让local DNS server去找:root DNS server,TLD DNS server,authoritative DNS server
      • 找到DNS name的方法:recursice query
    • 先找local DNS server,然后local DNS sever找root DNS server,然后root DNS server找TLD DNS server,然后TLD DNS server找authoritative DNS server。

Web and HTTP

WWW

client/server model with http

  • 首先用DNS把url转换成IP address
  • 建立tcp connection
  • 发送http request
  • 等待http response
  • fetch embedded resources
  • 清除闲置的tcp connection

HTTP

Hyper Text Transfer Protocol

  • 使用TCP,先建立TCP连接,然后用http发送请求
  • http是stateless的:不维持状态
  • cookies:server在client那里drop一个cookie,保存着server state。然后每次client发消息,就把之前的cookie一起发给server。相当于给client配了一个id,然后server可以在数据库里记录client的情况

  • HTTP Performance: Page Load Time (PLT)

    • Round Trip Time (RTT):
      • time for a small packet to travel from client to server and back. 一个来回叫一个RTT
    • Page Load Time (PLT):
      • one RTT to initiate TCP connection
      • one RTT for HTTP request and first few bytes of HTTP
      • file transmission time
      • total = 2RTT + transmit time
  • Nonpersistent HTTP:
    • one object sent over one TCP connection,每次发都要新建一个新的tcp connection
    • PLT = N*RTT + transmit time
  • Ways to decrease PLT
    • 同时并行发多个http请求
    • 尽量用persistent http
    • move content closer to client
    • SPDY,一种更快的web protocol
  • web cache (proxy server)
    • 目标:不用server,加个cache就行(中间环节)
    • browser直接发request到cache,如果有则拿,没有的话cache再向server请求
    • cache acts as both client and server
  • conditional GET:cache在发GET给server的时候,加个modify的date,如果date不一样,那server就返回新的data。否则就不用返回新data,回一个304 not modified。
  • content delivery networks:client接收完内容后,再把内容发给其他server和cache。这样下次别人要用可以直接拿cache和server里的。

FTP

  • Client-server model
  • 有两种connection,分开的:
    • TCP control connection,是persistent
    • TCP data connection,每个文件都要新开一个connection,是non-persistent
  • FTP server maintains “state”: current directory, earlier authentication

Electronic Mail

email是怎么做到receiver不在的时候我们的mail也能发到呢?

  • 四个部分
    • user agents
    • mail servers
    • transfer protocol (SMTP) ,服务器之间发送email
    • access protocol (POP3, IMAP),从服务器拿取email

P2P applications

  • P2P挑战:

    • No servers on which to rely: Communication must be peer-to-peer and self-organizing, not client-server. 必须自己调度!
    • Limited capabilities: How can one peer deliver content to all other peers? 一个人要发很多人怎么办?
    • Decentralized indexing: How will peers find content,find each other? 怎么找到其他人?
    • Participation incentives: Why will peers help each other? 为什么要互相帮助?
  • Distributed Hash Table (DHT)

    • Circular DHT: 每个peer只知道后继节点的ID. $ID(peer)=hash(IP, port)$
    • key look up: 平均$O(N)$的复杂度
    • key look up with shortcuts: 每个peer也维持一些shortcut,可以降到$O(logN)$
    • DHT Finger Table: chap2-2, P25
    • peer leave and join: 每个peer记住它后面两个节点,定时ping一下看看在不在,第一个节点走了的话,就让第二个节点把它的后面节点发过来。
  • BitTorrent Protocol

    • 选一个要接收的文件,和tracker请求peer list,然后和peer们进行传输
    • tit-for-tat: 一报还一报。过程:
    1. alice给bob乐观地来点加速,alice成为bob的top 4
    2. bob回报alice,bob也成为alice的top 4
    • Trackerless BitTorrent: 用DHT来标记文件和peer
  • P2P Case study: Skype
    • hierarchical overlay with SuperNodes
    • 问题:alice和bob都在NAT之后
    • 解决方法:
    • Alice and Bob connectwith their SNs.
    • Relay is chosen. Each peer initiates session with relay.
    • Peers can now communicate through NATs via relay.

Socket programming with TCP/UDP

  • 什么是socket:a door between application process and end-endtransport protocol (UDP or TCP) 应用层和传输层的桥梁

  • server和client得有一个socket number

    • socket用port number和IP进行区分
  • 需要connection的socket(TCP):

  • 不需要connection的socket(UDP):

ch3 传输层

  • 单位:segment

  • 提供进程间的数据传输服务

    • 软/硬件 = 传输实体 entity
    • (网络层:主机间)
  • 复用和分用
  • 差错检测

Segment (Transport layer) -> Packet (Network layer) -> Frame (Datalink layer)

Multiplexing and demultiplexing

  • Ports: server的port选的比较well known,client的port选的比较ephemeral(随意?)
  • Upward multiplexing和downward multiplexing,看个图就明白了

  • Multiplexing/demultiplexing: 先把所有socket的数据都合起来发出去,再在接收方那里解开,分到不同的socket。

    • 带connection的demux,TCP socket:带一个四元组,src IP and port, dst IP and port
    • 不带connection的demux,UDP socket: 带一个二元组,dst IP, dst port

      差错检测:CRC

Given m data bits, generator polynomia- of degree r G(x):

  1. Append r zero bits to the low-order end of the frame
    • (it now contains m + r bits. )
  2. Divide the m + r bits with r + 1 bit string corresponding to G(x) using modulo 2 division
    • (no carries for addition or borrows for subtraction. Both addition and subtraction are identica- to exclusive OR).
    • The remainder is the r bits CRC.
  3. Append the r bits to the m data bits into a m+r codeword which is divisible (modulo 2) by G(x).
  4. When the receiver gets the checksummed frame, it tries dividing it by G(x). If there is a remainder, there has been a transmission error.

两个主要协议

  • UDP 用户数据报协议
    • 提供无连接服务
    • 对方的运输层在收到UDP报文后,不需要给出任何确认
    • 单位:UDP用户数据报
    • 低时延,小文件适用
  • TCP 传输控制协议
    • 提供面向连接的服务
    • 不提供广播或多播服务
    • 单位:TCP报文段
    • 高时延,大文件适用

      UDP

  • 无连接
  • 不保证可靠交付
    • 可能发生lost,error,out of order (可在应用层增加可靠性)
  • 面向报文
    • 适合一次性传输少量数据
  • 实时传输,无拥塞控制
  • 首部开销小

    首部格式
  • 8B,由4部分构成

  • UDP长度:数据报差别
  • 检验和:检测是否出错

  • 分用如果找不到目的端口,则由发送方发送不可达信息(ICMP)

UDP校验

  • 伪首部只用于计算检验和,不向下传送也不向上递交

  • 具体步骤(发送端)
    • 填上伪首部
    • 全0填充检验和字段
    • 全0填充数据部分
    • 伪首部+首部+数据采用二进制反码求和
    • 和求反码填入检验和字段
    • 去掉伪首部并发送。
  • (接收端)
    • 填上伪首部
    • 伪首部+首部+数据采用二进制反码求和
    • 结果全1则无差错
主要特点
  • UDP是无连接的
  • UDP使用尽最大努力交付
  • UDP是面向报文的
  • UDP对应用层交下来的报文,既不合并,也不拆分,而是保留这些报文的边界
  • 应用程序必须选择合适大小的报文
    若报文太长,IP层在传送时可能要进行分片
    若报文太短,会使IP数据报的首部的相对长度太大
  • UDP没有拥塞控制
    因此网络出现的拥塞不会使源主机的发送速率降低
  • UDP支持一对一、一对多、多对一和多对多的交互通信
  • UDP的首部开销小,只有8个字节,比TCP的20个字节的首部要短

Why UDP?

  • no connection establishment (which can add delay)
  • no retransmission (which can add delay)
  • simple: no connection state at sender, receiver
  • small segment header: 8 bytes
  • no flow control and congestion control:
    • UDP can blast away as fast as desired

TCP

  1. Go-Back-N (GBN):

    • 发送方: GBN是一种滑动窗口协议,发送方可以连续发送多个数据帧,直到达到窗口大小为止。发送方会等待收到对窗口内所有数据帧的确认,然后才能发送下一个窗口的数据帧。
    • 接收方: 接收方按序接收数据帧,如有帧丢失,就会回退(Go-Back)并重新请求所有未确认的帧。
      • 接收方丢弃所有失序分组
    • 优点:接收方只需要缓存一个包就行,不需要缓存失序分组
  2. **Selective Repeat (SR):

    • 只重传那些没有正确ACK的包
    • 发送方和接收方都维持相同大小的window size。接收方把接收到的都buffer住。
      • $sending\ window + receiving\ window \leq MAX\ SEQ+1$
    • 发送方: SR也是一种滑动窗口协议,允许发送方同时发送多个数据帧。与GBN不同,发送方只需要重传丢失的帧,而不是整个窗口。
    • 接收方: 接收方按序接收数据帧,并确认它们。即使有帧丢失,接收方也会继续按序接收后续的帧。
  3. Transmission Contro- Protoco- (TCP):

    • 特点: TCP是一种面向连接的协议,提供可靠的、有序的数据传输。它使用滑动窗口协议,但其设计更为复杂。TCP包括流量控制、拥塞控制、连接建立和断开等多个功能。
    • 连接建立: 通过==三次握手==建立连接,确保双方都准备好进行通信。
    • 累积确认: TCP使用==累积确认==的机制。这意味着如果接收方成功接收了某个字节之前的所有字节,它只需确认最后一个字节,而不必逐个确认每个字节。
    • 累积确认号和确认标志:
      • TCP报文头部中的确认号字段指示下一个期望接收的字节。
      • 确认标志(ACK标志)用于指示报文是一个确认报文。
    • 滑动窗口:
      • 使用滑动窗口来控制发送和接收的数据量,以提高网络利用率。
    • 可靠性:
      • 提供==数据确认==、==重传==机制以确保数据的可靠传输。
    • 流量控制和拥塞控制:
      • TCP包括流量控制机制,防止快速发送方淹没较慢的接收方;包括拥塞控制,以应对网络拥塞情况。
TCP congestion control

congestion control: open loop, closed loop

  • Congestion Avoidance:提前预测,及时避免,主要两种方法
    • host centric:TCP congestion control
    • Router-centric: warning bit, choke packet, load shedding
  • AIMD: Additive Increase, Multiplicative Decrease
    • MD: decrease window by factor of 2 when loss,减少的时候一下子除以2
    • AI: additive increase until packet loss,增加的时候一个个加
  • Explicit Congestion Notification:
    • 直接通知堵塞的packet的sender

丢包判断:

  1. time out
  2. 连续3个duplicate的ACK
  • TCP Tahoe/Reno implements AIMD to limit the sending rate.
  • Sender uses packet loss as the network congestion signal.
  • TCP use a Congestion Window (CongWin) next to the window granted by the receiver.
    • The actual window size is the minimum of the two.
    • Self-clocking: The CongWin size should be adjusted frequently, to match the networking carrying capacity

端口

  • 虽然通信的终点是应用进程,但只要把所传送的报文交到目的主机的某个合适的目的端口
  • TCP/IP的运输层用一个16位端口号来标志一个端口,端口号只具有本地意义

  • 服务端

    • 熟知端口号 0-1023
    • 登记端口号 1024-49151
  • 客户端
    • 仅在客户进程运行时才动态选择
    • 49152-65535
  • 套接字 = IP + 端口号
    • IP确定主机
    • 端口号确定进程

ch4 网络层

主要任务:把分组从源端传输到目的端,为分组交换网上的不同主机提供通信服务 allow packets to be sent between any pair or hosts

路由器的工作:

  • routing: determine route from source to dest; determine the output link.
  • forwarding/switching: move packets from router’s input to appropriate router output
  • congestion control: drop packets, update routing table

IP service model:

  • Datagram 数据报
  • Unreliable
  • Best effort
  • Connectionless
    • No per-flow state, might mis-sequece packets

Virtual-Circuit and Datagram Switching

Datagram Switching

  • destination address as the index of forwarding

  • Forwarding table 转发表
  • Longest Prefix Matching
    • 减小转发表长度

Virtual-Circuit

VC consists of:

  • path from source to destination
  • VC numbers
  • entries in routers along path

packet carries VC number (rather than dest address) as the index of forwarding

转发表示例:

incoming interface incoming VC# outgoing interface outgoing VC#
1 12 3 22
2 63 1 18
3 7 2 17
1 97 3 87

Router architecture

  • Four parts: input and output port, routing processor and switching fabric.

Two key router functions:

  • run routing protocol
    • RIP, OSPF, BGP
  • forwarding datagrams from incoming to outgoing link

Input Port Queuing

  • Head-of-the-Line (HOL) blocking:
    • queued datagram at front of queue prevents others in queue from moving forward

Output Port Queuing

  • buffering when arriva- rate via switch exceeds output line speed
  • queueing (delay) and loss due to output port buffer overflow!

Packet Scheduling

Scheduling:

  • chooses among queued datagrams for transmission
    • fair queuing
    • weighted fair queuing

IP: Internet Protocol

Datagram format

IP Header TOS

IP Fragmentation and Reassembly
  • Network links have Maximum Transmission Unit (MTU)

IPv4

  • Classfu- IP addressing

  • Specia- addresses

Class Address
A 10.0.0.0 - 10.255.255.255
B 172.16.0.0 - 172.31.255.255
C 192.168.0.0 - 192.168.255.255

Subnetting: dividing an IP network into two or more
networks

VLSM (Variable Length Subnet Mask) 子网掩码
  • IP address = subnet id + host id
  • how to denote subnet mask?

    • a.b.c.d/x, where x is # bits in subnet portion of address
    • 1 for subnet id bits, 0 for host id bits (e.g. 255.255.255.0)
  • how to assign IP addresses for the subnets?

    • fix subnet part first
    • fix host part first

-> Given a class C IP address 223.1.1.0, how to assign IP addresses for the subnets?

  • Host first
  • Subnet first:
    • 6 subnets (>= 8 parts, host ID <= 5 bits)
    • -> x = 27
    • .32 -> .64 -> .96 … -> .192 (use broadcast address to indicate al- IP under a subnet)

  • 网络地址:表示了整个网络,不能被分配给具体的主机。例如,在子网掩码为/24的网络中,网络地址是第一个地址,即 x.x.x.0,不属于主机地址

  • 广播地址: 广播地址用于将数据包发送到网络上的所有主机。例如,在子网掩码为/24的网络中,广播地址是最后一个地址,即 x.x.x.255

CIDR表示法 Classless InterDomain Routing
  • Assign class C addresses in contiguous blocks of 256 addresses so that multiple entries in routing table can be reduced into one

CIDR表示法(a.b.c.d/x)转换为子网掩码通过将所有32位的二进制数中的前 x 位设置为 1,然后将 32-x 设置为 0 来完成。

  • /26确定了subnet标识符的长度为32位IP地址的前26位
  • subnet mask的前25位则位1,其余位设置为0,即可得到子网掩码

DHCP

DHCP的工作流程如下:

  • 设备连接到网络时,它发送DHCP请求(DHCP Discover)以寻找可用的DHCP服务器。
  • DHCP服务器收到请求后,为设备提供IP地址和其他配置信息(DHCP Offer)。
  • 设备选择一个提供的配置,并向选择的DHCP服务器发送请求(DHCP Request)。
  • 服务器确认请求,设备获得分配的IP地址和配置信息(DHCP Ack)。

通常路由器或无线路由器会集成DHCP服务器功能,以便自动为连接到网络的设备分配IP地址。

NAT: Network Address Translation
  • Motivation:
    hosts in LANs use private IP addresses and share one public IP address for Internet access:
    • handle public IP address shortage.
    • can change addresses of devices in LAN without notifying outside world
    • can change ISP without changing addresses of devices in LAN
    • devices inside not explicitly addressable, visible by outside world (a security plus).
NAT traversa- problem
  • solution 1: 静态NAT端口映射在NAT设备上手动配置
    • statically configure NAT to forward incoming connection requests at given port to server
    • e.g., (123.76.29.7, port 2500) always forwarded to 10.0.0.1 port 25000

端口地址转换(Port Address Translation,PAT)结合使用。在PAT中,多个设备可以共享同一个公共IP地址,但通过使用不同的端口号来区分它们。

  • solution 2: Universa- Plug and Play (UPnP) Internet Gateway Device (IGD) Protocol. NATed主机可以在运行时动态配置端口映射,无需手动干预NAT规则。
  • ==automate static NAT port map configuration==
    • Allows NATed host to:
      • learn public IP address (138.76.29.7) **学习公共IP地址
        • NATed主机可以使用UPnP协议获取与NAT设备关联的公共IP地址。这对于NATed主机了解其在互联网上的外部标识是很有用的。
      • add/remove port mappings (with lease times) **添加/删除端口映射
        • NATed主机可以通过UPnP协议请求NAT设备在路由器上创建或删除端口映射。这意味着NATed主机可以动态配置路由器以允许从外部访问它的服务。
        • 映射的端口是由UPnP协议与NAT设备协商确定的,租约时间规定了端口映射的持续时间,一旦过期,NAT设备可以自动删除映射。

  • solution 3: relaying (used in Skype)
    • NATed client establishes connection to relay 中继
    • Externa- client connects to relay
    • relay bridges packets between to connections

在中继方案中,不需要在NAT设备上配置端口映射规则,也不需要NATed客户端能够接收来自外部网络的连接。两方客户端都只需知道中继服务器的公共IP地址进行联络,而不需要直接处理彼此所在的NAT过程。

ICMP (Internet Contro- Message Protocol)

  • used by hosts & routers to communicate network-leve- information
    • error reporting: unreachable host, TT- exceeded, redirect, Checksum failed etc.
    • echo request/reply (used by ping)
  • network-layer “above” IP:

Type Code description
0 0 echo reply (ping)
3 0 dest. network unreachable
3 1 dest host unreachable
3 2 dest protoco- unreachable
3 3 dest port unreachable
3 4 ==fragmentation needed== [for path MTU discovery]
3 6 dest network
3 7 dest host
4 0 source quench (congestion contro- - not used)
8 0 echo request (ping)
9 0 route advertisement
10 0 router discovery
11 0 ==TT- expired== [for traceroute]
12 0 bad IP header

IPv6

  • Initia- motivation:
    • 32-bit address space soon to be completely allocated.
  • Additiona- motivation:

    • header format helps speed processing/forwarding
    • header changes to facilitate QoS
  • IPv6 datagram format:

    • fixed-length ==40 byte header==
    • extension headers allowed

  • IPv6 Addresses

    • The 16-byte IPv6 address is written as 8 groups of 4 hexadecima- digits with colons between
    • e.g. FE80::202:B3FF:FE1E:8329
  • An IPv6 address can be in one of three categories:

    • Unicast: A packet sent to a unicast address is delivered to the interface identified by that address.
    • Multicast: The packet wil- be processed by al- members of the multicast group.
    • Anycast (new to IPv6): The packet wil- be delivered to only one of the interfaces configured for the anycast address — usually to the nearest one.

SDN

数据平面->转发过程
硬件为主
控制平面->路由选择过程(较为复杂)
软件为主

  • 传统->SDN
    • 传统:路由选择器执行控制平面功能。既进行转发,也维护转发表
    • SDN:路由选择处理器负责与远程控制器通信,接受其计算的转发表项

路由选择 Routing

chap4-2

路由选择算法

  • static/dynamic routing
  • Each router learns the entire network topology through
    exchanging information with all other routers, and then
    calculate least cost path to the other routers.

  • Each router must do the following:

    • Discover its neighbors, measure the delay or cost to each of its neighbors.
    • Construct a packet telling all it has just learned.
    • Flood 洪泛 this packet to all other routers.
    • Compute the least cost path to every other router when costs of all the edges learnt
  • All least cost paths from a given source to other nodes in the network, constitute a sink tree

Distance vector routing (DVR) 距离向量路由
  • eg. 分布式Bellman-Ford路由算法, RIP

  • Each router maintains a table (i.e Distance Vector) with least
    cost/distance to every other routers.

  • Each router must do the following:

    • Discover its neighbors, measure the cost to each neighbor v.
    • Exchange DV with the neighbors.
    • Recalculate DV (the new least cost to every other routers) with the Bellman-Ford equation: $d_x(y) = min (c(x,v) + d_v(y) )$
      where $d_x(y)$ is least-cost from x to y, min is taken over all neighbors v of x

    DVR “count to infinity” problem

    • good news travels fast.
    • bad news travels slowly :
      • count-to-infinity in the presence of node crashes
    • unsuitable for large network.
      LSR vs DVR
  1. message complexity: how many msgs sent between all n nodes?
    • LS: with n nodes, E links, totally $O(n\times E)$ msgs sent
    • DV: exchange between neighbors only, totally $O(n)$ msgs sent
  2. computation complexity: algorithm for calculating least cost each
    • LS: Dijkstra , $O(n^2)$
    • DV: Bellman-Ford equation , $O(n)$
  3. speed of convergence: given a change, how long until the network re-stabilizes?
    • LS: 1 iteration. may have oscillations
    • DV: n iterations.
      • Good news travel fast, but possible count-to-infinity problem for bad news.
  4. Robustness: what can happen if a router fails or misbehaves?
    • LS: robust. Node route calculations are somewhat separated
    • DV: an incorrect node calculation can be diffused through the entire network. A node can advertise incorrect least-cost paths to its neighbors and then pass indirectly to its neighbor’s neighbors and then to all destinations.
Hierarchical Routing 层次路由算法

hierarchical routing saves table size, reduced update traffic.

  • “autonomous systems” (AS)
    • aggregate routers into regions, correspond to an administrative domain 管理域.
    • Assigned an unique 16/32 bit number.
  • ==intra-AS==/interior gateway routing 内部网关路由
    • should find the least cost path as best as possible
    • routers in same AS run same routing protocol -> trusted
    • routers in different AS can run different intra-AS routing protocol
  • ==inter-AS==/exterior gateway routing 外部网关路由
    • has to deal with a lot of politics.
    • Routers do not automatically use the routes they find, but have to check manually whether it is allowed.
    • admin controls over how traffic routed -> untrusted

Broadcast routing

In-network duplication
  • flooding: when node receives broadcast packet, sends copies to all neighbors
    • Problems: cycles & broadcast storm
  • controlled flooding:
    • TTL,age
    • node keeps track of packet IDs already brdcsted
    • reverse path forwarding (RPF):
      • only forward packet if it arrived on shortest path between node and source
  • spanning tree
    • no redundant packets received by any node
Reverse Path Forwarding
  • Method: use the routing table reversely. If the broadcast
    packet comes from a node which is the next hop to the source,
    then forwards copies of it onto all lines except the one it
    arrived on, else discards it.
  • Pros: efficient and easy to implement

ch5 数据链路层

Link layer is implemented in “adaptor” (network interface card NIC) in each host and routers.

Data-link layer has responsibility of transferring datagram from one node to physically adjacent node over a link (node-to-node job)

Functions

  • reliable data transfer 可靠传输
    • error control 差错控制
    • flow control 流量控制
  • sharing a broadcast channel: multiple access control
  • link layer addressing 封装成帧和透明传输

Functions

  • 加强物理层传输原始比特流的功能,使之对网络层表现为无差错链路

封装成帧

  • 添加首尾部,构成帧定界
  • 帧同步:接收方可以从二进制比特流中区分帧的起始和终止

透明传输

  • 不管所传数据是什么组合,都应当可在链路上传输。
  • 所传数据的比特组合恰好等于控制信息也不会导致误认。
  1. 字符计数法

    • 容易出错
  2. 字符填充法

SOH data EOT
Start of header End of transimission
  • 在数据段内的SOH和ESC前添加转义字节防止误判
  1. 零比特填充法
  • 每遇到5个1就填充1个0

  • HDLC – High-Level Data Link Control 高级数据链路控制

    • A pretty old, but widely used protocol for point-to-point connections.
    • bit-oriented
  • PPP – The Point-to-Point Protocol 点到点协议
    • Internet standard (RFC1661 1662 1663), is used in the Internet for a variety of purposes, including router-to-router traffic and home user-to-ISP traffic.
    • byte-oriented

ch6 物理层

  • 信源 - 信道 -> 信宿

通信方式

  • 单工通信

    • 单一方向,单一信道
  • 半双工/双向交替通信

    • 均可发送和接受,但是不能同时
    • 两条信道
  • 全双工/双向同时通信

传输方式

  • 串行/并行
  • 同步/异步

    • 同步:以数据区块为单位,先送出同步字符
    • 异步:以组为单位,加字符起始位和终止位
  • 码元

    • 固定时长的信号波形
    • M个离散状态 -> M进制码元

奈氏准则

在理想低通条件下,为了避免码间串扰,极限码元传输速率为2W Baud,W为信道带宽,单位为Hz。

香农定理

噪声存在于所有的电子设备和通信信道中。由于噪声随机产生,它的瞬时值有时会很大,因此噪声会使接收端对码元的判决产生错误。但是噪声的影响是相对的,若信号较强,那么噪声影响相对较小。因此,信噪比 (信号的平均功率S/噪声的平均功率N -> db表示 = $10log_{10}S/N$) 就很重要。

编码&调制

  • 信号类型
    • 基带信号:直接表达了要传输的信息的信号
      • 数字信道 -> 基带传输
    • 宽带信号:基带信号调制后的频分复用模拟信号
      • 模拟信道 -> 宽带传输

数据 -> 数字信号(编码)

曼彻斯特编码:自同步,但是占用两倍宽度的频带,数据传输速率为调制速率的一半
+差分:同1异0(虚线两侧)。更强的抗干扰性


信号电平翻转表示0

4B/5B:额外插入比特,保留控制码

模拟数据 -> 数字信号

高保真:PCM 脉码调制
f采样频率>=2f信号最高频率

数据 -> 模拟信号(调制)


调频+调相 = QAM
可以表示的码元类型为相位类型数*振幅类型数

模拟数据 -> 模拟信号

频分复用

数据交换

电路交换

  • 建立连接 -> 通信 -> 释放连接
  • 高占用,低时延,建立连接时间长,全双工,控制简单

报文交换

存储转发

  • 只适用于数字信号

分组交换

分组后存储转发

  • 数据报方式

    • 无连接服务
    • 分组多次,不能保证到达顺序
    • 每次转发进行验证后删除,有一定时延
  • 虚电路方式

    • 连接服务
    • 需要携带虚电路号信息
    • 顺序保证

传输介质

物理通路

  • 导向性

    • 双绞线
      • 屏蔽~ STP,非屏蔽~ UTP
    • 同轴电缆
    • 光纤
      • 光脉冲
      • 带宽极大
      • 实心纤芯 + 包层
      • 单模 -> 横向,远距离;多模 -> 易失真,近距离
  • 非导向性

    • 无线电波:所有方向
      • 强穿透,远距离
    • 微波:定向
      • 地面微波接力通信
      • 卫星通信
    • 红外线/激光:定向

设备

  • 中继器

    • 再生和还原数字信号
    • 没有存储转发功能
    • 使用范围有限制:5-4-3规则
  • 集线器

    • 再生 放大 转发信号
    • 共享式设备
    • 非定向