L
L
lenston2015-04-05 01:07:21
Java
lenston, 2015-04-05 01:07:21

How to send a packet beyond NAT?

There is a local network. It has multiple routers.
It is necessary to send a packet to all clients..
When using a similar code in JAVA

public class SendAll {
    static DatagramSocket s;
    static DatagramPacket dp;
    public SendAll(String Line){
        
        try{s=new DatagramSocket();
        }catch(Exception ex){}
        
        try{sendString(Line);
        }catch(Exception ex){}
        
        s.close();
    }
    static void sendString(String str)throws IOException{
        byte[]buf=str.getBytes();
        dp=new DatagramPacket(buf,buf.length,InetAddress.getByName(main.Const.BROADCAST),main.Const.PORT);
        s.send(dp);
    }
}

The packet is sent only to clients of the same subnet, for example, clients with IP 192.168.1.1-254,
but will not be sent to clients 192.168.2.1-254, NAT is used..
how to send the packet further?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Alexey Ostroverkhov, 2015-04-10
@sharptop

If I understand the code correctly, then you are trying to send a UDP broadcast. If so, then no way. Routers usually never broadcast beyond their own network so that there are no network storms.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question