!!@<>@!!

Editor –

WELCOME TO MY WORLD

This is my world i have a good idea about the tech world and our word name Abhi Tech

Click below to get a App

Explore

This is a group of blocks in columns. Column layouts can be adapted to fit different needs.

WordPress Experts

This is a group of blocks in columns. Column layouts can be adapted to fit different needs.

Experience

This is a group of blocks in columns. Column layouts can be adapted to fit different needs.

java programs

1..Leaky Bucket

public class leakyBucket{

    public static void main(String args[]) throws InterruptedException

    {

           int n,outgoing,incoming,store=0,Bucketsize;

        Scanner Scan=new Scanner(System.in);

        System.out.println(“enter the Bucketsize,outgoing rate,number of inputs,incoming size”);

        Bucketsize=Scan.nextInt();

        outgoing=Scan.nextInt();

        n=Scan.nextInt();

        incoming=Scan.nextInt();

        while(n!=0)

        {

            System.out.println(“incoming size”+incoming);

            if(incoming<=(Bucketsize=store))

            {

                store+=incoming;

                System.out.println(“Bucket buffer size”+store+”out of”+Bucketsize);

            }

            else

            {

                System.out.println(“packetloss:”+(incoming-(Bucketsize=store)));

                store=Bucketsize;

                    System.out.println(“Bucket buffer size”+store+”out of”+Bucketsize);

            }

            store=outgoing;

            System.out.println(“after outgoing:”+store+”packets left out of”+Bucketsize);

            n–;

            Thread.sleep(3000);

        }

        Scan.close();

    }

}

2 CRC ————————————————————–

import java.util.Scanner;

import java.io.*;

public class crc

{

    public static void main(String args[])

    {

        Scanner Sc=new Scanner(System.in);

        System.out.print(“enter message bits:”);

        String message=Sc.nextLine();

        System.out.println(“enter generator:”);

        String generator=Sc.nextLine();

        int data[]=new int[message.length()+generator.length()-1];

        int divisor[]=new int[generator.length()];

        for(int i=0;i<message.length();i++)

            data[i]=Integer.parseInt(message.charAt(i)+””);

        for(int i=0;i<generator.length();i++)

            divisor[i]=Integer.parseInt(generator.charAt(i)+””);

        for(int i=0;i<message.length();i++)

        {

            if(data[i]==1)

                for(int j=0;j<divisor.length;j++)

                    data[i+j]^=divisor[j];

        }

        System.out.print(“the checksumcode is:”);

        for(int i=0;i<message.length();i++)

            data[i]=Integer.parseInt(message.charAt(i)+””);

        for(int i=0;i<data.length;i++)

            System.out.print(data[i]);

                System.out.println();

                System.out.print(“enter checksumcode is:”);

                message=Sc.nextLine();

                System.out.print(“enter generator:”);

                generator=Sc.nextLine();

                data=new int[message.length()+generator.length()-1];

                divisor=new int[generator.length()];

                for(int i=0;i<message.length();i++)

                    data[i]=Integer.parseInt(message.charAt(i)+””);

                for(int i=0;i<generator.length();i++)

                    divisor[i]=Integer.parseInt(generator.charAt(i)+””);

                for(int i=0;i<message.length();i++)

                {

                    if(data[i]==1)

                        for(int j=0;j<divisor.length;j++)

                            data[i+j]^=divisor[j];

                }

                boolean valid=true;

                for(int i=0;i<data.length;i++)

                    if(data[i]==1){

                        valid=false;

                                break;

                               }        

    if(valid==true)

        System.out.println(“Data stream is valid”);

    else

        System.out.println(“Data stream  invalid crc error occured”);

}  

    }

4. Bellmanford

import java.util.Scanner;

public class Bellmanford

{

    private int D[];

    private int num_ver;

    public static final int MAX_VALUE=999;

    public Bellmanford(int num_ver)

    {

        this.num_ver=num_ver;

        D=new int[num_ver+1];

    }

    public void Bellmanfordvaluation(int Source,int A[][])

