Multicast.docx
- 文档编号:10917756
- 上传时间:2023-02-23
- 格式:DOCX
- 页数:36
- 大小:207.61KB
Multicast.docx
《Multicast.docx》由会员分享,可在线阅读,更多相关《Multicast.docx(36页珍藏版)》请在冰豆网上搜索。
Multicast
网络组播技术(NetworkMulticastTechnologies)
组播指的是单个发送者对应多个接收者的一种网络通信。
组播技术中,通过向多个接收方传送单信息流方式,可以减少具有多个接收方同时收听或查看相同资源情况下的网络通信流量。
对于n方视频会议,可以减少使用a(n-1)倍的带宽长度。
“组播”中较为典型的是采用组播地址的IP组播。
IPv6支持单播(Unicast)、组播(Multicast)以及任意播(Anycast)三种类型,IPv6中没有关于广播(Broadcast)的具体划分,而是作为组播的一个典型类型。
此外组播定义还包括一些其它协议,如使用“点对多点”或“多点对多点”连接的异步传输协议(ATM)。
组播技术基于“组”这样一个概念,属于接收方专有组,主要接收相同数据流。
该接收方组可以分配在英特网的任意地方。
TCP/IP中的主要组播技术和协议如下所述:
Internet组管理协议(IGMP和IGMPv3)―主要应用于主机及其最接近路由器之间,主机通过该协议通知路由器它需要收听哪个组播组。
组播知道IGMP流量中的交换机Snoop,从而避免了组播扩散现象。
协议无关组播(PIM)―主要用于组织分配组播流量,避免逐步路由选择回路现象。
PIM包括两种类型:
协议无关组播-密集模式(PIM-DM)和协议无关组播-稀疏模式(PIM-SM)。
其中后者较为常用。
组播开放最短路径优先(MOSPF)―OSPF的扩展协议,主要负责处理组播路由选择过程。
到目前为止尚未广泛应用。
多协议边缘网关协议(MBGP)―BGP的扩展协议,主要负责处理逐步路由选择过程。
MBGP支持不同余单播和组播拓朴技术,某些交换点利用到该技术。
组播信源发现协议(MSDP)―主要用于将Internet中所有组播源分配到所有RP。
如果组播源数目增长几倍时,一般不采纳该协议。
源特定组播(SSM)―确保组播传送的可靠性,利于使用广播。
主要应用于多用户收听少数源的场合。
SSM不需要提供IP组播地址管理并且对于Internet广播应用程序而言它是较为理想的选择。
显式组播(Xcast:
ExplicitMulticast)―Xcast支持大量小型组播会话。
通过显式对数据包中的目标文件进行编码实现,而非通过组播地址完成。
该协议适用于视频会议。
其它一些不是基于IP组播的组播技术,使用也较为广泛,如网际转发闲聊(InternetRelayChat)和PSYC。
实时传输协议(RTP)是一种与组播传送技术相关的音频/视频协议。
JRMS:
Itdefinesmechanismstomonitorhostpopulation,congestion,transferspeeds,anddatalossonaper-hostbasis,thusprovidingamorereliablemulticastenvironment.
Althoughseveralprotocolshavebeendevelopedforreliablemulticast,onlytwoareincludedintheJRMSAPI,Tree-BasedReliableMulticast(TRAM)andLight-WeightReliableMulticastProtocol(LRMP).
LateJoin
Perhapsoneofthemostappealingaspectsofreliablemulticastisthedynamicnatureofmulticastgroups.Butashostsjoinandleavethegroupasynchronously,afundamentalproblemarises:
hoststhatjointhegroupafterthesenderhasbegunsending,orlatejoins,willobviouslynotreceivethedatathatwassentpriortotheirmembershiptothegroup.Insomecases,suchasstreamingmedia,stockquotes,etc.,thelostdataisadmissible;however,somecontextsrequirethatsome,ifnotall,ofthedatathatwasmissedberesenttothelatejoins.Inshort,thedesigner(s)ofamulticastapplicationneedstodeterminehowlatejoinswillbehandledbasedonthenatureoftheinformationtheyaresending.JRMSsupportsnorecoveryandlimitedrecovery--thatis,recoverywithinathresholdoftime--initsTRAMpackage.
Channel
Amulticastchannelistheabstractconnectionbetweenthesenderandmulticastgroup.Althoughtheyarenotnecessaryformulticasting,channelsshouldbeusedinmostsituations,astheyprovideamoredynamicconnectionbetweensender(s)andhosts,andenabledynamicfilteringandadvertising.
Transport
AlthoughthereisnohardandfastruleforchoosingbetweenTRAMandLRMP,someguidelinesarepresentedheretoaidinthedecision.
∙Ifmultiplesendersarerequired,LRMPmustbeused.
∙TRAMhasbuiltincongestioncontrol.
∙TRAMhasbuiltinbandwidthstatisticswhichcanbeusefulfordebugging.
ClassDescriptions
∙LRMPTransportProfile
∙LRMPPacketSocket
∙TRAMStats
∙TRAMStreamSocket
∙TRAMPacketSocket
∙TRAMTransportProfile
LRMPTransportProfile
ThisclassdescribesthedataformattingoftheLRMPTransportProfile.Itprovidesawayofspecifyingmultiplereceivers,themaximumandminimumdatarates,orderingofthepackets,andauthentication,ifany.
LRMPPacketSocket
Thisclasshandlesdatatransmissiontoandfromthechannelorapplication.Itisverysimilartoastandardunicastsocket.
TRAMTransportProfile
TRAMTransportProfileprovidesmethodstomodifytransport-specificparameters(e.g.,maximumandminimumdatarates,TTLvalue,etc).
TRAMStreamSocket
TRAMStreamSocketimplementstheRMStreamSocketInterfaceandencapsulatesastreamingsocketthatallowscommunicationtoandfromthechannel.
TRAMPacketSocket
TRAMPacketSocketimplementstheRMPacketSocketInterfaceandallowsapplicationstosendandreceivepackets,settheinterfaceoverwhichdataistobesent,andclosethesocketaftercompletionortoaborttheconnectionbeforethesessionends.
TRAMStats
TRAMStatsdefinestheTRAMStatisticsblock.ThisistheobjectthatisreturnedbythegetRMStatistics()methodofTRAMStreamSocket.
Howisitused?
WhetherusingLRMPorTRAM,thesamebasicstepsareusedtocreateorconnecttoamulticastchannel.
∙CreateaTransportProfileobjectwithanaddressandport.
∙CreatethemulticastsocketusingeithercreateRMPacketSocket()orcreateRMStreamSocket().
∙Finally,usethesend()andreceive()functionstotransmitandreceivedata.
TRAM-BasedSenderProgram
...
import.*;
importjava.io.*;
importjava.util.*;
importcom.sun.multicast.reliable.transport.*;
importcom.sun.multicast.reliable.transport.tram.*;
publicclassSenderTestTRAM{
staticintnumSends=20;
staticStringsendString="HelloWorld!
";
staticInetAddressaddress=null;
staticintdataPort=6824;
staticStringaddr="224.100.100.224";
staticRMStreamSocketss;
...
Firstthemulticastpackagesareimported.ThisexampleusesTRAM,sothecom.sun.multicast.reliable.transport.trampackageisimported.Bydefault,thisprogramsendsthestring"HelloWorld!
"20times.Themulticastaddressusedbythisprogramwillbe224.100.100.224onport6824.DatawillbesentovertheRMStreamSocketss.
...
privatestaticvoidsetupSender()throwsIOException,Exception{
TRAMTransportProfiletp;
address=InetAddress.getByName(addr);
tp=newTRAMTransportProfile(address,dataPort);
tp.setLateJoinPreference(
TRAMTransportProfile.LATE_JOIN_WITH_NO_RECOVERY);
tp.setMaxDataRate(100000);
ss=tp.createRMStreamSocket(TransportProfile.SENDER);
}
...
ThisfunctionsetsuptheTransportProfileandRMStreamSocketforthisprogram.ATRAMTransportProfileiscreateduponthemulticastaddress.Thelatejoinpreferencespecifieswhetherthismulticastsessionwillallowreceiverstojointhesessionafterthesessionhasstarted,andifanyrecoveryistobedoneforthelatejoiners.Here,LATE_JOIN_WITH_NO_RECOVERYisspecifiedtoallowreceiverstojoinatanytimeandthesessionwillnotrecoverdataforthelatejoiners.Themaximumdatarateforthemulticastsessionissetto100kbps.Thenthesender'sRMStreamSocketiscreatedbyspecifyingthatthesocketwillactasasender.
...
privatestaticvoidstartSending()throwsException{
inttimesSent=1;
bytestringBytes[];
while(timesSent<=numSends){
RMStatisticsstat=(RMStatistics)ss.getRMStatistics();
OutputStreamos=ss.getOutputStream();
if(stat.getReceiverCount()>0){
stringBytes=(timesSent+"-"+sendString).getBytes();
System.out.println("Sending.");
os.write(stringBytes);
os.flush();
timesSent++;
}else{
System.out.println("Waitingforareceiver..."+newDate());
}
Thread.sleep(1000);
}
...
Thesendingoverthemulticaststreamisverysimilartoanyotherstream-basedinterface.Thesenderwaitsforareceivertojoin,bycheckinggetReceiverCountontheRMStatisticsobjectforthesession.
System.out.println("Haltingtransmission...");
ss.close();
}
publicstaticvoidmain(Stringargs[]){
if(args.length>0){
sendString=args[0];
}
if(args.length>1){
numSends=Integer.parseInt(args[1]);
}
try{
setupSender();
startSending();
}
catch(Exceptione){
e.printStackTrace();
System.exit
(1);
}
}
}
TRAM-basedReceiverProgram
privatestaticvoidsetupChannel()throwsIOException,Exception{
TRAMTransportProfiletp=null;
InetAddressaddress=InetAddress.getByName(channelAddr);
tp=newTRAMTransportProfile(address,dataPort);
tp.setLateJoinPreference(
TRAMTransportProfile.LATE_JOIN_WITH_NO_RECOVERY);
tp.setMaxDataRate(100000);
ss=tp.createRMStreamSocket(TransportProfile.RECEIVER);
}
privatestaticvoidstartReceiving()throwsException{
intlen;
intbuffer_size=1024;
bytebuffer[]=newbyte[buffer_size];
InputStreamis=ss.getInputStream();
do{
len=is.read(buffer);
if(len>0){
System.out.println(newString(buffer,0,len));
}
}while(len!
=-1);
System.out.println("Sessioncomplete.");
ss.close();
}
LRMP-basedSenderProgram
import.*;
importjava.io.*;
importjava.util.*;
importcom.sun.multicast.reliable.transport.*;
importcom.sun.multicast.reliable.transport.lrmp.*;
publicclassSenderTestLRMP{
staticintnumSends=20;
staticStringsendString="HelloWorld!
";
staticInetAddressaddress=null;
staticintdataPort=6824;
staticStringaddr="224.100.100.224";
staticRMPacketSocketps;
privatestaticvoidsetupSender()throwsIOException,Exception{
LRMPTransportProfiletp;
address=InetAddress.getByName(addr);
tp=newLRMPTransportProfile(address,dataPort);
tp.setMaxDataRate(100000);
ps=tp.createRMPacketSocket(TransportProfile.SENDER);
}
privatestaticvoidstartSending()throwsException{
inttimesSent=1;
while(timesSent<=numSends){
bytestringBytes[]=(timesSent+"-"+sendString).getBytes();
System.out.println("Sending.");
ps.send(newDatagramPacket(
stringBytes,stringBytes.length,address,dataPort));
timesSent++;
Thread.sleep(1000);
}
System.out.println("Haltingtransmission...");
ps.close();
}
publicstaticvoidmain(Stringargs[]){
if(args.length>0){
sendString=args[0];
}
if(args.length>1){
numSends=Integer.parseInt(args[1]);
}
try{
setupSender();
startSending();
}
catch(Exceptione){
e.printStackTrace();
System.exit
(1);
}
}
}
LRMP-basedReceiverProgram
privatestaticvoidsetupReceiver()throwsIOException,Exception{
LRMPTransportProfiletp=null;
InetAddressaddress=InetAddress.getByName(addr);
tp=newLRMPTransportProfile(address,dataPort);
ps=tp.createRMPacketSock
- 配套讲稿:
如PPT文件的首页显示word图标,表示该PPT已包含配套word讲稿。双击word图标可打开word文档。
- 特殊限制:
部分文档作品中含有的国旗、国徽等图片,仅作为作品整体效果示例展示,禁止商用。设计者仅对作品中独创性部分享有著作权。
- 关 键 词:
- Multicast
![提示](https://static.bdocx.com/images/bang_tan.gif)