Dr. K. N.
Modi Institute of Engineering & Technology
DEPARTMENT OF COMPUTER SCIENCE & ENGINEERING
Practical-File
Compiler Design Lab
Subject Code: BCS-652
Year:2024-25
Submitted to:- Submitted by:-
Ms.Archana Rajora Name:Ankita Mishra
Assistant Professor Roll No.:2200770100024
Course:B.Tech(CSE)
Year:3rd Year(6th Sem)
Exp. No. Objective of Experiment Date Sign.
Network Commands: Running and using
Ex-1 services/commands like ping, ip config, tracert,
hostname, netstat, arp, ns lookup etc.
To learn handling and configuration of networking
Ex-2 hardware like RJ-45 connector, CAT-6 cable, crimping
tool, etc. (A case study)
Cisco packet tracer: Overview & Introduction : Create a
connection between two devices and implementing
Ex-3 Local Area Network.( Case study will be assignned to
students to know about netwok design of our KIET
network.)
Cisco packet tracer: Implementation of
Ex-4 hub.Configuration of router, hub, switch etc. (using
simulators or real devices )
Network simulation using tools like Cisco Packet Tracer &
Ex-5 Implement layered procedure of OSI Model.
Study of Socket Programming and Client – Server model.
Ex-6 Applications using TCP Sockets like a. Echo client and
echo server b. Chat c. File Transfer
Socket programming using UDP and TCP (e.g., simple
Ex-7 DNS, data & time client/server, echo client/server,
iterative & concurrent servers)
Implementation of Stop and Wait Protocol and Sliding
Ex-8
Window Protocol
Topology Configuration: (I) Implementing Star Topology
Ex-9 using Cisco Packet Tracer. (II) Implementation of Mesh
Topology in Cisco
WAP to calculate Efficiency and Throughput of STOP N
Ex-9 WAIT using following data:Length of data L= 2
bytesBandwidth B= 10mbpsDistance of medium=
2kmVelocity of signal v= 2 X 10^5 meter/sec
WAP to implement CRC (cyclic redundancy check)
algorithm at sender’s side.Detail steps of objective:1.
Take any numeric data and convert it into binary or
Ex-10 directly take any binary data (This is the sender’s data)2.
Now like sender’s data, take any CRC code.3. Now finally,
find the actual data that is required to be send by the
sender after applying CRC.
Lab 1:
Network Commands: Running and using services/commands like ping, traceroute, nslookup, arp,
telnet, ftp,etc.
Using ipconfig command
ipconfig (standing for "Internet Protocol configuration") is a console application program of some
computer operating systems that displays all current TCP/IP network configuration values and
refreshes Dynamic Host Configuration Protocol (DHCP) and Domain Name System (DNS) settings.
Using ping command
Ping is a computer network administration software utility used to test the reachability of a host on an
Internet Protocol network. It is available for virtually all operating systems that have networking
capability, including most embedded network administration software.
Using tracert command
The tracert command is a Command Prompt command that's used to show several details about the
path that a packet takes from the computer or device you're on to whatever destination you specify.
Windows: tracert[-d] [-h MaxHops] [-w TimeOut] [-4] [-6] target [/?]
Linux: traceroute [-d] [-h MaxHops] [-w TimeOut] [-4] [-6] target [/?]
Using hostname command
Use this command to display the IP address of the remote machine.
hostname [-v] [-a] [--alias] [-d] [--domain] [-f] [--fqdn] [-A] [--all-fqdns] [-i] [--ip-address] [-I] [--all-ip-
addresses] [--long] [-s] [--short] [-y] [--yp] [--nis]
Using netstat command
In computing, netstat is a command-line network utility that displays network connections for
Transmission Control Protocol, routing tables, and a number of network interface and network
protocol statistics.
netstat [address_family_options] [--tcp|-t] [--udp|-u] [--raw|-w] [--listening|-l] [--all|-a] [--numeric|-n]
[--numeric-hosts][--numeric-ports][--numeric-ports] [--symbolic|-N] [--extend|-e[--extend|-e]] [--
timers|-o] [--program|-p] [--verbose|-v] [--continuous|-c] [delay]
Using arp command
arp command manipulates the System's ARP cache. It also allows a complete dump of the ARP cache.
ARP stands for Address Resolution Protocol. The primary function of this protocol is to resolve the IP
address of a system to its mac address, and hence it works between level 2(Data link layer) and level
3(Network layer).
Using ns lookup command
Ns lookup is a network administration command-line tool for querying the Domain Name System to
obtain the mapping between domain name and IP address, or other DNS records.
Ns lookup [HOST] [SERVER]
Lab 2:
Theory:
A twisted pair consists of two insulated conductor twisted together in the shape of a spiral. It can be
shielded or unshielded. The unshielded twisted pair cables are very cheap and easy to install. But they
are very badly affected by the electromagnetic noise interference. Twisting of wires will reduce the
effect of noise or external interference.
The induced emf into the two wires due to interference tends to cancel each other due to twisting.
Number of twists per unit length will determine the quality of cable. More twists means better quality.
There are 3 types of UTP cables:-
1. Straight-through cable
2. Crossover cable
3. Roll-over cable
A.Straight-through cable
Straight-Through refers to cables that have the pin assignments on each end of the cable. In other
words Pin 1 connector A goes to Pin 1 on connector B, Pin 2 to Pin 2 ect. Straight- Through wired
cables are most commonly used to connect a host to client. When we talk about cat5e patch cables,
the Straight-Through wired cat5e patch cable is used to connect computers, printers and other
network client devices to the router switch or hub (the host device in this instance).
B.Crossover cable
Crossover wired cables (commonly called crossover cables) are very much like Straight- Through cables
with the exception that TX and RX lines are crossed (they are at oposite positions on either end of the
cable. Using the 568-B standard as an example below you will see that Pin 1 on connector A goes to
Pin 3 on connector B. Pin 2 on connector A goes to Pin 6 on connector B ect. Crossover cables are
most commonly used to connect two hosts directly. Examples would be connecting a computer
directly to another computer, connecting a switch directly to another switch, or connecting a router to
a router.Note: While in the past when connecting two host devices directly a crossover cable was
required. Now days most devices have auto sensing technology that detects the cable and device and
crosses pairs when needed.
C.Roll-over cable
Rollover wired cables most commonly called rollover cables, have opposite Pin assignments on each
end of the cable or in other words it is "rolled over". Pin 1 of connector A would be connected to Pin 8
of connector B. Pin 2 of connector A would be connected to Pin 7 of connector B and so on. Rollover
cables, sometimes referred to as Yost cables are most commonly used to connect to a devices console
port to make programming changes to the device. Unlike crossover and straight-wired cables, rollover
cables are not intended to carry data but instead create an interface with the device.
STRAIGHT
Straight-Through refers to cables that have the pin assignments on each end of the cable. In other
words, Pin 1 connector A goes to Pin 1 on connector B, Pin 2 to Pin 2, etc. Straight-Through wired
cables are most commonly used to connect a host to a client. When we talk about cat5e patch cables,
the Straight-Through wired cat5e patch cable is used to connect computers, printers, and other
network client devices to the router switch or hub (the host device in this instance).
CROSS
Crossover wired cables (commonly called crossover cables) are very much like
Straight-Through cables with the exception that TX and RX lines are crossed (they are at opposite
positions on either end of the cable. Using the 568-B standard as an example below, you will see that
Pin 1 on connector A goes to Pin 3 on connector B. Pin 2 on connector A goes to Pin 6 on connector B,
etc. Crossover cables are most commonly used to connect two hosts directly. Examples would be
connecting a computer directly to another computer, connecting a switch directly to another switch,
or connecting a router to a router. Note: While in the past, when connecting two host devices directly,
a crossover cable was required. Nowadays, most devices have auto-sensing technology that detects
the cable and device and crosses pairs when needed.
Lab 3:
Cisco Packet Tracer --:> Working of Cisco Packet Tracer --:> Working of the different transmission
medium --:> Working of Switch and hubs.
A router that is turned off doesn’t work very well! Click on your router to bring up the configuration
menu and verify that it is turned on. When on, there will be a small green light below the switch as
seen in the diagram.
Next we have to open the Ethernet ports to allow communication. Although they are physically
connected, they are in a state that is known as being in administrative shut down. Now click on the
CLI tab to access the configuration menu. If you’ve used the Cisco IOS before, you will notice it looks
and acts the same way.
1. Press RETURN to start the session
2. Type enable to get to privileged mode (this gives you more options in configuring the router)
3. Type config terminal (or config t for short) to access the configuration menu.
4.Type interface fastethernet0/0 to access Ethernet0/0
1. Type ip address 192.168.10.1 255.255.255.0 to assign an IP address and subnet mask to the
interface.
2. Type no shutdown to open the interface up for business.
Star topology: Switch
Router: connecting two networks.
Lab 4:
Implement Byte-stuffing and bit-stuffing.
Sender side code: package byte_stuffing; import java.io.*; import java.util.*; import java.net.*;
public class Byte_Stuffing_Client { public static void main(String args[]) throws IOException
InetAddressip = InetAddress.getLocalHost(); int port = 45678;
Scanner sc = new Scanner(System.in);
// Opens a socket for connection Socket s = new Socket(ip, port);
// Declaring I/O Streams
DataInputStream dis = new Data Input Stream(s.getInputStream());
DataOutputStream dos = new
DataOutputStream(s.getOutputStream());
while (true) {
System.out.println("Enter the Message to be Sent : ");
String data = sc.nextLine();
String res = new String();
// Data in each frame is stuffed by 'F' at beginning and end data = 'F' + data + 'F';
for (int i = 0; i<data.length(); i++) {
// Stuff with 'E' if 'F' is found in the data to be sent
if (data.charAt(i) == 'F' &&i != 0 &&i !=
(data.length() - 1))
res = res + 'E' + data.charAt(i);
// Stuff with 'E' if 'E' is found in the data to be sent else if (data.charAt(i) == 'E') res = res + 'E' +
data.charAt(i);
else
res = res + data.charAt(i);
System.out.println("The data being sent (with byte stuffed)
is : " + res);
// Send the data to the receiver dos.writeUTF(res);
System.out.println("SedingMessage. .. ");
if (dis.readUTF().equals("success"))
System.out.println("Thanks for the Feedback Server!!");
// End Messaging
dos.writeUTF("bye"); break;
// Close all connections s.close(); dis.close(); dos.close();
}
}
Receiver side code:package byte_stuffing; import java.io.*; import java.net.*;
public class Byte_Stuffing{ public static void main(String[] args) throws IOException {
// Opens a socket for connection
ServerSocketservsock = new ServerSocket(45678);
// Used to block until a client connects to the server
Socket socket = servsock.accept();
// Declaring I/O Streams
DataInputStream dis = new
DataInputStream(socket.getInputStream());
DataOutputStream dos = new
DataOutputStream(socket.getOutputStream());
while (true) {
String out = new String();
// Used to read the data sent by client
String res = dis.readUTF();
System.out.println("Message Recevied...Successfully!!!");
System.out.println("The Stuffed Message is : " + res);
for (int i = 1; i<res.length() - 1; i++) {
// If data contains a 'D' or 'F' do not unstuff it if (res.charAt(i) == 'D' || res.charAt(i) == 'F') out = out +
res.charAt(i);
//
// If data contains 'E' followed by 'E', de-stuff the former 'E'
else if (res.charAt(i) == 'E' &&res.charAt(i + 1) ==
'E') {
out = out + 'E'; i++;
}
}
System.out.println("The Destuffed Message is : " + out); dos.writeUTF("success"); String ch =
dis.readUTF(); if (ch.equals("bye")) {
System.out.println("Messaging is over. .... EXITING"); break;
// Closing all connections socket.close(); dis.close(); dos.close();
Output:
Enter the Message to be Sent :
DFEDDFED
The data being sent (with byte stuffed) is : FDEFEEDDEFEEDF Seding Message....
Thanks for the Feedback Server!!
Message Recevied ... Successfully!!!
The Stuffed Message is : FDEFEEDDEFEEDF
The Destuffed Message is : DFEDDFED
Messaging is over .... EXITING
Bit Stuffing
Sender side code:
package bitstuffing; import java.io.*; import java.net.*; import java.util.Scanner; public class
BitStuffingClient { public static void main(String[] args) throws IOException {
// Opens a socket for connection
Socket socket = new Socket("localhost", 6789);
DataInputStream dis = new
DataInputStream(socket.getInputStream());
DataOutputStream dos = new
DataOutputStream(socket.getOutputStream());
// Scanner class object to take input
Scanner sc = new Scanner(System.in);
// Takes input of unstuffed data from user
System.out.println("Enter data: ");
String data = sc.nextLine();
int cnt = 0; String s = ""; for (int i = 0; i<data.length(); i++) {
char ch = data.charAt(i); if (ch == '1') {
// count number of consecutive 1's
// in user's data cnt++;
if (cnt< 5) s += ch; else {
// add one '0' after 5 consecutive 1's s = s + ch + '0';
cnt = 0;
} } else { s += ch; cnt = 0;
}
}
// add flag byte in the beginning // and end of stuffed data
s = "01111110" + s + "01111110";
System.out.println("Data stuffed in client: " + s); System.out.println("Sending to server for unstuffing");
dos.writeUTF(s);
}
}
Receiver package bitstuffing; import java.io.*;
import java.net.*;
public class BitStuffingServer { public static void main(String[] args) throws IOException
{
ServerSocketskt = new ServerSocket(6789);
// Used to block until a client connects to the server
Socket socket = skt.accept();
DataInputStream dis = new
DataInputStream(socket.getInputStream());
DataOutputStream dos = new
DataOutputStream(socket.getOutputStream());
// Receiving the string from the client which
// needs to be stuffed
String s = dis.readUTF();
System.out.println("Stuffed data from client: " + s);
System.out.println("Unstuffed data: ");
int cnt = 0;
// removal of stuffed bits:
// start from 9th bit because the first 8 // bits are of the special pattern.
for (int i = 8; i<s.length() - 8; i++) { char ch = s.charAt(i); if (ch == '1') { cnt++;
System.out.print(ch);
// After 5 consecutive 1's one stuffed bit //'0' is added. We need to remove that.
else {
// print unstuffed data System.out.print(ch);
// we only need to maintain count
// of consecutive 1's cnt = 0;
}
System.out.println();
}
}
Output:
User enters a binary data as input.
Enter data:
0000001
Data is stuffed and sent to the reciever for unstuffing.
Here server is the receiver.
Data stuffed in client: 01111110000000101111110
Sending to server for unstuffing
Receiver receives the stuffed data.
Stuffed data from client: 01111110000000101111110
Reciever has to unstuff the input data from sender and get the original data which was given as input
by the user.
Unstuffed data:
0000001
Lab 5:
Implement CRC algorithm to detect the error.
Cyclic redundancy check (CRC) code provides a simple, yet powerful, method for the detection of
burst errors during digital data transmission and storage. CRC
implementation can use either hardware or software methods. ........... Variouscommon CRC
codes will be used.
import java.io.*;
public class CRC
{ public static void main(String args[]) throws IOException {
Buffered Read erbr = 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.");
}
static String div(String num1,String num2)
{ int pointer = num2.length();
String result = num1.substring(0, pointer);
String remainder = "";
for(int i = 0; i< num2.length(); i++)
{ if(result.charAt(i) == num2.charAt(i))
remainder += "0";
else
remainder += "1";
}
while(pointer < num1.length())
{ if(remainder.charAt(0) == '0')
{ remainder = remainder.substring(1, remainder.length()); remainder = remainder +
String.valueOf(num1.charAt(pointer)); pointer++; } result = remainder; remainder = "";
for(int i = 0; i< num2.length(); i++)
{ if(result.charAt(i) == num2.charAt(i))
remainder += "0";
else
remainder += "1";
}
} return remainder.substring(1,remainder.length()); }
}
Lab 6:
Implement Stop and Wait ARQ in java.
Stop-and-wait ARQ, also referred to as alternating bit protocol, is a method in telecommunications to
send information between two connected devices. It ensures that information is not lost due to
dropped packets and that packets are received in the correct order. It is the simplest automatic repeat-
request mechanism. Server Side import java.net.*; import java.io.*;
class StopNWaitServer{
public static void main(String arg[]){ int i=0;
try{
System.out.println("Started");
ServerSocket s1= new ServerSocket(9292); //creating socket for M
Socket s11=s1.accept();
System.out.println("Client Connected");
DataInputStream dis= new DataInputStream(s11.getInputStream());
Integer M= (Integer)dis.read();
ServerSocket s2= new ServerSocket(9293); //socket for frame Socket s21=s2.accept();
DataInputStream dis2= new DataInputStream(s21.getInputStream());
DataOutputStream dos2= new
DataOutputStream(s21.getOutputStream());
while(i<=M)
String frame=dis2.readUTF(); //receiving frame
System.out.println(frame);
dos2.write(i); //making ack System.out.println("ACK sent"); i++;
}
catch(Exception e)
System.out.println("Bye ");
Receiver Side
import java.net.*; import java.io.*;
import java.util.*;
class StopNWaitRec
public static void main(String arg[])
Scanner scn= new Scanner(System.in); System.out.println("Enter frame no"); int M= scn.nextInt();
if(M==0)
System.out.println("No frames");
}{
try
Socket s1= new Socket("localhost",9292);
DataOutputStream dos1= new
DataOutputStream(s1.getOutputStream()); dos1.write(M);
String str1;
Socket s2=new Socket("localhost",9293);
DataInputStream dis2= new DataInputStream(s2.getInputStream());
DataOutputStream dos2= new
DataOutputStream(s2.getOutputStream());
for(int j=0;j<M;j++){
System.out.println("Enter msg for frame"); str1= scn.next();
System.out.println("Frame" +j+"Sent");
System.out.println(str1);
dos2.writeUTF(str1);
//waiting for ACK
Integer ack1=dis2.read();
System.out.println("Received ACK: "+ ack1);
}} catch(Exception e)
System.out.println("Error occurred"+e); }
}
Output side
Receiver Side
Lab 7
Study of Socket Programming and Client —Server model
If we are creating a connection between client and server using TCP then it has few functionality like,
TCP is suited for applications that require high reliability, and transmission time is relatively less
critical. It is used by other protocols like HTTP, HTTPs, FTP, SMTP, Telnet. TCP rearranges data packets
in the order specified. There is absolute guarantee that the data transferred remains intact and arrives
in the same order in which it was sent. TCP does Flow Control and requires three packets to set up a
socket connection, before any user data can be sent. TCP handles reliability and congestion control. It
also does error checking and error recovery. Erroneous packets are retransmitted from the source to
the destination. The entire process can be broken down into following steps:
The entire process can be broken down into following steps:
TCP Server –
1. using create(), Create TCP socket.
2. using bind(), Bind the socket to server address.
3. using listen(), put the server socket in a passive mode, where it waits for the client to approach
the server to make a connection
4. using accept(), At this point, connection is established between client and server, and they are
ready to transfer data.
1. Go back to Step 3.
TCP Client –
1. Create TCP socket.
2. connect newly created client socket to server.
/ /
/*Client Program*/
import java.util.*; import java.net.*; import java.io.*; public class Client
{ public static void main(String args[]) throws Exception
BufferedReaderbr=new BufferedReader(new InputStreamReader(System.in)); System.out.print("Enter
the value of m : "); int m=Integer.parseInt(br.readLine()); int x=(int)((Math.pow(2,m))-1);
System.out.print("Enter no. of frames to be sent:"); int count=Integer.parseInt(br.readLine()); int
data[]=new int[count]; int h=0; for(int i=0;i<count;i++)
System.out.print("Enter data for frame no " +h+ " => "); data[i]=Integer.parseInt(br.readLine()); h=
(h+1)%x;
}
Socket client=new Socket("localhost",5056);
ObjectInputStreamois=new ObjectInputStream(client.getInputStream());
ObjectOutputStreamoos=new ObjectOutputStream(client.getOutputStream());
System.out.println("Connected with server."); boolean flag=false;
GoBackNListener listener=new GoBackNListener(ois,x); listener=new GoBackNListener(ois,x);
listener.t.start(); int strt=0; h=0; oos.writeObject(x); do { int c=h; for(int i=h;i<count;i++)
System.out.print("|"+c+"|"); c=(c+1)%x;
System.out.println(); System.out.println(); h=strt; for(int i=strt;i<x;i++)
System.out.println("Sending frame:"+h); h=(h+1)%x;
System.out.println(); oos.writeObject(i); oos.writeObject(data[i]);
Thread.sleep(100);
} listener.t.join(3500); if(listener.reply!=x-1)
System.out.println("No reply from server in 3.5 seconds. Resending data from frame no " +
(listener.reply+1));
System.out.println();
strt=listener.reply+1;
flag=false;
} else
System.out.println("All elements sent successfully. Exiting"); flag=true;
}while(!flag); oos.writeObject(-1);
}
}
import java.net.*; import java.io.*; import java.util.*;
public class Server6{ public static void main(String []args) throws Exception{
//creating socket
ServerSocket server=new ServerSocket(6262);
System.out.println("Server Established.");
Socket client=server.accept();
//adding input and output stream
ObjectOutputStream oos=new ObjectOutputStream(client.getOutputStream());
ObjectInputStreamois= new ObjectInputStream(client.getInputStream()); System.out.println("Client is
now conneted."); int x= (Integer)ois.readObject(); int k=(Integer)ois.readObject();
int j=0; int i=(Integer)ois.readObject(); boolean flag=true;
Random r=new Random(6); int mod=r.nextInt(6); while(mod==1||mod==0) mod=r.nextInt(6);
while(true){ int c=k;
for(int h=0;h<=x;h++){
System.out.println("|"+c+"|"); c=(c+1)%x;
System.out.println(); System.out.println(); if(k==j){System.out.println("Frame"+k+"
recieved"+"\n"+"Data:"+j);
j++;
System.out.println();
}
else{
System.out.println("Frames are not in order.");
System.out.println("Expected :"+j+"\n"+"Recieved :"+k);
System.out.println(); if(j%mod==0 && flag){
System.out.println("Error found. Acknowledgement not sent."); flag=!flag;
j--; } else if(k==j-1){ oos.writeObject(k);
System.out.println("Acknowledgement sent");
System.out.println(); if(j%mod==0){
flag=!flag;
} k=(Integer)ois.readObject(); if(k==-1) break; i=(Integer)ois.readObject();
}
System.out.println("Client finished"); oos.writeObject(-1);
}
}
Lab 8:
Network simulation using tool NS2
Network Simulator-2 (NS)
NS is a discrete event simulator targeted at networking research. Ns provides substantial support for
simulation of TCP, routing, and multicast protocols over wired and wireless (local and satellite)
networks.
1. Install Oracle Virtual box
2. Download Ubuntu OS image 3.Load ubuntu image into virtual box 4.In Terminal:
a. sudo apt-get install -y nam
b. sudo apt-get install -y ns2
5.type ns on terminal. (if % symbol comes.. ns installed successfully). 6.Write tcl script of network
scenario
7.Record result in trace file.
Read trace file and analyse parameters.
TCL Script:
#Create a simulator object set ns [new Simulator]
#Define different colors for data flows (for NAM)
$ns color 1 Blue
#Open the NAM trace file set nf [open p2_1.nam w]
$ns namtrace-all $nf
#create the trace files set tracefile [open p2_1.tr w]
$ns trace-all $tracefile
#Define a 'finish' procedure
proc finish {} { global ns nf
$ns flush-trace #Close the NAM trace file close $nf
#Execute NAM on the trace file exec nam p2_1.nam &
exit 0
}
#step-1
#Create four nodes set n0 [$ns node] set n1 [$ns node] set n2 [$ns node] set n3 [$ns node]
#step-2
#Create links between the nodes
$ns duplex-link $n0 $n2 10Mb 1ms DropTail
$ns duplex-link $n1 $n2 20Mb 1ms DropTail
$ns duplex-link $n2 $n3 50Mb 2ms DropTail
#Set Queue Size of link (n2-n3) to 10
$ns queue-limit $n2 $n3 3
#Give node position (for NAM)
$ns duplex-link-op $n0 $n2 orient right-down
$ns duplex-link-op $n1 $n2 orient right-up
$ $ $
$ns duplex-link-op $n2 $n3 orient right
#Monitor the queue for link (n2-n3). (for NAM)
$ns duplex-link-op $n2 $n3 queuePos 0.5
#step -3:
#Setup a TCP connection set tcp [new Agent/TCP] $tcp set class_ 2 $ns attach-agent $n0 $tcp set sink
[new Agent/TCPSink] $ns attach-agent $n3 $sink
$ns connect $tcp $sink
$tcp set fid_ 1 # performing two different tcp's
#step- 4:
#Setup a FTP over TCP connection set ftp [new Application/FTP]
$ftp attach-agent $tcp
$ftp set type_ FTP
#Schedule events for the CBR and FTP agents
$ns at 0.1 "$ftp start"
$ns at 95.0 "$ftp stop"
#Detach tcp and sink agents (not really necessary)
$ns at 95.0 "$ns detach-agent $n0 $tcp ; $ns detach-agent $n3 $sink"
#Call the finish procedure after 5 seconds of simulation time
$ns at 100.0 "finish"
#Run the simulation
$ns run
AWK Script
BEGIN { recvdSize = 0 startTime = 400 stopTime = 0
event = $1 time = $2 node_id = $3 rec_id = $4
pkt_size = $6 level = $5
# Store start time
if (level == "tcp" &&pkt_size>= 1000) {
if ($2 <startTime) { startTime = $2
# Update total received packets' size and store packets arrival time
if (level == "tcp" && event == "r" &&pkt_size>= 100) {
if ($2 >stopTime) {
stopTime = $2
# Rip off the header
hdr_size = pkt_size % 1000
pkt_size -= hdr_size
# Store received packet's size
recvdSize += pkt_size
END {
printf("Average Throughput[kbps] = %.2f\t\t
StartTime=%.2f\tStopTime=%.2f\n",(recvdSize/(stopTime-startTime))*(8/1000),startTime,stopTime)
}
Lab 9:
Implement static routing and dynamic routing using RIP protocol.
1. Static routing
Static routing is the most secure way of routing. It reduces overhead from network resources. In this
type of routing we manually add routes in routing table. It is useful where numbers of route are
limited. Like other routing methods static routing also has its pros and cons.
Advantage of static routing
It is easy to implement.
It is most secure way of routing, since no information is shared with other routers.
It puts no overhead on resources such as CPU or memory.
Disadvantage of static routing
It is suitable only for small network.
If a link fails it cannot reroute the traffic.
To explain static routing, I will use packet tracer network simulator software. You can use any network
simulator software or can use a real Cisco devices to follow this guide. There is no difference in output
as long as your selected software contains the commands explained in this tutorial.
Router>enable
Router#configure terminal
Enter configuration commands, one per line. End with CNTL/Z.
Router(config)#
Router(config)#interface fastEthernet 0/0
Router(config-if)#ip address 10.0.0.1 255.0.0.0
Router(config-if)#no shutdown
Router(config-if)#exit
Router(config)#
/ /
Router#show controllers serial 0/0/0
Interface Serial0/0/0
Hardware is PowerQUICC MPC860
DCE V.35, clock rate 2000000
[Output omitted]
Router#configure terminal
Enter configuration commands, one per line. End with CNTL/Z. Router(config)#interface serial 0/0/0
Router(config-if)#ip address 192.168.0.253 255.255.255.252
Router(config-if)#clock rate 64000
Router(config-if)#bandwidth 64
Router(config-if)#no shutdown
Router(config-if)#exit
Router(config)#
Router>enable
Router#configure terminal
Enter configuration commands, one per line. End with CNTL/Z.
Router(config)#interface serial 0/0/0
Router(config-if)#ip address 192.168.0.254 255.255.255.252
Router(config-if)#no shutdown
Router(config-if)#exit
Router(config)#interface serial 0/0/1
Router(config-if)#ip address 192.168.0.249 255.255.255.252
Router(config-if)#clock rate 64000
Router(config-if)#bandwidth 64
Router(config-if)#no shutdown
Router(config-if)#exit
Router 2
Router>enable
Router#configure terminal
/
Enter configuration commands, one per line. End with CNTL/Z.
Router(config)#interface serial 0/0/0
Router(config-if)#ip address 192.168.0.250 255.255.255.252
Router(config-if)#no shutdown
Router(config-if)#exit
Router(config)#interface serial 0/0/1
Router(config-if)#ip address 192.168.0.
Experiment:
1. Analysis the frame, IP header and tcp header in http application.
2. Maintain the source and destination address of the communication.
3. Use filters to analyse the communication with specific destination machine.
4. Highlight the port category using by the source machine.
Analysis the frame, IP header and tcp header in http application.
Maintain the source and destination address of the communication.
Use filters to analyse the communication with specific destination machine.