Beefy Boxes and Bandwidth Generously Provided by pair Networks
Do you know where your variables are?
 
PerlMonks  

Networking in perl

by KVB (Novice)
on Jan 14, 2011 at 10:05 UTC ( [id://882318]=perlquestion: print w/replies, xml ) Need Help??

KVB has asked for the wisdom of the Perl Monks concerning the following question:

Hi, I want to write a script in perl for client(which has no internet connection).When a user opens a browser and enters url,my script should be able to get the IP request packet through raw socket and add mac address , change the destination address ,forward it to the known server .And it should be able to get the response from the server through some other socket and forward it the respective browser. I don't know how get this IP packets, plz help me anyone.

Replies are listed 'Best First'.
Re: Networking in perl
by chrestomanci (Priest) on Jan 14, 2011 at 10:13 UTC

    You say that your client does not have an internet connection.

    From the specification of the script you are trying to write, it sounds like they do, and you need to provide some sort of proxy to access it.

    If that is the case, then I think you would be better served by looking at existing proxy software such as squid, and seeing how you can configure it to suit your needs.

    In any case, you don't want to do network programming at the packet level if you don't have to. To operate a web proxy, even your rather strange one, you should be working at the TCP/IP stream level, but before you dive in, I think you need to step back and understand a bit better what your client needs.

      Hi, Thanks for replying. I am very much new to networking & perl. Here my client and server communicate through different protocol..for e.g GTP . So i need IP packet and wrap it into gtp header and send.And I am not bother about how my server acts on it.I just want to send that packet to the server.help me

        This is not realy a perl question.

        An internet search for GTP turns up GPRS_Tunnelling_Protocol Is that what you mean?

        If you are looking to tunnel internet packets through another networking protocol, then you need to setup a VPN. If you want to limit the traffic that can go through that VPN, then you need to put a firewall, and possibly a proxy in front of it. So to limit the websites that your users can access, you could setup the firewall so that it will only accept web connections from the proxy, and setup the proxy so that only a white list of sites are allowed.

Re: Networking in perl
by Anonyrnous Monk (Hermit) on Jan 14, 2011 at 10:14 UTC

    Before reinventing the wheel, you might want to evaluate existing web proxies (e.g. squid) as to whether they might help in your case...

    Of course, you can write your own proxy in Perl (preferably based on HTTP::Proxy), but I wouldn't do it at the IP level. Just provide a TCP socket that the browser can connect to the normal way.

Re: Networking in perl
by rowdog (Curate) on Jan 17, 2011 at 13:04 UTC

    If you really want to mangle packets, you'll need something like Net::Pcap. Don't forget to change the source address too or you'll never get a reply.

    My crystal ball tells me that you what you really want is NAT. Of course NAT isn't really about programming Perl so you might need to check out the documentation and/or forums for your OS.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: perlquestion [id://882318]
Approved by Corion
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others making s'mores by the fire in the courtyard of the Monastery: (7)
As of 2024-04-19 10:01 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found