Communication and Networks Assignment

profileTubekbay001
0_Lesson4InternetProtocols.pptx

Communications and Networks

version 1.0

Diploma in Information Technology

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

Lesson 4: Internet Protocols

1

Lesson 4 Learning Outcomes

Identify the purpose of the Application-Layer Protocols

Distinguish the two main types of Application-layer protocols

Distinguish between the three key standards of web protocols

Identify the components in a URL

Describe the four main HTTP request type functions

2

Lesson 4 Learning Outcomes

Describe the components in HTTP requests

Describe the architecture of a Web browser

3

Lesson 4 Outline

Application-layer Protocol

Web Protocols

Caching in Browser

4

Application-layer Programming

When programmer creates network applications, the programmer specifies some details:

Syntax and semantics of messages to be exchanged

Client or server initiates interaction

Error Control

When to terminate communication

5

Application-layer Protocol

Two broad types of application-layer protocols that depend on intended use:

Private communication

Standardised service

Size of a protocol specification depends on the complexity of the service

6

Private Communication

Private communication: communicate over the Internet with intention for private use

Straightforward interaction: code can be written without formal protocol specification

7

Standardised Service

Standardised service: expectation that many programmers will create server software to offer the service or client software to access the service

Must be documented independent of implementation

Specification must be precise and unambiguous

8

Representation and Transfer

Application-layer protocols specify two aspects of interaction:

Representation

Transfer

Aspect Description
Data Representation Syntax of data items that are exchanged, specific form used in transfer, translation of integers, characters and files between computers
Data Transfer Interaction between client and server, message syntax and semantics, valid and invalid exchange error handling, termination of interaction

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

9

Web Protocols

World Wide Web (WWW) is the most widely used services on the Internet but the web is complex

Many protocol standards have been devised to specify various aspects and details

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

Standard Description
HyperText Markup Language (HTML) Representation standard to specify the contents and layout of a web page
Uniform Resource Locator (URL) Representation standard to specify the format and meaning of web page identifiers
HyperText Transfer Protocol (HTTP) Transfer protocol to specify how a browser interacts with a web server to transfer data

10

Practice 4.1

For each of the following scenario, suggest the appropriate web protocols to use.

To specify how a web page look like

To specify the address of the web page

To specify how data are transferred to a web server

11

Lesson 4 Outline

Application-layer Protocol

Web Protocols

HyperText Markup Langauge (HTML)

Uniform Resource Locator (URL)

HyperText Transfer Protocol (HTTP)

Caching in Browser

12

HTML Representation

HTML specifies the syntax of a web page

HTML allows complex web page that contains graphics, audio, video text

Hypermedia rather of hypertext

13

HTML Characteristics

Uses textual representation

Describes pages that contain multimedia

Follows a declarative rather than procedural paradigm

Provides markup specifications instead of formatting

Permits embedded hyperlink in an arbitrary object

Allows a document to include metadata

14

Declarative Markup Language

Declarative: allows one to specify what is to be done, not how to do it

Markup language: gives general guidelines for display and does not include detailed formatting instructions

Allows a page to specify level of importance of a heading

Does not require author to specify the exact font, typeface, point size, or spacing for the heading

15

HTML Extension

HTML Extensions: created to allow the specification of an exact font, typeface, point size, and formatting.

A browser chooses all display details

16

Importance of Markup Language

Two advantages:

Allows a browser to adapt the page to the underlying display hardware

Web page can be formatted for a high-resolution or low-resolution display

Large screen or small like smartphone

17

HTML Tags

To specify markup, HTML uses tags embedded in the document

Tags provide structure as well as formatting

Example: IMG tag to encode a reference to an external image

Additional parameters can be added to specify the alignment of the figure with surrounding text

18

HTML Tags Properties

Tags control all display

White space (extra lines or blank characters) can be inserted at any point in the HTML document

Without effect on the formatted version that a browser displays

Case insensitive: does not distinguish between uppercase and lowercase letters

19

HTML Example

Code Output
<html> <head> <title> text that forms the document title </title> </head> <body> body of the document appears here </body> </html>
Here is an icon of a house. <IMG SRC="house_icon.gif" ALIGN=middle>

Here is an icon of a house

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

20

Practice 4.2

Why is HTML consider as a declarative language?

2. Why is HTML consider as a Markup language?

21

Lesson 4 Outline

Application-layer Protocol

Web Protocols

HyperText Markup Langauge (HTML)

Uniform Resource Locator (URL)

HyperText Transfer Protocol (HTTP)

Caching in Browser

22

URL Components

URL: syntactic form used by the Web to specify a web page

protocol://host_name:port/document?parameters

protocol: protocol used to access the document (HTTP,FTP)

host_name: domain name of the computer on which the document resides

port: port number that server is listening (default 80 for HTTP)

document: name of the document

%parameters: options for the page

Example: https://www.google.com/search?q=hello

Optional

Optional

23

Reason for URL

URL contains information that browsers need to retrieve a page

Browser uses the separator characters like “:”, “/”, and “%” to identify the components of a URL

Host name and protocol port are used to form a connection to the server on which the page resides

Browser uses the document and parameters to request a page

