Wednesday 30 April 2014

Fuzzy Logic Control - project

ABSTRACT
In view of the fast-growing Internet traffic, this paper propose a distributed traffic management framework, in which routers are deployed with intelligent data rate controllers to tackle the traffic mass. Unlike other explicit traffic control protocols that have to estimate network parameters (e.g., link latency, bottleneck bandwidth, packet loss rate, or the number of flows) in order to compute the allowed source sending rate, our fuzzy-logic-based controller can measure the router queue size directly; hence it avoids various potential performance problems arising from parameter estimations while reducing much consumption of computation and memory resources in routers. As a network parameter, the queue size can be accurately monitored and used to proactively decide if action should be taken to regulate the source sending rate, thus increasing the resilience of the network to traffic congestion. The communication QoS (Quality of Service) is assured by the good performances of our scheme such as max-min fairness, low queueing delay and good robustness to network dynamics. Simulation results and comparisons have verified the effectiveness and showed that our new traffic management scheme can achieve better performances than the existing protocols that rely on the estimation of network parameters.
                                For More Details: 9042681003


Monday 24 June 2013

network programs


/*PROGRAM USING TCP SOCKET*/
SOURCE CODE:
SERVER PROGRAM:
import java.io.*;
import java.net.*;
class TCPServer
{
public static void main(String args[])throws Exception
{
String fromclient;
String toclient;
ServerSocket Server=new ServerSocket(5000);
System.out.println("TCP server waiting for client on port     5000");
while(true)
{
Socket connected=Server.accept();
System.out.println("THE CLIENT"+" +connected.getInetAddress()+":"+connected.
getPort()+"IS CONNECTED");
BufferedReader inFromUser=new BufferedReader(new InputStreamReader(System.in));
BufferedReader inFromClient=new BufferedReader(new InputStream
Reader(connected.getInputStream()));
PrintWriter outToClient=new PrintWriter (connected.getOutputStream(),true);
while(true)
{
System.out.println("SEND(Type Q or q to Quit):");
toclient=inFromUser.readLine();
if(toclient.equals("q")||toclient.equals("Q"))
{
outToClient.println(toclient);
connected.close();
break;
}
else
outToClient.println(toclient);
fromclient=inFromClient.readLine();                                          if(fromclient.equals("q")||fromclient.equals("Q"))
{
connected.close();
break;
}
else
System.out.println("RECEIVED:"+fromclient);
}
}
}
}


























CLIENT PROGRAM:
import java.io.*;
import java.net.*;
class TCPClients
{
public static void main(String argv[])throws Exception
{
String FromServer;
String ToServer;
Socket ClientSocket=new Socket("localhost",5000);
BufferedReader inFromUser=new BufferedReader(new InputStreamReader(System.in));
PrintWriter outToServer=new PrintWriter(Client
Socket.getOutputStream(),true);
BufferedReader inFromServer=new BufferedReader(new InputStream
Reader(ClientSocket.getInputStream()));
while(true)
{
FromServer=inFromServer.readLine();
if(FromServer.equals("q")||FromServer.equals("Q"))
{
ClientSocket.close();
break;
}
else
{
System.out.println("RECEIVED:"+FromServer);
System.out.println("SEND(Type Q or q to Quit):");
ToServer=inFromUser.readLine();
if(ToServer.equals("Q")||ToServer.equals("q"))
{
outToServer.println(ToServer);
ClientSocket.close();
break;
}
else
{
outToServer.println(ToServer);
}
}
}
}
}

 --------------------------------------------------------


/*PROGRAM USING UDP SOCKET*/
Source code
SERVER PROGRAM:
import java.net.*;
import java.io.*;
class UDPServer
{
public static void main(String args[])throws Exception
{
byte[] receive_data=new byte[1024];
byte[] send_data=new byte[1024];
int recv_port;
DatagramSocket server_socket=new DatagramSocket(5000);
System.out.println("UDPServer waiting for client on port 5000");
while(true)
{
DatagramPacket receive_packet=new DatagramPacket(receive_data,receive_data.length);
server_socket.receive(receive_packet);
String data=new String(receive_packet.getData(),0,0,receive_packet.getLength());
InetAddress IPAddress=receive_packet.getAddress();
recv_port=receive_packet.getPort();
if(data.equals("q")||data.equals("Q"))
break;
else
System.out.println("("+IPAddress+","+recv_port+")said:"+data);
}
}
}








