The invention is related to the Internet. More specifically, the invention relates to compression and optimization of markup language documents in a Universal Plug and Play environment.
The advent of the Universal Plug and Play (UPnP) standard has led to new benefits of communication and interoperability between many devices connected to a network. UPnP enables the discovery and control of networked devices and services, such as mobile computers, servers, printers, and consumer electronic devices. A UPnP-enabled device can dynamically connect to a network, obtain an IP address, convey its capabilities, and learn about the presence and capabilities of other devices without any user intervention. As computing and network technology is incorporated within more and more devices and appliances the demand for small, fast, and efficient UPnP technology becomes greater.
Unlike the desktop PCs of today, many potential UPNP devices do not have powerful CPUs or large storage capabilities. Many handheld devices such as personal digital assistants (PDAs), cell phones, and remote controls among others benefit from UPNP functionality. Additionally, electronic appliances such as dishwashers, TVs, and refrigerators can also take advantage of UPnP capabilities to create a truly network connected home or business. To accomplish this connectivity and communication among these wide range of devices UPnP provides support for communication between devices. The actual network, the TCP/IP protocol, and HTTP provide basic network connectivity and addressing. On top of these standard Internet-based protocols, UPnP defines a UPnP protocol stack to handle discovery, description, control, events, and presentation among the connected devices.
The UPnP stack must be very small in order to run not only on PCs but also on all the small embedded devices such as digital cameras, audio players, remote controls, etc. A common UPnP stack is about 60-90 Kbytes, but about 20-25% of that size are static or mostly static Extensible Markup Language (XML) documents. XML documents, in regard to UPnP, are used for device and service descriptions, control messages, and eventing. All UPnP devices must be able to describe themselves upon request. The description of a UPnP device is encoded in a device description document and one or more service description documents.
Therefore, what is needed is a method for effectively optimizing and compressing these XML documents for storage on a device as well as for efficiently decompressing the documents on the fly when a document located on a device is requested by another device or control point on the network.
The present invention is illustrated by way of example and is not limited by the figures of the accompanying drawings, in which like references indicate similar elements, and in which:
Embodiments of an efficient universal plug-and-play markup language document optimization and compression scheme are disclosed. In the following description, numerous specific details are set forth. However, it is understood that embodiments may be practiced without these specific details. In other instances, well-known circuits, structures and techniques have not been shown in detail in order not to obscure the understanding of this description.
Reference throughout this specification to “one embodiment” or “an embodiment” indicate that a particular feature, structure, or characteristic described in connection with the embodiment is included in at least one embodiment. Thus, the appearances of the phrases “in one embodiment” or “in an embodiment” in various places throughout this specification are not necessarily all referring to the same embodiment. Furthermore, the particular features, structures, or characteristics may be combined in any suitable manner in one or more embodiments.
The document is then stored as compressed XML 110 directly in the UPnP stack, referred to as the Microstack 108 because of the smaller size with the optimized and compressed XML document. When the device fields a request from a second device for the document, such as a request for the device description, the Compressed XML document is decompressed on the fly as it is being transmitted to the second device. This decompression is completed by the Micro-extractor 112. Upon completion of the decompression the document will have been extracted from the stack and transmitted to the second device. The resulting UPnP XML document is functionally and data equivalent to UPNP XML document 100. UPNP devices can also act as an HTTP server for their presentation web pages. Thus, in another embodiment of the invention the document could be an HTML document, which can be decompressed and served on the fly similarly to an XML document. In yet another embodiment, the document can be any other web-based markup language that has similar qualities to XML or HTML.
On the other hand, if there is a match found the set of consecutive subsequent characters that do match a block of consecutive characters in the buffer is replaced with a look-back pointer value to the location in the buffer that points to the start of the consecutive block and a value that corresponds to the length of the block 310. This allows the entire set of subsequent appended characters to be replaced by a two-byte value and the document decreases in size by the length of the block minus two bytes. Therefore, the minimum number of sequential characters that need to match in order for a decrease in size is three because otherwise there wouldn't be a size decrease. In one embodiment the minimum size required to justify a pointer/length value replacement would need to be more than three characters because of the overhead associated with the replacement. Finally, there is a check to see if the file has come to an end after the replacement. If this is the case then the process finishes 312, otherwise the process returns to 306 where more characters are appended to the buffer.
The size in bits of the pointer and length values in the two-byte replacement value can be distributed in various arrangements. Depending on the type of document, the size of the sliding window, and the speed of the device the pointer value can longer, shorter, or the same length in bits as the length value. For example, in one embodiment the pointer can be a 10-bit value (which would allow the pointer to point backwards into the buffer at up to 1-Kbyte) and the block length would therefore be a 6-bit value (which would allow matching blocks up to 64 bytes long). Alternatively, in another embodiment the pointer can be an 8-bit value (which would allow the pointer to point backwards into the buffer at up to 256 bytes) and the block length would therefore be also an 8-bit value (which would allow matching blocks up to 256 bytes long). Other differing bit length pairs of values can be used in other embodiments to utilize the compression scheme most efficiently. In another embodiment, the replacement value would not be two bytes but some other number of bits greater or less than two bytes.
Upon completion of the compression algorithm a compressed web-based document such as the UPNP device description document or a UPnP service description document is stored directly in the UPnP stack on the device. This algorithm can be repeated for all compatible web-based documents that are to be stored on the UPNP stack located on the device. The document compression scheme should allow somewhere between a 6:1 to 9.5:1 compression ratio, which reduces the memory/storage space required to Depending on the amount and size of the web-based documents the entire UPnP stack footprint on the memory/storage located on the device can be reduced by 10% or greater. This is significant considering many of these devices are handheld and have limited storage capacity.
Once the device with the UPNP stack is accessed by a second device or control point on the network, the compressed documents must be decompressed by the Micro-extractor prior to being transferred to the second device. The decompression algorithm can be implemented in as small as 10 lines of code. It specifically is just a reversed process of the compression algorithm described above and in
In another embodiment, outside the current space of UPNP, a compressed web-based document stored on a first device can be sent to a second requesting device as a compressed document and then decompressed on-the-fly on the second device. In yet another embodiment, the Micro-extractor can be embedded within the web-based document itself so the extraction capabilities are self-contained within the document such as in a Javascript routine. The document can be sent from one device to a second device compressed and the second device can use the compression algorithm embedded within the document to decompress the document. An embedded compression algorithm can be modified on a document by document basis to account for content, device speed, device storage capability, and transfer speed.
Thus, an efficient UPnP markup language document optimization and compression scheme is disclosed. These embodiments have been described with reference to specific exemplary embodiments thereof. It will, however, be evident to persons having the benefit of this disclosure that various modifications and changes may be made to these embodiments without departing from the broader spirit and scope of the embodiments described herein. The specification and drawings are, accordingly, to be regarded in an illustrative rather than a restrictive sense.