Professional Documents
Culture Documents
Chapter - 2 Advanced Congestion Control Algorithms
Chapter - 2 Advanced Congestion Control Algorithms
2
Internet Protocol (IP)
3
Transport services and protocols
provide logical communication application
transport
between app processes running network
data link
on different hosts physical
network
data link
network physical
transport protocols run in end data link
physical
systems network
data link
sender side: breaks app physical network
data link
messages into segments, physical
4
Internet transport-layer protocols
Two end-to-end transport protocols
5
Internet transport protocols services
8
Connectionless demultiplexing…
DatagramSocket serverSocket =
new DatagramSocket(6428);
9157 6428 5775
P3 P1
P2
P1
9
Connection-oriented demux
TCP socket identified by Server host may support
4-tuple: many simultaneous TCP
source IP address sockets:
source port number each socket identified by its
dest IP address own 4-tuple
dest port number Web servers have
receiver host uses all different sockets for each
four values to direct connecting client
segment to appropriate
socket
10
Connection-oriented demux…
P1 P4 P5 P6 P2 P1P3
SP: 5775
DP: 80
S-IP: B
D-IP:C
11
Connection-oriented demux:
Threaded Web Server
P1 P4 P2 P1P3
SP: 5775
DP: 80
S-IP: B
D-IP:C
12
Connectionless vs connection-oriented
Mailbox(es) Socket(s)
15
some of the well-known ports used by UDP (see www.iana.org for
a complete list)
Port Protocol Description
7 Echo Echoes a received datagram back to the sender
9 Discard Discards any datagram that is received
11 Users Active users
13 Daytime Returns the date and the time
17 Quote Returns a quote of the day
19 Chargen Returns a string of characters
53 DNS Domain Name Service
67 Bootps Server port to download bootstrap information
68 Bootpc Client port to download bootstrap information
69 TFTP Trivial File Transfer Protocol
111 RPC Remote Procedure Call
123 NTP Network Time Protocol
161 SNMP Simple Network Management Protocol
162 SNMP Simple Network Management Protocol (trap)
16
Transmission Control Protocol (TCP)
17
Window Based Flow Control
Sliding window protocol
Window size minimum of
receiver’s advertised window - determined by
available buffer space at the receiver
congestion window - determined by the sender,
based on feedback from the network
Sender’s window
1 2 3 4 5 6 7 8 9 10 11 12 13
18
Window Based Flow Control
Sender’s window
1 2 3 4 5 6 7 8 9 10 11 12 13
Ack 5
1 2 3 4 5 6 7 8 9 10 11 12 13
Sender’s window
19
TCP: Overview RFCs: 793, 1122, 1323, 2018, 2581
22
TCP seq. #’s and ACKs
Seq. #’s: Host A Host B
byte stream User
“number” of first types
byte in segment’s ‘C’
host ACKs
data receipt of
‘C’, echoes
ACKs:
back ‘C’
seq # of next byte
expected from other
host ACKs
side receipt
cumulative ACK of echoed
‘C’
Q: how receiver handles
out-of-order segments
A: TCP spec doesn’t time
say, - up to
implementor
23
TCP Round Trip Time and Timeout
Q: how to set TCP Q: how to estimate RTT?
timeout value?
SampleRTT: measured time
It should be longer from segment transmission
than RTT until ACK receipt
If too short: ignore retransmissions
premature timeout SampleRTT will vary
• unnecessary
Average of several recent
retransmissions
measurements, not just
If too long:
current SampleRTT
slow reaction to
segment loss
24
Retransmission Time Out (RTO) estimation
Until an RTT measurement has been made for a segment
sent, the TCP sender should set RTO to three seconds
(G).
When the first RTT measurement R is made, the sender
must set:
SRTT = R, and RTTVAR = R/2
RTO = SRTT + max (G, K · RTTVAR), where K = 4
When a subsequent RTT measurement R’ is made, the
sender must update the variables as follows:
RTTVAR = (1 −β) · RTTVAR + β · |SRTT − R’ |
SRTT = (1 − α) · SRTT + α · R’
26
TCP Three phase handshaking:
connection establishment
client server
send ACK
ack=y+1
27
TCP Connection Management (cont.)
close
client closes socket:
clientSocket.close();
close
Step 1: client sends TCP FIN
control segment to server
timed wait
Step 2: server receives FIN,
replies with ACK. Closes
connection, sends FIN.
closed
28
TCP Connection Management (cont.)
closed
29
TCP reliable data transfer
TCP creates rdt service At the sender side:
on top of IP’s unreliable Reception of 3 DUPACKs
service mean, network is
Uses sliding window congested. (Sender enters
protocol fast recovery and fast
Cumulative acks retransmission phases)
TCP uses single Expiration of RTO means,
retransmission timer network is severely
Retransmissions are congested.(Sender enters to
triggered by: slow start phase)
Timeout (RTO) events
Three duplicate acks
30
Flow and congestion control
TCP is a window-based flow and congestion
control protocol.
31
Flow and congestion control
32
Connection control
The TCP sender is Note
limited by both AWND AWND is used to prevent
and CWND. the sender from
The sending window overrunning the
size of the sender is resources of the receiver.
taken as being the CWND is to prevent the
minimum of the AWND sender from sending
and the CWND. more data than the
network can
W = min (CWND, AWND) accommodate in the
current load conditions.
33
Principles of Congestion Control
Congestion:
informally: “too many sources sending too much data
too fast for network to handle”
different from flow control
manifestations:
lost packets (buffer overflow at routers)
long delays (queuing in router buffers)
34
TCP’s Congestion Control mechanisms
Has four phases:
Slow start,
Congestion
avoidance,
Fast retransmit and
Fast recovery.
Congestion
Slow start
avoidance
35
TCP Slow Start
36
TCP Slow Start (more)
RTT
loss event:
double CongWin every
RTT
done by incrementing
CongWin for every ACK
received
Summary: initial rate is
slow but ramps up
exponentially fast time
37
Congestion avoidance phase
TCP S TCP R
T1 T2 = 2 * T1
Time-out occurs
before ack received,
packet retransmitted
39
Detecting Packet Loss Using Dupacks:
Fast Retransmit Mechanism
Dupacks may be generated due to
packet loss, or
out-of-order packet delivery
41
TCP congestion control algorithm:
Example
Given:
• MSS (Maximum Segment Size) = 1024 byte
• Initially congestion window size(CWND)= 1kbyte at time 0
• The CWND then grows exponentially till it reaches the
threshold (16kbyte). (Slow start)
• Starting then, it grows linearly (congestion avoidance ) till it
reaches to 24 Kbyte. (Packet loss detected)
• At time 9, a timeout occurs.
42
TCP’s Congestion Control alg: Expiration of RTO
24
22
Congestion window size (CWND)
20
18 threshold
16
14 threshold
12
10
8
6
4
2
0
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17
Time 43
TCP’s Congestion Control alg: 3 DUPACKs
24
22
Congestion window size (CWND)
20
18 threshold
16
14
threshold
12
10
8
6
4
2
0
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17
Time 44
TCP and High Speed Networks
High Speed Networks (HSN) with the most up-to-date
networking technologies are currently being deployed to
support
a large variety of new scientific applications.
an increasing demand for high-speed Internet access and
bandwidth consuming applications.
46
High-Speed Applications
High-Speed Applications
Weather Simulation Video Conference Telemedicine
Transport Protocols
be able to transfer a large amount of data
over a long distance within a short amount of time
High-Speed Networks
47
What is High Speed TCP?
Changes the way TCP behaves at high speed
(ie large cwnd)
49
Why high-speed TCP?
The problem is that TCP increases its rate too slowly,
and decreases it too fast.
High-speed TCP algorithms tried to get around this
problem.
Goals of high-speed TCPs
Rapidly increase the data rate and maintain a high data
rate.
Be fair with normal TCP (e.g. RENO)
• This is especially required when sharing congested links.
• We cannot have two protocol stacks, one for congested
networks and one for uncongested networks.
Designed as minimal change to TCP to allow use of
high-bandwidth paths.
50
TCP Congestion Control
The instantaneous throughput of TCP is controlled by a variable cwnd,
TCP transmits approximately a cwnd number of packets per RTT
(Round-Trip Time).
53
Response Function of TCP
Response function of TCP is the average throughput of a TCP
connection in terms of the packet loss probability, the packet size,
and the round-trip time.
54
Proposed High-Speed Protocols
Window-Based Protocols
AIMD (Additive Increase Multiplicative Decrease)
• Jumbo Frame, GridFTP, PFTP, PSockets
HSTCP (High-Speed TCP) by Sally Floyd at ICIR, Berkeley
STCP (Scalable TCP) by Tom Kelly at Cambridge University
FAST (Fast AQM Scalable TCP) by Steven Low at California
Institute of Technology
Rate-Based Protocols
SABUL (Simple Available Bandwidth Utilization Library ) by
Robert Grossman at University of Illinois at Chicago
57
Scalable TCP
• Very simple modifications to TCP algorithms.
• For cwnd lwnd, use the traditional window update
algorithm.
• For cwnd > lwnd,
• Increase Function : for each ack, cwnd = cwnd +
[0.01 * cwnd]
• Decrease Function : for each loss, cwnd = cwnd -
0.125 * cwnd
• lwnd chosen to be 16 corresponding to the drop
probability of 5.86 * 10-3
• This response function is effectively MIMD.
58
STCP (Scalable TCP)
STCP adaptively increases cwnd, and decreases cwnd by 1/8.
TCP Response Function for Standard TCP TCP Response Function for Highspeed TCP
61
BIC (Binary Increase Congestion control)
62
BIC (Binary Increase Congestion control)
BIC adaptively increase cwnd, and decrease cwnd by 1/8
64
Processes Communication Using Socket
65
Elements of Client-Server
Computing/Communication
a client, a server, and network
network
client
server
• Processes follow protocols that define a set of rules that must be observed
by participants:
– How the data exchange is encoded?
– How events (sending, receiving) are synchronized (ordered) so that participants
66 can send and receive data in a coordinated manner?
Sockets
• process sends/receives host or
client
host or
server
messages to/from its socket
• socket analogous to door
controlled by
app developer
process process
– sending process gives message
out door socket socket
TCP with TCP with
– sending process relies on Internet buffers,
buffers,
transport infrastructure on variables variables
other side of door which brings
message to socket at receiving
process controlled
by OS
67
Addressing processes
• to receive messages, • identifier includes both IP
process must have address and port numbers
identifier associated with process on
• host device has unique host.
32-bit IP address • Example port numbers:
• Q: does IP address of – HTTP server: 80
host on which process – Mail server: 25
runs suffice for identifying
• to send HTTP message to a
the process?
web server with IP
– A: No, many processes address:217.110.45.12, we
can be running on same use:
host
– 217.110.45.12:80 68
Socket Addresses
69
Some of the well-known ports used by TCP and UDP
Port Protocol Description
7 Echo Echoes a received datagram back to the sender
9 Discard Discards any datagram that is received
11 Users Active users
13 Daytime Returns the date and the time
17 Quote Returns a quote of the day
19 Chargen Returns a string of characters
20 FTP, Data File Transfer Protocol (data connection)
21 FTP, Control File Transfer Protocol (control connection)
23 TELNET Terminal Network
25 SMTP Simple Mail Transfer Protocol
53 DNS Domain Name Server
67 BOOTP Bootstrap Protocol
79 Finger Lookup information about a user
80 HTTP Hypertext Transfer Protocol
111 70 RPC Remote Procedure Call
Java Sockets Java’s .net package
provides two classes:
Server ServerSocket(1234) Socket – for
implementing a client
ServerSocket – for
implementing a server
Input/read stream
Socket(“128.250.22.134”, 1234)
71
It can be host_name like “hen.aait.edu.et”
Socket programming
Goal: learn how to build client/server application that communicate using
sockets
Socket API
socket
• introduced in BSD4.1 UNIX,
1981 a host-local,
application-created,
• explicitly created, used, released OS-controlled interface (a
by apps “door”) into which
• client/server paradigm application process can
both send and
• two types of transport service receive messages to/from
via socket API: another application process
– reliable, byte stream-oriented
TCP
– unreliable datagram UDP
72
Socket programming using TCP
Client must contact server
• server process must first be running
• server must create socket (door) that welcomes client’s contact
Server Client
(running on hostid)
create socket,
port=x, for
incoming request:
ServerSocket servSock =new
ServerSocket(x)
write reply to
servSock read reply from
clientSocket
close
servSock
close
clientSocket 74
Stream terminology
keyboard monitor
• A stream is a sequence of
characters that flow into or out
inFromUser
of a process. input
stream
Client
Process
process
• An input stream is attached to
some input source for the
process, e.g., keyboard or
socket.
inFromServer
outToServer
output input
stream stream
75
Introducing the java.net Package
76
Main classes in java.net
77
Implementing a Server
1. Open the Server Socket:
ServerSocket server;
DataOutputStream os;
DataInputStream is;
server = new ServerSocket(PORT);
2. Wait for the Client Request:
Socket client = server.accept();
3. Create I/O streams for communicating to the client
is = new DataInputStream(
client.getInputStream() );
os = new DataOutputStream(
client.getOutputStream() );
4. Perform communication with client
Receive from client: String line =
is.readLine();
Send to client: os.println("Hello\n");
5. Close sockets: 78
client.close();
Implementing a Server
For multithreaded server:
while(true) {
i. wait for client requests (step 2 above)
ii. create a thread with “client” socket as parameter
(the thread creates streams (as in step (3) and does
communication as stated in (4).
Remove thread once service is provided.
}
79
Implementing a Client
1. Create a Socket Object:
client = new Socket( server, port_id );
2. Create I/O streams for communicating with the server.
is = new DataInputStream(client.getInputStream() );
os = new DataOutputStream( client.getOutputStream() );
3. Perform I/O or communication with the server:
– Receive data from the server:
String line = is.readLine();
– Send data to the server:
os.println("Hello\n");
4. Close the socket when done:
client.close(); 80
Server-Socket programming
• The java.net package provides ServerSocket and
DatagramSocket objects for servers at the TCP/IP
socket level.
ListenSocket Method
The listenSocket method creates a ServerSocket
object with port number on which the server
program is going to listen for client
communications.
82
Server-Socket Programming cont’d…
84
Server-Socket Programming cont’d…
Socket link=null;
try
{
link = servSock.accept();
}
catch(IOException e)
{
System.out.println("Accept failed: 1234");
}
85
Server-Socket Programming cont’d…
86
Server-Socket Programming cont’d…
Lastly, the listenSocket method loops on the input stream to
read data as it comes in from the client and writes to the output
stream to send the data back.
int numMessages = 0;
String message = in.readLine();
while (!message.equals("close")) {
System.out.println("Message received.");
numMessages++;
out.println("Message " + numMessages + ": " +
message);
message = in.readLine();
}
87
Lab: Server -Socket source code
import java.io.*;
import java.net.*;
public class Server {
private static ServerSocket servSock;
private static final int PORT=1234;
public static void main(String[] args)
throws IOException {
System.out.println("Openning port.....");
while(true)
{
listenSocket();
}
}
88
Lab: Server-Socket source code …
public static void listenSocket() {
try {
Create servSock=new ServerSocket(PORT);
server socket
at port 1234 } catch(IOException e) {
System.out.println("Unable to create
socket with port no:1234!");
System.exit(-1); }
Socket link=null;
try {
Create socket
connection
link=servSock.accept();
with the client } catch(IOException e){
System.out.println("Accept failed:
Port 1234");
89
}
Lab: Server-Socket source code …
try {
Create input BufferedReader in=new BufferedReader(new
stream, attached InputStreamReader(link.getInputStream(
to socket
)));
catch(IOException e)
{
System.out.println("Message is not
recieved");
End of while loop,
loop back and wait for }
another client connection
}
} 91
Client-Socket Programming
92
Client-Socket Programming cont’d…
93
Client-Socket Programming cont’d…
listenSocket Method
The listenSocket method first creates a Socket object
with the IP address (“local host”) and port number (1234)
where the server program is listening for client connection
requests.
Socket link= new Socket(host,PORT);
Lastly, it receives the input text sent back to it by the server and
prints the streams out.
String message, response;
do {
System.out.print("Enter message:");
message=userentry.readLine();
out.println(message);
response=in.readLine();
System.out.println("\nSERVER>" + response);
} while(!message.equals("close"));
96
Lab: Client-Socket Programming
import java.io.*;
import java.net.*;
public class Client {
private static InetAddress host;
private static final int PORT=1234;
public static void main(String[] args) throws
IOException {
Server is try {
local host=InetAddress.getLocalHost();
}
catch(UnknownHostException e)
{
System.out.println("Host id not found!");
System.exit(-1);
}
listenSocket();
}
97
Lab: Client-Socket Programming
public static void listenSocket() {
Socket link=null;
Create try {
client socket, link=new Socket(host,PORT);}
connect to server
catch(IOException e){
System.out.println("Unable to connect");
System.exit(-1);}
Create
try {
input stream
attached to socket BufferedReader in=new BufferedReader(new
InputStreamReader(link.getInputStream()));
Create PrintWriter out=new
output stream PrintWriter(link.getOutputStream(),true);
attached to socket