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

I am not really experienced in network programming and my job asked me to make a perl script that uses GET to download webpages and calculate how long it takes... That is easy, but the script must also simulate that the requests come from different IP-addresses. Does anybody know how to handle this? Please help me, Thanks HeffaK

Replies are listed 'Best First'.
Re: Can I simulate IP-addresses?
by traveler (Parson) on Apr 13, 2001 at 00:50 UTC
    This kind of depends on what you mean by come from different IP-addresses. If you mean different addresses in your company, that's one thing and may be possible depending on your network configuration. If you mean different locations on the Internet so you can test the response time from there, that's not so easy ;-).

    What is the goal of the simulation?

    --traveler

      I don't know if it is possible but I want to make one computer look like it is really several comuters. First I'll check how long it takes for user1 with IP-address so and so, then I'll check how long it takes for user2 which have IP address so and so. But I only want to use one computer so I need to make the requests pretend they are from different users...Does that make sense?
        Are you sure you're solving the right problem?

        If you're running timing tests, in all probability what someone wants is to gather statistics on how long it takes to load the pages from different computers. But they might not understand enough about networking to further qualify their request to mean computer located in different places on the internet, reaching the website through different paths.

        Gathering statistics from one computer that's pretending to be several is rather like asking the same person to take a survey three times.

        You may need to have a talk with whoever is asking you to run this experiment, to explain to them a bit about how networks work, and to help them clarify what they're trying to measure.

        To do this correctly, the host doing the queries needs to have multiple IP addresses. I don't know how this is done in Windows, but under Unix it can be accomplished using IP aliasing or whatever synonym is appropriate for your OS variant. Contact your system or network administrator for help with this.

        Once the machine is configured with multiple IP addresses per your needs, make use of the bind function before you make your outbound connect (this can be done with IO::Socket just as easily using the LocalAddr variable). This ensures the outbound connection comes from the IP address (and port, if you want that level of control) that you want.

Re: Can I simulate IP-addresses?
by reyjrar (Hermit) on Apr 13, 2001 at 03:18 UTC
    You could also possibly look at connecting to route servers located around the world and grabbing down the response times from there. You could use Time::HiRes for fun.. Take a look at these two programs that me and my co-worker wrote for some inspiration and also see http://traceroute.org for a list of route servers. You could basically combine these two programs into one and get a decent idea of what's going. You'll need to account for connectivity between you and the route server cuz all timing will be dnoe locally.

    Issue a list of commands on a route server: route-server.pl
    Time HTTP requests in a ping like manner: http_ping


    lemme know if you need some examples, email would be best..

    -brad..
Re: Can I simulate IP-addresses?
by idnopheq (Chaplain) on Apr 13, 2001 at 01:18 UTC
    Social engineering (in the good way). Invite customers, clients, partners, suppliers, etc. to run your perl script from their various locations and upload the results somewhere central. You'll need a broad sample over a lengthy period of time for better stats.

    To do it from a single Internet host is costly, unless you happen to already own a lot of different address blocks or have multiple egress points to the Internet throughout the world.

    This is more of a network routing issue than a perl issue IMHO. Never hurts to ask, though.

    HTH
    --
    idnopheq
    Apply yourself to new problems without preparation, develop confidence in your ability to to meet situations as they arrise.

Re: Can I simulate IP-addresses?
by Tuna (Friar) on Apr 13, 2001 at 00:58 UTC
A reply falls below the community's threshold of quality. You may see it by logging in.