0% found this document useful (0 votes)
16 views3 pages

Document

zsdxfcghj

Uploaded by

gangambika
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)
16 views3 pages

Document

zsdxfcghj

Uploaded by

gangambika
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/ 3

Package dev;

Import java.util.Random;

Import java.util.Scanner;

Public class Transmission {

Public static void transmission(long I, long N, long tf, long[] tt) {


While (I <= tf) {

Int z = 0;
For (long k = I; k < I + N && k <= tf; k++) {
System.out.println(“Sending Frame “ + k + “…”);
Tt[0]++;
}

For (long k = I; k < I + N && k <= tf; k++) {


Int f = new Random().nextInt(2);
If (f == 0) {
System.out.println(“Acknowledgment for Frame “ + k + “…”);
Z++;
} else {

System.out.println(“Timeout!! Frame Number : “ + k + “ Not


Received”);
System.out.println(“Retransmitting Window…”);
Break;
}
}

System.out.println();
I += z;
}
}

Public static void main(String[] args) {

Scanner scanner = new Scanner(System.in);


System.out.print(“Enter the Total number of frames: “);
Long tf = scanner.nextLong();
System.out.print(“Enter the Window Size: “);
Long N = scanner.nextLong();

Long I = 1;
Long[] tt = {0}; // Using an array to allow passing by reference
Transmission(I, N, tf, tt);

System.out.println(“Total number of frames which were sent and resent


are: “ + tt[0]);

Scanner.close();
}
}

You might also like