Вопрос

For testing reasons, I'm trying to generate a http packet with different source IP address and post it to a destination.

I'm going to use sharppcap or packetdotnet.

Found good samples here:

http://www.tamirgal.com/blog/post/SendTcpSynExamplecs.aspx

and here:

http://pcapdotnet.codeplex.com/wikipage?title=Pcap.Net%20Tutorial%20-%20Sending%20Packets

But I'm a noob in this area and I need help:

  1. What should I do before sending http packet? do a tcp handshake or what? can you post any samples about calling a url using post verb by sending http packet?

  2. For doing some stress tests I need to change the source ip address and destination response is not important to me. So changing the
    source address is enough? what about checksum and other properties?

Any sample or link would be helpful.

Это было полезно?

Решение 2

You'll have to establish a tcp connection with the server before you'll be able to send an http packet that will be received. Its a bit of work to build up from the ip level what you might need to do this kind of testing.

There are tools that will generate http sessions for you though. They can usually be configured to open a particular number of simultaneous http sessions as well, if this is what you are trying to do when you mention changing the source ip. Something like http://code.google.com/p/httperf/ or http://httpd.apache.org/docs/2.2/programs/ab.html might do it.

Другие советы

Doing as you describe is impossible, as Chris Morgan pointed out in his answer. Reasons are as follows:

  • HTTP protocol (for practical purposes - always) works over TCP connection
  • TCP connection must perform a handshake (3-packet mutual exchange - client->server->client->server) before actual data can start flowing
  • Due to the handshake, substituting the HTTP source IP address is impossible - as to establish a connection, you need to provide your valid IP (or you won't receive the second packet and will not be able to send the third required packet)
  • Source IP address will be taken from the established connection properties, so there's no way to forge it after the connection is established as well.

There's a nubmer of special cases in which it is partially possible (X-Forwarded-For and similar headers in HTTP request), but this must be researched on per-application basis.

So, in short: what you're requesting is impossible (except some very special cases), you can read more on TCP conneciton establishing on this Wiki article

Лицензировано под: CC-BY-SA с атрибуция
Не связан с StackOverflow
scroll top