    {

        for(int node=1;node<=num_ver;node++)

        {

            D[node]=MAX_VALUE;

        }

        D[Source]=0;        for(int node=1;node<num_ver-1;node++)

        {

            for(int sn=1;sn<=num_ver;sn++)

            {

                for(int dn=1;dn<=num_ver;dn++)

                {

                    if(A[sn][dn]!=MAX_VALUE)

                    {

                        if(D[dn]>D[sn]+A[sn][dn])

                            D[dn]=D[sn]+A[sn][dn];

                    }

                }

            }

        }

        for(int sn=1;sn<=num_ver;sn++)

        {

            for(int dn=1;dn<=num_ver;dn++)

            {

                    if(A[sn][dn]!=MAX_VALUE)

                    {

                        if(D[dn]>D[sn]+A[sn][dn])

                    System.out.println(“the graph contains negative edge cyacle”);

            }

        }

    }

    for(int vertex=1;vertex<=num_ver;vertex++)

    {

        System.out.println(“distance of source”+Source+”to”+vertex+”is”+D[vertex]);

    }

    }

public static void main(String args[])

{

    int num_ver=0;

    int Source;

    Scanner Scan=new Scanner(System.in);

    System.out.println(“enter the number of vertices”);

    num_ver=Scan.nextInt();

    int A[][]=new int[num_ver+1][num_ver+1];

    System.out.println(“enter the adjacency matrix”);

    for (int sn=1;sn<=num_ver;sn++)

    {

        for(int dn=1;dn<=num_ver;dn++)

        {

            A[sn][dn]=Scan.nextInt();

            if(sn==dn)

            {

                A[sn][dn]=0;

                continue;

            }

            if(A[sn][dn]==0)

            {

                A[sn][dn]=MAX_VALUE;

            }

        }

    }

        System.out.println(“enter the Source vertex”);

        Source=Scan.nextInt();

        Bellmanford b=new Bellmanford(num_ver);

        b.Bellmanfordvaluation(Source,A);

        Scan.close();

}

}  

5.TCP CLIENT

import java.net.*;

import java.io.*;

public class TCPClient

{

    public  static void main(String args[])throws Exception

    {

        Socket Sock=new Socket(“127.0.0.1”,4000);

        System.out.print(“enter file name\n”);

        BufferedReader br=new BufferedReader(new InputStreamReader(System.in));

        String fname=br.readLine();

        OutputStream ostream=Sock.getOutputStream();

        PrintWriter pwrite=new PrintWriter(ostream,true);

        pwrite.println(fname);

        InputStream istream=Sock.getInputStream();

        BufferedReader SocketRead=new BufferedReader(new InputStreamReader(istream));

        String str;

        while((str=SocketRead.readLine())!=null)

        {

            System.out.println(str);

        }

        pwrite.close(); SocketRead.close();

        br.close(); Sock.close();

    }

}

TCP SERVER

import java.io.*;

import java.net.ServerSocket;

import java.net.Socket;

public class TCPServer

{

    public static void main(String args[])throws Exception

    {

        ServerSocket SerSock=new ServerSocket(4000);

        System.out.println(“Server ready for connection”);

        Socket Sock=SerSock.accept();

        System.out.println(“connection successful|waiting for file name”);

        InputStream istream=Sock.getInputStream();

        BufferedReader br=new BufferedReader(new InputStreamReader(istream));

        String fname=br.readLine();

        BufferedReader contentRead=new BufferedReader(new FileReader(fname));

        OutputStream ostream=Sock.getOutputStream();

        PrintWriter pwrite=new PrintWriter(ostream,true);

        String str;

        while((str=contentRead.readLine())!=null)

        {

            pwrite.println(str);

        }

        System.out.println(“file content sent successfully”);

        Sock.close(); SerSock.close();

        pwrite.close();br.close();contentRead.close();

    }

}

6.UDP CLIENT

import java.io.*;

import java.net.*;

class  UDPClient

{

    public static void main(String agrs[])throws Exception

