You are on page 1of 14

Outline

CS4233 Network Programming z Introduction to the Internet

Introduction to TCP/IP z OSI network model

Chen-Lung Chan z TCP/IP model


Department of Computer Science
National Tsing Hua University z Network applications

z Socket

The Internet Challenges of the Internet


z An inter-net: a network of networks. z Scale:100,000,000s of hosts
z A set of networks that are connected with each other
z Networks are connected using routers that support z Heterogeneity:
communication in a hierarchical fashion
z 18,000+ administrative domains
z Often need other special devices at the boundaries for
security, accounting, .. z Thousands of applications
z The Internet: the interconnected set of networks of the z Lots of users
Internet Service Providers (ISPs) providing data
communications services. z Fast links, slow links, satellite links, cellular
z In order to inter-operate, all participating networks links, carrier pigeons
have to follow a common set of rules. z Diversity
of network technologies
z Adversarial environment (contention)
Implementing Packet-Switched
Packet Switching
Networks
z Source sends information as self-contained packets z Requirements for packets:
that have an address. z Header information: Addresses, etc.
z Source may have to break up single message in multiple z Data. What is packet size limit?
z Each packet travels independently to the destination z Everybody must agree on these for interoperability
host. z How do packets reach destination? Routing
z Routers and switches use the address in the packet to
determine how to forward the packets z Nodes in network forward packets towards
destination
z Analogy: a letter in surface mail.
z Routing tells nodes where to send the packets they
receive
z Design questions: What criteria to decide?
z Destination (essential)
z Source?
z “Type”?

IP Addresses (1/2) IP Addresses (2/2)

z Logical address at network layer Network ID Host ID


8 16 24 32
z 32 bit address space Class A 0 Network ID Host ID
z Network number, Host number
Class B 10
z Machines on the same “network” have
the same network number Class C 110

z One address per interface Class D 1110 Multicast Addresses

Class E 1111 Reserved for experiments


Subnetting Routing
z Add another layer to hierarchy
z Could subnet a class B into several chunks z Who chooses the routes?
z How to check an IP is in the same subnet? z A human: Static routing
z “AND” both IPs with the subnet mask
z Check if the result addresses are identical z Centralized routing (telenet, c.a. 1980s)
z Ex: {140.114.87.70, 140.114.87.72}, netmask = 255.255.255.0
⇒ {140.114.87.0, 140.114.87.0} z Distributed routing (Internet, …)

Network Host z Distributed routing uses a Routing Protocol


z Many different protocols are in use.
Network Subnet Host z Inside an organization: RIP, OSPF, etc
Subnet z Between organizations: BGP
111111111111111111111111 00000000
Mask

Host Routing Table Example Network Service Model

Destination Gateway Genmask Iface z What is the service model?


140.114.78.0 140.114.78.20 255.255.255.0 eth0
127.0.0.0 127.0.0.1 255.0.0.0 lo z Ethernet/Internet: best-effort – packets can get lost,
0.0.0.0 140.114.78.254 0.0.0.0 eth0 etc.

z Host 140.114.78.20 is in EECS 8F Ethernet


z What if you want more?
z Dest 140.114.78.0 Æ routing to the same Ethernet z Network can do it – Quality of Service
z Dest 127.0.0.0 Æ special loopback address
z Dest 0.0.0.0 Æ default route to rest of the Internet z Benefits of circuit switching in packet-switched net
z Main EECS 8F router: 140.114.78.254 z Hard in the Internet, easy in restricted contexts
z To see the routing table of your machine
z In Windows & UNIX: netstat –r z Hosts can do it – end-to-end Transport protocols
z To see the routing path to a host z TCP performs end-to-end retransmission of lost packets to
z UNIX: traceroute give the illusion of a reliable underlying network.
z Windows: tracert
Using Networks Using Networks Securely

z Layering and abstraction z The Internet is an unfriendly place


z Protocol stacks facilitate re-use z Hacking, viruses, denial-of-service, etc.
z Hide underlying complexity from the programmer z Cryptography to the rescue:
z Protocol reuse and code/library reuse
z Secure Sockets Layer (SSL)
z Many “human-friendly” abstractions: z Key management, etc.
z Higher-level protocols (e.g., reuse the Web’s HTTP
instead of writing your own!). z Policy control to the rescue:
z Naming (www.google.com vs. 64.233.161.99) z Firewalls / Denial of Service
z The Domain Name System, or DNS z Network address translation / virtual private
networks (NAT, VPN)

Applications Outline

z Allwell and good to have networks that z Introduction to the Internet