24

URL Hyperlinks

User can omit many of the parts of URL

protocol (http is assumed)

port (80 is assumed)

document name (index.html is assumed)

parameters (none are assumed)

25

Lesson 4 Outline

Application-layer Protocol

Web Protocols

HyperText Markup Langauge (HTML)

Uniform Resource Locator (URL)

HyperText Transfer Protocol (HTTP)

Caching in Browser

26

HTTP Transfer Protocol

HTTP: primary transfer protocol that a browser uses to interact with a web server

A browser is a client that extracts a server name from a URL and contacts the server

Most URLs contain an explicit reference of “http://” or omit the protocol (HTTP is assumed)

27

HTTP Characteristic

Uses textual control messages

Transfers binary data files

Can download or upload data

Incorporates caching

28

HTTP Methods

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

29

HTTP Request Type

Once connection is established, client sends an HTTP request to server

Request Description
GET Requests a document; server responds by sending status information followed by a copy of the document
HEAD Request status information; server responds by sending status information but does not send a copy of the document
POST Sends data to a server; the server appends the data to a specified item i.e. a message appended to a list
PUT Sends data to a server; the server uses the data to completely replace the specified item i.e. overwrites the previous data

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

30

HTTP GET Request

Most common form of interaction begins with client requesting a page from the server

Client sends a GET request over

Server responds by sending a header, a blank line, and the requested document

Source: Bing, licensed under CC BY-SA

31

HTTP GET Request Form

GET /item version CRLF

Item: the URL for the item being requested,

Version: version of the protocol (HTTP/1.0 or HTTP/1.1)

CRLF: two ASCII characters, carriage return and linefeed

to signify the end of a line of text

Version information is important in HTTP

allows protocol to change but remains backward compatible

client sends version information that allows server to choose highest version that both understand

32

HTTP Response Header

HTTP/1.0 status_code status_string CRLF

Server: server_identification CRLF

Last-Modified: date_document_was_changed CRLF

Content-Length: datasize CRLF

Content-Type: document_type CRLF

CRLF

Source: Bing, licensed under CC BY-SA

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

33

HTTP Status Code

First line of a response header contains a status code that tells the browser whether the server handled the request

If the request is not available, status code pinpoints the problem

Status Code Message Description
200 Ok The request is OK
400 Bad Request Server did not understand the request
404 Not Found Server cannot find the requested page
403 Forbidden Access is forbidden to the requested page

34

HTTP GET Response Example

Sample output from an Apache web server

Item requested is a text file containing 16 characters

“This is a test.” plus a NEWLINE character

GET request specifies HTTP version 1.0 but the server runs version 1.1

Server returns 9 lines of header, a blank line, and the contents of the file

35

HTTP POST Request

Another common HTTP request is POST

Mainly used to send data to server

POST: Parameters is sent in body of the HTTP request

POST /test/demo.php HTTP/1.1

Host: host_name

name1=value1&name2=value2

GET: Parameters is piggybacked on the URL

/test/demo.php?name1=value1&name2=value2

36

HTTP POST vs GET

HTTP POST HTTP GET
Never cached Can be cached
Do not remain in browser history Remain in the browser history
Cannot be bookmarked Can be bookmarked
No restrictions on data length Have length restrictions
Should not be used for sensitive data
Should only be used to request data not modify

37

HTTP PUT Request

Similar to POST request

But PUT is meant to replace data in server

PUT: Parameters is sent in body of the HTTP request

38

HTTP HEAD Request

Similar to GET request

For the same GET request, if HEAD is used, the headers are returned without the body

Useful to check what a GET will return before making the request

i.e. before downloading a large file

39

Practice 4.3

Distinguish between HTTP GET and HTTP POST functions. Detailing at least TWO differences.

40

Lesson 4 Outline

Application-layer Protocol

Web Protocols

Caching in Browser

41

Browser Structure

Browser structure is complex

A browser must understand HTTP and:

Contain client code for each protocols used

Must know how to interact with a server

How to interpret responses from server

How to access FTP service

Ability to cache frequently visited web pages

42

Browser Architecture

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

43

Caching in Browser

Caching is an important optimization for web access

users tend to visit the same web sites repeatedly

Much of the content on web consists of large images

Graphics Image Format (GIF)

Joint Picture Encoding Group (JPEG)

Such images often contain backgrounds or banners that do not change frequently

44

Cached Copy

Browser can reduce download times significantly

by saving a copy of image in a cache on user's disk and using cached copy

What happens if the document on server is modified after browser cache a copy?

How can a browser tell whether its cached copy is stale?

45

Updating Cache

When browser contacts server, response header shows the time document was modified

Browser saves Last-Modified date along with the cached copy

Browser makes HEAD request to the server

Server’s Last-Modified vs Cache’s Last-Modified

If cached version is stale, the browser downloads the new version

46

Updating Cache Algorithm

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

47

Cache Header

HTTP allows web site to include No-cache header that specifies a given item should not be cached

Browsers do not cache small items

Time to download the item with a GET request is approximately same as time to make a HEAD request

Keeping many small items in cache increases cache lookup times

48

Reading

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

49

End of Lesson

50