单播-组播-广播代码-以及广播地址-组播地址的计算.docx

单播-组播-广播代码-以及广播地址-组播地址的计算.docx

ID:55635159

大小:11.23 KB

页数:3页

时间:2020-05-21

单播-组播-广播代码-以及广播地址-组播地址的计算.docx_第1页
单播-组播-广播代码-以及广播地址-组播地址的计算.docx_第2页
单播-组播-广播代码-以及广播地址-组播地址的计算.docx_第3页
资源描述:

《单播-组播-广播代码-以及广播地址-组播地址的计算.docx》由会员上传分享,免费在线阅读,更多相关内容在教育资源-天天文库

1、单播,组播,广播代码,以及广播,组播地址的计算usingSystem;usingSystem.Collections.Generic;usingSystem.Linq;usingSystem.Text;usingSystem.Windows;usingSystem.Windows.Controls;usingSystem.Windows.Data;usingSystem.Windows.Documents;usingSystem.Windows.Input;usingSystem.Windows.Media;usingSyst

2、em.Windows.Media.Imaging;usingSystem.Windows.Navigation;usingSystem.Windows.Shapes;usingSystem.Timers;usingSystem.Threading;usingSystem.Net.Sockets;usingSystem.Net;namespaceBCast{publicpartialclassMainWindow:Window{publicMainWindow(){InitializeComponent();ThreadHand

3、le();t.Elapsed+=newElapsedEventHandler(t_Elapsed);t.AutoReset=true;t.Enabled=true;t.Start();}voidt_Elapsed(objectsender,ElapsedEventArgse){ClientSender();}Threadthread;System.Timers.Timert=newSystem.Timers.Timer(1000);publicvoidThreadHandle(){thread=newThread(newThr

4、eadStart(ClientGeter));thread.IsBackground=true;thread.Start();}UdpClientudpgeter=newUdpClient(10881);IPAddressiap=IPAddress.Parse("127.0.0.1");publicvoidClientGeter(){IPEndPointiep=newIPEndPoint(iap,10881);//udpgeter.JoinMulticastGroup(multicastIP);while(true){byte

5、[]b=udpgeter.Receive(refiep);stringstr=Encoding.UTF8.GetString(b);Console.WriteLine(str);(看看控制台是否得到了你想要的数据)}}UdpClientmulticastUDP=newUdpClient();组播的地址是保留的D类地址从224.0.0.0—239.255.255.255,而且一些地址有特定的用处如,224.0.0.0—244.0.0.255只能用于局域网中路由器是不会转发的,并且224.0.0.1是所有主机的地址,224.0.0

6、.2所有路由器的地址,224.0.0.5所有ospf路由器的地址,224.0.13事PIMv2路由器的地址;239.0.0.0—239.255.255.255是私有地址(如192.168.x..x);224.0.1.0—238.255.255.255可以用与Internet上的。//IPAddressmulticastIP=IPAddress.Parse("224.110.10.1");(组播)所谓广播地址指同时向网上所有的主机发送报文,也就是说,不管物理网络特性如何,internet网支持广播传输。如136.78.255.2

7、55就是B类地址中的一个广播地址,你将信息送到此地址,就是将信息送给网络号为136.78的所有主机。计算方法:首先计算网络地址=IP地址逻辑与子网掩码先把IP,子网掩码转为2进制,然后进行逻辑与运算,得出网络地址例:IP192.168.1.3子网掩码255.255.0.0IP转二进制...子网掩码...与运算后...192.168.0.0这就是网络地址,计出来后把网络地址后面的0全部改为255就是广播地址了,那么此例中广播地址就为192.168.255.255如果不会算的就在cmd中输入ipconfig,然后在计算机中用程序员

8、模式计算就OK了IPAddressmulticastIP=IPAddress.Parse("192.168.1.255");(广播)intmulticastPort=10881;publicvoidClientSender(){IPEndPointmulticastIep=n

当前文档最多预览五页,下载文档查看全文

此文档下载收益归作者所有

当前文档最多预览五页,下载文档查看全文
温馨提示:
1. 部分包含数学公式或PPT动画的文件,查看预览时可能会显示错乱或异常,文件下载后无此问题,请放心下载。
2. 本文档由用户上传,版权归属用户,天天文库负责整理代发布。如果您对本文档版权有争议请及时联系客服。
3. 下载前请仔细阅读文档内容,确认文档内容符合您的需求后进行下载,若出现内容与标题不符可向本站投诉处理。
4. 下载文档时可能由于网络波动等原因无法下载或下载错误,付费完成后未能成功下载的用户请联系客服处理。