7

I'm new here...been digging around for some help but figured I would join and ask for some guidance.

I'm looking to create an app that can create multiple "fake" devices. They need an IP Address and I'm guessing able to respond to ping. Being able to respond to WMI would also be nice. Kinda like a simulator. I'd like to create up to 50,000 devices but even starting with 1 would help.

What is needed for such an app? TCP Client/Listener? I've never done something like this before so please be gentle :)

user1786176
  • 139
  • 3
  • 7
  • Im curious how many network cards windows can support. Please tell us what happened with CPU and RAM usage on your machine after adding a lot of network adapters. – Kamil Oct 30 '12 at 17:05
  • You can have multiple IP addresses on a single network card. Is that what you're asking how to do? – Gabe Oct 30 '12 at 17:13

3 Answers3

3

You may install Virtual Network Adapter's (driver is included with Windows OS), but i have never used this. Driver for Virtual Network Adapter is here: %WINDIR%\Inf\Netloop.inf

You may use Command line tool called DevCon to add devices by script, like this:

devcon -r install %WINDIR% \Inf\Netloop.inf *MSLOOP

Installation unfortunatelly takes few seconds (on my Core Duo 2.0 laptop).

If you need to configure a lot of network cards you may use command line netsh.

Examples:

netsh in ip set address "Local Area Connection" static 10.0.0.1 255.0.0.0 10.0.0.1 1
netsh in ip add address "Local Area Connection" 10.0.0.2 255.0.0.0
netsh in ip set address "Local Area Connection 2" 10.0.0.3 255.0.0.0
netsh in ip set address "Local Area Connection 3" 10.0.0.4 255.0.0.0
netsh in ip set dns "Local Area Connection" static 10.0.0.250
netsh in ip set wins "Local Area Connection" static 10.0.0.250

You may dump/export current network configuration to a file (to see how current config looks):

netsh interface dump > file.txt

More netsh examples

Edit: removed informations not useful in this case.

Kamil
  • 13,363
  • 24
  • 88
  • 183
  • The software I'm trying to "trick" would just see the 1 device with multiple IP Addresses. Not really sure how to mimic multiple IP Addresses from 1 device. – user1786176 Oct 30 '12 at 16:24
  • I added information how to effectively add multiple addresses, but 50000 is a scary number and you may have problems. – Kamil Oct 30 '12 at 16:27
  • Thank you for the update but this will still be seen as 1 device (as seen from the software under test). – user1786176 Oct 30 '12 at 16:31
  • I added information about virtual network device and command line tool that helps with adding many virtual device instances. – Kamil Oct 30 '12 at 16:32
  • @Kamil...thanks for the help. I'll look at the Virtual Network Adapters. – user1786176 Oct 30 '12 at 16:37
  • I was curious and i installed few Virtual Network Adapters using that DevCon. They work like normal network adapters. My Apache server is responding, card responds for ping, i connected MMC to "another computer" using virtual card IP address. WMI should work too. Have fun. – Kamil Oct 30 '12 at 16:50
1

If I'm understanding you correctly, unfortunately this will not be easy as you need to virtualize network adapters to do the job you want. an IP address is bound to a nic (physical or logical), not something that can be specified in higher layer code. VMWare Workstation does include a plugin for Visual studio, so perhaps you can use it to generate many virtual nics and assign them ip's programatically, but otherwise you need to write virtual network card drivers (probably in a non-.net language) to do it, if you don't use an existing virtualization tech. you can stack many IP addresses on a nic, but the computer communicating with it will know they are all the same network entity. if thats fine with you, then just add all the IPs you want to the card you have.

on to the second part of your query, since you want the IPs to be able to recieve and send data, their addresses will have to be routable, so you can't just pick any old IP address. if you are fine being behind a NAT wall, you could use 10.x.y.z to address them, but on the outside of the nat they would all appear to be using the same public IP to the outside world. in order to expose 50k publicly routable IP addresses, you would first have to register and buy them.

lastly you can't use TCPClient to do Echo/Ping, since they use the ICMP protocol, but instead use the System.Net and System.Net.NetworkInformation namespace. Here is some VB code to send a ping just to give you the flavor of it:

Imports System
Imports System.Net
Imports System.Net.NetworkInformation


Public Class Pinger

    <System.Diagnostics.DebuggerNonUserCode()> _
        Public Sub New()
        MyBase.New()

        'This call is required by the Component Designer.
        InitializeComponent()

    End Sub


    Public Shared Function CanHostBePinged(ByVal IPAddr_DNS_OR_Host_Name As String) As Boolean
        Dim p As New Ping
        Dim po As New PingOptions

        po.Ttl = 256
        po.DontFragment = False

        Dim stringOut As String = "ABCDEFGHIJKLMNOPQRSTUVWXYZABCDE"
        Dim streamOut As Byte() = System.Text.Encoding.ASCII.GetBytes(stringOut)

        Try
            Dim reply As PingReply = p.Send(IPAddr_DNS_OR_Host_Name, 30, streamOut)
            If reply.Status = IPStatus.Success Then
                Return True
            Else
                Return False
            End If
        Catch ex As Exception
            Return False
        End Try

    End Function


End Class
Frank Thomas
  • 2,434
  • 1
  • 17
  • 28
0

I know this thread is very old, but I am posting my idea for anyone who might visit this question.

The previous answers already made clear that it is very difficult to achieve what the OP is trying to achieve. But I think if anybody needs such functionality for testing purposes there is a very easy way to achieve it.

We can create a simple web app in Node or .NET or whatever environment is comfortable. The web app's UI will allow us to do the following operations.

  1. Create a device with IP
  2. Mark an IP as Online or Offline.

If IP is online it is pingable, else not.

At the same time, the web app also exposes an API that when supplied with an IP says to us whether the IP is pingable or not. This way we mock the ping operation to an IP. Let's name this web app as PingMock.

Now in the original app, we can create a TestPingService which instead of pinging, sends an HTTP request to PingMock. This way we will be able to test our business logic without having access to actual IPs.

For testing business logic the final output of the PingService matters and not from where the output comes. This is how unit testing is conducted.

The PingMock web app is just an example. We can mock the Ping operation in whichever way we like.

Hem Bhagat
  • 323
  • 3
  • 12