3rd Review

Only available on StudyMode
  • Download(s) : 81
  • Published : March 7, 2013
Open Document
Text Preview
Introduction to Sockets Programming in C using TCP/IP

Professor: Panagiota Fatourou TA: Eleftherios Kosmas CSD - May 2012

Introduction
Computer Network
hosts, routers, communication channels
Host

Hosts run applications Routers forward information Packets: sequence of bytes contain control information e.g. destination host

Router

Communication channel

Protocol is an agreement
meaning of packets structure and size of packets e.g. Hypertext Transfer Protocol (HTTP) CS556 - Distributed Systems Tutorial by Eleftherios Kosmas 2

Protocol Families - TCP/IP
Several protocols for different problems Protocol Suites or Protocol Families: TCP/IP TCP/IP provides end-to-end connectivity specifying how data should be formatted, addressed, transmitted, routed, and received at the destination

can be used in the internet and in stand-alone private networks it is organized into layers CS556 - Distributed Systems Tutorial by Eleftherios Kosmas 3

TCP/IP
*

FTP, SMTP, … Transport Layer TCP or UDP Network Layer IP Communication Channels

* image is taken from “http://en.wikipedia.org/wiki/TCP/IP_model”

CS556 - Distributed Systems

Tutorial by Eleftherios Kosmas

4

Internet Protocol (IP)
provides a datagram service
packets are handled and delivered independently

best-effort protocol
may loose, reorder or duplicate packets

each packet must contain an IP address of its destination

CS556 - Distributed Systems

Tutorial by Eleftherios Kosmas

5

Addresses - IPv4
The 32 bits of an IPv4 address are broken into 4 octets, or 8 bit fields (0-255 value in decimal notation). For networks of different size, the first one (for large networks) to three (for small networks) octets can be used to identify the network, while the rest of the octets can be used to identify the node on the network. Range of addresses

7 Class A: 0 Network ID 14 Class B: 1 0 Network ID 21 Class C: 1 1 0 Network ID 28 Class D (multicast): 1 1 1 0 Multicast address 27 Class E (reserved): 1 1 1 1 0 unused 24 Host ID 16 Host ID 8 Host ID

1.0.0.0 to 127.255.255.255 128.0.0.0 to 191.255.255.255 192.0.0.0 to 223.255.255.255 224.0.0.0 to 239.255.255.255 240.0.0.0 to 255.255.255.255

CS556 - Distributed Systems

Tutorial by Eleftherios Kosmas

6

Local Area Network Addresses - IPv4

CS556 - Distributed Systems

Tutorial by Eleftherios Kosmas

7

TCP vs UDP
Both use port numbers
application-specific construct serving as a communication endpoint 16-bit unsigned integer, thus ranging from 0 to 65535 to provide end-to-end transport

UDP: User Datagram Protocol
no acknowledgements no retransmissions out of order, duplicates possible connectionless, i.e., app indicates destination for each packet

TCP: Transmission Control Protocol
reliable byte-stream channel (in order, all arrive, no duplicates) similar to file I/O

flow control connection-oriented bidirectional
CS556 - Distributed Systems Tutorial by Eleftherios Kosmas 8

TCP vs UDP
TCP is used for services with a large data capacity, and a persistent connection UDP is more commonly used for quick lookups, and single use query-reply actions. Some common examples of TCP and UDP with their default ports: DNS lookup FTP HTTP POP3 Telnet UDP TCP TCP TCP TCP 53 21 80 110 23

CS556 - Distributed Systems

Tutorial by Eleftherios Kosmas

9

Berkley Sockets
Universally known as Sockets It is an abstraction through which an application may send and receive data Provide generic access to interprocess communication services e.g. IPX/SPX, Appletalk, TCP/IP Standard API for networking Application Socket TCP IP Host

CS556 - Distributed Systems Channel

Application Socket TCP IP Router
Tutorial by Eleftherios Kosmas Channel

IP Host
10

Sockets
Uniquely identified by
an internet address an end-to-end protocol (e.g. TCP or UDP) a port number

Two types of (TCP/IP) sockets Stream sockets (e.g. uses TCP) provide reliable byte-stream...
tracking img