Presentation is loading. Please wait.

Presentation is loading. Please wait.

Telecooperation Technische Universität Darmstadt Copyrighted material; for TUD student use only Telecooperation P4: Internet Praktikum Q&A Session Telecooperation.

Similar presentations


Presentation on theme: "Telecooperation Technische Universität Darmstadt Copyrighted material; for TUD student use only Telecooperation P4: Internet Praktikum Q&A Session Telecooperation."— Presentation transcript:

1 Telecooperation Technische Universität Darmstadt Copyrighted material; for TUD student use only Telecooperation P4: Internet Praktikum Q&A Session Telecooperation Technische Universität Darmstadt Fernando Lyardet

2 Prof. Dr. M. Mühlhäuser Telekooperation © :2 SSDP The SSDP protocol allows a device to announce to other peers (in Upnp, the control points) that it has become available on the network. First Step: SSDP M_SEARCH (HTTPMU) –advertisement- (ssdp:alive) SSDP M_SEARCH (HTTPU) –description URL- (ssdp:discover) New Device

3 Prof. Dr. M. Mühlhäuser Telekooperation © :3 HTTPMU Service Advertisement On UDP, you send datagrams – Datagrams = self-contained messages Multicast UDP sends datagrams to a "group" For HTTPMU, the contents of the datagram are HTTPrequests There is no response to these multicast requests – the message may be received by any number of clients. It is not a request-response Situation  A request like GET cannot be interpreted as a request for a documenthttp://localhost/index.html HTTPMU is uses the syntax of HTTP while changing the semantics HTTPMU allows the possibility of new request types such as NOTIFY as well as the standard HTTP requests of GET, POST, HEAD, etc HTTPMU was invented to support UPnP. Is not a W3C standard

4 Prof. Dr. M. Mühlhäuser Telekooperation © :4 HTTPU Service Discovery HTTPU sends a single datagram over UDP to a host Uses unicast UDP The recipient may send a reply back to the host and port that sent the datagram Again, it is not expected that standard HTTP requests be sent, only that the syntax is obeyed Also no W3C Standard. HTTPU was invented for UPnP

5 Prof. Dr. M. Mühlhäuser Telekooperation © :5 Notifications (GENA) Notify is multicast by HTTPMU when a device wants to advertise itself, usually at startup Notify message include: –a statement about the device type such as schemas-upnporg:device:BinaryLight:0.9 –an HTTP URL for an XML description of the device Each device has a universally unique id (UUID) so that it can be identified even if it's IP address changes or it leaves and revisits the network There is no response to a notify A notify is also sent at graceful shutdown. The messages are distinguished by the field NTS which is set to ssdp:alive or ssdp:byebye NOTIFY * HTTP/1.1 HOST: :1900 CACHE-CONTROL: max-age = seconds until advertisement expires LOCATION: URL for UPnP description for root device NT: search target NTS: ssdp:alive SERVER: OS/version UPnP/1.0 product/version USN: advertisement UUID

6 Prof. Dr. M. Mühlhäuser Telekooperation © :6 Multicast with Java (Sender code outline) public void sendMsg() { MulticastSocket UDPmc; // Generate multicast ssdp:alive notify. // Some methods are only to give an idea (eg. „public string getHttpVersion()“) String aliveMsg = ""; aliveMsg = "NOTIFY * HTTP/" + getHttpVersion()+ CRLF; aliveMsg += "LOCATION: //+"....getLocalAddress().getHostAddress()“ + CRLF; //You must complete the notification Packet here... //Packet length should be <1500 bytes (Ethernet MTU=Maximun Transfer Unit). // However the MTU may vary according to the underlying hardware. //Create the datagram Packet to be sent DatagramPacket ssdpAliveMsgPacket = new DatagramPacket(aliveMsg.getBytes(), aliveMsg.getBytes().length, MULTICAST_GROUP, MULTICAST_PORT); //MULTICAST GROUP addresses have a range that consists of addresses from through to //(Class D addresses.) Example: the Multicast Group for upnp is: try { UDPmc = new MulticastSocket(); // Create Multicast Socket UDPmc.joinGroup(InetAddress.getByName(MULTICAST_GROUP)); // Bind the multicast socket to the Multicast group } catch (IOException e) {System.out.println("Exception creating&setting up the m-cast socket");} //Send alive Packet try { UDPmc.send(aliveMsg); } catch (IOException e) { System.out.println("Exception attempting to send Packet"); } // On closing the connection, some clean up: UDPmc.leaveGroup(InetAddress.getByName(MULTICAST_GROUP)); UDPmc.close();

7 Prof. Dr. M. Mühlhäuser Telekooperation © :7 Multicast with Java (Receiver outline) public ReceivePackets() { try { // create an empty packet to receive data DatagramPacket ssdpAliveMsgPacket = new DatagramPacket(ssdpAliveMsgPacket.getBytes(), ssdpAliveMsgPacket.getBytes().length,MULTICAST_GROUP, MULTICAST_PORT); //Create a Multicast socket MulticastSocket UDPmc = new MulticastSocket(MULTICAST_PORT); // Bind the socket to the Multicast group InetAddress group = InetAddress.getByName(MULTICAST_GROUP); MulticastSocket UDPmc.joinGroup(group); // wait for a packet UDPmc.receive(dp); // Clean up… UDPmc.leaveGroup(ia); UDPmc.close(); } catch (UnknownHostException e) { logger.error(e); } catch (IOException e) { logger.error(e); }


Download ppt "Telecooperation Technische Universität Darmstadt Copyrighted material; for TUD student use only Telecooperation P4: Internet Praktikum Q&A Session Telecooperation."

Similar presentations


Ads by Google