Download Introduction to networking, protocol layers, TCP/IP protocol suite

Document related concepts

Parallel port wikipedia , lookup

Piggybacking (Internet access) wikipedia , lookup

Airborne Networking wikipedia , lookup

Network tap wikipedia , lookup

Distributed firewall wikipedia , lookup

SIP extensions for the IP Multimedia Subsystem wikipedia , lookup

Point-to-Point Protocol over Ethernet wikipedia , lookup

AppleTalk wikipedia , lookup

Computer network wikipedia , lookup

Multiprotocol Label Switching wikipedia , lookup

Asynchronous Transfer Mode wikipedia , lookup

Serial digital interface wikipedia , lookup

Net bias wikipedia , lookup

RapidIO wikipedia , lookup

I²C wikipedia , lookup

IEEE 1355 wikipedia , lookup

Wake-on-LAN wikipedia , lookup

Deep packet inspection wikipedia , lookup

Zero-configuration networking wikipedia , lookup

Recursive InterNetwork Architecture (RINA) wikipedia , lookup

UniPro protocol stack wikipedia , lookup

Internet protocol suite wikipedia , lookup

Real-Time Messaging Protocol wikipedia , lookup

Cracking of wireless networks wikipedia , lookup

TCP congestion control wikipedia , lookup

Transcript
UNESCO/CISM SECOND ADVANCED
SCHOOL OF INFORMATICS
UNESCO PROJECT
Advanced Course on Networking
TCP/IP
Content

Internet Layer Protocols


Transport Layer Protocols



IP, ARP, RARP, ICMP.
UDP
TCP
Applications


DNS
Some services
TCP/IP Support Protocols
IP 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.
IP 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.
IP Datagram Fields
IP 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
IP addressing

internet is a virtual structure



addresses contained with 4 bytes




implemented entirely in software
packet frames and addresses were designed on
merit
conceptually the 32 bit number has two parts
hostid
netid
three primary classes of IP addresses
IP address classes
IP address classes

class A


class B


addresses for intermediate size networks. 256..65535 hosts.
14 bits for netid 16 bits for hostid
class C


a handful of network which have more than 65536 hosts
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
Network structure
Network structure
210.112.1.5
Network 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
Fragmentation and reassembly

IP datagrams may be fragmented en route


IP datagrams may be reassembled en route


if intermediate nodes cannot cope with a large datagram
(MTU (maximum transmission unit) is smaller than
datagram size)
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
Fragmentation and reassembly

consider trying to send a 1420 byte datagram when
the MTU is 620


split into 3 packets





1420 = 1400 data + 20 IP header
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
IP Support Protocols

ICMP (Internet Control Message Protocol)



routers use ICMP to



sends control information between the hosts
routers generate most of this information
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
Typical 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)
Address 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
Address 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
RARP (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
RARP (Reverse ARP)

at least one host on the IP network must contain a list of IP
addresses with corresponding datalink addresses



the sender fills in its datalink address




whereas ARP does not require that this list is present
a RARP is a broadcast request - any host may reply
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)
Transport Layer Protocols
TCP and UDP
Transport Layer Protocols


2 main protocols TCP & UDP
TCP – transmission control protocol




Connection oriented
Reliable –sequence of numbered segments &
acknowledgments with any required retransmissions
Flow control – sliding windows
UDP – user datagram protocol



Connectionless
Unreliable delivery of single segments
(datagrams)
Errors detected but not corrected (No acks)
TCP/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
there
it, address it, post it, hope it gets
TCP 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
When 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 counterproductive (Stream audio/video)
User Datagram Protocol (UDP)
UDP and the TCP/IP layered model
 UDP message format
 UDP and encapsulation
 UDP checksum

UDP And The TCP/IP Layered
Model
Conceptual Layer
UDP belongs
here
Objects Passed
Between Layers
Application
Messages or Streams
Transport
Transport Protocol Packets
Internet
IP Datagrams
Network Interface
Network-Specific Frames
Hardware
Multiplexing and Demultiplexing –
1
UDP
TCP
Other Protocols
Transport
IP Module
Interface 1
Network Interface
Interface 2
Interface 3
Multiplexing and Demultiplexing –
2
Port #1
......
Port #2
Demultiplexing based on
Port Number
UDP Datagram
Arrives
Port #65535
How Do We Allocate Port
Numbers?
Well known port numbers
 Dynamic binding

Port numbers
0 to 255
 256 to 1023



1024+
public port numbers
assigned to companies for
their own marketable apps
unregulated
Examples of public ports
UDP Message Format
UDP
Header
UDP
Data Area
UDP Source Port
UDP Destination Port
UDP Message Length
UDP Checksum
UDP and Encapsulation
UDP
Header
IP
Header
Frame
Header
UDP
Data Area
IP
Data Area
Frame
Data Area
UDP Checksum

Optional checksum calculated on
 UDP
datagram
 UDP pseudo-header
Source IP Address
Destination IP Address
Zero
 Does
