IP网络5种基本寻址方式 (单播、多播、广播、任播、地域多播)
Addressing methods
The Internet Protocol and other network addressing systems recognize five main addressing methodologies:
-单播Unicast
addressing uses a one-to-one association between destination address and network endpoint: each destination address uniquely identifies a single receiver endpoint.
-多播Multicast
addressing uses a one-to-unique many association, datagrams are routed from a single sender to multiple selected endpoints simultaneously in a single transmission.
详见《TCP/IP 详解 卷2 :实现》
第12章 IP多播
第13章 IGMP:Internet 组管理协议
第14章 IP多播 选路(路由)
代码的实现:
1.http://www.tldp.org/HOWTO/Multicast-HOWTO-6.html
2.libuv 中也有实现 (uv.h、 /win/udp.c、 /unix/udp.c)
主要看setsockopt()操作,以下是加入,离开组 (公网上的D组IP),使用 IGMP协议
switch (membership) {
case UV_JOIN_GROUP:
optname = IP_ADD_MEMBERSHIP;
break;
case UV_LEAVE_GROUP:
optname = IP_DROP_MEMBERSHIP;
break;
default:
return UV_EINVAL;
}
if (setsockopt(handle->socket,
IPPROTO_IP,
optname,
(char*) &mreq,
sizeof mreq) == SOCKET_ERROR) {...}
UV_EXTERN int uv_udp_init(uv_loop_t*, uv_udp_t* handle);
UV_EXTERN int uv_udp_init_ex(uv_loop_t*, uv_udp_t* handle, unsigned int flags);
UV_EXTERN int uv_udp_open(uv_udp_t* handle, uv_os_sock_t sock);
UV_EXTERN int uv_udp_bind(uv_udp_t* handle,
const struct sockaddr* addr,
unsigned int flags);
UV_EXTERN int uv_udp_getsockname(const uv_udp_t* handle,
struct sockaddr* name,
int* namelen);
UV_EXTERN int uv_udp_set_membership(uv_udp_t* handle,
const char* multicast_addr,
const char* interface_addr,
uv_membership membership);
UV_EXTERN int uv_udp_set_multicast_loop(uv_udp_t* handle, int on);
UV_EXTERN int uv_udp_set_multicast_ttl(uv_udp_t* handle, int ttl);
UV_EXTERN int uv_udp_set_multicast_interface(uv_udp_t* handle,
const char* interface_addr);
UV_EXTERN int uv_udp_set_broadcast(uv_udp_t* handle, int on);
UV_EXTERN int uv_udp_set_ttl(uv_udp_t* handle, int ttl);
UV_EXTERN int uv_udp_send(uv_udp_send_t* req,
uv_udp_t* handle,
const uv_buf_t bufs[],
unsigned int nbufs,
const struct sockaddr* addr,
uv_udp_send_cb send_cb);
UV_EXTERN int uv_udp_try_send(uv_udp_t* handle,
const uv_buf_t bufs[],
unsigned int nbufs,
const struct sockaddr* addr);
UV_EXTERN int uv_udp_recv_start(uv_udp_t* handle,
uv_alloc_cb alloc_cb,
uv_udp_recv_cb recv_cb);
UV_EXTERN int uv_udp_recv_stop(uv_udp_t* handle);
这里有cisco 整理的Multicast RFC的文档列表
IETF RFCs for IP Multicast
This appendix contains Internet Engineering Task Force (IETF) RFCs related to IP multicast. For information about IETF RFCs, see http://www.ietf.org/rfc.html.
RFCs
- RFC 2236 Internet Group Management Protocol
- RFC 2365 Administratively Scoped IP Multicast
- RFC 2858 Multiprotocol Extensions for BGP-4
- RFC 3376 Internet Group Management Protocol, Version 3
- RFC 3446 Anycast Rendezvous Point (RP) mechanism using Protocol Independent Multicast (PIM) and Multicast Source Discovery Protocol (MSDP)
- RFC 3569 An Overview of Source-Specific Multicast (SSM)
- RFC 3618 Multicast Source Discovery Protocol (MSDP)
- RFC 4291 IP Version 6 Addressing Architecture
- RFC 4541 Considerations for Internet Group Management Protocol (IGMP) and Multicast Listener Discovery (MLD) Snooping Switches
- RFC 4601 Protocol Independent Multicast - Sparse Mode (PIM-SM): Protocol Specification (Revised)
- RFC 4610 Anycast-RP Using Protocol Independent Multicast (PIM)
- RFC 5059 Bootstrap Router (BSR) Mechanism for Protocol Independent Multicast (PIM)
- RFC 5132 IP Multicast MIB
-广播boardcast
addressing uses a one-to-many association, datagrams are routed from a single sender to multiple endpoints simultaneously in a single transmission. The network automatically replicates datagrams as needed for all network segments (links) that contain an eligible receiver.
-任播Anycast
addressing routes datagrams to a single member of a group of potential receivers that are all identified by the same destination address. This is a one-to-nearest association.
-地域多播Geocast
refers to the delivery of information to a group of destinations in a network identified by their geographical locations. It is a specialized form of Multicast addressing used by some routing protocols for mobile ad hoc networks.
https://en.wikipedia.org/wiki/Geographic_routing
RFC 参考wiki中的 链接,这里我就不过多说明了
图片:

