52
Interoperab ility of TCP/IP Prepared by Cheng, Wang- jiunn 07/19/90 Instituter for Information Industry Interoperability of TCP/IP Page i

Interoperability of TCP/IP Prepared by Cheng, Wang-jiunn 07/19/90 Instituter for Information Industry Interoperability of TCP/IPPage i

  • View
    223

  • Download
    2

Embed Size (px)

Citation preview

Page 1: Interoperability of TCP/IP Prepared by Cheng, Wang-jiunn 07/19/90 Instituter for Information Industry Interoperability of TCP/IPPage i

Interoperability of

TCP/IPPrepared by Cheng, Wang-jiunn

07/19/90

Instituter for Information Industry

Interoperability of TCP/IP Page i

Page 2: Interoperability of TCP/IP Prepared by Cheng, Wang-jiunn 07/19/90 Instituter for Information Industry Interoperability of TCP/IPPage i

Interoperability• Open System : are built on international standards and, in a multi-vendor computing environment, enable users to achieve.

• Portability : the ability to use application software on computers from different vendors.

• Scalability : the ability to use the same application and system on all classes of computers from desktop workstation to supercomputers.

• Interoperability : the ability to have applications and computers from different vendors work together on a network.

Interoperability Page iii

Page 3: Interoperability of TCP/IP Prepared by Cheng, Wang-jiunn 07/19/90 Instituter for Information Industry Interoperability of TCP/IPPage i

Internetworking•Introduction•Underlying Network Technologies•Long Haul vs. Local Area Networks•Summary and Conclusion•Discussion •Internet Address•Connectionless Delivery System•Internet Datagram•Routing IP Datagram•Error and Control Messages

Internetworking Page 1-0

Page 4: Interoperability of TCP/IP Prepared by Cheng, Wang-jiunn 07/19/90 Instituter for Information Industry Interoperability of TCP/IPPage i

IntroductionHeterogeneous Hardware System

Multiple, diverse underlying hardware technologies Many disparate physical networks

Internetwork/InternetTCP/IP internet

A new technology, A virtual networkA method of interconnecting physical networks

A set of conventions for using networks to interact Not a new kind of physical network

Homogeneous SystemA coordinated, cooperative unit/whole/entity

A unified, universal interconnection of networks

Introduction Page 1-1

Page 5: Interoperability of TCP/IP Prepared by Cheng, Wang-jiunn 07/19/90 Instituter for Information Industry Interoperability of TCP/IPPage i

Introduction (cont’d)

Primary Goal :

a scheme to hide the underlying network hardware and to provide universal communication services .

Primary Result :

a concept to provide the framework for all design decisions.

Know-how :

How to build the internet protocols ?

How to provide the interoperability ?

Introduction (cont’d) Page 1-2

Page 6: Interoperability of TCP/IP Prepared by Cheng, Wang-jiunn 07/19/90 Instituter for Information Industry Interoperability of TCP/IPPage i

DDN PROTOCOL HANDBOOK - VOLUME ONE

Application Protocols

Application Protocols

Native mode

Application Program

Mall Application

Application Program

FTP SMTP Telnet

Host-Host Protocols

TCP

IP

Optional Other

Network Access Protocols

APANET Access Protocols(1822) DDN Standard X.25

DDN Backbone Network

Host-Type B Terminal TAC

Host-Type A Terminal

HOST TYPE B

HOST TYPE C

Figure 3-1 : The DoD Protocol Architecture

Page 7: Interoperability of TCP/IP Prepared by Cheng, Wang-jiunn 07/19/90 Instituter for Information Industry Interoperability of TCP/IPPage i

Underlying Network Technologies

Circuit-switched Network - Data are transmitted thru a dedicated communication path, connection, circuit link between two nodes.

Advantage : guaranteed capacity

Disadvantage : fixed cost (independent of traffic )

Example : Public Switching Telephone Network(PSTN)

Packet-switched Network - Data are sent out unnecessarily thru a dedicated connection, but in a sequence of packets which are multiplexed on intermachine connections.

Advantage : multiple connections provided (cost dependent on traffic)

Disadvantage : no guaranteed capacity

Example : Public Switching Data Network(PSDN)

Underlying Network Technologies Page 1-3

Page 8: Interoperability of TCP/IP Prepared by Cheng, Wang-jiunn 07/19/90 Instituter for Information Industry Interoperability of TCP/IPPage i

