Professional Documents
Culture Documents
Week -4:
TOPOLOGIES:
BUS:
MESH:
RING:
STAR:
Week -5a
BITSTUFFING:
stuffedData += bit;
if (count == 5) {
stuffedData += '0'; // Insert a stuffed bit
count = 0;
}
}
if (bit == '1') {
count++;
} else {
count = 0;
}
return destuffedData;
}
}
OUTPUT:
BYTESTUFFING:
OUTPUT:
Week -5 b
import java.util.Random;
class StopAndWait {
static final int FRAME_SIZE = 5;
static final int TIMEOUT = 1000; // 1 second
sender.start();
receiver.start();
}
}
public Sender() {
}
import java.util.LinkedList;
import java.util.Queue;
import java.util.Random;
class SlidingWindow {
static final int WINDOW_SIZE = 4;
static final int FRAME_SIZE = 10;
sender.start();
receiver.start();
}
}
public Sender() {
}
CRC:
if (isValid) {
System.out.println("CRC Check: Valid");
} else {
System.out.println("CRC Check: Invalid");
}
}
OUTPUT:
CRC:
import java.io.*;
class cr
{
public static void main(String args[]) throws IOException
{
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
System.out.println("Enter Generator:");
String gen = br.readLine();
System.out.println("Enter Data:");
String data = br.readLine();
String code = data;
while(code.length() < (data.length() + gen.length() - 1))
code = code + "0";
code = data + div(code,gen);
System.out.println("The transmitted Code Word is: " + code);
System.out.println("Please enter the received Code Word: ");
String rec = br.readLine();
if(Integer.parseInt(div(rec,gen)) == 0)
System.out.println("The received code word contains no errors.");
else
System.out.println("The received code word contains errors.");
}
OUTPUT:
WEEK -7
CSMA:
import java.util.Random;
class NetworkNode {
private String nodeName;
private boolean busy;
// Simulate CSMA/CD
System.out.println("Simulating CSMA/CD:");
for (NetworkNode node : nodes) {
if (!node.isBusy()) {
// Node is not busy, can transmit
node.transmitData();
} else {
System.out.println(node.getNodeName() + " detected a
collision.");
// Simulate collision
handleCollision();
}
}
// Simulate CSMA/CA
System.out.println("\nSimulating CSMA/CA:");
for (NetworkNode node : nodes) {
if (!node.isBusy() && !isChannelBusy()) {
// Node is not busy, and the channel is not busy, can transmit
node.transmitData();
} else {
System.out.println(node.getNodeName() + " sensed the channel
is busy or is busy.");
// Simulate collision avoidance (wait for a random backoff
time)
backoff();
}
}
}
OUTPUT:
WEEK-8:
DISTANCE VECTOR:
STEPS:
step 1: selection
step 2: connections
select PC0 -> desktop -> Ip Configuration -> IP Address:192.168.10.2 -> enter -> Default
Gateway:192.168.10.1
select PC1 -> desktop -> Ip Configuration -> IP Address:192.168.20.2 -> enter -> Default
Gateway:192.168.20.1
select PC2 -> desktop -> Ip Configuration -> IP Address:192.168.30.2 -> enter -> Default
Gateway:192.168.30.1
step 4: router configuration
select Router0 -> Config -> Fast ethernet 0/0 -> IP Address:192.168.10.1(default gateway)
select Router1 -> Config -> Fast ethernet 0/0 -> IP Address:192.168.20.1(default gateway)
select Router2 -> Config -> Fast ethernet 0/0 -> IP Address:192.168.30.1(default gateway)
Result: u can see the red arrow changing to green arrow from switches to routers
u can see the near(right) router0 clock Serial2/0 so click on router0 -> config -> Serial2/0 -> clock rate
: 64000 & IP Address:10.0.0.2 & select ON i.e Tick it
u can see the near(left) router1 Serial2/0 so click on router1 -> config -> Serial2/0 ->
u can see the near(right) router1 clock Serial3/0 so click on router0 -> config -> Serial3/0 -> clock rate
: 64000 & IP Address:20.0.0.2 & select ON i.e Tick it
u can see the near(left) router2 Serial2/0 so click on router2 -> config -> Serial2/0 ->
Result: u can see the red arrow changing to green arrow between the routers
Step 6: RIP
select Router0 -> Config -> RIP -> Network: 192.168.10.1 and click on add ->Network: 10.0.0.2 and
click on add
select Router1 -> Config -> RIP -> Network: 192.168.20.1 and click on add ->Network: 10.0.0.3 and
click on add & Network: 20.0.0.2 and click on add
select Router2 -> Config -> RIP -> Network: 192.168.30.1 and click on add ->Network: 20.0.0.3 and
click on add
select the message and send it to pc0 to pc1 & pc1 to pc2
CLIENT:
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.net.Socket;
String clientMessage;
while (true) {
clientMessage = clientInput.readLine();
clientOutput.println(clientMessage);
}
} catch (IOException e) {
e.printStackTrace();
}
}
}
SERVER:
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.net.ServerSocket;
import java.net.Socket;
String serverMessage;
while (true) {
serverMessage = serverInput.readLine();
serverOutput.println(serverMessage);
}
} catch (IOException e) {
e.printStackTrace();
}
}
}
OUTPUT:
STEPS:
1. Save the codes in notepad with java extension i.e client.java & server.java.
2. Compile the codes i.e javac client.java & javac server.java.
3. Run server side first i.e java server.java.
4. Open new cmd and run java client.
WEEK 10:
FTP:
STEPS:
step 1 : Selections
Select 1 server{Server-PT Server 1},1 Router{1841 Router0},1 Switch {2950-24 Switch0}, 2 PC's{PC-PT
PC0,PC1}
Step 2: connections
click on router0 -> config -> Fastethernet0/0 ->activate by click on -> IP Address:10.10.10.1
Fastethernet0/1 ->activate by click on -> IP Address:192.168.0.1
click on PC0 -> Desktop -> IP Configuration -> IP Address:192.168.0.2 ->Default Gateway:192.168.0.1
click on PC0 -> Desktop -> IP Configuration -> IP Address:192.168.0.3 ->Default Gateway:192.168.0.1
click on Server0 -> Desktop -> IP Configuration -> IP Address:10.10.10.2 ->Default
Gateway:10.10.10.1
click on Server0 -> Services -> FTP -> username: cisco1 & password:test & click on RWDRL and click
on add
click on PC0 -> Desktop -> Text editor -> write hello word,testing file for ftp server and save
it(hello.txt) now go to -> cmd : write some commands
commands:
username:cisco1
password:test
230 - Logged in
->ftp>put hello.txt
transfer complete
->ftp>dir
go to another pc{PC1}
click on PC1 -> Desktop -> cmd -> write some commands
commands:
username:cisco1
password:test
230 - Logged in
->ftp>get hello.txt
transfer complete
WEEK 11:
TELNET:
STEPS:
step 1 : Selections
Select 1 Switch {2950T-24 Switch0}, 5 PC's{PC-PT PC0,PC1,PC2,PC3,PC4}
Step 2: connections
PC0,PC1,PC2,PC3(client) -> Switch0 -> PC5(network adminstrator)
Switch>
Switch>enable
Switch#configure terminal
Enter configuration commands, one per line. End with CNTL/Z.
Switch(config)#interface vlan 1
Switch(config-if)#ip address 192.168.10.100 255.255.255.0
Switch(config-if)#no shutdown
Switch(config-if)#
LINK-5-CHANGED: Interface Vlanl, changed state to up
LINEPROTO-5-UPDOWN: Line protocol on Interface Vlanl, changed state to up
Switch(config-if)#exit
Switch(config)#line vty 0 15
Switch (config-line)#password telnet@1234
Switch(config-line)#login
Switch(config-line)#exit
Switch(config)#exit
Switch#
%SYS-5-CONFIG I: Configured from console by console
Switch#copy running-config startup-config
Destination filename [startup-config]?
Building configuration...
[OK]
Switch#configure terminal
Enter configuration commands, one per line. End with CNTL/Z.
Switch(config) #enable password admin@1234
Switch(config)#exit
Switch#
%SYS-5-CONFIG I: Configured from console by console
Switch#copy running-config startup-config
Destination filename (startup-config)?
Building configuration...
[OK]
step 4:
click on PC4 -> Desktop -> IP Configuration -> IP Address:192.168.10.2
click on PC4 -> Desktop -> cmd: write some commands
commands:
Cisco Packet Tracer PC Command Line 1.0
C:\>telnet 192.168.10.100
Trying 192.168.10.100... Open
User Access Verification
Password: telnet@1234
Switch>enable
Password: admin@1234
Switch#configure terminal
Enter configuration commands, one per line. End with CNTL/Z.
Switch(config)#interface fastethernet 0/3
Switch(config-if)#shutdown
Switch(config-if)#no shutdown
Switch(config-if)#
Step 5: Result
u can see the fastethernet 0/3 cable turning red when commanding shutdown and turning green
when commanding no shutdown.
WEEK 12:
RSA:
class RSA {
public static void main(String args[]) {
int p, q, n, z, d = 0, e, i;
OUTPUT: