Forum Discussion

Altera_Forum's avatar
Altera_Forum
Icon for Honored Contributor rankHonored Contributor
17 years ago

how to use multicast with Interniche

I am having problem of enabling multicast functionalitiy in the nichestack.

Interniche website seems to claim it supports multicast

I went in th ipport.h and moved

IP_MULTICAST define outside of # ifdef UNUSED

but the compilation did not pass.

What else do i need to do?

Has anyone done it?

Any example?

5 Replies

  • Altera_Forum's avatar
    Altera_Forum
    Icon for Honored Contributor rankHonored Contributor

    Hi

    I have the same problem.

    Defining IP_MULTICAST is not the only thing to do.

    I join a small guide provided by Altera.

    Compilation is OK but It doesn't work for me.

    I think we have to modify mcastlist() routine located in allports.c.

    But I don't know exactly what to do.

    Mikael.
  • Altera_Forum's avatar
    Altera_Forum
    Icon for Honored Contributor rankHonored Contributor

    Hi,

    I have worked out how to do multicast, i am posting the steps here for everyone to share.

    1. in IPPORT.h

    You need to turn on 3 defines.

    # define IP_MULTICAST 1 // obvious one# define ETHMCAST 1 // give the readme.txt in ipmc directory, turn this one# define IGMP_V2 // This is not mentioned anywhere, i figured it out myself by reading the code

    2. Do whatever you need to get it compiled. Eg undefine IN_MENUS, comment out codes that causes compilation errors. Appearently they are bunch of code relates to ipmc demostration, and they have no use at all. I would strongly recommend altera to remove them from being compiled in by default, they cause so much confusion.

    3. define a dummy mcastlist()

    nets[0]->n_mcastlist = this_mcastlist;

    Giving the documentation it said, the idea is to have this done at the mac level.

    And i am using tse, there is an option called multicast hash table which you can enable. But anyway, i am a pure software guy, i dont have much idea there.

    But in my case, i did not turn on the option in tse (I tried to turn it on, but then my fpga would not compile, and i am not a hardware guy, i dont know how to fix it). I simply used a dummy mcastlist(), it works anyway.

    That is all, multicast should work now.

    BTW, if anyone knows how to detect ethernet cable disconnection, that'd be good. I looked around in TSE and Interniche code, it does not seem possible.
  • Altera_Forum's avatar
    Altera_Forum
    Icon for Honored Contributor rankHonored Contributor

    Hi

    Thanks for your response, I have just a little problem.

    I defined a dummy mcastlist() :

    int dummy_mcastlist(struct in_multi * multi_ptr)
    {
    USE_ARG(multi_ptr);
    return 0;
    }

    And I put this line just after Nichestack initialization

    extern int dummy_mcastlist(struct in_multi * multi_ptr)
    ...
    while (!iniche_net_ready)
        TK_SLEEP(1);
    nets->n_mcastlist = dummy_mcastlist;

    Compilation is OK but setsockopt() fails on MULTICAST_IF :

       memset(&local_addr,0,sizeof(local_addr)); 
        local_addr.sin_family = AF_INET;
        local_addr.sin_port = htons(USED_PORT);
        local_addr.sin_addr.s_addr = htonl(INADDR_ANY);    
        if((setsockopt (sock, IPPROTO_IP, IP_MULTICAST_IF,(char*) &local_addr,sizeof(local_addr)))<0)
        {
        fprintf(stderr,"multicast_if failed\n");}

    I am not able to send multicast packet.

    What's wrong?

    Have I to do some changes in allports.c?

    Thanks.

    Mikael.
  • Altera_Forum's avatar
    Altera_Forum
    Icon for Honored Contributor rankHonored Contributor

    Hi

    I am now able to set IP_MULTICAST_IF and IP_ADD_MEMBERSHIP options.

    It was a socket programming error:

    considere the following code :

     struct in_addr local_addr;
       IP4_ADDR(local_address.s_addr,192,168,1,2);
        
        if((setsockopt (sock, IPPROTO_IP,    IP_MULTICAST_IF,&local_addr,sizeof(local_addr)))<0)
        {
        fprintf(stderr,"multicast_if failed\n");}

    But sendto always returns an error.

    Any idea?

    Thanks.

    Mikael.