Unit 1

学习目标:

  1. how an application use the Internet
  2. The structure of the Internet:The 4 layer model
  3. The Internet protocol(IP)
  4. Basic architectural ideas and principles:
    • Packet switching
    • Layering
    • Encapsulation

1.1 A Day in the life of an Application

  • Dominant model:

    • bidrectional
    • reliable byte stream connection
1. World Wide Web (HTTP)
  • C/S架构
  • 发送commands,接收responses
  • request:"GET / HTTP/1.1"
  • response: "HTTP/1.1 200 OK"
2. BitTorrent
  • P2P架构
  • break files into "pieces"
  • 所有存有pieces file的client被称为swarm,client join and leave swarms
  • tracker追踪swarm的成员,通过torrent file向一个tracker获取swarm中的client列表
  • request: "GET list of clients in swarm"
  • response: "200 OK list of clients"
3. Skype
  • mixed架构
  • 如果两个client能互联,就在client间建立连接--->P2P
  • 如果有一方存在NAT:Client A-----Internet-----NAT---ClientB
    • 由于NAT,B可以连接A,但A无法连接B
    • A cannot open connection to B
    • B在一个Rendezvous上注册,A向Rendezvous发送请求,Rendezvous转发请求给B,B主动和A建立连接
  • 双方均存在NAT
    • 通过一个Relay转发服务器作为中转,转发双方的消息

1.2 What the Internet is: The 4 Layer Internet Model

  1. Application:(http, bit-torrent)

    • application-specific semantics
  2. Transport:(tcp, udp)
    • guarantees correct, in-order delivery of data end-to-end
    • controls congestion
  3. Network:(IP)
    • must use the Internet Protocol(IP)
    • best-effort attempt to deliver datagrams, no promises
    • IP datagrams can get lost, out of order, and can be corrupted
  4. Link:(802.11, 3G, DSL, Ethernet)
    • one-hop control
    • delivers data over a single link between an end host and router, or between routers

two extra things need to know:

  1. IP is the "thin waist"
  2. the 7-layer OSI Model
    • Application------http--------Application----7
    • Application------ASCII-----Presentation--6
    • Transport--------TCP-------Session--------5
    • Transport--------TCP-------Transport------4
    • Network----------IP----------Network--------3
    • Link---------------Ethernet----Link------------2
    • Link---------------Ethernet----Physical------1

1.3 What the Internet is: The IP service model

  1. The Internet Protocol(IP)

    • Transport Segment
    • IP Datagram、Packets
    • Link Frame
  2. The IP service Model

    Property Behavior
    Datagram Hop by hop routing
    Unreliable Packets might be dropped because of full wait queue
    Best effort
    Connectionless No per-flow state. Might be mis-sequenced
  3. why simple?

    • faster, more streamlined and lower cost to build and maintain
    • The end-to-end principle: implement features in the end hosts if possible
    • Allows a variety of reliable(or not) services to be built on top
    • Works over any link layer: IP makes very few assumptions about the link layer below
  4. The IP service model

    1. Tries to prevent packets looping forever(TTL, time to live)
    2. Will fragment packets if they are too long
    3. Uses a header checksum to reduce chances of delivering datagram to wrong destination
    4. Allows for new versions of IP
      • IPv4: 32 bit
      • IPv6: 128 bit
    5. Allows for new options to be added to header

Quiz:

In an alternative to the Internet Protocol called "ATM" proposed in the 1990s, the source and destination address is replaced by a unique "flow" identifier that is dynamically created for each new end-to-end communication. Before the communication starts, the flow identifier is added to each router along the path, to indicate the next hop, and then removed when the communication is over. Which of the following statements are implications of this design? Check all that apply.

  1. (+)There is state in the network for every communication flow, rather than just for every destination.
  2. (-)If a link fails, there is no need to update any state in the network.
  3. (-)There must be a centralized controller to manage the insertion and removal of identifiers, as well as update them whenever a flow needs to be re-routed.
  4. (-)It means we no longer need a transport layer to reliably deliver correct, in-order data to applications.

1.4 A day in the life of a packet

  • application: stream of data
  • transport: segment of data
  • network: packet of data
  1. TCB Byte Stream

    • "3-way handshaking"
    • "SYN" "SYN/ACK" "ACK"
    • To computer:network layer address: IP address
    • To application:transport layer address: port
      • web server: port 80
  2. Inside the Stream

    • hops: a link of two nodes
    • access point
  3. Inside Each Hop

    • forwarding table

      • key: IP address pattern, value: link
      • longest prefix match
    • default entry: least specific router
      • mostly used in edge network

1.5 Principle: Packet Switching

  • Packet: A self-contained unit of data that carries information necessary for it to reach its destination.
  • Flow: A collection of datagrams belonging to the same end-to-end communicaition, e.g. a TCP connection
  • two consequences
    • Simple: no per-flow state required, self-contained
    • Efficient: allows flows to use all available link capacity
      • Staticstical Multiplexing: taking a single resource and sharing it across multiple users in a probabilistic way

