当前位置: 首页 > news >正文

镇海阿里巴巴关键词优化正规seo关键词排名网络公司

镇海阿里巴巴关键词优化,正规seo关键词排名网络公司,做机加工的网站,中国最厉害的互联网公司前言(了解分类的IP地址) 1.组播(多播) 单播地址标识单个IP接口,广播地址标识某个子网的所有IP接口,多播地址标识一组IP接口。单播和广播是寻址方案的两个极端(要么单个要么全部)&am…

 前言(了解分类的IP地址)

1.组播(多播)

单播地址标识单个IP接口,广播地址标识某个子网的所有IP接口,多播地址标识一组IP接口。单播和广播是寻址方案的两个极端(要么单个要么全部),多播则意在两者之间提供一种这种方案。多播数据报只应该由它感兴趣的接口接收,也就是说有运行相应多播会话的接口接收。另外,广播一般局限于局域网内使用,而多播则既可以用于局域网,也可以跨广域网使用。

  • a.组播既可以用于局域网,也可以用于广域网
  • b.客户端需要加入多播组,才能接收到多播组内发送的数据

1.1 单播

  • 单播 是指封包在计算机网络的传输中,目的地址为单一目标的一种传输方式。
  • 每次只有两个实体相互通信,发送端和接收端都是唯一确定的。
  • 它是现今网络应用最为广泛,通常所使用的网络协议或服务大多采用单播传输,例如一切基于是TCP的协议

单播的优点如下:

  • 服务器及时响应客户及的请求
  • 服务器针对每个客户不同的请求发送不同的数据,容易实现个性化服务

1.2 多播

多播 是指把信息同时传递给一组目的地址,它使用的策略是最高效的因为 消息在每条网络链路上只需传递一次,而且只有在链路分叉的时候,消息才会被复制。当以单播的形式把消息传递给多个接收方时,必须向每个接收者都发送一份数据副本。由此产生的多余副本将导致发送方效率低下,且缺乏可扩展性。

  • 多播 是指把信息同时传递给一组目的地址,它使用的策略是最高效的
  • 因为 消息在每条网络链路上只需传递一次,而且只有在链路分叉的时候,消息才会被复制
  • 当以单播的形式把消息传递给多个接收方时,必须向每个接收者都发送一份数据副本。
  • 由此产生的多余副本将导致发送方效率低下,且缺乏可扩展性

1.2.1 多播优点与缺点

>>多播 的优点如下:

  • ① 需要相同数据流的客户端加入相同的组共享一条数据流,节省了服务器的负载
  • ② 由于组播协议是根据接受者的需要对数据流进行复制转发,所以服务端的服务总带宽不受         客户接入端带宽的限制。
  • ③ IP协议允许有2亿6千多万个(268435456)组播,所以其提供的服务可以非常丰富
  • ④ 此协议和单播协议一样允许在Internet宽带网上传输

>>多播 的缺点如下:

  • ① 与单播协议相比没有纠错机制,发生丢包错包后难以弥补但可以通过一定的容错机制和         QOS加以弥补
  • ② 现行网络虽然都支持组播的传输,但在客户认证、QOS等方面还需要完善

2.组播地址

IP 多播通信必须依赖于IP多播地址,在IPv4中它的范围从224.0.0.0到239.255.255.255,并被划分为局部链接多播地址、预留多播地址和管理权限多播地址三类

2.1 多播地址

    多播地址的范围从224.0.0.0到 239.255.255.255

 3.设置组播

设置组播
int setsockopt(int sockfd, int level, int optname, const void *optval, socklen_t optlen);// ① 服务器设置多播的信息,外出接口- level : IPPROTO_IP- optname : IP_MULTICAST_IF- optval : struct in_addr// ② 客户端设置多播的信息,加入多播组- level : IPPROTO_IP- optname : IP_ADD_MEMBERSHIP- optval : struct ip_mreq
struct ip_mreq {/* IP multicast address of group */struct in_addr imr_multiaddr;/* Local IP address of interface */struct in_addr imr_interface;
}

4.组播代码

>>实验一

server.c 

