473,382 Members | 1,313 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,382 software developers and data experts.

Trying to send an ARP(Address Resolution Protocol) Message with Socket

I'm trying to send an ARP to determine different devices on the
network. I need to see the MAC address of my devices on my LAN. With
the MAC I can determine if I need to talk to that devices. I figured
the ARP is the best we to find who is out there. I'm using C# and the
Raw SocketType. I run into the WSACancelBlockingCall problem. Here's
my code:

Socket MyPing = new Socket(AddressFamily.InterNetwork,
SocketType.Raw , ProtocolType.IP );

MyPing.SetSocketOption(SocketOptionLevel.IP,
SocketOptionName.HeaderIncluded, true);

byte[] DataARP = new byte[] { 00, 0x01, 0x08, 0x00, 0x06, 0x04, 0x00,
0x01, 0x00, 0x13, 0x8f, 0x88, 0xe1, 0x51, 0xc0, 0xa8, 0x00, 0x03, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0xc0, 0xa8, 0x00, 0x0a };

//Fake an IP Address so I can send with SendTo
IPAddress IP = new IPAddress(new byte[] { 192, 168, 1, 1
});
IPEndPoint IPEP = new IPEndPoint(IP, 5931);

//Local IP for Receiving
IPEndPoint Local = new IPEndPoint(IPAddress.Any, 0);
EndPoint EP = (EndPoint)Local;

MyPing.SendTo(DataARP, IPEP);

It's a very simple app. All I want to do is send data only with the
Eithernet II Header. I figured I need a Raw socket, but it's canceling
my sending. I'm debuging with Ethereal.

Aug 6 '06 #1
7 11998

"Shoveler" <ma**********@hotmail.comwrote in message
news:11**********************@m73g2000cwd.googlegr oups.com...
I'm trying to send an ARP to determine different devices on the
network. I need to see the MAC address of my devices on my LAN. With
the MAC I can determine if I need to talk to that devices. I figured
the ARP is the best we to find who is out there. I'm using C# and the
Raw SocketType. I run into the WSACancelBlockingCall problem. Here's
my code:

Socket MyPing = new Socket(AddressFamily.InterNetwork,
SocketType.Raw , ProtocolType.IP );

MyPing.SetSocketOption(SocketOptionLevel.IP,
SocketOptionName.HeaderIncluded, true);

byte[] DataARP = new byte[] { 00, 0x01, 0x08, 0x00, 0x06, 0x04, 0x00,
0x01, 0x00, 0x13, 0x8f, 0x88, 0xe1, 0x51, 0xc0, 0xa8, 0x00, 0x03, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0xc0, 0xa8, 0x00, 0x0a };

//Fake an IP Address so I can send with SendTo
IPAddress IP = new IPAddress(new byte[] { 192, 168, 1, 1
});
IPEndPoint IPEP = new IPEndPoint(IP, 5931);

//Local IP for Receiving
IPEndPoint Local = new IPEndPoint(IPAddress.Any, 0);
EndPoint EP = (EndPoint)Local;

MyPing.SendTo(DataARP, IPEP);

It's a very simple app. All I want to do is send data only with the
Eithernet II Header. I figured I need a Raw socket, but it's canceling
my sending. I'm debuging with Ethereal.
I'm no expert on raw sockets - I've never used them... But, didn't xp sp2
remove (or severly) limit access to raw sockets? Assuming your doing this
on an XP SP2 box :)

--
Tom Shelton [MVP]
Aug 6 '06 #2
Shoveler wrote:
I figured the ARP is the best we to find who is out there.
Have you considered sending a UDP broadcast to which your devices send a
reply?

hth,
Max
Aug 6 '06 #3
Try to use WMI class:
http://msdn.microsoft.com/library/de...figuration.asp

The link is for Win32. .Net framework will be System.Management Class.

Hope it helps.

chanmm

"Shoveler" <ma**********@hotmail.comwrote in message
news:11**********************@m73g2000cwd.googlegr oups.com...
I'm trying to send an ARP to determine different devices on the
network. I need to see the MAC address of my devices on my LAN. With
the MAC I can determine if I need to talk to that devices. I figured
the ARP is the best we to find who is out there. I'm using C# and the
Raw SocketType. I run into the WSACancelBlockingCall problem. Here's
my code:

Socket MyPing = new Socket(AddressFamily.InterNetwork,
SocketType.Raw , ProtocolType.IP );

MyPing.SetSocketOption(SocketOptionLevel.IP,
SocketOptionName.HeaderIncluded, true);

