473,790 Members | 2,421 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

TCP connection to MAC address

Hello,

I would like to convert to following process to code. Any advice is
welcome.

I have a hardware device which requires the this procedure to set it's
IP address. First create an static ARP entry for the device's MAC
address and the desired IP address. Then telnet to this IP address on
TCP port 1. This will set the device to temporarily respond to that IP
address. Now you can use HTTP to access the device's web interface and
explicitly set it's IP address.

Basically it looks like creating a TCP connection on port 1, based on
MAC address instead of IP address, then a normal TCP connection on port
80 to do an HTTP POST and set the IP address. The first step may be a
little more involved, since the IP address will have to be included
somewhere.

Please excuse any stupid/misinformed questions - I'm completely new to
C#, and .net for that matter (coming from a VB6 background). I'm
currently using the 2005 Express edition, if that makes any difference.

Regards,
Nicolas

*** Sent via Developersdex http://www.developersdex.com ***
Aug 31 '07 #1
6 7052
Nicolas Noakes wrote:
Hello,

I would like to convert to following process to code. Any advice is
welcome.

I have a hardware device which requires the this procedure to set it's
IP address. First create an static ARP entry for the device's MAC
address and the desired IP address. Then telnet to this IP address on
TCP port 1. This will set the device to temporarily respond to that IP
address. Now you can use HTTP to access the device's web interface and
explicitly set it's IP address.
Could you flesh out this process a bit more? I'm confused as to what
you're trying to do. It seems like you want to have some kind of remote
configuration of the host's IP address abilities. What I don't
understand is why creating a static ARP entry is even necessary?

Chris.
Aug 31 '07 #2
Chris,

The device a networked logic controller. There is no practical method
available for displaying or otherwise retrieving it's current IP
address. It does not support DHCP - I assume for the same reason that it
cannot tell you what it is using so it would be pointless. The device
may not have an address set (as supplied), or may be on another IP
subnet, or you may just not know its IP address.

Therefore, until you have set the device to an explicit IP address that
you know of, you have no way of communicating with it on the network.

So, here are the instructions from the manufacturer to assign a
temporary IP address to the device (works until the device is rebooted)

1) Create a static ARP entry linking its MAC address to the IP address
you want to give it. e.g.:

arp -s 192.168.1.100 00-02-20-a0-b4-cd

2) Attempt to telnet to this IP address on TCP port 1. Note that this is
expected to fail, it is just a check measure. e.g.:

telnet 192.168.1.100 1

3) Access the device's web interface on the chosen IP address and
explicitly set its IP address, etc. e.g.:

http://192.168.1.100
This process in not difficult or problematic, but it is very manual. I
would like to write a small utility where I can simply enter the MAC
address and desired IP address and click "Set". Both as a useful tool,
and to learn networking from a C# point of view.

Does that help? Thanks for your interest.

Regards,
Nicolas

*** Sent via Developersdex http://www.developersdex.com ***
Aug 31 '07 #3
Nicolas Noakes wrote:
Chris,

The device a networked logic controller. There is no practical method
available for displaying or otherwise retrieving it's current IP
address. It does not support DHCP - I assume for the same reason that it
cannot tell you what it is using so it would be pointless. The device
may not have an address set (as supplied), or may be on another IP
subnet, or you may just not know its IP address.

Therefore, until you have set the device to an explicit IP address that
you know of, you have no way of communicating with it on the network.
Understood. I'm surprised that they don't support the loopback interface.

[Snippage of instructions]
This process in not difficult or problematic, but it is very manual. I
would like to write a small utility where I can simply enter the MAC
address and desired IP address and click "Set". Both as a useful tool,
and to learn networking from a C# point of view.

