The Moose and Squirrel Files

October 31, 2008

Movember – Fighting Prostate Cancer

Filed under: Uncategorized — Tags: , , — networknerd @ 12:06 pm

Ok this is not a normal post for a geek blog, but statistically speaking there is a very high chance that if you’ve stumbled across this blog that you have a prostate and that you are at risk! Apologies in advance to all you geekgirls that might be offended by that statement.

Ben Smallwood, a lawyer but nonetheless a gentleman, is currently braving cruel “70’s porn star” jokes to raise funds for this worthwhile cause.  No he hasn’t “come to clean ze pool” . He’s raising money for a charity that benefits all men. Please help the cause by donating at the Movember website https://www.movember.com/au/donate/donate-details.php?action=sonsorlink&rego=1574726&country=au

More information is available at http://au.movember.com/
Movember - Sponsor Me

September 11, 2008

Social Bookmarking

Filed under: Uncategorized — Tags: , — networknerd @ 5:38 pm

Social Bookmarking is apparently all the rage.  I didn’t know what it was until last week.  I admit that I had seen all the links to Digg and del.icio.us, but truthfully I did not know what they were about. Clicking on links to find out is not good security practice so I just didn’t bother.

Now after having a discussion with Judy I learnt that social bookmarking is really huge. Apparently people bookmark stuff that interests them and tag/classify it and then share them amongst themselves.  In the information retrieval business this stuff is called document classification.  It’s clearly a hard thing to do in an automated fashion, but by harnessing the restless energy of the web 2.0 masses social bookmarking has become a distributed document classifcation process.  Since everyone is classifying and tagging their links and depositing the information onto a central server it makes searching that data simpler and more focussed than we could hope to achieve from a keyword search on google.

I admit now that I’m being cynical but I can’t understand how these sites manage to keep the lights on without doing advertising, or selling information.  Judy tells me there’s lots of free stuff on the web. I contend that there’s no such thing as a free lunch.

Now you can see that the previous post has a whole bunch of bookmarking icons.  They look like an unwanted appendage to me.  I won’t be repeating the exercise, since this blog is mostly about organising my random stuff for easier searching rather than public consumption. In fact all the sites seem to have their own bookmarklet, so the addition of the icons seems redundant.  People will bookmark if they want to.

The best part of this whole exercise is that I am reminded once again of the power of bookmarklets.  I first learnt about them when I stumbled across Connotea.  As I look again this seems like a social bookmarking site for academic reference material.

Bookmarklets though have grabbed my interest for the time being.  I’ll post something on my experiments very soon.

September 5, 2008

Detect Physical Network Adapters using WMI

Filed under: Uncategorized — Tags: , , — networknerd @ 2:07 pm

Getting a list of network adapters is easy just execute a wmi query “select * from win32_networkadapter”.  The hard part is determining which adapters are physical adapters.  I actually tackled this problem about three years ago.  My first efforts involved googling furiously to see what everyone else had done.  Not much.  Looked like I was on my own.

I messed around with wbemtest looking at all the adapters returned from the query and looked for any properties that would tell me if they were physical.  As luck would have it I started clicking on the associators to see if any related classes would help.

It’s obvious in hindsight that the answer is that physical adapters use resources (IO, memory or IRQ). Simple no?  Just execute an associators query for every network adapter returned from the original query.  If one of the returned classes is Win32_IRQResource, Win32_DeviceMemoryAddress or Win32_PortResource then the device is physical.   The script below shows how it is done.  As always some caveats apply.  Network cards in notebooks often have a power saving feature that releases the resources.  They magically return of course when the network card gets link or the power is connected to the notebook.  USB network cards don’t show up using this method either.


Option Explicit

'Constants describing associator classes which indicate a physical adapter
const IRQCLASS = "Win32_IRQResource"
const DEVMEMCLASS = "Win32_DeviceMemoryAddress"
const PORTCLASS = "Win32_PortResource"

'constants for wmi asynccontext key
const CONTEXT_KEY = "pnpdeviceid"
'WQL Query constants
const QRY_ALL_NIC = "select * from win32_networkadapter"
const QRY_NIC_ASSOC = "associators of {Win32_NetworkAdapter.DeviceID='"
const QRY_NIC_ASSOC2 = "'}"

Dim WshShell, oExec
dim ethernic, wnic, nic
dim assoc
dim devid
dim boolPhysicalAdapter
dim colNics, colassoc
dim wmisrv_cimv2

Set WshShell = CreateObject("WScript.Shell")

Set wmisrv_cimv2 = GetObject("winmgmts:root/cimv2")
'get a collection of all win32_networkadapters. We query the associators of each nic and see if
'any of the associator classes indicate they are physical adapters ie do they use memory addresses,
'io port or IRQ resources.
set colNics = wmisrv_cimv2.execquery(QRY_ALL_NIC)
for each nic in colNics
  set colassoc = wmisrv_cimv2.execquery(QRY_NIC_ASSOC & nic.DeviceID & QRY_NIC_ASSOC2)
  boolPhysicalAdapter = FALSE
  for each assoc in colassoc
    select case assoc.Path_.Class
      case IRQCLASS, DEVMEMCLASS, PORTCLASS
        wshShell.logevent 4, "Network adapter " & nic.name & " is an ethernet adapter" & vbcrlf _
          & "pnpdeviceid = " & nic.pnpdeviceid
        boolPhysicalAdapter = TRUE
        exit for
      case else
    end select
  next
  if boolPhysicalAdapter = FALSE then
    wshShell.logevent 4, "Network adapter " & nic.name & " ignored!" & vbcrlf _
      & "Not a physical adapter: pnpdeviceid = " & nic.pnpdeviceid
  end if
next

add to del.icio.us :: Add to Blinkslist :: add to furl :: Digg it :: add to ma.gnolia :: Stumble It! :: add to simpy :: seed the vine :: :: :: TailRank :: post to facebook

August 23, 2008

Display RSS in a Browser Window

Filed under: Uncategorized — Tags: , — networknerd @ 12:16 pm

One of the knowledge management people at work were amazed by a server application that rendered RSS news feeds as HTML to the client browser. I opined that that was a trivial exercise and that the same thing could be done client side on the browser.  To prove the point I googled up some javascript from Tim Huffam and pasted it straight into a web page. That should have been the end of the story.  Next day I hear that it doesn’t work for some RSS feeds.  Turns out that they are all from feedburner.

Javascript debugging was a bust, so I moved down the application tree and used a telnet client to connect to feeds.feedburner.com. That returned a 302 code and a new host to check feedproxy.feedburner.com.  Trying the feedproxy.feedburner.com url in IE worked. The answer must be that the MSXML2.DOMDocument.3.0 cant handle redirects. All good in theory except that a nagging doubt, confirmed by google, tells me otherwise.

Next move was to open up word and try it in VBA (The debugging is much better than IE).  Naturally it worked properly first time.  So why did the activex object behave differently in IE?  When in doubt look at packets.  Wireshark was installed and a capture was performed using IE and netcat to perform the HTTP GET. For IE the return from the server was HTML.  For netcat the return was pure XML.  The next conclusion I jumped to was that it was dependent on the useragent header in the get request.  Wrong again. I eventually narrowed it down to the referer header. Oh well, most of my exercise does come from jumping to the wrong conclusion.

Feedburner must use some clever server side stuff (mod_rewrite perhaps) to detect if the requester is using a browser based on the referer header.

I did  prove to myself once again though that most application level problems can be more readily identified at the network level.

Create a free website or blog at WordPress.com.