6 Replies - 1186 Views - Last Post: 15 April 2011 - 07:46 AM Rate Topic: -----

#1 sarah waleed   User is offline

  • D.I.C Head

Reputation: 0
  • View blog
  • Posts: 124
  • Joined: 12-January 11

confuse in how to began my program

Posted 07 April 2011 - 01:56 PM

hello,
now to believe that i search to what i want for more that 4 months i send the things that i confused about it and please i want a clear arrengement or new code that let me know what is the right i feel every day that i go to the wrong way more and more
when recently i read about JPcap i thought that all that i write may be wrong but also i have i problem in writing a complete code by using the JPcap
so please i write that code below and i know that it was not for compilation but i want u to see that what i confused in and that i am realy work hard
and i put a comment in the code and between them about the problems that i have


\\ this is the began of my server and any server that i have no problem with it, ok
public static void main(String[] args) throws IOException {
ServerSocket clientSocket = null;
boolean listening = true;
bindAddr = InetAddress.getByName("10.0.0.1");
try {
clientSocket = new ServerSocket(80, 1000, bindAddr);
System.out.println("-started listening to port 80.");
} catch (IOException e) {
System.err.println("Could not listen on port: 80.");
System.exit(1);
}
int port = 3804;
int portP = port;
while (listening) {



now my problem is with what below, is the place of the filtering method is while listening and before accepting the socket? how can i read the packets and check it (the checking procedure is that, i read the packet and extract the TTL value from it, then compare that value with a table that i save before if its equels i pass that packet else i drop that packet)

\*my problem began here, is the below right if i want to filter the incoming packets? how i check it before accept the unwanted packets*/
 try {
        in = new BufferedReader(new FileReader("one-line.txt"));
\* i also want to ask about the above, is that mean that the containt of the ("one-line.txt") is an information that the server will send to the client or an information that the server save about the client? */
	
  } catch (FileNotFoundException e){}



ok now i want to ask if i write the above ( in = new BufferedReader(new FileReader("one-line.txt")); )
did i need to write the below(byte[] buf = new byte[256]; ) because i think that is for saving the client info., doesn't it?

byte[] buf = new byte[256];
Packet packet = new Packet(buf, buf.length);
socket.receive(packet);\\was that save the packet as it is, with its header info.?



now i want to extract the TTL value how can i do that? was the below code right to do it?

TTL=byte[8];
\\ then i continue the procedure by comparing with the table



i think that i must use socket.send(packet); at the client is that right? to save the entire packet with its header and save it in the byte[] as one packet a time, is that right?

after all what above and if the packet was wanted i accept it by accepting the socket?or what?

new PublicServerThread(clientSocket.accept(), portP, bindAddr).start();



sooo thanks to any help
so thanks for the time u take to read my post
with regards

This post has been edited by sarah waleed: 08 April 2011 - 08:10 AM


Is This A Good Question/Topic? 1
  • +

Replies To: confuse in how to began my program

#2 Dogstopper   User is offline

  • The Ninjaducky
  • member icon

Reputation: 2975
  • View blog
  • Posts: 11,224
  • Joined: 15-July 08

Re: confuse in how to began my program

Posted 07 April 2011 - 03:31 PM

You said you put the question in the comment - but your indenting is so bad that I cannot clearly decipher anything in that code. Can you format it correctly and maybe use blank lines to separate ideas in your code. That way, all can read it. Thanks!
Was This Post Helpful? 0
  • +
  • -

#3 darek9576   User is offline

  • D.I.C Lover

Reputation: 204
  • View blog
  • Posts: 1,747
  • Joined: 13-March 10

Re: confuse in how to began my program

Posted 07 April 2011 - 03:33 PM

Comments go like this:

// or /* */
Was This Post Helpful? 0
  • +
  • -

#4 sarah waleed   User is offline

  • D.I.C Head

Reputation: 0
  • View blog
  • Posts: 124
  • Joined: 12-January 11

Re: confuse in how to began my program

Posted 08 April 2011 - 02:49 PM

hi
i did not know if u know that i edit the post is it clear now
thanks!
with regards :)
Was This Post Helpful? -2
  • +
  • -

#5 sarah waleed   User is offline

  • D.I.C Head

Reputation: 0
  • View blog
  • Posts: 124
  • Joined: 12-January 11

Re: confuse in how to began my program

Posted 10 April 2011 - 12:01 PM

hello
please i want some one who know about the network to tell me is there is a way to extract the packet containt?
is it the jpcap?
or some think else? so what is it?
yesterday i read some think that i think it is not full true,
i read that i can not receive the packet header info. when using TCP and UDP
is that right?
thanks for any help

This post has been edited by sarah waleed: 10 April 2011 - 12:03 PM

Was This Post Helpful? 1
  • +
  • -

#6 pbl   User is offline

  • There is nothing you can't do with a JTable
  • member icon

Reputation: 8381
  • View blog
  • Posts: 31,956
  • Joined: 06-March 08

Re: confuse in how to began my program

Posted 10 April 2011 - 09:28 PM

I guess the jpcap forum is more appropriate for that question
Not everybody here is familiar with that package

http://groups.google.com/group/jpcap

There are also tutorials and examples there

http://netresearch.i...ujii/Jpcap/doc/
Was This Post Helpful? 1
  • +
  • -

#7 sarah waleed   User is offline

  • D.I.C Head

Reputation: 0
  • View blog
  • Posts: 124
  • Joined: 12-January 11

Re: confuse in how to began my program

Posted 15 April 2011 - 07:46 AM

hello everybody,
i hope that u all fine and wish to u a great day

for all who want to know about jpcap
that was the summary:
Jpcap can be used to sniff packets that go by, but it's not really
capable of intercepting packets or adding ‎security directly to the TCP/IP
stack, and when Jpcap receives a packet, it's just a copy.
The original packet still goes to the destination IP address. ‎

i hope that this was helpful :)
with best wishes and regards
Was This Post Helpful? 3
  • +
  • -

Page 1 of 1