Communication and Networks Assignment

profileTubekbay001
0_Lesson3InternetNetworking.pptx

Communications and Networks

version 1.0

Diploma in Information Technology

Copyright © 2020 by Singapore Institute of Management Pte Ltd. All rights reserved.

Lesson 3: Internet Networking

1

Lesson 3 Learning Outcomes

Distinguish between connectionless and connection-oriented communication

Distinguish the role of server and client in a client-server model

Identify the characteristics of a server and client

Understand how multiple clients and servers can be used to work together

Define concurrent servers

Describe the motivation for peer-to-peer interaction on the Internet

2

Lesson 3 Learning Outcomes

Describe what is the purpose of sockets

Identify the key functions of sockets

3

Lesson 3 Outline

Communication Paradigms

Client Server Model

Network Programming

4

Internet Rich Diversity of Services

None of the services is part of underlying communication infrastructure

Internet provides a general-purpose mechanism where:

Individual services are supplied by application programs that run on computers attached to the Internet

5

Programming on the Internet

Possible to create Internet applications without knowing how networks operate

However, understanding network protocols and technologies allows them to write efficient and reliable code

Enables applications to scale across many sites

6

Internet Communication Paradigms

Source: Douglas, C (2016) Computer Networks and Internets

Stream Paradigms Message Paradigms
Connection-oriented Connectionless
1-to-1 communication Many-to-many communication
Sequence of individual bytes Sequence of individual messages
Arbitrary length transfer Each message limited to 64 Kbytes
Used by most applications Used for multimedia applications
Built on TCP protocol Built on UDP protocol

7

Stream Transport

Stream: sequence of bytes flows from one application program to another

Without attaching meaning to the bytes and without inserting boundaries

Two streams between pair of communicating applications, one in each direction

Accepts input from one, delivers to the other

Sending application can choose to generate one byte at a time or can generate blocks of bytes

Network can choose to combine smaller blocks into one large block or divide a large block into smaller blocks

8

Message Transport

Message: the network accepts and delivers messages

Each message delivered corresponds to message transmitted

Never delivers part of a message, nor does it join multiple messages together

Sender places exactly n bytes in outgoing message

Receiver receives n bytes in the incoming message

9

Message Transport Types

Unicast

a message can be sent from an application on one computer directly to an application on another, 1-to-1

Multicast

a message can be multicast to some of the computers on a network, 1-to-many

Broadcast

a message can be broadcast to all computers on a given network, 1-to-all

10

Message Transport Reliability

Message transport is unreliable

Unreliable means no guarantee:

Lost: never delivered

Duplication: more than one copy arrives

Ordered: out-of-order

Programmers must ensure the application operates correctly even if packets are lost or reordered

11

Message vs Stream

Most applications require delivery guarantees

Use stream services

Programmers tend to use stream service except in special situations

E.g. video, where multicast is needed, the application provides support to handle packet reordering and loss

12

Connection-oriented Communication

Stream service is connection-oriented:

Applications must request connection be created

Once established, connection allows applications to send data in either direction

Finally, when communication finishes, the applications request the connection be terminated

Source: Douglas, C (2016) Computer Networks and Internets

Algorithm for Stream Paradigm

13

Practice 3.1

Distinguish between stream and message communication with TWO differences

Describe the THREE steps in a stream paradigm communication algorithm

14

Lesson 3 Outline

Communication Paradigms

Client Server Model

Network Programming

15

Client-server Model

16

How can a pair of applications that run on two independent computers coordinate to guarantee that they request a connection at the same time?

The answer lies in a form of interaction known as the client-server model

A server starts first and awaits contact

A client starts second and initiates the connection

Application programs known as clients and servers handle all services in the Internet

16

Client-Server Differences

Source: Douglas, C (2016) Computer Networks and Internets

Server Application Client Application
Starts first Starts second
Does not need to know which client will contact it Must know which server to contact
Waits passively and arbitrarily long for contact from a client Initiates a contact whenever communication is needed
Communicates with a client by both sending and receiving data Communicates with a sever by sending and receiving data
Stays running after servicing one client and waits for another May terminate after interacting with a server

17

Characteristics of Client Software

A client software:

Invoked directly by a user, executes only for one session

Runs locally on a user's personal computer

Actively initiates contact with a server

Can access multiple services as needed, but usually contacts one remote server at a time

Does not require especially powerful computer hardware

18

Characteristics of Server Software

A server software:

A special-purpose, privileged program

Dedicated to providing one service that can handle multiple remote clients at the same time

Is invoked automatically when a system boots, and continues to execute through many sessions

Runs on a large, powerful computer

Waits passively for contact from arbitrary remote clients

Accepts contact from arbitrary clients, but offers a single service

Requires powerful hardware and a sophisticated OS

19

Server Programs & Server-class Computers

Server: a program that waits passively for communication

Not to the computer on which it executes

When a computer is running server program(s), it is sometimes called a server

Hardware vendors contribute to the confusion as they classify powerful machines as servers

20

Server Programs and Server-class Computers

Source: Douglas, C (2016) Computer Networks and Internets

21

Requests & Response

Once contact is established, two-way communication is possible

From a client to a server

From a server to a client

A client can send a series of requests

The server issues a series of responses

A database client might allow a user to look up more than one item at a time

22

One Computer, Multiple Servers

A computer that operate multiple servers is useful

Hardware can be shared

Has lower system administration overhead than multiple computer systems

