16
資 資 Lee 3-1> Application Layer and Client-Server Model A3

資 管 Lee Application Layer and Client-Server Model A3

Embed Size (px)

Citation preview

Page 1: 資 管 Lee Application Layer and Client-Server Model A3

資 管 Lee

<A3-1>

Application Layerand Client-Server Model

A3

Page 2: 資 管 Lee Application Layer and Client-Server Model A3

資 管 Lee

<A3-2>

Application Layer, BOOTP, and DHCP

Application Layer in TCP/IP is equivalent to the combined session, presentation, and application layers of the OSI model.

ICMP

IPARP

RARP

TCP UDPIGMP

SMTP

FTP

TFTP

DNS

SNMP

BOOTP

Applicationlayer

Transportlayer

Networklayer

Data linklayer

Physicallayer

Underlying LAN or WANtechnology

Page 3: 資 管 Lee Application Layer and Client-Server Model A3

資 管 Lee

<A3-3> 資 管

Model

Client

Server

Client

Client

Questions:1. Both application programs be

able to request services and provide services ?

2. An application program provide services only to one specific ap.?

3. When should an application program be running?

4. Only one universal application program that can provide any type of service a user wants?

Page 4: 資 管 Lee Application Layer and Client-Server Model A3

資 管 Lee

<A3-4> 資 管

Concurrency in server types

Server

Server types1. Connectionless iterative2. Connectionless concurrency3. Connection-oriented iterative4. Connection-oriented concurrency

Client

UDP

Ephemeralport

UDP

Client

UDP

Ephemeralport

Client

UDP

Ephemeralport

One client at a time

Connectionless iterative

Page 5: 資 管 Lee Application Layer and Client-Server Model A3

資 管 Lee

<A3-5> 資 管

Parentserver

Client

UDP

Ephemeralport

TCP

Client

UDP

Ephemeralport

Client

UDP

Ephemeralport

Well-known port is usedonly for connection establishment

Connection-oriented concurrent sever

childserver

childserver

childserver

Ephemeralport

Page 6: 資 管 Lee Application Layer and Client-Server Model A3

資 管 Lee

<A3-6> 資 管

Program and Processes

64x yData

Instructionpointer

Datapointer

Other information

Process 2(Started later)

12-1x yData

Instructionpointer

Datapointer

Other information

Process 1(Started earlier)

int main(void){/* Declaration */ int x; int y;/* statement */…….…….…….……

Return ();

}

Page 7: 資 管 Lee Application Layer and Client-Server Model A3

資 管 Lee

<A3-7>

Examples of a server program

…….int main(void){……;……; pid_t pod; for (;;) { /* Connection from client

8? pid= fork(); if( pid !=0) { /* code for parent */

}else{ /* code for child */

} }}

For a fork instruction:When fork is called, it returns two values,The returned value available to the parent process is the process is the processid of the created child. The returned value available to the child process is simply 0.

Page 8: 資 管 Lee Application Layer and Client-Server Model A3

資 管 Lee

<A3-8>

Each computer that is attached to a TCP/IP internet must know the following information:◦ Its IP address◦ Its subnet mask◦ The IP address of a router◦ The IP address of a name server

Usually stored in a configuration file and accessed by the computer during the bootstrap process.

Page 9: 資 管 Lee Application Layer and Client-Server Model A3

資 管 Lee

<A3-9>

BOOTP (Bootstrap Protocol)

Op. code: request (1) reply (2)

Hardware type: Ethernet (1)

Hardware length: address (6)

Transaction ID: client tag ID

Server name: contains a null-terminated string consisting of the domain name of the server.

Boot filename: in a reply packet from the server. Full name pathname of the boot file.

