Advanced Computer Networks: Lecture 39. This lecture will cover the following: presentation formatting; data compression; eXternal Data Representation (XDR); abstract syntax notation one (ASN-1); run length encoding (RLE); differential pulse code modulation (DPCM);...
CS716 Advanced Computer Networks By Dr. Amir Qayyum 1 Lecture No. 39 Presentation Formatting Outline Presentation Formatting Data compression Presentation Formatting Application Application Data Data Presentation Presentation Decoding Encoding Message Message ■■■ Message Presentation Formatting • Data types we consider – – – – – Integers Floats Strings Arrays Structs • Types of data we do not consider – Images – Video – Multimedia documents Difficulties • Representation of base types – Floating point: IEEE 754 versus nonstandard – Integer: bigendian vs littleendian (e.g., 34,677,374) (2) Big-endian (17) (34) (126) 00100010 01111110 (34) (17) (2) 00100010 00010001 00000010 00000010 00010001 (126) Little-endian 01111110 Low address • Compiler layout of structures High address Taxonomy • Data types – Base types (e.g. ints, floats), must convert – Flat types (e.g. structures, arrays), must pack – Complex types (e.g. pointers), must linearize Application data structure Argument marshaller Taxonomy • Conversion Strategy – Canonical intermediate form – Receivermakesright (an N x N solution) Taxonomy (cont) • Tagged versus untagged data type = len = INT value = 417892 Taxonomy (cont) • Stubs – Compiled – Interpreted Interface descriptor for procedure P Call P Arguments Client stub Code P Specification Stub compiler Code Marshalled arguments Arguments Server stub Marshalled arguments RPC RPC Message 10 Lossless Algorithms • Run Length Encoding (RLE) – Example: AAABBCDDDD encoding as 3A2B1C4D – Good for scanned text (8to1 compression ratio) – Can increase size for data with variation (e.g. some images) 18 Lossless Algorithms • Differential Pulse Code Modulation (DPCM) – Example AAABBCDDDD encoding as A0001123333 – Change reference symbol if delta becomes too large – Works better than RLE for many digital images (1.5to1) 19 DictionaryBased Methods • Build dictionary of common terms – Variable length strings • Transmit index into dictionary for each term • LempelZiv (LZ) is the bestknown example • Commonly achieve 2to1 ration on text • Variation of LZ used to compress GIF images – First reduce 24bit color to 8bit color – Treat common sequence of pixels as terms in dictionary – Not uncommon to achieve 10to1 compression (x3) 20 Image Compression • JPEG: Joint Photographic Expert Group (ISO/ITU) • Lossy stillimage compression • Three phase process JPEG compression Source image DCT Quantization Encoding Compressed image – Process in 8x8 block chunks (macroblock) – Grayscale: each pixel is three values (YUV) – DCT: transforms signal from spatial domain into and equivalent signal in the frequency domain (lossless) – Apply a quantization to the results (lossy) – RLElike encoding (lossless) 21 Quantization and Encoding • Quantization Table 3 5 7 9 11 13 15 17 5 7 9 11 13 15 17 19 7 9 11 13 15 17 19 21 9 11 13 15 17 19 21 23 11 13 15 17 19 21 23 25 13 15 17 19 21 23 25 27 15 17 19 21 23 25 27 29 17 19 21 23 25 27 29 31 • Encoding Pattern 22 MPEG • Motion Picture Expert Group • Lossy compression of video • First approximation: JPEG on each frame • Also remove interframe redundancy 23 • Frame types MPEG (cont) – I frames: intrapicture – P frames: predicted picture – B frames: bidirectional predicted picture Input stream Frame Frame Frame Frame Frame Frame Frame MPEG compression Forward prediction CompressedI frame B frame B frame P frame B frame B frame I frame stream Bidirectional prediction • Example sequence transmitted as I P B B I B B 24 MPEG (cont) • B and P frames – Coordinate for the macroblock in the frame – Motion vector relative to previous reference frame (B, P) – Motion vector relative to subsequent reference frame (B) – Delta for each pixel in the macro block • Effectiveness – Typically 90to1 – As high as 150to1 – 30to1 for I frames – P and B frames get another 3 to 5x 25 Frame as Collection of Macroblocks Color frame 16 × 16 pixel region 16 × 16 macroblock with Y component × macroblock with U component × macroblock with V component 26 MP3 ã CDQuality 44.1kHzsamplingrate 2ì44.1ì1000ì16=1.41Mbps 49/16ì1.41Mbps=4.32Mbps ã Strategy Splitintosomenumberoffrequencybands Divideeachsubbandintoasequenceofblocks EncodeeachblockusingDCT+Quantization+ Huffman – Trick: how many bits assigned to each subband 27 RTP • ApplicationLevel Framing • Data Packets – Sequence number – Timestamp (app defines “tick”) • Control Packets (send periodically) – Loss rate (fraction of packets received since last report) – Measured jitter 28 Transmitting MPEG • Adapt the encoding – Resolution – Frame rate – Quantization table – GOP mix • Packetization • Dealing with loss • GOPinduced latency 29 Figure 7.15 SeqHdr Group of pictures SeqHdr Group of pictures ■■■ SeqEndCode GOPHdr Picture Picture ■■■ Picture PictureHdr Slice Slice ■■■ Slice SliceHdr Macroblock Macroblock ■■■ Macroblock MBHdr Block(0) Block(1) Block(2) Block(3) Block(4) 30 Block(5) Layered Video • Layered encoding – e.g. wavelet encoded • Receiver Layered Multicast (RLM) – Transmit each layer to a different group address – Receivers subscribe to the groups they can “afford” – Probe to learn if you can afford next higher group/layer • Smart Packet Dropper (multicast or unicast) – Select layers to send/drop based on observed congestion – Observe directly or use RTP feedback 31 RealTime Scheduling • • • • Priority Earliest Deadline First (EDF) Rate Monotonic (RM) Proportional Share – With feedback – With adjustments for deadlines 32 ... xdr_item(XDR *xdrs, struct item *ptr) { return(xdr_int(xdrs, &ptr->count) && xdr_string(xdrs, &ptr->name, MAXNAME) && xdr_array(xdrs, &ptr->list, &ptr->count, MAXLIST, sizeof(int), xdr_int)); } Count Name... Integer: bigendian vs littleendian (e.g., 34,677,374) (2) Big-endian (17) (34) (126) 00100010 01111110 (34) (17) (2) 00100010 00010001 00000010 00000010 00010001 (126) Little-endian 01111110 Low address • Compiler layout of structures.. .Lecture? ?No.? ?39 Presentation Formatting Outline Presentation Formatting Data compression Presentation Formatting