multicast-test icon indicating copy to clipboard operation
multicast-test copied to clipboard

command line parameters

Open ghost opened this issue 2 years ago • 8 comments

We are working on a Multicast environment testing products and we are trying to test systems and automate those tests.

MC-test works great but it can go further by adding command line arguments to just "fire it and watch".

A simple -s for "send" or -r for "receive", -i for "interface" (like eth0, ens2, whatever) would be nice. Or a simpler and better way: "-r eth0", "-s ens5", "-r 10.2.5.29",... For example: Sender: mc-test -s eth0 Receiver: mc-test -r ens6

ghost avatar Jan 06 '23 17:01 ghost

Agreed. Are you planning to raise a PR?

enclave-marc-barry avatar Jan 08 '23 13:01 enclave-marc-barry

No, I'm not a developer, sorry. I'm only hoping that someone can do the trick.

fsuarezo avatar Jan 09 '23 12:01 fsuarezo

how can I change the multicast ip address?

gochan21 avatar Dec 14 '23 10:12 gochan21

@gochan21 README.md has the answer: "By default, the tool uses multicast stream IP address 239.0.1.2 with port 20480. Pull requests to enable customisation are welcome."

enclave-marc-barry avatar Dec 14 '23 11:12 enclave-marc-barry

I've created a pull request #7 to allow the user to change the multicast address and port. It doesn't go as far as accepting command line arguments (yet)

groupmsl avatar Jan 04 '24 16:01 groupmsl

That's great, thank you for raising the PR. I think the validation code is a more complicated than it needs to be. Could you make it a little easier to understand by using TryPrase() instead? Something like..

while (true)
{
    Console.Write("Enter multicast address to use [239.0.1.2]: ");

    if (IPAddress.TryParse(Console.ReadLine(), out IPAddress multicastAddress))
    {
        if (IsMulticast(multicastAddress))
        {
            MulticastAddress = multicastAddress;
            break;
        }

        Console.WriteLine("A multicast IP addresses must be between 224.0.0.0 to 239.255.255.255.");
    }
    else
    {
        if (string.IsNullOrEmpty(multicastAddress)) 
        {
            break; // use default multicast address
        }

        Console.WriteLine("Not a valid IP address.");
    }
}

I like that you're checking to see if the address is in the multi-cast range, but perhaps a helper method?

private static bool IsMulticast(IPAddress ip)
{
    byte firstOctet = ip.GetAddressBytes()[0];
    return firstOctet >= 224 && firstOctet <= 239;
}

I don't understand the need for <Nullable>enable</Nullable>?

enclave-marc-barry avatar Jan 04 '24 17:01 enclave-marc-barry

I have made changes similar to these and updated the PR. I like what you did as it also allows for the user to use the default multicast address and port if not specified.

RE: nullable, it was in the default .csprj created with a dotnet create console, but (as you hinted) it isn't required and removes a bunch of warnings when disabled. I have done this in the latest commit.

groupmsl avatar Jan 05 '24 11:01 groupmsl

Thanks @groupmsl. That PR won't close this issue for CLI-based config options, but introducing the ability to change multicast address and port I'm sure will be helpful to anyone else using the tool 👍

enclave-marc-barry avatar Jan 05 '24 17:01 enclave-marc-barry