Title | 1816413052 Exp2 - Grade: 9 |
---|---|
Course | Understanding Self for Effectiveness |
Institution | Amity University |
Pages | 9 |
File Size | 207.7 KB |
File Type | |
Total Downloads | 63 |
Total Views | 139 |
BETTER...
EXPERIMENT 2 OBJECTIVE: Implementation of Stop and Wait Protocol and Sliding Window Protocol. STOP AND WAIT PROTOCOL: DESCRIPTION: • The frame is sent one-by-one to the Receiver(Server) from the Sender(Client) side. • Acknowledgment is sent from Server to the Client • The next frame is sent after receiving the acknowledgment from the server-side. • This technique/method is known to be STOP-and-WAIT Protocol. ALGORITHM : Sender Step1: sequence 🡨 0 Step2: Accept new packet and assign sequence to it. Step3: Send packet sequence with sequence number sequence. Step4: Set timer for recently sent packets. Step5: If error free acknowledgment from receiver and NextFrameExpected->sequence then sequence🡨 NextFrameExpected. Step6: If time out then go to step3. Step7: Stop. Receiver Step1: Start. Step2: NextFrameExpected🡨 0, repeat steps 3 forever. Step3: If error-free frame received and sequence= NextFrameExpected, then pass packet to higher layer and NextFrameExpected🡨 NextFrameExpected+1(modulo 2). Step4: Stop.
PROGRAM: Sender.java import java.io.*; import java.net.*; import java.util.Scanner; public class Sender { public static void main(String args[])
Shobhit Gupta
1816413052
{ int p=9000,i,q=8000; String h="localhost"; try { Scanner scanner = new Scanner(System.in); System.out.print("Enter number of frames : "); int number = scanner.nextInt(); if(number==0) { System.out.println("No frame is sent"); } else { Socket s2; s2= new Socket(h,q); DataOutputStream d1 = new DataOutputStream(s2.getOutputStream()); d1.write(number); } String str1; for (i=0;i...