Underlying Network Technologies(cont’d)

Packet Broadcast Network- Data are sent out in a sequence

of packet thru a shared, common medium without switching nodes.

• A special case of Packet-switched network.Example : Local networks, Packet radio networks, Satellite networksWhy many computers interconnection use packet-switched networks ?

• Cost and performance

Underlying Network Technologies(cont’d)Page 1- 4

Page 9: Interoperability of TCP/IP Prepared by Cheng, Wang-jiunn 07/19/90 Instituter for Information Industry Interoperability of TCP/IPPage i

Long Haul Networks vs. Local Area Networks

Long Haul Local AreaGeographicalDistance

Long Short

TransmissionSpeed

9.6Kbps-1.54Mbps 3Mbps-100Mbps

ConnectionMethod

Indirectly via somespecial purpose packetswitching computers

Directly via anetwork deviceinterface

TransmissionMedium

Leased lineCoaxial cable orcopper wire cable

Performance High delay Little delay

Long Haul Networks vs. Local Area NetworksPage 1-5

Page 10: Interoperability of TCP/IP Prepared by Cheng, Wang-jiunn 07/19/90 Instituter for Information Industry Interoperability of TCP/IPPage i

Summary

Internet Protocols

Local Area Network

Long Haul Network

Other general-purpose network protocols

• Ethernet• ProNet-10 (high speed)

• NSFNET (backbone)• ARPANET• Cypress (low speed)

• X25NET (STANET) (AMPRNET)

Conclusion

The Internet Protocols are extremely flexible in that almost any underlying technologies can be used to transfer Internet traffic.

Summary and Conclusion Page 1-6

Page 11: Interoperability of TCP/IP Prepared by Cheng, Wang-jiunn 07/19/90 Instituter for Information Industry Interoperability of TCP/IPPage i

Discussion1.network-level interconnection verse application-level interconnection.

2.interconnection through gateways. (IP router or Internet Gateway)

3.a universal set of machine identifiers (names or addresses) : a network independence in the interface.

4.user’s view :• interconnection at the network level becoming more clear - applications without changing on any machine.

Communication at the network level becoming more subtle - users not necessary to know underlying network technologies.5.questions :

• how to map IP address into hardware address ?

• how to run multiple services on one machine ?

• how to route packets via gateways ?

Discussion Page 1-7

Page 12: Interoperability of TCP/IP Prepared by Cheng, Wang-jiunn 07/19/90 Instituter for Information Industry Interoperability of TCP/IPPage i

Internet Address• Universal Identifiers / Internet numbers 1.name - what an object is 2.address - where it is 3.route - how to get there

• Four Classes of Internet Addresses 1.Class A nnn.rrr.rrr.rrr (dotted decimal notation) 2.Class B nnn.nnn.rrr.rrr 3.Class C nnn.nnn.nnn.rrr 4.Class D Multicast address 5.Class E Reserved

0

1

1

1

0

1

1 1

0

1

Network Id

Network Id

Network Id

Host Id

Host Id

Host Id

Multicast address

Internet Address Page 1-8

Page 13: Interoperability of TCP/IP Prepared by Cheng, Wang-jiunn 07/19/90 Instituter for Information Industry Interoperability of TCP/IPPage i

Internet Address (cont’d)

• Four Categories of Users of Internet Address1.R - Research2.D - Defense3.G - Government (non-defense)4.C - Commercial5.T - Temporary (old number in the transition period)

• Special Addresses1.zero - this2.all ones - all hosts3.net id 127 - loopback function

Internet Address (cont’d) Page 1-9

Page 14: Interoperability of TCP/IP Prepared by Cheng, Wang-jiunn 07/19/90 Instituter for Information Industry Interoperability of TCP/IPPage i

Internet Address (cont’d)

IP ADDRESS (RFC1009)

Loopback(127, any)