CLIENT PROGRAM:
import java.net.*;
import java.io.*;
class UDPClient
{
public static void main(String args[])throws Exception
{
byte[] send_data=new byte[1024];
BufferedReader infromuser=new BufferedReader(new InputStreamReader(System.in));
DatagramSocket client_socket=new DatagramSocket();
InetAddress IPAddress=InetAddress.getByName("127.0.0.1");
while(true)
{
System.out.println("Type something(q or Q to quit):");
String data=infromuser.readLine();
if(data.equals("q")||data.equals("Q"))
break;
else
{
send_data=data.getBytes();
DatagramPacket send_packet=new DatagramPacket(send_
data,send_data.length,IPAddress,5000);
client_socket.send(send_packet);
}
}
client_socket.close();
}
}


/*SIMULATION OF SLIDING WINDOW PROTOCOL*/
SOURCE CODE:
//SENDER:
import java.net.*;
import java.io.*;
import java.rmi.*;
public class Sender
{
public static void main(String a[])throws Exception
{
ServerSocket ser=new ServerSocket(10);
Socket s=ser.accept();
DataInputStream in=new DataInputStream(System.in);
DataInputStream in1=new DataInputStream(s.getInputStream());
String sbuff[]=new String[8];
PrintStream p;
int sptr=0,sws=8,nf,ano,i;
String ch;
do
{
p=new PrintStream(s.getOutputStream());
System.out.println("Enter the no.of frames:");
nf=Integer.parseInt(in.readLine());
p.println(nf);
if(nf<=sws-1)
{
System.out.println("Enter"+nf+"messages to be send\n");
for(i=1;i<=nf;i++)
{
sbuff[sptr]=in.readLine();
p.println(sbuff[sptr]);
sptr=++sptr%8;
}
sws-=nf;
System.out.println("Acknowledgement received");
ano=Integer.parseInt(in1.readLine());
System.out.println("for"+ano+"frames");
sws+=nf;
}
else
{
System.out.println("The no.of frames exceeds window size");
break;
}
System.out.println("Do you wants to send some more frames:");
ch=in.readLine();
p.println(ch);
}
while(ch.equals("yes"));
s.close();
}
}




















//CLIENT:
import java.net.*;
import java.io.*;
class Receiver
{
public static void main(String a[])throws Exception
{
Socket s=new Socket(InetAddress.getLocalHost(),10);
DataInputStream in=new DataInputStream(s.getInputStream());
PrintStream p=new PrintStream(s.getOutputStream());
int i=0,rptr=-1,nf,rws=8;
String rbuff[]=new String[8];
String ch;
System.out.println();
do
{
nf=Integer.parseInt(in.readLine());
if(nf<=rws-1)
{
for(i=1;i<=nf;i++)
{
rptr=++rptr%8;
rbuff[rptr]=in.readLine();
System.out.println("The received frame"+rptr+"is:"+rbuff[rptr]);
}
rws-=nf;
System.out.println("\nAcknowledgement sent\n");
p.println(rptr+1);
rws+=nf;
}
else
break;
ch=in.readLine();
}while(ch.equals("yes"));
}
}







Tuesday 18 June 2013

REMOTE METHOD INVOCATION(RMI)


Calculator.java



import java.rmi.Remote;
import java.rmi.RemoteException;

public interface Calculator extends Remote
{
    public long add(long a,long b) throws RemoteException;
}

CalculatorImpl.java


import java.rmi.RemoteException;
import java.rmi.server.UnicastRemoteObject;

public class CalculatorImpl extends UnicastRemoteObject implements Calculator
{
    protected CalculatorImpl() throws RemoteException
    {
        super();
    }
    public long add(long a, long b) throws RemoteException
    {
        return a+b;
    }
}

CalculatorServer.java
?

21
import java.rmi.Naming;

public class CalculatorServer
{
    CalculatorServer()
    {
        try
        {
            Calculator c = new CalculatorImpl();
            Naming.rebind("rmi://127.0.0.1:1099/CalculatorService", c);
        }
        catch (Exception e)
        {
            e.printStackTrace();
        }
    }
    public static void main(String[] args)
    {
        new CalculatorServer();
    }
}


CalculatorClient.java
?

import java.rmi.Naming;

public class CalculatorClient
{
    public static void main(String[] args)
    {
        try
        {
            Calculator c = (Calculator) Naming.lookup("//127.0.0.1:1099/CalculatorService");
            System.out.println("addition : "+c.add(10, 15));
        }
        catch (Exception e)
        {
            System.out.println(e);
        }
    }
}
See more at: http://www.java2all.com/1/5/22/113/Technology/RMI/RMI-Program/RMI-Program-in-java#sthash.bbdLDMkn.dpuf