Np unit1


Published on

  • Be the first to comment

  • Be the first to like this

No Downloads
Total views
On SlideShare
From Embeds
Number of Embeds
Embeds 0
No embeds

No notes for slide

Np unit1

  1. 1.  Inter process communication (IPC) between processes on different hosts over the network. IPC has Two Forms : ◦ Local IPC ◦ Network IPC
  2. 2. ◦ 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
  3. 3.  Pipe FIFO Message Queues Shared Memory Semaphores Sockets
  4. 4.  Client / Server Communication link Client Server Figure 1.1 Network application : client and server Client ... Client Server ... Client Figure 1.2 Server handling multiple clients at the same time.
  5. 5.  Example : Client and Server on the same Ethernet communication using TCP User Web Application protocol Web Application process Client server layer TCP protocol TCP TCP transport layer Protocol stack IP IP protocol IP network layer within kernel Ethernet Ethernet protocol Ethernet datalink layer driver driver Actual flow between client and server Ethernet Figure 1.3 Client and server on the same Ethernet communicating using TCP
  6. 6.  Example : Client and Server on different LANs connected through WAN. client server application application Host Host with with TCP/IP TCP/IP LAN LAN router router WAN router router router router Figure 1.4 Client and server on different LANs connected through a WAN
  7. 7. application7 Application details user6 Presentation process Application5 Session Sockets XTI4 Transport TCP | | UDP3 Network IPv4, IPv6 kernel communication2 Datalink Device driver details1 Physical and Hardware OSI Model Internet protocol suite Figure 1.14 Layers on OSI model and Internet protocol suite 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.
  8. 8.  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
  9. 9.  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.
  10. 10.  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.
  11. 11. TCP UDPBinding between Yes (connection- No (connection-client and server oriented) less)Data Byte-stream RecordReliability Yes (ack, time- No out, retx)Sequencing Yes NoFlow control Yes (window- No based)Full-duplex Yes Yes 13
  12. 12.  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 clients initial sequence number for the data that the client will send on the connection. The server must acknowledge (ACK) the clients 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 clients SYN in a single segment. The client must acknowledge the servers SYN.
  13. 13. TCP Connection: Establishment Three-way handshake client server socket,bind,listen socket LISTEN(passive open) connect (blocks) SYN j accept (blocks) (active open) SYN_SENT SYN k, ack j+1 SYN_RCVD ESTABLISHED connect returns ack k+1 ESTABLISHED accept returns read (blocks)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)
  14. 14.  One application calls close first, and we say that this end performs the active close. This ends 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.
  15. 15. TCP Connection: Termination Four-way handshake client server FIN mclose CLOSE_WAIT (passive close)(active close) FIN_WAIT_1 read returns 0 ack m+1 FIN_WAIT_2 close FIN n LAST_ACK TIME_WAIT 1~4 mins ack n+1 CLOSED CLOSED TIME_WAIT to allow old duplicate segment to expire for reliable termination (the end performing active close might have to retx the final ACK)
  16. 16. s ta rtin g p o in t C LO SED a p p l: p a s s iv e o p e n ap s e n d : < n o t h in g > pl :a se ct nd K ive N AC L IS T E N : S N, op SY Y : nd p a s s iv e o p e n en se T ; YN RS : S v: v rec re c re c v : S Y N a p p l: c lo s e SYN _R C VD SYN _SEN T send: SYN , AC K K o r tim e o u t se re s im u lta n e o u s o p e n AC a c tiv e o p e n n d c v: N, :< AC : SY AC K no K cv : th in re nd g> se re c v : F IN E S T A B L IS H E D C L O S E _ W A IT send: AC K d a ta tra n s f e r s ta te e lo s re c v : c lo s e pl :c IN send: F IN ap : F nd - State se re c v : F IN s im u lta n e o u s c lo s e re c v : A C Ktransition F IN _ W A IT _ 1 send: AC K C L O S IN G LA S T_A C K s e n d : < n o th in g >diagram re v: c p a s s iv e c lo s e se F re c v : AC K n d IN , re c v : A C K send: < n o th in g > : A AC s e n d : < n o th in g > CK K re c v : F IN F IN _ W A IT _ 2 T IM E _ W A IT send: AC K 2 M S L tim e o u t a c t iv e c lo s e F ig u re 2 . 4 T C P s t a t e t ra n s it io n d ia g ra m
  17. 17. c lie n t s e rv e r socket,bind,listen socket LISTEN(passive open) c o n n e c t ( b lo c k s ) a c c p e t ( b lo c k s ) ( a c t io n o p e n ) SYN J , m s s = 14 S YN _S EN T 60 Watching SYN K, ac k J + 1 , ms s = 10 24 the Packets ESTABLISHED c o n n e c t re tu rn s a c k K+ 1 <client forms request> ESTABLISHED a c c e pt re tu rn s write r e a d ( b lo c k s ) r e a d ( b lo c k s ) data(re q uest) r e a d re tu rn s <server processes request> write p ly) d ata (re r e a d ( b lo c k s ) uest ac k o f req r e a d re tu rn s ac k o f rep ly close ( a c t iv e c lo s e ) FIN M F IN _ W A IT _ 1 C L O S E _ W A IT ( p a s s iv e c lo s e ) 1 r e a d re tu rn s 0 ac k M + close F IN _ W A IT _ 2 FIN N LA S T _A C K T IM E _ W A IT ac k N + 1 C LO S E D F ig u re 2 . 5 P a c k e t e x c h a n g e f o r T C P c o n n e c tio n UNIX Network Programming 19
  18. 18.  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
  19. 19.  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
  20. 20.  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.
  21. 21. c o n n e c t io n re q u e s t to s e rv e r c lie n t 2 0 6 . 6 2 . 2 2 6 . 3 5 , p o rt 2 1lis te n in g s o c k e t (* .21, * .* ) {,} F ig u re 2 . 8 C o n n e c t io n re q u e s t f ro m c lie n t t o s e rv e r s e rv e r c lie n tlis te n in g s o c k e t (* .21, * .* ) {, on} e cti fork nn co s e rv e r ( c h ild ) c o n n e c te d socket { 206.62.22 6.35 .21, 1 98.6 9.10.2 .150 0} F ig u re 2 . 9 C o n c u rre n t s e rv e r h a s c h ild h a n d le c lie n t
  22. 22. s e rv e r c lie n t 1lis te n in g s o c k e t (* .21, * .* ) {, io n ec t} nn fork co s e rv e r c lie n t 2 ( c h ild 1 ) c o n n e c te d socket {, {, io n 198.69.10 .2.1 500} ec t} nn co s e rv e r ( c h ild 2 ) c o n n e c te d socket {, 198.69.10 .2.1 501} F ig u re 2 . 1 0 S e c o n d c lie n t c o n n e c t io n w it h s a m e s e rv e r
  23. 23.  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.
  24. 24.  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.
  25. 25.  DF (don’t fragment) ◦ A router that receives an IPv4 datagram with the DF bit set whose size exceeds the outgoing links 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.
  26. 26. Notice: TCP and UDP port number is same.