SlideShare una empresa de Scribd logo
1 de 90
Descargar para leer sin conexión
1
DEPARTMENT OF INFORMATION TECHNOLOGY
LAB MANUAL CUM RECORD NOTE BOOK
CS8581 - NETWORKS LAB
Reg. 2017 - Third Year IT / ODD Semester
Prepared by,
D.Kayathri Devi, AP/IT
Name :
Registration Number : Roll Number :
Branch :
Year :
This is the Bonafide Record work done in the CS 8581 - Networks Laboratory
during the year
STAFF IN CHARGE HEAD OF THE DEPARTMENT
Submitted for the Practical examinationheld on
Engineering and Technology, S.P.G.C.Nagar, K.Vellakulam ,Near
Virudhunagar,Madurai.
at Kamaraj College of
INTERNAL EXAMINER EXTERNAL EXAMINER
2
CS8581 – Networks Laboratory Department of Information Technology
3
PROGRAMME EDUCATION OBJECTIVES
Mission
To make the department of Information Technology the unique of its kind in the
field of Research and Development activities in this part of world.
Vision
To impart highly innovative and technical knowledge in the field of Information
Technology to the urban and unreachable rural student folks through Total Quality
Education
Technical Knowledge
PEO 1 : Graduates of the programme will exhibit expertise in technical knowledge by
applying distinctive skills in various fields of Information Technology
Life long learning and Societal Needs
PEO 2 : Graduates will become pioneers in the field of IT by working collaboratively
and providing solutions to meet societal needs through persistent learning
Total Quality Education
PEO 3 : Graduates will be able to adopt innovative practices and contribute towards
research and technological development in the field of IT through Total Quality
Education
DEPARTMENT OF INFORMATION TECHOLOGY
5
CS 8581 - Networks Laboratory Department of Information Technology
PROGRAM OUTCOMES (POs)
Engineering Graduates will be able to:
1. Engineering knowledge: Apply the knowledge of mathematics, science, engineering
fundamentals, and an engineering specialization to the solution of complex engineering
problems.
2. Problem analysis: Identify, formulate, review research literature, and analyse complex
engineering problems reaching substantiated conclusions using first principles of mathematics,
natural sciences, and engineering sciences.
3. Design/development of solutions: Design solutions for complex engineering problems and
design system components or processes that meet the specified needs with appropriate
consideration for the public health and safety, and the cultural, societal, and environmental
considerations.
4. Conduct investigations of complex problems: Use research-based knowledge and research
methods including design of experiments, analysis and interpretation of data, and synthesis of
the information to provide valid conclusions.
5. Modern tool usage: Create, select, and apply appropriate techniques, resources, and modern
engineering and IT tools including prediction and modelling to complex engineering activities
with an understanding of the limitations.
6. The engineer and society: Apply reasoning informed by the contextual knowledge to assess
societal, health, safety, legal and cultural issues and the consequent responsibilities relevant to
the professional engineering practice.
7. Environment and sustainability: Understand the impact of the professional engineering
solutions in societal and environmental contexts, and demonstrate the knowledge of, and need
for sustainable development.
8. Ethics: Apply ethical principles and commit to professional ethics and responsibilities and
norms of the engineering practice.
9. Individual and team work: Function effectively as an individual, and as a member or leader in
diverse teams, and in multidisciplinary settings.
10. Communication: Communicate effectively on complex engineering activities with the
engineering community and with society at large, such as, being able to comprehend and write
effective reports and design documentation, make effective presentations, and give and receive
6
clear instructions.
CS 8581 - Networks Laboratory Department of Information Technology
11. Project management and finance: Demonstrate knowledge and understanding of the
engineering and management principles and apply these to one’s own work, as a member and
leader in a team, to manage projects and in multidisciplinary environments.
12. Life-long learning: Recognize the need for, and have the preparation and ability to engage in
independent and life-long learning in the broadest context of technological change.
PROGRAM SPECIFIC OUTCOMES (PSO)
Engineering Graduates will be able to:
1. Design and develop applications in the field of Information Technology by applying the
knowledge acquired from Computer Organization & Engineering, Networking, Software
Engineering & Programming, Data Analytics & other allied topics.
2. Demonstrate an ability to analyze ,design, and develop software solutions to cater the needs of
diversified business sectors
11
[Type text]IT [Type text] [Type text]
CS 8581 - Networks Laboratory Department of Information Technology
Syllabus
CS 8581 NETWORKS LABORATORY L T P C
0 0 4 2
OBJECTIVES:
The student should be made to:
➢ To learn and use network Commands.
➢ To learn Socket Programming.
➢ To implement and analyze various network protocols.
➢ To learn and use simulation tools.
➢ To use simulation tools to analyze the performance of various network protocols.
COURSE OUTCOMES :
C Course
No.
Course Outcome
[Students should be able to ..]
Knowledge
Level
LIST OF EXPERIMENTS:
1. Learn to use commands like tcpdump, netstat,ifconfig,nslookup, traceroute. Capture ping and traceroute PDUs using
a network protocol analyzer and examine.
2. Write a HTTP web client program to download a web page using TCP Sockets.
3. Applications using TCP Sockets like :
a. Echo Client and Echo Server
b. Chat
c. File Transfer
4. Simulation of DNS using UDP Sockets.
5. Write a code simulating ARP/RARP protocols.
6. Study of Network Simulator and Simulation of Congestion Control Algorithms using NS
7. Study of TCP/UDP performance using Simulation Tool.
8. Simulation of Distance Vector /Link State Routing Algorithm.
9. Performance Evaluation of Routing Protocols using Simulation Tool.
10. Simulation of Error Correction Code ( like CRC).
TOTAL: 60 PERIODS
SOFTWARE Requirements :
C / C++ / Java / Equivalent Compiler
Network simulator like NS2/Glomosim/OPNET/Equivalent
12
[Type text]IT [Type text] [Type text]
CS 8581 - Networks Laboratory Department of Information Technology
Correlation between the course and the Program Outcomes (POs) and Program Specific Outcomes (PSOs)
Cours
Outcomes
Program out comes
Program
Specific
outcomes
PO1
(K3)
PO2
(K4)
PO3
(K5)
PO4
(K5)
PO5
(K6)
PO6
(K3)
PO7
(K2)
PO8
(K3)
PO9
(A3)
PO10
(A3)
PO11
(K3)
PO12
(A5)
PSO1
(K3)
PSO2
(K4)
Correlation Levels : L: Slight M: Moderate S : Substantial
MEASURING TOOL FOR COURSE OUTCOME EVALUATION
Rubrics for Record Assessment
Category
Marks
allotted
Logic
Understood the
basic concept
and logic - 40
Understood the
logic and basic
concept but lacks
in presenting it –
35
Understood the basic
concept but lacks in
understanding the
logic - 30
Understood the basic
concept but fails to
give detail
description - 15
No knowledge in
basic concept - 0
40
Code
Design
Code that
satisfies the
entire logic - 40
Code deigned
with some syntax
errors - 35
Code designed with
some logic mistakes -
30
Code designed with
wrong logic - 15
Wrong logic &
no programming
structure - 0
40
Record
Submission
Submission on
date - 10
Submission with
1 day’s delay - 8
Submission with 2
day’s delay - 6
Submission with 3
day’s delay - 4
Submission with
4 day’s delay - 2
10
Viva 10
Total 100
13
[Type text]IT [Type text] [Type text]
CS 8581 - Networks Laboratory Department of Information Technology
List of Experiments
Sl.No Topic Name
No. of
Periods
Cum.
No. of
Periods
Mapped
to CO
Prerequisite
Knowledge
Cycle – I
1
Study of socket programming and client-server
model
3 3
Syntax of basic
concepts
2
a)Implementation of Stop and Wait Protocol 3 6 C307.1
Concept of Stop
and Wait Protocol
b)Implementation of Sliding Window Protocol 3 9 C307.1
Concept of Sliding
Window Protocol
3
a)Implementation of Echo Server using TCP
socket
6 15
C307.2
TCP Socket
Functions
(Concepts of Echo,
Chat, FTP)
b)Implementation of Chat Application using
TCP
C307.2
c)Implementation of File Transfer Protocol using
TCP socket
C307.2
Cycle – II
4
a)Implementation of Chat Application using
UDP socket
6 21
C307.2 TCP Socket
Functions
(Concepts of Echo,
Chat, FTP)
b)Implementation of File Transfer Protocol
using UDP socket
C307.2
c)Implementation of DNS using UDP socket C307.2
5
a)Simulation of ARP
3 24 C307.3
Concepts of ARP
& RARPb)Simulation of RARP
6
a)Implementation of PING
3 27 C307.3
Concept of PING,
TRACEROUTE
commands
b)Implementation of TRACEROUTE
Cycle – III
7
Webpage upload and download using TCP
socket
3 30 C307.4 Concepts of HTTP
8 Implementation of Remote Procedure Call 3 33 C307.4 Concepts of RPC
9
a)Study of Network Simulator
3 36
C307.5
Introduction to
NS2
b)Simulation of TCP congestion control using
Network Simulator
C307.5
Concepts of
Congestion Control
10
Simulation of Routing Protocols using Network
Simulator
3 39 C307.5
Concepts of
Routing Protocol
Content Beyond Syllabus
11
Implementation of Bit stuffing and Debit
stuffing
3 42 C307.1
Concept of Bit
Stuffing
Model Exam 3 45
Total Number of Periods : 45
14
[Type text]IT [Type text] [Type text]
CS 8581 - Networks Laboratory Department of Information Technology
INDEX
S.No Date CO Topic Name
P.No
Design&
Logic[40]
Code&output
[40]
Record
Submission
[10]
Viva[10]
Total
[100]
Sign.
Cycle – I
1
Study of socket programming and client-server
model
<-- Not Applicable -->
2 C307.1
a)Implementation of Stop and Wait Protocol
b)Implementation of Sliding Window Protocol
3 C307.2
a)Implementation of Echo Server using TCP
socket
b)Implementation of Chat Application using TCP
socket
c)Implementation of File Transfer Protocol using
TCP socket
Cycle – II
4 C307.2
a)Implementation of Chat Application using UDP
socket
b)Implementation of File Transfer Protocol using
UDP socket
c)Implementation of DNS using UDP socket
5 C307.3
a)Simulation of ARP
b)Simulation of RARP
6 C307.3
a)Implementation of PING
b)Implementation of TRACEROUTE
Cycle – III
7 C307.4 Webpage upload and download using TCP socket
8 C307.4 Implementation of Remote Procedure Call
9
C307.5 a)Study of Network Simulator <-- Not Applicable -->
b)Simulation of TCP congestion control using
Network Simulator
10
C307.5
Simulation of Routing Protocols using Network
Simulator
Content Beyond Syllabus
11
C307.1
Implementation of Bit stuffing and Debit stuffing
15
[Type text]IT [Type text] [Type text]
CS 8581 - Networks Laboratory Department of Information Technology
CO Attainment Calculation :
Target Value = 80 % of Marks Internal
Assessment
CO ATTAINMENT - INTERNAL ASSESSMENT
Laboratory Mark
CO Number Mark Obtained
CO Attained?
[Y/N]
Signature
CO1
CO2
CO3
CO4
CO5
Total Marks (100)
S. No. Assessment Tool Percentage of Contribution
(%)
1 Laboratory Rubrics 75
2 Model Exam 25
12
CS 8581 - Networks Laboratory Department of Information Technology
Model Exam
CO Number
Marks
Total Mark
CO Attained?
[Y/N]Allotted Obtained
Internal Assessment = 75% of Laboratory Mark + 25% of Model Mark
=
Internal Assessment = %
Note:
If CO Attainment,
Y = Laboratory Mark (%) >= Target Value (%)
N = Laboratory Mark (%) < Target Value (%)
Action Plan :
(if CO not attained)
For Regular Laboratory Session :
CO
Reason for not
attaining CO
Remedial Action
Plan
Remarks Signature
13
[Type text] [Type text] [Type text]
CS 8581 - Networks Laboratory Department of Information Technology
For Model Exam :
CO
Reason for not
attaining CO
Remedial Action
Plan
Remarks Signature
14
[Type text] [Type text] [Type text]
CS 8581 - Networks Laboratory Department of Information Technology
Pre - Assessment Questions Date : _______________
Fill up the following :
1. ______ is a connection-oriented and reliable protocol, ______ is a less reliable protocol.
2. The TCP and UDP protocols use ______ to map incoming data to a particular process running on a computer.
3. Datagrams are normally sent by ______ protocol.
4. Java uses ______ class representing a server and ______ class representing the client that uses TCP protocol.
5. ______ is used to wait for accepting client connection requests.
6. Class ______ is used to create a packet of data for UDP protocol.
7. If something goes wrong related to the network, ______ will be thrown when dealing with TCP/UDP programming
in Java.
8. The main purpose of URL encoding is to maintain the ______ between various platforms.
9. Based on the URL encoding mechanism, “www.test.com/test me&test you” becomes ______.
10. ______ method is used to instantiate a URLConnection instance.
State TRUE or FALSE.
11. UDP is more reliable than TCP protocol.
12. The same port number can be reused many times when binding with sockets simultaneously
13. In order to create a client socket connecting to a particular server, the IP address must be given to the client socket,
or it cannot connect to the server.
14. Sockets provide an interface for programming networks at the transport layer
15. Call Socket.close() method will close the TCP server that socket connects to
Write your observation about the Effect of the following code :
Socket socket = new Socket(“localhost,” 1254);
___________________________________________________________________________
Score : / 16 Signature of the Staff in Charge
[Name : ]
15
[Type text] [Type text] [Type text]
CS 8581 - Networks Laboratory Department of Information Technology
Ex No : 1 Study of Socket Programming CO : Basics
& K : K1 - Remember
Date : Client-Server Model
Aim:
To study about the fundamentals of Socket Programming and the concepts of Client - Server Model.
References :
1.tutorialspoint
2. http://www.buyya.com/java/Chapter13.pdf
Description :
Network Programming :
• writing programs that execute across multiple devices
• devices are all connected to each other using a network
• java.net package provides support for TCP and UDP
• TCP − TCP stands for Transmission Control Protocol
- allows reliable communication between two applications.
- TCP is typically used over the Internet Protocol, which is referred to as TCP/IP.
- TCP is a two-way communication protocol, hence data can be sent across both
streams at the same time
• UDP − UDP stands for User Datagram Protocol
- a connection-less protocol that allows for packets of data to be transmitted between
applications.
Socket Programming :
o java.net.Socket class represents a socket
o java.net.ServerSocket class provides a mechanism for the server program to listen for clients and establish
connections with them.
16
[Type text] [Type text] [Type text]
CS 8581 - Networks Laboratory Department of Information Technology
ServerSocket Class Methods :
The java.net.ServerSocket class is used by server applications to obtain a port and listen for client requests.
The ServerSocket class has four constructors −
Sr.No. Method & Description
1
public ServerSocket(int port) throws IOException
Attempts to create a server socket bound to the specified port. An exception occurs if the port is already bound by
another application.
2
public ServerSocket(int port, int backlog) throws IOException
Similar to the previous constructor, the backlog parameter specifies how many incoming clients to store in a wait
queue.
3
public ServerSocket(int port, int backlog, InetAddress address) throws IOException
Similar to the previous constructor, the InetAddress parameter specifies the local IP address to bind to. The
InetAddress is used for servers that may have multiple IP addresses, allowing the server to specify which of its IP
addresses to accept client requests on.
4
public ServerSocket() throws IOException
Creates an unbound server socket. When using this constructor, use the bind() method when you are ready to bind
the server socket.
Sr.No. Method & Description
1
public int getLocalPort()
Returns the port that the server socket is listening on. This method is useful if you passed in 0 as the port
number in a constructor and let the server find a port for you.
2
public Socket accept() throws IOException
Waits for an incoming client. This method blocks until either a client connects to the server on the
specified port or the socket times out, assuming that the time-out value has been set using the
setSoTimeout() method. Otherwise, this method blocks indefinitely.
3
public void setSoTimeout(int timeout)
Sets the time-out value for how long the server socket waits for a client during the accept().
4
public void bind(SocketAddress host, int backlog)
Binds the socket to the specified server and port in the SocketAddress object. Use this method if you have
instantiated the ServerSocket using the no-argument constructor.
17
[Type text] [Type text] [Type text]
CS 8581 - Networks Laboratory Department of Information Technology
Socket Class Methods
The Socket class has five constructors that a client uses to connect to a server
Sr.No. Method & Description
1
public Socket(String host, int port) throws UnknownHostException, IOException.
This method attempts to connect to the specified server at the specified port. If this constructor does not throw
an exception, the connection is successful and the client is connected to the server.
2
public Socket(InetAddress host, int port) throws IOException
This method is identical to the previous constructor, except that the host is denoted by an InetAddress object.
3
public Socket(String host, int port, InetAddress localAddress, int localPort) throws IOException.
Connects to the specified host and port, creating a socket on the local host at the specified address and port.
4
public Socket(InetAddress host, int port, InetAddress localAddress, int localPort) throws IOException.
This method is identical to the previous constructor, except that the host is denoted by an InetAddress object
instead of a String.
5
public Socket()
Creates an unconnected socket. Use the connect() method to connect this socket to a server.
Sr.No. Method & Description
1
public void connect(SocketAddress host, int timeout) throws IOException
This method connects the socket to the specified host. This method is needed only when you instantiate the
Socket using the no-argument constructor.
2
public InetAddress getInetAddress()
This method returns the address of the other computer that this socket is connected to.
3
public int getPort()
Returns the port the socket is bound to on the remote machine.
4
public int getLocalPort()
Returns the port the socket is bound to on the local machine.
5
public SocketAddress getRemoteSocketAddress()
Returns the address of the remote socket.
6
public InputStream getInputStream() throws IOException
Returns the input stream of the socket. The input stream is connected to the output stream of the remote
socket.
18
[Type text] [Type text] [Type text]
CS 8581 - Networks Laboratory Department of Information Technology
Client - Server Model :
Result :
Thus the study about the fundamentals of Socket Programming and the concepts of Client-Server Model was
carried out successfully.
7
public OutputStream getOutputStream() throws IOException
Returns the output stream of the socket. The output stream is connected to the input stream of the remote
socket.
8
public void close() throws IOException
Closes the socket, which makes this Socket object no longer capable of connecting again to any server.
19
[Type text] [Type text] [Type text]
CS 8581 - Networks Laboratory Department of Information Technology
Ex . No : 1 Viva Questions Marks : ____/ 10
1. Define : Socket
2. State the types of Sockets.
1.___________________
2. ___________________
3. ___________________
3. What is meant by System Call?
4. Which Java Classes support Socket Programming?
1. ________________________
2. ________________________
5. What is meant by loopback address?
6. What is meant by port?. Give Example.
7. Match the following :
1. HTTP - a. Port 23
2. SMTP - b. Port 53
3. Telnet - c. Port 25
4. DNS - d. Port 80
Criteria Allotted Awarded
Design & Algorithm 20
Logic 20
Code 20
Output 20
Record Submission 10
Viva 10
Total 100
Staff Signature
20
[Type text] [Type text] [Type text]
CS 8581 - Networks Laboratory Department of Information Technology
Ex No : 2(a) Implementation of Stop and wait Protocol CO : C307.1
Date : K : K3
AIM
To write a ‘Java’ program to perform implementation of Stop and wait protocol
ALGORITHM
Stop and Wait ARQ
1. Get the input data.
2.Send the data one by one from the sender side.
3.The data is received at the receiver side one by one.
4.If we send an acknowledgement , send next data. Otherwise resend the previous data
5.End of the process.
CODE :
21
[Type text] [Type text] [Type text]
CS 8581 - Networks Laboratory Department of Information Technology
22
[Type text] [Type text] [Type text]
CS 8581 - Networks Laboratory Department of Information Technology
OUTPUT :
23
[Type text] [Type text] [Type text]
CS 8581 - Networks Laboratory Department of Information Technology
Ex No : 2(a) Implementation of Stop and Wait Protocol
Viva Questions
1. In Stop and Wait Protocol, if the sequence number of the sent frame is 5, what is the number of the acknowledgement
frame ?. _____
2. Maximum window size in Stop and Wait Protocol is ____
3. Stop and Wait ARQ is also called as _________________
4. In Stop and Wait ARQ, Modulo ____ numbering is used.
RESULT:
Thus the Java program for implementing stop and wait protocol was done and correct output was verified
Criteria Allotted Awarded
Design & Algorithm 20
Logic 20
Code 20
Output 20
Record Submission 10
Viva 10
Total 100
Staff Signature
24
[Type text] [Type text] [Type text]
CS 8581 - Networks Laboratory Department of Information Technology
Ex No : 2(b) Implementation of Sliding Window Protocols CO : C307.1
Date : K : K3
AIM
To write a ‘Java’ program to perform implementation of Sliding window protocols.
ALGORITHM
Go Back-N ARQ
1. Get the input data.
2. Assign the window size.
3. Send the data one by one in the sender side according to the window size..
4. The data is received at the receiver side one by one according to the window size.
5. If we send an acknowledgement , the window expands to include places for the number of frames to be send.
6. Otherwise resend frames(data) according to the window size.
7. Display the sender’s data and window status and receiver’s data and window status accordingly
8. End of the process.
Selective and Repeat ARQ:
1.Get the input data.
2.Assign the frame size.
3.Send the data one by one in the sender side according to the window size..
4.The data is received at the receiver side one by one according to the frame size.
5.If we send an acknowledgement , the window expands to include places for the number of frames to be send.
6. Otherwise resend the data for selective frame which is not received.
7.Display the sender’s data and window status and receiver’s data and window status accordingly
8.End of the process.
25
[Type text] [Type text] [Type text]
CS 8581 - Networks Laboratory Department of Information Technology
CODE
26
[Type text] [Type text] [Type text]
CS 8581 - Networks Laboratory Department of Information Technology
OUTPUT
27
[Type text] [Type text] [Type text]
CS 8581 - Networks Laboratory Department of Information Technology
Viva Questions :
1. List out the advantages of Sliding Window Protocols.
2. Define : Piggybacking.
3. Sliding window is useful for error _______________
4. How many windows will be maintained in sliding window protocol?. List them.
RESULT:
Thus the Java program for implementing Sliding Window protocol was done and correct output was verified
Criteria Allotted Awarded
Design & Algorithm 20
Logic 20
Code 20
Output 20
Record Submission 10
Viva 10
Total 100
Staff Signature
28
[Type text] [Type text] [Type text]
CS 8581 - Networks Laboratory Department of Information Technology
Ex No : 3(a) Implementation of Echo Server & Client using TCP CO : C307.2
Date : K : K3
AIM:
To write a Java program to implement TCP echo client and server.
ALGORITHM:
TCP ECHO SERVER:
1. Include the necessary packages to support functions for socket definitions, Socket types , Internet address,
I/O functions and unix system calls.
2. Declare variables, socket descriptor and port number.
3. Create a Stream socket and assign its socket descriptor value in a variable
4. Initialize all the socket address values to zero.
5. Assign the socket address family and port numbers
6. Bind the socket with address and port number using bind() function.
7. Establish the connection request with the client by using the Listen() function.
8. The connection request from client is accepted using the accept() function and thus connection is established.
9. Then child process is created and str-echo() function is called to execute.
10. Here the size and buffer is initialized
11. Message from the client is read and stored in n and it is written to the server buffer.
12. If the buffer is full, then same read operation is carried.
13. If the buffer is empty, then read error.
14. Terminate the connection.
TCP ECHO CLIENT:
1. Include the necessary packages to support functions for socket definitions, Socket types , Internet address, I/O
functions and unix system calls.
2. Declare variables, socket descriptor and port number.
3. Create a Stream socket and assign its socket descriptor value in a variable
4. Initialize all the socket address values to zero.
5. Assign the socket address family and port number.
6. Using inet() function, convert the presentation (ASCII address to numeric address).
29
[Type text] [Type text] [Type text]
CS 8581 - Networks Laboratory Department of Information Technology
7. Then the connect function is to make the connection with the server side
8. The the function strcli() is executed with the arguments file pointer and socket descriptor
9. the two buffers receive and send buffer are initialied
10. the messge sent by the server is read by fgets() function, if the value is not null.
11. The value from send buffer is written at client side.
12. If the receive buffer is not full , the error messge is displyes
13. Else the message is echoed from the receive buffer.
CODE :
Client.java
import java.io.*;
import java.net.*;
import java.util.*;
class Client{
public static void main(String args[])throws IOException
{
try
{
Socket s = new Socket("127.0.0.1",2222);
DataOutputStream dos = new DataOutputStream(s.getOutputStream());
DataInputStream din = new DataInputStream(s.getInputStream());
Scanner sc = new Scanner(System.in);
System.out.println("Enter your Message:");
String name = sc.nextLine();
dos.writeUTF(name);
String in = (String)din.readUTF();
System.out.println(in);
s.close();
}
catch(Exception e)
{
System.out.print(e);
}
}
}
Server.java
import java.io.*;
import java.util.*;
import java.net.*;
class Server{
public static void main(String args[])throws IOException
{
try
{
ServerSocket ss = new ServerSocket(2222);
30
[Type text] [Type text] [Type text]
CS 8581 - Networks Laboratory Department of Information Technology
Socket s = ss.accept();
DataOutputStream dos = new DataOutputStream(s.getOutputStream());
DataInputStream din = new DataInputStream(s.getInputStream());
String in = (String)din.readUTF();
dos.writeUTF(in);
System.out.println(in);
s.close();
ss.close();
}
catch(Exception e)
{
System.out.print(e);
}
}
}
OUTPUT:
31
[Type text] [Type text] [Type text]
CS 8581 - Networks Laboratory Department of Information Technology
Viva Questions :
1. If the client sends "Hello" to echo server, what does the echo server send back ? ____________
2. State the purpose of Echo Server
3. Write the package and suitable socket class to create a Server Socket.
____________________ ____________________
RESULT :
Thus the program for TCP Echo client and server was written and correct output was verified.
Criteria Allotted Awarded
Design & Algorithm 20
Logic 20
Code 20
Output 20
Record Submission 10
Viva 10
Total 100
Staff Signature
32
[Type text] [Type text] [Type text]
CS 8581 - Networks Laboratory Department of Information Technology
Ex No : 3(b) Implementation of Chat Server & Client using TCP CO : C307.2
Date : K : K3
AIM:
To write a Java program for Chatting between TCP Client and Server.
Reference :
1. http://pirate.shu.edu/~wachsmut/Teaching/CSAS2214/Virtual/Lectures/chat-client-server.html
2. https://www.youtube.com/watch?v=kqBmsLvWU14
ALGORITHM:
CHATING TCP SERVER
1. Include the necessary packages to support functions for socket definitions, Socket types , Internet address, I/O
functions and unix system calls.
2. Declare variables, socket descriptor and port number.
3. Create a Stream socket and assign its socket descriptor value in a variable
4. Initialize all the socket address values to zero.
5. Assign the socket address family and port numbers
6. Bind the socket with address and port number using bind() function.
7. Establish the connection request with the client by using the Listen() function.
8. The connection request from client is accepted using the accept() function and thus connection is established.
9. If the fork does not return zero, make the server to be in listening state
10. Else send the message to the client.
11. Close the socket.
CHATING TCP CLIENT
1. Include the necessary packages to support functions for socket definitions, Socket types , Internet address,
I/O functions and unix system calls.
2. Declare variables, socket descriptor and port number.
3. Create a Stream socket and assign its socket descriptor value in a variable
4. Initialize all the socket address values to zero.
5. Assign the socket address family and port number.
6. Using inet() function, convert the presentation (ASCII address to numeric address).
7. Then the connect function is to make the connection with the server side
33
[Type text] [Type text] [Type text]
CS 8581 - Networks Laboratory Department of Information Technology
8. The the function strcli() is executed with the arguments file pointer and socket descriptor
9. the two buffers receive and send buffer are initialied
10.the messge sent by the server is read by fgets() function, if the value is not null.
11. The value from send buffer is written at client side.
12. If the receive buffer is not full , the error messge is displayed
13. Else send the message to the server.
14. Close the socket
CODE :
TCPClient
import java.io.*;
import java.net.*;
import java.util.*;
class TCPClient{
public static void main(String args[])throws IOException
{
try
{
System.out.println("JegaApp Chat Application");
Socket s = new Socket("127.0.0.1",2000);
while(true){
DataOutputStream dos = new DataOutputStream(s.getOutputStream());
DataInputStream din = new DataInputStream(s.getInputStream());
Scanner sc = new Scanner(System.in);
System.out.println("Enter your Message to pass:(Type 'Bye' to Exit the Chat)");
String msg = sc.nextLine();
dos.writeUTF(msg);
String input = (String)din.readUTF();
System.out.println("Server Says... "+input);
if(input.equalsIgnoreCase("Bye"))
{
break;
}
}
s.close();
}
catch(Exception e)
{
System.out.print(e);
}
}
}
34
[Type text] [Type text] [Type text]
CS 8581 - Networks Laboratory Department of Information Technology
TCPServer
import java.io.*;
import java.util.*;
import java.net.*;
class TCPServer{
public static void main(String args[])throws IOException
{
try
{
System.out.println("JegaApp Chat Application");
ServerSocket ss = new ServerSocket(2000);
Socket s = ss.accept();
while(true){
DataOutputStream dos = new DataOutputStream(s.getOutputStream());
DataInputStream din = new DataInputStream(s.getInputStream());
String in = (String)din.readUTF();
System.out.println("Client Says... "+in);
Scanner sc = new Scanner(System.in);
System.out.println("Enter your Message to pass:(Type 'Bye' to Exit the Chat)");
String out = sc.nextLine();
dos.writeUTF(out);
if(in.equalsIgnoreCase("Bye"))
{
break;
}
}
s.close();
ss.close();
}
catch(Exception e)
{
System.out.print(e);
}
}
}
35
[Type text] [Type text] [Type text]
CS 8581 - Networks Laboratory Department of Information Technology
OUTPUT :
Viva Questions:
1. What is Loop back IP Address.?
2. Mention its purpose.
3. State the purpose of Chat Server- Client.
RESULT :
Thus the program for Chatting TCP Client and Server was written and correct output was verified.
Criteria Allotted Awarded
Design & Algorithm 20
Logic 20
Code 20
Output 20
Record Submission 10
Viva 10
Total 100
Staff Signature
36
[Type text] [Type text] [Type text]
CS 8581 - Networks Laboratory Department of Information Technology
Ex No : 3(c) Implementation of File Transfer using TCP CO : C307.2
Date : K : K3
AIM
To Perform File Transfer in Client & Server Using TCP/IP.
ALGORITHM
CLIENT SIDE
1. Start.
2. Establish a connection between the Client and Server.
3. Socket ss=new Socket(InetAddress.getLocalHost(),1100);
4. Implement a client that can send two requests.
i) To get a file from the server.
ii) To put or send a file to the server.
5. After getting approval from the server ,the client either get file from the server or send
6. file to the server.
SERVER SIDE
1. Start.
2. Implement a server socket that listens to a particular port number.
3. Server reads the filename and sends the data stored in the file for the‘get’ request.
4. It reads the data from the input stream and writes it to a file in theserver for the ‘put’ instruction.
5. Exit upon client’s request.
6. Stop.
CODE :
FTPSEREVER.JAVA
import java.io.*;
import java.net.*;
import java.util.*;
public class FTPServer
{
public static void main(String args[])throws IOException
{
try
{
int num;
Scanner sc=new Scanner(System.in);
ServerSocket ss=new ServerSocket(10087);
37
[Type text] [Type text] [Type text]
CS 8581 - Networks Laboratory Department of Information Technology
Socket s=ss.accept();
System.out.println("Waiting.....");
DataInputStream dis=new DataInputStream(s.getInputStream());
String input=(String)dis.readUTF();
DataOutputStream dos=new DataOutputStream(s.getOutputStream());
FileInputStream fis = new FileInputStream("num.txt");
FileOutputStream fos = new FileOutputStream(input);
while((num=fis.read())!= -1)
{
if(num%2==0)
{
fos.write(num);
}
}
dos.writeUTF(input);
System.out.println("File is sent to client");
ss.close();
s.close();
}
catch(Exception e)
{
System.out.println("Port not available"+e);
}
}
}
FTPCLIENT.JAVA
import java.io.*;
import java.net.*;
import java.util.*;
public class FTPClient
{
public static void main(String args[])throws IOException
{
try
{
int number;
Socket s=new Socket("127.0.0.1",10087);
Scanner sc=new Scanner(System.in);
System.out.println("Enter the file name:");
String fn=sc.next();
DataOutputStream dos=new DataOutputStream(s.getOutputStream());
dos.writeUTF(fn);
DataInputStream dis=new DataInputStream(s.getInputStream());
String input=(String)dis.readUTF();
FileInputStream fis=new FileInputStream(input);
System.out.println("Even Numbers in the" +fn+" are");
int i=0;
38
[Type text] [Type text] [Type text]
CS 8581 - Networks Laboratory Department of Information Technology
while((i=fis.read())!=-1)
{
System.out.println((char)i);
}
s.close();
}
catch(Exception e)
{
System.out.println("Port not available "+e);
}
}
}
OUTPUT:
39
[Type text] [Type text] [Type text]
CS 8581 - Networks Laboratory Department of Information Technology
Viva Questions :
1. Abbreviate : FTP
2. Ports used by FTP is ____________
3. State the Role of FTP Server and FTP Client.
4. Who will perform File Upload ___________
5. Who will allow File Download ____________
RESULT
Thus the File transfer Operation is done & executed successfully.
Criteria Allotted Awarded
Design & Algorithm 20
Logic 20
Code 20
Output 20
Record Submission 10
Viva 10
Total 100
Staff Signature
40
[Type text] [Type text] [Type text]
CS 8581 - Networks Laboratory Department of Information Technology
Ex No : 4(a) Implementation of Chat using UDP CO : C307.2
Date : K : K3
AIM
To write a program to implement simple client-server application using UDP.
ALGORITHM
CLIENT SIDE
1. Create a datagram socket with server’s IP address.
2. Create datagram packets with data, data length and the port address.
3. Send the datagram packets to server through datagram sockets
4. Receive the datagram packets from server through datagram sockets
5. Close the socket.
SERVER SIDE
1. Create a datagram socket with port address.
2. Create datagram packets with data, data length and the port address.
3. Send the datagram packets to client through datagram sockets
4. Receive the datagram packets from client through datagram sockets
5. Close the socket.
CODE
ClientUDP.java
import java.io.*;
import java.net.*;
class ClientUDP
{
public static void main(String args[])throws IOException
{
try
{
DatagramSocket ds=new DatagramSocket();
InetAddress ina=InetAddress.getByName("127.0.0.1");
byte[] data=new byte[1024];
String d="Hello";
data=d.getBytes();
DatagramPacket dp=new DatagramPacket(data,data.length,ina,10001);
ds.send(dp);
}
41
[Type text] [Type text] [Type text]
CS 8581 - Networks Laboratory Department of Information Technology
catch(Exception e)
{
System.out.println(e);
}
}
}
ServerUDP.java
import java.net.*;
import java.io.*;
class ServerUDP
{
public static void main(String args[]) throws IOException
{
try
{
DatagramSocket dss=new DatagramSocket(10001);
byte[] dat=new byte[1024];
String fromc="";
DatagramPacket dps=new DatagramPacket(dat,dat.length);
dss.receive(dps);
fromc=new String(dps.getData());
System.out.println(""+fromc.trim());
}
catch(Exception e)
{
System.out.println(e);
}
}
}
OUTPUT
42
[Type text] [Type text] [Type text]
CS 8581 - Networks Laboratory Department of Information Technology
Viva Questions:
1. Abbreviate : UDP
2. Differentiate : TCP and UDP
3. When UDP is Useful?
Result:
Thus the above program a client-server application for chat using UDP was executed and successfully
Criteria Allotted Awarded
Design & Algorithm 20
Logic 20
Code 20
Output 20
Record Submission 10
Viva 10
Total 100
Staff Signature
43
[Type text] [Type text] [Type text]
CS 8581 - Networks Laboratory Department of Information Technology
Ex No : 4(b) Implementation of FTP using UDP CO : C307.2
Date : K : K3
Aim
To implement FTP using UDP.
References :
https://www.youtube.com/watch?v=NXQ7wwvDF2A
ALGORITHM
Client Side :
1. Create a DatagramSocket to connect to the server
2. Set the name of the Client Machine
3. Create DatagramPackets to send and receive data to and from the server
4. Create the necessary file objects to receive and send the data
5. Display the received data fro the server in the client's Interface
6. Terminate the client side
Server Side :
1. Create a Datagram Socket class for server and determine the port on which the server's resources can be fetched.
2. Create the DatagramPackets to send and receive the files to and from the server
3. Create the necessary objects to receive and send the file data
4. Terminate the servver side.
CODE :
44
[Type text] [Type text] [Type text]
CS 8581 - Networks Laboratory Department of Information Technology
45
[Type text] [Type text] [Type text]
CS 8581 - Networks Laboratory Department of Information Technology
OUTPUT :
Viva Questions :
1. Create the socket using UDP in Java
2. Mention the types of Files with their extensions.
Result :
Thus the program to implement FDP using UDP was done and executed successfully.
Criteria Allotted Awarded
Design & Algorithm 20
Logic 20
Code 20
Output 20
Record Submission 10
Viva 10
Total 100
Staff Signature
46
[Type text] [Type text] [Type text]
CS 8581 - Networks Laboratory Department of Information Technology
Ex No : 4(c) Implementation of DNS using UDP CO : C307.2
Date : K : K3
Aim
To implement DNS using UDP.
ALGORITHM
Client Side :
1. Create a DatagramSocket to connect to the server
2. Set the name of the Client Machine
3. Create DatagramPackets to send and receive data to and from the server
4. Enter the IP address or the URL for which the DNS resolving mechanism is required
5. Display the received data in the form of IP address or Domain Name from the server in the client's Interface
6. Terminate the client side
Server Side :
1. Create a Datagram Socket class for server and determine the port on which the server's resources can be fetched.
2. Create the DatagramPackets to send and receive the IP address / URL from the client
3. Terminate the server side.
CODE :
DNSSERVERUDP.JAVA
import java.io.*;
import java.util.*;
import java.net.*;
class DNSServerUDP
{
public static void main(String args[])throws Exception
{
DatagramSocket dss=new DatagramSocket(10001);
String[] dn={"www.google.com","www.yahoo.com","www.gmail.com"};
String[] ip={"192.162.3.2","192.162.3.3","192.162.3.4"};
String temp="";
int flag=0;
try
{
byte[] rm=new byte[1024];
System.out.println("Waiting...");
DatagramPacket dps=new DatagramPacket(rm,rm.length);
dss.receive(dps);
47
[Type text] [Type text] [Type text]
CS 8581 - Networks Laboratory Department of Information Technology
String rec=new String(dps.getData());
for(int i=0;i<3;i++)
{
if((rec.trim()).equals(dn[i]))
{
temp=ip[i];
flag=1;
}
}
byte[] sm=new byte[1024];
InetAddress ia=dps.getAddress();
int port=dps.getPort();
sm=temp.getBytes();
String not="IP not found";
byte[] sn=new byte[1024];
sn=not.getBytes();
if(flag==1)
{
DatagramPacket dps1=new DatagramPacket(sm,sm.length,ia,port);
dss.send(dps1);
}
else
{
DatagramPacket dps1=new DatagramPacket(sn,sn.length,ia,port);
dss.send(dps1);
}
}
catch(Exception e)
{
System.out.println(e);
}
}
}
DNSCLIENTUDP.JAVA
import java.net.*;
import java.util.*;
class DNSClientUDP
{
public static void main(String args[])throws Exception
{
DatagramSocket dsc=new DatagramSocket();
InetAddress ia=InetAddress.getByName("127.0.0.1");
Scanner sc=new Scanner(System.in);
try
{
System.out.println("Enter the domain name:");
String msg=sc.next();
48
[Type text] [Type text] [Type text]
CS 8581 - Networks Laboratory Department of Information Technology
byte[] sm=new byte[1024];
sm=msg.getBytes();
DatagramPacket dpc=new DatagramPacket(sm,sm.length,ia,10001);
dsc.send(dpc);
byte[] rm=new byte[1024];
DatagramPacket dpc1=new DatagramPacket(rm,rm.length);
dsc.receive(dpc1);
String rec=new String(dpc1.getData());
System.out.println("IP address:"+rec.trim());
}
catch(Exception e)
{
System.out.println(e);
}
}
}
OUTPUT :
49
[Type text] [Type text] [Type text]
CS 8581 - Networks Laboratory Department of Information Technology
Viva Questions :
1. Abbreviate : DNS
2. What is the purpose of Name Server?.
3. Give an example for Lookup?
4. List out any four domains.
5. ____ port is used by DNS
6. DNS works over ______
Result :
Thus the program to implement DNS using UDP was done and executed successfully.
Criteria Allotted Awarded
Design & Algorithm 20
Logic 20
Code 20
Output 20
Record Submission 10
Viva 10
Total 100
Staff Signature
50
[Type text] [Type text] [Type text]
CS 8581 - Networks Laboratory Department of Information Technology
Ex No : 5(a) Simulation of ARP CO : C307.3
Date : K : K3
AIM
To implement Address Resolution Protocol .
ALGORITHM
CLIENT SIDE
1. Establish a connection between the Client and Server. Socket ss=new
Socket(InetAddress.getLocalHost(),1100);
2. Create instance output stream writer
PrintWriter ps=new PrintWriter(s.getOutputStream(),true);
3. Get the IP Address to resolve its physical address.
4. Send the IPAddress to its output Stream.ps.println(ip);
5. Print the Physical Address received from the server.
SERVER SIDE
1. Accept the connection request by the client.
ServerSocket ss=new ServerSocket(2000);Socket s=ss.accept();
2. Get the IPaddress from its inputstream.
BufferedReader br1=new BufferedReader(newInputStreamReader(s.getInputStream()));
ip=br1.readLine();
3. During runtime execute the processRuntime r=Runtime.getRuntime(); Process
p=r.exec("arp -a "+ip);
4. Send the Physical Address to the client.
CODE :
ArpClient.java
import java.io.*;
import java.net.*;
class ArpClient
{
public static void main(String args[])throws IOException
{
try
{
Socket ss=new Socket(InetAddress.getLocalHost(),1100);
51
[Type text] [Type text] [Type text]
CS 8581 - Networks Laboratory Department of Information Technology
PrintStream ps=new PrintStream(ss.getOutputStream());
BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
String ip;
System.out.println("Enter the IP ADDRESS:");
ip=br.readLine();
ps.println(ip);
String str;
BufferedReader br2=new BufferedReader(new
InputStreamReader(ss.getInputStream()));
System.out.println("ARP From Server::");
str=br2.readLine();
System.out.println("The ARP Entries aren"+str);
}
catch(Exception e)
{
System.out.println("Error"+e);
}
}
}
ArpServer.java
import java.io.*;
import java.net.*;
class ArpServer
{
public static void main(String args[])throws IOException
{
try
{
ServerSocket ss=new ServerSocket(2930);
Socket s=ss.accept();
System.out.println("Connected to Client....");
PrintStream ps=new PrintStream(s.getOutputStream());
BufferedReader br1=new BufferedReader(new
InputStreamReader(s.getInputStream()));
String ip;
ip=br1.readLine();
Runtime r=Runtime.getRuntime();
Process p=r.exec("arp -a "+ip);
52
[Type text] [Type text] [Type text]
CS 8581 - Networks Laboratory Department of Information Technology
System.out.println();
BufferedReader br2=new BufferedReader(new
InputStreamReader(p.getInputStream()));
String str;
while((str=br2.readLine())!=null)
{
ps.println(str);
}
}
catch(Exception e)
{
System.out.println("Error"+e);
}
}
}
OUTPUT:
53
[Type text] [Type text] [Type text]
CS 8581 - Networks Laboratory Department of Information Technology
Viva Questions:
1. Abbreviate : ARP
2. Define : MAC and abbreviate it.
3. What is physical address and logical address?
RESULT :
Thus the ARP was written and executed successfully.
Criteria Allotted Awarded
Design & Algorithm 20
Logic 20
Code 20
Output 20
Record Submission 10
Viva 10
Total 100
Staff Signature
54
[Type text] [Type text] [Type text]
CS 8581 - Networks Laboratory Department of Information Technology
Ex No : 5(b) Simulation of RARP CO : C307.3
Date : K : K3
AIM
To simulate the Reverse Address Resolution Protocol .
ALGORITHM
CLIENT SIDE
1. Start the Program
2. Use the necessary packages
3. Create a client side socket
4. Establish a connection with the server.
5. Request the server to display the IP address of the MAC address
6. Terminate the Program
SERVER SIDE
1. Start the Program
2. Use the necessary packages
3. Create a server socket
4. Establish a connection with the client
5. Server must maintain a list of IP address and MAC address in a separated lists
6. As per the client's request, display the IP address to the client
7. Terminate the Program
CODE :
ClientRARP.java
import java.io.*;
import java.net.*;
import java.util.*;
class ClientRARP
{
public static void main(String args[]) throws IOException
{
try
{
BufferedReader in=new BufferedReader(new InputStreamReader(System.in));
Socket clsct=new Socket("127.0.0.1",10039);
55
[Type text] [Type text] [Type text]
CS 8581 - Networks Laboratory Department of Information Technology
DataInputStream din=new DataInputStream(clsct.getInputStream());
DataOutputStream dout=new DataOutputStream(clsct.getOutputStream());
System.out.println("Enter the MAC address:");
String str1=in.readLine();
dout.writeBytes(str1+'n');
String str=din.readLine();
System.out.println(str);
clsct.close();
}
catch (Exception e)
{
System.out.println(e);
}
}
}
ServerRARP.java
import java.io.*;
import java.net.*;
import java.util.*;
class ServerRARP
{
public static void main(String args[]) throws IOException
{
try
{
System.out.println("Waiting.....");
ServerSocket ss=new ServerSocket(10039);
Socket s=ss.accept();
DataInputStream din=new DataInputStream(s.getInputStream());
DataOutputStream dout=new DataOutputStream(s.getOutputStream());
String str=din.readLine();
String temp="";
int flag=0;
String ip[]={"165.165.80.80","165.165.79.1"};
String mac[]={"6A:08:AA:C2","8A:BC:E3:FA"};
for(int i=0;i<ip.length;i++)
{
if(str.equals(mac[i]))
{
temp=ip[i];
56
[Type text] [Type text] [Type text]
CS 8581 - Networks Laboratory Department of Information Technology
flag=1;
break;
}
}
if(flag==1)
dout.writeBytes("The IP Address is: "+temp);
else
dout.writeBytes("MAC address not found");
ss.close();
s.close();
}
catch(Exception e)
{
System.out.println(e);
}
}
}
OUTPUT:
57
[Type text] [Type text] [Type text]
CS 8581 - Networks Laboratory Department of Information Technology
Viva Questions :
1. Abbreviate : RARP
2. What RARP will do?
RESULT :
Thus the RARP was written and executed successfully.
Criteria Allotted Awarded
Design & Algorithm 20
Logic 20
Code 20
Output 20
Record Submission 10
Viva 10
Total 100
Staff Signature
58
[Type text] [Type text] [Type text]
CS 8581 - Networks Laboratory Department of Information Technology
Ex No : 6(a) Implementation of PING CO : C307.3
Date : K : K3
Aim:
To implement PING command using Java.
Algorithm:
1. Start the Java IDE
2. Create a Java Project
3. Create a Process object to collect the runtime command
4. Use Scanner / BufferedReader class object to process the command
5. Once the project is run, the PING results will be shown on the interface.
6. End the Program.
CODE :
59
[Type text] [Type text] [Type text]
CS 8581 - Networks Laboratory Department of Information Technology
60
[Type text] [Type text] [Type text]
CS 8581 - Networks Laboratory Department of Information Technology
OUTPUT :
Viva Questions:
1. State the Purpose of PING Command?.
2. How to use Ping Command. Write the Syntax.
3. ping www.google.com what is the result of this?
RESULT:
Thus the PING Command was successfully implemented using Java.
Criteria Allotted Awarded
Design & Algorithm 20
Logic 20
Code 20
Output 20
Record Submission 10
Viva 10
Total 100
Staff Signature
61
[Type text] [Type text] [Type text]
CS 8581 - Networks Laboratory Department of Information Technology
Ex No : 6(b) Implementation of TRACEROUTE CO : C307.3
Date : K : K3
Aim:
To implement TRACEROUTE command using Java.
Algorithm:
1. Start the Java IDE
2. Create a Java Project
3. Create a Process object to collect the runtime command
4. Use Scanner / BufferedReader class object to process the command
5. Once the project is run, the TRACEROUTE results will be shown on the interface.
6. End the Program.
CODE :
62
[Type text] [Type text] [Type text]
CS 8581 - Networks Laboratory Department of Information Technology
63
[Type text] [Type text] [Type text]
CS 8581 - Networks Laboratory Department of Information Technology
OUTPUT :
Viva Questions :
1. What is the purpose of traceroute command?
2. Write the syntax for traceroute command.
Result:
Thus the TRACEROUTE Command was successfully implemented using Java.
Criteria Allotted Awarded
Design & Algorithm 20
Logic 20
Code 20
Output 20
Record Submission 10
Viva 10
Total 100
Staff Signature
64
[Type text] [Type text] [Type text]
CS 8581 - Networks Laboratory Department of Information Technology
Ex No : 7 Web Page download using TCP Sockets CO : C307.4
Date : K : K3
AIM
To download a webpage using Java
ALGORITHM:
CLIENT SIDE:
1) Start the program.
2) Create a socket which binds the Ip address of server and the port address to acquire service.
3) After establishing connection send the url to server.
4) Open a file and store the received data into the file.
5) Close the socket.
6) End the program.
SERVER SIDE
1) Start the program.
2) Create a server socket to activate the port address.
3) Create a socket for the server socket which accepts the connection.
4) After establishing connection receive url from client.
5) Download the content of the url received and send the data to client.
6) Close the socket.
7) End the program.
CODE :
65
[Type text] [Type text] [Type text]
CS 8581 - Networks Laboratory Department of Information Technology
66
[Type text] [Type text] [Type text]
CS 8581 - Networks Laboratory Department of Information Technology
OUTPUT:
Viva Quetions:
1. What is a Web Page?
2. Is it possible to download a web page from a
server?
RESULT:
Thus the webpage download using TCP Socket was done and verified successfully.
Criteria Allotted Awarded
Design & Algorithm 20
Logic 20
Code 20
Output 20
Record Submission 10
Viva 10
Total 100
Staff Signature
67
[Type text] [Type text] [Type text]
CS 8581 - Networks Laboratory Department of Information Technology
Ex No : 8 Implementation of Remote Procedure Call CO : C307.4
Date : K : K3
AIM
To implement Remote Command Execution(RCE).
ALGORITHM
CLIENT SIDE
1. Establish a connection between the Client and Server. Socket client=new
Socket("127.0.0.1",6555);
2. Create instances for input and output streams.
Print Stream ps=new Print Stream(client.getOutputStream());
3. BufferedReader br=new BufferedReader(newInputStreamReader(System.in));
4. Enter the command in Client Window. Send the
message to its output str=br.readLine();
ps.println(str);
SERVER SIDE
1. Accept the connection request by the client. ServerSocket
server=new ServerSocket(6555);
Socket s=server.accept();
2. Get the IPaddress from its inputstream.
BufferedReader br1=new BufferedReader(newInputStreamReader(s.getInputStream()));
ip=br1.readLine();
3. During runtime execute the process Runtime
r=Runtime.getRuntime();
Process p=r.exec(str);
CODE :
68
[Type text] [Type text] [Type text]
CS 8581 - Networks Laboratory Department of Information Technology
69
[Type text] [Type text] [Type text]
CS 8581 - Networks Laboratory Department of Information Technology
OUTPUT :
Viva Questions :
1. Explain the Purpose of Remote Command
Execution
Result :
Thus the implementation RCE is done & executed successfully.
Criteria Allotted Awarded
Design & Algorithm 20
Logic 20
Code 20
Output 20
Record Submission 10
Viva 10
Total 100
Staff Signature
70
[Type text] [Type text] [Type text]
CS 8581 - Networks Laboratory Department of Information Technology
Ex No : 9(a) Study of Network Simulator CO : C307.5
Date : K : K3
Aim :
To study about the Network Simulator
Description :
What is NS2?
•Short characterization
– discrete event network simulator
– packet-level
– link layer and up
– wired and wireless
•A collaborative simulation platform
– freely distributed, open source
– developed by researchers in universities and research institutes
– provide common reference ⇒ promote sharing
– test suites ⇒ increase confidence in results
•Intended users
– researchers
– developers
– educators
NS models
•Traffic models and applications
– web, FTP, telnet, constant bit rate, on-off
•Transport protocols
– unicast: TCP (Tahoe, Reno, Vegas, …), UDP
– multicast: SRM
•Routing and queuing
– wired routing (unicast, multicast), ad hoc routing, Mobile IP
– queuing models: drop tail, RED, fair queuing
•Physical media
– wired (point-to-point, LANs), wireless (multiple propagation models), satellite
71
[Type text] [Type text] [Type text]
CS 8581 - Networks Laboratory Department of Information Technology
BASIC TCL
Variables:
set x 10
puts “x is $x”
Functions and expressions:
Set y [pow $x 2]
Set y [expr $x*$x]
Control flow:
if {$x > 0} {return $x} else {return [expr -$x]}
while {$x > 0} {
puts $x
incr x –1
}
for {set i 0} {$i < 10} {incr i} {puts $i}
Procedures:
proc fact {n} { if {$n == 1} {
return 1 } else {
expr $n*[fact [incr n –1]]]
}
}
proc sum {} { global a b expr $a+$b
}
Tcl benefits:
• Tcl also contains lists, associative arrays, etc.
• Can use a real programming language to construct topologies, traffic sources, applications, etc.
ELEMENTS OF TCL
• Assumption:
– we only consider wired simulations (without routing)
• Important elements:
– Create the event scheduler and random number generator
– Create network
• nodes and links
– Create transport connection
72
[Type text] [Type text] [Type text]
CS 8581 - Networks Laboratory Department of Information Technology
• TCP, UDP
– Create applications
• CBR, FTP
– Setup tracing
• trace queues and flows
CREATING THE EVENT SCHEDULER
• Create event scheduler
– set ns [new Simulator]
• Schedule events
– $ns at <time> <event>
– <event>: any legitimate ns/tcl commands
• Start scheduler
– $ns run
CREATING THE NETWORK
• Nodes
– set n0 [$ns node]
– set n1 [$ns node]
• Links and queuing
– $ns duplex-link $n0 $n1 <bandwidth> <delay> <queue_type>
– <queue_type>: DropTail, RED, CBQ, FQ, SFQ, DRR
– example: link with 10 Mbps, 10 ms delay, buffer size 100, RED buffer control
$ns duplex-link $n0 $n1 10Mbps 10ms RED
# Set queue size
$ns queue-limit $n0 $n1 100
# Set RED parameters
set redq [[$ns link $n0 $n1] queue]
$redq set thresh_ 0
$redq set maxthresh_ 100
$redq set linterm_ 20
$redq set mean_pktsize_ 500
$redq set q_weight_ 0.001
73
[Type text] [Type text] [Type text]
CS 8581 - Networks Laboratory Department of Information Technology
CREATING CONNECTIONS : UDP
• UDP
– set udp [new Agent/UDP]
– set null [new Agent/Null]
– $ns attach-agent $n0 $udp
– $ns attach-agent $n1 $null
– $ns connect $udp $null
• All above combined into one command:
– $ns create-connection <src_type> <src_node> <dst_type> <dst_node> <packet_class>
– $ns create-connection UDP $n0 Null $n1 1
CREATING TRAFFIC : On top of UDP
• CBR
– Constant Bit Rate
– set src [new Application/Traffic/CBR]
• Exponential or Pareto on-off
– on/off times exponentially/Pareto distributed
– set src [new Application/Traffic/Exponential]
– set src [new Application/Traffic/Pareto]
• Connecting application to transport
– “$udp” defined earlier
– $src attach-agent $udp
CREATING CONNECTIONS : TCP
• TCP
– set tcp [new Agent/TCP]
– set tcpsink [new Agent/TCPSink]
– $ns attach-agent $n0 $tcp
– $ns attach-agent $n1 $tcpsink
– $ns connect $tcp $tcpsink
• … or above in one command:
– $ns create-connection TCP $n0 TCPSink $n1 1
• Different TCP variants:
– TCP = Tahoe TCP (slow start, AIMD)
– TCP/Reno = Reno TCP (above + fast retransmit/fast recovery)
– TCP/NewReno = modefied Reno TCP with improved fast retransmit
– TCP/Sack1 = SACK TCP (selective ACK)
74
[Type text] [Type text] [Type text]
CS 8581 - Networks Laboratory Department of Information Technology
– other sources: TCP for asymmetric links (wireless), RTP source, RTCP source
– different sinks: for each TCP type, LossMonitor (sink with packet loss monitoring)
CREATING TRAFFIC : On top of TCP
• FTP
– set ftp [new Application/FTP]
– $ftp attach-agent $tcp
• Telnet
– set telnet [new Application/Telnet]
– $telnet attach-agent $tcp
STARTING/STOPPING TRAFFIC AGENTS
• Starting and stopping times scheduled as events to the scheduler
– $ns at <time> <event>
• Starting
– $ns at 1.0 “$ftp start”
– greedy source (sends infinitely long)
– similarly for CBR, telnet and on/off sources
• Stopping
– $ns at 5.0 “$ftp stop”
– similarly for CBR, telnet and on/off sources
• Sending for example 1000 packets
– $ns at 7.0 “$ftp produce 1000”
– works only for FTP
TRACING
• Trace packets on all links of the network
– $ns trace-all [open test.out w]
• Turn on tracing on specific links
– $ns trace-queue $n0 $n1
• Tace format:
+ 0.89456 0 2 cbr 210 ------- 0 0.0 3.1 0 0 - 0.89456 0 2 cbr 210 --
----- 0 0.0 3.1 0 0 r 1.00234 0 2 cbr 210 ------- 0 0.0 3.1 0 0
– event type: (enque = +, deque = -, receive = r, drop = d)
– event time
– node ids of traced link (2 fields)
– name of packet (“source’s name”)
– packet size
75
[Type text] [Type text] [Type text]
CS 8581 - Networks Laboratory Department of Information Technology
– flags (not used here)
– flow identifier
– source/destination addresses (2 fields)
– sequence number
– unique packet identifier (all packets created in the simulaiton have a unique id)
MONITORING
• Sometimes tracing produces “too much” data
– e.g., just want to know number of arrivals or dropped packets on a link or per flow
– monitors
• Queue monitors
– set qmon [$ns monitor-queue $n0 $n1]
– to read number of packet arrivals and drops
• set parr [$qmon set parrivals_]
• set drops [$qmon set pdrops_]
• Flow monitors
– enable flow monitoring
• set fmon [$ns makeflowmon Fid]
• $ns attach-fmon [$ns link $n0 $n1] $fmon
– count arrivals and drops for flow with id xx
• set fclassifier [$fmon classifier]
• set flow1 [$fclassifier lookup auto 0 0 xx]
• set parr [$flow1 set parrivals_]
• set pdrops [$flow1 set pdrops_]
GENERIC SCRIPT STRUCTURE
set ns [new Simulator]
# [Turn on tracing]
# Create topology VIVA :
# Setup packet loss, link dynamics
# Create routing agents
# Create:
# - multicast groups
# - protocol agents
# - application and/or setup traffic sources
# Post-processing procs
# Start simulation
Result :
Thus the study of Network Simulator is completed successfully.
76
[Type text] [Type text] [Type text]
CS 8581 - Networks Laboratory Department of Information Technology
Ex No : 6 (b) Simulation of TCP Congestion Control using Network Simulator CO : R17C308.3
Date : K : K3
Aim :
To simulate TCP Congestion Control mechanism using NS-2
Description :
The topology in the wired network is set-up using the node and link creation APIs. The bottleneck is a
duplex link that has router in both directions representing the traffic flow from multiple sources. The congestion in
the wired network can be created using the bottleneck link. Create a tcl script file to induce the congestion in which
each link is configured with the specific bandwidth, propagation delay and DropTail queue. Data transmission
between the sender1 and receiver1 is created using the tcp connection and FTP application. Data transmission
between the sender2 and receiver2 is created using the udp agent and CBR traffic. Congestion occurs at the link
between router1 and router2 (bottleneck link) due to the high data flow rate that exceeds the link capacity. The length
of the queue is limited. TCP enforces congestion control mechanism automatically by adjusting the sending data rate
according to the acknowledgment arrival time.
CODE :
#Create a simulator object
set ns [new Simulator]
#Define different colors for data flows
$ns color 1 Blue
$ns color 2 Red
#Open the nam trace file
set nf [open out.nam w]
$ns namtrace-all $nf
#Define a 'finish' procedure
proc finish {} {
global ns nf
$ns flush-trace
#Close the trace file
close $nf
#Execute nam on the trace file
exec nam out.nam &
exit 0
77
[Type text] [Type text] [Type text]
CS 8581 - Networks Laboratory Department of Information Technology
}
#Create four nodes
set n0 [$ns node]
set n1 [$ns node]
set n2 [$ns node]
set n3 [$ns node]
#Create links between the nodes
$ns duplex-link $n0 $n2 1Mb 10ms DropTail
$ns duplex-link $n1 $n2 1Mb 10ms DropTail
$ns duplex-link $n3 $n2 1Mb 10ms SFQ
$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 the link between node 2 and node 3
$ns duplex-link-op $n2 $n3 queuePos 0.5
#Create a UDP agent and attach it to node n0
set udp0 [new Agent/UDP]
$udp0 set class_ 1
$ns attach-agent $n0 $udp0
# Create a CBR traffic source and attach it to udp0
set cbr0 [new Application/Traffic/CBR]
$cbr0 set packetSize_ 500
$cbr0 set interval_ 0.005
$cbr0 attach-agent $udp0
#Create a UDP agent and attach it to node n1
set udp1 [new Agent/UDP]
$udp1 set class_ 2
$ns attach-agent $n1 $udp1
# Create a CBR traffic source and attach it to udp1
set cbr1 [new Application/Traffic/CBR]
$cbr1 set packetSize_ 500
$cbr1 set interval_ 0.005
$cbr1 attach-agent $udp1
#Create a Null agent (a traffic sink) and attach it to node n3
set null0 [new Agent/Null]
$ns attach-agent $n3 $null0
#Connect the traffic sources with the traffic sink
$ns connect $udp0 $null0
$ns connect $udp1 $null0
#Schedule events for the CBR agents
$ns at 0.5 "$cbr0 start"
$ns at 1.0 "$cbr1 start"
78
[Type text] [Type text] [Type text]
CS 8581 - Networks Laboratory Department of Information Technology
$ns at 4.0 "$cbr1 stop"
$ns at 4.5 "$cbr0 stop"
#Call the finish procedure after 5 seconds of simulation time
$ns at 5.0 "finish"
#Run the simulation
$ns run
OUTPUT :
Before Congestion
79
[Type text] [Type text] [Type text]
CS 8581 - Networks Laboratory Department of Information Technology
After Congestion
Viva Questions :
1. Define : Congestion
2. State the effects of Congestion
Result :
Thus the TCP Congestion Control mechanism using NS-2 was simulated successfully.
Criteria Allotted Awarded
Design & Algorithm 20
Logic 20
Code 20
Output 20
Record Submission 10
Viva 10
Total 100
Staff Signature
80
[Type text] [Type text] [Type text]
CS 8581 - Networks Laboratory Department of Information Technology
Ex No : 10 Simulation of Routing Protocols using Network Simulator CO : C307.5
Date : K : K3
Aim:
To simulate routing protocols like Link State and Distance Vector algorithms using NS-2
Description:
Link State Routing Protocol :
The Link State (LS) routing protocol has two components such as routing agent and route logic. The routing agent
exchanges routing packet with neighbors in the link state manner while the route logic does Dijkstra on exploiting
the information gathered by the routing agents to perform the actual route computation.
Distance Vector Routing Protocol :
In Distance Vector (DV), each node sends periodic route updates for every 2 seconds. Apart from the periodic
updates, each node/agent sends triggered updates as a result of changes in the forwarding table in the node if any.
This occurs either due to changes in the network topology or the node received a route update and as a result, it
composes a fresh route.
Algorithm : Link State Routing Protocol
81
[Type text] [Type text] [Type text]
CS 8581 - Networks Laboratory Department of Information Technology
CODE :
LSRP.TCL
#Create a new simulator object
set ns [new Simulator]
#Open trace Files
set nr [open lsrp.tr w]
$ns trace-all $nr
set nf [open lsrp.nam w]
$ns namtrace-all $nf
#Finish Procedure
proc finish { } {
global ns nr nf
$ns flush-trace
close $nf
close $nr
exec nam lsrp.nam &
exit 0
}
#Create 12 nodes
for { set i 0 } { $i < 12} { incr i 1 } {
set n($i) [$ns node]}
#Create Links
for {set i 0} {$i < 8} {incr i} {
$ns duplex-link $n($i) $n([expr $i+1]) 1Mb 10ms DropTail }
$ns duplex-link $n(0) $n(8) 1Mb 10ms DropTail
$ns duplex-link $n(1) $n(10) 1Mb 10ms DropTail
$ns duplex-link $n(0) $n(9) 1Mb 10ms DropTail
$ns duplex-link $n(9) $n(11) 1Mb 10ms DropTail
$ns duplex-link $n(10) $n(11) 1Mb 10ms DropTail
$ns duplex-link $n(11) $n(5) 1Mb 10ms DropTail
#Create UDP Agent and attach it to Node n0
set udp0 [new Agent/UDP]
$ns attach-agent $n(0) $udp0
#Create CBR traffic and attach it to UDP Agent udp0
set cbr0 [new Application/Traffic/CBR]
$cbr0 set packetSize_ 500
$cbr0 set interval_ 0.005
$cbr0 attach-agent $udp0
82
[Type text] [Type text] [Type text]
CS 8581 - Networks Laboratory Department of Information Technology
#Setup UDP connection between n0 and n5
#Set n5 as Sink for Source Node n0
set null0 [new Agent/Null]
$ns attach-agent $n(5) $null0
$ns connect $udp0 $null0
#Create UDP Agent and attach it to Node n1
set udp1 [new Agent/UDP]
$ns attach-agent $n(1) $udp1
#Create CBR traffic and attach it to UDP Agent udp1
set cbr1 [new Application/Traffic/CBR]
$cbr1 set packetSize_ 500
$cbr1 set interval_ 0.005
$cbr1 attach-agent $udp1
#Create Sink for n5
set null0 [new Agent/Null]
$ns attach-agent $n(5) $null0
$ns connect $udp1 $null0
#define Link State algorithm as routing protocol
$ns rtproto LS
#define links going down and coming up
$ns rtmodel-at 10.0 down $n(11) $n(5)
$ns rtmodel-at 15.0 down $n(7) $n(6)
$ns rtmodel-at 30.0 up $n(11) $n(5)
$ns rtmodel-at 20.0 up $n(7) $n(6)
#Set different colors for the two CBR traffic flows
$udp0 set fid_ 1
$udp1 set fid_ 2
$ns color 1 Red
$ns color 2 Green
#Set start time and stop time for traffic flows
$ns at 1.0 "$cbr0 start"
$ns at 2.0 "$cbr1 start"
#Call the Finish Procedure
$ns at 45 "finish"
#Run the Simulation
$ns run
83
[Type text] [Type text] [Type text]
CS 8581 - Networks Laboratory Department of Information Technology
OUTPUT :
84
[Type text] [Type text] [Type text]
CS 8581 - Networks Laboratory Department of Information Technology
Algorithm : Distance Vector Routing Protocol
CODE :
DVRP.TCL
#Create a new simulator object
set ns [new Simulator]
#Open trace Files
set nr [open dvrp.tr w]
$ns trace-all $nr
set nf [open dvrp.nam w]
$ns namtrace-all $nf
#Finish Procedure
proc finish { } {
global ns nr nf
$ns flush-trace
close $nf
close $nr
exec nam dvrp.nam &
exit 0
}
#Create 12 nodes
for { set i 0 } { $i < 12} { incr i 1 } {
set n($i) [$ns node]}
#Create Links
for {set i 0} {$i < 8} {incr i} {
$ns duplex-link $n($i) $n([expr $i+1]) 1Mb 10ms DropTail }
$ns duplex-link $n(0) $n(8) 1Mb 10ms DropTail
85
[Type text] [Type text] [Type text]
CS 8581 - Networks Laboratory Department of Information Technology
$ns duplex-link $n(1) $n(10) 1Mb 10ms DropTail
$ns duplex-link $n(0) $n(9) 1Mb 10ms DropTail
$ns duplex-link $n(9) $n(11) 1Mb 10ms DropTail
$ns duplex-link $n(10) $n(11) 1Mb 10ms DropTail
$ns duplex-link $n(11) $n(5) 1Mb 10ms DropTail
#Create UDP Agent and attach it to Node n0
set udp0 [new Agent/UDP]
$ns attach-agent $n(0) $udp0
#Create CBR traffic and attach it to UDP Agent udp0
set cbr0 [new Application/Traffic/CBR]
$cbr0 set packetSize_ 500
$cbr0 set interval_ 0.005
$cbr0 attach-agent $udp0
#Setup UDP connection between n0 and n5
#Set n5 as Sink for Source Node n0
set null0 [new Agent/Null]
$ns attach-agent $n(5) $null0
$ns connect $udp0 $null0
#Create UDP Agent and attach it to Node n1
set udp1 [new Agent/UDP]
$ns attach-agent $n(1) $udp1
#Create CBR traffic and attach it to UDP Agent udp1
set cbr1 [new Application/Traffic/CBR]
$cbr1 set packetSize_ 500
$cbr1 set interval_ 0.005
$cbr1 attach-agent $udp1
#Create Sink for n5
set null0 [new Agent/Null]
$ns attach-agent $n(5) $null0
$ns connect $udp1 $null0
#define distance vector algorithm as routing protocol
$ns rtproto DV
#define links going down and coming up
$ns rtmodel-at 10.0 down $n(11) $n(5)
$ns rtmodel-at 15.0 down $n(7) $n(6)
$ns rtmodel-at 30.0 up $n(11) $n(5)
$ns rtmodel-at 20.0 up $n(7) $n(6)
86
[Type text] [Type text] [Type text]
CS 8581 - Networks Laboratory Department of Information Technology
#Set different colors for the two CBR traffic flows
$udp0 set fid_ 1
$udp1 set fid_ 2
$ns color 1 Red
$ns color 2 Green
#Set start time and stop time for traffic flows
$ns at 1.0 "$cbr0 start"
$ns at 2.0 "$cbr1 start"
#Call the Finish Procedure
$ns at 45 "finish"
#Run the Simulation
$ns run
OUTPUT:
87
[Type text] [Type text] [Type text]
CS 8581 - Networks Laboratory Department of Information Technology
Viva Questions :
1. List any two differences between Distance Vector and link state Routing Protoclos
2. Routing Information Protocol is an example for __________________________
3. Protocol example for Link State Routing
Protocols is: _________ , ________
Result :
Thus the Routing Protocols were simulated successfully.
Criteria Allotted Awarded
Design & Algorithm 20
Logic 20
Code 20
Output 20
Record Submission 10
Viva 10
Total 100
Staff Signature
88
[Type text] [Type text] [Type text]
CS 8581 - Networks Laboratory Department of Information Technology
Ex No : 11 Implementation of Bit Stuffing & DeStuffing CO : C307.1
Date : K : K3
AIM:
To write a Java Program to perform Bit Stuffing and Bit Destuffing
ALGORITHM:
Bit Stuffing:
1. Create two file pointers namely f1 and f2.
2. Use first file pointer to open the input file and second file pointer to write the output in output file
3. Read input file and check whether there are 5 consecutive ones.
4. If 5 consecutive one’s appear in the input file, stuff 0 as its next bit else continue
5. Repeat steps 3&4 until all the bits are read
6. write a data along with stuffed bits in the output file.
Bit Destuffing:
1. Create two file pointers namely f1 and f2.
2. Use first file pointer to open the input file and second file pointer to write the output in output file
3. Read input file and check whether there are 5 consecutive ones.
4. If zero is followed by 5 consecutive one’s, then delete zero bit else continue.
5. Repeat steps 3&4 until all the bits are read
6. write a data along with destuffed bits in the output file.
CODE :
89
[Type text] [Type text] [Type text]
CS 8581 - Networks Laboratory Department of Information Technology
90
[Type text] [Type text] [Type text]
CS 8581 - Networks Laboratory Department of Information Technology
OUTPUT :
Viva Questions :
1. What is Bit stuffing?.
2. In which OSI layer, bit stuffing will be done?
3. State the purpose of Bit stuffing.
4. Stuff the following: 0101111110101
RESULT:
Thus the Program for Bit stuffing and Bit Destuffing was written and correct output was verified
Criteria Allotted Awarded
Design & Algorithm 20
Logic 20
Code 20
Output 20
Record Submission 10
Viva 10
Total 100
Staff Signature
91
[Type text] [Type text] [Type text]
CS 8581 - Networks Laboratory Department of Information Technology
REFERENCES :
1. http://javabasicstudy.blogspot.com/2011/07/program-for-reverse-address-resolutuion.html#more
2. https://www.youtube.com/watch?v=3YoKVswJsKI
3. Socket Programming in Java : https://goo.gl/jlMEbg

