DOC PREVIEW
U of I CS 438 - Introduction to Unix Network Programming

This preview shows page 1-2-3-4-5-6-42-43-44-45-46-47-85-86-87-88-89-90 out of 90 pages.

Save
View full document
View full document
Premium Document
Do you want full access? Go Premium and unlock all 90 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 90 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 90 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 90 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 90 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 90 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 90 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 90 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 90 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 90 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 90 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 90 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 90 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 90 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 90 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 90 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 90 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 90 pages.
Access to all documents
Download any document
Ad free experience
Premium Document
Do you want full access? Go Premium and unlock all 90 pages.
Access to all documents
Download any document
Ad free experience

Unformatted text preview:

Introduction to Unix Network Programming Reference Stevens Unix Network Programming How do we Communicate Send a mail from Alice to Bob Alice in Champaign Bob in Hollywood Bob Example US Postal Service Alice Hollywood California Champaign Illinois 8 30 06 UIUC CS ECE 438 Fall 2006 2 What does Alice do Alice 200 Cornfield Rd Champaign IL 61820 Bob 100 Santa Monica Blvd Hollywood CA 90028 8 30 06 Bob s address to a mailbox Bob s name in case people share mailbox Postage have to pay Alice s own name and address in case Bob wants to return a message UIUC CS ECE 438 Fall 2006 3 What does Bob do Alice 200 Cornfield Rd Champaign IL 61820 Bob 100 Santa Monica Blvd Hollywood CA 90028 8 30 06 Install a mailbox Receive the mail Get rid of envelope Read the message UIUC CS ECE 438 Fall 2006 4 What about sending a TCP IP packet Very similar to Alice mailing to Bob Different terminologies very confusing Different technologies 8 30 06 We have to remember Suppose to be better faster more reliable cheaper UIUC CS ECE 438 Fall 2006 5 Two simplest networking programs Alice the sending process Alice s address 128 174 246 177 IP addr Alice s name 12345 port int main int sockfd struct sockaddr in bob addr alice addr bzero bob addr sizeof bob addr bob addr sin family AF INET bob addr sin addr s addr 0xD834A784 bob addr sin port 23456 Bob the receiving process Bob s address 216 52 167 132 IP addr Bob s name 23456 port int main int sockfd n struct sockaddr in bob addr alice addr char mesg 100 bzero bob addr sizeof bob addr bob addr sin family AF INET bob addr sin addr s addr 0xD834A784 bob addr sin port 23456 do the same for alice addr sockfd socket AF INET SOCK DGRAM 0 sendto sockfd hi strlen hi 0 bob addr sizeof bob addr 8 30 06 sockfd socket AF INET SOCK DGRAM 0 bind sockfd bob addr sizeof bob addr n recvfrom sockfd mesg 100 0 alice addr sizeof alice addr 2006 UIUC CS ECE 438 Fall 6 What are the problems Message may be lost 8 30 06 Network is congested Receiver is congested Message may be duplicated corrupted Multiple messages re ordered Concurrent connections UIUC CS ECE 438 Fall 2006 7 Direction and Principles Transport Network Data Link Physical 8 30 06 UIUC CS ECE 438 Fall 2006 8 Direction and Principles Programming Transport Network learn to use Internet for communication with focus on implementation of networking concepts Data Link Physical 8 30 06 UIUC CS ECE 438 Fall 2006 8 Direction and Principles Programming Transport Network learn to use Internet for communication with focus on implementation of networking concepts Data Link Physical learn to build network from ground up Principles and Concepts 8 30 06 UIUC CS ECE 438 Fall 2006 8 Sockets process sends receives messages to from its socket socket analogous to mailbox sending process relies on transport infrastructure which brings message to socket at receiving process 8 30 06 host or server host or server process controlled by app developer process socket socket TCP with buffers variables TCP with buffers variables UIUC CS ECE 438 Fall 2006 Internet 9 Network Programming with Sockets 8 30 06 UIUC CS ECE 438 Fall 2006 10 Network Programming with Sockets Reading 8 30 06 Stevens 2nd ed Ch 1 6 or 1st ed Ch 1 3 6 UIUC CS ECE 438 Fall 2006 10 Network Programming with Sockets Reading Stevens 2nd ed Ch 1 6 or 1st ed Ch 1 3 6 Sockets API A transport layer service interface 8 30 06 Introduced in 1981 by BSD 4 1 Implemented as library and or system calls Similar interfaces to TCP and UDP Can also serve as interface to IP for super user known as raw sockets UIUC CS ECE 438 Fall 2006 10 Outline 8 30 06 Client Sever Model TCP UDP Overview Addresses and Data Sockets API Example UIUC CS ECE 438 Fall 2006 11 Client Server Model Asymmetric Communication Client Server Daemon Client Server Client Client sends requests Server sends replies Well known name e g IP address port Waits for contact Processes requests sends replies Client Initiates contact Waits for response Client 8 30 06 UIUC CS ECE 438 Fall 2006 12 Socket Communication Client process 3 way handshaking Client socket 8 30 06 Server process Listening socket Connection socket UIUC CS ECE 438 Fall 2006 13 Client Server Communication Model Service Model Concurrent Sequential Server maintains multiple connections but processes responses sequentially Client and server categories are not disjoint 8 30 06 Server processes only one client s requests at a time Hybrid Server processes multiple clients requests simultaneously A server can be a client of another server A server can be a client of its own client UIUC CS ECE 438 Fall 2006 14 TCP Connections Transmission Control Protocol TCP Service OSI Transport Layer Service Model Reliable byte stream interpreted by application 16 bit port space allows multiple connections on a single host Connection oriented 8 30 06 Set up connection before communicating Tear down connection when done UIUC CS ECE 438 Fall 2006 15 TCP Service Reliable Data Transfer Sequenced Data Transfer Guarantees in order delivery of data If A sends M1 followed by M2 to B B never receives M2 before M1 Regulated Data Flow Guarantees delivery of all data Exactly once if no catastrophic failures Monitors network and adjusts transmission appropriately Prevents senders from wasting bandwidth Reduces global congestion problems Data Transmission 8 30 06 Full Duplex byte stream UIUC CS ECE 438 Fall 2006 16 UDP Services User Datagram Protocol Service 8 30 06 OSI Transport Layer Provides a thin layer over IP 16 bit port space distinct from TCP ports allows multiple recipients on a single host UIUC CS ECE 438 Fall 2006 17 UDP Services Unit of Transfer Unreliable No guaranteed delivery Drops packets silently Unordered Datagram variable length packet No guarantee of maintained order of delivery Unlimited Transmission 8 30 06 No flow control UIUC CS ECE 438 Fall 2006 18 Addresses and Data Internet domain names IP addresses 8 30 06 Human readable Variable length Ex sal cs uiuc edu Easily handled by routers computers Fixed length Somewhat geographical Ex 128 174 252 217 UIUC CS ECE 438 Fall 2006 19 Byte Ordering Big Endian vs Little Endian Little Endian Intel DEC Big Endian Sun SGI HP Most significant byte of word is stored in the lowest memory address Network Byte Order Big Endian 8 30 06 Least significant byte of word is stored in the lowest memory address Allows both sides to communicate Must be used for some data i e IP Addresses Good form for all binary data UIUC CS ECE 438 Fall 2006 20 Byte Ordering


View Full Document

U of I CS 438 - Introduction to Unix Network Programming

Documents in this Course
Routing

Routing

5 pages

TCP

TCP

26 pages

TROLL

TROLL

3 pages

Load more
Download Introduction to Unix Network Programming
Our administrator received your request to download this document. We will send you the file to your email shortly.
Loading Unlocking...
Login

Join to view Introduction to Unix Network Programming and access 3M+ class-specific study document.

or
We will never post anything without your permission.
Don't have an account?
Sign Up

Join to view Introduction to Unix Network Programming 2 2 and access 3M+ class-specific study document.

or

By creating an account you agree to our Privacy Policy and Terms Of Use

Already a member?