How to define sender IP address?

M

Marcel Bode

Hello everybody,

is there anybody who knows how to set a sender IP address in C#.
I want to send UDP packets to a server and simulate different computers
with different IP addresses. The server always expects a different IP
address in the UDP packet. So I need a possibility to set the sender
IP.
Hopefully anybody knows something about this topic.

Thanks a lot!
Greeting Marcel
 
I

Ignacio Machin \( .NET/ C# MVP \)

Hi,


Marcel Bode said:
Hello everybody,

is there anybody who knows how to set a sender IP address in C#.
I want to send UDP packets to a server and simulate different computers
with different IP addresses. The server always expects a different IP
address in the UDP packet. So I need a possibility to set the sender
IP.
Hopefully anybody knows something about this topic.


You do realise thhat you will not get any response from the server right?

The response packages will be send to the machine with that IP address.

A better suggestion would be if you assign differents IPs to your local
computer and then select from these IPs when you create your local
IPEndPoint.
 
M

Marcel Bode

Hi,

I think your suggestion, is the correct way but I am trying to simulate
5000 different computer with 5000 different IP addresses.....hmmm I
think it's not easy

But thanks a lot!

Marcel
 
I

Ignacio Machin \( .NET/ C# MVP \)

Hi,


Marcel Bode said:
Hi,

I think your suggestion, is the correct way but I am trying to simulate
5000 different computer with 5000 different IP addresses.....hmmm I
think it's not easy

What is what you want to do in the first place?

Why you need 5K differents IPs?
 
M

Marcel Bode

Hi,

okay it's a stress test! You know, I am trying to test a application on
a server. The server expects a logon from different devices or in this
case only one computer. Every device must have a unique IP address. To
see how the system handles maybe a logon from 5000 devices at the same
time, I want to programm a simulation application.
So all the logon information from the device must have different IP
addresses.
Hopefully now you know the main background.

bye Marcel
 
I

Ignacio Machin \( .NET/ C# MVP \)

Hi,


Marcel Bode said:
Hi,

okay it's a stress test! You know, I am trying to test a application on
a server. The server expects a logon from different devices or in this
case only one computer. Every device must have a unique IP address. To
see how the system handles maybe a logon from 5000 devices at the same
time, I want to programm a simulation application.
So all the logon information from the device must have different IP
addresses.
Hopefully now you know the main background.

In this case I would generate a fake ip in the server side, each time a new
session start you , instead of getting the source IP (most probably using
Page.UserHostIP ) you generate a new IP:

// string sourceIP = Page.UserHostIP ;
string sourceIP = GenerateRandomIP();

and then you can do your stress test from one computer only
 
W

William Stacey [MVP]

Change the server to temp remove the logic and checks for dup IPs, then you
can stress. After, uncomment the logic and test it again with fewer source
IPs.

--
William Stacey [MVP]

| Hi,
|
| okay it's a stress test! You know, I am trying to test a application on
| a server. The server expects a logon from different devices or in this
| case only one computer. Every device must have a unique IP address. To
| see how the system handles maybe a logon from 5000 devices at the same
| time, I want to programm a simulation application.
| So all the logon information from the device must have different IP
| addresses.
| Hopefully now you know the main background.
|
| bye Marcel
|
 
V

Vadym Stetsyak

Hello, Ignacio!

IMN> In this case I would generate a fake ip in the server side, each time
IMN> a new session start you , instead of getting the source IP (most
IMN> probably using Page.UserHostIP ) you generate a new IP:

IMN> // string sourceIP = Page.UserHostIP ;
IMN> string sourceIP = GenerateRandomIP();

IMN> and then you can do your stress test from one computer only

IMO OP didn't state that this is web app, so we can have no Page class.

--
Regards, Vadym Stetsyak
www: http://vadmyst.blogspot.com
 
V

Vadym Stetsyak

Hello, Marcel!

MB> okay it's a stress test! You know, I am trying to test a application on
MB> a server. The server expects a logon from different devices or in this
MB> case only one computer. Every device must have a unique IP address. To
MB> see how the system handles maybe a logon from 5000 devices at the same
MB> time, I want to programm a simulation application.
MB> So all the logon information from the device must have different IP
MB> addresses.
MB> Hopefully now you know the main background.

What kind of application it is? Is it hosted on IIS. Does the application determine IPs duplication?

--
Regards, Vadym Stetsyak
www: http://vadmyst.blogspot.com
 
I

Ignacio Machin \( .NET/ C# MVP \)

Hi,

Vadym Stetsyak said:
Hello, Ignacio!

IMN> In this case I would generate a fake ip in the server side, each time
IMN> a new session start you , instead of getting the source IP (most
IMN> probably using Page.UserHostIP ) you generate a new IP:

IMN> // string sourceIP = Page.UserHostIP ;
IMN> string sourceIP = GenerateRandomIP();

IMN> and then you can do your stress test from one computer only

IMO OP didn't state that this is web app, so we can have no Page class.

You are right, my mistake, but the same apply to any platform , just change
the line from where you are getting the remote IP and use a generated IP.
 
M

Marcel Bode

Hi Vadym,

it's no web server or something like that. The server side is a Java
application with connecting to a database. It is effectively the
central for all existing devices. When a device wants to join the
system it must logon and then it can use the services and the central
application you can observe the devices. I don't want to change the
server side, because maybe then I also change the results of the
simulation. And I don't have access to the source code of the central
side. I can only change the client/device side. That's it!

Now I am trying some hacking tools. They are very powerful and when I
install such a tool on the server side, it maybe can filter the
outgoing and incoming udp packets and change the IP. Maybe it's quite
easier then searching for a solution in C#.

But hey, I thank all of you! If you still have some suggestions, let me
know!

Bye Marcel
 
I

Ignacio Machin \( .NET/ C# MVP \)

Hi,

And why is so important the IP?

Are you doing any validation/auth based on that?
 
M

Marcel Bode

hi,

the different IP makes sure that the logon information is coming from
different devices.
So yes, it's a kind of validation!

bye
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top