1.6 Principle: Layering

  • layering: the organizaiton of a system into a number of separate functional components or layers
  • Reasons for layering:
    1. Modularity
    2. Well defined service
    3. Reuse
    4. Separation of concerns
    5. Continuous improvement
    6. Peer to peer communications

1.7 Principle: Encapsulation

  • layering:

    • Transport: segment, inter-application communication
    • Link: frame, inter-host communication on a shared link
  • How layering manifests in data representation?
    • layer N data is payload to layer N - 1
    • allows to layer recursively
    • Example: VPN(Virtual Private Network)
      • VPN open a secure connection to a network you trust (like your office network)



  • Encapsulated payloads
    • Help separation of concerns
    • Help enforce boundaries/layering
    • Simplify layer implementations
    • Can not protect from malicious attacks

1.8 Byte order and Packet format

  • Network byte order is big endian
  • Helper functions: htons(), ntohs(), htonl(), ntohl()
    • htons:"host to network short"
    uint16_t http_port = 80; //Host order
    if (packet->port == http_port) { ... //network vs. host order uint16_t http_port = 80;//Host order
    uint16_t packet_port = ntohs(packet->port);
    if (packet_port == http_port) { ... //OK

Quiz:

(+)The layout of a character string in memory is the same on big-endian and little-endian architectures.

1.9 IPv4 addresses and CIDR

  1. Goal of Internet Protocal(IP) Addresses

    • Stitch many different networks together
    • Need network-independent, unique address
  2. Internet Protocal, Version 4
    • Layer 3(network) address
    • 32 bits long(4 octets):a.b.c.d
      • ex: 171.64.64.64
    • Netmask: tells the device which IP addresses are local -- on the same link -- and which require going through an IP router.
      if (A & netmask == B & netmask) {
      on the same network
      }
      • 如果dest和src的掩码相同就不用经过路由器转发,可以直接发送
      • smaller netmask means larger network
  3. Classes Inter-Domain Routing(CIDR, 无类别域间路由)
    • 最初架构:将所有IP地址分成3类,每一类将IP地址分成两个部分,network和host,分别表示

      • network part: administrative domain, such as MIT, BBN
      • host part: which device within that network

    • 当前CIDR架构:
      • Rather than hava prefixes only of length 8, 16, and 24 bits, CIDR allows prefixes to be any number of bits
      • Address block is pair: address, count
      • All CIDR prefixes define a block of addresses that is a power of 2
        • 因此描述IP地址时需要附带其掩码长度
        • eg: 171.64.0.0/16 means any address in the range 171.64.0.0 to 171.64.255.255
    • IPv4 Address Assignment
      • IANA: Internet Assigned Numbers Authority

        • Internet Corporation for Assignment of Names and Numbers(ICANN)'s job
      • IANA gives out /8s(16百万个地址) to Regional Internet Registries(RIRs,每个大陆有一个,每个RIR有自己的分配政策)
        • Ran out in Feburary 2011, 当只剩下最后5个/8s时,IANA给每个RIR一个/8
  4. Longest prefix match(LPM)
    • forwarding table is a set of CIDR entries

1.10 Address resolution protocol(ARP)

  1. Layers of Address

    • ARP: The mechanism by which the network layer can discover the link address associated with a network address it's directly connected.
    • A link address describes a particular network card. eg: Ethernet has 48 bit addresses
    • Host: 171.67.76.65
    • Interface: 00:13:72:4c:d9:6a
  2. Addressing Problem
    • 因为子网掩码的概念,router或gateway通常有多个interface,每个接口(interface)对应一个识别自身网卡link address以及一个识别host主机的network layer address,例如下图中的网关(gateway),具有两个network cards:

      • 当A向B发送IP packet时,通过子网掩码知道A和B不在一个网络中,因此首先需要经过gateway,A虽然知道gateway的IP地址,但是不一定知道gateway的link address
  3. Encapsulation
    • 在IP层,Ip packet只需要知道dest和source host的ip地址
    • 在Link layer,负责一段链路,因此每一段链路的link layer address
  4. Address Resolution Protocol
    • request-reply protocal
    • Each node keeps a cache of mappings from IP addresses on its network to link layer addresses
    • 请求发送方式:广播(Link address全1,48个1)
      • 请求中包含请求者的ip和link address,因此所有收到该ARP请求的节点都可以insert or refresh a mapping from their cache
    • 响应发送方式:协议要求unicast(单播),通常实现为广播
      • 节点仅响应对他们自己的请求
      • 因此,如果一个节点断开连接或crash,当所有mappings过期后才算离开网络
        • mappings存储时间取决于设备,Mac OSX保持20min。Cicso设备保持4hours
    • 节点进入网络也可以发送gratuitour(免费) ARP packets,requesting non-existent mappings,in order to advertise themselves on a network
  5. ARP Packet Format(RFC826)

    • Hardware: what link layer this request or response is for
    • Protocol: what network protocol this request is for
    • length fields: 长度
    • opcode:packet类型是发送还是响应

cs244a-Introduction to Computer Networking-Unit1的更多相关文章

  1. A Simple Introduction To Computer Networking

    Most networking discussions are a jumble of acronyms. Forget the configuration details - what are th ...

  2. MIT Introduction to Computer Science and Programming (Lesson one )

    MIT Introduction to Computer Science and Programming (Lesson one ) 这篇文是记载 MIT 计算机科学及编程导论 第一集 的笔记 Les ...

  3. Computer Networking: A Top Down Approach

    目录 Chapter 1: Computer Networks and the Internet 1. What is the Internet? 2. The Network Edge 3. The ...

  4. Note 2 for <Pratical Programming : An Introduction to Computer Science Using Python 3>

    Book Imformation : <Pratical Programming : An Introduction to Computer Science Using Python 3> ...

  5. Note 1 for <Pratical Programming : An Introduction to Computer Science Using Python 3>

    Book Imformation : <Pratical Programming : An Introduction to Computer Science Using Python 3> ...

  6. Introduction to Computer Science and Programming in Python--MIT

    学习总结--(Introduction to Computer Science and Programming in Python--MIT) 导论 主题 重新利用数据结构来表达知识 理解算法的复杂性 ...

  7. Introduction to Computer Networks(网络架构与七层参考模式)

    Network Connectivity 1. Important terminologies 1) Link 设备连接的连线.Link本身既可以是有线的,也可以是无线的. 2) Node 设备.电脑 ...

  8. An Introduction to Computer Thinking

    1.Die Grundlage des Computers 1.1 Binärzahl in die Dezimalzahl umsetzen Bereiten nach Gewicht,dann b ...

  9. MITx: 6.00.1x Introduction to Computer Science and Programming Using Python Week 2: Simple Programs 4. Functions

    ESTIMATED TIME TO COMPLETE: 18 minutes We can use the idea of bisection search to determine if a cha ...

  10. edX MITx: 6.00.1x Introduction to Computer Science and Programming Using Python 课程 Week 1: Python Basics Problem Set 1 Problem 3

    Assume s is a string of lower case characters. Write a program that prints the longest substring of  ...