byte[] DataARP = new byte[] { 00, 0x01, 0x08, 0x00, 0x06, 0x04, 0x00,
0x01, 0x00, 0x13, 0x8f, 0x88, 0xe1, 0x51, 0xc0, 0xa8, 0x00, 0x03, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0xc0, 0xa8, 0x00, 0x0a };

//Fake an IP Address so I can send with SendTo
IPAddress IP = new IPAddress(new byte[] { 192, 168, 1, 1
});
IPEndPoint IPEP = new IPEndPoint(IP, 5931);

//Local IP for Receiving
IPEndPoint Local = new IPEndPoint(IPAddress.Any, 0);
EndPoint EP = (EndPoint)Local;

MyPing.SendTo(DataARP, IPEP);

It's a very simple app. All I want to do is send data only with the
Eithernet II Header. I figured I need a Raw socket, but it's canceling
my sending. I'm debuging with Ethereal.

Aug 6 '06 #4

Markus Stoeger wrote:
Shoveler wrote:
I figured the ARP is the best we to find who is out there.

Have you considered sending a UDP broadcast to which your devices send a
reply?

hth,
Max
The devices I need to talk with do use UDP for communication, but I'd
rather try to find it by his MAC Address. If there's any other way to
retrieve the MAC within C#, I'm all ears. Is there a way to access the
ARP Cache in the system?

Aug 6 '06 #5
I'm no expert on raw sockets - I've never used them... But, didn't xp sp2
remove (or severly) limit access to raw sockets? Assuming your doing this
on an XP SP2 box :)

--
Tom Shelton [MVP]
Yup, I'm using WinXP with SP2. I'm using C# 2005 Express Edition. I
was wondering if I upgraded to the Pro, I would be able to use all
Socket functions?

Aug 6 '06 #6

"Shoveler" <ma**********@hotmail.comwrote in message
news:11*********************@m79g2000cwm.googlegro ups.com...
>
>I'm no expert on raw sockets - I've never used them... But, didn't xp
sp2
remove (or severly) limit access to raw sockets? Assuming your doing
this
on an XP SP2 box :)

--
Tom Shelton [MVP]

Yup, I'm using WinXP with SP2. I'm using C# 2005 Express Edition. I
was wondering if I upgraded to the Pro, I would be able to use all
Socket functions?
If you are indeed running into the XPSP2 raw socket limitations, then
upgrading to Pro won't help. This is a limitation of the OS. One way to
test is to try on a pre sp2 XP box.

--
Tom Shelton [MVP]
Aug 7 '06 #7
Thanks for the info guys!

I'm already running XP Pro, I was thinking about the C#2005 Pro, but
the OS still limits it. I've downloaded a C# converted app of WinPcap.
It works great for downloading entire packets, so I now have access to
the MAC Address of each device on the LAN that sends a message. I
really don't need to send ARP commands, I'll just let to OS do it when
I ping.
If you are indeed running into the XPSP2 raw socket limitations, then
upgrading to Pro won't help. This is a limitation of the OS. One way to
test is to try on a pre sp2 XP box.

--
Tom Shelton [MVP]
Aug 9 '06 #8

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

Similar topics

1
by: crowl | last post by:
Hi all, I'm looking for a simple c source sample which I can send message to ICQ and MSN Messenger. I have search with google, but without luck on my side. Do you know any doc for programming...
3
by: Eka Gautama | last post by:
Hi all, Is it possible to intercept net send message? I don't want windows show the message to screen directly, but i want process first, then display to the screen... Thanks
0
by: Jerry | last post by:
Hi, I send a message WM_HELP, but it return false. The code is: Point point = new Point(e.X, e.Y); Control child = GetChildAtPoint(point); if (child != null) { point = PointToScreen(point); ...
4
by: trint | last post by:
How can I send from myApp, over the internet with c#.net, a message to another instance of myApp?? Like Yahoo or MSN? Thanks, Trint
7
by: Ahmad Jalil Qarshi | last post by:
Hi! I want to develop two applications one a Windows Service and the other a GUI based application. I want some sort of communication between Service and GUI. I have decided to use Remoting for...
2
by: ad | last post by:
How can I send message to cellular phone by program?
5
by: napster | last post by:
hi, I am working on a project to control some pc activities from mobile but am not able to send a message from mobile to pc.I have tried the AT commands but its not working for me.Can anybody help...
1
by: sauravpn | last post by:
I am new to perl and I cant figure out how to write a perl script to send message to syslog wih facilty user
1
by: Balabhadra Kar | last post by:
Hello how can i send message to all mobile set using asp code .Please Help me. thnak.s
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...

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.