[j-sim-users] Use of INET structure
onkar1 at umbc.edu
Thu Mar 30 13:36:56 CST 2006
I want to write a Server application thar runs on a specific port (simulated
port) and uses the underlying INET structure. It should be able to do the
1. Keep listening to incoming requests on a certain port.
2. On receiving a request, it should be able to send a reply back to the
client (and not just write something to its own console, as is demonstrated
for the initial few examples using PktDispatcher). Hence it will need to
know the client's IP address to send a response back.
3. The network layer of this server should be able to capture packets that
are coming in as requests or going out as response and do some packet
filtering (drop the packets) or NATing (change the apparent source/
I tried to do this in 2 ways for DNSService.
a. I wrote a DNSServer Class extending the Component class. This
class implemented the "process(Object data_, Port port_)." I connected its
downport to the upport of the PktDispatcher class through TCL commands.
However when this method is called, the PktDispatcher has already detatched
the Packet Header and sends only the data part of the incoming packet to the
DNSServer class. Now the server has no way of knowing the client's IP
address (correct me if it works differently). So how will it send the
response back to the client? Do I need to tweak the PktDispatcher class to
send the packet header to upper layer as well?
b. I tried to implement the service the way it's normally
implemented, using Sockets. For this I wrote the DNSServer class by
extending the drcl.inet.socket.SocketApplication class. Now the job of
writing the request-response mechanism is quite simple as I just have to
read/write from the socket. However this class seems to use actual
java.net.Socket class. I got the impression that it doesn't use
PktDispatcher as its underlying layer. So i might lose my packet capturing
ability if I take this approach. Is there something I am missing? Is there a
way I can fit in the PacketFilter with this approach?
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the j-sim-users