Programming Forums
User Name Password Register
 

RSS Feed
FORUM INDEX | TODAY'S POSTS | UNANSWERED THREADS | ADVANCED SEARCH

Reply
 
Thread Tools Display Modes
Old Jan 15th, 2007, 9:19 AM   #1
fresher
Newbie
 
Join Date: Dec 2006
Posts: 13
Rep Power: 0 fresher is on a distinguished road
network monitoring program

Hi all, is anyone able to help me out with this great task in java pls? I have tried my best but have just hit the brick wall. any responses greatly appreciated.

Below is the specification ( couldnt attach it unfortunately)


NETWORK MONITORING PROGRAM

The aim of this project is to create a network monitoring utility that will enable a network engineer / technician to inspect machines on his / her network and check for good operation. You will need to design and implement two programs.

1. The main utility.
2. The client program.

Main utility program.
This program must have a User Graphic Interface, that presents all computers currently attached on the network and allow the user to select and view information about a particular one if he/she so wishes. Also computers on the network should come up with a different icon or colour if there is a particular problem associated with them by the user
of the utility. The main core function of the utility is to communicate with the client program in regular intervals and check for good operation. If the communication cannot be established or the client takes too long to answer or it sends back a predefined message of trouble then the user can identify that this particular machine is problematic. 
`------
The client utility’s function is to run in all computers on the network and periodically report back (or upon request) to the main utility computer the status of its operation. The client utility may contain information about the user of the terminal at that particular
moment or simply report back in a set amount of time, indicating otherwise that there is a problem. This utility does not need to have a user interface, it may require however a settings interface if you so wish.

I’m assessed based on the following:

• Graphics Interface
• Networking 
• Use of objects, Methods, good understanding of java basics 
o Solid use of Java
o Object Oriented Programming principles
o Proper identification of variables
o Flow diagrams
o Simplicity
o Functionality
A FEW HELPFUL TIPS:
• Remember to use Java’s coding conventions.
• Write well-structured and readable code with appropriate comments in the right
places.

hints and tips:
• Keep the fundamentals of Object Orientation in mind when you write your code i.e. reuse objects, don’t write unnecessarily long programs if you can split the work into different classes, try and use constructors to initialize your programs and don’t burden your main class with variable assignments, etc.
• Finally, write small pieces of code and compile them and add functionality to it. It would help, NOT to write your whole program together and then try and compile it and sort out your 1000 or so odd errors yourself while the supervisors are busy looking at someone else’s 2000 odd errors!!!

------------this is my attempt before hitting the brick wall
SERVER
//***************************
/*
*
*program description
*author etc
*
*/
//*******************************

// TCP server which sends a message to client - non threaded
import java.io.*;
import java.util.*;
import java.net.*;


public class TCPserverText
{
public static void main(String args[])
{
        BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
        
        // port to receive TCP connections
        int receivePort=9000;             
         Socket socket=null;
            try
                {
                  System.out.println("TCP server starting...: IP address "
                       + InetAddress.getLocalHost().toString() + " port " + receivePort );
                       
                  ServerSocket serverSocket = new ServerSocket(receivePort);
                  
                  // Wait for client to connect.
                  socket = serverSocket.accept();                  
                  System.out.println("Client connection detected from IP address " + socket.getInetAddress()
                                  + " port " + socket.getPort());
                                  
                  // open writer to the client and  send  a message
                  PrintWriter pw = new PrintWriter(socket.getOutputStream());
                  pw.println("Hello " + socket.getInetAddress() + " on port " + socket.getPort());
                  //System.out.println("enter text to send to client");
                  // loop sending messages to client
                  while(true)                       
                    try
                      {
                       pw.flush();
                       String line = in.readLine();
                       pw.println(line);
                     }
                    catch (Exception se) {System.err.println("closing connection"); break;}
                  pw.close();
                  serverSocket.close();
                }
                
                
            catch (Exception se) {System.err.println( se); }
        }
}

CLIENT
------
// TCP client which receives a message from  server

import java.io.*;
import java.util.*;
import java.net.*;


	class IPgenerator2
	{
  		String view_host;
  		String accept;
  		int choice;
		String ip = "148.197.67.";
	
		String ipmethd()
		{
	
	
		KeyboardInput in = new KeyboardInput();
	
		for(int i = 1; i < 10; i++) {
		System.out.print(i);
		System.out.print(". ");
		//System.out.print();
		System.out.println(ip + i);
		}
		System.out.println();
		
		//enter a different network id or hit enter to continue
		//to allow user to enter a different netwrok portion
		//hitting enter implies network is same
			
		//System.out.print("Enter your network part or press enter to proceed: ");
			//String network = in.readString();
			
			//test
			//.out.println(network);
			
			//if enter is pressed - same network
		  //	if("".equals(network))
			//{
			
				System.out.print("SELECT A MACHINE TO VIEW FROM LIST: ");
				int choice = in.readInteger();
				
					
				
			//	}
			//	else
			
				//pass new network part to ip string variable
			//	ip = network;
				
		
		
		
				//real switch 
				switch (choice)
  		 		{ 
 		
 				case 1:
 				view_host = "148.197.67.211";
 				//System.out.println("You selected to view machine with IP: " + view_host);
 				//return view_host = "192.168.2.1"; 
 				break;
 	
 				case 2:
 				view_host = "148.197.67.212";
 				//System.out.println("You selected to view machine with IP: " +  view_host);
 				//return view_host = "192.168.2.2";
 				break;
 			
 				case 3:
 				view_host = "148.197.67.213";
 				//System.out.println("You selected to view machine with IP: " +  view_host);
 				//return view_host = "192.168.2.3";
 				break;
 			
 				case 4:
 				view_host = "148.197.67.214";
 				//System.out.println("You selected to view machine with IP: " +  view_host);
 				//return view_host = "192.168.2.4";
 				break;
 			
 				case 5:
 				view_host = "148.197.67.215";
 				//System.out.println("You selected to view machine with IP: " +  view_host);
 				//return view_host = "192.168.2.4";
 				break;
 			
 				case 6:
 				view_host = "148.197.67.216";
 				//System.out.println("You selected to view machine with IP: " +  view_host);
 				//return view_host = "192.168.2.4";
 				break;
 			
 	
 				default:
 				System.out.println("This machine doesnt exist, please choose a valid host");
 			
 				//return view_host;
 				}
 				
 		 	return view_host; 
 		 
	 	    }
 	  }




	//client program starts here

	public class TCPclientText
	{
	
			public static void main(String args[])
			{
			//initialisation
			String view_host; 
			IPgenerator2 ip = new IPgenerator2();
			
			//call ipgenerator
			//ip.ipmethd();
	
	   
			//server IP address
 		  	//String remoteIPaddress="192.168.2.4";
 		 	// int remotePort=9000;
  
  
  
			  //array to hold list of client IPs say registered
 			 //array enables me select the client to connect to
 			// String remoteIPaddress[]={"192.168.2.4","192.168.2.5","192.168.2.6"};
 			//call ip generator and assign it 
 			
  			String remoteIPaddress =ip.ipmethd();
   			int remotePort=9000;
   	
  			//for(int index=0; index<3;index++)
   
  			 try
       			{
        		// connect to server with remoteIPaddress on remotePort
        		//Socket socket1 = new Socket( remoteIPaddress, remotePort );
        		//here I have selected to connect to just the first client - index 0
        		Socket socket1 = new Socket( remoteIPaddress, remotePort );
        
        
        		//timeout after 3sec of inactivity
        		//socket1.setSoTimeout(3000);
        
        		// open reader to receive messages from server
        		BufferedReader inFromServer = new BufferedReader(new InputStreamReader( socket1.getInputStream()));
        		System.out.println("Server contacted OK ");
        
        
        		// loop reading messages from server
        		while(true)                
            	{
            	
            	String line = inFromServer.readLine();
            	System.out.println("From server " + line);
            	}  
              
         	}
        
        		catch(UnknownHostException e){
            	System.err.println("Don't know about host ....");    
            	}       
        
        	//predefined message is returned if server cannot be contacted
        	catch(ConnectException e){
            System.err.println("Unreachable node!, failure in connecting to server"); 
            }    
        
    	catch (IOException e) {System.err.println("TCP client error " +  e); }
    
    	//if server suddenly shutsdown for instance
    
         }
    }
It mustnt be with the GUI. coding that works will be very helpful indeed.

many thanks for responses in advance pls im stuck...

Last edited by fresher; Jan 15th, 2007 at 9:49 AM.
fresher is offline   Reply With Quote
Old Jan 15th, 2007, 10:19 AM   #2
BinarySurfer
Programmer
 
BinarySurfer's Avatar
 
Join Date: Dec 2006
Posts: 50
Rep Power: 2 BinarySurfer is on a distinguished road
So, the client reports its computer's traffic to the main utility, right?
BinarySurfer is offline   Reply With Quote
Old Jan 15th, 2007, 10:29 AM   #3
fresher
Newbie
 
Join Date: Dec 2006
Posts: 13
Rep Power: 0 fresher is on a distinguished road
Quote:
Originally Posted by BinarySurfer View Post
So, the client reports its computer's traffic to the main utility, right?
Yes it reports its traffic, name, Ip and working status (in green). thanks
I just want something that works pls.
fresher is offline   Reply With Quote
Old Jan 15th, 2007, 11:04 AM   #4
Arevos
Programming Guru
 
Arevos's Avatar
 
Join Date: Aug 2005
Location: England
Posts: 1,499
Rep Power: 5 Arevos is on a distinguished road
What do you mean by its "traffic"? Also, just to be clear, I take it this is homework or coursework of some kind?
Arevos is offline   Reply With Quote
Old Jan 15th, 2007, 11:21 AM   #5
fresher
Newbie
 
Join Date: Dec 2006
Posts: 13
Rep Power: 0 fresher is on a distinguished road
Quote:
Originally Posted by Arevos View Post
What do you mean by its "traffic"? Also, just to be clear, I take it this is homework or coursework of some kind?
Its not traffic per se perhaps i didnt get what he meant by 'traffic'. it is a group project made up of java newbies.
fresher is offline   Reply With Quote
Old Jan 15th, 2007, 12:23 PM   #6
Arevos
Programming Guru
 
Arevos's Avatar
 
Join Date: Aug 2005
Location: England
Posts: 1,499
Rep Power: 5 Arevos is on a distinguished road
Quote:
Originally Posted by fresher View Post
Its not traffic per se perhaps i didnt get what he meant by 'traffic'. it is a group project made up of java newbies.
Okay, so it just reports on IP, hostname and whether the clients are operational? Do the clients autodetect the server (via some sort of network broadcast) or do you have to explicitly configure each client with the server IP?
Arevos is offline   Reply With Quote
Old Jan 15th, 2007, 12:37 PM   #7
fresher
Newbie
 
Join Date: Dec 2006
Posts: 13
Rep Power: 0 fresher is on a distinguished road
Quote:
Originally Posted by Arevos View Post
Okay, so it just reports on IP, hostname and whether the clients are operational? Do the clients autodetect the server (via some sort of network broadcast) or do you have to explicitly configure each client with the server IP?
Yes it just reports on IP, working condition, etc.....only on request by the network engineer from the main utility. In other words connection is by "handshake" - only one client can connect at a time (no threading is required in order to accept multiple connections). Yes you configure each client with the server ip but i guess you should be able to change the ip depending on the network it runs on. thanks for your posts thus far. Im happy to clarify more please. I'd be glad with something that works simply; not fossy.


PS. The network eng specifies which machine to connect to since all machine will be listening for connection.
fresher is offline   Reply With Quote
Old Jan 16th, 2007, 8:58 AM   #8
Infinite Recursion
Programming Guru
 
Infinite Recursion's Avatar
 
Join Date: Jul 2004
Location: United States
Posts: 3,467
Rep Power: 8 Infinite Recursion is on a distinguished road
Send a message via MSN to Infinite Recursion Send a message via Yahoo to Infinite Recursion
I wouldn't hardcode the IP addresses in if I were you...
__________________
http://jasonpowers.net

"There are a thousand hacking at the branches of evil to one who is striking at the root."
Infinite Recursion is offline   Reply With Quote
Reply

Bookmarks

« Previous Thread in Forum | Next Thread in Forum »

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Language display in program Prm753 C++ 3 May 30th, 2006 5:45 PM
Creating a program to test a program sixstringartist C 8 Jan 21st, 2006 1:15 PM
problem with network program Brent C++ 57 Aug 31st, 2005 12:57 PM
auto run hidden program. kuroko C++ 9 Aug 6th, 2005 10:05 AM
airport Log program using 3D linked List : problem reading from file gemini_shooter C++ 0 Mar 2nd, 2005 4:12 PM




DaniWeb IT Discussion Community
All times are GMT -5. The time now is 4:53 AM.

Powered by vBulletin® Version 3.7.0, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Copyright ©2007 DaniWeb® LLC