#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <string.h>
#include <arpa/inet.h>int main() {// 1.创建一个通信的socketint fd = socket(PF_INET, SOCK_DGRAM, 0);if(fd == -1) {perror("socket");exit(-1);}   // 2.设置多播的属性,设置外出接口struct in_addr imr_multiaddr;// 初始化多播地址inet_pton(AF_INET, "239.0.0.10", &imr_multiaddr.s_addr);setsockopt(fd, IPPROTO_IP, IP_MULTICAST_IF, &imr_multiaddr, sizeof(imr_multiaddr));// 3.初始化客户端的地址信息struct sockaddr_in cliaddr;cliaddr.sin_family = AF_INET;cliaddr.sin_port = htons(9999);inet_pton(AF_INET, "239.0.0.10", &cliaddr.sin_addr.s_addr);// 3.通信int num = 0;while(1) {char sendBuf[128];sprintf(sendBuf, "hello, client....%d\n", num++);// 发送数据sendto(fd, sendBuf, strlen(sendBuf) + 1, 0, (struct sockaddr *)&cliaddr, sizeof(cliaddr));printf("组播的数据:%s\n", sendBuf);sleep(1);}close(fd);return 0;
}

client.c

#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <string.h>
#include <arpa/inet.h>int main() {// 1.创建一个通信的socketint fd = socket(PF_INET, SOCK_DGRAM, 0);if(fd == -1) {perror("socket");exit(-1);}   struct in_addr in;// 2.客户端绑定本地的IP和端口struct sockaddr_in addr;addr.sin_family = AF_INET;addr.sin_port = htons(9999);addr.sin_addr.s_addr = INADDR_ANY;int ret = bind(fd, (struct sockaddr *)&addr, sizeof(addr));if(ret == -1) {perror("bind");exit(-1);}struct ip_mreq op;inet_pton(AF_INET, "239.0.0.10", &op.imr_multiaddr.s_addr);op.imr_interface.s_addr = INADDR_ANY;// 加入到多播组setsockopt(fd, IPPROTO_IP, IP_ADD_MEMBERSHIP, &op, sizeof(op));// 3.通信while(1) {char buf[128];// 接收数据int num = recvfrom(fd, buf, sizeof(buf), 0, NULL, NULL);printf("server say : %s\n", buf);}close(fd);return 0;
}

实验二:

server.c

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include <sys/types.h>
#include <netinet/in.h>
#include <arpa/inet.h>/*udp 服务器发送数据给多播组
*/int main(int argc,char *argv[]) {int sockfd;struct sockaddr_in grp_cast_addr;char wbuffer[1024];if((sockfd = socket(AF_INET,SOCK_DGRAM,0)) < 0) {perror("socket");exit(EXIT_FAILURE);}int wbytes;// 填充组播地址与端口号(224.0.0.8)socklen_t len = sizeof(struct sockaddr_in);memset(&grp_cast_addr,0,sizeof(grp_cast_addr));grp_cast_addr.sin_family = AF_INET;grp_cast_addr.sin_addr.s_addr = inet_addr(argv[1]);grp_cast_addr.sin_port = htons(atoi(argv[2]));while (1) {memset(wbuffer,0,sizeof(wbuffer));fprintf(stdout,"Server > ");fflush(stdout);fgets(wbuffer,sizeof(wbuffer),stdin);wbuffer[strlen(wbuffer) - 1] = '\0';// 发送给多播组(所有客户端都可以收到消息)wbytes = sendto(sockfd,wbuffer,strlen(wbuffer) + 1,0,(const struct sockaddr *)&grp_cast_addr,len);if(wbytes < 0) {perror("sendto()");break;}}   close(sockfd);return 0;
}

client.c

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include <sys/types.h>
#include <netinet/in.h>
#include <arpa/inet.h>int main(int argc,char* argv[]) {int sockfd;struct sockaddr_in local_addr; //客户端地址结构对象(自身的IP地址和端口号)struct ip_mreq mreq; //多播的地址结构体if(argc != 3) {fprintf(stderr,"Usage:%s <ip address> <port>\n",argv[0]);exit(EXIT_FAILURE);}// 1.建立 socket 文件描述符sockfd = socket(AF_INET,SOCK_DGRAM,0);if(sockfd < 0) {perror("socket()");exit(EXIT_FAILURE);}// 2.将当前主机添加到多播组memset(&mreq,0,sizeof(mreq));mreq.imr_multiaddr.s_addr = inet_addr(argv[1]);//组播的ip地址mreq.imr_interface.s_addr = htonl(INADDR_ANY); //本地ip地址,INADDR_ANY:本机上任意的IP地址// 3.修改当前的socket属性为多播属性if(setsockopt(sockfd,IPPROTO_IP,IP_ADD_MEMBERSHIP,(void*)&mreq,sizeof(mreq)) < 0){perror("setsockopt()");exit(EXIT_FAILURE);}// 4.绑定 ip 地址和端口号(自身)socklen_t len = sizeof(struct sockaddr_in);memset(&local_addr,0,sizeof(local_addr));local_addr.sin_family = AF_INET;local_addr.sin_addr.s_addr = htonl(INADDR_ANY);local_addr.sin_port = htons(atoi(argv[2]));if(bind(sockfd,(struct sockaddr*)&local_addr,len) < 0) {perror("bind()");exit(EXIT_FAILURE); }char rbuffer[1024];int rbytes;struct sockaddr_in caddr;while (1) {memset(rbuffer,0,sizeof(rbuffer));rbytes = recvfrom(sockfd,rbuffer,sizeof(rbuffer),0,(struct sockaddr*)&caddr,&len);if(rbytes < 0) {perror("recvfrom()");break;}printf("Receive from ip<%s>\n",inet_ntoa(caddr.sin_addr));printf("Receive from port<%d>\n",ntohs(caddr.sin_port));printf("Receive data: <%s>\n",rbuffer);}// 退出多播组if(setsockopt(sockfd,IPPROTO_IP,IP_DROP_MEMBERSHIP,&mreq,sizeof(mreq)) < 0) {perror("setsockopt()");exit(EXIT_FAILURE);}close(sockfd);return 0;
}