随机推荐

  1. THUWC 2019游记

    坑先占着QwQ 不太喜欢写Blog, 因此我的Blog一直很冷清,但是还是想写写这种游记啦,反正是给自己看的 Day -4 颓了一整天,一道题都没写 于是无聊用GL写了一个海战游戏,让两个程序对打-- ...

  2. Remove the Substring

    D2. Remove the Substring (hard version) 思路:其实就是贪心吧,先从前往后找,找到 t 可在 s 中存在的最小位置 (pre),再从后往前找,找到 t 可在 s ...

  3. [CSP-S模拟测试]:求和(数学)

    题目传送门(内部题107) 输入格式 一行五个正整数$x_1,y_1,x_2,y_2,m$ 输出格式 输出一个整数,为所求的答案对$m$取模后的结果. 样例 样例输入: 2 1 5 3 10007 样 ...

  4. MyBatis中的JdbcType映射介绍

    版权声明:本文为博主原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接和本声明.                                               本 ...

  5. Docker入门-构建第一个Java程序

    定制镜像 准备一个没有第三方依赖的java web项目,可能参考示例maven结构项目: session-web.war 把该war上传到安装有docker软件的服务器上宿主目录下.在同级目录创建Do ...

  6. 全面解读php-php会话控制技术

    一.PHP会话控制技术 1.为什么要使用会话控制技术? 因为http协议是无状态协议,所以同一个用户在请求同一个页面两次的时候,http协议不会认为这两次请求都来自于同一个用户,会把它们当做是两次请求 ...

  7. hibernate必须的包下载以及各个包的作用

    hibernate必须的包(点击下载) 对应的入门级代码例子(点击下载) hibernate3.jar  hibernate核心包 commons-collections-2.1.1.jar  集合包 ...

  8. 浏览器端-W3School-JavaScript:JavaScript Date 对象

    ylbtech-浏览器端-W3School-JavaScript:JavaScript Date 对象 1.返回顶部 1. Date 对象 Date 对象用于处理日期和时间. 创建 Date 对象的语 ...

  9. 2019-7-29未命名文件 sdfsdfsdf

    2019-7-29未命名文件 sdfsdfsdf 新建模板小书匠 欢迎使用 小书匠(xiaoshujiang)编辑器,您可以通过设置里的修改模板来改变新建文章的内容.

  10. 函数参数<一>

    <1> 定义带有参数的函数 示例如下: def add2num(a, b): c = a+b print (c) <2> 调用带有参数的函数 以调用上面的add2num(a, ...