Title: UNESCOCISM SECOND ADVANCED SCHOOL OF INFORMATICS UNESCO PROJECT Advanced Course on Networking TCPIP
1UNESCO/CISM SECOND ADVANCED SCHOOL OF
INFORMATICSUNESCO PROJECT Advanced Course on
Networking TCP/IP
2Content
- Internet Layer Protocols
- IP, ARP, RARP, ICMP.
- Transport Layer Protocols
- UDP
- TCP
- Applications
- DNS
- Some services
3TCP/IP Support Protocols
4IP Protocol
- Internet Prococol
- provides the packet delivery service for TCP, UDP
and ICMP - user processes do not normally explicitly
generate IP datagrams - Address Resolution Protocol maps an Internet
address into a hardware address - Reverse Address Resolution Protocol
- maps a hardware address into an Internet address.
5IP datagram structure
- an IP datagram consists of a header parts and a
text part - header has a 20 byte fixed part and a variable
length optional part - type of service field allows different
combinations of reliability and speed to be
chosen - for digital speech IP can be told to emphasize
fast delivery - for file transfer is taking IP can be told that
accuracy is paramount at the expense of speed.
6IP Datagram Fields
7IP Datagram Fields
- total length length of both header and data
- identification all fragments of a datagram
contain the same id value host can determine
which datagram an incoming fragment belongs - DF do not fragment
- MF more fragments (All fragments except last
one must have this bit set to true ) - Fragment offset must be a multiple of 8. Tells
receiver where this fragment belongs in the
datagram. - Time to live in seconds. Decrements each second
or each hop, when it reaches 0 it is thrown away
- Protocol field tells which of the various
transport processes the datagram belongs, ie.,
TCP or UDP - Header checksum verifies header only
- Source and destination address indicate the
network number
8IP addressing
- internet is a virtual structure
- implemented entirely in software
- packet frames and addresses were designed on
merit - addresses contained with 4 bytes
- conceptually the 32 bit number has two parts
- hostid
- netid
- three primary classes of IP addresses
9IP address classes
10IP address classes
- class A
- a handful of network which have more than 65536
hosts - class B
- addresses for intermediate size networks.
256..65535 hosts. 14 bits for netid 16 bits for
hostid - class C
- networks which have less than 256 hosts
- class D
- multicast, hosts may dynamically join/leave
multicast group - hosts may be in many different multicast groups
11Network structure
12Network structure
210.112.1.5
13Network and Broadcast addresses
- two reserved hosted-s
- Internet addresses can be used to refer to
networks as well as network cards. By convention
the network address has hostid all bits 0 - a broadcast address conversely has hostid bits
all 1 - one of the weakness of IP addressing is that if a
machine changes network - its IP address must
change
14Fragmentation and reassembly
- IP datagrams may be fragmented en route
- if intermediate nodes cannot cope with a large
datagram (MTU (maximum transmission unit) is
smaller than datagram size) - IP datagrams may be reassembled en route
- although not a good idea as routing is dynamic.
(So datagrams may not always travel the same
route) - to fragment a datagram into two a node creates
two new datagrams with same fragment ids - the first offset is 0, MF 1
- the second offset is n, MF 0
15Fragmentation and reassembly
- consider trying to send a 1420 byte datagram when
the MTU is 620 - 1420 1400 data 20 IP header
- split into 3 packets
- first packet length 620 20 new IP header
600 old data, offset 0 - second packet length 620 20 new IP header
600 old data, offset 600 - third packet length 220 20 new IP header
200 old data, offset 1200 - the new fragments have the same unique frag id as
the original why? - reassembly reverses this process
16IP Support Protocols
- ICMP (Internet Control Message Protocol)
- sends control information between the hosts
- routers generate most of this information
- routers use ICMP to
- inform hosts that a packet could not be delivered
because of an error - or a better route exists to a particular
destination - ICMP messages are send using IP frames
- ICMP messages use the IP protocol field and set
it to 1
17Typical ICMP messages are
- destination unreachable - when a router cannot
find a routing table entry for the destination of
an IP packet - routing redirect - a router sends a routing
redirect message to inform a host that a better
route exists via another router - time expired - message indicates a packets ttl
field has reached 0 - usually because of a configuration error
- malfunctioning router
- echo request and echo reply - echo request
messages request that the destination return the
data in an echo reply message (ping)
18Address Resolution Protocol
- IP address space is virtual and has no addressing
relationship with the underlying datalink
protocols - every network interface has an IP address
- every network interface has a datalink address
- datalink addresses vary in format and size
- suppose IP is sending a packet to a remote host
on the same Ethernet - IP needs destination Ethernet address
- could manually keep track of hosts and their
interface card datalink addresses
19Address Resolution Protocol
- clearly on a large network this becomes
unmanageable - ARP (Address Resolution Protocol) is an automatic
method which maps any network level address (IP
address) to datalink address - ARP does this by exploiting the broadcast
capability commonly found in most LAN datalink
protocols
20RARP (Reverse ARP)
- ARP maps from network addresses to datalink
addresses - sometimes you require the opposite mapping
- many machines can read their datalink hardware to
find out the datalink address - but then needs to find out its IP address
- for example, disk less workstation, X terminal,
printer
21RARP (Reverse ARP)
- at least one host on the IP network must contain
a list of IP addresses with corresponding
datalink addresses - whereas ARP does not require that this list is
present - a RARP is a broadcast request - any host may
reply - the sender fills in its datalink address
- its network address is filled with zeros
- specifies the target datalink address (normally
the same as sender) - the RARP server fills in the requested IP
(network) address - RARP is normally the first step taken when a
diskless workstation it powered up - once it knows its own IP address it can then
proceed to load its operating system from a
network server by using a simple file transfer
protocol (TFTP)
22Transport Layer Protocols
23Transport Layer Protocols
- 2 main protocols TCP UDP
- TCP transmission control protocol
- Connection oriented
- Reliable sequence of numbered segments
acknowledgments with any required
re-transmissions - Flow control sliding windows
- UDP user datagram protocol
- Connectionless
- Unreliable delivery of single segments
(datagrams) - Errors detected but not corrected (No acks)
24TCP/UDP analogies
- TCP as a telephone call
- Make a connection ring number
- Verifies connectivity
- Use connection communicate
- Reliability can you repeat that please?
- Flow control normal human courtesy
- Close connection receiver down
- UDP as a letter
- Write it, address it, post it, hope it gets there
25TCP vs UDP
- Relative merits
- TCP
- Reliable
- High network overheads
- Complex and large software
- UDP
- Unreliable (may not be a problem)
- Low network overheads
- Simple and small software
26When to use UDP
- Use TCP unless there is a reason for UDP
- Possible reasons to use UDP
- When the network efficiency is needed
- (SNMP)
- When the sw simplicity is needed
- (Bootstrap loading)
- When the reliability of TCP is counter-productive
(Stream audio/video)
27User Datagram Protocol (UDP)
- UDP and the TCP/IP layered model
- UDP message format
- UDP and encapsulation
- UDP checksum
28UDP And The TCP/IP Layered Model
29Multiplexing and Demultiplexing 1
30Multiplexing and Demultiplexing 2
31How Do We Allocate Port Numbers?
- Well known port numbers
- Dynamic binding
32Port numbers
- 0 to 255 public port numbers
- 256 to 1023 assigned to companies for
- their own marketable apps
- 1024 unregulated
33Examples of public ports
34UDP Message Format
35UDP and Encapsulation
36UDP Checksum
- Optional checksum calculated on
- UDP datagram
- UDP pseudo-header
- Does this violate layering?
37UDP Checksum
38Differences between TCP UDP
39Properties of a Reliable Delivery Service
- Stream Orientation Application just transfers a
stream of bytes - Virtual Circuit Connection Is TCP VC?
- Buffered Transfer TCP decides what size TCP
messages are, not user - Unstructured Stream There is no structure in
the stream of bytes as far as TCP is concerned - Full Duplex Connection Can transfer data in
both directions simultaneously and independently
40Positive Acknowledgement A Simple Example
41Positive Acknowledgement Packet Doesnt Arrive
42Positive Acknowledgement ACK Doesnt Arrive
43Round Trip Time (RTT)
44Round Trip Time (RTT)Estimate too low
45Round Trip Time (RTT)Estimate too high
46Sending Multiple Packets
- Receiver may not be able to process packets as
fast as they arrive - In fact ACKs serve at least 3 different purposes
- Recovery from lost packets
- Limit the rate at which sender can send packets
- Control congestion in the network
- Compromise solution is required
- The Sliding Window
47Sliding Windows Example
- Given a window size 6 packets
- A has sent packets 1 to 7
- A has received ACKs 1 to 4
48Sliding Windows ACK Received
- A receives ACK 5 and the window slides to the
right
49Sliding Windows Packet 8 sent
- A sends Packet 8 and the window remain unchanged
50Sliding Windows Packet 9 sent
- A sends Packet 9 and the window remain unchanged
51Sliding Windows Packet 6 ACK-ed
- A receives ACK for Packet 6 and the window slides
to the right
52Sliding Windows Packet 6 ACK-ed
- A sends packets 10, 11, and 12. No ACK received ?
no more packets can be sent.
53Sliding WindowsWindow size?
- Different protocols fix the window size in
different ways - Fixed by protocol specification
- Agreed when connection established
- Adjusted whilst connection in progress
- (Demo is given later)
54Sliding Windows Missing ACKs ?
- With just one outstanding ACK it was easy. If A
doesnt get an ACK it sends the packet again - With several ACKs outstanding it gets much more
complicated - What does A do when it detects a missing ACK?
- What does B do when it detects a missing packet?
- Different protocols use different solutions
55Sliding Windows Missing ACKs ?
- There are two extreme positions
- When something goes missing A resends every
packet starting with the first unacknowledged
packet. - This is called Go-Back-N.
- When something goes missing A B co-operate to
just resend those packets B hasnt received. - This is called Selective Retransmission.
56TCP Encapsulation
57TCP Header
58TCP Header Fields
- Source Port Port number of sender of segment
- Destination Port Port number of intended
recipient - Sequence Number TCP uses byte numbers not
packet numbers - Acknowledgement Number Number of the byte the
sender of this segment expects next - Window The size of the sliding window in bytes
- Checksum Just like the UDP checksum
- Control bits Special purpose bits
- Data User data
59 Usage of SEQ-ACK-WIN Fields Example
60TCP is Complicated
- RFC 793 is over 90 pages long but doesnt cover
everything - There are a number of additional RFCs covering
various aspects of TCP - There are a number of reference implementations
which have performance enhancing features - There is no single TCP specification
61Next TCP continues
- Establishing A TCP Connection
- Timeouts and Retransmission
- Congestion
- Closing A TCP Connection
62TCP Connections
- There are obviously two end points to a
connection - An end point is identified by a combination of
host IP address port number - One end point that initiates the connection. This
performs an active open - One end point that accepts the connection. This
performs a passive open - The passive open must occur before the active
open can succeed - The passive end point can support multiple
connections
63Establishing A TCP Connection
64Timeouts and Retransmission
- Selecting the correct value for the timeout is
crucial to efficiently implementing TCP.
65Round-Trip Time (RTT)
66Round-Trip Time (RTT)
- RTT varies according to
- Different hosts
- Different times of day
- Even from second to second
- If we need to retransmit then what is the RTT?
- Time from original transmission to receiving ACK
- Time from last retransmission to receiving ACK
67Measuring RTT Karns Algorithm
- Ignore retransmission when trying to estimate RTT
- Increase timeout value until transmission
succeeds - Then recalculate RTT when retransmission no
longer needed
68Estimating Timeout ValueOriginal Method
- rtt ALPHA rtt ( 1 ALPHA ) sample
- timeout BETA rtt
- 0 ALPHA
- BETA 1 typically 2
Last Measured value
69RTT trajectory using Karns Algorithm
70RTT Karns Algorithm
71Estimating Timeout Value Revised Method
- diff sample rtt
- rtt rtt DELTA diff
- dev dev RHO ( abs(diff) dev )
- timeout rtt ETA dev
- 0
- 0
- ETA 1 typically 3
72Slow-Start (Additive) Recovery
- When starting a new connection or increasing
traffic after congestion is over - congestion window one segment
- for each ACK received
- congestion window congestion window one
segment
73Multiplicative Decrease Congestion Avoidance
- Sender also maintains a congestion window
- If a segment is lost then
- congestion window MIN (congestion window/2 ,
one segment ) - allowed window MIN ( receive window, congestion
window ) - ? increase retransmission timer for all segments
in allowed window
74How does it work?
75How does it work?
Exponential Increase
Exponential Increase Increase CW with for each
received ACK
76How does it work?
Can be 64 Kbyte
Exponential Increase
77How does it work?
Linear Increase Increase CW with one for
each ACK-ed Window
Exponential Increase Increase CW with for each
received ACK
78How does it work?
Linear Increase
Probably due to loss or congestion
Exponential Increase
79Closing A TCP Connection
80Applications
- Naming and infrastructure
- there is a need for a mapping of textual domain
names to numeric IP addresses - difficult to remember 193.63.130.52 is the class
C address for floppsie! - also require services such as a consistent time
between different machines
81Domain Name Service (DNS)
- the Internet standard DNS maps host names, such
as floppsie.comp.glam.ac.uk to IP addresses such
as 193.63.130.52 - DNS namespace is partitioned hierarchically into
a tree - glam.ac.uk - may map onto several class C
networks - floppsie.comp - indicates a machine within the
computer studies network - an interface card on class C network
193.63.130.xx
82Naming and infrastructure
- we could have a simple lookup table that is
manually updated - soon becomes unmanageable
- use a dynamic mechanism, domain name service
- have a machine which will keep track of IP
addresses and ASCII names - if it cannot resolve a name it requests help from
another machine higher up the tree - the DNS protocol specifies how DNS clients ask
DNS servers for mappings - and how DNS servers communicate with each other.
83More Applications
- E-mail SMTP (MIME), POP3, IMAP
- FTP File Transfer Protocol
- Telnet Remote Login
- HTTP HyperText Transfer Protocol (WWW)
- NFS Network File System
- DHCP Dynamic Host Configuration Protocol