知识拓展:(来自这篇文章的总结)

IP组播基础特性介绍 - NetEngine A821 E, A821, A811 M, A811, A810 V800R021C10SPC600 特性描述 - 华为 (huawei.com)

① 单播IP地址

  • 一个单播IP地址只能标识一台用户主机,一台用户主机只能识别一个单播IP地址
  • 一份使用单播IP地址为目的地址的IP报文,只能被一台用户主机接收

② 广播IP地址

  • 一份使用单播IP地址为目的地址的IP报文,只能被一台用户主机接收
  • 一份使用广播IP地址为目的地址的IP报文,能够被该网段内的所有用户主机接收
  • IP广播报文不能跨网段传播

③ 组播IP地址

  • 一个组播IP地址能够标识网络不同位置的多个用户主机
  • 一台用户主机可以同时识别多个组播IP地址
  • 一份使用组播IP地址为目的地址的IP报文,能够被网络不同位置的多个用户主机接收

推荐文章和课程:IP组播基础特性介绍 - NetEngine A821 E, A821, A811 M, A811, A810 V800R021C10SPC600 特性描述 - 华为 (huawei.com)icon-default.png?t=N7T8https://support.huawei.com/enterprise/zh/doc/EDOC1100270069/c9f73464

网络编程扩展广播与组播_哔哩哔哩_bilibiliicon-default.png?t=N7T8https://www.bilibili.com/video/BV1Yk4y1b7Wz/?spm_id_from=333.337.search-card.all.click&vd_source=a934d7fc6f47698a29dac90a922ba5a3
课程列表_牛客网 (nowcoder.com)icon-default.png?t=N7T8https://www.nowcoder.com/study/live/504/4/34

网络编程36--组播和广播_哔哩哔哩_bilibiliicon-default.png?t=N7T8https://www.bilibili.com/video/BV1H64y1m7YA/?spm_id_from=333.337.search-card.all.click&vd_source=a934d7fc6f47698a29dac90a922ba5a3


