Np unit1
-
Upload
vamsitricks -
Category
Documents
-
view
120 -
download
10
description
Transcript of Np unit1
Inter process communication (IPC) between processes on different hosts over the network.
IPC has Two Forms :
◦ Local IPC◦ Network IPC
◦ Local IPC Communication between local processes (on same
host) PIPE FIFO System V IPC
Message queues Semaphores Shared Memory
◦ Network IPC Communication between processes on different host socket
Pipe
FIFO
Message Queues
Shared Memory
Semaphores
Sockets
Client / Server
Client ServerCommunication link
Figure 1.1 Network application : client and server
Client
Client
Client
Server...
...
Figure 1.2 Server handling multiple clients at the same time.
Example : Client and Server on the same Ethernet communication using TCP
WebClient
TCP
IP
Ethernetdriver
Webserver
TCP
IP
Ethernetdriver
TCP protocol
Application protocol
IP protocol
Ethernet protocol
Actual flow between client and server
Ethernet
Application layer
transport layer
network layer
datalink layer
User
process
Protocol stack
within kernel
Figure 1.3 Client and server on the same Ethernet communicating using TCP
Example : Client and Server on different LANs connected through WAN.
clientapplication
Hostwith
TCP/IP
serverapplication
Hostwith
TCP/IP
router
router router router
router
router
LAN LAN
WAN
Figure 1.4 Client and server on different LANs connected through a WAN
First, the upper three layers handle all the details of the application and The lower four layers handle all the communication details.
Second, the upper three layers is called a user process while the lower four layers are provided as part of the operating system kernel.
Application
SessionPresentation
TransportNetworkDatalinkPhysical
7
6
5
4
3
2
1
OSI Model
Application
TCP | | UDPIPv4, IPv6
Device driverand Hardware
Internet protocol suite
SocketsXTI
userprocess
kernel
applicationdetails
communicationdetails
Figure 1.14 Layers on OSI model and Internet protocol suite
POSIX◦ POSIX is an acronym for Portable Operating System Interface.
◦ POSIX is not a single standard, but a family of standards being developed by the Institute for Electrical and Electronics Engineers, Inc., normally called the IEEE.
◦ The POSIX standards have also been adopted as international standards by ISO and the International Electro technical Commission (IEC), called ISO/IEC.
Open group◦ The Open Group was formed in 1996 by the consolidation of the X/Open Company and the Open
Software Foundation.
◦ It is an international association of vendors and end-user customers from industry, government, and academia.
IETF◦ The Internet Engineering Task Force (IETF) is a large, open, international community of network
designers, operators, vendors, and researchers concerned with the evolution of the Internet architecture and the smooth operation of the Internet.
◦ It is open to any interested individual
TCP provides connections between clients and servers (connection oriented protocol).
TCP also provides reliability.
TCP contains algorithms to estimate the round-trip time (RTT) between a client and server dynamically so that it knows how long to wait for an acknowledgment.
TCP also sequences the data by associating a sequence number with every byte that it sends.
TCP provides flow control. TCP always tells its peer exactly how many bytes of data it is willing to accept from the peer at any one time.
TCP connection is full-duplex.
UDP provides a connectionless service, as there need not be any long-term relationship between a UDP client and server.
UDP provides no flow control.
UDP supports multicasting.
UDP is a simple transport-layer protocol.
The application writes a message to a UDP socket, which is then encapsulated in a UDP datagram, which is then further encapsulated as an IP datagram, which is then sent to its destination.
There is no guarantee that a UDP datagram will ever reach its final destination, that order will be preserved across the network, or that datagram arrive only once.
13
TCP UDP
Binding betweenclient and server
Yes (connection-oriented)
No (connection-less)
Data Byte-stream Record
Reliability Yes (ack, time-out, retx)
No
Sequencing Yes No
Flow control Yes (window-based)
No
Full-duplex Yes Yes
The server must be prepared to accept an incoming connection. (By calling socket, bind, and listen )and is called a passive open.
The client issues an active open by calling connect. This causes the client TCP to send a "synchronize" (SYN) segment, which tells the server the client's initial sequence number for the data that the client will send on the connection.
The server must acknowledge (ACK) the client's SYN and the server must also send its own SYN containing the initial sequence number for the data that the server will send on the connection. The server sends its SYN and the ACK of the client's SYN in a single segment.
The client must acknowledge the server's SYN.
TCP Connection: Establishment
Three-way handshake
client server
socket connect (blocks)(active open) SYN_SENT
ESTABLISHED connect returns
socket,bind,listenLISTEN(passive open)accept (blocks)
ESTABLISHEDaccept returnsread (blocks)
SYN j
SYN k, ack j+1
ack k+1
SYN_RCVD
TCP options (in SYN): MSS (maximum segment size) option, window scale option (advertized window up to 65535x2^14, 1GB), timestamp option (the latter two: long fat pipe options)
One application calls close first, and we say that this end performs the active close. This end's TCP sends a FIN segment, which means it is finished sending data.
The other end that receives the FIN performs the passive close. The received FIN is acknowledged by TCP. The receipt of the FIN is also passed to the application as an end-of-file, since the receipt of the FIN means the application will not receive any additional data on the connection.
Sometime later, the application that received the end-of-file will close its socket. This causes its TCP to send a FIN.
The TCP on the system that receives this final FIN acknowledges the FIN.
TCP Connection: Termination
Four-way handshakeclient server
ack n+1
FIN m
ack m+1
FIN n
close(active close) FIN_WAIT_1
CLOSE_WAIT (passive close)read returns 0
closeLAST_ACK
CLOSED
FIN_WAIT_2
TIME_WAIT
CLOSED
1~4 mins
TIME_WAIT to allow old duplicate segment to expire for reliable termination(the end performing active close might have to retx the final ACK)
C LO S E D
L IS TE N
E S TAB L IS H E D
S Y N _R C VD S Y N _S E N T
C LO S E _WAIT
C LO S IN G LAS T_AC KF IN _WAIT_1
TIM E _WAITF IN _WAIT_2
starting po int
pass ive open
data transfer state
ac tive open
simultaneous c lose
2M S L timeout
pass ive c lose
appl: pass ive opensend: < nothing>
recv: S YN
send: S YN , AC Ks imultaneous open
recv: F INsend: AC K
recv: AC K
send: < nothing>
appl: c loseor timeout
recv : c losesend: F IN
recv : AC Ksend: < nothing>
recv : F INsend: AC K
recv : F INsend: AC K
recv : AC Ksend: < nothing>
ac tive c lose
F igure 2.4 TC P s tate trans ition diagram
- Statetransitiondiagram
UNIX Network Programming 19
Watching the Packets
c lient serversocket,bind,listenLISTEN(passive open)accpet(b loc ks)
socketconnect(b loc ks)
(ac tion open) S YN _S E N T
ESTABLISHEDconnect returns
ESTABLISHEDaccept returnsread(b loc ks)
F igure 2.5 P ac ket exc hange fo r TC P c onnec tion
closeLAST_AC K
close(ac tive c lose)
F IN _WAIT_1C LO S E _WAIT(pass ive c lose)read re turns 0
writeread(b locks)
read re turns
read re turns
<client forms request>
<server processes request>
writeread(b locks)
C LO SED
FIN_W AIT_2
T IM E_W AIT
The end that performs the active close is the end that remains in the TIME_WAIT state=>because that end is the one that might have to retransmit the final ACK.
The MSL is the maximum amount of time that any given IP datagram can live in a network.
There are two reason for TIME_WAIT state
◦ to implement TCP’s full-duplex connection termination reliably
◦ to allow old duplicate segments to expire in the network
TCP,UDP define a group of well known port to identify well known services.
Clients normally use ephemeral ports, that is short lived ports.
These port no are normally assigned automatically by the transport protocol to the client.
IANA maintains list of port numbers assignments.1. Well-known ports: 0 to 1023controlled and assigned by
IANA.2. Registered ports: 1024 to 49151. These are not controlled
by IANA.3. Dynamic or private port:49152 to 65,535
The socket pair for a TCP connection is the four-tuple that defines the two endpoints of the connection: ◦ local IP address, local port, foreign IP, Foreign
port. A socket pair uniquely identifies every TCP
connection on a network. Two values that identify each endpoint, an
IP address and a port number are often called a socket.
server c lient
(* .21, * . * )
206.62.226.35206.62.226.66 198.69.10.2
{198.69.10.2.1500,206.62.226.35.21}
lis tening socket
connection request to
206.62.226.35, port 21
F igure 2.8 C onnec tion request from c lient to server
server c lient
(* .21, * . * )
206.62.226.35206.62.226.66 198.69.10.2
{198.69.10.2.1500,206.62.226.35.21}
lis tening socket
connection
F igure 2.9 C oncurrent server has child handle c lient
server(child)
{206.62.226.35.21,198.69.10.2.1500}
connected socket
fork
server c lient1
(* .21, * . * )
206.62.226.35206.62.226.66 198.69.10.2
{198.69.10.2.1500,206.62.226.35.21}
lis tening socket
connection
F igure 2.10 S econd c lient connec tion with same server
server(child1)
{206.62.226.35.21,198.69.10.2.1500}
connected socket
fork
server(child2)
{206.62.226.35.21,198.69.10.2.1501}
connected socket
c lient2
{198.69.10.2.1500,206.62.226.35.21}
connection
Maximum size of IPv4 => 65535 byte Maximum size of IPv6 => 65575 byte MTU(maximum transmit unit) => fragmentation The smallest MTU in the path between two hosts is
called the path MTU Today, the Ethernet MTU of 1,500 bytes is often
the path MTU. The path MTU need not be the same in both directions between any two hosts
When an IP datagram is to be sent out an interface, if the size of the datagram exceeds the link MTU, fragmentation is performed by both IPv4 and IPv6.
The fragments are not normally reassembled until they reach the final destination.
IPv4 hosts perform fragmentation on datagrams that they generate and IPv4 routers perform fragmentation on datagrams that they forward.
But with IPv6, only hosts perform fragmentation on datagrams that they generate; IPv6 routers do not fragment datagrams that they are forwarding.
DF (don’t fragment)
◦ A router that receives an IPv4 datagram with the DF bit set whose size exceeds the outgoing link's MTU generates an ICMPv4 "destination unreachable, fragmentation needed but DF bit set" error message
◦ TCP decreases the amount of data it sends per datagram and retransmits.
◦ TCP has a maximum segment size (MSS) that announces to the peer TCP the maximum amount of TCP data that the peer can send per segment. The goal of the MSS is to tell the peer the actual value of the reassembly buffer size and to try to avoid fragmentation. The MSS is often set to the interface MTU minus the fixed sizes of the IP and TCP headers.
Notice: TCP and UDP port number is same.