cnetwork-programmingbroadcastwan

Broadcast on different subnets


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?

Thank you for helping


Solution

  • 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

    Also check this: UDP broadcast packets across subnets

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