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

UDP and TCP的更多相关文章

  1. 移动端IM系统的协议选型:UDP还是TCP?

    1.前言 对于有过网络编程经验的开发者来说,使用何种数据传输层协议来实现数据的通信,是个非常基础的问题,它涉及到你的第一行代码该如何编写. 从PC时代的IM开始,IM开发者就在为数据传输协议的选型争论 ...

  2. RUDP之一 —— UDP VS TCP

    原文链接 原文:http://gafferongames.com/networking-for-game-programmers/udp-vs-tcp/ 介绍 大家好,我是Glenn Fiedler, ...

  3. 第五章 运输层(UDP和TCP三次握手,四次挥手分析)

    序言   通过这章,可以知道其实三次握手和四次挥手其实真的好简单,通过这章的学习,我相信你也会同样的认为,以后在也不需要听到别人问三次握手的过程而自己一脸懵逼了,觉得人家好屌,其实也就是他懂你不懂,仅 ...

  4. 网游中的网络编程系列1:UDP vs. TCP

    原文:UDP vs. TCP,作者是Glenn Fiedler,专注于游戏网络编程相关工作多年. 目录 网游中的网络编程系列1:UDP vs. TCP 网游中的网络编程2:发送和接收数据包 网游中的网 ...

  5. DNS分别在什么情况下使用UDP和TCP

    DNS同时占用UDP和TCP端口53是公认的,这种单个应用协议同时使用两种传输协议的情况在TCP/IP栈也算是个另类.但很少有人知道DNS分别在什么情况下使用这两种协议.     如果用wiresha ...

  6. JAVA基础学习day24--Socket基础一UDP与TCP的基本使用

    一.网络模型 1.1.OIS参考模型 1.2.TCP/IP参考模型 1.3.网络通讯要素 IP地址:IPV4/IPV6 端口号:0-65535,一般0-1024,都被系统占用,mysql:3306,o ...

  7. 初识-----基于Socket的UDP和TCP编程及测试代码

    一.概述 TCP(传输控制协议)和UDP(用户数据报协议是网络体系结构TCP/IP模型中传输层一层中的两个不同的通信协议. TCP:传输控制协议,一种面向连接的协议,给用户进程提供可靠的全双工的字节流 ...

  8. 通信协议之HTTP,UDP,TCP协议

    1.UDP,TCP,HTTP之间的关系 tcp/ip是个协议组,它可以分为4个层次,即网路接口层,网络层,传输层,以及应用层, 在网络层有IP协议.ICMP协议.ARP协议.RARP协议和BOOTP协 ...

  9. Http UDP还是TCP

    http://1024monkeys.wordpress.com/2014/04/01/game-servers-udp-vs-tcp/ 在编写网络游戏的时候,到底使用UDP还是TCP的问题迟早都要面 ...

  10. 游戏服务器:到底使用UDP还是TCP

    http://blog.jobbole.com/64638/ 在编写网络游戏的时候,到底使用UDP还是TCP的问题迟早都要面对. 一般来说你会听到人们这样说:“除非你正在写一个动作类游戏,否则你就用T ...

随机推荐

  1. Java--详解WebService技术

    Java--详解WebService技术 一.什么是 webservice WebService是一种跨编程语言和跨操作系统平台的远程调用技术. 所谓跨编程语言和跨操作平台,就是说服务端程序采用jav ...

  2. nodejs的get与post

    index.html <html> <body> <form action="/api/v1/records" method="post&q ...

  3. VS2013 C++ 动态链接库的生成

    原文:http://www.cnblogs.com/djiankuo/p/5092025.html 这个东西搞了好几天,现在终于没有问题了,其实现在想来还是微软做的东西好用啊,在这里点个赞!!! LL ...

  4. 二维码Zxing&Zbar

    二维码Zxing&Zbar 前言:该项目主要介绍了二维码扫描.闪光灯开启.本地二维码图片识别.二维码生成.分别是zxing和zbar(网格二维码)分别实现,具体效果运行项目apk... 开发环 ...

  5. windows c++ 修改用户的文件夹操作权限

    一般Windows下的系统文件(夹)只让受限帐户读取而不让写入和修改.如果要开启写操作权限就需要手动修改文件(夹)的用户帐户安全权限(这操作当然要在管理员帐户下执行).以下用程序封装了一下该操作: # ...

  6. Linux下mysql安装过程

    到mysql官网下载mysql编译好的二进制安装包,在下载页面Select Platform:选项选择linux-generic,然后把页面拉到底部,64位系统下载Linux - Generic (g ...

  7. html 颜色在线取色器

    推荐一个链接 还不错 http://www.atool.org/colorpicker.php

  8. SQL Server ->> T-SQL查询面试题之实例版

    1 - 3 题: 数据表结构: OrderID ProductID OrderDate  SaleAmount 1 1 2015-01-01 100 2 6  2015-02-01 900 3 1   ...

  9. 使用WdatePicker日期组件时,选择日期后,执行某个方法

    WdatePicker({onpicked:function(){alert(123);},dateFmt:'yyyy年MM月dd日',maxDate:'%y-%M-%d'}) 1.onpicked: ...

  10. SVNKit学习——wiki+简介(二)

    这篇文章是参考SVNKit官网在wiki的文档,做了个人的理解~ 首先抛出一个疑问,Subversion是做什么的,SVNKit又是用来干什么的? 相信一般工作过的同学都用过或了解过svn,不了解的同 ...