Pergunta

I've developed a program in C# that uses a UDP multicast system. My multicast group it's using 224.0.0.1 address to communicate.

The scenario is the following one:

  • I have several servers running this program;
  • Each server uses a different port to communicate;
  • The servers share the same network.

I want to protect each server from noise caused by others. If someone decides to use same address and port it wont be pleasant for the stability of the program.

How can I isolate my address and port from noise caused by external traffic?

How can I isolate my multicast traffic and protect it from going out of the network?

Foi útil?

Solução

For the first question, I believe you may be able to implement some sort of control layer.

  • From the network topology POV:

    • You may try to configure your router or proxy to allow only specific machines to send packets to specific addresses, multicast addresses included.
  • Programatically:

    • Add a local catalog of valid servers. If a packet is received from an unknown address, discard it.
    • Encrypt the packet payload with a reversible algorithm like Rijndael. Payloads that fail to be decrypted may be declared invalid.

For the second question - set the socket TimeToLive to 1. That means the multicast data will only 'hop' once. Quote:

s.SetSocketOption(SocketOptionLevel.IP,
    SocketOptionName.MulticastTimeToLive, 2);

This sets the time to live for the socket - this is very important in defining scope for the multicast data. Setting a value of 1 will mean the multicast data will not leave the local network, setting it to anything above this will allow the multicast data to pass through several routers, with each router decrementing the TTL by 1. Getting the TTL value right is important for bandwidth considerations

http://www.codeproject.com/Articles/1705/IP-Multicasting-in-C

Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top