osx - Does a NIC 'know' its MAC address? -


my understanding ethernet nic 'knows' mac address. when packets arrive on wire, nic checks see if destination mac matches mac, , if so, forwards packet network stack. alleviates operating system of having examine each , every packet arrives on wire.

i'd know os driver functions support this. i've been looking @ ndis 5.1 reference, , have found this: http://msdn.microsoft.com/en-us/library/windows/hardware/ff557131%28v=vs.85%29.aspx , think i'm close, haven't hit jackpot yet.

i'm preparing class materials , want tell class nic knows mac address, don't want teach unless can verify myself it's true. seeing os driver functions support satisfy doubt.

i appreciate (and comment) community provide.

packet filtering

your understanding correct. nic fair amount of filtering in hardware, spare cpu excessive filtering. generally, typical ethernet nic have programmable packet filter allows packets if meet criteria, these:

  • the destination mac address matches 1 of set of programmable destination addresses (typically you'd put own unicast address target set, several multicast addresses).
  • the destination address broadcast address (for ethernet, that's ff-ff-ff-ff-ff-ff).
  • the destination address multicast address (for ethernet, first byte has lsb set)

in typical operation, windows program nic accept traffic destined nic's unicast address, broadcast address, , handful of multicast address (e.g., ipv6 neighbor discovery , upnp).

the hardware packet filter's purpose reduce cpu usage of host. windows not rely on hardware packet filter functional correctness. if badly-behaved nic indicate packets unfiltered, windows automatically fall filtering in software.

updating packet filter

windows may modify packet filter on hardware. example, if run netmon or wireshark , enable "promiscuous mode", ndis instruct nic indicate all traffic, if destination non-local unicast address.

if interesting lab experiment, open powershell , run command query current packet filter:

get-wmiobject -namespace root\wmi -class msndis_currentpacketfilter |     format-list instancename, ndiscurrentpacketfilter 

you can pipe command make output more readable:

    % { @{ $_.instancename = "{0:x8}" -f $_.ndiscurrentpacketfilter } } 

the packet filter presented integer, bitmask of ndis_packet_type_xxx constants sdk/wdk header file ntddndis.h. if enable promiscuous mode in netmon or wireshark, should see packet filter change include ndis_packet_type_promiscuous flag (0x20). disabling netmon or wireshark restore pre-existing packet filter.

other filtering types

i've described basic level of packet filtering, ethernet nics support. (microsoft requires minimal level of support "device.network.lan.base.packetfiltering" logo requirement.) more sophisticated hardware can cool stuff.

for example, hardware supports multiple receive queues has multiple receive filters. nic indicates packets match each filter separately, on separate cpus, make easier hypervisor distribute traffic virtualized guest operating systems.

disclaimer

your question mentions both os x , ndis, windows technology. remarks apply ndis , windows, work microsoft.


Comments

Popular posts from this blog

java - Run a .jar on Heroku -

java - Jtable duplicate Rows -

validation - How to pass paramaters like unix into windows batch file -