0% found this document useful (0 votes)
4 views

Lecture 3

Uploaded by

8xkhfy5f2z
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
4 views

Lecture 3

Uploaded by

8xkhfy5f2z
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 35

Faculty of

Computer
and
Information
Sciences
Information
Technology
Prepared by Dr.Samia Chelloug
Networks Programming
and Applications

IT 341T

Lecture 3: Networks
Programming Basics
Main Reference

Behrouz A.Forouzan, Data Communications and


Networking 5th Edition (Chapters 23, 24 & 25)

James F. Kurose , Keith W. Ross, Computer Networking:


A Top-Down Approach (Chapter 2)

Prepared by Dr.Samia Chelloug 3


Introduction

 The application layer provides services to the end


users.

 Communication is provided using a logical


connection.

 The two application layers assume that there is an imaginary


direct connection through which they can send and receive
messages.

Prepared by Dr.Samia Chelloug 4


Introduction

Prepared by Dr.Samia Chelloug 5


Examples of networks applications
7

 E-mail  Voice over IP (e.g., Skype)


 Web  Real-time video
 Text messaging conferencing
 Remote login  Social networking
 P2P file sharing
 Multi-user network games
 Streaming stored video
(YouTube, Hulu, Netflix)

Prepared by Dr.Samia Chelloug 6


How to write networks applications?
7
 Write programs that:
• run on (different) end systems
• communicate over network

e.g., web server software


communicates with browser software
 No need to write software for
network-core devices
• Network-core devices do not run
user applications

Prepared by Dr.Samia Chelloug 7


Application Architectures
8

 Possible structure of applications:

• Client-server

• Peer-to-peer (P2P)

Prepared by Dr.Samia Chelloug 8


Client Server architecture
8
Server:
• always-on host
• permanent IP address
• data centers for scaling

Clients:
• communicate with server
• may be intermittently connected
• may have dynamic IP addresses
• do not communicate directly with each
other

Prepared by Dr.Samia Chelloug 9


Peer to peer architecture
 No always-on server
 Arbitrary end systems directly
communicate
 Peers request service from other peers,
Provide service in return to other peers
• self scalability – new peers bring
new service capacity, as well as new
service demands
 Peers are intermittently connected and
Change IP addresses
• complex management

Prepared by Dr.Samia Chelloug 10


Process communication

 Process: program running clients, servers


within a host Client process: process that
initiates communication
 Within same host, two Server process: process that
processes communicate using waits to be contacted
inter-process communication
(defined by OS)


Applications with P2P
Processes in different hosts
architectures have client
communicate by exchanging
processes & server processes
messages

Prepared by Dr.Samia Chelloug 11


Socket
 Process sends/receives messages to/from its socket
 Socket is analogous to a door
• sending process shoves message out door
• sending process relies on transport infrastructure on other
side of door to deliver message to socket at receiving
process

Prepared by Dr.Samia Chelloug 12


API

2
 How can a client process communicate with a server process?

• If we need a process to be able to communicate with another


process, we need a new set of instructions to tell the lowest four
layersof the TCP/IP suite to open the connection, send and
receive data from the other end, and close the connection.

• A set of instructions of this kind is normally referred to


as an application programming interface (API).

Prepared by Dr.Samia Chelloug 13


Socket interface

Prepared by Dr.Samia Chelloug 14


Use of sockets in process-to-process
communication

Prepared by Dr.Samia Chelloug 15


Socket address

Prepared by Dr.Samia Chelloug 16


Socket address
 To receive messages,  Identifier includes both IP
process must have address and port numbers
identifier associated with process on
host.
 Host device has unique 32-
bit IP address  Example port numbers:
HTTP server: 80
Q: does IP address of host on mail server: 25
which process runs suffice for to send HTTP message to
identifying the process? gaia.cs.umass.edu web server:
IP address: 128.119.245.12
port number: 80

Prepared by Dr.Samia Chelloug 17