需要特别说明的是 使用场合
视频直播:
基本都是 【组播】(寻址,路由分发) + UDP(穿透)视频点播:
一般是用TCP。比较容易的控制进度,打开,关闭等操作。
但是也有用UDP的,一些顺序控制,操作。 要自己实现。
youku视频点播, 抓包发现,既有TCP,又有UDP(大的视频)。 那么问题来了UDP遇到如下几个问题,怎么办?
1.网络丢包 + 帧顺序 问题
按照文件块发送,但是网络差的时候,UDP丢帧,就重传这个文件块的数据。
文件块保持数据的顺序性, UDP顺序保证的话,估计是adobeflash的服务器和adobeflash客户端中 有类RTSP的协议。( 增加 帧序号,等信息)
2. 进度等操作
(youku 拖拽位置等操作,如果是UDP做的话,那么每个位置坐标就要对应数据内容块的位置。 其实有可能是adobeflash框架中实现的(包里面有信息,暂时认为是类RTSP 的协议吧),youku只是用adobeflash的服务端而已。)
YouTube 的数据包也可以抓来看下,(应该也是用UDP, 每个数据包都有 时间戳,SYN顺序 等信息。) 从右开始插入排序,放到解码队列,然后再播放。
客户端使用时候再 具体做处理。
待验证。。。
广播:
一般用于局域网。
容易混淆的是 多播和任播,
==========
相关
webcast
A webcast is a media presentation distributed over the Internet using streaming media technology to distribute a single content source to many simultaneous listeners/viewers. A webcast may either be distributed live or on demand. Essentially, webcasting is “broadcasting” over the Internet.Packet forwarding
Packet forwarding is the relaying of packets from one network segment to another by nodes in a computer network.
The Network Layer of the OSI Layer is responsible for Packet Forwarding.[1] The simplest forwarding model—unicasting—involves a packet being relayed from link to link along a chain leading from the packet's source to its destination. However, other forwarding strategies are commonly used. Broadcasting requires a packet to be duplicated and copies sent on multiple links with the goal of delivering a copy to every device on the network. In practice, broadcast packets are not forwarded everywhere on a network, but only to devices within a broadcast domain, making broadcast a relative term. Less common than broadcasting, but perhaps of greater utility and theoretical significance, is multicasting, where a packet is selectively duplicated and copies delivered to each of a set of recipients.Port forwarding 常用于穿透
In computer networking, port forwarding or port mapping is an application of network address translation (NAT) that redirects a communication request from one address and port number combination to another while the packets are traversing a network gateway, such as a router or firewall. This technique is most commonly used to make services on a host residing on a protected or masqueraded (internal) network available to hosts on the opposite side of the gateway (external network), by remapping the destination IP address and port number of the communication to an internal host.[1][2]Types of port forwarding
Port forwarding can be divided into the following types:[4]- Local port forwarding
- Remote port forwarding
- Dynamic port forwarding
p2pTV
The term P2PTV refers to peer-to-peer (P2P) software applications designed to redistribute video streams in real time on a P2P network; the distributed video streams are typically TV channels from all over the world but may also come from other sources. The draw to these applications is significant because they have the potential to make any TV channel globally available by any individual feeding the stream into the network where each peer joining to watch the video is a relay to other peer viewers, allowing a scalable distribution among a large audience with no incremental cost for the source.-
Content networking techniques
- Content service protocols
- Peer-to-peer CDNs ==>Peer-to-peer network
- Private CDNs
需要注意的是,里面一些链接有相关的公司的产品, 直接可以通过这个 可以找到一些开源代码。
相关书籍:
Data.Communications.and.Networking 5th Edition
IP网络5种基本寻址方式 (单播、多播、广播、任播、地域多播)的更多相关文章
- Java单播、组播(多播)、广播的简单实现
简介 单播有TCP和UDP两种实现,组播(多播)和广播只有UDP一种实现.单播和广播基本一样,只是广播的数据包IP为广播IP. 单播 DatagramSocket和DatagramPacket 服 ...
- TCP/IP网络编程之多播与广播
多播 多播方式的数据传输是基于UDP完成的,因此,与UDP服务端/客户端的实现非常接近.区别在于,UDP数据传输以单一目标进行,而多播数据同时传递到加入(注册)特定组的大量主机.换言之,采用多播方式时 ...
- 单播、广播和多播IP地址
除地址类别外,还可根据传输的消息特征将IP地址分为单播.广播或多播.主机使用IP地址进行一对一(单播).一对多(多播)或一对所有(广播)的通信. 1.单播 单播地址是IP网络中最常见的.包含单播目标地 ...
- 【miscellaneous】单播、广播和多播IP地址
转自:http://www.cnblogs.com/gaoxing/archive/2012/02/19/2358484.html 除地址类别外,还可根据传输的消息特征将IP地址分为单播.广播或多播. ...
- linux网络编程之一-----多播(组播)编程
什么是多播 组播(Multicast)是网络一种点对多(one to many)的通信方式,通过报文复制完成网络中一台server对应多台接收者的高效数据传 送.对其形象的比喻就是类似于广播电台和电视 ...
- UDP 单播、广播和多播
阅读目录(Content) 一.UDP广播 二.UDP多播 1.多播(组播)的概念 2.广域网的多播 三.UDP广播与单播 广播与单播的比较 使用UDP协议进行信息的传输之前不需要建议连接.换句话说就 ...
- TCP/IP详解学习笔记(9)-- 广播,多播,IGMP:网际组管理协议
1.概述 IP有三种地址:单播地址, 广播地址,多播地址. 广播和多播仅应用于UDP. 每个以太网帧包含源主机和目的主机的以太网地址.通常每个以太网帧发往单个目的主机,目 ...
- UDP 单播、广播、多播
一.UDP广播 广播UDP与单播UDP的区别就是IP地址不同,广播使用广播地址255.255.255.255,将消息发送到在同一广播网络上的每个主机.值得强调的是:本地广播信息是不会被路由器转发.当然 ...
- Java单播、广播、多播(组播)---转
一.通信方式分类 在当前的网络通信中有三种通信模式:单播.广播和多播(组播),其中多播出现时间最晚,同时具备单播和广播的优点. 单播:单台主机与单台主机之间的通信 广播:当台主机与网络中的所有主机通信 ...
随机推荐
- POJ 2251 Dungeon Master(广搜,三维,简单)
题目 简单的3d广搜,做法类似与 hdu 的 胜利大逃亡 #define _CRT_SECURE_NO_WARNINGS #include<stdio.h> #include<str ...
- HDU 4509 湫湫系列故事——减肥记II(暴力模拟即可)
看了题目后,没自己做,直接看别人题解了,这里转一下. 看了之后,突然想起scanf还可以按照自己写的格式输入数据啊,差点连这个都忘记了啊. 注意输入中时间可能有重复的. http://www.cnbl ...
- EXPRESS.JS再出发
那个那个MEAN的书,看得七七八八,有了大概,现在就要一样一样的加深记忆啦.. EXPRSS.JS的东东,网上有现成入门书籍: 第一期代码测试: var express = require('expr ...
- OpenStack重启之后,dashboard登录不上去
ubuntu 12.04装好openstack之后,安装成功,终端打出如下信息: Horizon is now available at http://192.168.0.2/Keystone is ...
- 欧拉工程第68题:Magic 5-gon ring
题目链接 任意一条线上的三个数的和都等于9,顺时针,从最小的外圈开始,得到的序列是:432621213 和 序列 9位的字符串:三角环所能形成的最大字符串为432621513. ...
- 获取其他进程中ListBox和ComboBox的内容
(*// 标题:获取其他进程中ListBox和ComboBox的内容 说明:Window2000+Delphi6调试通过 设计:Zswang 支持:wjhu111@21cn.com 日期:2004-0 ...
- 不重启使XP环境变量生效
不重启使XP环境变量生效 http://www.pkghost.cn/wz/sort0185/8874.html 在“我的电脑”->“属性”->“高级”->“环境变量”中增加或修改环 ...
- iOS 用命令实现简单的打包过程
`xcode-select --print-path`/Platforms/iPhoneOS.platform/Developer/usr/bin/PackageApplication // 获得打包 ...
- Lua表的构造及遍历
关于lua中的table,主要的困惑来自于table既可以当array用又可以当record用,有时候就会混淆不清. lua中的table貌似是用map来实现的,array是语法糖,一种特例.下面是l ...
- 安装nginx创建错误
./configure: error: the HTTP gzip module requires the zlib library. 解决: yum install -y zlib-devel -- ...