SlideShare una empresa de Scribd logo
1 de 32
   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
                             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.
   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
   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
application
7 Application                                                               details
                                                                       user
6 Presentation                                                       process
                               Application
5   Session                                          Sockets
                                                       XTI
4  Transport                 TCP | | UDP
3   Network                    IPv4, IPv6                             kernel
                                                                        communication
2   Datalink                 Device driver                                   details
1   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.
   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.
TCP               UDP
Binding between Yes (connection- No (connection-
client and server oriented)      less)
Data              Byte-stream    Record
Reliability     Yes (ack, time-   No
                out, retx)
Sequencing      Yes               No
Flow control    Yes (window-      No
                based)
Full-duplex     Yes               Yes




                                                   13
   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,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)
   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 handshake
                      client                   server

                                    FIN m
close                                              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)
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 K
transition    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
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
   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.
206.62.226.35
                                    206.62.226.66                                                                   198.69.10.2

                                                                        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 1
lis te n in g s o c k e t              (* .21, * .* )                                                           { 198.69.10.2.1500,
                                                                                                                 206.62.226.35.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


                                    206.62.226.35
                                    206.62.226.66                                                                   198.69.10.2


                                              s e rv e r                                                               c lie n t
lis te n in g s o c k e t              (* .21, * .* )                                                           { 198.69.10.2.1500,
                                                                                                 on              206.62.226.35.21}
                                                                                       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
206.62.226.35
                                       206.62.226.66                                                               198.69.10.2


                                                s e rv e r                                                               c lie n t 1
lis te n in g s o c k e t                (* .21, * .* )                                                      { 198.69.10.2.1500,
                                                                                               io   n
                                                                                          ec t                206.62.226.35.21}
                                                                                     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                     { 206.62.226.35.21,                                                        { 198.69.10.2.1500,
                                                                                               io n
                                   198.69.10 .2.1 500}                                    ec t                206.62.226.35.21}
                                                                                     nn
                                                                                co


                                           s e rv e r
                                         ( c h ild 2 )
   c o n n e c te d
       socket                     { 206.62.226.35.21,
                                   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
   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.
Np unit1

Más contenido relacionado

La actualidad más candente

Programming TCP/IP with Sockets
Programming TCP/IP with SocketsProgramming TCP/IP with Sockets
Programming TCP/IP with Socketselliando dias
 
Socket programming using C
Socket programming using CSocket programming using C
Socket programming using CAjit Nayak
 
Socket programming
Socket programmingSocket programming
Socket programmingUjjwal Kumar
 
Final networks lab manual
Final networks lab manualFinal networks lab manual
Final networks lab manualJaya Prasanna
 
Client server examples for tcp abnormal conditions
Client server examples for tcp abnormal conditionsClient server examples for tcp abnormal conditions
Client server examples for tcp abnormal conditionsCEC Landran
 
RARP, BOOTP, DHCP and PXE Protocols
RARP, BOOTP, DHCP and PXE ProtocolsRARP, BOOTP, DHCP and PXE Protocols
RARP, BOOTP, DHCP and PXE ProtocolsPeter R. Egli
 
Socket programming in C
Socket programming in CSocket programming in C
Socket programming in CDeepak Swain
 
Transport layer interface
Transport layer interface Transport layer interface
Transport layer interface CEC Landran
 
Arp and rarp
Arp and rarpArp and rarp
Arp and rarpMohd Arif
 
Tcp Ip Overview
Tcp Ip OverviewTcp Ip Overview
Tcp Ip OverviewAmir Malik
 
Computer network (16)
Computer network (16)Computer network (16)
Computer network (16)NYversity
 
Ipv6 cheat sheet
Ipv6 cheat sheetIpv6 cheat sheet
Ipv6 cheat sheetjulianlz
 

La actualidad más candente (20)

Programming TCP/IP with Sockets
Programming TCP/IP with SocketsProgramming TCP/IP with Sockets
Programming TCP/IP with Sockets
 
IPC SOCKET
IPC SOCKETIPC SOCKET
IPC SOCKET
 
Socket programming using C
Socket programming using CSocket programming using C
Socket programming using C
 
Socket programming
Socket programmingSocket programming
Socket programming
 
Final networks lab manual
Final networks lab manualFinal networks lab manual
Final networks lab manual
 
Basics of sockets
Basics of socketsBasics of sockets
Basics of sockets
 
Part 12 : Local Area Networks
Part 12 : Local Area Networks Part 12 : Local Area Networks
Part 12 : Local Area Networks
 
Socket programming in c
Socket programming in cSocket programming in c
Socket programming in c
 
Sockets
SocketsSockets
Sockets
 
Introduction to TCP/IP
Introduction to TCP/IPIntroduction to TCP/IP
Introduction to TCP/IP
 
Client server examples for tcp abnormal conditions
Client server examples for tcp abnormal conditionsClient server examples for tcp abnormal conditions
Client server examples for tcp abnormal conditions
 
RARP, BOOTP, DHCP and PXE Protocols
RARP, BOOTP, DHCP and PXE ProtocolsRARP, BOOTP, DHCP and PXE Protocols
RARP, BOOTP, DHCP and PXE Protocols
 
Socket programming in C
Socket programming in CSocket programming in C
Socket programming in C
 
Transport layer interface
Transport layer interface Transport layer interface
Transport layer interface
 
Arp and rarp
Arp and rarpArp and rarp
Arp and rarp
 
Day-3 PowerPoint
Day-3 PowerPointDay-3 PowerPoint
Day-3 PowerPoint
 
Tcp Ip Overview
Tcp Ip OverviewTcp Ip Overview
Tcp Ip Overview
 
Computer network (16)
Computer network (16)Computer network (16)
Computer network (16)
 
Ipv6 cheat sheet
Ipv6 cheat sheetIpv6 cheat sheet
Ipv6 cheat sheet
 
Arp and rarp
Arp and rarpArp and rarp
Arp and rarp
 

Similar a Np unit1

Similar a Np unit1 (20)

Web and internet technology notes for BCA students
Web and internet technology notes for BCA studentsWeb and internet technology notes for BCA students
Web and internet technology notes for BCA students
 
App layer
App layerApp layer
App layer
 
More on Tcp/Ip
More on Tcp/IpMore on Tcp/Ip
More on Tcp/Ip
 
3rd edition chapter2
3rd edition chapter23rd edition chapter2
3rd edition chapter2
 
Tcp3 wayhandshakeprocess
Tcp3 wayhandshakeprocessTcp3 wayhandshakeprocess
Tcp3 wayhandshakeprocess
 
Ajp notes-chapter-04
Ajp notes-chapter-04Ajp notes-chapter-04
Ajp notes-chapter-04
 
Chapter Five - Transport Layer.pptx
Chapter Five - Transport Layer.pptxChapter Five - Transport Layer.pptx
Chapter Five - Transport Layer.pptx
 
NP-lab-manual (1).pdf
NP-lab-manual (1).pdfNP-lab-manual (1).pdf
NP-lab-manual (1).pdf
 
NP-lab-manual.pdf
NP-lab-manual.pdfNP-lab-manual.pdf
NP-lab-manual.pdf
 
NP-lab-manual.docx
NP-lab-manual.docxNP-lab-manual.docx
NP-lab-manual.docx
 
Chapter3 transport
Chapter3 transportChapter3 transport
Chapter3 transport
 
CCNA (R & S) Module 01 - Introduction to Networks - Chapter 9
CCNA (R & S) Module 01 - Introduction to Networks - Chapter 9CCNA (R & S) Module 01 - Introduction to Networks - Chapter 9
CCNA (R & S) Module 01 - Introduction to Networks - Chapter 9
 
TCP/IP Basics
TCP/IP BasicsTCP/IP Basics
TCP/IP Basics
 
TCP Vs UDP
TCP Vs UDP TCP Vs UDP
TCP Vs UDP
 
Week3 applications
Week3 applicationsWeek3 applications
Week3 applications
 
Ctp
CtpCtp
Ctp
 
Network programming in Java
Network programming in JavaNetwork programming in Java
Network programming in Java
 
Chapter 2
Chapter 2Chapter 2
Chapter 2
 
Transport layer
Transport layerTransport layer
Transport layer
 
02 protocol architecture
02 protocol architecture02 protocol architecture
02 protocol architecture
 

Más de vamsitricks (20)

Unit 6
Unit 6Unit 6
Unit 6
 
Np unit iv i
Np unit iv iNp unit iv i
Np unit iv i
 
Unit 7
Unit 7Unit 7
Unit 7
 
Npc16
Npc16Npc16
Npc16
 
Npc14
Npc14Npc14
Npc14
 
Npc13
Npc13Npc13
Npc13
 
Npc08
Npc08Npc08
Npc08
 
Unit 3
Unit 3Unit 3
Unit 3
 
Unit 5
Unit 5Unit 5
Unit 5
 
Unit 2
Unit 2Unit 2
Unit 2
 
Unit 7
Unit 7Unit 7
Unit 7
 
Unit 6
Unit 6Unit 6
Unit 6
 
Unit 4
Unit 4Unit 4
Unit 4
 
Unit4wt
Unit4wtUnit4wt
Unit4wt
 
Unit3wt
Unit3wtUnit3wt
Unit3wt
 
Unit2wt
Unit2wtUnit2wt
Unit2wt
 
Unit 1wt
Unit 1wtUnit 1wt
Unit 1wt
 
Servletarchitecture,lifecycle,get,post
Servletarchitecture,lifecycle,get,postServletarchitecture,lifecycle,get,post
Servletarchitecture,lifecycle,get,post
 
Jsp with mvc
Jsp with mvcJsp with mvc
Jsp with mvc
 
Cookies
CookiesCookies
Cookies
 

Np unit1

  • 1. Inter process communication (IPC) between processes on different hosts over the network.  IPC has Two Forms : ◦ Local IPC ◦ Network IPC
  • 2.
  • 3. ◦ 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
  • 4.
  • 5. Pipe  FIFO  Message Queues  Shared Memory  Semaphores  Sockets
  • 6. 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.
  • 7. 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
  • 8. 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
  • 9. application 7 Application details user 6 Presentation process Application 5 Session Sockets XTI 4 Transport TCP | | UDP 3 Network IPv4, IPv6 kernel communication 2 Datalink Device driver details 1 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.
  • 10. 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
  • 11. 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.
  • 12. 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 between Yes (connection- No (connection- client and server oriented) less) Data Byte-stream Record Reliability Yes (ack, time- No out, retx) Sequencing Yes No Flow control Yes (window- No based) Full-duplex Yes Yes 13
  • 14. 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.
  • 15. 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)
  • 16. 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.
  • 17. TCP Connection: Termination Four-way handshake client server FIN m close 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)
  • 18. 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 K transition 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
  • 19. 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
  • 20. 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
  • 21. 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
  • 22.
  • 23. 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.
  • 24. 206.62.226.35 206.62.226.66 198.69.10.2 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 1 lis te n in g s o c k e t (* .21, * .* ) { 198.69.10.2.1500, 206.62.226.35.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 206.62.226.35 206.62.226.66 198.69.10.2 s e rv e r c lie n t lis te n in g s o c k e t (* .21, * .* ) { 198.69.10.2.1500, on 206.62.226.35.21} 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
  • 25. 206.62.226.35 206.62.226.66 198.69.10.2 s e rv e r c lie n t 1 lis te n in g s o c k e t (* .21, * .* ) { 198.69.10.2.1500, io n ec t 206.62.226.35.21} 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 { 206.62.226.35.21, { 198.69.10.2.1500, io n 198.69.10 .2.1 500} ec t 206.62.226.35.21} nn co s e rv e r ( c h ild 2 ) c o n n e c te d socket { 206.62.226.35.21, 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
  • 26. 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.
  • 27. 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.
  • 28. 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.
  • 29.
  • 30.
  • 31. Notice: TCP and UDP port number is same.