Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / Languages / C# / July 2007

Tip: Looking for answers? Try searching our database.

Multiple IPs

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Fred - 19 Jul 2007 06:17 GMT
Our server has 8 IPs with 121.232.21.1 as default (example).
I wrote a windows service that downloads podcasts (mp3s) off the net.
However every time this service runs it clogs down the entire server, even
though its not that bandwidth intensive. (30kps on a 100Mbps line)
Process resource at 20% max.
I would like to know if anyone knows what is causing this problem. What
command in c# can I use to assign the service a different IP to download ie
121.232.21.5 maybe that would help with the problem.

Fred
Nicholas Paldino [.NET/C# MVP] - 19 Jul 2007 16:09 GMT
Fred,

   It sounds strange that you would have eight NIC cards with the same IP
address.  That's certainly going to cause some problems.  Why do you have so
many?  Adding extra NIC cards is not going to give you any edge in
downloading from the web, as the bottleneck is the actual network pipe.

   As for changing the service to use a different IP to download (and it
sounds like you aren't downloading, but rather, serving up the mp3s), that's
dependent on the service itself.  It might not offer a command line way to
change whatever IP address it's using.

Signature

         - Nicholas Paldino [.NET/C# MVP]
         - mvp@spam.guard.caspershouse.com

> Our server has 8 IPs with 121.232.21.1 as default (example).
> I wrote a windows service that downloads podcasts (mp3s) off the net.
[quoted text clipped - 6 lines]
>
> Fred
Fred - 19 Jul 2007 21:38 GMT
sorry if i wasn't clear enough in the first post. the server has only 1 NIC
but has 8 ip addresses assigned to it.
actually it's not the service that uses the default ip it's everything. if i
use ie and go to a web page it uses 121.232.21.1.
How can I make my app aware of the multiple IPs and specify which one to
use?

>    As for changing the service to use a different IP to download (and it
> sounds like you aren't downloading, but rather, serving up the mp3s),
> that's dependent on the service itself.  It might not offer a command line
> way to change whatever IP address it's using.

I wrote the service myself so I have access to the source code. just need to
know the correct c# statement to use.

Fred

> Fred,
>
>    It sounds strange that you would have eight NIC cards with the same IP
> address.  That's certainly going to cause some problems.  Why do you have
> so many?  Adding extra NIC cards is not going to give you any edge in
> downloading from the web, as the bottleneck is the actual network pipe.

>> Our server has 8 IPs with 121.232.21.1 as default (example).
>> I wrote a windows service that downloads podcasts (mp3s) off the net.
[quoted text clipped - 6 lines]
>>
>> Fred
Peter Duniho - 19 Jul 2007 18:06 GMT
> Our server has 8 IPs with 121.232.21.1 as default (example).
> I wrote a windows service that downloads podcasts (mp3s) off the net.
> However every time this service runs it clogs down the entire server,  
> even though its not that bandwidth intensive. (30kps on a 100Mbps line)

Why do you think that the download is only 30kbps?  Did you implement code  
specifically to throttle your downloads?

If so, you should post the code that you think is not doing what you want  
it to do.  It's hard to answer the question without the code.

Of course, if you really have a 100Mbps Internet connection, one would not  
expect a _single_ file download to saturate your bandwidth, since the  
other end (the hosting server sending you the data) is highly unlikely to  
be able to serve up the data that fast.  But a) a 100Mbps Internet  
connection is extremely unusual (so it seems unlikely that's what you  
really have) and b) if you were to try to download many files at once,  
that could in fact saturate even a 100Mbps connection.

Pete
Fred - 19 Jul 2007 22:58 GMT
no, thats the speed i get from the server that hosts the mp3s

the code uses TcpClient
TcpClient tcpClientC = new TcpClient ();

How can I tell it to use an ip of my choice?
Peter Duniho - 20 Jul 2007 01:23 GMT
I wish people would quote when they reply.

> no, thats the speed i get from the server that hosts the mp3s

What's the speed you get from the server that hosts the mp3s?  The 30kpbs?

If the server hosting the mp3s is only passing you the data at 30kpbs,  
you're not going to download the data any faster than that.  I certainly  
don't see how your own network could get saturated under those conditions,  
unless your Internet connection is only a 30kbps connection (56K modem on  
a noisy phone line).

> the code uses TcpClient TcpClient tcpClientC = new TcpClient ();
>
> How can I tell it to use an ip of my choice?

I also don't understand what you mean when you say that you've got a  
single NIC, but 8 IP addresses.  I've never heard of such a thing.  How do  
you get your one NIC configured for 8 different IP addresses?

Beyond that, why do you think that using different IP addresses is going  
to help, if it's your network adapter that's saturated, even if it _is_  
possible to have multiple IP addresses assigned to a single network  
adapter?

If you have multiple network adapters, you can use the IP address assigned  
to each adapter as the address to which a Socket or Tcp/UdpClient is  
bound, which will affect how and whether inbound data gets sent to the  
Socket or ...Client.  However, you can't control how your outbound data is  
sent, including connection requests.  The network driver looks at the  
destination address and selects what it thinks is an appropriate route.  
(There are, of course, really low level ways to affect the routing, but  
this isn't accessible by .NET I don't think).

Pete
Mythran - 20 Jul 2007 16:32 GMT
>> the code uses TcpClient TcpClient tcpClientC = new TcpClient ();
>>
>> How can I tell it to use an ip of my choice?

> I also don't understand what you mean when you say that you've got a
> single NIC, but 8 IP addresses.  I've never heard of such a thing.  How do
> you get your one NIC configured for 8 different IP addresses?

Actually, this is quite common....my department has multiple ip addresses on
single NICS as well.  :)

Mythran
Peter Duniho - 20 Jul 2007 17:17 GMT
> Actually, this is quite common....my department has multiple ip  
> addresses on single NICS as well.  :)