Broadcast(-1)(Net#, -1)(Net#, -1, -1)(Net#, Subnet#, -1)

Network(Net#, 0)(Net#, Subnet#, 0)

Host (0, 0)(0, Host#)(Net#, Host#)(Net#, Subnet#, Host#)

Internet Address (cont’d) Page 1-10

RFC 10062 “Internet Numbers” [email protected]

Page 15: Interoperability of TCP/IP Prepared by Cheng, Wang-jiunn 07/19/90 Instituter for Information Industry Interoperability of TCP/IPPage i

Internet Address (cont’d)

• Disadvantages1.addresses refer to connections, not to hosts.2.time-consuming to change address when network grows.3.routing problem at multi-homed host / multiple addresses.

• Authority1.assigned by a central authority SRI-NIC.2.to guarantee uniqueness.

• Example1.Berkeley’s class B address is 128.32. The computer network connects

about 2,000 hosts over 50 subnets and 59 gateways.2.What are the SEED-NET and the III-NET ?

Internet Address (cont’d) Page 1-11

Page 16: Interoperability of TCP/IP Prepared by Cheng, Wang-jiunn 07/19/90 Instituter for Information Industry Interoperability of TCP/IPPage i

Mapping Internet Address to Physical Address

• Resolution thru Dynamic Binding vs. Direct Mapping1.dynamic binding - to use a low-level protocol.

2.direct mapping - to use a hash function.

• Address Resolution Protocol (ARP) :

to find the physical address of a target host on the same network.

1.using only the target’s Internet address.

2.a low-level protocol that hides the underlying network

physical address.

Mapping IA to PA Page 1-12

Page 17: Interoperability of TCP/IP Prepared by Cheng, Wang-jiunn 07/19/90 Instituter for Information Industry Interoperability of TCP/IPPage i

Connectionless Delivery System

• Internet service1.packet delivery - send and receive.

2.unreliable delivery - lost, duplicated, delivered

out of order, or discarded by host due to resources

exhausted.

3.best-effort delivery - making an earnest attempt to

deliver packets.

4.connectionless delivery - packet independence.

Connectionless Delivery System Page 1-13

Page 18: Interoperability of TCP/IP Prepared by Cheng, Wang-jiunn 07/19/90 Instituter for Information Industry Interoperability of TCP/IPPage i

Internet Datagram• Frame and Datagram

FRAME HEADER COMPLETE DATAGRAM TREATED AS DATA

DATAGRAM AREA DATA AREA

• Datagram Size Ethernet - 1500 octets ProNET - 10 - 2000 octets X.25 - 128 to ??? octets

• Network Maximum Transfer Unit (MTU) the largest amount of data that can be transferred across a given physical network.

• Recommendation : networks and gateways should be prepared to handle datagrams of up to 576 octets without fragmenting them.

Internet Datagram Page 1-14

Page 19: Interoperability of TCP/IP Prepared by Cheng, Wang-jiunn 07/19/90 Instituter for Information Industry Interoperability of TCP/IPPage i

Internet Datagram (cont’d)• Datagram Format

VERS TOTAL LENGTHTYPE OF SRVLEN

• Type of service : how to handle this datagram 1.precedence 3 bit - 0 thru 7 network control.* for implementing congestion control algorithm not affected by the congestion.2.D 1 bit - low delay (telnet)3.T 1 bit - high through (ftp)4.R 1 bit - high reliability * a hint to routing algorithm not a demand.

0 4 8 16 19

FLAGSIDENT FRAGMENT OFFTIME HEADER CHECKSUMPROTOCOL

SOURCE IP ADDRESSDESTINATION IP ADDRESS

OPTIONSDATA

PADDING

Internet Datagram (cont’d) Page 1-15

Page 20: Interoperability of TCP/IP Prepared by Cheng, Wang-jiunn 07/19/90 Instituter for Information Industry Interoperability of TCP/IPPage i

Internet Datagram (cont’d)

• Time to Live - how long to remain this datagram1.sender sets a max. time to datagram2.hosts or gateways decrement TTL by a unit time per header processing.3.hosts or gateways discard the datagram when the TTL reaches zero.

• Fragmentation Control1.identifier - hosts generate a unique value for identifier; gateways fragment the datagram by coping this field into every fragment; destine host use identifier to reassemble the datagram.2.flags - do not fragment bit; more fragment bit; last fragment bit.3. fragment offset - starting at offset zero; no necessary to receive fragments in order; discarding datagram whenever one or more fragments are lost.

Internet Datagram (cont’d) Page 1-16

Page 21: Interoperability of TCP/IP Prepared by Cheng, Wang-jiunn 07/19/90 Instituter for Information Industry Interoperability of TCP/IPPage i

Internet Datagram (cont’d)

• Header Checksum1.reducing processing time at gateways.2.independent of higher level checksum scheme.3.having corrupted data go undetected.4.forcing higher level protocols to add their own checksum.

• Options : for network testing or debugging to help monitor and control the Internet.1.variable length depending on which options are selected.2.no special separators.

Internet Datagram (cont’d) Page 1-17

Page 22: Interoperability of TCP/IP Prepared by Cheng, Wang-jiunn 07/19/90 Instituter for Information Industry Interoperability of TCP/IPPage i

Routing IP Datagrams

• Direct Routing 1. a single network. (same network portion of Internet address)2. no gateway.3. frame directly sending to the destination.

• Indirect Routing1. multiple physical networks. (different network portion of Internet address)2. interconnected by gateways.3. frame passing from gateway to gateway until reach a gateway can deliver it directly.

Routing IP Datagram Page 1-18

Page 23: Interoperability of TCP/IP Prepared by Cheng, Wang-jiunn 07/19/90 Instituter for Information Industry Interoperability of TCP/IPPage i

Routing IP Datagrams(con’d)

• Internet routing table : table-driven routing 1.entry ( N, G, I ) N : the destine Internet network address G : Internet address of a gateway for network N I : the physical network interface for network N2.this host or gateway can indirectly head for the datagram of network N via the next-hop gateway thru the physical network

interface I whenever the network portion of destination Internet address matches the network N.

• Default Routing : useful in hosts with a single physical network attached.

• Host-specific Routing : for debugging or specific cases.Routing IP Datagram (con’d) Page 1-19

Page 24: Interoperability of TCP/IP Prepared by Cheng, Wang-jiunn 07/19/90 Instituter for Information Industry Interoperability of TCP/IPPage i

Routing IP Datagrams(con’d)• Summary of routing by network id1. multiple paths may not be used concurrently.2. the final gateway has to report problems back to source.3. two-way communication between gateway is necessary.

• The Final Algorithm :Route_IP_Datagram ( datagram, routing_table )Extract destination IP address, I(d), form datagram Compute IP address of destination network, I(n)if I(n) matches any direct connected network address send datagram to destination over that network;else if I(d) appears as host-specific route route datagram as specified in the table;else if I(n) appears in routing table route datagram as specified in the table;else if a default route has been specified route datagram to the default gateway;else declare a routing error;

Routing IP Datagram (cont’d) Page 1-20

Page 25: Interoperability of TCP/IP Prepared by Cheng, Wang-jiunn 07/19/90 Instituter for Information Industry Interoperability of TCP/IPPage i

• Goal : how gateways use the mechanism to report delivery problems to test whether destinations are reachable

• Error Conditions when the destination is disconnected when the TTL expires when gateway becomes congestion when the reassemble timer expires

• Internet Control Message Protocol (ICMP) : as a part of Internet Protocol to report error from gateway or host to provide information to gateway or host to send back to original source internet software, not to application

Error and Control Messages Page 1-21

Error and Control Messages

Page 26: Interoperability of TCP/IP Prepared by Cheng, Wang-jiunn 07/19/90 Instituter for Information Industry Interoperability of TCP/IPPage i

Error and Control Messages(cont’d)

• Format : as a portion of IP, not a higher level protocol

IP HEADER ICMP MESSAGE AS DATA

Type Field ICMP Message Type 0 Echo Reply 3 Destination Unreachable 4 Source Quench 5 Redirect (change a route)8 Echo Request 11 Time Exceeded for a Datagram 12 Parameter Problem on a datagram 13 Timestamp Request14 Timestamp Reply 15 Information Request16 Information Reply 17 Address Mask Request18 Address Mask Reply

Error and Control Messages(cont’d) Page 1-22

Page 27: Interoperability of TCP/IP Prepared by Cheng, Wang-jiunn 07/19/90 Instituter for Information Industry Interoperability of TCP/IPPage i

User Datagram Protocol

• Introduction

• Header Format

• Port Philosophy

• Example

User Datagram Protocol Page 2-0

Page 28: Interoperability of TCP/IP Prepared by Cheng, Wang-jiunn 07/19/90 Instituter for Information Industry Interoperability of TCP/IPPage i

IntroductionDatagram

is a self-contained package of data carrying enough header

information, and can be routed from source to destination with independence of earlier exchanges.

Datagram Fragmentis

a fragment which carries a portion of data and a copy of original datagram header.

Datagram Serviceis

that the receiver can determine the boundaries of the datagram and all datagrams are delivered with non-zero probability to

desired destination without preserved original sequence.

Introduction Page 2-1

Page 29: Interoperability of TCP/IP Prepared by Cheng, Wang-jiunn 07/19/90 Instituter for Information Industry Interoperability of TCP/IPPage i

Introduction (cont’d)

UDP

is

the User Datagram Protocol.

The Protocol uses datagram service (IP service),

that is , an unreliable connectionless delivery

service, to transport messages, and supports the

demultiplexing capability to allow multiple

application programs to use datagram service

within a single host simultaneously.

Introduction ( cont’d ) Page 2-2

Page 30: Interoperability of TCP/IP Prepared by Cheng, Wang-jiunn 07/19/90 Instituter for Information Industry Interoperability of TCP/IPPage i

Header Format

• Source Port : an optional field, indicating the port of the sending process.• Destination Port : within the context of a particular internet destination address.• Length = UDP header + Data ( >=8 )• Checksum : the 16-bit 1’s complement of the 1’s complement sum of “Pseudo header + UDP header + Data + Padding ( if necessary)”

Header Format Page 2-3

Source Address

Destination Address

Zero Protocol(17) TCP Length

Source Port Destination Port

Length Checksum

Data octets ...

00

16 1

3

Page 31: Interoperability of TCP/IP Prepared by Cheng, Wang-jiunn 07/19/90 Instituter for Information Industry Interoperability of TCP/IPPage i

Port PhilosophyMultiplexing / Demultiplexing : the 16-bit port number of each UDP message is used to distinguish / demultiplex among multiple processes within a host simultaneously.

Port 1

UDP : Demultiplexing Based On Port

IP Layer

UDP Datagram arrives

Port 2 Port 3

Example of demultiplexing one layer above IP

• Static binding : universal assignment, well-known port assignment.• Dynamic binding : assigned by one network software, request-reply assignment.• Hybrid binding : only 0-255 ports are designed for well- known port; others are available for arbitrary application program to use.

Port Philosophy3 Page 2-4

Page 32: Interoperability of TCP/IP Prepared by Cheng, Wang-jiunn 07/19/90 Instituter for Information Industry Interoperability of TCP/IPPage i

Transmission Control Protocol

• Introduction

• Basic Operations

• Header Format

• Sequence Numbers

• TCP Connection

• Examples

Transmission Control Protocol Page 3-0

Page 33: Interoperability of TCP/IP Prepared by Cheng, Wang-jiunn 07/19/90 Instituter for Information Industry Interoperability of TCP/IPPage i

Introduction

TCPis

the Transmission Control Protocol, a part of the Internet Protocol Suite, a highly reliable host-to-host

protocol, a standard interprocess communication protocol, a connection-oriented, end-to-end reliable

protocol, a reliable process-to-process communication service

ininterconnected systems,

multiple networks,a wide spectrum of communication systems ranging from hard-wired connections to packet-switched or

circuit-switched networks.

Introduction Page 3-1

Page 34: Interoperability of TCP/IP Prepared by Cheng, Wang-jiunn 07/19/90 Instituter for Information Industry Interoperability of TCP/IPPage i

Internet Datagram (cont’d)

Internet Datagram (cont’d) Page 3-2

Higher-levelTCP

Internet protocolCommunication network

Protocol Layering

Telnet FTP Voice ...

...TCP RTP

Internet Protocol & ICMP

Local Network Protocol

Application Level

Host Level

Gateway Level

Network LevelProtocol Relationships

Page 35: Interoperability of TCP/IP Prepared by Cheng, Wang-jiunn 07/19/90 Instituter for Information Industry Interoperability of TCP/IPPage i

Basic Operations

• Basic Data Transfer

• Reliability

• Flow Control

• Multiplexing

• Connections

• Precedence and Security

Basic Operations Page 3-3

Page 36: Interoperability of TCP/IP Prepared by Cheng, Wang-jiunn 07/19/90 Instituter for Information Industry Interoperability of TCP/IPPage i

Basic Operations (cont’d)

Basic Data Transfer

• stream orientation : to transfer a continuous stream of octets.

• full duplex connection : to transfer data in both directions.

• Buffered transfer : to transfer data by segments (some number of octets), to block and forward by TCP, to force transfer via a push mechanism.

Basic Operations (cont’d) Page 3-4

Page 37: Interoperability of TCP/IP Prepared by Cheng, Wang-jiunn 07/19/90 Instituter for Information Industry Interoperability of TCP/IPPage i

Basic Operations (cont’d)

Reliability

• sequence number : to correct out of order segments and

to eliminate duplicated segments at the receiver.

• positive acknowledgment : to retransmit segment (lost) if

the ACK is not received within a timeout interval.

• checksum : to discard the damaged segments.

Basic Operations (cont’d) Page 3-5

Page 38: Interoperability of TCP/IP Prepared by Cheng, Wang-jiunn 07/19/90 Instituter for Information Industry Interoperability of TCP/IPPage i

Basic Operations (cont’d)

Flow Control

• window : to regulate the rate at which data arrives from a sending TCP. (a byte-level sliding window)

Multiplexing

• a set of ports : to support multiple processes to use TCP simultaneously.

• Socket = port + internet address

• a pair of sockets : to uniquely identify each connection throughout the internet.

• Static and dynamic binding ports to processes. (refer to UDP “Port Philosophy”)

Basic Operations (cont’d) Page 3-6

Page 39: Interoperability of TCP/IP Prepared by Cheng, Wang-jiunn 07/19/90 Instituter for Information Industry Interoperability of TCP/IPPage i

Page 3-8Basic Operations (cont’d)

Basic Operations (cont’d)

Connections

• a three-way handshake mechanism : to establish a connection (initialize the status information: sockets, sequence numbers, and window sizes) and to terminate a connection (free the resources for other uses)

• clock-based sequence numbers : to avoid erroneous of delay duplicated packets

Precedence and Security

• to allow the users of TCP to indicate the Security and Precedence of their communication.

Page 40: Interoperability of TCP/IP Prepared by Cheng, Wang-jiunn 07/19/90 Instituter for Information Industry Interoperability of TCP/IPPage i

Sequence Number

• Stream orientation : each octet has a sequence

number and can be acknowledged over a TCP

connection.

• The space of sequence number is 0 to 2**32-1.

• Send Sequence Space :

• Receive Sequence Space :

Sequence Number Page 3-9

Page 41: Interoperability of TCP/IP Prepared by Cheng, Wang-jiunn 07/19/90 Instituter for Information Industry Interoperability of TCP/IPPage i

Sequence Number (cont’d)• The comparison of an acceptable and new acknowledgment : SND.UNA < SEG.ACK = < SND.NXT

• The comparison of a new segment of data : RCV.NXT = < SEG.SEQ <RCV.NXT + RCV.WND

• The comparison of zero windows and zero length segments :

Sequence Number (cont’d ) Page 3-10

Segment Length

Receive Window

Test

0

0

> 0

> 0 > 0

> 0

0

0 SEG.SEQ = RCV.WND

RCV.NXT =< SEG.SEQ < RCV.NXT + RCV.WND

not acceptable

RCV.NXT =< SEG.SEQ < RCV.NXT + RCV.WND or RCV.NXT =< SEG.SEQ + SEG.LEN -1 < RCV.NXT + RCV.WND

Page 42: Interoperability of TCP/IP Prepared by Cheng, Wang-jiunn 07/19/90 Instituter for Information Industry Interoperability of TCP/IPPage i

TCP Connection

CLOSED

passive OPEN CLOSE create TCB delete TCB

LISTEN

rcv SYN SEND SYN snd SYN,ACK snd SYN SYN

RCVD SENTrcv SYNsnd ACK

rcv ACK of SYN rcv SYN , ACK x snd SYN

ESTAB CLOSE snd FIN CLOSE rcv FIN snd FIN snd ACK

FIN CLOSEWAIT-1 WAIT

FIN CLOSING LAST WAIT-2 ACK

rcv ACK of SYN rcv ACK of SYN x x

rcv FIN Timeout = 2MSL snd ACK TIME delete TCB CLOSED WAIT

TCP Connection State Diagram

Page 43: Interoperability of TCP/IP Prepared by Cheng, Wang-jiunn 07/19/90 Instituter for Information Industry Interoperability of TCP/IPPage i

TCP Connection Initiation

Introduction and IPa/TCP/PORTa denotes the application which is accessible via

noation PORTa of the TCP transport protocol on the machine with

IP address IPa.

[oldA,oldB] --> [newA.newB] denotes the state transiitions

between processes A and B.

Prelude “ftp iii2.pdd.iii.net.tw” command is issued by user at machine

with address IPa.

Name to address To translate the host name iii2.pdd.iii.net.tw into a 32-bit IP

translation address IPb.

Dimain Name The dynamic bindung method currently in use is the DNS. The

System procedure of the name resolver used to trandlte

iii2.pdd.iii.net.tw into an IP address is shown as follows in

short : IPa’s local name cache, IPa’s near name database,

and IPa’s far name database.

If the name translation succeeds, IPb corresponds to

iii2.pdd.iii.net.tw.

Well-known The well-known socket number for the ftp service can be found

soket “ftp“ at the local database,such as /etc/services file . this socket

number is denoted as PORTftp.

Page 44: Interoperability of TCP/IP Prepared by Cheng, Wang-jiunn 07/19/90 Instituter for Information Industry Interoperability of TCP/IPPage i

TCP Connection Initiation (cont’d)

Establishing a The ftp client process now is trying to establesh a connection between IPa/TCP/PORTa

local TCP and IPb/TCP/PORTftp. So the local TCP will allocate a socket for establishing

Control Block this new connection.

Three-way The three-way handshake is to synchronize the two TCP’s as to the sttate transitions

Handshake from[CLOSED,LISTEN] to [ESTAB,ESTAB].

The first Construct TCP header : IPa/TCP calculates an Initial Send Sequence (ISSa) number for

datagram the connection. The number is used to protect this new connection from accepting

data from some previous connection (delay duplicate packet). The datagram with

ISSa and SYN bit is prepared. A state transition occurs on IPa/TCP from

[CLOSED,LISTEN] to [SYN SEND, LISTEN].

Construct IP header : The scenario of examinimg Ipb is shown as follows : routing to

local TCP (IPa/TCP = IPb/TCP), routing to a common physical line, such as LAN

, (from Dla to DLb directly) or routing to a remote network via gateways indirectly.

Routing via a In the lastt case, Ipa will need to send the datagram to an Internet Gateway (IP Router)

for forwarding to IPb. Using the static routing method, Ipa will lookup the cache

of routing table to find out the next hop IPc (which should has a physical link

in common with DLa ) for the datagram. Otherwise , IPa reports error to IPa/TCP.

If succeeds, the datagram will bepassed to DLa, and then be sent to DLc.

Page 45: Interoperability of TCP/IP Prepared by Cheng, Wang-jiunn 07/19/90 Instituter for Information Industry Interoperability of TCP/IPPage i

TCP Connection Initiation (cont’d)

Adddress The next hop may be the travelling path of IPa -> IPc -> Ipb ---->Ipb and

resolution by Dla is not equal to IPa, so Dla needs to use some mechanism to translate

the Data IP address Ipc into physical address DLc. There are two schemes in

Link Layer common use : the direct mapping and dynamic binding.

ARP The ARP processing entity DLa/ARP will lookup the ARP cache to see

if the mapping (IPc, DLc) had been resolved recently or broadcast an

ARP request packet with the ARP packet type.

Back to the DLc will examine the packet and forward it to DLc/ARP.

datagram DLc/ARP will prepare an ARP response packet which contains

the mapping (IPc,DLc) and deliver the packet to Dla directly.

DLa will receive the ARP response packet from DLc.

DLa/ARP will discover that it now knows the mapping from Ipa to IPb via

IPc, the packet (containing the TCP/IP datagram) will be delivered to DLc.

Eventually, DLb will receive the original packet and will hand the packet to

IPb.

IPb verifies the IP header checksum. If the checksum is incorrect, the datagram

will be discarded silently.

If IPb/TCP does exist , IPb will pass the incoming datagram to IPb/TCP

, itherwise , IPb/ICMP will send an ICMP error message back to the sinder

IPa/TCP

Page 46: Interoperability of TCP/IP Prepared by Cheng, Wang-jiunn 07/19/90 Instituter for Information Industry Interoperability of TCP/IPPage i

TCP Connection Initiation (cint’d)

TCP Checksum IPb/TCP will validate the TCP checksum. If the checksum is

valid, IPb/TCP will examine the header:

IPa/TCP/PORa, IPb/TCP/PORTftp, ISSa, and SYN bit.

The pair of sockets are defined by the tuple (IPa, PORTa, IPb,

PORTftp) and represent a TCP connection. So, IPb/TCP

will search its list of active connections looking for (IPa,

PORTa, IPb, PORTftp).

Half-open If such a connection is found, IPb/TCP will send an

connections acknowledgement dataguam for the already existing

connection to IPa/TCP, and will drop the incoming

datagram. This could happen in the state [SYN SENT,

ESTABLISHED].

IPb/TCP takes this SYN datagram as an old delayed datagram

and the acknowledgement datagam is to inform IPa/TCP of

the existence of the existing connection.

Closing half-open If the SYN datagram was an old datagram, IPa/TCP will ignore

the acknowledgement datagram.

Otherwise, IPa/TCP will know that the connection (IPa, PORTa,

IPb, PORTftp) was incorrect (Seq#<>ISSa, probably due

to IPa which had restarted accidentally). So, IPa/TCP will

send a TCP reset data gram to IPb/TCP.

This reset datagram will cause Ipb/TCP to close the old commection.

Page 47: Interoperability of TCP/IP Prepared by Cheng, Wang-jiunn 07/19/90 Instituter for Information Industry Interoperability of TCP/IPPage i

TCP Connection Initiation (cont’d)

Normal If IPb/TCP dose not f ind the connection (IPa, PORTa, IPb, PORTftp),

processing it will look t o see if there is any process listening on PORTftp.

If no such process exists, IPb/TCP will send a reset datagram to

IPa/TCP, that is, at the state [SYN SENT, CLOSED]. If such a

process is listening for IPb/TCP/PORTftp, IPb/TCP will construct

a datagram to send in reply to the received datagram with ISSa+1

, ISSb, and SYN bit and a state transition occurs :

[SYN SENT, LISTEN] --> [SYN SENT, SYNRCVD].

In a manner similar to IPa, IPb will examine the address IPa,

DLb will request DLb/ARP,... back to IPa, eventually.

Connection Normally, IPa/TCP will verify the checksum, ISSa+1 , ... and will

Established send a datagram to IPb/TCP with an acknowledgement

number of ISSb+1. At this point, the state transitiion is :

[SYN SENT, SYN RCVD] --> [ESTAB,SYN RCVD].

IPb/TCP will receive the acknowledgement packet from

IPa/TCP. At this point, the state transition is :

[ESTAB, SYN RCVD] --> [ESTAB, ESTAB].

After these interactions , the connection is open and the user is

now able to file transfer to or from iii2.pdd.iii.net.tw.

Page 48: Interoperability of TCP/IP Prepared by Cheng, Wang-jiunn 07/19/90 Instituter for Information Industry Interoperability of TCP/IPPage i

Socket Interface

•Client/Server

•File Format

•Network Functions

•System Calls

•Example

Page 49: Interoperability of TCP/IP Prepared by Cheng, Wang-jiunn 07/19/90 Instituter for Information Industry Interoperability of TCP/IPPage i

Client/Server

Comparison of sockets, TL1. message queues, and FIFOs

Page 50: Interoperability of TCP/IP Prepared by Cheng, Wang-jiunn 07/19/90 Instituter for Information Industry Interoperability of TCP/IPPage i

socket()

bind()

listen()

accept()

read()

write()

socket()

connect()

write()

read()

blocks until connection from client

process request

connection establishment

data(request)

data(reply)

(connection-oriented protocol)Server

Client

Client/Server(cont’d)

Socket system calls for connection-oriented protocol

Page 51: Interoperability of TCP/IP Prepared by Cheng, Wang-jiunn 07/19/90 Instituter for Information Industry Interoperability of TCP/IPPage i

socket()

bind()

recvfrom()

sendto()

socket()

bind()

sendto()

recvfrom()

blocks until data

receivedfrom a client

process request

data(request)

data(reply)

(connectionless protocol)Server

Client

Client/Server(cont’d)

Socket system calls for connectionless protocol

Page 52: Interoperability of TCP/IP Prepared by Cheng, Wang-jiunn 07/19/90 Instituter for Information Industry Interoperability of TCP/IPPage i

gethostbyname

getservbyname

gethostname

create socket

prepare datafor structruresockaddr-in

connect withserver

receive response(read)

gethostname

prepare datafor structuresockaddr_in

create socket

bind name to socket

send message(write)

listen

fork child process

accept client

write

process

read

getservbyname

gethostbyname

start

start

start

ExampleSERVER

CLIENT

DEAMON