Board index » delphi » How get MAC address from TCP/IP packets?

How get MAC address from TCP/IP packets?

Subj?

--

Eugene Vorobyov
Microsoft Certified Professional + Internet,
MCSE

 

Re:How get MAC address from TCP/IP packets?


Quote
Eugene Vorobyov wrote:

> Subj?

Short answer is "no way".  TCP is transport layer prtocol,
IP is network layer, MAC addresses are Ethernet -- data link
layer.  Dunno if they show people network stack models in MS
certification courses -- won't be surprised if they don't --
anyway, data link layer is below network layer.
That is, TCP/IP packets are encapsulated in ethernet packets,
not the other way around, so when you get a TCP/IP packet all
ethernet stuff is already stripped from it.  Including MAC
addresses.

FWIW on decent OS you can run ioctl(SIOCGARP,arpreq) to get ethernet
address from ARP table.  Don't ask me how to do it in WinDelphi,
search for ARP in MS help files.

Or you could go low-level, capture ethernet packets, filter out the ones
you need and get MAC address that way.

HTH
Dimitri

Re:How get MAC address from TCP/IP packets?


You can't do it directly AFAIK. Try using ARP -a from a prompt, or
within a Delphi prog by shelling and redirecting StdIn and StdOut.
Hacky, but it'll work just fine.

Eg:

C:\WINNT\system32>arp -a

Interface: 10.0.0.2 on Interface 2
  Internet Address      Physical Address      Type
  10.0.0.1              00-00-b4-6b-02-dd     dynamic

MH.

Quote
Eugene Vorobyov wrote:
> Eugene Vorobyov
> Microsoft Certified Professional + Internet,
> MCSE

And you're a microsoft certified professional? WTF does the darn MS
certification certify one for? Evidently not basics of address
resolution protocols <g>

MH.

--
Martin Harvey.
http://www.harvey27.demon.co.uk/mch24/
PGP key available from above address,
or http://wwwkeys.pgp.net/

Re:How get MAC address from TCP/IP packets?


Quote
Martin Harvey <mar...@aziraphale.demon.co.uk> wrote in message

news:36BB9B56.ED123A85@aziraphale.demon.co.uk...

Quote
>You can't do it directly AFAIK. Try using ARP -a from a prompt, or
>within a Delphi prog by shelling and redirecting StdIn and StdOut.
>Hacky, but it'll work just fine.

>Eg:

>C:\WINNT\system32>arp -a

>Interface: 10.0.0.2 on Interface 2
>  Internet Address      Physical Address      Type
>  10.0.0.1              00-00-b4-6b-02-dd     dynamic

>MH.

>Eugene Vorobyov wrote:
>> Eugene Vorobyov
>> Microsoft Certified Professional + Internet,
>> MCSE

>And you're a microsoft certified professional? WTF does the darn MS
>certification certify one for? Evidently not basics of address
>resolution protocols <g>

Ok. I needed to define MAC address of removed network card, use only TCP/IP
protocol in the local network.

- Show quoted text -

Quote

>MH.

>--
>Martin Harvey.
>http://www.harvey27.demon.co.uk/mch24/
>PGP key available from above address,
>or http://wwwkeys.pgp.net/

Other Threads