0% found this document useful (0 votes)
6 views27 pages

Unit 3-22ECG61 CNA Dr. Sunil S. Harakannanavar

Uploaded by

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

Unit 3-22ECG61 CNA Dr. Sunil S. Harakannanavar

Uploaded by

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

COMPUTER NETWORKS AND

APPLICATIONS (22ECG61)

Unit-3
Application Programming
TextBook - Data Communications and Networking, 5/e By Behrouz A
Forouzan, published by McGraw-Hill

Presented By

Dr. Sunil S. Harakannanavar


Associate Professor
Department of Electronics and Communication Engineering
Nitte Meenakshi Institute of Technology,
4/10/2025 Yelahanka, Bengaluru-560064 1
Contents
Application Programming Interface
Using Services of the Transport Layer
Iterative Communication Using UDP
Iterative Communication Using TCP
WWW and HTTP Architecture - Web client, server, URL, and web documents.
Non-persistent vs persistent connections, message format, request message, response
message, conditional request, cookies, caching and proxy server, HTTP security.

TextBook - Data Communications and Networking, 5/e by Behrouz A


Forouzan, published by McGraw-Hill
4/10/2025 2
Course Outcome

UNDERSTAND THE ANALYZE THE PRINCIPLES OF APPLY THE CONCEPTS OF ANALYZE THE PROTOCOLS OF UNDERSTAND THE
FUNDAMENTALS OF DATA TRANSPORT LAYER WWW AND HTTP FOR CLIENT REAL TIME APPLICATIONS OF FUNDAMENTALS OF
COMMUNICATIONS AND PROTOCOLS. SERVER PROGRAMMING. MULTIMEDIA. NETWORK, TRANSPORT, AND
NETWORKING. APPLICATION LAYER SECURITY.

4/10/2025 3
Course Outline
Application Programming Interface, Using Services of the Transport Layer, Iterative
Communication Using UDP, Iterative Communication Using TCP.
WWW and HTTP Architecture - Web client, server, URL, and web documents.
Non-persistent vs persistent connections, message format, request message, response
message, conditional request, cookies, caching and proxy server, HTTP security.

Textbook Sections: 25.2, 26.1.1, 26.1.2

TextBook - Data Communications and Networking, 5/e by Behrouz A


Forouzan, published by McGraw-Hill
4/10/2025 4
CLIENT-SERVER PROGRAMMING

▪ Process Communication:
• Communication occurs between two running application programs
(called processes): a client and a server.
▪ Client:
• The initiator of the communication.
• Sends a request to the server.
• Has a finite lifetime – runs when needed, performs its task, then stops.
▪ Server:
• Waits passively for a request.
• Processes the client’s request and sends back a response.
• Has an infinite lifetime – it should run continuously, ready to serve
clients at any time.
▪ Startup Sequence:
• The server must be started before the client to ensure it can receive
the request when the client sends it.
▪ System Setup:
• The client and server can be on different machines connected via a
network (e.g., Internet, LAN).
• They communicate using application-layer protocols like HTTP, FTP,
SMTP, etc.
4/10/2025 5
Real-World Example

▪ You open a browser (client) and type a URL.


▪ The browser sends an HTTP request to a web server.
▪ The server processes the request and sends back the web page.
▪ You view the page, and the client can close afterward, while the server continues running for other
requests.

4/10/2025 6
Application Programming Interface (API)

An Application Programming Interface (API) is a set of instructions that allows an application


process (running at the application layer) to communicate with the operating system, particularly
the lower four layers of the TCP/IP protocol suite.

Purpose of API in Networking:


▪ Enables a client process to open a connection, send and receive data, and close the
connection.
▪ Provides communication capabilities between two processes, such as a client and a server.

4/10/2025 7
Application Programming Interface (API)

Role in the TCP/IP Model:


▪ Acts as the interface between the application layer and the lower four layers (transport,
network, data link, physical) of the TCP/IP protocol stack, which are implemented in the operating
system.

Common Communication APIs:


Several APIs are available for inter-process communication over networks, including:
▪ Socket Interface (most common)
▪ Transport Layer Interface (TLI)
▪ Stream APIs

Socket Interface: Treats network communication as reading from and writing to a source/sink
(like files or input/output devices).

4/10/2025 8
Sockets

▪ A socket is an endpoint for


communication between two machines
(or processes) over a network.
▪ It enables a program to send and
receive data just like reading/writing
from a file.
▪ In essence, a socket is a software
object that connects the application
layer with the transport layer (like TCP
or UDP).

4/10/2025 9
Position of Socket interface

Advantages of Using Socket API:


▪ Makes network communication easier
and more familiar for developers.
▪ Promotes code reuse by allowing the
same I/O functions used for
files/devices to be used for network
sockets.

4/10/2025 10
Sockets

How Sockets Work: Client-Server Model Server Side:


Client Side: 1.Create a socket.
1.Create a socket. 2.Bind it to an IP address and port.
2.Connect to the server’s IP address and port. 3.Listen for incoming connections.
3.Send and receive data. 4.Accept connections.
4.Close the socket. 5.Receive and send data.

Why important
▪ Allow real-time communication over a network.
▪ Enable inter-process communication (even across the internet).
▪ Core building block for networked applications (web browsers, email, chat apps).

4/10/2025 11
Sockets

Allows processes to use networking in


the same way they interact with other
input/output devices (like keyboard,
files, monitor, etc.) through standard
programming instructions.

4/10/2025 12
Sockets

Basic Components of a Socket


Each socket is defined by a combination Types Protocol Use Case
of:
Reliable communication (e.g.,
▪ IP address (identifies the host) Stream Socket TCP
HTTP, FTP)
▪ Port number (identifies the specific
Fast, connectionless (e.g., DNS,
process or service) Datagram Socket UDP
VoIP)
This combination is known as a socket
address. For custom protocols (e.g.,
Raw Socket IP layer
network tools)

4/10/2025 13
Sockets (Process to Process Communication)

4/10/2025 14
Sockets Address

A socket address is a unique identifier used for communication between two processes over a
network in the client-server model.

IP Address Identifies the host device

Port Number Identifies the specific app

4/10/2025 15
Using Services of the Transport Layer

▪ The Transport Layer provides end-to-end communication between processes on different hosts.
▪ It ensures reliable or unreliable delivery of data, depending on the protocol used (e.g., TCP or UDP).

Service Description
Process-to-Process Delivery Sends data directly to the correct application using port numbers.

Multiplexing/Demultiplexing Allows multiple applications to use the network simultaneously.


Services Provided to the
For protocols like TCP, handles the three-way handshake and clean
Connection Establishment and Termination Application Layer
disconnect.

Error Control Ensures that data is received accurately and in order (TCP).

Flow Control Prevents the sender from overwhelming the receiver.

Congestion Control Helps avoid overwhelming the network (mainly with TCP).

4/10/2025 16
How application layer uses it?

When an application (like a browser or email client) sends data, it hands it off to the Transport Layer.

The transport layer:


▪ Encapsulates the data into segments.
▪ Adds headers (with source/destination port numbers, sequence numbers, etc.).
▪ Passes it down to the Network Layer.

4/10/2025 17
The Application Layer relies on the Transport Layer to:

▪ Route messages to the correct process using port numbers,

▪ Ensure data is delivered reliably (TCP) or quickly (UDP),

▪ And manage communication sessions between sender and receiver.

4/10/2025 18
Iterative Communication Using UDP
▪ Single Client at a Time (Iterative Model):
▪ In iterative communication, the server handles one client request at a time, processes it,
sends a response, and then moves on to the next request.
▪ Unlike concurrent servers, it does not create a new process/thread for each client.
▪ Connectionless Protocol (UDP):
▪ UDP is used as the transport protocol, which is connectionless, meaning there is no
handshake or persistent connection between client and server.
▪ Each message is treated independently, making the communication faster but less reliable.
▪ Lightweight and Efficient:
▪ Suitable for simple, fast services (e.g., DNS lookup, time service).
▪ The server uses a single socket to receive a datagram from a client, processes it, and sends
back a reply — all using the same thread.
4/10/2025 19
Sockets Used for UDP

▪ Datagram Socket (SOCK_DGRAM):


UDP uses datagram sockets, which are created using
the SOCK_DGRAM type. These sockets support
connectionless communication.
▪ No Connection Setup Required:
Unlike TCP, UDP sockets do not require a connection
to be established before sending or receiving data.
▪ Unreliable but Fast:
UDP sockets do not guarantee delivery, ordering, or
error checking.
▪ One Socket for All Clients:
A UDP server typically uses a single socket to serve
multiple clients.

4/10/2025 20
Flow diagram for
iterative UDP
communication

4/10/2025 21
4/10/2025 22
Iterative Communication Using TCP

▪ Reliable, ordered, and connection-oriented.

▪ One client at a time: new connections wait until the current one

finishes.

▪ Easier to build but not ideal for scalable or high-load applications.

4/10/2025 23
Sockets used in TCP Communication

4/10/2025 24
Iterative TCP
Communication

4/10/2025 25
4/10/2025 26
Thank You

4/10/2025 27

You might also like