Okay, so how do you do that?

I'm got a computer with a single NIC.  How do I assign multiple IP  
addresses to it?

In any case, the real point here is that it's the hardware that determines  
the bandwidth, not the number of logical addresses assigned to the  
hardware.  Using a different IP address on the same hardware isn't going  
to help throughput.

Pete
Ged - 20 Jul 2007 17:33 GMT
Getting a bit OT but, to get multiple IP's on a box, you need to add
multiple network cards.

>> Actually, this is quite common....my department has multiple ip
>> addresses on single NICS as well.  :)
[quoted text clipped - 10 lines]
>
> Pete
Peter Duniho - 20 Jul 2007 17:46 GMT
> Getting a bit OT but, to get multiple IP's on a box, you need to add  
> multiple network cards.

Two people have already claimed that's not true.

I am curious to hear how they accomplish it.
Mythran - 20 Jul 2007 23:01 GMT
>> Getting a bit OT but, to get multiple IP's on a box, you need to add
>> multiple network cards.
>
> Two people have already claimed that's not true.
>
> I am curious to hear how they accomplish it.

On the machine sending this post, I have 4 IP's associated with the
computer, 1 NIC.  It's not really dependant on the hardware, but the actual
drivers and software the monitors the hardware that respond to specific
events.  In my case, on my development machine, I have VMWare adapters
(virtual) that all use the same network card as everything else, and they
have different IP addresses specified for them.  If you go to another
computer on the network and connect to any of those IP addresses (or ping)
you will get a response from my computer.

Now, I haven't been in school in years nor do I work with customizing
hardware or driver software on a day-to-day basis, so take it with a grain
of salt ... as you already have been doin' anyways :)

Mythran
Peter Duniho - 20 Jul 2007 23:22 GMT
> [...] In my case, on my development machine, I have VMWare adapters  
> (virtual) that all use the same network card as everything else, and  
> they have different IP addresses specified for them.  If you go to  
> another computer on the network and connect to any of those IP addresses  
> (or ping) you will get a response from my computer.

Ah.  Okay.  I guess somehow the virtual machine software has managed to  
map the same MAC address to multiple IP addresses.  I wasn't aware that  
was possible (though since I'm using virtual machine software myself, I  
suppose I could run into that one day myself :) ).

Even so, the OP isn't going to change his bandwidth capacity by using  
different IP addresses.

Thanks,
Pete
Enkidu - 21 Jul 2007 06:36 GMT
>> [...] In my case, on my development machine, I have VMWare adapters
>> (virtual) that all use the same network card as everything else, and
[quoted text clipped - 6 lines]
> was possible (though since I'm using virtual machine software myself, I
> suppose I could run into that one day myself :) ).

It doesn't need to be virtualised to have multiple IP addresses. You can
do it by just configuring the Advanced properties of the NIC.

