Will do!!!
Catching Flies With Alice
Back in the day, I worked in Alzheimer’s units in nursing homes. My favorite patient — or ‘resident’ — was Alice, who couldn’t remember my name, though she recognized me and was very friendly. Her medication had her manic, and she was forever walking restlessly. She once had a cut on her knee, and she got in and out of bed so frequently that I could count the blood polka dots on the edge of the bed.
The Alzheimer’s unit had 8′ drop ceilings, and there were usually flies on the ceiling [classy joint]. So, I’d fill up a cup with water and add a little detergent. Alice and I would walk up and down the long main hall, and when I saw a fly on the ceiling I’d lift the cup up slowly under the fly, and the fly would drop into the cup, get trapped by the detergent, and squirm to death. I’d hold the cup down for Alice to watch, and she got a kick out of it. We spent hours walking up and down that hall, holding hands and catching flies [the other residents decided to sleep]. It was the easiest way to keep her calm.
This weekend, my sleeping schedule got screwed up, and at midnight I ended up grabbing a book of the shelf for a good re-read. The book is “God Bless You, Mr. Rosewater,” by Kurt Vonnegut Jr., of course, and I hadn’t read it since high school. Plugging along, I got to page 78:
“The tumbler-and-soapsuds techniqe worked like this: A woman would look for a fly hanging upside down. She would then bring her tumbler of suds directly under the fly very slowly, taking advantage of the fact that an upside-down fly, when approached by danger, will drop striaght down two inches or more, in a free fall, before using his wings. Ideally, the fly would not sense danger until it was directly below him, and he would obligingly drop into the suds to be caught, to work his way down through the bubbles, to drown.”
“Of this technique Eliot often said: ‘Nobody believes it until she tries it. Once she finds out it works, she never wants to quit.’”
So that’s where I picked that up! What an unexpected surprise! Nostalgia …. catching flies with Alice……
Alice’s doctor played around with her medication, and there was about a two week period where Alice was lucid and could remember my name. “Alice, do you know my name?” “Jason,” and she’d smile like she was a six-year-old who just got a new bicycle. Then she went downhill and ended up in the hospital. I went to visit her every day, but she was near death and couldn’t even open her eyes. The nurses put a respirator mask over her mouth, to keep out the flies. She died pretty shortly after entering the hospital.
How strange that as I approach 40, one of my fondest memories is the hours spent with a 70-year-old woman with dementia, who couldn’t remember my name, walking up and down the hall, holding hands, catching flies in a cup of dishwater…..
On UNIX, it’s simple to delete matching files in a directory, over a certain age (e.g., all .txt files over 2 days old):
find /some/directory -type f -ctime +2 -name \*.txt -exec rm -f '{}' \;
On Windows, it’s ridiculously complicated. Here’s a PowerShell script, modified from somewhere….:
$a = Get-ChildItem 'C:\Temp\subdir\*' -include *.txt if ($a.count -gt 1) { foreach($x in $a) { $y = ((Get-Date) - $x.CreationTime).Days if ($y -gt 7 -and $x.PsISContainer -ne $True) { #$x.Delete() #uncomment here to delete Write-Host $x } } }
Miscellany
1) Rather odd to see a sickle and hammer on a Microsoft employee’s contact info:
2) When I see an ad for 5hourenergydrink.com, I think of RFC 1123 (http://www.faqs.org/rfcs/rfc1123.html). Does that make me some sort of geek?
“The syntax of a legal Internet host name was specified in RFC-952 [DNS:4]. One aspect of host name syntax is hereby changed: the restriction on the first character is relaxed to allow either a letter or a digit. Host software MUST support this more liberal syntax.” And 3com rejoiced.
3) In tuxedo pants, there’s a hole in the top of the pockets so you can pull down your shirt to unwrinkle it. Why don’t they have those in other pants/jeans? It’s mighty convenient.
4) You never see Frequently Unasked Questions.
DNS Load Balancing
A “Poor Man’s Load Balancer” is just publishing multiple DNS records for the same resource. However, it doesn’t really work, and it certainly doesn’t work the way novices expect it to. The publishing DNS server can give them in any order, or it may give them in a specific order, or it might give different result sets to different clients, or any intervening caching server my truncate or reorder results, or your client OS may want to sort result sets its own way, or your application may cache and sort its own results. Different resolver libraries handle results differently, and you can get different results by which function your application calls (getaddrinfo? gethostbyname? IPv4 or IPv6?).
Relevant links
- Why DNS Based Global Server Load Balancing (GSLB) Doesnt Work
- Overview of DNS Caching In Browsers – Addendum to Why DNS Based GSLB Doesnt Work
- ‘Re CVS cvs.openbsd.org src’ – MARC
- Bug#340514 marked as done (libc6 dns resolver sort ip address list)
- DNS Round Robin and Destination IP address selection – Microsoft Enterprise Networking Team – Site Home – TechNet Blogs
- DNS Shuffle Records and Round-Robin (DNS RR) Chapter 12. Designing for High Availability Integrated cisco and unix network architectures Networking eTutorials.org
- FGA The uselessness of Round Robin resource record set shuffling
- djbdns – How to balance load among many web servers
- Re [TLS] Server Name Indication (SNI) in an IPv6 world
- resolv.conf(5) resolver config file – Linux man page
- test the round robin DNS features of the resolver functions » KutuKupret
- What is DNS round robin and subnet prioritization
- Windows Vista and Windows Server 2008 DNS clients do not honor DNS round robin by default
- Mark Minasi’s Reader Forum – DNS resolution order
- Mark Minasi’s Reader Forum – Name Resolution Order
- DNS balancing
- BIND’s rrset-order statement
- How Internet Explorer uses the cache for DNS host entries
- How to Disable Client-Side DNS Caching in Windows XP and Windows Server 2003
- BIND 9.4 Manual – Load Balancing
File: squid.zip
Miscellany. Overview diagram in Visio and PNG. adzapper postmatch. squid examples to redirect based on source IP. squid tee. Wiki squid/adzapper template. Wiki template for Java client config file (you’d be surprised how many people don’t know about it…).
Here’s the quickest way I’ve found to produce good diagrams for certain types of technical diagrams. You can export them to SVG or EPS and use them in most anything.
Protocol Diagrams (packet diagrams): use the LaTeX bytefield package. It’s easy.
Sequence Diagrams: use Mscgen. Easier than Graphviz on this.
Graphs (general): use Graphviz. And the Perl module generally makes life easier.
State Diagrams: use Graphviz, or Tikz. Tikz is intimidating, but state diagrams are simple enough.
General drawing: try Inkscape, and don’t forget OpenClipArt.org.
It’s terrible practice, I know, but my password is the name of my dog. My dog’s name is H^7a(;tQ.
Flash Performance on Terminal Services RDP 7.1
[This is a followup to my 2008 post on Flash performance over RDP.]
Windows Server 2008 R2 Service Pack 1 is being released to the masses today, and the graphics improvements Microsoft picked up when they bought Calista are now released as RemoteFX. This RDP 7.1 update should provide better display performance for those forced by a cruel and uncaring universe to make Adobe Flash available over RDP over broadband. One hopes.
The most effective course of action remains to block Flash advertisements at the proxy server (squid + adzapper, or Privoxy), and require the user to enable Flash when needed. If the Flash file (.swf, say) is blocked, multiply all your performance hits by 0 — there’s nothing to transfer or optimize. Block all the junk you don’t need.
Notes…..
Continue reading »
PageUp System Requirements
Page-Ups are the handiest little gadgets. Watch out for the shipping costs. Especially look out to make sure you meet the minimum system requirements.
Here’s how to use Perl and libpcap to process a capture file offline. This particular example parses RDP cookies….
# ./watch_rdp_cookies.pl session.cap 192.168.0.93:46890:192.168.0.88:3389:mstshash=corp\jaso 192.168.0.93:46890:192.168.0.88:3389:0 192.168.0.93:49469:192.168.0.89:3389:msts=1493215424.15629.0000(192.168.0.89:3389)
Overview
Windows terminal server (remote desktop session host) environments needing load balancing and high availability may use 3rd-party load balancers to distribute initial connections and persist further network connections. Load balancers utilize RDP cookies — short text strings sent by RDP clients in initial connection requests.
Native Windows functionality may be sufficient for some needs, say by creating a terminal server farm and using round-robin DNS to distribute initial connections (“Poor Man’s Load Balancing”). For example, given three terminal servers (TERM{1,2,3}) with IP addresses 10.10.10.{1,2,3}, the administrator would publish a DNS A record (e.g., “TERMFARM”) with the multiple IP addresses of each terminal server. The client requests the address for “TERMFARM” is [somewhat] randomly given one of the IP addresses and connects to that server. Of course, when the client disconnects and tries to connect again, a different IP address may be returned, and the client would log in at that server, causing two active sessions to be open. This is very unproductive for users, and it’s a waste of resources. Microsoft Session Broker (Connection Broker) can be used to keep track of open sessions, and subsequent reconnects redirect the user back to the server hosting their existing session (“revectoring”). This generally works fine. There are a few downfalls: 1) the initial connection may fail if the randomly-returned server is down, and the client will wait 30 seconds before trying the next, 2) Windows Server 2003 must be the more expensive Enterprise Edition to use Session Broker, 4) Windows 2003′s Session Broker doesn’t do any actual load balancing, and 5) Windows Server 2008′s Connection Broker is better (load balances solely on session count), but it incorporates no other intelligence. Additionally, RDP clients have to have direct IP connectivity with the terminal servers, which may not be desirable in some cases.
As an alternative, consider putting a couple of UNIX servers out in front, running HAProxy on a shared IP address, by using keepalived or similar. RDP clients would connect to a DNS name pointing to an IP address. keepalived manages the failover IP address so that if the primary load balancer fails, the second one picks up the traffic. The HAProxy load balancing software understands RDP cookies and can load balance connection requests. Savvy admins and value-added companies can add more intelligence to the load balancing. You could weight some servers higher than others, or include memory and CPU load, rather than using a sessions-per-host metric. Also, using a 3rd-party load balancer can hide the servers, simplifying network and firewall administration effort.
Connection Request Protocol Details
Remote Desktop Protocol (RDP) clients send a small text string – a cookie or routing token– when starting a new connection. RDP is implemented through the ITU X.224 protocol, where commands are encapsulated in Protocol Data Units (PDU). RDP connection requests use X.224 Connection Request PDU.
ITU “T.123 : Network-specific data protocol stacks for multimedia conferencing”: http://www.itu.int/rec/T-REC-T.123/en
ITU “X.224 : Information technology – Open Systems Interconnection – Protocol for providing the connection-mode transport service”: http://www.itu.int/rec/T-REC-X.224/en
Microsoft “2.2.1.1 Client X.224 Connection Request PDU” : http://msdn.microsoft.com/en-us/library/cc240470
A X.224 Connection Request PDU has the following layout:
Cookies
Cookies are simple text strings and have nothing to do with authentication or any type of negotiation — they are just a string of text set by the RDP client. There are two types of cookies, and they’re mutually exclusive – a connection request can only contain one type of cookie. They are:
- User cookie (”mstshash”): ANSI text string that almost always contains a username.
- IP cookie (”msts”): numeric string that encodes the IP address and port number to route the connection to.
User Cookies (mstshash:)
A user cookie is intended to map a user to a specific terminal server, even if the user disconnects and reconnects from a different client and IP address.
The format of the user cookie is:
Cookie:[space]mstshash=[ANSI string][0x0d0a]
10:57:26.321918 192.168.0.201.33520 > 192.168.0.93.3389:
P 2000684428:2000684480(52) ack 3864383132 win 5840
<nop,nop,timestamp 2842032495848714> (DF)
0000: 4500 0068 53a2 4000 4006 6477 c0a8 00c9 E..hS¢@.@.dw(.?
0010: c0a8 005d 82f0 0d3d 7740 058c e655 ce9c (.].?.=w@..?U?.
0020: 8018 16d0 3908 0000 0101 080a 0004 562b ...?9.........V+
0030: 94c3 a10a 0300 0034 2fe0 0000 0000 0043 .á....4/?.....C
0040: 6f6f 6b69 653a 206d 7374 7368 6173 683d ookie: mstshash=
0050: 6a61 736f 6e74 6573 7440 636f 7270 0d0a jasontest@corp..
0060: 0100 0800 0000 0000 ........
The cookie is then “mstshash=jasontest@corp”.
A load balancer will keep a table listing the cookie and target server IP address, using the cookie to balance the initial connection if no state already exists, or routing the connection to the appropriate server if an existing session does exist.
For example, USER1 has no existing session on any terminal server. USER1’s RDP client sends an RDP Connection Request to the load balancer (with cookie “mstshash=USER1”), and the load balancer sees that “mstshash=USER1” has no existing state (no active sessions). The load balancer, depending on configuration, applies an algorithm to determine where the request should be sent. Most load balancers default to round-robin, but different implementations may have more intelligent methods, like using terminal server agents to report back load (memory, CPU, etc.,) that the load balancer can use when routing initial connections. USER1’s connection request is sent to a terminal server.
Cookie Size and Interoperability
Different RDP client implementations impose different size limits on the user cookie:
- The Windows RDP client (mstsc.exe) truncates the user cookie to 9 characters.
- Newer versions of the Windows RDP client can use the LoadBalanceInfo property and set the cookie up to 110 characters. More
- rdesktop limits the cookie to 127 characters.
- ProperJavaRDP and Elusiva’s “Open Source Java RDP” fork both truncate the user cookie to 9 characters (iso.java: “if(uname.length() > 9) uname = uname.substring(0,9);”)
This truncation causes certain issues.
The most well-known issue is a collision that occurs when cookies are truncated to 9 characters. For instance, the default Microsoft client cookie for DOMAIN\USER1 is “DOMAIN\US” (9 characters). The default Microsoft client cookie for DOMAIN\USER2 is also “DOMAIN\US” (9 characters). The cookies are the same for both connection requests, and a load balancer would route them to the same server. The consensus solution for this is to use the USER@DOMAIN login format. So, USER1@DOMAIN would have cookie “USER1@DOM”, while USER2@DOMAIN would be “USER2@DOM”.
But note that the user can’t switch formats. “CORP\Bob” connects with cookie “CORP\Bob” and disconnects. He connects again, but uses “Bob@CORP” with cookie “Bob@CORP”. These cookies are different, so a load balancer will treat the connections differently — he may end up with different sessions on different servers.
Another snafu occurs when switching between clients that truncate the cookie and those that don’t. CORP\ROBERT logs in from a Windows XP RDC client and opens a session on TERM-01. He heads out to the warehouse and logs in from a UNIX thin client using rdesktop. But he ends up with a new session on TERM-02. His first connection was with cookie “CORP\ROBE”, while his second connection used cookie “CORP\ROBERT”.
IP Cookies
IP-based routing tokens “msts=” are handed back by Windows Session Broker / Connection Broker when “Use IP Address Redirection” is disabled.
Cookie:[space]msts=[ip address].[port].[reserved][0x0d0a]
09:39:40.133269 192.168.0.93.34764 > 192.168.0.87.3389: P 3072855348:3072855403(55) ack 1295660978 win 46 <nop,nop,timestamp 2836782526209545> (DF) 0000: 4500 006b d090 4000 4006 e7f7 c0a8 005d E..k?.@.@.??(.] 0010: c0a8 0057 87cc 0d3d b728 0d34 4d3a 37b2 (.W.?.=·(.4M:7² 0020: 8018 002e 8262 0000 0101 080a a915 ddbe .....b......©.? 0030: 0003 3289 0300 0037 32e0 0000 0000 0043 ..2....72?.....C 0040: 6f6f 6b69 653a 206d 7374 733d 3134 3933 ookie: msts=1493 0050: 3231 3534 3234 2e31 3536 3239 2e30 3030 215424.15629.000 0060: 300d 0a01 0008 0000 0000 00 0..........
Decode the IP address as follows:
- Convert decimal to hex: 1493215424 = 59 00 A8 C0.
- Reverse the bytes: C0 A8 00 59.
- Convert back to decimal: 192 168 0 89 (192.168.0.89).
Decode the TCP port likewise:
- Convert decimal to hex: 15629 = 3D 0D.
- Reverse the bytes: 0D 3D.
- Convert back to decimal: D3D = 3389.
The reserved section should always be “0000“.
Monitoring
I wrote a short Perl script to parse offline tcpdump packet dumps for RDP cookies:
http://www.snakelegs.org/2011/02/06/perl-and-libpcap-parsing-capture-files-offline-rdp-cookies/
tcpdump
tcpdump -s 65535 -X ’dst port 3389 and tcp[37] == 0xe0’
Wireshark
Filter: x224.rdp_rt
Network Monitor
Description == “X224:Connection Request”
Make sure the Windows parser profile is loaded.
Remote Desktop Protocol (RDP) clients send a small text string – a cookie or routing
token– when starting a new connection. RDP is implemented through the ITU
X.224 protocol, where commands are encapsulated in Protocol Data Units (PDU).
RDP connection requests use X.224 Connection Request PDU.
http://msdn.microsoft.com/en-us/library/cc240470
http://207.46.16.248/en-us/library/dd644639
A X.224 Connection Request PDU has the following layout:
One Page Technical Resume/CV LaTeX/XeTeX template
To check DNS [updated 9/29/2010]:
http://www.squish.net/dnscheck/
…and more online….
dnstrace: debugging tool in djbdns
Men and Mice’s “DNS Expert” is pricy, but worth it if you’re cleaning up a lot of zones.
Microsoft’s free DNSlint with a demonstration and training webcast
Cryptoclans
Cryptoclans rock.
This Perl script takes as input a pipe-delimited file where:
- each line is a puzzle
- the first field is the topic
- each additional field is an item
Try it with family member names, favorite meals, old pets, whatever. Note that a character might be the same in plaintext and ciphertext. I may change that later.
Download cryptoclans.txt
Schrodinger’s Cat Ate My Homework
Schrodinger’s cat ate my homework.
Windows Embedded Standard Partial Updates with IGEL Thin Clients
Assemble your tools:
- Download the Partial Update manual, the LUNA Reference Guide, and the catalog sample from the Manuals.
- Download samples from the Hotfixes and Samples pages.
- If you don’t have a suitable text editor, try Notepad++, which has syntax highlighting for Lua scripts. Lua for Windows (below) includes the IDE SciTE, as well [and switch it to a monospace font...].
- Visit the Lua scripting language main website and download Lua for Windows.
- Order “Programming in Lua (2nd Edition).” It may be overkill, but there’s no sense being half-assed about it.
- Download OpenSSL for Windows to compute your MD5 hashes required for file copies.
Example script to install Flash 10.1, slightly modified from sample scripts.
To determine your local phone carrier:
Dial 00
To determine your long distance carrier:
Dial 1-700-555-4141
Ingredients
- 1 1/2 lbs ground beef
- 1 onion chopped
- 2 Tsp sugar
- 3/4 Tsp black pepper
- 1/2 cup chopped green bell pepper
- 1/2 cup chopped red bell pepper
- 4 Tlb chili powder
- 2 Tsp garlic powder
- 1 15oz diced tomato with green chiles
- 1 15oz can crushed tomatoes
- 5 15oz can chili beans
- 1 package chili mix
Directions
Cook ground beef with onions, peppers, garlic powder, pepper and season salt (mystery ingredient?).
Drain and add dash of chili powder.
Add chili mix with beans and warm on low heat. Add sugar and pepper. Cook 10 minutes.









