Sun Microsystems V2.0 manual Broadcasting

Models: V2.0

1 54
Download 54 pages 11.11 Kb
Page 34
Image 34

There are some important points to note about using this operation:

If setting a timeout it must be set before opening streams or creating datagrams.

A TimeoutException is generated if the caller is blocked waiting for input for longer than the period specified.

Setting a timeout of 0 causes the exception to be generated immediately if data is not available.

Setting a timeout of -1 turns off timeouts, that is, wait forever.

Broadcasting

It is possible to broadcast datagrams. By default, broadcasts are transmitted over two hops, so they may be received by devices out of immediate radio range operating on the same PAN. The broadcast is not inter-PAN. Broadcasting is not reliable: datagrams sent might not be delivered. SPOTs ignore the echoes of broadcasts that they transmitted themselves or have already received.

To perform broadcasting first open a special radiogram connection:

DatagramConnection conn = (DatagramConnection)Connector.open("radiogram://broadcast:<portnum>");

where <portnum> is the port number you wish to use. Datagrams sent using this connection will be received by listening devices within the PAN.

Note that broadcast connections cannot be used to receive. If you want to receive replies to a broadcast then open a server connection, which can be on the same port.

If you wish broadcasts to travel for more or less than the default two hops, do

((RadiogramConnection)conn).setMaxBroadcastHops(3);

Broadcasting and basestations

As described in the section Using the Basestation, basestations may operate in either shared or dedicated mode. Imagine a remote SPOT, out of range of the basestation, which broadcasts a radiogram with the default two hops set. An intermediate SPOT that is in range of the basestation then picks up the radiogram, and relays it. Because the basestation receives the packet after two hops, it does not relay it.

In dedicated mode, the host application uses the basestation’s address and therefore receives this radiogram. In shared mode, the host application is still one more hop from the host process managing the basestation, and so does not receive the radiogram. Similar considerations apply to packets sent from host applications. For this reason, application developers using broadcast packets to communicate between remote SPOTs and host applications will need to consider the impact of basestation mode on the number of broadcast hops they set.

These considerations will also impact anyone that works directly with the I802.15.4 MAC layer or lower levels of the radio communications stack. At the MAC layer, all packets are sent single hop: using a dedicated basestation these will reach remote SPOTs, using a shared basestation they will not.

Port number usage

The valid range of port numbers for both the radio and radiogram protocols is 0 to 255. However, for each protocol, ports in the range 0 to 31 are reserved for system use; applications should not use port numbers in this range.

34

Page 34
Image 34
Sun Microsystems V2.0 manual Broadcasting