Does that help? Thanks for your interest.
Yes it does. Going back to your OP:
Basically it looks like creating a TCP connection on port 1, based on
MAC address instead of IP address, then a normal TCP connection on
port 80 to do an HTTP POST and set the IP address. The first step may
be a little more involved, since the IP address will have to be
included somewhere.
It is not initiating a TCP connection to a MAC address, as those are on
different layers. All it is doing is emulating the loopback address by
setting a default IP, and hitting it on a specific port as a sort of
"secret knock" to unlocking the web interface to the configuration manager.

All you need to really do is:
- Set the static arp table entry to the IP you've chosen.
- Open a TCP connection to that IP on port 1.
- When that fails (you indicated it wasn't expected to work), ignore the
failure and connect to port 80 using a web browser control.

In your code the only thing involving the MAC would be setting the ARP
table entry, and possibly retrieving the MAC address. It is still a very
separate step from the TCP connection to TCP/1 and initiating a web
browser connection.

My suggestion would be to use localhost as the default address
(127.0.0.1) provided it is not already in use on the device. If not,
pick an unused private IP range (10/8, 192.168/16, or 172/8 - IIRC) and
assign it an IP in those ranges.

Chris.
Aug 31 '07 #4
Chris Shepherd wrote:
Understood. I'm surprised that they don't support the loopback interface.
and
It is not initiating a TCP connection to a MAC address, as those are on
different layers. All it is doing is emulating the loopback address by
setting a default IP, and hitting it on a specific port as a sort of
"secret knock" to unlocking the web interface to the configuration manager.
Perhaps is should have posted in a networking group? I don't follow how
it would help if my device supported the loopback interface. How would
it work it that case? Or rather, how does loopback support in the device
enable me to connect to it from my PC? (These questions are straying
off-topic but I am interested to understand better)
All you need to really do is:
- Set the static arp table entry to the IP you've chosen.
- Open a TCP connection to that IP on port 1.
- When that fails (you indicated it wasn't expected to work), ignore the
failure and connect to port 80 using a web browser control.
Ok, I could basically perform the identical process from code. My only
question is whether there is a method to add the static arp entry from
code, or would I have to do it through a shell command?
My suggestion would be to use localhost as the default address
(127.0.0.1) provided it is not already in use on the device. If not,
pick an unused private IP range (10/8, 192.168/16, or 172/8 - IIRC) and
assign it an IP in those ranges.
Again, my lack of understanding on the loopback interface, but why the
default address of 127.0.0.1? That would mean hijacking my own
localhost, surely? Which may not be nice to someone using my proposed
tool who happens to also have a local web server running on their dev
machine.

Thanks for you interest.

Regards,
Nicolas
Sep 3 '07 #5
Nicolas Noakes wrote:
Chris Shepherd wrote:
>It is not initiating a TCP connection to a MAC address, as those are
on different layers. All it is doing is emulating the loopback address
by setting a default IP, and hitting it on a specific port as a sort
of "secret knock" to unlocking the web interface to the configuration
manager.

Perhaps is should have posted in a networking group? I don't follow how
it would help if my device supported the loopback interface. How would
it work it that case? Or rather, how does loopback support in the device
enable me to connect to it from my PC? (These questions are straying
off-topic but I am interested to understand better)
I think the misunderstandin g was all mine. I was picturing the device as
a networked handheld/embedded system that would be locally configured,
not remotely.
>All you need to really do is:
- Set the static arp table entry to the IP you've chosen.
- Open a TCP connection to that IP on port 1.
- When that fails (you indicated it wasn't expected to work), ignore
the failure and connect to port 80 using a web browser control.

Ok, I could basically perform the identical process from code. My only
question is whether there is a method to add the static arp entry from
code, or would I have to do it through a shell command?
A shell command would be simplest, but I would bet that Microsoft has
exposed the required API calls to do it. I've never had to do it, so I
couldn't tell you where to start unfortunately.
>My suggestion would be to use localhost as the default address
(127.0.0.1) provided it is not already in use on the device. If not,
pick an unused private IP range (10/8, 192.168/16, or 172/8 - IIRC)
and assign it an IP in those ranges.

Again, my lack of understanding on the loopback interface, but why the
default address of 127.0.0.1? That would mean hijacking my own
localhost, surely? Which may not be nice to someone using my proposed
tool who happens to also have a local web server running on their dev
machine.
Well, this is where I failed to understand what you meant. For remotely
configuring it, I would definitely use a specific address on your range
(or small range of addresses) in the event that you will be
simultaneously configuring multiple of these devices on the same network.

Chris.
Sep 4 '07 #6
I think the misunderstandin g was all mine. I was picturing the device as a
networked handheld/embedded system that would be locally configured, not
remotely.
Fine, that makes your comments much clearer! I want to write a utility to
run on a pc
A shell command would be simplest, but I would bet that Microsoft has
exposed the required API calls to do it. I've never had to do it, so I
couldn't tell you where to start unfortunately.
I'll carry on looking into it, thanks.
Sep 10 '07 #7

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
14525
by: Harry | last post by:
Using Oracle 8i enterprise on win 2000 (sp3) Installed the standard configuration & whenever I make a connection it takes about 10 secs. It's running on a P1900 with 1gb Ram so no reason there for slowness. Once I'm connected the queries work pretty much instantanously but to connect using SQLPLUS, Toad, ODBC, OLEDB all take about 10 secs. I connect using OLEDB from Visual Basic development environment & after the 1st connection...
9
17035
by: mcbill20 | last post by:
Hello all. I just installed Oracle 10g developer tools on a machine running XP Pro and Office XP. Before this I had just the Oracle 9 client installed. I the previous configuration, I was able to access any of the Oracle tables on another machine but now I am having problems. Unfortunately, I don't remember the correct syntax for the ODBC connect string and I am hoping that is my whole problem. I am trying to connect to an Oracle 9...
1
1447
by: James Goodman | last post by:
In VB6 I used to set my applications to automatically look for the source DB in the program installation directory. If it wasnt found it was fairly easy to pop a dialog asking the user to specify the path. I am writing an app at the moment which will require the user to connect to the DB over a network connection. I am not sure of the connection address at present. I have created my data-bound forms using server explorer to create the...
5
24021
by: Suresh | last post by:
Hi Guys I have Db2 server installed on remote server. i am connecting to that remote server by using VPN. I want to connect that remote DB2 server instance using my local machine DB2 development client. Bur Its gives me following error message. I searched lots of things on net and tried on remote server but i didnt got suceess. Can any one tell me how to set TCP\IP
6
14813
by: felix.citycs | last post by:
Why I cannot do with this code and exception is thrown with "the requested address is not valid in its context" try { IPAddress inputDNS_IP = Dns.Resolve(inputDNS_IP).AddressList; // start the data port and listen for connection from input host this.dataListener = new TcpListener(inputDNS_IP, dataPort);
17
5566
by: John Salerno | last post by:
Let me see if this question even makes sense...I'm reading Core Python Programming and I jumped ahead to the more specific topics like network programming. I plan to follow along with the example in that chapter and create a socket connection between my desktop and laptop. However, these two computers are already connected on my home network (using the Windows Network Setup Wizard), so I was wondering if this will have any effect on what...
3
3491
by: dynamo08 | last post by:
Hi, I am new to socket programming, I wrote an ftpclient which connects to an ftp server and downloads a file to the client computer. Now in one client connection I want to download multiple files by forking the parent connection. So far I have this, the code downloads only one file, and then gives the following error "Transfer Completed425 Unable to build data connection: Invalid argument" Appreciate if someone can help me here. The...
3
3740
Airslash
by: Airslash | last post by:
Hello, I've written my own TCPClient and TCPServer class components to handle traffic over the network between applications. When I test the components locally they work. In the local network between different machines they also work. When I try to connect to a remote location that's added to our network with Tunnels, I'm receiving a Timeout on the connect, but a ping to the IP from commandline works fine without a problem. There's a...
0
10413
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10200
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
9986
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
9021
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
6769
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5422
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5551
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4094
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3707
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.