{"id":103118,"date":"2019-11-20T07:00:00","date_gmt":"2019-11-20T15:00:00","guid":{"rendered":"http:\/\/devblogs.microsoft.com\/oldnewthing\/?p=103118"},"modified":"2019-11-19T22:07:28","modified_gmt":"2019-11-20T06:07:28","slug":"20191120-00","status":"publish","type":"post","link":"https:\/\/devblogs.microsoft.com\/oldnewthing\/20191120-00\/?p=103118","title":{"rendered":"The case of the <CODE>Uuid&shy;Create&shy;Sequential<\/CODE> that didn&#8217;t use the MAC address"},"content":{"rendered":"<p>A customer reported that the <code>Uuid\u00adCreate\u00adSequential<\/code> function was generating UUIDs that did not place the network card&#8217;s MAC address in the final bytes of the UUID.<\/p>\n<p>Sequentially-generated UUIDs are so-called Version 1 UUIDs: A combination of a timestamp and a MAC address. The timestamp is incremented to produce sequential UUIDs.<\/p>\n<p>So why wasn&#8217;t the MAC address being used in the UUID? Instead, the high bit of the first byte of the MAC address was set, indicating that this was a pseudo-random MAC address rather than a real one. (In real MAC addresses, the first bit is zero, indicating a unicast destination.)<\/p>\n<p>It took a lot of investigation, but the team finally got to the root of the problem.<\/p>\n<p>Their systems had a virtual network card, and the driver for the virtual network card generated a MAC address where the Organizationally Unique Identifier (OUI) was <code>FFFFFF<\/code>.<\/p>\n<p>Uh, oh.<\/p>\n<p>Remember I said that in real MAC addresses, the first bit is zero, indicating a unicast destination. But their MAC address had the first bit (indeed the first 24 bits) all set!<\/p>\n<p>When the system gets the MAC address for the purpose of creating sequential UUIDs, it ignores network adapters who report a OUI of <code>FFFFFF<\/code>, on the assumption that they are fake network adapters and therefore do not carry a unique MAC address.<\/p>\n<p>And if <i>all<\/i> of the network adapters are fake, then the UUID generation algorithm falls back to the case where there is no network adapter at all and generates a pseudo-random one. And sets the bit that says &#8220;This is a fake MAC address.&#8221;<\/p>\n<p>When told that their virtual network card driver was setting the OUI to <code>FFFFFF<\/code>, they answered, &#8220;Is that a problem? Should we be using something else?&#8221;<\/p>\n<p>It&#8217;s actually a good thing that they accidentally chose a blatantly invalid OUI for their fake MAC address, because it makes things as clear as possible (within the expressive range of 48-bit MAC addresses) that the MAC address is fake and should not be relied upon for global uniqueness. The <code>Uuid\u00adCreate\u00adSequential<\/code> function is correct to ignore that artificial MAC address and fall back on a pseudo-randomly-generated one.<\/p>\n<p>The problem was not in the <code>Uuid\u00adCreate\u00adSequential<\/code> function, nor was it in their virtual network card. It was in their expectations! If you have a fake network card, then its MAC cannot be used to generate sequential GUIDs.<\/p>\n<p><b>Bonus chatter<\/b>: The <a href=\"https:\/\/docs.microsoft.com\/en-us\/windows-hardware\/drivers\/debugger\/setting-up-a-network-debugging-connection-automatically\"> kdnet<\/a> feature also sets up a virtual network card with a vendor ID of all F&#8217;s. So if you enabled kdnet, and you don&#8217;t have a real network card, then you may encounter this problem, too.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>If you want to use it, make sure it&#8217;s good.<\/p>\n","protected":false},"author":1069,"featured_media":111744,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[1],"tags":[26],"class_list":["post-103118","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-oldnewthing","tag-other"],"acf":[],"blog_post_summary":"<p>If you want to use it, make sure it&#8217;s good.<\/p>\n","_links":{"self":[{"href":"https:\/\/devblogs.microsoft.com\/oldnewthing\/wp-json\/wp\/v2\/posts\/103118","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/devblogs.microsoft.com\/oldnewthing\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/devblogs.microsoft.com\/oldnewthing\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/oldnewthing\/wp-json\/wp\/v2\/users\/1069"}],"replies":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/oldnewthing\/wp-json\/wp\/v2\/comments?post=103118"}],"version-history":[{"count":0,"href":"https:\/\/devblogs.microsoft.com\/oldnewthing\/wp-json\/wp\/v2\/posts\/103118\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/oldnewthing\/wp-json\/wp\/v2\/media\/111744"}],"wp:attachment":[{"href":"https:\/\/devblogs.microsoft.com\/oldnewthing\/wp-json\/wp\/v2\/media?parent=103118"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/oldnewthing\/wp-json\/wp\/v2\/categories?post=103118"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/oldnewthing\/wp-json\/wp\/v2\/tags?post=103118"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}