0% found this document useful (0 votes)
21 views6 pages

Lab Report 4

Uploaded by

Md Mohibullah
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
21 views6 pages

Lab Report 4

Uploaded by

Md Mohibullah
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 6

Green University of Bangladesh

Department of Computer Science and Engineering (CSE)


Semester: (Fall, Year: 2024), B.Sc. in CSE (Day)

Lab Report:04

Course Title: Computer Networking Lab


Course Code: CSE-312
Section:221-D17
Students Details
Name ID
Md. Kajol Sarker 221902165

Submission Date: 03/12/2024


Course Teacher’s Name: Mohammad Ehsan Shahmi Chowdhury

[For teachers use only: Don’t write anything inside this box]

Lab Report Status

Marks: Signature:

Comments: Date:
1 TITLE OF THE LAB REPORT EXPERIMENT
TCP Congestion Control Using TCP Tahoe.

TCP Tahoe is a congestion control algorithm designed to manage data transmission


in networks by dynamically adjusting the sender’s transmission rate based on perceived
network congestion. It achieves this using three main phases: Slow Start, Congestion
Avoidance, and Fast Recovery, ensuring reliable and efficient data delivery. Unlike
other protocols, TCP Tahoe responds to congestion by resetting its congestion window
(cwnd) to 1 MSS and resuming transmission from the Slow Start phase, promoting
network stability. This report explores the complete concept of TCP congestion control
and demonstrates its implementation in Java.

2 OBJECTIVES
• To understand the principles of TCP congestion control and its impact on reliable
data transmission.

• To explore the differences between TCP Tahoe and other variants like TCP Reno.

• To implement TCP Tahoe in Java, simulating network behavior under varying


conditions.

• To analyze the role of Slow Start, Congestion Avoidance, and Fast Recovery
phases in controlling congestion.

• To evaluate TCP Tahoe’s effectiveness in maintaining stability and fairness in


network usage.

3 PROCEDURE
1. Understanding TCP Congestion Control:

• Learn the fundamental concepts of TCP, focusing on how it ensures reliable,


error-free data delivery.
• Study the key variables, such as cwnd (congestion window) and ssthresh
(slow start threshold).

2. Analyze the Phases of TCP Tahoe:

• Slow Start: Begin with a small cwnd and double it with each acknowledg-
ment to explore available bandwidth.
• Congestion Avoidance: After reaching ssthresh, increment cwnd linearly
to prevent congestion.
• Fast Recovery: Reset cwnd to 1 MSS upon detecting congestion and re-
sume from Slow Start.

1
3. Implementation in Java:

• Write Java code for TCP Tahoe, incorporating random congestion simula-
tions.
• Implement methods for congestion detection, adjustment of cwnd, and phase
transitions.

4. Testing and Output Validation:

• Simulate different scenarios with varying initial values of ssthresh and


data sizes.
• Analyze the behavior of the program during Slow Start, Congestion Avoid-
ance, and Fast Recovery.

4 IMPLEMENTATION
package tcpcongestioncontrol;
import java.util.Random;
import java.util.Scanner;

public class TCPTahoe {


private int cwnd; // Congestion Window
private int ssthresh; // Slow Start Threshold
private boolean congestion; // Congestion state flag

public TCPTahoe(int initialSsthresh) {


cwnd = 1; // Start with 1 MSS
ssthresh = initialSsthresh;
congestion = false; // No congestion initially
}

public void run() {


System.out.println("Connected to the Server...");
System.out.println("Enter the total length of the data to send: ");
Scanner scan = new Scanner(System.in);
int totalData = scan.nextInt();

int dataSent = 0;
int round = 0;

while (dataSent < totalData) {


round++;
System.out.println("\nRound " + round + ": Sending data...");
System.out.println("Current cwnd: " + cwnd + " | ssthresh: " + ssthresh

// Send packets and simulate acknowledgment or congestion


if (!sendPackets()) {

2
handleCongestion();
} else {
// If no congestion, adjust cwnd
if (cwnd < ssthresh) {
// Slow Start: Exponential growth
cwnd *= 2;
System.out.println("Slow Start Phase: cwnd doubled to " + cwnd)
} else {
// Congestion Avoidance: Linear growth
cwnd += 1;
System.out.println("Congestion Avoidance Phase: cwnd increased
}
}

// Update data sent


dataSent += cwnd;
System.out.println("Total data sent so far: " + dataSent + " bytes");
}

System.out.println("\nData transmission complete in " + round + " rounds.")


}

private boolean sendPackets() {


// Simulate random congestion detection
Random random = new Random();
return random.nextBoolean(); // 50% chance of congestion
}

private void handleCongestion() {


System.out.println("Congestion detected! Adjusting parameters...");
// Reduce ssthresh to half of the current cwnd
ssthresh = Math.max(cwnd / 2, 1);
System.out.println("New ssthresh: " + ssthresh);

// Reset cwnd to 1 (restart Slow Start)


cwnd = 1;
System.out.println("Restarting Slow Start: cwnd reset to " + cwnd);
}

public static void main(String[] args) {


Scanner scanner = new Scanner(System.in);
System.out.print("Enter the initial ssthresh value: ");
int initialSsthresh = scanner.nextInt();

TCPTahoe tcpTahoe = new TCPTahoe(initialSsthresh);


tcpTahoe.run();
}
}

3
5 TEST RESULT / OUTPUT

Figure 1: TCP Tahoe Congestion Window Behavior During Slow Start

Figure 2: TCP Tahoe Congestion Window Transition After Congestion Detection

4
Figure 3: Overall TCP Tahoe Sawtooth Behavior

6 ANALYSIS AND DISCUSSION


TCP Tahoe’s behavior is driven by a systematic response to network congestion. Dur-
ing the Slow Start phase, the exponential increase in the congestion window allows
rapid utilization of available bandwidth. However, as cwnd grows larger, the proto-
col transitions to Congestion Avoidance, employing a linear growth strategy to prevent
oversaturation. When congestion is detected, TCP Tahoe resets cwnd to 1 MSS, ensur-
ing the network recovers without additional pressure. This conservative approach may
reduce transmission efficiency temporarily, but it guarantees stability in the long term.
By combining these mechanisms, TCP Tahoe maintains a balance between throughput
and fairness across multiple connections

7 SUMMARY:
TCP Tahoe is a foundational congestion control algorithm that effectively manages net-
work traffic under varying conditions. It balances efficiency and fairness through its
three phases, ensuring reliable data delivery even in congested networks.By resetting
cwnd during congestion and gradually increasing the transmission rate, TCP Tahoe
promotes stable network operation. Its simplicity and adaptability make it a critical
component of modern TCP implementations.

You might also like