Port numbers

Prepared by Dr.Samia Chelloug 18


IP addresses versus port
numbers

Prepared by Dr.Samia Chelloug 19


ICANN ranges

Prepared by Dr.Samia Chelloug 20


ICANN ranges

0
 Well-known ports. The ports ranging from 0 to 1023 are
assigned and controlled by ICANN. These are the well-
known ports.

❑Registered ports. The ports ranging from 1024 to 49,151


are not assigned or controlled by ICANN. They can only
be registered with ICANN to prevent duplication.

❑ Dynamic ports. The ports ranging from 49,152 to 65,535


are neither controlled nor registered. They can be used as
temporary or private port numbers.

Prepared by Dr.Samia Chelloug 21


Example
 In UNIX, the well-known ports are stored in a file called
/etc/services. Each line in this file gives the name of the server and
the well-known port number.

 We can use the grep utility to extract the line corresponding to the
desired application. The following shows the port for FTP. Note
that FTP can use port 21 with either UDP or TCP.
Example (continued)

SNMP uses two port numbers (161 and 162), each for a
different purpose.

Prepared by Dr.Samia Chelloug 23


Well-known ports used with UDP
and TCP

Prepared by Dr.Samia Chelloug 24


Using transport layer
4
 A pair of processes provide services to the users of the Internet,
human or programs.

 A pair of processes, however, need to use the services provided


by the transport layer for communication because there is no
physical communication at the application layer.

 There are three common transport-layer protocols in the


TCP/IP suite: UDP, TCP, and SCTP. Most standard
applications have been designed to use the services of one of
these protocols.

Prepared by Dr.Samia Chelloug 25


SCTP
4
 SCTP combines the best features of UDP and TCP.

 SCTP is a reliable message oriented protocol.

 It preserves the message boundaries and at the same time


detects lost data, duplicate data, and out-of-order data.

 It also has congestion control and flow control


mechanisms.

Prepared by Dr.Samia Chelloug 26


Iterative Using UDP
5
 An iterative server can process one client request at a time;
it receives a request, processes it, and sends the response
to the requestor before handling another request.

 When the server is handling the request from a client, the


requests from other clients, and even other requests from the
same client, need to be queued at the server site and wait for
the server to be freed.

 The received and queued requests are handled in the first-in,


first-out fashion.

Prepared by Dr.Samia Chelloug 27


Iterative communication using UDP
5
 UDP: no “connection” between client & server
• no handshaking before sending data
• sender explicitly attaches IP destination address and port #
to each packet
• receiver extracts sender IP address and port# from received
packet
transmitted data may be lost or received out-of-order
 Application viewpoint:
• UDP provides unreliable transfer of groups of bytes
(“datagrams”) between client and server

Prepared by Dr.Samia Chelloug 28


Sockets for UDP communication

Prepared by Dr.Samia Chelloug 29


Flow diagram for iterative UDP communication

Prepared by Dr.Samia Chelloug 30


Iterative Using TCP
8
 Although iterative communication using TCP is not very
common, because it is simpler we discuss this type of
communication in this section.

Prepared by Dr.Samia Chelloug 31


Iterative communication using TCP
8
 Client must contact server  When contacted by client,
 Server process must first be server TCP creates new socket
running for server process to
 Server must have created communicate with that
socket (door) that welcomes particular client
client’s contact allows server to talk with

multiple clients
Client contacts the server source port numbers used to
by: distinguish clients
 Creating TCP socket,
specifying IP address, port Application viewpoint:
number of server process TCP provides reliable, in-order
 When client creates socket: byte-stream transfer (“pipe”)
client TCP establishes between client and server
connection to server TCP
Prepared by Dr.Samia Chelloug 32
Sockets used in TCP communication

2
Create

5
Create

Prepared by Dr.Samia Chelloug 33


Flow diagram for iterative TCP communication

Prepared by Dr.Samia Chelloug 34


THANK
YOU

You might also like