> Even so, the OP isn't going to change his bandwidth capacity by using
> different IP addresses.

This is true, I think.

Cheers,

Cliff

Signature

Have you ever noticed that if something is advertised as 'amusing' or
'hilarious', it usually isn't?

Peter Duniho - 21 Jul 2007 17:43 GMT
> It doesn't need to be virtualised to have multiple IP addresses. You can  
> do it by just configuring the Advanced properties of the NIC.

Ahhh...so simple.  I've configured so many network adapters in my  
lifetime, and I've never paid any attention to that part of the settings.  
Amazing.  :)

I wonder if this sort of thing is easy to get to on other operating  
systems.

>> Even so, the OP isn't going to change his bandwidth capacity by using  
>> different IP addresses.
>>
> This is true, I think.

It had better be.  If my network card has extra bandwidth that's it's  
reserving instead of letting me use it even when I'm not actually using  
one of the extra IP addresses, that's a network card I want in the trash.

Thanks,
Pete
Enkidu - 22 Jul 2007 02:32 GMT
>> It doesn't need to be virtualised to have multiple IP addresses. You
>> can do it by just configuring the Advanced properties of the NIC.
>
> Ahhh...so simple.  I've configured so many network adapters in my
> lifetime, and I've never paid any attention to that part of the
> settings.  Amazing.  :)

If you'd used IIS with multiple IP addresses, you would have known this,
I think! I guess it come under the heading of "Things you don't know
because you've never had to consider them"!!

> I wonder if this sort of thing is easy to get to on other operating
> systems.

If you are thinking of the L-word or the U-word my experience is that it
is just as easy.

>>> Even so, the OP isn't going to change his bandwidth capacity by using
>>> different IP addresses.
[quoted text clipped - 4 lines]
> reserving instead of letting me use it even when I'm not actually using
> one of the extra IP addresses, that's a network card I want in the trash.

I'm not sure what you are saying here. If your NIC has multiple IP
addresses, you aren't going to get extra bandwidth out of it. If it is a
100Mbps card it is never going to transfer data faster than that,
compression aside.

Cheers,

Cliff

Signature

Have you ever noticed that if something is advertised as 'amusing' or
'hilarious', it usually isn't?

Fred - 22 Jul 2007 09:02 GMT
ok that may be true. but i would still like to know if theres a way to tell
my program to send data from a different ip in c#.

>>> It doesn't need to be virtualised to have multiple IP addresses. You can
>>> do it by just configuring the Advanced properties of the NIC.
[quoted text clipped - 30 lines]
>
> Cliff
Peter Duniho - 22 Jul 2007 18:10 GMT
> ok that may be true. but i would still like to know if theres a way to  
> tell my program to send data from a different ip in c#.

No, not really.  You have very little control over which network card is  
actually used, at least via sockets (in .NET or otherwise).

That said, if you bind to a specific address, your network communications  
will appear to come from a specific address, and replies will be sent to  
that specific address.  And of course, if you only have one network card  
then of course that one card will always be used, even if you have  
multiple IP addresses assigned to the card.

So far, you haven't really described what problem it is exactly you're  
trying to solve.  It's already been pointed out that there's no  
correlation between which IP address you're using and the available  
bandwidth used.  You don't get more bandwidth by using different IP  
addresses.

So if you still want to specify an IP address, you must be trying to solve  
some other problem instead.  If you can explain what problem you're trying  
to solve, you would get better answers.

Pete
Fred - 22 Jul 2007 21:18 GMT
That's the only problem I'm trying to solve. I'm getting new hardware for
the server.
So if .NET doesn't provide direct access to the NIC, then what language
does? For future reference

>> ok that may be true. but i would still like to know if theres a way to
>> tell my program to send data from a different ip in c#.
[quoted text clipped - 19 lines]
>
> Pete
Peter Duniho - 22 Jul 2007 21:29 GMT
> That's the only problem I'm trying to solve.

What is the only problem you're trying to solve?  To what does the word  
"that" refer?  Bandwidth is the only problem you've mentioned so far, and  
it has nothing to do with what IP addresses are used.

> I'm getting new hardware for the server.

If that's relevant, you might want to explain why.  It doesn't seem to be.

> So if .NET doesn't provide direct access to the NIC, then what language  
> does? For future reference

