How to simulate an IP address - a device simulator is required

I'm new here ... digging around for some help, but decided that I join and ask for some recommendations.

I am looking to create an application that can create several "fake" devices. They need an IP address, and I assume I can answer ping. It would be nice to be able to respond to WMI. A kind of simulator. I would like to create up to 50,000 devices, but even starting with 1 will help.

What is needed for such an application? TCP client / listener? I have never done something like this before, so please be careful :)

+6
source share
2 answers

You can install a virtual network adapter (the driver is included in the Windows OS), but I never used it. The driver for the virtual network adapter is here: %WINDIR%\Inf\Netloop.inf

You can use the DevCon command line tool to add devices using a script, for example:

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

Installation fails in a few seconds (on my Core Duo 2.0 laptop).

If you need to configure many network cards, you can use the netsh command line.

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 can upload / export the current network configuration to a file (to see what the current configuration looks like):

 netsh interface dump > file.txt 

Additional netsh examples

Edit: deleted data is not useful in this case.

+3
source

If I understand you correctly, unfortunately, it will not be easy, because you need to virtualize network adapters to do the work you need. The IP address is tied to nic (physical or logical), and not to what can be specified in the top-level code. VMWare Workstation includes a plug-in for Visual Studio, so maybe you can use it to create many virtual nics and assign them programmatically, but otherwise you need to write virtual network card drivers (possibly in netbook language) to do this if you are not using existing virtualization technology. you can add many IP addresses to nic, but the computer interacting with it will know that they are the same network object. if it’s good with you, then just add all the IP addresses you want to use on your card.

in the second part of your request, since you want the IP addresses to be able to receive and send data, their addresses must be routed, so you can’t just pick any old IP address. if you are well outside the NAT wall, you can use 10.xyz to solve them, but on the outside of nat, they seem to be using the same public IP address for the outside world. In order to set 50k public IP addresses, you must first register and buy them.

Finally, you cannot use TCPClient to perform Echo / Ping, since they use the ICMP protocol, but instead use the System.Net and System.Net.NetworkInformation namespaces. Here are some VB code to send ping to give you its taste:

 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 
+1
source

All Articles