Receiving multicast messages

inma
2004-02-20
2004-02-29
  • inma

    inma - 2004-02-20

    Hello!!

    I think it would be a good idea to filter the messages that both control point and device receive from a multicast address, that is, to check if they receive messages which have been sent to the multicast group they are joined to, especially working in IPv6, since I have noticed that listenting to the multicast address [FF02::C]:1900, messages sent to the multicast address 239.255.255.250:1900 are also listened. So I encourage  to do something like this:

    Class SSDPNotifySocket:  
    public void run()
        {
            Thread thisThread = Thread.currentThread();
           
            ControlPoint ctrlPoint = getControlPoint();
           
            while (deviceNotifyThread == thisThread) {
                Thread.yield();

                SSDPPacket packet = receive();

             /****************** added code*************************/
                 String host = packet.getHost();
                String mihost = /*multicast address it is joined to*/
                if (useIPv6Address == true)
                    mihost ="["+mihost+"]";
                mihost += ":"+Integer.toString(SSDP.PORT);

                if (host.compareTo(mihost)==0){

                    if (ctrlPoint != null){

                        ctrlPoint.notifyReceived(packet);
                    }
                }

    Something similar could be used in the class SSDPSearchSocket.

    Could you be so kind as to tell me what your opinion is, please?

    Another topic I would like to comment is about running first a device working only on IPv6 and then launching a control point working on both IPv4 and IPv6. When the device receives M-Search messages from the control point, it sends responses to it via IPv6 addresses. However,the control point receives these responses in a DatagramSocket used from the IPv4 interface. Therefore, when the control points subscribes to a device service, it indicates its IPv4 address to receive the notification events, since it was to this address where he received the search responses. As the device only works on IPv6, he should not work using IPv4 addresses.... If you do not mind, could you be so kind as to tell me which the reason could be??

    I hope all my suggestions could be useful to improve this sdk.

    Thank you very much in advance.
    Cheers,
    Inma.

     
    • Satoshi Konno

      Satoshi Konno - 2004-02-29

      Hi Inma,

      Thanks for you suggestion.

      I don't know why the IPv4 interface recieved the IPv6 SSDP message now, but I would add the following codes to filter SSDP packets.

      HTTPMUSocket :
      public InetAddress getMulticastInetAddress()
      {
          return ssdpMultiGroup.getAddress();
      }

      SSDPPacket :
      public InetAddress getHostInetAddress()
      {
          String addrStr = "127.0.0.1";
          String host = getHost();
          int canmaIdx = host.lastIndexOf(":");
          if (0 <= canmaIdx) {
              addrStr = host.substring(0, canmaIdx);
              if (addrStr.charAt(0) == '[')
                  addrStr = addrStr.substring(1, addrStr.length());
              if (addrStr.charAt(addrStr.length()-1) == ']')
                  addrStr = addrStr.substring(0, addrStr.length()-1);
          }
          InetSocketAddress isockaddr = new InetSocketAddress(addrStr, 0);
          return isockaddr.getAddress();
      }

      SSDPNotifySocket:
      public void run()
      {
          Thread thisThread = Thread.currentThread();
          ControlPoint ctrlPoint = getControlPoint();
          while (deviceNotifyThread == thisThread) {
              Thread.yield();
              SSDPPacket packet = receive();
              InetAddress maddr = getMulticastInetAddress();
              InetAddress pmaddr = packet.getHostInetAddress();
              if (maddr.equals(pmaddr) == false)
                  continue;
              if (ctrlPoint != null)
                  ctrlPoint.notifyReceived(packet);
          }
      }

       

Get latest updates about Open Source Projects, Conferences and News.

Sign up for the SourceForge newsletter:





No, thanks