Describe function and performance of TCP/IP protocol works
Size: 279.28 KB
Language: en
Added: Jul 30, 2024
Slides: 25 pages
Slide Content
1
How the TCP/IP Protocol Works
2
Overview
•This is not a lecture on how to program TCP/IP,
rather an introduction to how major portions works
•IP
•Addressing: IP addresses
•UDP
•TCP: flow control, error recovery, establishment,
diconnect
3
Internet Protocol (IP RFC-791)
Transport Services
Connectionless packet delivery service
Application services
TCP/IP Internet provides 4 layers of service
•Layering allows one to replace one service without affecting
others
•IP layer (basic unit of transfer in TCP/IP) provides:
•Best-effort (does not discard capriciously), unreliable(no
guarantees)
•Packet may be lost, duplicated, out-of-order with no
notification
•Connectionless (each packet treated independently)
IP software provides routing
Network layer
4
Internet datagram
•Basic transfer unit
•Format of Internet datagram
Datagram headerDatagram data area
Vers Type of serv. Total length
0 8 16 31
Datagram IdentificationFlags
24
Hlen
4
Fragment offset
19
Time To LiveProtocol Header Checksum
Source IP address
Destination IP address
IP Options (if any) Padding
Data
…
5
IP datagram format (cont.)
•Vers(4 bits): version of IP protocol (IPv4=4)
•Hlen(4 bits): Header length in 32 bit words, without options (usual
case) = 20
•Type of Service –TOS(8 bits): little used in past, now being used for
QoSExamples: Less Delay, High throughput, Reliability of packet…
•Total length(16 bits): length of datagram in bytes, includes header
and data (Header= (20 to 60 bytes), Data= 20to 65535bytes
•Datagram Identification (16 bits) : it is unique number assigned by
the sender used with fragmentation
•Flags (3 bits) : used for fragmentation
The 1
st
bit is reserved and must be zero
The 2
nd
bit is DF (Do Not Fragment),0Means allow fragmentation
The 3
rd
bit MF (More fragments), 0 means least fragment
6
IP Datagram format (cont.)
•Fragment Offset:it is used to reassemble the full datagram
•Time to live –TTL(8bits): specifies how long datagram is
allowed to remain in internet or travel
–Routers decrement by 1
–When TTL = 0 router discards datagram
–Prevents infinite loops
•Protocol Number(8 bits): specifies the format of the data
area
–Protocol numbers administered by central authority to guarantee
agreement, e.g. TCP=6, UDP=17, ICMP:1 …
7
IP Datagram format (cont.)
•Header Checksum: It is a checksum for the
information contained in the header. If the header
checksum does not match the contents, the datagram
is discarded & it is also used for security purpose
•Source & destination IP address(32 bits each):
contain IP address of sender and intended recipient
•Options(variable length): Mainly used to record a
route, or timestamps, or specify routing
8
Internet Addressing
•IP address is a 32 bit integer
–Refers to interface rather than host
–Consists of network and host portions
•Enables routers to keep 1 entry/network instead of 1/host
–Class A, B, C for unicast
–Class D for multicast
–Class E reserved
–Classless addresses
•Written as 4 octets/bytes in decimal format
–E.g. 134.79.16.1, 127.0.0.1
9
Internet Class-based addresses
•Class A: large number of hosts, few networks
–0nnnnnnn hhhhhhhh hhhhhhhh hhhhhhhh
•7 network bits (0 and 127 reserved, so 126 networks), 24 host bits (> 16M
hosts/net)
•Initial byte 1-127 (decimal)
•Class B: medium number of hosts and networks
–10nnnnnn nnnnnnnn hhhhhhhh hhhhhhhh
•16,384 class B networks, 65,534 hosts/network
•Initial byte 128-191 (decimal)
•Class C: large number of small networks
–110nnnnn nnnnnnnn nnnnnnnn hhhhhhhh
•2,097,152 networks, 254 hosts/network
•Initial byte 192-223 (decimal)
•Class D: 224-239 (decimal) Multicast [RFC1112]
•Class E: 240-255 (decimal) Reserved
10
UDP Datagram format
•Source/destination port: port numbers identify sending & receiving
processes
–Port number & IP address allow any application in any computer on Internet to
be uniquely identified (Example:HTTP:80)
–Used to demultiplex datagrams to processes
–Ports can be static or dynamic
•Static (< 1024) assigned centrally, known as well known ports
•Dynamic
•Message length in bytes includes the UDP header and data
Source port Destination port
UDP message lenChecksum (opt.)
0 8 16 3124
Data
…
11
UDP Datagram format
•Both UDP & TCP include a pseudo-header with the UDP datagram
just for the checksum calculations
Data: Data filed size is variable. It contains user data
12
UDP applications
•Message oriented, e.g. SNMP, DNS, time
•File system, e.g. NFS, AFS
•Lightweight file transfer, e.g. tftp, bootp
13
Transmission Control Protocol -TCP
•RFC 768 & host requirements RFC 1122
–Reliable stream transport
•Connection oriented (full duplex virtual circuit)
–Conceptually place call, two ends communicate to agree on details
–After agreeing application notified of connection
–During transfer, ends communicate continuously to verify data received
correctly
–When done, ends tear down the connection
–If UDP is like regular mail, TCP is like phone call
•Provides buffering and flow control
•Takes care of lost packets, out of order, duplicates, long delays
•Isolates application program from network details
•Jargon
–Segment = TCP packet
–Socket= source (address + port) + destination (address + port)
14
TCP layering
•To ID connection need:
–Source: (address, port) AND Destination: (address, port)
–Only need one port on host to allow multiple connections, since
each connection will have different (host, port) at other end
•E.g. single host can serve multiple telnet connections
•Passive open: application contacts OS & indicates will
accept incoming connection, OS assigns port and listens
•Active open: application requests OS to connect to an (host,
port)
IP
Port 1
TCP UDP
Port 2Port 1Port 2
Demux on
IP protocol
Demux on
Port number
Network
Transport
App.
IP port 6
15
TCP –providing reliability
•Positive acknowledgement (ACK) with
retransmission
–Sender keeps record of each packet sent
–Sender awaits an ACK
–Sender starts timer when sends packet
Send pkt 1
Rcv ACK 1
Send pkt 2
Rcv ACK 2
Network messages
Rcv pkt 1
Rcv pkt 2
Send ACK 2
Send ACK 1
Sender siteReceiver site
Time
16
TCP –simple lost packet recovery
Send pkt 1
Start timer
ACK normally
arrives
Rcv ACK 1
Network messages
Pkt should arrive
Rcv pkt 1
Send ACK 1
ACK should be sent
Sender site Receiver site
Loss
Timer expires
Retransmit pkt 1
start timer
17
TCP –improving performance
•BUT simple ACK protocol wastes bandwidth since it must
delay sending next packet until it gets ACK
•Use sliding window
•Sender can send 4 packets of data without ACK
–When sender gets ACK then can send another packet
–Window = unacknowledged packets/bytes
–Keeps timer for each packet
12 3 4 5 6 7 8 …
Initial window of 4 packets
12 3 4 5 6 7 8 …
Window slides
Packets successfully sent
Packets sent, awaiting ACK
Packets to be sent
18
TCP flow control
•Windows vary over time
–Receiver advertises (in ACKs) how many it can receive
•Based on buffers etc. available
–Sender adjusts its window to match advertisement
–If receiver buffers fill, it sends smaller adverts
•Used to match buffer requirements of receiver
•Also used to address congestion control (e.g. in
intermediate routers)
19
TCP Segment format
Source/Dest port: TCP port numbers to ID applications at
both ends of connection. (Example: HTTP:port is 80,
Sequence number: ID position in sender’s byte stream
20
TCP segment format –cont.
•Sequence Number: Each byte in the stream that
TCP sends is numbered
•Egg: I have 10MB data divide into 1MB blocks and
give sequence number from 0 to 9
•Acknowledgement: identifies the sequence number
of the byte the sender of this segment expects to
receive next
•Header length: specifies the length of the segment
header in 32 bit multiples. If there are no options,
the Header length = 5 (20 bytes)
•Reservedfor future use, set to 0
21
TCP Segment format-cont
•ACK: ACK is set to 1 to indicate the
acknowledgement number valid ( whenever segment
reached destination)
•PSH: The received should pass this data to the
application as soon as possible (Push data to move
at application layer)
•RST: This flag is used to reset the connection. It is
also used to reject an invalid segment
•SYN: Synchronization sequence number to initiate a
connection.
The connection SYN=1 and ACK=0
22
TCP Segment format-cont
•The connection SYN=1 and ACK=0
•FIN: the FIN bit is used to release a connection. It
specifies that the sender is finished sending data
•Window size: it is specifies the number of bytes the
receiver is will to accept. This field can be used to
control the flow of data and congestion
•Checksum: Used for transport layer error detection
•Urgent pointer: if the URG bit flag is set , the
segment contains urgent data meaning the receiving
TCP entity must delivery to high layers immediately
23
TCP Segment format-cont
•Options: Size of this field is variable optional and
may used to provide other functions that are not
covered by header
•Egg: SACK, timestamps, maximum segment size
etc.
•Window: Advertises how much data this station is
willing to accept. Can depend on buffer space
remaining.
•Checksum: Verifies the integrity of the TCP header
and data. It is mandatory.
24
TCP Segment format-cont
•Urgent pointer: used with the URG flag to indicate
where the urgent data starts in the data stream.
Typically used with a file transfer abort during FTP
or when pressing an interrupt key in telnet.
it is valid if it’s set to 1 and any urgent data send by
sender
25
TCP close connection
•Modified 3 way handshake (or 4 way termination)
•App tells TCP to close, TCP sends remaining data & waits
for ACK, then sends FIN
•Site 2 TCP ACKs FIN, tells its application “end of data”
•Site 2 sends FIN when its app closes connection (may be
long delay (e.g. require human interaction).
(App closes)
Send FIN seq=x
Rcv ACK segment
Rcv FIN segment
Receive ACK segment
Send ACK x=1
(inform app)
Site 1 Site 2
Rcv FIN + ACK seg
Send ACK y+1
(app closes connection)
Send FIN seq=y, ACK x+1