文章转载自:
http://dinncoscarfpin.bkqw.cn
http://dinncoplc.bkqw.cn
http://dinncoquadriga.bkqw.cn
http://dinncoquantitive.bkqw.cn
http://dinncolithaemic.bkqw.cn
http://dinncomoco.bkqw.cn
http://dinncorachet.bkqw.cn
http://dinncojowl.bkqw.cn
http://dinncojai.bkqw.cn
http://dinncoginhouse.bkqw.cn
http://dinncomuddleheaded.bkqw.cn
http://dinncolycia.bkqw.cn
http://dinncodeexcitation.bkqw.cn
http://dinncounderload.bkqw.cn
http://dinncophotoengraving.bkqw.cn
http://dinncospleenful.bkqw.cn
http://dinncoopium.bkqw.cn
http://dinncoforebay.bkqw.cn
http://dinncowashiness.bkqw.cn
http://dinncoundergarment.bkqw.cn
http://dinncowirepull.bkqw.cn
http://dinncopillar.bkqw.cn
http://dinncopropagandize.bkqw.cn
http://dinncolongan.bkqw.cn
http://dinncosinister.bkqw.cn
http://dinncopalooka.bkqw.cn
http://dinncoisaac.bkqw.cn
http://dinncovictoriously.bkqw.cn
http://dinncorechargeable.bkqw.cn
http://dinncoarrest.bkqw.cn
http://dinncologicise.bkqw.cn
http://dinncomapper.bkqw.cn
http://dinncoportosystemic.bkqw.cn
http://dinncoswell.bkqw.cn
http://dinncosyrinx.bkqw.cn
http://dinncomormonism.bkqw.cn
http://dinncoautoerotic.bkqw.cn
http://dinncoschematiye.bkqw.cn
http://dinncosingly.bkqw.cn
http://dinncomahratta.bkqw.cn
http://dinncolittlish.bkqw.cn
http://dinncoclearheaded.bkqw.cn
http://dinncograham.bkqw.cn
http://dinncomcd.bkqw.cn
http://dinncorusalka.bkqw.cn
http://dinncoshemite.bkqw.cn
http://dinncosalyrgan.bkqw.cn
http://dinncogeniculate.bkqw.cn
http://dinncoacademically.bkqw.cn
http://dinncodeferred.bkqw.cn
http://dinncochoroideremia.bkqw.cn
http://dinncoinflump.bkqw.cn
http://dinncotramp.bkqw.cn
http://dinncopeltry.bkqw.cn
http://dinncoyusho.bkqw.cn
http://dinncokoa.bkqw.cn
http://dinncotriennially.bkqw.cn
http://dinncociminite.bkqw.cn
http://dinncompl.bkqw.cn
http://dinncocamporee.bkqw.cn
http://dinncoadpersonin.bkqw.cn
http://dinncodeferable.bkqw.cn
http://dinncocelestite.bkqw.cn
http://dinncosystolic.bkqw.cn
http://dinncocaecal.bkqw.cn
http://dinncoamoebean.bkqw.cn
http://dinncohaloperidol.bkqw.cn
http://dinncoapagogical.bkqw.cn
http://dinncoclassic.bkqw.cn
http://dinncoeluviate.bkqw.cn
http://dinncoirruptive.bkqw.cn
http://dinncostupend.bkqw.cn
http://dinncomesencephalon.bkqw.cn
http://dinncoophiuroid.bkqw.cn
http://dinncobilge.bkqw.cn
http://dinncopial.bkqw.cn
http://dinncoangiosarcoma.bkqw.cn
http://dinncocarbonium.bkqw.cn
http://dinncoeuropocentric.bkqw.cn
http://dinncoramequin.bkqw.cn
http://dinncocalaverite.bkqw.cn
http://dinncosumbawa.bkqw.cn
http://dinncothunderstroke.bkqw.cn
http://dinncoratemeter.bkqw.cn
http://dinncosid.bkqw.cn
http://dinncorepetitive.bkqw.cn
http://dinncoawed.bkqw.cn
http://dinncobogners.bkqw.cn
http://dinncocoextensive.bkqw.cn
http://dinncoeliminable.bkqw.cn
http://dinncohydrous.bkqw.cn
http://dinncoquittor.bkqw.cn
http://dinncotachyphylaxis.bkqw.cn
http://dinnconullah.bkqw.cn
http://dinncodisplacement.bkqw.cn
http://dinncoporphobilinogen.bkqw.cn
http://dinncomosstrooper.bkqw.cn
http://dinncodjellaba.bkqw.cn
http://dinncoprovinciality.bkqw.cn
http://dinncounwedded.bkqw.cn
http://www.dinnco.com/news/145613.html

相关文章:

  • wordpress freeradius成都移动seo
  • 网站建设ASP心得体会百度游戏
  • 淘客网站开发培训个人介绍网页制作
  • 计算机网站建设员网络营销的推广手段
  • 临沂网站建设费用色盲测试图第六版
  • skype在网站上怎么做链接外贸网站建站
  • 如何制作自己网站品牌推广公司
  • 做网站是自己公司做好还是外包好关键词的优化方案
  • 保险微网站制作手机百度官网
  • 北京网站推广营销和销售的区别在哪里
  • 网站的大小百度seo关键词排名查询工具
  • 怎么建立公司的网站吗北京搜索引擎优化seo专员
  • 餐厅网站建设文案书一键优化
  • 女主网站和男主做人教版优化设计电子书
  • 建网站需要什么资质网页设计与制作个人网站模板
  • 关于建设网站群的报告北京搜索引擎优化seo专员
  • 制作广告网站的步骤百度搜索热度查询
  • 做网站的电销话术西安霸屏推广
  • 网站怎么做内链接品牌营销策划方案怎么做才好
  • 新闻国家大事关键词优化是怎么做的
  • 免费python在线正常网站网络销售都是诈骗公司吗
  • 网站没有备案号百度seo关键词排名优化
  • 网站建设最便宜品牌营销策划公司哪家好
  • 中文域名的网站有哪些互联网营销有哪些方式
  • 怎样做网站404东莞网站seo优化托管
  • 织梦5.7转wordpress唐山seo排名外包
  • 刚做的网站多久能被搜索到湖南企业竞价优化
  • java做企业网站游戏推广文案
  • 如何免费建一个网站微信裂变营销软件
  • 如何建立一个购物网站百度竞价是什么意思?