zoukankan      html  css  js  c++  java
  • UDP and TCP

    UDP

    • unreliable, just add de-multiplexing and error checking on data than IP.
    • Best effort datagram(数据报) service
    • Multiplexing enables sharing of IP datagram service
    • Simple transmitter & receiver
      • Connectionless: no handshaking & no connection state
      • Low header overhead
      • No flow control, no error control, no congestion control
      • UDP datagrams can be lost or out-of-order
    • Applications
      • multimedia (e.g. RTP)
      • network services (e.g. DNS, RIP, SNMP)

    UDP Datagram

    • 0-255

      • Well-known ports
    • 256-1023

      • Less well-known ports
    • 1024-65536

      • Ephemeral(短暂的) client ports
    • Source and destination port numbers

      • Client ports are ephemeral(短暂的)
      • Server ports are well-known
      • Max number is 65,535
    • UDP length

      • Total number of bytes in datagram (including header)
      • 8 bytes ≤ length ≤ 65,535
    • UDP Checksum

      • Optionally detects errors in UDP datagram(Because the error packet will be discard)

    UDP De-Multiplexing(解复用)

    • All UDP datagrams arriving to IP address B and destination port number n are delivered to the same process
    • Source port number is not used in demultiplexing

    UDP Checksum Calculation

    • UDP checksum detects for end-to-end errors
    • Covers pseudoheader(伪报头) followed by UDP datagram
    • IP addresses included to detect against** misdelivery(错误传输)**
    • The use of UDP checksums is optional
    • But hosts are required to have checksums enabled

    TCP

    • Reliable byte-stream service
    • More complex transmitter & receiver
      • Connection-oriented: full-duplex(全双工) unicast connection between client & server processes
      • Connection setup, connection state, connection release
      • Higher header overhead
      • Error control, flow control, and congestion(拥塞) control
      • Higher delay than UDP
    • Most applications use TCP
      • HTTP, SMTP, FTP, TELNET, POP3, …

    TCP Multiplexing

    • A TCP connection is specified by a 4-tuple(数组)
      • (source IP address, source port, destination IP address, destination port)
    • TCP allows multiplexing of multiple connections between end systems to support multiple applications simultaneously

    Reliable Byte-Stream Service

    • Stream Data Transfer:transfers a contiguous stream of bytes across the network, with no indication of boundaries
    • groups bytes into segments(部分)
    • transmits segments as convenient (Push function defined)
      Reliability: error control to deal with IP transfer impairments(损害)

    TCP Segment Format

    TCP Header

    Window Size:TCP protocol need ACK to ensure the packet be transported, if we receive ACK after every packet arriving, it will waste a lot of time.So we need the Window Size to tell us how many packet we can send one time.

    • 16 bits to advertise window size
    • Used for flow control
    • Sender will accept bytes with SN from ACK to ACK + window
    • Maximum win size 65535 bytes
    • TCP Checksum
    • Internet checksum method
    • TCP pseudoheader + TCP segment
  • 相关阅读:
    留言板!
    NX二次开发-OLE/COM向EXCEL表格中插入图片
    NX二次开发-UFUN读取图纸尺寸的值UF_DRF_ask_dimension_text
    NX二次开发-UFUN修剪体UF_MODL_trim_body
    NX二次开发-UFUN相加布尔操作,可保留或删除目标体,工具体UF_MODL_unite_bodies_with_retained_options
    C++之判断字符串是否是数字
    CommandLineToArgvW调EXE传入参数【转载】
    NX二次开发-用户自定义资源栏选项卡RegisterActivationCallback
    NX二次开发-自定义添加右键菜单RegisterConfigureContextMenuCallback
    NX二次开发-调系统命令UF_load_library[UFUN调DLL]
  • 原文地址:https://www.cnblogs.com/vancasola/p/7683910.html
Copyright © 2011-2022 走看看