Define "direct access to the NIC".  To me "direct access" means you are  
communicating directly with, and controlling the operation of, the NIC.  
There is no user-level API that allows this.  You would need to write a  
driver for the NIC to do that.

If you mean something else, then you need to be more clear about what you  
mean.

Pete
Peter Duniho - 22 Jul 2007 18:06 GMT
>>>> Even so, the OP isn't going to change his bandwidth capacity by using  
>>>> different IP addresses.
[quoted text clipped - 3 lines]
>>
> I'm not sure what you are saying here.

I'm saying that "It had better be [true]", in reply to the statement "This  
is true".

> If your NIC has multiple IP addresses, you aren't going to get extra  
> bandwidth out of it. If it is a 100Mbps card it is never going to  
> transfer data faster than that, compression aside.

That's my point.  If using multiple IP addresses _did_ make something  
faster, it could only be because the 100Mbps card (for example) wasn't  
already using the full 100Mbps with a single IP address.

I wouldn't want a network card like that.

Pete
Enkidu - 23 Jul 2007 11:27 GMT
>>>>> Even so, the OP isn't going to change his bandwidth capacity by
>>>>> using different IP addresses.
[quoted text clipped - 16 lines]
>
> I wouldn't want a network card like that.

OK, but there's the case where you are connecting from your NIC (using
either one or more IP addresses) to more than one destination. Then I
guess that the bandwidth *used* would be more than the bandwidth to a
single destination (so that you could max out the bandwidth), but it
wouldn't matter if you used the same source IP address. I agree, using
more than one IP address should have no effect.

Cheers,

Cliff

Signature

Have you ever noticed that if something is advertised as 'amusing' or
'hilarious', it usually isn't?

Enkidu - 21 Jul 2007 06:33 GMT
> Getting a bit OT but, to get multiple IP's on a box, you need to add
> multiple network cards.

This is not true. If your NIC is already configured for fixed IP
addresses you can add extra IP address in the Advanced section of the IP
properties for the NIC.

Cheers,

Cliff

Signature

Have you ever noticed that if something is advertised as 'amusing' or
'hilarious', it usually isn't?

Enkidu - 21 Jul 2007 06:32 GMT
>> Actually, this is quite common....my department has multiple ip
>> addresses on single NICS as well.  :)
[quoted text clipped - 3 lines]
> I'm got a computer with a single NIC.  How do I assign multiple IP
> addresses to it?

In the advanced properties of the NIC. If you are using DHCP, you can
add fixed IP addresses.

Cheers,

Cliff

Signature

Have you ever noticed that if something is advertised as 'amusing' or
'hilarious', it usually isn't?

Fred - 21 Jul 2007 08:53 GMT
So can C# access an alternative IP?

>>> Actually, this is quite common....my department has multiple ip
>>> addresses on single NICS as well.  :)
[quoted text clipped - 10 lines]
>
> Cliff
Enkidu - 21 Jul 2007 11:56 GMT
What do you mean, Fred? I've not done much socket programming and I was
talking about how you define extra IP addresses to the OS.

I'm not sure how the IP address that the traffic appears to the receiver
 to be from is determined. It pretty much *has* to be able to be
programmatically determined otherwise you would not be able to set up
IIS (which is a program after all!) to respond to requests to multiple
IP addresses and I know it can do that!

How you do it in C#, I don't know. Probably by binding to one of the IP
addresses somehow. A quick Google came up with a Java example, so I find
it hard to believe that it can't be achieved in C#.

Cheers,

Cliff

> So can C# access an alternative IP?
>
[quoted text clipped - 8 lines]
>> In the advanced properties of the NIC. If you are using DHCP, you can
>> add fixed IP addresses.
Signature


Have you ever noticed that if something is advertised as 'amusing' or
'hilarious', it usually isn't?

Peter Duniho - 21 Jul 2007 17:34 GMT
> [...]
> How you do it in C#, I don't know. Probably by binding to one of the IP  
> addresses somehow. A quick Google came up with a Java example, so I find  
> it hard to believe that it can't be achieved in C#.

As I already did point out in this thread, if you do have multiple IP  
addresses, you can bind the socket to a specific IP address if you only  
want to receive data on a specific IP address.  However, this only affects  
incoming data.  You can't reliably control what IP address is used to send  
data via this method, as the network driver will route the traffic  
according to its own rules.

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.