Posts

Showing posts from 2018

Client Server Chatting

// A Java program for a Server import java.net.*; import java.io.*;   public class Server {     //initialize socket and input stream     private Socket          socket   = null;     private ServerSocket    server   = null;     private DataInputStream in       =  null;       // constructor with port     public Server(int port)     {         // starts server and waits for a connection         try         {             server = new ServerSocket(port);             System.out.println("Server started");               System.out.println("Waiting for a client ...");               socket = server.accept();             System.out.println("Client accepted");               // takes input from the client socket             in = new DataInputStream(                 new BufferedInputStream(socket.getInputStream()));               String line = "";               // reads message from client until "Over" is sent        

DV and LS Routing Algorithm Implementation in ns2

#Create a simulator object set ns [new Simulator] #Tell the simulator to use dynamic routing $ns rtproto DV/LS #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 } #Create seven nodes for {set i 0} {$i < 7} {incr i} {         set n($i) [$ns node] } #Create links between the nodes for {set i 0} {$i < 7} {incr i} {         $ns duplex-link $n($i) $n([expr ($i+1)%7]) 1Mb 10ms DropTail } #Create a UDP agent and attach it to node n(0) set udp0 [new Agent/UDP] $ns attach-agent $n(0) $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 Null agent (a traffic sink) and attach it to nod

exp 6.2.tcl

#Create a simulator object set ns [new Simulator] #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 } #Create two nodes set n0 [$ns node] set n1 [$ns node] #Create a duplex link between the nodes $ns duplex-link $n0 $n1 1Mb 10ms DropTail #Create a UDP agent and attach it to node n0 set udp0 [new Agent/UDP] $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 Null agent (a traffic sink) and attach it to node n1 set null0 [new Agent/Null] $ns attach-agent $n1 $null0 #Connect the traffic source with the traffic sink $ns connect $udp0 $null0 #Schedule events for t

EXPERIMENT NO 1

Image
Cisco Packet Tracer - Subnetting a Network A sub network or subnet is a logical subdivision of an IP network. The practice of dividing a network into two or more networks is called sub netting. Subnetting offers many advantages. Some of them are. 1. It provides security to the network. 2. Speeds up the network thus improving the performance of the network. 3. It allows for better organization of the resources. Procedure: To create a subnet, first we need to have proper planning as to how many subnets we need and how many we may need in the future. Presently, I need three subnets. The number of subnets should always be calculated in the powers of 2. 2 to the power of 1 = 2 This doesn’t satisfy our requirement as we need three subnets. 2 to the power of 2 = 4 This satisfies our requirement. So we need to take two bits from the host portion of the IP address. 192.168.10.1 to 192.168.10.255 is the address range available to us with subnet mask 255.255.255.0, Wr