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单播、广播、多播(组播)---转
一.通信方式分类 在当前的网络通信中有三种通信模式:单播.广播和多播(组播),其中多播出现时间最晚,同时具备单播和广播的优点. 单播:单台主机与单台主机之间的通信 广播:当台主机与网络中的所有主机通信 ...
随机推荐
- Appium绑定
锁定 锁定屏幕 # python driver.lock(5) 将 app 置于后台 把当前应用放到后台去 # python driver.background_app(5) 收起键盘 收起键盘 # ...
- C# foreach循环绑定key数组和value 数组(备用)
<div class="ContextualTab inner_warp clearfix" data-max="2" data-blur=false d ...
- crontab 指定执行用户
linux下可以通过配置crontab来定时执行任务,执行体可以是一条系统命令或自己写的一个脚本,同时可以指派用户来执行.配置crontab有两种方法.方法1.使用crontab命令,例如添加一个新的 ...
- [转]HttpClient的超时用法小记
HttpClient的超时用法小记 HttpClient在使用中有两个超时时间,是一直接触和使用的,由于上次工作中使用httpClient造成了系统悲剧的情况,特地对它的两个超时时间进行了小小的测试, ...
- linux 踢出用户方法
linux系统root用户可强制踢制其它登录用户, 首先以root登录以便查看全部的在线用户信息,可用w命令查看登录用户信息 强制踢人命令格式:pkill -kill -t tty 解释: pkill ...
- Sina App Engine(SAE)入门教程(10)- Cron(定时任务)使用
参考资料 SAE Cron说明文档 Cron能干什么? cron 可以定时的触发一个脚本,在sae上最大的频率是一分钟一次.你可以用其来完成自己需要的业务逻辑,例如定期的抓取某些网页完菜信息的采集,定 ...
- 与Google轻轻地擦肩而过
第一集 因为那几年三天两头往硅谷里飞,所以我实在记不清这个故事到底是发生在98年还是99年夏天某日的一个下午. 那天我和Excite.com的创始人Mark V. H.在Palo Alto的一家餐厅共 ...
- CString, QString, char*之间的转换(包括VC编译开关)
传给未分配内存的const char* (LPCTSTR)指针. CString cstr(asdd); const char* ch = (LPCTSTR)cstr; ch指向的地址和cstr相同. ...
- C++工具系列博文合集
http://www.cnblogs.com/itech/category/240779.html
- Executing Raw SQL Queries using Entity Framework
原文 Executing Raw SQL Queries using Entity Framework While working with Entity Framework developers m ...