    {

    BufferedReader informUser=new BufferedReader(new InputStreamReader(System.in));

    DatagramSocket ClientSocket=new DatagramSocket();

    InetAddress IPAddress=InetAddress.getByName(“localhost”);

    byte[]sendData=new byte[1024];

    byte[]receiveData=new byte[1024];

    System.out.println(“enter START to be connected to Server”);

    String Sentence=informUser.readLine();

    sendData=Sentence.getBytes();

    DatagramPacket sendPacket=new DatagramPacket(sendData,sendData.length,IPAddress,9876);

    ClientSocket.send(sendPacket);

    DatagramPacket receivePacket=new DatagramPacket(receiveData,receiveData.length);

    ClientSocket.receive(receivePacket);

    String modifiedSentence=new String(receivePacket.getData());

    System.out.println(“message sent from server:”+modifiedSentence);

    ClientSocket.close();

    }

}

UDP SERVER

import java.io.*;

import java.net.*;

import java.util.Scanner;

class UDPServer

{

    public static void main(String args[])throws Exception

    {

        DatagramSocket ServerSocket=new DatagramSocket(9876);

        System.out.println(“Server started on port 9876”);

        byte[]receiveData=new byte[1024];

        byte[]sendData=new byte[1024];

        DatagramPacket receivePacket=new DatagramPacket(receiveData,receiveData.length);

        ServerSocket.receive(receivePacket);

        receivePacket.getData();

        InetAddress IPAddress=receivePacket.getAddress();

        int port=receivePacket.getPort();

        System.out.println(“client connected”);

        Scanner input=new Scanner(System.in);

        System.out.println(“enter the message to be sent”);

        String message=input.nextLine();

        sendData=message.getBytes();

        DatagramPacket sendPacket=new DatagramPacket(sendData,sendData.length,IPAddress,port);

        ServerSocket.send(sendPacket);

        System.exit(0);

    }

}

7.RSA

import java.util.*;

import java.io.*;

public class rsa

{

        static int gcd (int m,int n)

        {

            while(n!=0)

            {

            int r=m%n;

            m=n;

            n=r;

        }

        return m;

}

    public static void main(String args[])

        {

        int p=0,q=0,e=0,d=0,phi=0,n=0;

        int number[]=new int[100];

        int encrypted[]=new int[100];

        int decrypted[]=new int[100];

        int i=0,j=0,nofelem=0;

            Scanner Sc=new Scanner(System.in);

            String message;

                System.out.println(“enter the message to be encrypted:”);

                message=Sc.nextLine();

                System.out.println(“enter the value of p and q\n”);

                p=Sc.nextInt();

                q=Sc.nextInt();

                n=p*q;

                phi=(p-1)*(q-1);

                for(i=2;i<phi;i++)

                    if(gcd(i,phi)==1)

                        break;

                e=i;

                for(i=2;i<phi;i++)

                    if((e*i-1)%phi==0)

                        break;

                d=i;

                for(i=0;i<message.length();i++)

                {

                    char c=message.charAt(i);

                    int a=(int)c;

                    number[i]=c-96;

                }

                    nofelem=message.length();

                    for(i=0;i<nofelem;i++)

                    {

                        encrypted[i]=1;

                        for(j=0;j<e;j++)

                            encrypted[i]=(encrypted[i]*number[i])%n;

                    }

                    System.out.println(“\n encrypted message”);

                    for(i=0;i<nofelem;i++)

                    {

                        System.out.println(encrypted[i]);

                        System.out.println((char)(encrypted[i]+96));

                    }

                    for(i=0;i<nofelem;i++)

                    {

                        decrypted[i]=1;

                        for(j=0;j<d;j++)

                            decrypted[i]=(decrypted[i]*number[i])%n;

                    }

                    System.out.println();

                    System.out.println(“\n decrypted message”);

                    for(i=0;i<nofelem;i++)

                        System.out.println((char)(decrypted[i]+96));

                    System.out.println();

                    return;

                }

}

Not all those who wander are lost.

J. R. R. TOLKIEN

Add or remove columns and adjust their dimensions.

This column contains two paragraph blocks. The adjacent column contains a pullquote block.

About Us

Visitors will want to know who is on the other side of the page. Use this space to write about your business

Get In Touch

  • mail@a2001.com

Drop By




Design a site like this with WordPress.com
Get started