Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Objectives: (1) to get familiar with medium access control; (2) to further under

ID: 3852968 • Letter: O

Question

Objectives: (1) to get familiar with medium access control; (2) to further understand the importance of protocols; (3) to master sliding window mechanism; and (4) to study a concrete second-layer protocol, theHigh-level Data Link Control (HDLC)

In this lab, students are required to make Java programs using sockets to support the communications between multiple computers on the network. The following gives the details:

1. The intended local area network consists of at least three (3) computers, which can be simulated by three or more Java programs on the same computer or different computers.

2. The local area network is controlled by using the HDLC (refer to textbook)

.3. The Normal Response Mode (NRM) is used.

4. The 8-bit control field format is used

5. In the network, there is one and only one computer that is the primary station(e.g., A in the figure above), and all others are secondary stations (e.g., B, C and others in the figure above)

6. The identification (address) and the role (primary or secondary) for the computers are known when a computer starts up.

7. The communications can be made between these secondary computers. When B sends a message to C, C should print the message on its screen.

8. On the screen of A, a communication log can be displayed.

9. Sliding window is used

10. The maximum length of the information field is 64 bytes.

Objectives: (1) to get familiar with medium access control, (2) to further understand the importance of protocols, (3) to master sliding window mechanism; and (4) to study a concrete second-layer protocol, the High-level Data Link Control (HDLC). In this lab, students are required to make Java programs using sockets to support the communications between multiple computers on the network. The following gives the details: 1. The intended local area network consists of at least three (3) computers, which can be simulated by three or more Java programs on the same computer or different computers. 2. The local area network is controlled by using the HDLC (refer to textbook). 3. The Normal Response Mode (NRM) is used. 4. The 8-bit control field format is used. 5. In the network, there is one and only one computer that is the primary station (e.g., A in the figure above), and all others are secondary stations (e.g., B, C and others in the figure above). 6. The identification (address) and the role (primary or secondary) for the computers are known when a computer starts up. 7. The communications can be made betveen these secondary computers. When B sends a message to C, C should print the message on its screen. 8. On the screen of A, a communication log can be displayed. 9. Sliding window is used. 10. The maximum length of the information field is 64 bytes. 11. Necessary assumptions can be made.

Explanation / Answer

import java.net.*;
import java.io.*;
class MyServer{
public static void main(String args[])throws Exception{
ServerSocket ss=new ServerSocket(4444);
Socket s=ss.accept();
DataInputStream din=new DataInputStream(s.getInputStream());
DataOutputStream dout=new DataOutputStream(s.getOutputStream());
BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
String str="",str2="";
while(!str.equals("stop")){
str=din.readUTF();
System.out.println("client says: "+str);
str2=br.readLine();
dout.writeUTF(str2);
dout.flush();
}
din.close();
s.close();
ss.close();
}
}