Más contenido relacionado

La actualidad más candente

통신시스템(Wcdma network)
통신시스템(Wcdma network)통신시스템(Wcdma network)
통신시스템(Wcdma network)
영기 김
 
Training document e ran2.2_lte tdd system multiple antenna techniques(mimo an...
Training document e ran2.2_lte tdd system multiple antenna techniques(mimo an...Training document e ran2.2_lte tdd system multiple antenna techniques(mimo an...
Training document e ran2.2_lte tdd system multiple antenna techniques(mimo an...
ProcExpl
 
LTE Reviews - PCI Analysis
LTE Reviews - PCI AnalysisLTE Reviews - PCI Analysis
LTE Reviews - PCI Analysis
paulo_campolina
 
Multicarrier interworking strategy
Multicarrier interworking strategyMulticarrier interworking strategy
Multicarrier interworking strategy
Hieu Phong
 

La actualidad más candente (20)

Mobile computing Unit III MANET Notes
Mobile computing Unit III MANET NotesMobile computing Unit III MANET Notes
Mobile computing Unit III MANET Notes
 
Introduction to layer 2 attacks & mitigation
Introduction to layer 2 attacks & mitigationIntroduction to layer 2 attacks & mitigation
Introduction to layer 2 attacks & mitigation
 
Mobile Originated Call Process in Simple Words
Mobile Originated Call Process in Simple WordsMobile Originated Call Process in Simple Words
Mobile Originated Call Process in Simple Words
 
Dmcr lte trial feature
Dmcr lte trial featureDmcr lte trial feature
Dmcr lte trial feature
 
Gsm architecture
Gsm architecture Gsm architecture
Gsm architecture
 
GPRS KPIs based on network performance
GPRS KPIs based on network performance GPRS KPIs based on network performance
GPRS KPIs based on network performance
 
Destination Sequenced Distance Vector Routing (DSDV)
Destination Sequenced Distance Vector Routing (DSDV)Destination Sequenced Distance Vector Routing (DSDV)
Destination Sequenced Distance Vector Routing (DSDV)
 
Wireless & Mobile Communications Questions & Answers
Wireless & Mobile Communications Questions & AnswersWireless & Mobile Communications Questions & Answers
Wireless & Mobile Communications Questions & Answers
 
190937694 csfb-call-flows
190937694 csfb-call-flows190937694 csfb-call-flows
190937694 csfb-call-flows
 
통신시스템(Wcdma network)
통신시스템(Wcdma network)통신시스템(Wcdma network)
통신시스템(Wcdma network)
 
Training document e ran2.2_lte tdd system multiple antenna techniques(mimo an...
Training document e ran2.2_lte tdd system multiple antenna techniques(mimo an...Training document e ran2.2_lte tdd system multiple antenna techniques(mimo an...
Training document e ran2.2_lte tdd system multiple antenna techniques(mimo an...
 
Dynamic Routing All Algorithms, Working And Basics
Dynamic Routing All Algorithms, Working And BasicsDynamic Routing All Algorithms, Working And Basics
Dynamic Routing All Algorithms, Working And Basics
 
LTE Reviews - PCI Analysis
LTE Reviews - PCI AnalysisLTE Reviews - PCI Analysis
LTE Reviews - PCI Analysis
 
Gsm architecture and call flow
Gsm architecture and call flowGsm architecture and call flow
Gsm architecture and call flow
 
Mobile Ad hoc network
Mobile Ad hoc networkMobile Ad hoc network
Mobile Ad hoc network
 
Multicarrier interworking strategy
Multicarrier interworking strategyMulticarrier interworking strategy
Multicarrier interworking strategy
 
OSPF Virtual Link
OSPF Virtual LinkOSPF Virtual Link
OSPF Virtual Link
 
Network survivability karunakar
Network survivability karunakarNetwork survivability karunakar
Network survivability karunakar
 
Cognitive radio networks
Cognitive radio networksCognitive radio networks
Cognitive radio networks
 
Synchronization For High Frequency Trading Networks: A How To Guide
Synchronization For High Frequency Trading Networks: A How To GuideSynchronization For High Frequency Trading Networks: A How To Guide
Synchronization For High Frequency Trading Networks: A How To Guide
 

Similar a IT6511 Networks Laboratory

1 unit- PPT - SS22-23.pptx
1 unit- PPT - SS22-23.pptx1 unit- PPT - SS22-23.pptx
1 unit- PPT - SS22-23.pptx
inian2
 
Final teit syllabus_2012_course_04.06.2014
Final teit syllabus_2012_course_04.06.2014Final teit syllabus_2012_course_04.06.2014
Final teit syllabus_2012_course_04.06.2014
deepti112233
 
(R18) B.Tech. CSE Syllabus.pdf
(R18) B.Tech. CSE Syllabus.pdf(R18) B.Tech. CSE Syllabus.pdf
(R18) B.Tech. CSE Syllabus.pdf
fisdfg
 
1619_DANGANTHANH_GCS190644_AssignmentFull.docx
1619_DANGANTHANH_GCS190644_AssignmentFull.docx1619_DANGANTHANH_GCS190644_AssignmentFull.docx
1619_DANGANTHANH_GCS190644_AssignmentFull.docx
khangphanvan
 

Similar a IT6511 Networks Laboratory (20)

Cs8581 networks lab manual 2017
Cs8581 networks lab manual   2017Cs8581 networks lab manual   2017
Cs8581 networks lab manual 2017
 
Cn lab manual sb 19_scsl56 (1)
Cn lab manual sb 19_scsl56 (1)Cn lab manual sb 19_scsl56 (1)
Cn lab manual sb 19_scsl56 (1)
 
Ade manual with co po-18scheme
Ade manual with co po-18schemeAde manual with co po-18scheme
Ade manual with co po-18scheme
 
Dsp lab manual
Dsp lab manualDsp lab manual
Dsp lab manual
 
Hdllab1
Hdllab1Hdllab1
Hdllab1
 
Dc course file
Dc course fileDc course file
Dc course file
 
1 unit- PPT - SS22-23.pptx
1 unit- PPT - SS22-23.pptx1 unit- PPT - SS22-23.pptx
1 unit- PPT - SS22-23.pptx
 
Np lab
Np labNp lab
Np lab
 
CS8461 Operating System Lab Manual S.Selvi
CS8461 Operating System Lab Manual S.SelviCS8461 Operating System Lab Manual S.Selvi
CS8461 Operating System Lab Manual S.Selvi
 
Digital System Design with FPGAs Lab Manual.pdf
Digital System Design with FPGAs Lab Manual.pdfDigital System Design with FPGAs Lab Manual.pdf
Digital System Design with FPGAs Lab Manual.pdf
 
1 unit- PPT - SS22-23.pptx
1 unit- PPT - SS22-23.pptx1 unit- PPT - SS22-23.pptx
1 unit- PPT - SS22-23.pptx
 
Final teit syllabus_2012_course_04.06.2014
Final teit syllabus_2012_course_04.06.2014Final teit syllabus_2012_course_04.06.2014
Final teit syllabus_2012_course_04.06.2014
 
B tech information technology syllabus - MITAOE
B tech information technology syllabus - MITAOEB tech information technology syllabus - MITAOE
B tech information technology syllabus - MITAOE
 
Ece r14 3rd_to8th
Ece r14 3rd_to8thEce r14 3rd_to8th
Ece r14 3rd_to8th
 
37.%20 m.e.%20cse%20
37.%20 m.e.%20cse%2037.%20 m.e.%20cse%20
37.%20 m.e.%20cse%20
 
Syllabus
SyllabusSyllabus
Syllabus
 
Syllabus
SyllabusSyllabus
Syllabus
 
WIRELESS LAN TECHNOLOGIES
WIRELESS LAN TECHNOLOGIESWIRELESS LAN TECHNOLOGIES
WIRELESS LAN TECHNOLOGIES
 
(R18) B.Tech. CSE Syllabus.pdf
(R18) B.Tech. CSE Syllabus.pdf(R18) B.Tech. CSE Syllabus.pdf
(R18) B.Tech. CSE Syllabus.pdf
 
1619_DANGANTHANH_GCS190644_AssignmentFull.docx
1619_DANGANTHANH_GCS190644_AssignmentFull.docx1619_DANGANTHANH_GCS190644_AssignmentFull.docx
1619_DANGANTHANH_GCS190644_AssignmentFull.docx
 

Último

result management system report for college project
result management system report for college projectresult management system report for college project
result management system report for college project
Tonystark477637
 
Structural Analysis and Design of Foundations: A Comprehensive Handbook for S...
Structural Analysis and Design of Foundations: A Comprehensive Handbook for S...Structural Analysis and Design of Foundations: A Comprehensive Handbook for S...
Structural Analysis and Design of Foundations: A Comprehensive Handbook for S...
Dr.Costas Sachpazis
 

Último (20)

ONLINE FOOD ORDER SYSTEM PROJECT REPORT.pdf
ONLINE FOOD ORDER SYSTEM PROJECT REPORT.pdfONLINE FOOD ORDER SYSTEM PROJECT REPORT.pdf
ONLINE FOOD ORDER SYSTEM PROJECT REPORT.pdf
 
Roadmap to Membership of RICS - Pathways and Routes
Roadmap to Membership of RICS - Pathways and RoutesRoadmap to Membership of RICS - Pathways and Routes
Roadmap to Membership of RICS - Pathways and Routes
 
Glass Ceramics: Processing and Properties
Glass Ceramics: Processing and PropertiesGlass Ceramics: Processing and Properties
Glass Ceramics: Processing and Properties
 
Call Girls Walvekar Nagar Call Me 7737669865 Budget Friendly No Advance Booking
Call Girls Walvekar Nagar Call Me 7737669865 Budget Friendly No Advance BookingCall Girls Walvekar Nagar Call Me 7737669865 Budget Friendly No Advance Booking
Call Girls Walvekar Nagar Call Me 7737669865 Budget Friendly No Advance Booking
 
NFPA 5000 2024 standard .
NFPA 5000 2024 standard                                  .NFPA 5000 2024 standard                                  .
NFPA 5000 2024 standard .
 
PVC VS. FIBERGLASS (FRP) GRAVITY SEWER - UNI BELL
PVC VS. FIBERGLASS (FRP) GRAVITY SEWER - UNI BELLPVC VS. FIBERGLASS (FRP) GRAVITY SEWER - UNI BELL
PVC VS. FIBERGLASS (FRP) GRAVITY SEWER - UNI BELL
 
result management system report for college project
result management system report for college projectresult management system report for college project
result management system report for college project
 
UNIT - IV - Air Compressors and its Performance
UNIT - IV - Air Compressors and its PerformanceUNIT - IV - Air Compressors and its Performance
UNIT - IV - Air Compressors and its Performance
 
Unit 1 - Soil Classification and Compaction.pdf
Unit 1 - Soil Classification and Compaction.pdfUnit 1 - Soil Classification and Compaction.pdf
Unit 1 - Soil Classification and Compaction.pdf
 
Structural Analysis and Design of Foundations: A Comprehensive Handbook for S...
Structural Analysis and Design of Foundations: A Comprehensive Handbook for S...Structural Analysis and Design of Foundations: A Comprehensive Handbook for S...
Structural Analysis and Design of Foundations: A Comprehensive Handbook for S...
 
(INDIRA) Call Girl Bhosari Call Now 8617697112 Bhosari Escorts 24x7
(INDIRA) Call Girl Bhosari Call Now 8617697112 Bhosari Escorts 24x7(INDIRA) Call Girl Bhosari Call Now 8617697112 Bhosari Escorts 24x7
(INDIRA) Call Girl Bhosari Call Now 8617697112 Bhosari Escorts 24x7
 
Water Industry Process Automation & Control Monthly - April 2024
Water Industry Process Automation & Control Monthly - April 2024Water Industry Process Automation & Control Monthly - April 2024
Water Industry Process Automation & Control Monthly - April 2024
 
The Most Attractive Pune Call Girls Budhwar Peth 8250192130 Will You Miss Thi...
The Most Attractive Pune Call Girls Budhwar Peth 8250192130 Will You Miss Thi...The Most Attractive Pune Call Girls Budhwar Peth 8250192130 Will You Miss Thi...
The Most Attractive Pune Call Girls Budhwar Peth 8250192130 Will You Miss Thi...
 
Call Girls Pimpri Chinchwad Call Me 7737669865 Budget Friendly No Advance Boo...
Call Girls Pimpri Chinchwad Call Me 7737669865 Budget Friendly No Advance Boo...Call Girls Pimpri Chinchwad Call Me 7737669865 Budget Friendly No Advance Boo...
Call Girls Pimpri Chinchwad Call Me 7737669865 Budget Friendly No Advance Boo...
 
Thermal Engineering-R & A / C - unit - V
Thermal Engineering-R & A / C - unit - VThermal Engineering-R & A / C - unit - V
Thermal Engineering-R & A / C - unit - V
 
University management System project report..pdf
University management System project report..pdfUniversity management System project report..pdf
University management System project report..pdf
 
BSides Seattle 2024 - Stopping Ethan Hunt From Taking Your Data.pptx
BSides Seattle 2024 - Stopping Ethan Hunt From Taking Your Data.pptxBSides Seattle 2024 - Stopping Ethan Hunt From Taking Your Data.pptx
BSides Seattle 2024 - Stopping Ethan Hunt From Taking Your Data.pptx
 
data_management_and _data_science_cheat_sheet.pdf
data_management_and _data_science_cheat_sheet.pdfdata_management_and _data_science_cheat_sheet.pdf
data_management_and _data_science_cheat_sheet.pdf
 
Booking open Available Pune Call Girls Koregaon Park 6297143586 Call Hot Ind...
Booking open Available Pune Call Girls Koregaon Park  6297143586 Call Hot Ind...Booking open Available Pune Call Girls Koregaon Park  6297143586 Call Hot Ind...
Booking open Available Pune Call Girls Koregaon Park 6297143586 Call Hot Ind...
 
(INDIRA) Call Girl Aurangabad Call Now 8617697112 Aurangabad Escorts 24x7
(INDIRA) Call Girl Aurangabad Call Now 8617697112 Aurangabad Escorts 24x7(INDIRA) Call Girl Aurangabad Call Now 8617697112 Aurangabad Escorts 24x7
(INDIRA) Call Girl Aurangabad Call Now 8617697112 Aurangabad Escorts 24x7
 

IT6511 Networks Laboratory

  • 1. 1 DEPARTMENT OF INFORMATION TECHNOLOGY LAB MANUAL CUM RECORD NOTE BOOK CS8581 - NETWORKS LAB Reg. 2017 - Third Year IT / ODD Semester Prepared by, D.Kayathri Devi, AP/IT
  • 2. Name : Registration Number : Roll Number : Branch : Year : This is the Bonafide Record work done in the CS 8581 - Networks Laboratory during the year STAFF IN CHARGE HEAD OF THE DEPARTMENT Submitted for the Practical examinationheld on Engineering and Technology, S.P.G.C.Nagar, K.Vellakulam ,Near Virudhunagar,Madurai. at Kamaraj College of INTERNAL EXAMINER EXTERNAL EXAMINER 2
  • 3. CS8581 – Networks Laboratory Department of Information Technology 3 PROGRAMME EDUCATION OBJECTIVES Mission To make the department of Information Technology the unique of its kind in the field of Research and Development activities in this part of world. Vision To impart highly innovative and technical knowledge in the field of Information Technology to the urban and unreachable rural student folks through Total Quality Education Technical Knowledge PEO 1 : Graduates of the programme will exhibit expertise in technical knowledge by applying distinctive skills in various fields of Information Technology Life long learning and Societal Needs PEO 2 : Graduates will become pioneers in the field of IT by working collaboratively and providing solutions to meet societal needs through persistent learning Total Quality Education PEO 3 : Graduates will be able to adopt innovative practices and contribute towards research and technological development in the field of IT through Total Quality Education DEPARTMENT OF INFORMATION TECHOLOGY
  • 4. 5 CS 8581 - Networks Laboratory Department of Information Technology PROGRAM OUTCOMES (POs) Engineering Graduates will be able to: 1. Engineering knowledge: Apply the knowledge of mathematics, science, engineering fundamentals, and an engineering specialization to the solution of complex engineering problems. 2. Problem analysis: Identify, formulate, review research literature, and analyse complex engineering problems reaching substantiated conclusions using first principles of mathematics, natural sciences, and engineering sciences. 3. Design/development of solutions: Design solutions for complex engineering problems and design system components or processes that meet the specified needs with appropriate consideration for the public health and safety, and the cultural, societal, and environmental considerations. 4. Conduct investigations of complex problems: Use research-based knowledge and research methods including design of experiments, analysis and interpretation of data, and synthesis of the information to provide valid conclusions. 5. Modern tool usage: Create, select, and apply appropriate techniques, resources, and modern engineering and IT tools including prediction and modelling to complex engineering activities with an understanding of the limitations. 6. The engineer and society: Apply reasoning informed by the contextual knowledge to assess societal, health, safety, legal and cultural issues and the consequent responsibilities relevant to the professional engineering practice. 7. Environment and sustainability: Understand the impact of the professional engineering solutions in societal and environmental contexts, and demonstrate the knowledge of, and need for sustainable development. 8. Ethics: Apply ethical principles and commit to professional ethics and responsibilities and norms of the engineering practice. 9. Individual and team work: Function effectively as an individual, and as a member or leader in diverse teams, and in multidisciplinary settings. 10. Communication: Communicate effectively on complex engineering activities with the engineering community and with society at large, such as, being able to comprehend and write effective reports and design documentation, make effective presentations, and give and receive
  • 5. 6 clear instructions. CS 8581 - Networks Laboratory Department of Information Technology 11. Project management and finance: Demonstrate knowledge and understanding of the engineering and management principles and apply these to one’s own work, as a member and leader in a team, to manage projects and in multidisciplinary environments. 12. Life-long learning: Recognize the need for, and have the preparation and ability to engage in independent and life-long learning in the broadest context of technological change. PROGRAM SPECIFIC OUTCOMES (PSO) Engineering Graduates will be able to: 1. Design and develop applications in the field of Information Technology by applying the knowledge acquired from Computer Organization & Engineering, Networking, Software Engineering & Programming, Data Analytics & other allied topics. 2. Demonstrate an ability to analyze ,design, and develop software solutions to cater the needs of diversified business sectors
  • 6. 11 [Type text]IT [Type text] [Type text] CS 8581 - Networks Laboratory Department of Information Technology Syllabus CS 8581 NETWORKS LABORATORY L T P C 0 0 4 2 OBJECTIVES: The student should be made to: ➢ To learn and use network Commands. ➢ To learn Socket Programming. ➢ To implement and analyze various network protocols. ➢ To learn and use simulation tools. ➢ To use simulation tools to analyze the performance of various network protocols. COURSE OUTCOMES : C Course No. Course Outcome [Students should be able to ..] Knowledge Level LIST OF EXPERIMENTS: 1. Learn to use commands like tcpdump, netstat,ifconfig,nslookup, traceroute. Capture ping and traceroute PDUs using a network protocol analyzer and examine. 2. Write a HTTP web client program to download a web page using TCP Sockets. 3. Applications using TCP Sockets like : a. Echo Client and Echo Server b. Chat c. File Transfer 4. Simulation of DNS using UDP Sockets. 5. Write a code simulating ARP/RARP protocols. 6. Study of Network Simulator and Simulation of Congestion Control Algorithms using NS 7. Study of TCP/UDP performance using Simulation Tool. 8. Simulation of Distance Vector /Link State Routing Algorithm. 9. Performance Evaluation of Routing Protocols using Simulation Tool. 10. Simulation of Error Correction Code ( like CRC). TOTAL: 60 PERIODS SOFTWARE Requirements : C / C++ / Java / Equivalent Compiler Network simulator like NS2/Glomosim/OPNET/Equivalent
  • 7. 12 [Type text]IT [Type text] [Type text] CS 8581 - Networks Laboratory Department of Information Technology Correlation between the course and the Program Outcomes (POs) and Program Specific Outcomes (PSOs) Cours Outcomes Program out comes Program Specific outcomes PO1 (K3) PO2 (K4) PO3 (K5) PO4 (K5) PO5 (K6) PO6 (K3) PO7 (K2) PO8 (K3) PO9 (A3) PO10 (A3) PO11 (K3) PO12 (A5) PSO1 (K3) PSO2 (K4) Correlation Levels : L: Slight M: Moderate S : Substantial MEASURING TOOL FOR COURSE OUTCOME EVALUATION Rubrics for Record Assessment Category Marks allotted Logic Understood the basic concept and logic - 40 Understood the logic and basic concept but lacks in presenting it – 35 Understood the basic concept but lacks in understanding the logic - 30 Understood the basic concept but fails to give detail description - 15 No knowledge in basic concept - 0 40 Code Design Code that satisfies the entire logic - 40 Code deigned with some syntax errors - 35 Code designed with some logic mistakes - 30 Code designed with wrong logic - 15 Wrong logic & no programming structure - 0 40 Record Submission Submission on date - 10 Submission with 1 day’s delay - 8 Submission with 2 day’s delay - 6 Submission with 3 day’s delay - 4 Submission with 4 day’s delay - 2 10 Viva 10 Total 100
  • 8. 13 [Type text]IT [Type text] [Type text] CS 8581 - Networks Laboratory Department of Information Technology List of Experiments Sl.No Topic Name No. of Periods Cum. No. of Periods Mapped to CO Prerequisite Knowledge Cycle – I 1 Study of socket programming and client-server model 3 3 Syntax of basic concepts 2 a)Implementation of Stop and Wait Protocol 3 6 C307.1 Concept of Stop and Wait Protocol b)Implementation of Sliding Window Protocol 3 9 C307.1 Concept of Sliding Window Protocol 3 a)Implementation of Echo Server using TCP socket 6 15 C307.2 TCP Socket Functions (Concepts of Echo, Chat, FTP) b)Implementation of Chat Application using TCP C307.2 c)Implementation of File Transfer Protocol using TCP socket C307.2 Cycle – II 4 a)Implementation of Chat Application using UDP socket 6 21 C307.2 TCP Socket Functions (Concepts of Echo, Chat, FTP) b)Implementation of File Transfer Protocol using UDP socket C307.2 c)Implementation of DNS using UDP socket C307.2 5 a)Simulation of ARP 3 24 C307.3 Concepts of ARP & RARPb)Simulation of RARP 6 a)Implementation of PING 3 27 C307.3 Concept of PING, TRACEROUTE commands b)Implementation of TRACEROUTE Cycle – III 7 Webpage upload and download using TCP socket 3 30 C307.4 Concepts of HTTP 8 Implementation of Remote Procedure Call 3 33 C307.4 Concepts of RPC 9 a)Study of Network Simulator 3 36 C307.5 Introduction to NS2 b)Simulation of TCP congestion control using Network Simulator C307.5 Concepts of Congestion Control 10 Simulation of Routing Protocols using Network Simulator 3 39 C307.5 Concepts of Routing Protocol Content Beyond Syllabus 11 Implementation of Bit stuffing and Debit stuffing 3 42 C307.1 Concept of Bit Stuffing Model Exam 3 45 Total Number of Periods : 45
  • 9. 14 [Type text]IT [Type text] [Type text] CS 8581 - Networks Laboratory Department of Information Technology INDEX S.No Date CO Topic Name P.No Design& Logic[40] Code&output [40] Record Submission [10] Viva[10] Total [100] Sign. Cycle – I 1 Study of socket programming and client-server model <-- Not Applicable --> 2 C307.1 a)Implementation of Stop and Wait Protocol b)Implementation of Sliding Window Protocol 3 C307.2 a)Implementation of Echo Server using TCP socket b)Implementation of Chat Application using TCP socket c)Implementation of File Transfer Protocol using TCP socket Cycle – II 4 C307.2 a)Implementation of Chat Application using UDP socket b)Implementation of File Transfer Protocol using UDP socket c)Implementation of DNS using UDP socket 5 C307.3 a)Simulation of ARP b)Simulation of RARP 6 C307.3 a)Implementation of PING b)Implementation of TRACEROUTE Cycle – III 7 C307.4 Webpage upload and download using TCP socket 8 C307.4 Implementation of Remote Procedure Call 9 C307.5 a)Study of Network Simulator <-- Not Applicable --> b)Simulation of TCP congestion control using Network Simulator 10 C307.5 Simulation of Routing Protocols using Network Simulator Content Beyond Syllabus 11 C307.1 Implementation of Bit stuffing and Debit stuffing
  • 10. 15 [Type text]IT [Type text] [Type text] CS 8581 - Networks Laboratory Department of Information Technology CO Attainment Calculation : Target Value = 80 % of Marks Internal Assessment CO ATTAINMENT - INTERNAL ASSESSMENT Laboratory Mark CO Number Mark Obtained CO Attained? [Y/N] Signature CO1 CO2 CO3 CO4 CO5 Total Marks (100) S. No. Assessment Tool Percentage of Contribution (%) 1 Laboratory Rubrics 75 2 Model Exam 25
  • 11. 12 CS 8581 - Networks Laboratory Department of Information Technology Model Exam CO Number Marks Total Mark CO Attained? [Y/N]Allotted Obtained Internal Assessment = 75% of Laboratory Mark + 25% of Model Mark = Internal Assessment = % Note: If CO Attainment, Y = Laboratory Mark (%) >= Target Value (%) N = Laboratory Mark (%) < Target Value (%) Action Plan : (if CO not attained) For Regular Laboratory Session : CO Reason for not attaining CO Remedial Action Plan Remarks Signature
  • 12. 13 [Type text] [Type text] [Type text] CS 8581 - Networks Laboratory Department of Information Technology For Model Exam : CO Reason for not attaining CO Remedial Action Plan Remarks Signature
  • 13. 14 [Type text] [Type text] [Type text] CS 8581 - Networks Laboratory Department of Information Technology Pre - Assessment Questions Date : _______________ Fill up the following : 1. ______ is a connection-oriented and reliable protocol, ______ is a less reliable protocol. 2. The TCP and UDP protocols use ______ to map incoming data to a particular process running on a computer. 3. Datagrams are normally sent by ______ protocol. 4. Java uses ______ class representing a server and ______ class representing the client that uses TCP protocol. 5. ______ is used to wait for accepting client connection requests. 6. Class ______ is used to create a packet of data for UDP protocol. 7. If something goes wrong related to the network, ______ will be thrown when dealing with TCP/UDP programming in Java. 8. The main purpose of URL encoding is to maintain the ______ between various platforms. 9. Based on the URL encoding mechanism, “www.test.com/test me&test you” becomes ______. 10. ______ method is used to instantiate a URLConnection instance. State TRUE or FALSE. 11. UDP is more reliable than TCP protocol. 12. The same port number can be reused many times when binding with sockets simultaneously 13. In order to create a client socket connecting to a particular server, the IP address must be given to the client socket, or it cannot connect to the server. 14. Sockets provide an interface for programming networks at the transport layer 15. Call Socket.close() method will close the TCP server that socket connects to Write your observation about the Effect of the following code : Socket socket = new Socket(“localhost,” 1254); ___________________________________________________________________________ Score : / 16 Signature of the Staff in Charge [Name : ]
  • 14. 15 [Type text] [Type text] [Type text] CS 8581 - Networks Laboratory Department of Information Technology Ex No : 1 Study of Socket Programming CO : Basics & K : K1 - Remember Date : Client-Server Model Aim: To study about the fundamentals of Socket Programming and the concepts of Client - Server Model. References : 1.tutorialspoint 2. http://www.buyya.com/java/Chapter13.pdf Description : Network Programming : • writing programs that execute across multiple devices • devices are all connected to each other using a network • java.net package provides support for TCP and UDP • TCP − TCP stands for Transmission Control Protocol - allows reliable communication between two applications. - TCP is typically used over the Internet Protocol, which is referred to as TCP/IP. - TCP is a two-way communication protocol, hence data can be sent across both streams at the same time • UDP − UDP stands for User Datagram Protocol - a connection-less protocol that allows for packets of data to be transmitted between applications. Socket Programming : o java.net.Socket class represents a socket o java.net.ServerSocket class provides a mechanism for the server program to listen for clients and establish connections with them.
  • 15. 16 [Type text] [Type text] [Type text] CS 8581 - Networks Laboratory Department of Information Technology ServerSocket Class Methods : The java.net.ServerSocket class is used by server applications to obtain a port and listen for client requests. The ServerSocket class has four constructors − Sr.No. Method & Description 1 public ServerSocket(int port) throws IOException Attempts to create a server socket bound to the specified port. An exception occurs if the port is already bound by another application. 2 public ServerSocket(int port, int backlog) throws IOException Similar to the previous constructor, the backlog parameter specifies how many incoming clients to store in a wait queue. 3 public ServerSocket(int port, int backlog, InetAddress address) throws IOException Similar to the previous constructor, the InetAddress parameter specifies the local IP address to bind to. The InetAddress is used for servers that may have multiple IP addresses, allowing the server to specify which of its IP addresses to accept client requests on. 4 public ServerSocket() throws IOException Creates an unbound server socket. When using this constructor, use the bind() method when you are ready to bind the server socket. Sr.No. Method & Description 1 public int getLocalPort() Returns the port that the server socket is listening on. This method is useful if you passed in 0 as the port number in a constructor and let the server find a port for you. 2 public Socket accept() throws IOException Waits for an incoming client. This method blocks until either a client connects to the server on the specified port or the socket times out, assuming that the time-out value has been set using the setSoTimeout() method. Otherwise, this method blocks indefinitely. 3 public void setSoTimeout(int timeout) Sets the time-out value for how long the server socket waits for a client during the accept(). 4 public void bind(SocketAddress host, int backlog) Binds the socket to the specified server and port in the SocketAddress object. Use this method if you have instantiated the ServerSocket using the no-argument constructor.
  • 16. 17 [Type text] [Type text] [Type text] CS 8581 - Networks Laboratory Department of Information Technology Socket Class Methods The Socket class has five constructors that a client uses to connect to a server Sr.No. Method & Description 1 public Socket(String host, int port) throws UnknownHostException, IOException. This method attempts to connect to the specified server at the specified port. If this constructor does not throw an exception, the connection is successful and the client is connected to the server. 2 public Socket(InetAddress host, int port) throws IOException This method is identical to the previous constructor, except that the host is denoted by an InetAddress object. 3 public Socket(String host, int port, InetAddress localAddress, int localPort) throws IOException. Connects to the specified host and port, creating a socket on the local host at the specified address and port. 4 public Socket(InetAddress host, int port, InetAddress localAddress, int localPort) throws IOException. This method is identical to the previous constructor, except that the host is denoted by an InetAddress object instead of a String. 5 public Socket() Creates an unconnected socket. Use the connect() method to connect this socket to a server. Sr.No. Method & Description 1 public void connect(SocketAddress host, int timeout) throws IOException This method connects the socket to the specified host. This method is needed only when you instantiate the Socket using the no-argument constructor. 2 public InetAddress getInetAddress() This method returns the address of the other computer that this socket is connected to. 3 public int getPort() Returns the port the socket is bound to on the remote machine. 4 public int getLocalPort() Returns the port the socket is bound to on the local machine. 5 public SocketAddress getRemoteSocketAddress() Returns the address of the remote socket. 6 public InputStream getInputStream() throws IOException Returns the input stream of the socket. The input stream is connected to the output stream of the remote socket.
  • 17. 18 [Type text] [Type text] [Type text] CS 8581 - Networks Laboratory Department of Information Technology Client - Server Model : Result : Thus the study about the fundamentals of Socket Programming and the concepts of Client-Server Model was carried out successfully. 7 public OutputStream getOutputStream() throws IOException Returns the output stream of the socket. The output stream is connected to the input stream of the remote socket. 8 public void close() throws IOException Closes the socket, which makes this Socket object no longer capable of connecting again to any server.
  • 18. 19 [Type text] [Type text] [Type text] CS 8581 - Networks Laboratory Department of Information Technology Ex . No : 1 Viva Questions Marks : ____/ 10 1. Define : Socket 2. State the types of Sockets. 1.___________________ 2. ___________________ 3. ___________________ 3. What is meant by System Call? 4. Which Java Classes support Socket Programming? 1. ________________________ 2. ________________________ 5. What is meant by loopback address? 6. What is meant by port?. Give Example. 7. Match the following : 1. HTTP - a. Port 23 2. SMTP - b. Port 53 3. Telnet - c. Port 25 4. DNS - d. Port 80 Criteria Allotted Awarded Design & Algorithm 20 Logic 20 Code 20 Output 20 Record Submission 10 Viva 10 Total 100 Staff Signature
  • 19. 20 [Type text] [Type text] [Type text] CS 8581 - Networks Laboratory Department of Information Technology Ex No : 2(a) Implementation of Stop and wait Protocol CO : C307.1 Date : K : K3 AIM To write a ‘Java’ program to perform implementation of Stop and wait protocol ALGORITHM Stop and Wait ARQ 1. Get the input data. 2.Send the data one by one from the sender side. 3.The data is received at the receiver side one by one. 4.If we send an acknowledgement , send next data. Otherwise resend the previous data 5.End of the process. CODE :
  • 20. 21 [Type text] [Type text] [Type text] CS 8581 - Networks Laboratory Department of Information Technology
  • 21. 22 [Type text] [Type text] [Type text] CS 8581 - Networks Laboratory Department of Information Technology OUTPUT :
  • 22. 23 [Type text] [Type text] [Type text] CS 8581 - Networks Laboratory Department of Information Technology Ex No : 2(a) Implementation of Stop and Wait Protocol Viva Questions 1. In Stop and Wait Protocol, if the sequence number of the sent frame is 5, what is the number of the acknowledgement frame ?. _____ 2. Maximum window size in Stop and Wait Protocol is ____ 3. Stop and Wait ARQ is also called as _________________ 4. In Stop and Wait ARQ, Modulo ____ numbering is used. RESULT: Thus the Java program for implementing stop and wait protocol was done and correct output was verified Criteria Allotted Awarded Design & Algorithm 20 Logic 20 Code 20 Output 20 Record Submission 10 Viva 10 Total 100 Staff Signature
  • 23. 24 [Type text] [Type text] [Type text] CS 8581 - Networks Laboratory Department of Information Technology Ex No : 2(b) Implementation of Sliding Window Protocols CO : C307.1 Date : K : K3 AIM To write a ‘Java’ program to perform implementation of Sliding window protocols. ALGORITHM Go Back-N ARQ 1. Get the input data. 2. Assign the window size. 3. Send the data one by one in the sender side according to the window size.. 4. The data is received at the receiver side one by one according to the window size. 5. If we send an acknowledgement , the window expands to include places for the number of frames to be send. 6. Otherwise resend frames(data) according to the window size. 7. Display the sender’s data and window status and receiver’s data and window status accordingly 8. End of the process. Selective and Repeat ARQ: 1.Get the input data. 2.Assign the frame size. 3.Send the data one by one in the sender side according to the window size.. 4.The data is received at the receiver side one by one according to the frame size. 5.If we send an acknowledgement , the window expands to include places for the number of frames to be send. 6. Otherwise resend the data for selective frame which is not received. 7.Display the sender’s data and window status and receiver’s data and window status accordingly 8.End of the process.
  • 24. 25 [Type text] [Type text] [Type text] CS 8581 - Networks Laboratory Department of Information Technology CODE
  • 25. 26 [Type text] [Type text] [Type text] CS 8581 - Networks Laboratory Department of Information Technology OUTPUT
  • 26. 27 [Type text] [Type text] [Type text] CS 8581 - Networks Laboratory Department of Information Technology Viva Questions : 1. List out the advantages of Sliding Window Protocols. 2. Define : Piggybacking. 3. Sliding window is useful for error _______________ 4. How many windows will be maintained in sliding window protocol?. List them. RESULT: Thus the Java program for implementing Sliding Window protocol was done and correct output was verified Criteria Allotted Awarded Design & Algorithm 20 Logic 20 Code 20 Output 20 Record Submission 10 Viva 10 Total 100 Staff Signature
  • 27. 28 [Type text] [Type text] [Type text] CS 8581 - Networks Laboratory Department of Information Technology Ex No : 3(a) Implementation of Echo Server & Client using TCP CO : C307.2 Date : K : K3 AIM: To write a Java program to implement TCP echo client and server. ALGORITHM: TCP ECHO SERVER: 1. Include the necessary packages to support functions for socket definitions, Socket types , Internet address, I/O functions and unix system calls. 2. Declare variables, socket descriptor and port number. 3. Create a Stream socket and assign its socket descriptor value in a variable 4. Initialize all the socket address values to zero. 5. Assign the socket address family and port numbers 6. Bind the socket with address and port number using bind() function. 7. Establish the connection request with the client by using the Listen() function. 8. The connection request from client is accepted using the accept() function and thus connection is established. 9. Then child process is created and str-echo() function is called to execute. 10. Here the size and buffer is initialized 11. Message from the client is read and stored in n and it is written to the server buffer. 12. If the buffer is full, then same read operation is carried. 13. If the buffer is empty, then read error. 14. Terminate the connection. TCP ECHO CLIENT: 1. Include the necessary packages to support functions for socket definitions, Socket types , Internet address, I/O functions and unix system calls. 2. Declare variables, socket descriptor and port number. 3. Create a Stream socket and assign its socket descriptor value in a variable 4. Initialize all the socket address values to zero. 5. Assign the socket address family and port number. 6. Using inet() function, convert the presentation (ASCII address to numeric address).
  • 28. 29 [Type text] [Type text] [Type text] CS 8581 - Networks Laboratory Department of Information Technology 7. Then the connect function is to make the connection with the server side 8. The the function strcli() is executed with the arguments file pointer and socket descriptor 9. the two buffers receive and send buffer are initialied 10. the messge sent by the server is read by fgets() function, if the value is not null. 11. The value from send buffer is written at client side. 12. If the receive buffer is not full , the error messge is displyes 13. Else the message is echoed from the receive buffer. CODE : Client.java import java.io.*; import java.net.*; import java.util.*; class Client{ public static void main(String args[])throws IOException { try { Socket s = new Socket("127.0.0.1",2222); DataOutputStream dos = new DataOutputStream(s.getOutputStream()); DataInputStream din = new DataInputStream(s.getInputStream()); Scanner sc = new Scanner(System.in); System.out.println("Enter your Message:"); String name = sc.nextLine(); dos.writeUTF(name); String in = (String)din.readUTF(); System.out.println(in); s.close(); } catch(Exception e) { System.out.print(e); } } } Server.java import java.io.*; import java.util.*; import java.net.*; class Server{ public static void main(String args[])throws IOException { try { ServerSocket ss = new ServerSocket(2222);
  • 29. 30 [Type text] [Type text] [Type text] CS 8581 - Networks Laboratory Department of Information Technology Socket s = ss.accept(); DataOutputStream dos = new DataOutputStream(s.getOutputStream()); DataInputStream din = new DataInputStream(s.getInputStream()); String in = (String)din.readUTF(); dos.writeUTF(in); System.out.println(in); s.close(); ss.close(); } catch(Exception e) { System.out.print(e); } } } OUTPUT:
  • 30. 31 [Type text] [Type text] [Type text] CS 8581 - Networks Laboratory Department of Information Technology Viva Questions : 1. If the client sends "Hello" to echo server, what does the echo server send back ? ____________ 2. State the purpose of Echo Server 3. Write the package and suitable socket class to create a Server Socket. ____________________ ____________________ RESULT : Thus the program for TCP Echo client and server was written and correct output was verified. Criteria Allotted Awarded Design & Algorithm 20 Logic 20 Code 20 Output 20 Record Submission 10 Viva 10 Total 100 Staff Signature
  • 31. 32 [Type text] [Type text] [Type text] CS 8581 - Networks Laboratory Department of Information Technology Ex No : 3(b) Implementation of Chat Server & Client using TCP CO : C307.2 Date : K : K3 AIM: To write a Java program for Chatting between TCP Client and Server. Reference : 1. http://pirate.shu.edu/~wachsmut/Teaching/CSAS2214/Virtual/Lectures/chat-client-server.html 2. https://www.youtube.com/watch?v=kqBmsLvWU14 ALGORITHM: CHATING TCP SERVER 1. Include the necessary packages to support functions for socket definitions, Socket types , Internet address, I/O functions and unix system calls. 2. Declare variables, socket descriptor and port number. 3. Create a Stream socket and assign its socket descriptor value in a variable 4. Initialize all the socket address values to zero. 5. Assign the socket address family and port numbers 6. Bind the socket with address and port number using bind() function. 7. Establish the connection request with the client by using the Listen() function. 8. The connection request from client is accepted using the accept() function and thus connection is established. 9. If the fork does not return zero, make the server to be in listening state 10. Else send the message to the client. 11. Close the socket. CHATING TCP CLIENT 1. Include the necessary packages to support functions for socket definitions, Socket types , Internet address, I/O functions and unix system calls. 2. Declare variables, socket descriptor and port number. 3. Create a Stream socket and assign its socket descriptor value in a variable 4. Initialize all the socket address values to zero. 5. Assign the socket address family and port number. 6. Using inet() function, convert the presentation (ASCII address to numeric address). 7. Then the connect function is to make the connection with the server side
  • 32. 33 [Type text] [Type text] [Type text] CS 8581 - Networks Laboratory Department of Information Technology 8. The the function strcli() is executed with the arguments file pointer and socket descriptor 9. the two buffers receive and send buffer are initialied 10.the messge sent by the server is read by fgets() function, if the value is not null. 11. The value from send buffer is written at client side. 12. If the receive buffer is not full , the error messge is displayed 13. Else send the message to the server. 14. Close the socket CODE : TCPClient import java.io.*; import java.net.*; import java.util.*; class TCPClient{ public static void main(String args[])throws IOException { try { System.out.println("JegaApp Chat Application"); Socket s = new Socket("127.0.0.1",2000); while(true){ DataOutputStream dos = new DataOutputStream(s.getOutputStream()); DataInputStream din = new DataInputStream(s.getInputStream()); Scanner sc = new Scanner(System.in); System.out.println("Enter your Message to pass:(Type 'Bye' to Exit the Chat)"); String msg = sc.nextLine(); dos.writeUTF(msg); String input = (String)din.readUTF(); System.out.println("Server Says... "+input); if(input.equalsIgnoreCase("Bye")) { break; } } s.close(); } catch(Exception e) { System.out.print(e); } } }
  • 33. 34 [Type text] [Type text] [Type text] CS 8581 - Networks Laboratory Department of Information Technology TCPServer import java.io.*; import java.util.*; import java.net.*; class TCPServer{ public static void main(String args[])throws IOException { try { System.out.println("JegaApp Chat Application"); ServerSocket ss = new ServerSocket(2000); Socket s = ss.accept(); while(true){ DataOutputStream dos = new DataOutputStream(s.getOutputStream()); DataInputStream din = new DataInputStream(s.getInputStream()); String in = (String)din.readUTF(); System.out.println("Client Says... "+in); Scanner sc = new Scanner(System.in); System.out.println("Enter your Message to pass:(Type 'Bye' to Exit the Chat)"); String out = sc.nextLine(); dos.writeUTF(out); if(in.equalsIgnoreCase("Bye")) { break; } } s.close(); ss.close(); } catch(Exception e) { System.out.print(e); } } }
  • 34. 35 [Type text] [Type text] [Type text] CS 8581 - Networks Laboratory Department of Information Technology OUTPUT : Viva Questions: 1. What is Loop back IP Address.? 2. Mention its purpose. 3. State the purpose of Chat Server- Client. RESULT : Thus the program for Chatting TCP Client and Server was written and correct output was verified. Criteria Allotted Awarded Design & Algorithm 20 Logic 20 Code 20 Output 20 Record Submission 10 Viva 10 Total 100 Staff Signature
  • 35. 36 [Type text] [Type text] [Type text] CS 8581 - Networks Laboratory Department of Information Technology Ex No : 3(c) Implementation of File Transfer using TCP CO : C307.2 Date : K : K3 AIM To Perform File Transfer in Client & Server Using TCP/IP. ALGORITHM CLIENT SIDE 1. Start. 2. Establish a connection between the Client and Server. 3. Socket ss=new Socket(InetAddress.getLocalHost(),1100); 4. Implement a client that can send two requests. i) To get a file from the server. ii) To put or send a file to the server. 5. After getting approval from the server ,the client either get file from the server or send 6. file to the server. SERVER SIDE 1. Start. 2. Implement a server socket that listens to a particular port number. 3. Server reads the filename and sends the data stored in the file for the‘get’ request. 4. It reads the data from the input stream and writes it to a file in theserver for the ‘put’ instruction. 5. Exit upon client’s request. 6. Stop. CODE : FTPSEREVER.JAVA import java.io.*; import java.net.*; import java.util.*; public class FTPServer { public static void main(String args[])throws IOException { try { int num; Scanner sc=new Scanner(System.in); ServerSocket ss=new ServerSocket(10087);
  • 36. 37 [Type text] [Type text] [Type text] CS 8581 - Networks Laboratory Department of Information Technology Socket s=ss.accept(); System.out.println("Waiting....."); DataInputStream dis=new DataInputStream(s.getInputStream()); String input=(String)dis.readUTF(); DataOutputStream dos=new DataOutputStream(s.getOutputStream()); FileInputStream fis = new FileInputStream("num.txt"); FileOutputStream fos = new FileOutputStream(input); while((num=fis.read())!= -1) { if(num%2==0) { fos.write(num); } } dos.writeUTF(input); System.out.println("File is sent to client"); ss.close(); s.close(); } catch(Exception e) { System.out.println("Port not available"+e); } } } FTPCLIENT.JAVA import java.io.*; import java.net.*; import java.util.*; public class FTPClient { public static void main(String args[])throws IOException { try { int number; Socket s=new Socket("127.0.0.1",10087); Scanner sc=new Scanner(System.in); System.out.println("Enter the file name:"); String fn=sc.next(); DataOutputStream dos=new DataOutputStream(s.getOutputStream()); dos.writeUTF(fn); DataInputStream dis=new DataInputStream(s.getInputStream()); String input=(String)dis.readUTF(); FileInputStream fis=new FileInputStream(input); System.out.println("Even Numbers in the" +fn+" are"); int i=0;
  • 37. 38 [Type text] [Type text] [Type text] CS 8581 - Networks Laboratory Department of Information Technology while((i=fis.read())!=-1) { System.out.println((char)i); } s.close(); } catch(Exception e) { System.out.println("Port not available "+e); } } } OUTPUT:
  • 38. 39 [Type text] [Type text] [Type text] CS 8581 - Networks Laboratory Department of Information Technology Viva Questions : 1. Abbreviate : FTP 2. Ports used by FTP is ____________ 3. State the Role of FTP Server and FTP Client. 4. Who will perform File Upload ___________ 5. Who will allow File Download ____________ RESULT Thus the File transfer Operation is done & executed successfully. Criteria Allotted Awarded Design & Algorithm 20 Logic 20 Code 20 Output 20 Record Submission 10 Viva 10 Total 100 Staff Signature
  • 39. 40 [Type text] [Type text] [Type text] CS 8581 - Networks Laboratory Department of Information Technology Ex No : 4(a) Implementation of Chat using UDP CO : C307.2 Date : K : K3 AIM To write a program to implement simple client-server application using UDP. ALGORITHM CLIENT SIDE 1. Create a datagram socket with server’s IP address. 2. Create datagram packets with data, data length and the port address. 3. Send the datagram packets to server through datagram sockets 4. Receive the datagram packets from server through datagram sockets 5. Close the socket. SERVER SIDE 1. Create a datagram socket with port address. 2. Create datagram packets with data, data length and the port address. 3. Send the datagram packets to client through datagram sockets 4. Receive the datagram packets from client through datagram sockets 5. Close the socket. CODE ClientUDP.java import java.io.*; import java.net.*; class ClientUDP { public static void main(String args[])throws IOException { try { DatagramSocket ds=new DatagramSocket(); InetAddress ina=InetAddress.getByName("127.0.0.1"); byte[] data=new byte[1024]; String d="Hello"; data=d.getBytes(); DatagramPacket dp=new DatagramPacket(data,data.length,ina,10001); ds.send(dp); }
  • 40. 41 [Type text] [Type text] [Type text] CS 8581 - Networks Laboratory Department of Information Technology catch(Exception e) { System.out.println(e); } } } ServerUDP.java import java.net.*; import java.io.*; class ServerUDP { public static void main(String args[]) throws IOException { try { DatagramSocket dss=new DatagramSocket(10001); byte[] dat=new byte[1024]; String fromc=""; DatagramPacket dps=new DatagramPacket(dat,dat.length); dss.receive(dps); fromc=new String(dps.getData()); System.out.println(""+fromc.trim()); } catch(Exception e) { System.out.println(e); } } } OUTPUT
  • 41. 42 [Type text] [Type text] [Type text] CS 8581 - Networks Laboratory Department of Information Technology Viva Questions: 1. Abbreviate : UDP 2. Differentiate : TCP and UDP 3. When UDP is Useful? Result: Thus the above program a client-server application for chat using UDP was executed and successfully Criteria Allotted Awarded Design & Algorithm 20 Logic 20 Code 20 Output 20 Record Submission 10 Viva 10 Total 100 Staff Signature
  • 42. 43 [Type text] [Type text] [Type text] CS 8581 - Networks Laboratory Department of Information Technology Ex No : 4(b) Implementation of FTP using UDP CO : C307.2 Date : K : K3 Aim To implement FTP using UDP. References : https://www.youtube.com/watch?v=NXQ7wwvDF2A ALGORITHM Client Side : 1. Create a DatagramSocket to connect to the server 2. Set the name of the Client Machine 3. Create DatagramPackets to send and receive data to and from the server 4. Create the necessary file objects to receive and send the data 5. Display the received data fro the server in the client's Interface 6. Terminate the client side Server Side : 1. Create a Datagram Socket class for server and determine the port on which the server's resources can be fetched. 2. Create the DatagramPackets to send and receive the files to and from the server 3. Create the necessary objects to receive and send the file data 4. Terminate the servver side. CODE :
  • 43. 44 [Type text] [Type text] [Type text] CS 8581 - Networks Laboratory Department of Information Technology
  • 44. 45 [Type text] [Type text] [Type text] CS 8581 - Networks Laboratory Department of Information Technology OUTPUT : Viva Questions : 1. Create the socket using UDP in Java 2. Mention the types of Files with their extensions. Result : Thus the program to implement FDP using UDP was done and executed successfully. Criteria Allotted Awarded Design & Algorithm 20 Logic 20 Code 20 Output 20 Record Submission 10 Viva 10 Total 100 Staff Signature
  • 45. 46 [Type text] [Type text] [Type text] CS 8581 - Networks Laboratory Department of Information Technology Ex No : 4(c) Implementation of DNS using UDP CO : C307.2 Date : K : K3 Aim To implement DNS using UDP. ALGORITHM Client Side : 1. Create a DatagramSocket to connect to the server 2. Set the name of the Client Machine 3. Create DatagramPackets to send and receive data to and from the server 4. Enter the IP address or the URL for which the DNS resolving mechanism is required 5. Display the received data in the form of IP address or Domain Name from the server in the client's Interface 6. Terminate the client side Server Side : 1. Create a Datagram Socket class for server and determine the port on which the server's resources can be fetched. 2. Create the DatagramPackets to send and receive the IP address / URL from the client 3. Terminate the server side. CODE : DNSSERVERUDP.JAVA import java.io.*; import java.util.*; import java.net.*; class DNSServerUDP { public static void main(String args[])throws Exception { DatagramSocket dss=new DatagramSocket(10001); String[] dn={"www.google.com","www.yahoo.com","www.gmail.com"}; String[] ip={"192.162.3.2","192.162.3.3","192.162.3.4"}; String temp=""; int flag=0; try { byte[] rm=new byte[1024]; System.out.println("Waiting..."); DatagramPacket dps=new DatagramPacket(rm,rm.length); dss.receive(dps);
  • 46. 47 [Type text] [Type text] [Type text] CS 8581 - Networks Laboratory Department of Information Technology String rec=new String(dps.getData()); for(int i=0;i<3;i++) { if((rec.trim()).equals(dn[i])) { temp=ip[i]; flag=1; } } byte[] sm=new byte[1024]; InetAddress ia=dps.getAddress(); int port=dps.getPort(); sm=temp.getBytes(); String not="IP not found"; byte[] sn=new byte[1024]; sn=not.getBytes(); if(flag==1) { DatagramPacket dps1=new DatagramPacket(sm,sm.length,ia,port); dss.send(dps1); } else { DatagramPacket dps1=new DatagramPacket(sn,sn.length,ia,port); dss.send(dps1); } } catch(Exception e) { System.out.println(e); } } } DNSCLIENTUDP.JAVA import java.net.*; import java.util.*; class DNSClientUDP { public static void main(String args[])throws Exception { DatagramSocket dsc=new DatagramSocket(); InetAddress ia=InetAddress.getByName("127.0.0.1"); Scanner sc=new Scanner(System.in); try { System.out.println("Enter the domain name:"); String msg=sc.next();
  • 47. 48 [Type text] [Type text] [Type text] CS 8581 - Networks Laboratory Department of Information Technology byte[] sm=new byte[1024]; sm=msg.getBytes(); DatagramPacket dpc=new DatagramPacket(sm,sm.length,ia,10001); dsc.send(dpc); byte[] rm=new byte[1024]; DatagramPacket dpc1=new DatagramPacket(rm,rm.length); dsc.receive(dpc1); String rec=new String(dpc1.getData()); System.out.println("IP address:"+rec.trim()); } catch(Exception e) { System.out.println(e); } } } OUTPUT :
  • 48. 49 [Type text] [Type text] [Type text] CS 8581 - Networks Laboratory Department of Information Technology Viva Questions : 1. Abbreviate : DNS 2. What is the purpose of Name Server?. 3. Give an example for Lookup? 4. List out any four domains. 5. ____ port is used by DNS 6. DNS works over ______ Result : Thus the program to implement DNS using UDP was done and executed successfully. Criteria Allotted Awarded Design & Algorithm 20 Logic 20 Code 20 Output 20 Record Submission 10 Viva 10 Total 100 Staff Signature
  • 49. 50 [Type text] [Type text] [Type text] CS 8581 - Networks Laboratory Department of Information Technology Ex No : 5(a) Simulation of ARP CO : C307.3 Date : K : K3 AIM To implement Address Resolution Protocol . ALGORITHM CLIENT SIDE 1. Establish a connection between the Client and Server. Socket ss=new Socket(InetAddress.getLocalHost(),1100); 2. Create instance output stream writer PrintWriter ps=new PrintWriter(s.getOutputStream(),true); 3. Get the IP Address to resolve its physical address. 4. Send the IPAddress to its output Stream.ps.println(ip); 5. Print the Physical Address received from the server. SERVER SIDE 1. Accept the connection request by the client. ServerSocket ss=new ServerSocket(2000);Socket s=ss.accept(); 2. Get the IPaddress from its inputstream. BufferedReader br1=new BufferedReader(newInputStreamReader(s.getInputStream())); ip=br1.readLine(); 3. During runtime execute the processRuntime r=Runtime.getRuntime(); Process p=r.exec("arp -a "+ip); 4. Send the Physical Address to the client. CODE : ArpClient.java import java.io.*; import java.net.*; class ArpClient { public static void main(String args[])throws IOException { try { Socket ss=new Socket(InetAddress.getLocalHost(),1100);
  • 50. 51 [Type text] [Type text] [Type text] CS 8581 - Networks Laboratory Department of Information Technology PrintStream ps=new PrintStream(ss.getOutputStream()); BufferedReader br=new BufferedReader(new InputStreamReader(System.in)); String ip; System.out.println("Enter the IP ADDRESS:"); ip=br.readLine(); ps.println(ip); String str; BufferedReader br2=new BufferedReader(new InputStreamReader(ss.getInputStream())); System.out.println("ARP From Server::"); str=br2.readLine(); System.out.println("The ARP Entries aren"+str); } catch(Exception e) { System.out.println("Error"+e); } } } ArpServer.java import java.io.*; import java.net.*; class ArpServer { public static void main(String args[])throws IOException { try { ServerSocket ss=new ServerSocket(2930); Socket s=ss.accept(); System.out.println("Connected to Client...."); PrintStream ps=new PrintStream(s.getOutputStream()); BufferedReader br1=new BufferedReader(new InputStreamReader(s.getInputStream())); String ip; ip=br1.readLine(); Runtime r=Runtime.getRuntime(); Process p=r.exec("arp -a "+ip);
  • 51. 52 [Type text] [Type text] [Type text] CS 8581 - Networks Laboratory Department of Information Technology System.out.println(); BufferedReader br2=new BufferedReader(new InputStreamReader(p.getInputStream())); String str; while((str=br2.readLine())!=null) { ps.println(str); } } catch(Exception e) { System.out.println("Error"+e); } } } OUTPUT:
  • 52. 53 [Type text] [Type text] [Type text] CS 8581 - Networks Laboratory Department of Information Technology Viva Questions: 1. Abbreviate : ARP 2. Define : MAC and abbreviate it. 3. What is physical address and logical address? RESULT : Thus the ARP was written and executed successfully. Criteria Allotted Awarded Design & Algorithm 20 Logic 20 Code 20 Output 20 Record Submission 10 Viva 10 Total 100 Staff Signature
  • 53. 54 [Type text] [Type text] [Type text] CS 8581 - Networks Laboratory Department of Information Technology Ex No : 5(b) Simulation of RARP CO : C307.3 Date : K : K3 AIM To simulate the Reverse Address Resolution Protocol . ALGORITHM CLIENT SIDE 1. Start the Program 2. Use the necessary packages 3. Create a client side socket 4. Establish a connection with the server. 5. Request the server to display the IP address of the MAC address 6. Terminate the Program SERVER SIDE 1. Start the Program 2. Use the necessary packages 3. Create a server socket 4. Establish a connection with the client 5. Server must maintain a list of IP address and MAC address in a separated lists 6. As per the client's request, display the IP address to the client 7. Terminate the Program CODE : ClientRARP.java import java.io.*; import java.net.*; import java.util.*; class ClientRARP { public static void main(String args[]) throws IOException { try { BufferedReader in=new BufferedReader(new InputStreamReader(System.in)); Socket clsct=new Socket("127.0.0.1",10039);
  • 54. 55 [Type text] [Type text] [Type text] CS 8581 - Networks Laboratory Department of Information Technology DataInputStream din=new DataInputStream(clsct.getInputStream()); DataOutputStream dout=new DataOutputStream(clsct.getOutputStream()); System.out.println("Enter the MAC address:"); String str1=in.readLine(); dout.writeBytes(str1+'n'); String str=din.readLine(); System.out.println(str); clsct.close(); } catch (Exception e) { System.out.println(e); } } } ServerRARP.java import java.io.*; import java.net.*; import java.util.*; class ServerRARP { public static void main(String args[]) throws IOException { try { System.out.println("Waiting....."); ServerSocket ss=new ServerSocket(10039); Socket s=ss.accept(); DataInputStream din=new DataInputStream(s.getInputStream()); DataOutputStream dout=new DataOutputStream(s.getOutputStream()); String str=din.readLine(); String temp=""; int flag=0; String ip[]={"165.165.80.80","165.165.79.1"}; String mac[]={"6A:08:AA:C2","8A:BC:E3:FA"}; for(int i=0;i<ip.length;i++) { if(str.equals(mac[i])) { temp=ip[i];
  • 55. 56 [Type text] [Type text] [Type text] CS 8581 - Networks Laboratory Department of Information Technology flag=1; break; } } if(flag==1) dout.writeBytes("The IP Address is: "+temp); else dout.writeBytes("MAC address not found"); ss.close(); s.close(); } catch(Exception e) { System.out.println(e); } } } OUTPUT:
  • 56. 57 [Type text] [Type text] [Type text] CS 8581 - Networks Laboratory Department of Information Technology Viva Questions : 1. Abbreviate : RARP 2. What RARP will do? RESULT : Thus the RARP was written and executed successfully. Criteria Allotted Awarded Design & Algorithm 20 Logic 20 Code 20 Output 20 Record Submission 10 Viva 10 Total 100 Staff Signature
  • 57. 58 [Type text] [Type text] [Type text] CS 8581 - Networks Laboratory Department of Information Technology Ex No : 6(a) Implementation of PING CO : C307.3 Date : K : K3 Aim: To implement PING command using Java. Algorithm: 1. Start the Java IDE 2. Create a Java Project 3. Create a Process object to collect the runtime command 4. Use Scanner / BufferedReader class object to process the command 5. Once the project is run, the PING results will be shown on the interface. 6. End the Program. CODE :
  • 58. 59 [Type text] [Type text] [Type text] CS 8581 - Networks Laboratory Department of Information Technology
  • 59. 60 [Type text] [Type text] [Type text] CS 8581 - Networks Laboratory Department of Information Technology OUTPUT : Viva Questions: 1. State the Purpose of PING Command?. 2. How to use Ping Command. Write the Syntax. 3. ping www.google.com what is the result of this? RESULT: Thus the PING Command was successfully implemented using Java. Criteria Allotted Awarded Design & Algorithm 20 Logic 20 Code 20 Output 20 Record Submission 10 Viva 10 Total 100 Staff Signature
  • 60. 61 [Type text] [Type text] [Type text] CS 8581 - Networks Laboratory Department of Information Technology Ex No : 6(b) Implementation of TRACEROUTE CO : C307.3 Date : K : K3 Aim: To implement TRACEROUTE command using Java. Algorithm: 1. Start the Java IDE 2. Create a Java Project 3. Create a Process object to collect the runtime command 4. Use Scanner / BufferedReader class object to process the command 5. Once the project is run, the TRACEROUTE results will be shown on the interface. 6. End the Program. CODE :
  • 61. 62 [Type text] [Type text] [Type text] CS 8581 - Networks Laboratory Department of Information Technology
  • 62. 63 [Type text] [Type text] [Type text] CS 8581 - Networks Laboratory Department of Information Technology OUTPUT : Viva Questions : 1. What is the purpose of traceroute command? 2. Write the syntax for traceroute command. Result: Thus the TRACEROUTE Command was successfully implemented using Java. Criteria Allotted Awarded Design & Algorithm 20 Logic 20 Code 20 Output 20 Record Submission 10 Viva 10 Total 100 Staff Signature
  • 63. 64 [Type text] [Type text] [Type text] CS 8581 - Networks Laboratory Department of Information Technology Ex No : 7 Web Page download using TCP Sockets CO : C307.4 Date : K : K3 AIM To download a webpage using Java ALGORITHM: CLIENT SIDE: 1) Start the program. 2) Create a socket which binds the Ip address of server and the port address to acquire service. 3) After establishing connection send the url to server. 4) Open a file and store the received data into the file. 5) Close the socket. 6) End the program. SERVER SIDE 1) Start the program. 2) Create a server socket to activate the port address. 3) Create a socket for the server socket which accepts the connection. 4) After establishing connection receive url from client. 5) Download the content of the url received and send the data to client. 6) Close the socket. 7) End the program. CODE :
  • 64. 65 [Type text] [Type text] [Type text] CS 8581 - Networks Laboratory Department of Information Technology
  • 65. 66 [Type text] [Type text] [Type text] CS 8581 - Networks Laboratory Department of Information Technology OUTPUT: Viva Quetions: 1. What is a Web Page? 2. Is it possible to download a web page from a server? RESULT: Thus the webpage download using TCP Socket was done and verified successfully. Criteria Allotted Awarded Design & Algorithm 20 Logic 20 Code 20 Output 20 Record Submission 10 Viva 10 Total 100 Staff Signature
  • 66. 67 [Type text] [Type text] [Type text] CS 8581 - Networks Laboratory Department of Information Technology Ex No : 8 Implementation of Remote Procedure Call CO : C307.4 Date : K : K3 AIM To implement Remote Command Execution(RCE). ALGORITHM CLIENT SIDE 1. Establish a connection between the Client and Server. Socket client=new Socket("127.0.0.1",6555); 2. Create instances for input and output streams. Print Stream ps=new Print Stream(client.getOutputStream()); 3. BufferedReader br=new BufferedReader(newInputStreamReader(System.in)); 4. Enter the command in Client Window. Send the message to its output str=br.readLine(); ps.println(str); SERVER SIDE 1. Accept the connection request by the client. ServerSocket server=new ServerSocket(6555); Socket s=server.accept(); 2. Get the IPaddress from its inputstream. BufferedReader br1=new BufferedReader(newInputStreamReader(s.getInputStream())); ip=br1.readLine(); 3. During runtime execute the process Runtime r=Runtime.getRuntime(); Process p=r.exec(str); CODE :
  • 67. 68 [Type text] [Type text] [Type text] CS 8581 - Networks Laboratory Department of Information Technology
  • 68. 69 [Type text] [Type text] [Type text] CS 8581 - Networks Laboratory Department of Information Technology OUTPUT : Viva Questions : 1. Explain the Purpose of Remote Command Execution Result : Thus the implementation RCE is done & executed successfully. Criteria Allotted Awarded Design & Algorithm 20 Logic 20 Code 20 Output 20 Record Submission 10 Viva 10 Total 100 Staff Signature
  • 69. 70 [Type text] [Type text] [Type text] CS 8581 - Networks Laboratory Department of Information Technology Ex No : 9(a) Study of Network Simulator CO : C307.5 Date : K : K3 Aim : To study about the Network Simulator Description : What is NS2? •Short characterization – discrete event network simulator – packet-level – link layer and up – wired and wireless •A collaborative simulation platform – freely distributed, open source – developed by researchers in universities and research institutes – provide common reference ⇒ promote sharing – test suites ⇒ increase confidence in results •Intended users – researchers – developers – educators NS models •Traffic models and applications – web, FTP, telnet, constant bit rate, on-off •Transport protocols – unicast: TCP (Tahoe, Reno, Vegas, …), UDP – multicast: SRM •Routing and queuing – wired routing (unicast, multicast), ad hoc routing, Mobile IP – queuing models: drop tail, RED, fair queuing •Physical media – wired (point-to-point, LANs), wireless (multiple propagation models), satellite
  • 70. 71 [Type text] [Type text] [Type text] CS 8581 - Networks Laboratory Department of Information Technology BASIC TCL Variables: set x 10 puts “x is $x” Functions and expressions: Set y [pow $x 2] Set y [expr $x*$x] Control flow: if {$x > 0} {return $x} else {return [expr -$x]} while {$x > 0} { puts $x incr x –1 } for {set i 0} {$i < 10} {incr i} {puts $i} Procedures: proc fact {n} { if {$n == 1} { return 1 } else { expr $n*[fact [incr n –1]]] } } proc sum {} { global a b expr $a+$b } Tcl benefits: • Tcl also contains lists, associative arrays, etc. • Can use a real programming language to construct topologies, traffic sources, applications, etc. ELEMENTS OF TCL • Assumption: – we only consider wired simulations (without routing) • Important elements: – Create the event scheduler and random number generator – Create network • nodes and links – Create transport connection
  • 71. 72 [Type text] [Type text] [Type text] CS 8581 - Networks Laboratory Department of Information Technology • TCP, UDP – Create applications • CBR, FTP – Setup tracing • trace queues and flows CREATING THE EVENT SCHEDULER • Create event scheduler – set ns [new Simulator] • Schedule events – $ns at <time> <event> – <event>: any legitimate ns/tcl commands • Start scheduler – $ns run CREATING THE NETWORK • Nodes – set n0 [$ns node] – set n1 [$ns node] • Links and queuing – $ns duplex-link $n0 $n1 <bandwidth> <delay> <queue_type> – <queue_type>: DropTail, RED, CBQ, FQ, SFQ, DRR – example: link with 10 Mbps, 10 ms delay, buffer size 100, RED buffer control $ns duplex-link $n0 $n1 10Mbps 10ms RED # Set queue size $ns queue-limit $n0 $n1 100 # Set RED parameters set redq [[$ns link $n0 $n1] queue] $redq set thresh_ 0 $redq set maxthresh_ 100 $redq set linterm_ 20 $redq set mean_pktsize_ 500 $redq set q_weight_ 0.001
  • 72. 73 [Type text] [Type text] [Type text] CS 8581 - Networks Laboratory Department of Information Technology CREATING CONNECTIONS : UDP • UDP – set udp [new Agent/UDP] – set null [new Agent/Null] – $ns attach-agent $n0 $udp – $ns attach-agent $n1 $null – $ns connect $udp $null • All above combined into one command: – $ns create-connection <src_type> <src_node> <dst_type> <dst_node> <packet_class> – $ns create-connection UDP $n0 Null $n1 1 CREATING TRAFFIC : On top of UDP • CBR – Constant Bit Rate – set src [new Application/Traffic/CBR] • Exponential or Pareto on-off – on/off times exponentially/Pareto distributed – set src [new Application/Traffic/Exponential] – set src [new Application/Traffic/Pareto] • Connecting application to transport – “$udp” defined earlier – $src attach-agent $udp CREATING CONNECTIONS : TCP • TCP – set tcp [new Agent/TCP] – set tcpsink [new Agent/TCPSink] – $ns attach-agent $n0 $tcp – $ns attach-agent $n1 $tcpsink – $ns connect $tcp $tcpsink • … or above in one command: – $ns create-connection TCP $n0 TCPSink $n1 1 • Different TCP variants: – TCP = Tahoe TCP (slow start, AIMD) – TCP/Reno = Reno TCP (above + fast retransmit/fast recovery) – TCP/NewReno = modefied Reno TCP with improved fast retransmit – TCP/Sack1 = SACK TCP (selective ACK)
  • 73. 74 [Type text] [Type text] [Type text] CS 8581 - Networks Laboratory Department of Information Technology – other sources: TCP for asymmetric links (wireless), RTP source, RTCP source – different sinks: for each TCP type, LossMonitor (sink with packet loss monitoring) CREATING TRAFFIC : On top of TCP • FTP – set ftp [new Application/FTP] – $ftp attach-agent $tcp • Telnet – set telnet [new Application/Telnet] – $telnet attach-agent $tcp STARTING/STOPPING TRAFFIC AGENTS • Starting and stopping times scheduled as events to the scheduler – $ns at <time> <event> • Starting – $ns at 1.0 “$ftp start” – greedy source (sends infinitely long) – similarly for CBR, telnet and on/off sources • Stopping – $ns at 5.0 “$ftp stop” – similarly for CBR, telnet and on/off sources • Sending for example 1000 packets – $ns at 7.0 “$ftp produce 1000” – works only for FTP TRACING • Trace packets on all links of the network – $ns trace-all [open test.out w] • Turn on tracing on specific links – $ns trace-queue $n0 $n1 • Tace format: + 0.89456 0 2 cbr 210 ------- 0 0.0 3.1 0 0 - 0.89456 0 2 cbr 210 -- ----- 0 0.0 3.1 0 0 r 1.00234 0 2 cbr 210 ------- 0 0.0 3.1 0 0 – event type: (enque = +, deque = -, receive = r, drop = d) – event time – node ids of traced link (2 fields) – name of packet (“source’s name”) – packet size
  • 74. 75 [Type text] [Type text] [Type text] CS 8581 - Networks Laboratory Department of Information Technology – flags (not used here) – flow identifier – source/destination addresses (2 fields) – sequence number – unique packet identifier (all packets created in the simulaiton have a unique id) MONITORING • Sometimes tracing produces “too much” data – e.g., just want to know number of arrivals or dropped packets on a link or per flow – monitors • Queue monitors – set qmon [$ns monitor-queue $n0 $n1] – to read number of packet arrivals and drops • set parr [$qmon set parrivals_] • set drops [$qmon set pdrops_] • Flow monitors – enable flow monitoring • set fmon [$ns makeflowmon Fid] • $ns attach-fmon [$ns link $n0 $n1] $fmon – count arrivals and drops for flow with id xx • set fclassifier [$fmon classifier] • set flow1 [$fclassifier lookup auto 0 0 xx] • set parr [$flow1 set parrivals_] • set pdrops [$flow1 set pdrops_] GENERIC SCRIPT STRUCTURE set ns [new Simulator] # [Turn on tracing] # Create topology VIVA : # Setup packet loss, link dynamics # Create routing agents # Create: # - multicast groups # - protocol agents # - application and/or setup traffic sources # Post-processing procs # Start simulation Result : Thus the study of Network Simulator is completed successfully.
  • 75. 76 [Type text] [Type text] [Type text] CS 8581 - Networks Laboratory Department of Information Technology Ex No : 6 (b) Simulation of TCP Congestion Control using Network Simulator CO : R17C308.3 Date : K : K3 Aim : To simulate TCP Congestion Control mechanism using NS-2 Description : The topology in the wired network is set-up using the node and link creation APIs. The bottleneck is a duplex link that has router in both directions representing the traffic flow from multiple sources. The congestion in the wired network can be created using the bottleneck link. Create a tcl script file to induce the congestion in which each link is configured with the specific bandwidth, propagation delay and DropTail queue. Data transmission between the sender1 and receiver1 is created using the tcp connection and FTP application. Data transmission between the sender2 and receiver2 is created using the udp agent and CBR traffic. Congestion occurs at the link between router1 and router2 (bottleneck link) due to the high data flow rate that exceeds the link capacity. The length of the queue is limited. TCP enforces congestion control mechanism automatically by adjusting the sending data rate according to the acknowledgment arrival time. CODE : #Create a simulator object set ns [new Simulator] #Define different colors for data flows $ns color 1 Blue $ns color 2 Red #Open the nam trace file set nf [open out.nam w] $ns namtrace-all $nf #Define a 'finish' procedure proc finish {} { global ns nf $ns flush-trace #Close the trace file close $nf #Execute nam on the trace file exec nam out.nam & exit 0
  • 76. 77 [Type text] [Type text] [Type text] CS 8581 - Networks Laboratory Department of Information Technology } #Create four nodes set n0 [$ns node] set n1 [$ns node] set n2 [$ns node] set n3 [$ns node] #Create links between the nodes $ns duplex-link $n0 $n2 1Mb 10ms DropTail $ns duplex-link $n1 $n2 1Mb 10ms DropTail $ns duplex-link $n3 $n2 1Mb 10ms SFQ $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 the link between node 2 and node 3 $ns duplex-link-op $n2 $n3 queuePos 0.5 #Create a UDP agent and attach it to node n0 set udp0 [new Agent/UDP] $udp0 set class_ 1 $ns attach-agent $n0 $udp0 # Create a CBR traffic source and attach it to udp0 set cbr0 [new Application/Traffic/CBR] $cbr0 set packetSize_ 500 $cbr0 set interval_ 0.005 $cbr0 attach-agent $udp0 #Create a UDP agent and attach it to node n1 set udp1 [new Agent/UDP] $udp1 set class_ 2 $ns attach-agent $n1 $udp1 # Create a CBR traffic source and attach it to udp1 set cbr1 [new Application/Traffic/CBR] $cbr1 set packetSize_ 500 $cbr1 set interval_ 0.005 $cbr1 attach-agent $udp1 #Create a Null agent (a traffic sink) and attach it to node n3 set null0 [new Agent/Null] $ns attach-agent $n3 $null0 #Connect the traffic sources with the traffic sink $ns connect $udp0 $null0 $ns connect $udp1 $null0 #Schedule events for the CBR agents $ns at 0.5 "$cbr0 start" $ns at 1.0 "$cbr1 start"
  • 77. 78 [Type text] [Type text] [Type text] CS 8581 - Networks Laboratory Department of Information Technology $ns at 4.0 "$cbr1 stop" $ns at 4.5 "$cbr0 stop" #Call the finish procedure after 5 seconds of simulation time $ns at 5.0 "finish" #Run the simulation $ns run OUTPUT : Before Congestion
  • 78. 79 [Type text] [Type text] [Type text] CS 8581 - Networks Laboratory Department of Information Technology After Congestion Viva Questions : 1. Define : Congestion 2. State the effects of Congestion Result : Thus the TCP Congestion Control mechanism using NS-2 was simulated successfully. Criteria Allotted Awarded Design & Algorithm 20 Logic 20 Code 20 Output 20 Record Submission 10 Viva 10 Total 100 Staff Signature
  • 79. 80 [Type text] [Type text] [Type text] CS 8581 - Networks Laboratory Department of Information Technology Ex No : 10 Simulation of Routing Protocols using Network Simulator CO : C307.5 Date : K : K3 Aim: To simulate routing protocols like Link State and Distance Vector algorithms using NS-2 Description: Link State Routing Protocol : The Link State (LS) routing protocol has two components such as routing agent and route logic. The routing agent exchanges routing packet with neighbors in the link state manner while the route logic does Dijkstra on exploiting the information gathered by the routing agents to perform the actual route computation. Distance Vector Routing Protocol : In Distance Vector (DV), each node sends periodic route updates for every 2 seconds. Apart from the periodic updates, each node/agent sends triggered updates as a result of changes in the forwarding table in the node if any. This occurs either due to changes in the network topology or the node received a route update and as a result, it composes a fresh route. Algorithm : Link State Routing Protocol
  • 80. 81 [Type text] [Type text] [Type text] CS 8581 - Networks Laboratory Department of Information Technology CODE : LSRP.TCL #Create a new simulator object set ns [new Simulator] #Open trace Files set nr [open lsrp.tr w] $ns trace-all $nr set nf [open lsrp.nam w] $ns namtrace-all $nf #Finish Procedure proc finish { } { global ns nr nf $ns flush-trace close $nf close $nr exec nam lsrp.nam & exit 0 } #Create 12 nodes for { set i 0 } { $i < 12} { incr i 1 } { set n($i) [$ns node]} #Create Links for {set i 0} {$i < 8} {incr i} { $ns duplex-link $n($i) $n([expr $i+1]) 1Mb 10ms DropTail } $ns duplex-link $n(0) $n(8) 1Mb 10ms DropTail $ns duplex-link $n(1) $n(10) 1Mb 10ms DropTail $ns duplex-link $n(0) $n(9) 1Mb 10ms DropTail $ns duplex-link $n(9) $n(11) 1Mb 10ms DropTail $ns duplex-link $n(10) $n(11) 1Mb 10ms DropTail $ns duplex-link $n(11) $n(5) 1Mb 10ms DropTail #Create UDP Agent and attach it to Node n0 set udp0 [new Agent/UDP] $ns attach-agent $n(0) $udp0 #Create CBR traffic and attach it to UDP Agent udp0 set cbr0 [new Application/Traffic/CBR] $cbr0 set packetSize_ 500 $cbr0 set interval_ 0.005 $cbr0 attach-agent $udp0
  • 81. 82 [Type text] [Type text] [Type text] CS 8581 - Networks Laboratory Department of Information Technology #Setup UDP connection between n0 and n5 #Set n5 as Sink for Source Node n0 set null0 [new Agent/Null] $ns attach-agent $n(5) $null0 $ns connect $udp0 $null0 #Create UDP Agent and attach it to Node n1 set udp1 [new Agent/UDP] $ns attach-agent $n(1) $udp1 #Create CBR traffic and attach it to UDP Agent udp1 set cbr1 [new Application/Traffic/CBR] $cbr1 set packetSize_ 500 $cbr1 set interval_ 0.005 $cbr1 attach-agent $udp1 #Create Sink for n5 set null0 [new Agent/Null] $ns attach-agent $n(5) $null0 $ns connect $udp1 $null0 #define Link State algorithm as routing protocol $ns rtproto LS #define links going down and coming up $ns rtmodel-at 10.0 down $n(11) $n(5) $ns rtmodel-at 15.0 down $n(7) $n(6) $ns rtmodel-at 30.0 up $n(11) $n(5) $ns rtmodel-at 20.0 up $n(7) $n(6) #Set different colors for the two CBR traffic flows $udp0 set fid_ 1 $udp1 set fid_ 2 $ns color 1 Red $ns color 2 Green #Set start time and stop time for traffic flows $ns at 1.0 "$cbr0 start" $ns at 2.0 "$cbr1 start" #Call the Finish Procedure $ns at 45 "finish" #Run the Simulation $ns run
  • 82. 83 [Type text] [Type text] [Type text] CS 8581 - Networks Laboratory Department of Information Technology OUTPUT :
  • 83. 84 [Type text] [Type text] [Type text] CS 8581 - Networks Laboratory Department of Information Technology Algorithm : Distance Vector Routing Protocol CODE : DVRP.TCL #Create a new simulator object set ns [new Simulator] #Open trace Files set nr [open dvrp.tr w] $ns trace-all $nr set nf [open dvrp.nam w] $ns namtrace-all $nf #Finish Procedure proc finish { } { global ns nr nf $ns flush-trace close $nf close $nr exec nam dvrp.nam & exit 0 } #Create 12 nodes for { set i 0 } { $i < 12} { incr i 1 } { set n($i) [$ns node]} #Create Links for {set i 0} {$i < 8} {incr i} { $ns duplex-link $n($i) $n([expr $i+1]) 1Mb 10ms DropTail } $ns duplex-link $n(0) $n(8) 1Mb 10ms DropTail
  • 84. 85 [Type text] [Type text] [Type text] CS 8581 - Networks Laboratory Department of Information Technology $ns duplex-link $n(1) $n(10) 1Mb 10ms DropTail $ns duplex-link $n(0) $n(9) 1Mb 10ms DropTail $ns duplex-link $n(9) $n(11) 1Mb 10ms DropTail $ns duplex-link $n(10) $n(11) 1Mb 10ms DropTail $ns duplex-link $n(11) $n(5) 1Mb 10ms DropTail #Create UDP Agent and attach it to Node n0 set udp0 [new Agent/UDP] $ns attach-agent $n(0) $udp0 #Create CBR traffic and attach it to UDP Agent udp0 set cbr0 [new Application/Traffic/CBR] $cbr0 set packetSize_ 500 $cbr0 set interval_ 0.005 $cbr0 attach-agent $udp0 #Setup UDP connection between n0 and n5 #Set n5 as Sink for Source Node n0 set null0 [new Agent/Null] $ns attach-agent $n(5) $null0 $ns connect $udp0 $null0 #Create UDP Agent and attach it to Node n1 set udp1 [new Agent/UDP] $ns attach-agent $n(1) $udp1 #Create CBR traffic and attach it to UDP Agent udp1 set cbr1 [new Application/Traffic/CBR] $cbr1 set packetSize_ 500 $cbr1 set interval_ 0.005 $cbr1 attach-agent $udp1 #Create Sink for n5 set null0 [new Agent/Null] $ns attach-agent $n(5) $null0 $ns connect $udp1 $null0 #define distance vector algorithm as routing protocol $ns rtproto DV #define links going down and coming up $ns rtmodel-at 10.0 down $n(11) $n(5) $ns rtmodel-at 15.0 down $n(7) $n(6) $ns rtmodel-at 30.0 up $n(11) $n(5) $ns rtmodel-at 20.0 up $n(7) $n(6)
  • 85. 86 [Type text] [Type text] [Type text] CS 8581 - Networks Laboratory Department of Information Technology #Set different colors for the two CBR traffic flows $udp0 set fid_ 1 $udp1 set fid_ 2 $ns color 1 Red $ns color 2 Green #Set start time and stop time for traffic flows $ns at 1.0 "$cbr0 start" $ns at 2.0 "$cbr1 start" #Call the Finish Procedure $ns at 45 "finish" #Run the Simulation $ns run OUTPUT:
  • 86. 87 [Type text] [Type text] [Type text] CS 8581 - Networks Laboratory Department of Information Technology Viva Questions : 1. List any two differences between Distance Vector and link state Routing Protoclos 2. Routing Information Protocol is an example for __________________________ 3. Protocol example for Link State Routing Protocols is: _________ , ________ Result : Thus the Routing Protocols were simulated successfully. Criteria Allotted Awarded Design & Algorithm 20 Logic 20 Code 20 Output 20 Record Submission 10 Viva 10 Total 100 Staff Signature
  • 87. 88 [Type text] [Type text] [Type text] CS 8581 - Networks Laboratory Department of Information Technology Ex No : 11 Implementation of Bit Stuffing & DeStuffing CO : C307.1 Date : K : K3 AIM: To write a Java Program to perform Bit Stuffing and Bit Destuffing ALGORITHM: Bit Stuffing: 1. Create two file pointers namely f1 and f2. 2. Use first file pointer to open the input file and second file pointer to write the output in output file 3. Read input file and check whether there are 5 consecutive ones. 4. If 5 consecutive one’s appear in the input file, stuff 0 as its next bit else continue 5. Repeat steps 3&4 until all the bits are read 6. write a data along with stuffed bits in the output file. Bit Destuffing: 1. Create two file pointers namely f1 and f2. 2. Use first file pointer to open the input file and second file pointer to write the output in output file 3. Read input file and check whether there are 5 consecutive ones. 4. If zero is followed by 5 consecutive one’s, then delete zero bit else continue. 5. Repeat steps 3&4 until all the bits are read 6. write a data along with destuffed bits in the output file. CODE :
  • 88. 89 [Type text] [Type text] [Type text] CS 8581 - Networks Laboratory Department of Information Technology
  • 89. 90 [Type text] [Type text] [Type text] CS 8581 - Networks Laboratory Department of Information Technology OUTPUT : Viva Questions : 1. What is Bit stuffing?. 2. In which OSI layer, bit stuffing will be done? 3. State the purpose of Bit stuffing. 4. Stuff the following: 0101111110101 RESULT: Thus the Program for Bit stuffing and Bit Destuffing was written and correct output was verified Criteria Allotted Awarded Design & Algorithm 20 Logic 20 Code 20 Output 20 Record Submission 10 Viva 10 Total 100 Staff Signature
  • 90. 91 [Type text] [Type text] [Type text] CS 8581 - Networks Laboratory Department of Information Technology REFERENCES : 1. http://javabasicstudy.blogspot.com/2011/07/program-for-reverse-address-resolutuion.html#more 2. https://www.youtube.com/watch?v=3YoKVswJsKI 3. Socket Programming in Java : https://goo.gl/jlMEbg