Demand for a server is often sporadic:

Server can remain idle for long periods of time and does not use the CPU while waiting for a request to arrive

If demand is low, consolidating servers can reduce cost without reducing performance

23

Multiple Clients & Servers

A computer can run:

A single client

A single server

Multiple copies of a client that contact a given server

Multiple clients that each contact a server

Multiple servers, each for a service

24

Multiple Clients Benefits

A computer with multiple clients is useful as services can be accessed simultaneously

For example, a user can have three (3) windows open simultaneously running three (3) applications:

Email

Chat service

Web browser

25

Server Identification

Internet protocols divide identification to 2 pieces:

Identifier for the computer on which a server runs

Identifier for a service on the computer

Each computer in the Internet is assigned a unique 32-bit identifier known as an Internet Protocol (IP) address

192.168.1.0

It is an Internet layer address

26

DNS for Server Identification

A client must specify the server’s IP address

To make server identification easy, each computer is assigned a name and the Domain Name System (DNS)

Thus, a user specifies a name such as www.cisco.com rather than an integer address

27

Server Demultiplexing

Each service available in the Internet is assigned a unique 16-bit identifier known as port number

Email: 25, HTTP: 80

It is a Transport layer address

When a server begins, it registers with OS by specifying the port number for its service

A client contacts a server to request service

the request contains a port number

A request arrives at a server

software uses port number to determine which application on the server will handle request

28

Server Identification & Demultiplexing

Source: Douglas, C (2016) Computer Networks and Internets

29

Server Circular Dependencies

Circular dependencies: a server for one service can act as client for another

Before it can fill in a web page, a web server may need to become a client of a database

A server may also become the client of a security service to verify a client is allowed access to the service

Database

Server

Web Page Server

User

Client of

Client of

30

Concurrent Servers

Most servers are concurrent

A server uses more than one thread of control

Concurrent execution depends on the OS being used and the code is divided into 2 pieces

Main program (thread)

Handler

Main thread accepts contact from client and creates a thread of control for the client

Each thread of control interacts with a single client and runs the handler code

31

Running Concurrent Servers

After handling one client the thread terminates

Main thread keeps server alive after creating a thread to handle a request

If N clients are simultaneously using a concurrent server, N+1 threads will be running:

N threads for each client

+1 main thread to wait for additional requests

Main Thread

User

User

Web Page Server

Handler 1

Handler 2

32

Server Bottlenecks

If a single server provides a given service

the network connection between the server and the Internet can become a bottleneck

User

Internet

Server

User

User

Bottleneck

33

Peer-to-Peer Interactions

One way to avoid a bottleneck forms the basis of file sharing known as a peer-to-peer (P2P) architecture

Data is distributed equally among a set of N servers

Each request is sent to the appropriate server

Each server only provides 1/N of the data

User

Internet

Server 1 of N

User

1/N traffic

Server 2 of N

34

Practice 3.2

Describe TWO identification methods that Internet Protocols uses to identify servers

Explain what is server circular dependencies and bottleneck.

35

Lesson 3 Outline

Communication Paradigms

Client Server Model

Network Programming

36

What is an API?

Source: https://www.youtube.com/watch?v=s7wmiS2mSXY

37

Socket API

Application Program Interface (API): interface that an application uses to specify communication

Details of an API depend on the OS

de facto standard for software that communicates over the Internet is the socket API

commonly abbreviated sockets

Socket API is available for many OS

Windows, various UNIX, Linux

38

Sockets & Descriptors

Originally developed as part of UNIX OS, the socket API is integrated with I/O

When an application creates a socket, OS returns a small integer descriptor that identifies the socket

Application passes the descriptor as an argument

when it calls functions to perform an operation on the socket such as to transfer data across the network or to receive data

39

Network I/O

In many OS, socket descriptors are integrated with other I/O descriptors

An application can use the read and write operations for socket I/O or I/O to a file

40

Socket Functions

In socket programming an application must specify many details, such as

address, port number, whether the application will act as a client or as a server

To avoid having a single socket function with many parameters, designers of the socket API chose to define many functions

An application creates a socket, and then invokes functions for details

41

Pros & Cons of Socket Approach

Advantage of socket approach is that most functions have three or fewer parameters

Disadvantage is that a programmer must remember to call multiple functions when using sockets

42

Major Functions in Socket API

Source: Douglas, C (2016) Computer Networks and Internets

43

Socket Calls in a Client and Server

This illustrates the sequence of socket calls made by a typical client and server that use a stream connection

In some applications, send and recv are called in the reverse order

Source: Douglas, C (2016) Computer Networks and Internets

44

Client Connection Functions

Clients call connect to establish a connection with a specific server

connect (socket, saddress, saddresslen)

Argument socket is the descriptor of a socket to use for the connection

45

Sockets in Message Paradigm

Socket functions used to send and receive messages are more complicated than stream paradigm because many options are available

A sender can choose whether to store the recipient’s address in the socket and merely send data or to specify the recipient’s address each time a message is transmitted

One function allows a sender to place the address and message in a structure and pass the address of the structure as an argument, and another function allows a sender to pass the address and message as separate arguments

46

Practice 3.3

What is an Application Program Interface (API)?

Discuss one advantage and one disadvantage of using sockets.

47

Reading

Douglas, C. (2016). Computer Networks and Internets, Global Edition (6th ed.). Pearson Education. ISBN: 978-1292061177 Chapter 3

48

End of Lesson

49