questions about advertisement

Andre
2008-07-11
2012-12-14
  • Andre
    Andre
    2008-07-11

    I'm using tag version 352 (1.6.6) because the latest in SVN won't build on windows.

    I created a device based on the sample device. I took out everything to do with the service table since I am just testing discovery and advertisement. The weird thing is that the advertisement is sent every ~20 seconds, even though the default_advr_expire is set to 100.
    I then traced it to: UpnpSendAdvertisement. Here, the incoming value first gets divided by two and then 30 gets subtracted from it - why is that? There doesn't seem to be a check for <= 0 in or before the call to TimerThreadSchedule.

     
    • Hi Andre,

      I will take a look at the code, but from what you describe, it looks like the current code is wrong. Would you mind creating an entry at the bug tracker and if possible posting a patch with the proposed solution?

      Regards,
      Marcelo.

       
    • Andre
      Andre
      2008-07-17

      The incoming value of Exp (which is set to a default of 100) is checked against being less than 1 in UpnpSendAdvertisement. If it is less than 1, it gets set to DEFAULT_MAXAGE (1800).
      Subsequently, a timer is created with TimerThreadSchedule and its second parameter time_t time is set to:

      (Exp /2) - AUTO_ADVERTISEMENT_TIME

      AUTO_ADVERTISEMENT_TIME is defined as 30.

      Depending on the initial value of Exp, this value could become 0 or negative.

      First, I would like to know if there is a good reason for this calculation.

      UPnP DeviceArchitecture v1.0 spec mentions a minimum of 1800 seconds and so the calculation should be performed accordingly:

      if (Exp < DEFAULT_MAXAGE)
         Exp = DEFAULT_MAXAGE;

      Then use the value of Exp in the call to TimerThreadSchedule.
      Any objections?

       
    • Bob Ciora
      Bob Ciora
      2008-07-17

      Actually, the spec says that the max-age directive "[s]should be > 1800 seconds".  It's a "should", not a "shall".  So setting it to DEFAULT_MAXAGE (1800) if it's any value less than that would be a violation of the standard.

      I'm of the mind that you let the application developer set the value.  I agree that an "Exp" value of 0 should be reserved to allow DEFAULT_MAXAGE.  But if someone is foolish enough to send "Exp = 1" to fire the advertisement thread once per second, then let them clutter their network.  You can only be defensive up to a point.

       
    • Andre
      Andre
      2008-07-18

      I'm not sure which spec you are referring to, but this one:
      http://www.upnp.org/specs/arch/UPnP-DeviceArchitecture-v1.0.pdf

      mentions the following top of page 16:

      "CACHE-CONTROL
      Required. Must have max-age directive that specifies number of seconds the advertisement is valid. After this duration,
      control points should assume the device (or service) is no longer available. Should be greater than or equal to 1800
      seconds (30 minutes). Specified by UPnP vendor. Integer."

      However, on page 15, the following is shown:
      "Due to the unreliable nature of UDP, devices should send each of the above discovery messages more than once, although to
      avoid network congestion discovery messages should not be sent more than three times. In addition, the device must re-send its
      advertisements periodically prior to expiration of the duration specified in the CACHE-CONTROL header; it is recommended that
      such refreshing of advertisements be done at a randomly-distributed interval of less than one-half of the advertisement
      expiration time, so as to provide the opportunity for recovery from lost advertisements before the advertisement expires, and to
      distribute over time the advertisement refreshment of multiple devices on the network in order to avoid spikes in network traffic."

      So, does this mean that the time interval should be a randomly selected number between 1 and (Exp/2)-1?