lec10

lec10 - Serialization and Bit Operations CS 2022:...

Info iconThis preview shows pages 1–8. Sign up to view the full content.

View Full Document Right Arrow Icon
Serialization and Bit Operations CS 2022: Introduction to C Instructor: Hussam Abu-Libdeh Presented by: Renato Paes Leme Cornell University (based on slides by Saikat Guha) Fall 2009, Lecture 10 Serialization and Bit Operations CS 2022, Fall 2009, Lecture 10
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Serialization Sending data between programs Disk Network Pipes Between programs on multiple hosts Diferent endianness Diferent architectures Serialization and Bit Operations CS 2022, Fall 2009, Lecture 10
Background image of page 2
Binary vs. Text Binary. . . Compact Easy to encode/decode Faster e.g. IP, TCP, AIM, . . . Text. . . Easily debugged (Can be) self-documenting Arch/Endian independent e.g. HTTP, SMTP, MSN Serialization and Bit Operations CS 2022, Fall 2009, Lecture 10
Background image of page 3

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Ok, but how? What serialization solution to use? tpl library c11n library Google protocol bufers Customized solution Which standard to use? XML, XDR, protocol bufer, . .. Network protocol standards Serialization and Bit Operations CS 2022, Fall 2009, Lecture 10
Background image of page 4
Handling Endianness Decimal: 3735928559 Binary: 11011110101011011011111011101111 Hex: 0xdeadbeef Big Endian: 0xde 0xad 0xbe 0xef Little Endian: 0xef 0xbe 0xad 0xde Always in big-endian form when loaded into the CPU Serialization and Bit Operations CS 2022, Fall 2009, Lecture 10
Background image of page 5

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Bit-Operations AND-Mask (clear bits) 1101111010101101 10111110 11101111 0xdead be ef 0000000000000000 11111111 00000000 0x0000 FF 00 = = 0000000000000000 10111110 00000000 0x0000 be 00 Serialization and Bit Operations CS 2022, Fall 2009, Lecture 10
Background image of page 6
Bit-Operations OR-Mask (sets bits) a | b 1101111010101101 10111110 11101111 0xdead be ef | | 0000000000000000 01010101 00000000 0x0000 55 00 = = 1101111010101101 11111111 11101111 0xdead FF ef Serialization and Bit Operations CS 2022, Fall 2009, Lecture 10
Background image of page 7

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Image of page 8
This is the end of the preview. Sign up to access the rest of the document.

This document was uploaded on 03/10/2011.

Page1 / 24

lec10 - Serialization and Bit Operations CS 2022:...

This preview shows document pages 1 - 8. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online