deliver packets, but what do we actually
do with them? z OSI network model
z The Web
z TCP/IP model
z E-Mail
z Peer to Peer z Network applications
z Voice over IP
z Socket
Network Model (OSI) Physical Layer

Moves bits from one end to other

z Media Dependent
z Copper: Coaxial/Twisted Pair; Typically up to 100 Mbps
z Fiber: Single/Multi Mode; Can transmit in Gigabits/second
z Satellite: Channels of 64 kbps, 128 kbps
z Radio waves: Ranges from Kbps to Mbps

Data Link Layer Network Layer


Deliver data from a host to another
z Why do we need a network layer?
z Can all machines in the world be Ethernet?
z Other technologies (modems, token ring)
Controls a single physical link z Goals and Services:
z Medium Access Control (MAC) z Hide type of subnets (Ethernet, Token Ring,
z CSMA/CD, CSMA/CA, Token-Ring, … FDDI ... )
z Logical Link Control (LLC): z Hide topology of subnets
z Framing (start and stop)
z Error Detection
z Choose good routes
z Error Correction z Uniform addressing scheme
z Optimal Use of Links (Sliding Window Protocol) z OSPF, BGP in Internet
z Examples: HDLC, LAP-B, LAP-D
Transport Layer Session Layer
Provide end-to-end transmission quality to two users Define the rule of a session
z Accepts data from session layer and split it into
smaller units (if needed) and pass them to network z Allows users on different machines to
layer. establish sessions between them.
z Typical transport layer would provide error-free point-
to-point data channel that delivers message/bytes in z Allows ordinary data transport (as does
the order in which they were sent.
transport layer) and also provides
z However, other possible kind could be transport of
isolated messages with no guarantee. enhanced services useful for some
z It is a true end-to-end layer from source to destination applications (e.g. checkpointing of
(in lower layers protocols are between each machine
and its immediate neighbors).
sessions, dialog control).

Presentation Layer Application Layer


Deliver “meaningful” data to users z Handles application specific
z Performs certain functions that are requested
sufficiently often to warrant finding a general issues/protocols
solution for them. z e.g. different file naming conventions,
z Unlike lower layers, this layer is concerned different ways of representing text lines
with syntax and semantics of the information
z Various special and general purpose
transmitted.
z Manages abstract data structures and
facilities are taken care of by application
converts from the representation inside the layer while two remote applications
computer (e.g. ASCII, Unicode) to the network communicate with each other.
standard and back.
Outline OSI and TCP/IP Models

z Introduction to the Internet OSI TCP/IP


Application Application
z OSI network model Presentation
Session
z TCP/IP model
Transport Transport

z Network applications Network Internet

Data Link Data Link


z Socket
Physical Physical

TCP/IP Layers (1/2) TCP/IP Layers (2/2)

z Physical: z Network:
z transmitting bits over a communication z addressing and routing of packets
channel z Transport:
z Data Link: z end-to-end connection characteristics
z transforming the raw physical layer into a z Application:
‘link’ for the higher layer
z “application” protocols
Layering: Physical Communication Layering: Logical Communication
data
data
application application
transport transport
transport
network network
link link
physical physical
Router
network ack network Router
application link application link
transport physical transport data physical
network network
link link
data data
physical physical
application application application application
transport transport transport transport
transport
network network network network
link link link link
physical physical physical physical

Overview of TCP/IP (1/2) Overview of TCP/IP (2/2)

z Some TCP/IP protocols: z Some TCP/IP protocols ... cont’d


z TCP: Transmission control protocol z ICMP: Internet Control Message Protocol
z Connection-oriented, reliable, full duplex, byte stream
service z Handles errors and control information for IP
(ping, traceroute)
z UDP: User datagram protocol
z Connectionless, unreliable z IGMP: Internet Group Management Protocol
z IPv4: Internet Protocol, version 4. z Used in IP multicast
The protocol that glues the Internet together.
z
z Socket programming
z Provides (unreliable) packet delivery service for TCP, UDP,
ICMP, IGMP z The use of TCP and UDP
z IPv6: Internet Protocol, version 6. z Can also access the lower layers directly (raw
z 128 bits address, newer version of Internet Protocol socket)
UDP: User Datagram Protocol TCP: Transmission Control Protocol

z Unreliable, connectionless service z Guaranteed service protocol