Options: additional information (network mask or default router address. Used only in a reply message. The serer uses a number of 99.130.83.99, if present, the next 60 bytes are options.

Operation code Hardware type Hardware length Hop count

Transaction ID

Number of seconds Unused

Client IP address

Your IP address

Server IP address

Gateway IP address

Client hardware address (16bytes)

Server name (optional, 64bytes)

Boot file name (optional, 128 bytes)

options

Page 10: 資 管 Lee Application Layer and Client-Server Model A3

資 管 Lee

<A3-10> 資 管

Option formatDescription Tag Lengt

hValue

Padding 0

Subnet mask 1 4 Subnet mask

Time offset 2 4Time of the day

Default routers 3 variab

leIP addresses

Time servers 4 variab

leIP addresses

DNS servers 6 variable

IP addresses

Print servers 9 variable

IP addresses

Host name 12 variable

DNS name

Boot file size 13 2 Integer

Vendor specific

128~254

variable

Specific information

End of list 255

Tag(0)

TagLength

Value(Variable length)

Tag(255)

Page 11: 資 管 Lee Application Layer and Client-Server Model A3

資 管 Lee

<A3-11> 資 管

Operation

Client Server67

Server67

Server67

Client 68

Client 68

Passiveopen

UDP

UDP

UDP

UDP

UDP

Request

RequestReply

Request DP SP DA SA

SP: Source port (68)DP: Destination port (67)SA: Source address (All 0s)DA: Destination address (All 1s)

Reply DP SP DA SA

SP: Source port (67)DP: Destination port (68)SA: Source address (Server unicast addr.)DA: Destination address (All 1s or client addr.)

Page 12: 資 管 Lee Application Layer and Client-Server Model A3

資 管 Lee

<A3-12>

Operation steps:◦ The BOOTP server uses UDP port number 67 and waits for a

client.◦ The client sends a BOOTP request message to the server. The

message is encapsulated in a UDP user datagram, using the UDP port number 68. the UDP user datagram, in turn, is encapsulated in an IP datagram. The reader may ask how the client can send an IP datagram when it knows neither its own IP address nor the server’s IP address. The client uses all 0s as the source address and all 1s as the destination address.

◦ The server replies to the client with either a broadcast or a unicast message using UDP destination port 68. the unicast reply message is preferred because.

UDP port for a client is well-known port 68 instead of an ephemeral port.

Since the server defines the pathname of a file, client can use TFTP to obtain the rest of the needed information.

Page 13: 資 管 Lee Application Layer and Client-Server Model A3

資 管 Lee

<A3-13>

Dynamic Host Configuration Protocol (DHCP) BOOTP is a static configuration protocol. DHCP provides dynamic configuration. It is an

extension to BOOTP and is backward compatible with BOOTP.

DHCP is also needed when a host move from network to network or is connected and disconnected from a network. Provides temporary IP addresses for a limited period of time.

A DHCP server has two database. The first database statically binds physical addresses with IP addresses. The same type as BOOTP. DHCP has a second database with a pool of available IP addresses. When a DHCP client requests a temporary IP address, the DHCP server goes to the pool of available unused IP address, and assigned an IP address for a negotiable period of time.

Page 14: 資 管 Lee Application Layer and Client-Server Model A3

資 管 Lee

<A3-14>

DHCP packet format

DHCP format is backward compatible with BOOTP.

Except:

Flag. specify a forced broadcast reply.

Options. Several options have been added to the list of options. And up to 312 bytes.

Operation code Hardware type Hardware length Hop count

Transaction ID

Number of seconds F Unused

Client IP address

Your IP address

Server IP address

Gateway IP address

Client hardware address (16bytes)

Server name (optional, 64bytes)

Boot file name (optional, 128 bytes)

options

Page 15: 資 管 Lee Application Layer and Client-Server Model A3

資 管 Lee

<A3-15> 資 管

Option formatDescription Tag Lengt

hValue

Padding 0

Subnet mask 1 4 Subnet mask

Time offset 2 4Time of the day

Default routers 3 variab

leIP addresses

Time servers 4 variab

leIP addresses

DNS servers 6 variable

IP addresses

Print servers 9 variable

IP addresses

Host name 12 variable

DNS name

Boot file size 13 2 Integer

Vendor specific

128~254

variable

Specific information

End of list 255

Tag(0)

TagLength

Value(Variable length)

Tag(255)

Page 16: 資 管 Lee Application Layer and Client-Server Model A3

資 管 Lee

<A3-16> 資 管

Client Server67

Server67Client 68

Passiveopen

UDP

UDP UDPDHCPDISCOVER

Server67Client 68

UDP UDPDHCPOFFER

Server67Client 68

UDP UDPDHCPREQUEST

Server67Client 68

UDP UDPDHCPACK

Server67Client 68

UDP UDPDHCPREQUEST

Before 50 percent of lease time expires

Server67Client 68

UDP UDPDHCPREQUEST

If the server does not respond, the request is repeated.

Server67Client 68

UDP UDPDHCPNACK

If the server responds with a NACK, the client must start all over again.

Server67Client 68

UDP UDPDHCPACK

If the server responds with a ACK, the client has a new lease.

Server67Client 68

UDP UDPDHCPRELEASE

Operation in DHCP:1. The client broadcast a DHCPDISCOVER message.2. DHCPOFFER offer an IP address and also the duration of the lease3. The client chooses one of the offers and sends a

DHCPREQUEST message to the selected server.4. The server responds with a DHCPACK message

and creates the binding between the client physical address and its IP address. Now the client can use the IP address until the lease expires.

5. Before 50 percent of the lease period is reached, the client sends another DHCPREQUEST and asksfor renewal.

6. If the server responds with a DHCPACK, the client has a new lease agreement and can reset its timer.If DHCPNACK is received, the client must stop using the IP address and to step 1.

7. If the server does not respond, the client sends another DHCPREQUEST when the lease time reaches 87.5 percent.