Docsity

Presentation Formatting-Advance Computer Networking-Lecture Slides, Slides of Computer Networks

Partial preview of the text

Download Presentation Formatting-Advance Computer Networking-Lecture Slides and more Slides Computer Networks in PDF only on Docsity!

2

Lecture No. 39

3

Presentation Formatting

Outline

Presentation FormattingData compression

5

Presentation Formatting

  • Data types we consider
    • Integers– Floats– Strings– Arrays– Structs
      • Types of data we do not consider
        • Images– Video– Multimedia documents

6

Difficulties

  • Representation of base types
    • Floating point: IEEE 754 versus non-standard– Integer: big-endian vs little-endian (e.g., 34,677,374)
      • Compiler layout of structures

(126)

(34)

(17)

(2)

00000010

Big-endianLittle- endian

(2)

(17)

(34)

(126)

Low address

High address

0

0

111111

0 0

0 0 1

0 0

1

0 0

0

01

001

0 0

0 0 1

0 0

1

0 0

0

01

001

0 0 0

000 0

1

0

0 1 1 1 1 1 1

8

Taxonomy

  • Conversion Strategy
    • Canonical intermediate form– Receiver-makes-right (an

N

x

N

solution)

9

Taxonomy (cont)

  • Tagged versus untagged data
type =
INT
len = 4
value = 417892

11

eXternal Data Representation

(XDR)

  • Defined by Sun for use with SunRPC• C type system (without function

pointers)

  • Canonical intermediate form• Untagged (except array length)• Compiled stubs

12

#define MAXNAME 256;#define MAXLIST 100;struct item {

int

count;

char

name[MAXNAME];

int

list[MAXLIST];

**};bool_txdr_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 J

O

3

7

H

N

S

O

N

List

3

4 9 7

2 6 5

8 321

Example Code (XDR)

14

ASN.1 BER Representation

length

0

k

1

k containing

length

(a) (b)

15

Network Data Representation (NDR)

  • Defined by DCE• Essentially the C type

system

  • Receiver-makes-right

(architecture tag)

  • Individual data items

untagged

  • Compiled stubs from IDL• 4-byte architecture tag
  • IntegerRep
  • 0 = big-endian• 1 = little-endian
  • CharRep
  • 0 = ASCII• 1 = EBCDIC
  • FloatRep
  • 0 = IEEE 754• 1 = VAX• 2 = Cray• 3 = IBM

IntegrRep 0

4

8

16

24

31

FloatRep

CharRep

Extension 1

Extension 2

17

Compression Overview

  • Encoding and Compression
    • Huffman codes
      • Lossless
        • Data received = data sent– Used for executables, text files, numeric data
          • Lossy
            • Data received is not equal to data sent– Used for images, video, audio

18

Lossless Algorithms

  • Run Length Encoding (RLE)
    • Example: AAABBCDDDD encoding as

3A2B1C4D

  • Good for scanned text (8-to-

compression ratio)

  • Can increase size for data with variation

(e.g. some images)

20

Dictionary-Based Methods

Build dictionary of common terms

  • Variable length strings

Transmit index into dictionary for each term

Lempel-Ziv (LZ) is the best-known example

Commonly achieve 2-to-1 ration on text

Variation of LZ used to compress GIF images

  • First reduce 24-bit color to 8-bit color– Treat common sequence of pixels as terms in

dictionary

  • Not uncommon to achieve 10-to-1 compression (

x

21

Image Compression

JPEG: Joint Photographic Expert Group (ISO/ITU)

Lossy still-image compression

Three phase process

  • Process in 8x8 block chunks (macro-block)– Grayscale: each pixel is three values (YUV)– DCT: transforms signal from spatial domain into and equivalent

signal in the frequency domain (loss-less)

Sourceimage – Apply a quantization to the results (lossy)– RLE-like encoding (loss-less)

JPEG compression

DCT

Quantization

Encoding

Compressed

image