z Data may be lost, duplicated, or reordered z ensures that a packet has been received by the
destination by using acknowledgements and
z Client and server do not have any long term retransmission
relation z applications need to establish a TCP connection
z Can perform (unreliable) multicast prior to transfer
z Useful for Applications such as voice and z Features
video, where z Connection Oriented
z retransmission should be avoided z Reliable
z Byte Stream
z the loss of a few packets does not greatly affect
performance z Flow Control
z Congestion Control

Reliable Communication Outline

z Implementing reliable communication may z Introduction to the Internet


require
z Sequence number, acknowledgement, z OSI network model
retransmission, timeout (RTT)
z Sliding window protocol for efficiency z TCP/IP model
z Flow control

z Connection establishment and release z Network applications

z Socket
Network Applications Client-Server paradigm
application
transport
z Domain Name Service (DNS) network
link
z Simple Mail Transfer Protocol (SMTP) physical Reply
network
z Network File System (NFS) link
Request physical
z Network Management (SNMP) Typical network app
z Network Security (Secured Socket Layer has two pieces:
application
SSL) client and server transport
network
link
physical

Actions Example: Web Access (HTTP)


net.html www.it.iitb.ac.in
z Client <html>

http://www.it.iitb.ac.in/net.html
Some networking companies:
z initiates contact with server (“speaks first”) <a href=“http://www.cisco.com”>

Request for resource


Cisco</a>
z typically requests service from server <a href=“http://www.motorola.com”>
z e.g.: sends request for Web page Motorola</a> Response:
</html> net.html
z Server
z provides requested service to client www.cisco.com
Client
HTML rendering
z e.g., sends requested Web page of net.html
Some networking companies:
Cisco Motorola
Some Application Protocols Example: HTTP
Application Underlying z $ telnet www.cs.nthu.edu.tw 80
Application layer protocol transport protocol Trying 140.114.77.3...
Connected to www.cs.nthu.edu.tw.
Escape character is '^]'.
e-mail smtp [RFC 821] TCP GET /index.html
remote terminal access telnet [RFC 854] TCP <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
Web http [RFC 2068] TCP <HTML>
<HEAD>
file transfer ftp [RFC 959] TCP <TITLE>國立清華大學資訊工程系</TITLE>
streaming multimedia proprietary TCP or UDP <META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=BIG5">
(e.g. RealNetworks) <META NAME="Generator" CONTENT="NetObjects Fusion 8 for Windows">
<SCRIPT>
remote file server NFS TCP or UDP <!--
Internet telephony proprietary typically UDP function F_loadRollover(){} function F_roll(){}
//-->
(e.g., Vocaltec) </SCRIPT>
<SCRIPT LANGUAGE="JavaScript1.2" SRC="./assets/rollover.js"></SCRIPT>
<NOLAYER>

Traditional Distributed Applications Middleware (1/2)

z Application logic z Software between application programs


z Transport interface code: and OS/network
z Makes the appropriate network calls to send
and receive the messages z Provides a set of higher-level distributed
z Usually divided into transport-independent computing capabilities and a set of
and transport-dependent parts standards-based interfaces
z Middleware provides transparency of the
transport interface code
Middleware (2/2) Middleware & API

z Interfaces allow applications to be Application Program


distributed and to take advantage of
other services provided over the network.
z Middleware is a set of services that are
API API API
accessible to application programmers Middleware
Middleware Middleware
through an API. Service 1 Service 2 Service 3
z Example: Sockets, RPC, CORBA

Outline Sockets API

z Introduction to the Internet z Interfacebetween application and


transport layer
z OSI network model
z two processes communicate by
z TCP/IP model z sending data into a socket

z reading data out of a socket


z Network applications
“identifies” Server process
z Client
z Socket using <IP address ; port number>
Sockets Interface Socket (1/2)
controlled by
controlled by process application z host-local, application-owned, OS-
application process developer
developer
socket
controlled, communication interface
socket

TCP with controlled by


z two processes communicate by
controlled by TCP with buffers, operating
operating buffers,
internet variables system sending data into socket, reading
system variables
data out of socket
host or
z door between application process
host or
server and transport protocol
server

Socket (2/2) Socket Types

z Socket identification:
z “IPaddress” of client and server hosts
z “port number” of client and server
applications
z Socket types:
z reliable,
byte stream-oriented (TCP)
z Unreliable, connection-less datagram
(UDP)
Client Actions Server Actions

z Create a socket (socket()) z Create a socket (socket())


z Map server name to IP address z Bind to port number (bind())
(gethostbyname()) z Listen on the socket (listen())
z Connect to a given port on the server z Accept client connections (accept())
address (connect())
z Server process must be running!
z Client must contact server first!

Socket Programming

You might also like