Category : CN LAB

10. Write a program on datagram socket for client/server to display the messages on client side, typed at the server side.UDPServer.java – PROGRAM  import java.net.*;import java.util.Scanner; public class UDPServer { public static void main(String[] args) throws Exception{ Scanner in = new Scanner(System.in); DatagramSocket socket=new DatagramSocket(); String msg=in.nextLine(); byte code[]=msg.getBytes(); InetAddress iAddress=InetAddress.getByName(“127.0.0.1”); DatagramPacket request=new DatagramPacket(code,code.length,iAddress,4000); socket.send(request); }} ..

Read more

2. Implement transmission of ping messages/trace route over a network topology consisting of 6 nodes and find the number of packets dropped due to congestion.cn2.tcl – PROGRAMset val(stop) 10.0 ; # time of simulation end#Create a ns simulatorset ns [new Simulator]#Open the NS trace fileset tracefile [open 3.tr w]$ns trace-all $tracefile#Open the NAM trace fileset namfile ..

Read more

12. Write a program for congestion control using leaky bucket algorithm.Leaky.java – PROGRAMimport java.util.Scanner;public class Leaky { public static void main(String[] args)  { Scanner sc = new Scanner(System.in); int bcktsize, iter, rate, line, total = 0; int[] pkt = new int[25]; System.out.print(“Enter the bucket size and output rate(both in MB):”); bcktsize = sc.nextInt(); rate = sc.nextInt(); System.out.println(“Enter ..

Read more

4. Implement simple ESS and with transmitting nodes in wire-less LAN by simulation and determine the performance with respect to transmission of packets. cn4.tcl – PROGRAM # Simulation parameters setup set val(chan) Channel/WirelessChannel ;# channel type set val(prop) Propagation/TwoRayGround ;# radio-propagation model set val(netif) Phy/WirelessPhy ;# network interface type set val(mac) Mac/802_11 ;# MAC type ..

Read more

6. Implement and study the performance of CDMA on NS2/NS3 (Using stack called Call net) or equivalent environment. cn6.tcl – PROGRAM set opt(title) zero ; set opt(stop) 100 ; set opt(ecn) 0 ; set opt(type) umts ; set opt(secondDelay) 55 ; set opt(minth) 30 ; set opt(maxth) 0 ; set opt(adaptive) 1 ; 0 for ..

Read more

7. Write a program for error detecting code using CRC-CCITT (16- bits). Crc.java – PROGRAM import java.util.Scanner; public class Crc { static int n,m,msb,i,j,k,g[],d[],z[],r[]; public static void main(String[] args)  { Scanner s=new Scanner(System.in); System.out.println(“Enter no. of databits:”); n=s.nextInt(); System.out.println(“Enter no. of generator bits:”); m=s.nextInt(); d=new int[m+n]; g=new int[n]; System.out.println(“Enter databits:”); for(i=0;i<n;i++) d[i]=s.nextInt(); System.out.println(“Enter generator bits:”); ..

Read more

9. Using TCP/IP sockets, write a client – server program to make the client send the file name and to make the server send back the contents of the requested file if present.Server,java – PROGRAMimport java.io.*;import java.net.*;import java.util.Scanner;public class Server { public static void main(String[] args) throws Exception  { System.out.println(“Server ready for communication”); ServerSocket serverSocket=new ServerSocket(4000); Socket ..

Read more

11. Write a program for simple RSA algorithm to encrypt and decrypt the data.RSA.java – PROGRAMimport java.io.DataInputStream; import java.io.IOException; import java.math.BigInteger; import java.util.Random; public class RSA {     private BigInteger d, e, p, q, N, phi;     private int bitlength = 1024;     private Random r;         public RSA()     {         r = new Random();       ..

Read more

1. Implement three nodes point – to – point network with duplex links between them. Set the queue size, vary the bandwidth and find the number of packets dropped. cn1.tcl – PROGRAM # Simulation parameters setup set val(stop) 6.0 ; # stopping time of the simulation # Initialization #Create a ns simulator set ns [new ..

Read more

8. Write a program to find the shortest path between vertices using bellman-ford algorithm.BellmanFord.java – PROGRAMimport java.util.Scanner;public class BellmanFord { int d[],noofvertices; public BellmanFord(int noofvertices)  { this.noofvertices = noofvertices; d = new int[noofvertices + 1]; } public static void main(String[] args)  { int noofvertices,source; Scanner s = new Scanner(System.in); System.out.println(“Enter the number of vertices:”); noofvertices = s.nextInt(); ..

Read more