Protocol
UDP Length
this violate layering?
UDP Checksum
Compute Checksum on all this
Pseudo Header
Not Sent
UDP Header
Sent as IP Data
UDP Data
Differences between TCP &
UDP
Feature
UDP
TCP
Analogy
Letter Post
Phone Call
Connection Phase
None
Yes
Messages
Individual, unrelated
Sequence
Lost Message
User has to deal with
loss
Protocol tries to
recover
Message Order
Maintained?
No
Yes
Disconnection Phase
No
Yes
Duplicate Messages
Maybe
No
Complexity
Low
High
Properties 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
Positive Acknowledgement
A Simple Example
A
Packet (1)
ACK(1)
B
Process Packet (1)
Packet (2)
ACK(2)
Process Packet (2)
Positive Acknowledgement
Packet Doesn’t Arrive
A
Start Timer
B
Packet (1)
Timer Expires
Start Timer
Packet (1)
ACK(1)
Stop Timer
Process Packet (1)
Positive Acknowledgement
ACK Doesn’t Arrive
A
Start Timer
B
Packet (1)
ACK(1)
Process Packet (1)
Timer Expires
Start Timer
Packet (1)
ACK(1)
Stop Timer
Discard Packet (1)
Round Trip Time (RTT)
A
B
Packet(1)
Round Trip Time
ACK(1)
Process Packet(1)
Round Trip Time (RTT)
Estimate too low
A
B
Packet(1)
Estimated Round
Trip Time
Process Packet(1)
Packet(1)
ACK(1)
Round Trip Time (RTT)
Estimate too high
A
B
Packet(1)
Estimated Round
Trip Time
Packet(1)
Sending Multiple Packets


Receiver may not be able to process packets
as fast as they arrive
In fact ACK’s 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
Sliding Windows – Example



Given a window size = 6 packets
A has sent packets 1 to 7
A has received ACK’s 1 to 4
Window Size = 6
1
2
Sent &
Acked
3
4
5
6
Sent not
Acked
7
8
9
10
Could be
sent
11
12
13
Can not be
sent yet
...
Sliding Windows
ACK Received

A receives ACK 5 and the window
slides to the right
Window Size = 6
1
2
Sent &
Acked
3
4
5
6
7
Sent
not
Acked
8
9
10
Could be
sent
11
12
13
...
Can not
be sent
Sliding Windows
Packet 8 sent

A sends Packet 8 and the window
remain unchanged
Window Size = 6
1
2
Sent &
Acked
3
4
5
6
7
Sent
not
Acked
8
9
10
11
Could be
sent
12
13
...
Can not
be sent
Sliding Windows
Packet 9 sent

A sends Packet 9 and the window
remain unchanged
Window Size = 6
1
2
Sent &
Acked
3
4
5
6
7
8
Sent
not
Acked
9
10
11
Could
be sent
12
13
...
Can not
be sent
Sliding Windows
Packet 6 ACK-ed

A receives ACK for Packet 6 and the
window slides to the right
Window Size = 6
…
3
Sent &
Acked
4
5
6
7
8
Sent
not
Acked
9
10
11
12
Could be
sent
13
14
...
Can not
be sent
Sliding Windows
Packet 6 ACK-ed

A sends packets 10, 11, and 12. No ACK
received  no more packets can be
sent.
Window Size = 6
…
3
Sent &
Acked
4
5
6
7
8
9
10
11
Sent not Acked
12
13
14
...
Can not
be sent
Sliding Windows
Window 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)
Sliding Windows
Missing ACK’s ?





With just one outstanding ACK it was easy. If
A doesn’t get an ACK it sends the packet
again
With several ACK’s 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
Sliding Windows
Missing ACK’s ?

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 cooperate to just resend those packets B
hasn’t received.
This is called Selective Retransmission.
TCP Encapsulation
TCP
Header
IP
Header
TCP
Data Area
IP
Data Area
TCP Header
TCP 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
Usage of SEQ-ACK-WIN Fields
Example
TCP is Complicated
RFC 793 is over 90 pages long – but
doesn’t cover everything
 There are a number of additional RFC’s
covering various aspects of TCP
 There are a number of “reference
implementations” which have
performance enhancing features
 There is no single TCP specification

Next : TCP continues
Establishing A TCP Connection
 Timeouts and Retransmission
 Congestion
 Closing A TCP Connection

TCP 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
Establishing A TCP Connection
Timeouts and
Retransmission

Selecting the correct value for the
timeout is crucial to efficiently
implementing TCP.
A
Start Timer
B
Data
ACK
Timer Expires
Round-Trip Time (RTT)
800
700
600
RTT for datagram
18 was 3751
RTT for datagram
50 was 1124
500
400
300
200
100
0
0
10
20
30
40
50
60
70
80
90
100
Round-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
Measuring RTT: Karn’s
Algorithm
Ignore retransmission when trying to
estimate RTT
 Increase timeout value until
transmission succeeds
 Then recalculate RTT when
retransmission no longer needed

Estimating Timeout Value
Original Method
rtt = ALPHA * rtt + ( 1 – ALPHA ) * sample
timeout = BETA * rtt
New
0 ≤ ALPHA < 1
BETA > 1
Old
typically 0.9
typically 2
Last Measured value
RTT trajectory using Karn’s
Algorithm
800
700
600
alpha = 0.9
500
400
300
200
100
0
1
21
41
61
81
RTT: Karn’s Algorithm
800
800
700
700
600
600
RTT for datagram
18 was 3751
RTT for datagram
50 was 1124
alpha = 0.9
500
500
400
400
300
300
200
200
100
100
0
0
0
10
20
30
40
50
60
70
80
90
100
1
21
41
61
81
Estimating Timeout Value
Revised Method
diff = sample – rtt
rtt = rtt + DELTA * diff
dev = dev + RHO * ( abs(diff) – dev )
timeout = rtt + ETA * dev
0 < DELTA < 1
0 < RHO < 1
ETA ≥ 1
typically ⅛
typically ¼
typically 3
Slow-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
Multiplicative 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
How does it work?
How does it work?
Exponential
Increase :
Increase CW
with for each
received ACK
How does it work?
Can be 64 Kbyte
Exponential
Increase
How does it work?
Linear Increase : Increase CW with one for
each ACKed Window
Exponential
Increase :
Increase CW
with for each
received ACK
How does it work?
Linear
Increase
Exponential
Increase
Probably due to
loss or congestion
Closing A TCP Connection
A
B
FIN seq = x
ACK x+1
Applications

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
Domain 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
Naming 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.
More 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
