本文介绍了在不同子网中广播的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

请帮助我解决我的问题。一方面,我将IP 172.27.13.2的服务器连接到路由器172.27.13.1的WAN接口...然后在路由器192.168.1.1的无线LAN上,我连接了一些客户端。现在,我将用C编写代码,其中客户端从服务器请求一些UDP流,然后服务器向客户端广播流,如果某些数据包丢失,客户端必须向服务器发送NACK。我的问题是:
因为服务器和客户端位于不同的子网上,如何从服务器广播?
客户端如何将请求和NACK发送到服务器,因为它们位于不同的子网中?
这些问题可以通过路由器配置还是用C代码解决?

Please if you can help me about my problem. On one side I have server with IP 172.27.13.2 connected to the WAN interface of router 172.27.13.1 ...Then on wireless LAN of my router 192.168.1.1 I have connected a few clients. Now I will write code in C where client are requesting some UDP streams from server, then server broadcasts streams to clients, and if some packets get lost clients must send NACK to server. My questions is:Because server and clients are on different subnets how can I broadcast from server?And how the client can send request and NACKs to server because they are in different subnets?Are these problems can be solved by router configurations or in C code?

感谢您的帮助

推荐答案

您不能广播到其他子网。路由器通常不会将广播数据包转发到不同的子网,除非您具有可以正确配置的非常特殊的路由器(例如Cisco ...)。但是,您可以将多播用于此类任务。这是

You cannot broadcast to different subnets. Routers do not usually forward broadcast packets to different subnets, unless you have a very special router that can be configured properly (e.g. Cisco ...). You could however use multicast for such a task. Here's a C example

也检查以下内容:

注意:c示例中的某些包含项丢失了,但是很容易找到

NOTE: some includes in the c example are missing, but they are easy to find

这篇关于在不同子网中广播的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-20 07:30
查看更多