Tuesday, 24 December 2013

Quality Learning

What is learning? More specifically, what is quality learning in the context of software engineering? According to Kimble (1961), learning is the relatively permanent change  in response resulting from extended practice. Ritter et al. have published a paper on Learning and Retention, retention being one of the key characteristics of "quality learning".

Ritter explains that one of the consequences of "quality learning" is being able to perform a task faster the more times you do it. The task could be computer related, mathematics related or even writing books.

Ritter refers to Rasmussen 1983 for a theory of learning: consisting of declarative knowledge acquisition, proceduralisation followed by "skill tuning" (also known as the "autonomous stage"). At this point, users are considered to be "experts".

It is worth contemplating the work of Rasmussen and what motivated him to develop his theory of learning. Jens Rasmussen was a Danish engineer known for his work in "safety science". His theory of learning was adopted in Reason's book "Human Error". The area of study is sometimes referred to as "human factors" or more colloquially, HCI.

ITIL - Who Owns it? What are the Core Concepts? Service Delivery vs. Service Support.

The ITIL provides a set of practices for IT Service Management (ITSM). The official books are Crown Copyright (this is a specific type of copyright in the UK, officially defined under the Copyright, Designs and Patents Act 1988) and the acronym ITIL is a registered trademark of the Cabinet Office (again in the UK).

Two of the core parts of ITIL include IT Service Delivery (delivery of an IT service, including SLAs, recovery plans, expense tracking and financial management) and IT Service Support (which includes areas like Incident Management, Problem Management and Change Management).

Sunday, 15 December 2013

Proof Wiki

Pure mathematics is often used in proofs of program correctness. An interesting website aimed at demonstrating mathematical proof is ProofWiki.

Code Metrics in Visual Studio

MSVS can produce a number of software measurements. The "code metrics" are summarised in the following MSDN article. They comprise the folllowing:

* Maintainability index (high values are good, below 20 is bad)
* Cyclomatic Complexity
* Depth of inheritance
* Class Coupling
* Lines of Code

For more depth on cyclomatic complexity one can consult the original article by Thomas McCabe published in the IEEE Transactions on Software Engineering in 1976.

Wednesday, 11 December 2013

The Doubly-Linked List in C#

LinkedList in System.Collections.Generic is your friend - if you want bidirectional iteration.

Warning: Relevance of System.Collections.Specialized Diminished in a Post-.NET-Generics World

This namespace (System.dll) surfaced early in .NET 1.1. and the classes and structures have remained pretty much the same since. There have been some tweaks in terms of new interfaces and delegates, but by and large, this namespace has remained fairly static. In the post-.NET-generics world it's relevance has waned somewhat but it still contains some useful and interesting abstractions, for which even the .NET 4.5 programmer can achieve rewards.

Of all the classes, StringDictionary, a dictionary whose keys and values are strings, is the most easy and obvious to use, and maybe is a bit neater than using System.Collections.Generic in this specific case.

The namespace also has ListDictionary intended to have superior performance than a Hashtable for a small number of items (less than 10) by using a singly-linked list to implement the IDictionary interface.

.NET Subtleties: An Assembly's CodeBase versus its Location

CodeBase versus Location

The CodeBase property on the Assembly class gets the "original" location of a .NET assembly, for example, if an assembly was downloaded from the web, the CodeBase property would start with "http://".

The CodeBase property is not guaranteed to be set for assemblies in the GAC.  I repeat, the CodeBase property is not guaranteed to be set for assemblies in the GAC.

This differs from the Assembly's Location, which is where the assembly is currently at. Suzanne Cook's CLR notes are a great starting point to learn more about assemblies in a more coherent setting than just reading standard documentation.

Here's a Thing

Before you go writing code relying on the CodeBase property, take a moment to think whether your application may have the right "path discovery permissions" to actually query this property sensibly.

A Task Worth Doing

As assemblies are fundamental and unavoidable piece of the .NET ecosystem, understanding the Assembly class in System.Reflection is a task well doing.

Tuesday, 10 December 2013

Mastering WordArt in PowerPoint

To insert some fancy WordArt into your PowerPoint presentation, simply go to Insert in the Ribbon and click "WordArt". (Hint: it is in the "Text" segment of the Insert Ribbon area).

Ha, that was easy.

What's not so easy is knowing how to change the default properties on the WordArt. The first thing you need to be aware of is there are separate settings for Shape Properties and then for Text Properties.

Text Properties are easy, they basically determine what colors to use for the Fill, for the Outline and any fancy effects you want to add to the text, such as Shadow or Bevelled appearance. But even here there is subtlety. For example, for smaller WordArt you may find it visually appealing to have the Text Color and Outline set to the same color.

Shape Fill determines how the rectangle text box holding the text is rendered. If you want a see-through text box (i.e. you are overlaying text on a diagram which you want to still be able to see with the overwritten text) you need to set Shape Fill to be No Fill and Shape Outline to No Outline.

To rotate text, hit Alt and press the left and right arrow keys.

Now Text Size.The default text size is absolutely humongous. To bring it down to size, the Home tab in the Ribbon will allow you to adjust (e.g. 20 is quite reasonable, or if you have lots of these WordArts springing up around the place, 16 is a good size too).

Books and Resources on Software Design

So you want to become a legendary Windows software designer? Why not try reading some Unix first?

The design of operating systems can yield a rich source of knowledge and insights into software design. Take a look, for example, at:

The Design of the Unix Operating System, by Maurice J. Bach, first published in 1990, is a great book on how the Unix kernel has been designed and written, starting with an overview of the file and process subsystems, files and processes being core concepts in any Unix system. 

The beauty of this book is that it teaches you to think of the subsystems you need to create within the larger architecture of a software application in order to ensure conceptual scalability.

The book is also available on GitHub.

Monday, 25 November 2013

Targeting a Specific .NET Runtime using the Startup Settings Schema

This post highlights the power of the startup element in an app.config or web.config file. It is a must-know knowledge for any .NET aficionado.

The startup settings in an app.config or web.config file specify which CLR should be used to run the system.

The aforementioned settings appear in an element called simply startup. Within startup, we have two possible entries, one of which is deprecated.

The element includes the supportedRuntime and requiredRuntime elements. Each element has a version and SKU (from "stock keeping unit" in inventory management). The requiredRuntime is actually, to all intents and purposes, deprecated, and not meant to be used for .NET versions other than 1.0.

Note that if you have a configSections element in your configuration, this will need to come before the startup settings element.

Sometimes, you may see the startup element even at the end of a config file!

More rules regarding the configuration file schema can be found here. Another useful article oriented to .NET 4.5 development is the following.

Meet the "DAR-th Vader" of Entity Framework which tries to Dynamically Load All Assemblies

This is done via the EDM.DefaultAssemblyResolver when executing GetAllDiscoverableAssemblies. The EDM.DefaultAssemblyResolver (aka the "DAR") can also be likened to the Gollum in Lord of the Rings, at least as far as assemblies are concerned, using an "inspect-only" bind.

Some other useful methods to know in this process:

EntityConnection->GetMetadataWorkspace; returns a "metadata workspace" (or MW). The MW is created when an EntityConnection is created. Metadata is then loaded into memory and used by the EDM application to access information about the underlying data source. When GetMetadataWorkspace is called, the metadata is "locked". The docs for System.Data.Objects say that the MW is not CLS-compliant so will likely not be compatible across .NET languages.

Unfortunately, this metadata workspace sometimes seems to contain irrelevant information for the purposes of data connection.

Troubleshooting .NET Deployment - How the .NET Runtime Locates Assemblies

This is a summary of the msdn article focusing on deployment of .NET applications. To quote directly (capitalisation for emphasis):  "to SUCCESSFULLY deploy your .NET Framework application, you MUST understand HOW the CLR locates and BINDS to the assemblies that make up your application".

Additionally, the runtime, "BY DEFAULT, attempts to bind to the EXACT VERSION of an assembly that the application was BUILT WITH". It then adds that this behaviour can be overwritten in configuration settings.


JavaScript, CSS3 and HTML5 Could be the New Silverlight Slash De-Facto RIA Replacement

Critics say HTML5 will destroy Silverlight but this is only a half-truth.

Many Silverlight aficionados will not change the good habits they have learned writing MVVM applications for the web, and may instead adapt their skills to new JavaScript/HTML5 frameworks that borrow style and structure from the Silverlight world. So Silverlight will still live, even when all the Silverlight applications are gone.

Now the web developer must face the necessity to be familiar with at least one JavaScript framework such as Angular or Knockout. JavaScript graphics libraries such as Raphael and Bonsai, too, will become useful.

As an example of "Silverlight-similarity" amongst these frameworks, read about how data binding is done in Angular, to transform HTML and make it more XAML-istic.

Reflection-Only Load Context

Loading an assembly into a reflection-only load context, means loading it for inspection rather than execution (according to MSDN).  The load can be performed on a string, revealing the FQDN of the assembly, or an array of bytes, in the underlying COFF-format.

ReflectionOnlyLoad(string)
ReflectionOnlyLoad(byte[])

To load for execution, it must be loaded into an execution context. Note that dependencies are not automatically loaded in Reflection-only load.

Sunday, 24 November 2013

The MSIL Assembler - ilasm

The MSIL Assembler compiles IL code into a portable executable (PE) file. Its usage is as follows:

ilasm [options] filename

The options include flags for specific processor architectures e.g. /arm for ARM CPU, /itanium for Intel Itanium and /x64 for 64-bit AMD processor. Assembly of IL is essentially what a JIT compiler, such as csc, does.

Saturday, 23 November 2013

An Alternative to Threads: Tasks in Task Parallel Library

.NET 4 introduces an alternative to Threads, known as Tasks, which is part of mscorlib. This is the new and preferred way to do asynchronous programming in .NET.

Task factories are the new tool of choice to create Tasks (the new incarnation of Threads) and start them immediately. They can also be used to create task continuations. A continuation task is a task that invokes another task on completion. The task that completes before the next task is called is known as the antecedent.

A task can be created using the syntax:  Task.Factory.StartNew( () => ...).

The above syntax says we must supply a delegate as a lambda expression a.k.a. anonymous function, or object of type Action, to the StartNew method of the Factory object (default instance of TaskFactory).

The StartNew method returns an object of type Task.  Task.WaitAll takes a list of tasks and blocks until all the tasks specified have completed. It can be called with an optional extra argument, specifying the wating time timeout in milliseconds (stored as an Int32, implemented as a struct in mscorlib, though you already knew that).

Because now we are talking about tasks not threads, we can no longer talk about multithreading, and to talk about multitasking seems rather an over-use of the term. Therefore, we need a new term, and for that we have been given the new conjunction, Task parallelism. 

Friday, 22 November 2013

Asynchronous Programming in a Pre and Post Dot Net 4 World

Dot net 4 recommends using Tasks over Threads. But what vestiges of the pre-dot net four programming universe retain their relevance in the "dot-net four and above" programming world? For that we must turn to the interfaces of System.Threading.

IAsyncResult emerged as early as Dot net 1.1 in Visual Basic, C# and Managed C++, literally as the "return type of methods that implement an asynchronous operation". An IAsyncResult has a property AsyncState that contains information about the asynchronous operation. The boolean IsCompleted indicates whether the operation has completed.

gacutil

What TWO caches is the gacutil useful for exploring?

gacutil is useful for two things - viewing and manipulating the Global Assembly Cache, a repository for .NET shared libraries, and the Download Cache, which downloads "managed objects" referenced in the HTML object element in web pages accessed from IE.

Where is the gac located?

In the pre-Dot Net 4 world, the gac was located, by default, in %windir%\assembly.  In Dot Net 4 onwards, this moved to %windir%\Microsoft.NET\assembly.

What BASIC commands can be done using gacutil?

gacutil /l  -- list contents of GAC
gacutil /ldl  -- list contents of download cache

Wednesday, 13 November 2013

The Giga in Gigabyte and Gigahertz

From the Greek meaning Giant

Giga comes from the Greek word meaning "giant".

A Billion, A Thousand Million, or Ten to the Power Nine

It's a prefix in the metric system representing a "thousand million" or more colloquially, a "billion", or ten to the power nine, or ten to the power ten minus one. It was used in the film Back to the Future ("Wait a minute, Doc. Are you telling me you built a time machine..out of a Delorean?").

The Giga in CPU Clock Rates

Say, a CPU has a clock rate of 2 GHz. It means it has a clock rate of 2 billion Hertz. This is the "frequency" of the oscillator crystal (crystal oscillators produce sine wave signals with very precise frequency).

The Giga in Computer Speed

One Gigaflop is one billion floating point operations a second.

What's next after Giga?

After Giga, the next notch is Tera. A tera is ten to the power twelve or a million million a.k.a. a trillion. It has the symbol T. It is derived from the Greek teras meaning "monster".

Windows Kernel Memory Usage on a 32-bit Vista box vs. 64-bit Windows 7 box

In the 32-bit world, address space discipline is paramount. Vista dedicates 2GB of RAM to the Windows kernel, or fifty percent of the total virtual address space given to a 32 bit program (owing to pointers' addressing constraints). The other half is used by the thread currently running on the CPU. In the 64 bit world, kernel implementers can play more fast and loose with memory.

Dude, where's my RAM? Hint: Ask SuperFetch

The  RAM-guzzling nostrum known as SuperFetch, which some refer to a "kernel enhancement", made its Windows debut in Vista in 2007. Basically its concept is to cache frequently used applications or application data in memory to reduce boot time. Turn it off with services.msc - it's meant to speed things up, but instead can slow things down.

Tuesday, 5 November 2013

.NET 4 Security Model Acknowledges Mistakes were Made with CAS

.NET 4 changed *many* aspects of the .NET security model. One important change was the reducing the complexity of Code Access Security (CAS) by shifting responsibilities from the runtime to the developers. This certainly impacted code using Assembly.Load in System.Reflection (thank you mscorlib!)

The .NET Security Blog is definitely worth revisiting from time to time to get the latest download on .NET Security design decisions.

Saturday, 2 November 2013

WoW64

WoW64 (Windows-on-Windows 64 bit) allows you to launch 32-bit applications on all the 64-bit Windows versions with approximately 2% performance loss in terms of speed.

What was new in Windows 7?

Windows 7 may be old news now but it is worth recollecting what was new in this landmark version of the OS. First the basics:
  • Windows 7 is the successor to Vista, also known as Windows 6. 
  • Businesses are offered Professional, Ultimate and Enterprise versions on Windows 7. 
New features in Windows 7.
  • BitLocker comes with Windows 7 and is designed to protect hard drives from accidental loss or theft by encrypting the hard drive; it is available in Ultimate and Enterprise.
  • DirectAccess that allows you to work on Sharepoint documents on a remote computer without the traditional hassles of VPN.
Windows 7 has 32-bit (x86) and 64-bit (x64) builds and many organizations have chosen to deploy 64-bit builds for network future-proofing.

The AppData Directory in Windows and How to Keep it Clean

The AppData directory is Windows is a dumping ground for applications to store data. You can access it from cmd.exe using %appdata%.  Sometimes stuff you have uninstalled leaves stuff here so review it periodically and clean it up.

The AppData folder uses three locations for settings data:
  • Local
  • LocalLow
  • Roaming
Roaming profiles are typically (not always) copied from a central server to the Roaming subdirectory in AppData. Local is for local profiles, and LocalLow is for less trusted applications running on local profile. An example of something which might be in LocalLow includes JREs, Apple QuickTime and Adobe Acrobat.

The annoying thing is that the AppData directory is typically hidden on Windows, and even once you've located it, there are many hidden subdirectories.

Media files take up the most memory. Here are some typical offenders:
  • FLVService is one application that can rapidly occupy space in AppData.
  • AppData\Local\Microsoft\Media Player\Transcoded Files Cache: you'll be surprised how many tmp files get created here

Sunday, 29 September 2013

.NET AppDomains and why Threads are Special

.NET AppDomains and Their Relationship to Processes, Assemblies and Threads

An Application Domain , or AppDomain, in .NET, provides a boundary wall between running .NET applications, to enhance reliability and security. They are like discrete pinball machines.

AppDomains and Processes; Plus Points of Partitioning Arrangement

AppDomains are structured such that several of these domains may be run in a single process; in math terms, the process space is partitioned into AppDomain space i.e. can have several of these non-intersecting AppDomains that make up the process space. This avoids the "resident" applications from the overhead of making inter-process calls when they need to communicate (everyone is in the same process "locale").

AppDomains and Assemblies

A .NET assembly must be loaded into an AppDomain in order to be able to run. A typical application will load several assemblies into a single AppDomain.

AppDomains and Threads

A thread must run in an AppDomain, but has the ability to cross into other AppDomains. They are bit like electrons within atoms.(Thread.GetDomain will tell you what AppDomain a thread is currently running in).

Alt-V-O- The Output Window of Visual Studio

The Output Window in Visual Studio shows Output from the Build.

Alt-V-O is the shortcut to get it up - in case you have closed it by accident, or to create extra space.  If you find it hard to read, try clicking "Toggle Word Wrap" (the right-most button on the Output Window toolbar that looks like a "carriage return").

Writing a Function that Never Returns in C#

Unfortunately, there is no standard way of declaring this e.g. "public never FunctionThatNeverReturns()" is one possible syntax but is not part of standard C#.

In fact, it's not part of standard C++ either. However, some compilers, such as GCC, have a way to express this by declaring function attributes which are enclosed within double round brackets.

void fatal() __attribute__ ((noreturn)) { ... }

Unfortunately, adding this attribute does not mean the function will not return control to the caller in exceptional cases, e.g. when an exception is thrown or a longjmp is attempted.

vshost can improve debugging speed but can get locked!

The vshost file was introduced in Visual Studio 2005 to make debugging launch quicker. The vshost.exe that is created as part of your application is also known as the "Hosting Process". They are not designed to be run directly or included as part of a deployment. Its performance boost comes from having an application domain already created, that the debugger gets associated with.

Sometimes the vshost file gets locked. You need to close the Visual Studio with that project opened to unlock it.

Saturday, 28 September 2013

Don't Forget the Computer in Computer Science

As Peter Norvig, author of "AI - A Modern Approach" reminds us, we should not forget the "computer" in computer science. For example, having a handle on how long branch misprediction takes on a "typical" PC (hint: it's in nanoseconds), or a fetch from an L1 cache versus a fetch from an L2 cache (hint: big difference). We might note that mutex lock/unlock is pretty expensive in contrast to the aforementioned operations.

Monday, 23 September 2013

The Standard Way to Install a Windows Service from the Command Line

Step One: Open a command window with Administrator privileges. Cd into the appropriate .NET framework directory probably C:\windows\framework\microsoft.net and so forth. Run installutil on your exe and you're done! Installutil /u does an uninstall - in case you change your window.

Sunday, 25 August 2013

The Grid: What it Means in a New WPF Application

Grids within Windows

When you wizard-up a new WPF application, and look at the MainWindow's XAML, you expectedly see a beginning and ending Window tag, which comes as no surprise given that the Window class is clearly fundamental to Window Creation.  Within these Window tags, you see Grid tags. Now this you might be less familiar with.

Now I will tell you some quick facts that you already know. The Grid class is part of System.Windows. Controls, and came about in .NET 3.0 and is also included in Silverlight. This is pretty much true for just about any of the early WPF Controls, so nothing deeply insightful about Grid just yet.

What Grids Actually Are

Now for the revelation. A Grid is a Panel (just like a StackPanel or any other Panel) that inherits from teh abstract class Panel (System.Windows.Controls.Panel to give it its fully-qualified form). Many of its properties come from earlier classes in the hierarchy. Unless you know the classes in the hierarchy well you will have a difficult job knowing what is unique to Grid, and what is just inherited members.

Positioning Controls in a Grid using Attributes

A Grid allows you to create Grid.RowDefinitions and Grid.ColumnDefinitions using RowDefinition and ColumnDefinition tags respectively.Then each control will have Grid.Row=X and Grid.Column=Y in their attribute chain.

All you wanted to know about WPF (and Silverlight) StackPanel..

StackPanel is a bit like a ToolBar that instead of going from left to right or right to left, goes top to bottom (in the default case). Although a StackPanel is actually more flexible..as it can also go from left to right, simply by setting the attribute Orientation="Horizontal". As common with WPF controls, this one has been around since .NET 3.0 and is also included in Silverlight. It inherits from System.Windows.Controls.Panel which inherits from System.Windows.FrameworkElement (from PresentationFramework.dll).  Interestingly, the same inheritance structure is true also for Silverlight! However, the dll in which is class is contained is quite different (System.Windows.dll).

What do you know about ToolBar programming in WPF?

The WPF ToolBar has been around since .NET 3.0. It contains buttons (often with images) that invoke commands.  A ToolBar is often located within a ToolBarTray. The ToolBar is given a Band, which is an integer that indicates its position within the ToolBarTray.

Saturday, 24 August 2013

K32GetModuleInformation - could not be located in DLL KERNEL32.DLL

Happens on install of Visual Studio 2012 Express.

Wednesday, 21 August 2013

The readonly keyword in C# (and its similarity to adjectives)

This keyword, or more precisely a modifier, is that acts as a piece of in-code documentation. The readonly keyword says the member variable is initialized only on first declaration or in the constructor; nothing else can set the variable. It does not offer performance gains.

The const keyword on the other hand indicates a variable can only be initialized at the point of declaration. It is thus more restrictive than the readonly modifier.

Note that in-code documentation in the form of modifiers generally have to be verifiable by the compiler at compile time; this is one of the unwritten design rules of C#.

A modifier is anything used to modify the declaration of types and type members. An example modifier on a class is the partial modifier. Access modifiers comprise private, public, internal and protected.

Static is a modifier we hardly even think about; we use it so often in coding. Modifiers are like adjectives (e.g. the "blue" boat, the "static" void method).

Wednesday, 24 July 2013

John Carmack on Focus

Focused, hard work is the real key to success. Keep your eyes on the goal, and just keep taking the next step towards completing it. If you aren't sure which way to do something do it both ways and see which works better.

Focus is a matter of deciding which things you're not going to do.

Programming

Windows programming in C# is great, but hear the advice of programming greats, to understand why it is necessary to alternate technologies every once in a while.

"I am a big proponent of temporarily changing programming scope every once in a while to reset some assumptions and habits" - John Carmack, co-founder of id Software

"Low level programming is good for the programmer's soul" - John Carmack.

"You are only competent one level below your training" - Anon.

Sunday, 30 June 2013

System.InvalidOperationException

The exception that is thrown when a method call is invalid for the object's current state.

It inherits from System.SystemException.

It has many child exceptions, such as System.Net.WebException.

Thursday, 27 June 2013

Relational Databases

Thanks to Edgar Codd

Relational databases are built on the concept of relations, which are basically tables. Another way of explaining what a relation is, is a row/column format for storing information. The relational database was first defined in 1970 by Edgar Codd of the IBM San Jose Research Lab (first West Coast research lab for IBM).

Tuples, Attributes and Relations

In the jargon of relational databases, a tuple is a row, an attribute name is a column name, a relation is a table (a set of tuples with the same attributes).


Thursday, 20 June 2013

More mscorlib: System.WeakReference

System.WeakReference references an object while still allowing it to be GC'ed.

Thursday, 30 May 2013

Ambient Transaction

System.Transactions.dll supports transaction-oriented programming in SQL Server, ADO.NET, MSMQ. The core abstraction is the IDisposable Transaction class. An implicit programming model is also supported via the TransactionScope class. This is where you will start hearing terms like "ambient transaction context".

Saturday, 18 May 2013

Good Books on Active Directory, Network Operating System and Cloud Computing

Active Directory, 5th Edition, May 17th 2013, O'Reilly, Brian Desmond, Robbie Allen et.al. - recommended reading. A great book on all things Active Directory.

For wider reading on network operating systems, and how they might change with the cloud, Barrie Sosinsky's books are good ones to dive into:

Networking Bible, Barrie Sosinsky, September 2009, John Wiley and Sons (almost a thousand pages of networking goodness)
Cloud Computing Bible, Barrie Sosinsky, January 2011, John Wiley and Sons

Active Directory Programming in .NET and the Concept of the "Network Operating System"

Programming the Active Directory

Directory Services are a specialized part of .NET and thus the API functionality is contained in its own dedicated DLL (System.DirectoryServices.dll).

AD programming, specifically, can be done via the System.DirectoryServices.ActiveDirectory namespace which provides access to the ADSI, although DirectoryServices provides access to a wider range of directory services, such as NDS (the Novell NetWare directory service).

ADSI is the name of the programmatic interface into Active Directory. Admin tasks such as backing up databases, testing printers and administering user accounts can be done via the ADSI (Active Directory Service Interfaces).

Evolution of Directory Services

Here is an interesting comparison of AD versus Novell NetWare. More interesting than the comparison, is the discussion of the evolution of directory services, from a "white pages" service of people on the network, to a way to access network resources such as printers, and apply security permissions. AD thus has quite an impressive scope. There is also the provision of "directory-enabled infrastructure" such as shared file systems.

Some people call this the "NOS" or Network Operating System. Windows NT introduced the notion of "domains" (security and administrative boundaries within the network) and the related notion of "domain controllers" (administrative services in the "NOS").  There were certain limitations in the initial releases of Windows NT (such as domains supporting only a maximum of 40,000 objects - users, groups, computers), causing Microsoft to later embrace the LDAP standard in the design of new technology.

X.500 DAP and Some of its Limitations (Directory Server Technology from late 80s to late 90s)

In 1988, the ITU and ISO came together to develop the X.500 model for directory services, based on the OSI model (rather than the more lightweight TCP/IP). This led to the development a more lightweight version called LDAP. Version 3 of LDAP was published in 1997.  LDAP-based directory servers have been developed by many vendors including IBM, Microsoft and Novell.

Basic X.500 Concepts and Terminology

X.500 refers to Directory System Agents (DSAs) i.e. directory servers, each holding part of the Directory Information Base (DIB). The DIB objects are structured by a Directory Information Tree (DIT). As LDAP emerged, the first LDAP-based servers were gateways into X.500 servers, before the trend came to break away from X.500 altogether.

Active Directory Concepts

The basic structuring concepts in AD are DOMAINS, DOMAIN TREES and FORESTS. This is the logical structure of AD. Domains in AD consist of a hierarchical structure of containers and objects, like in X.500 and a DNS name as a unique identified (e.g. techno.com). Adding europe.techno.com and asia.techno.com would create a hierarchical structure called a domain tree. Domains in a domain tree trust each other via transitive trusts (if A trusts B, B trusts C, then A trusts C). A FOREST is a collection of one or more domain trees. Domains are administered by domain controllers.

Time Synchronisation in the Forest

 This is based on Network Time Protocol (NTP).

Thursday, 16 May 2013

Directory Services - the "White Pages" of the Network

Directory services provide detailed info about users or objects on a network. Early examples include the WHOIS service. Later in the 1990s came Novell Netware. Then came LDAP, which was designed to run on TCP/IP. AD was designed to run on LDAP.

Some abbreviations needed to understand the LDAP specification:

TLS - Transport Layer Security
PDU - Protocol Data Unit
SASL - Simple Authentication and Security Layer

AD technology is a shining example of Microsoft confidently embracing Internet technology such as LDAP and TCP/IP. AD also borrows a lot of concepts from the X.500 directory structure.

What is wusa.exe?

wusa.exe is the Windows Update Standalone Installer. It lives in %windir%\System32. It is available on Windows Server 2012 as well as Windows 7 and 8. It is used to install "update packages" with .msu extension.

Windows Groups and Roles - A Peaceful Coexistence

Ah, the dilemmas of enterprise authorization! Groups, or roles, for my permissioning, groups or roles, I query? The two need not be conflicting, necessarily.

Roles have the positive externality of existing outside of Active Directory (AD). Because they are external to AD, they can be flexibly employed to allow authorisation of any system.

They can work together by making membership of the role a group! Then update the group to give everyone in the group that role! Amazing!

A Windows Cloud in the Azure Sky (backed by Solid Data Centers)

Windows Azure has had a lot of publicity of late, as Microsoft's flagship cloud platform, the latest nuance in its PaaS offering (Platform as a Service). In PaaS, the platform provider provides the data center facilities and tools to deploy applications.

Locations of Azure datacenters include San Antonio, Texas (a migration of their Quincy, Washington site), Hong Kong and Dublin, Ireland. A good way to track datacenter activity is the site datacenterknowledge.com.

net group

The Power of net group (a.k.a. net groups)

This command is used to manage groups in Windows domains.

e.g. net group __groupname__ /add

will add the __groupname__ to the domain.

Without parameters, it displays the name of a server and the names of groups on that server.

The Limitation of net groups

However, one should be careful. This command is only used for global groups; there is a corresponding command, net localgroup, for local groups. Note the singular, localgroup, not localgroups.

The nice thing about net localgroup is you don't need to be on a domain controller for this to work. You can run this command on any Windows PC. Some familiar local groups include Administrators and Event Log Readers.

This command can only be used on a Windows domain controller!

The Domain Controller lingo hails from the world of Microsoft Servers. In NT Server, one controller was configured as the Primary Domain Controller with the others being mere BDCs. Updates such as password changes and group membership could only be made via the PDC which would then propagate changes to all the BDCs responsible for authenticating users to the domain. From a DR perspective, if the PDC were to go down, a BDC could be promoted to PDC status. PDCs are recommended to be on dedicated machines running nothing else owing to their critical nature.

Windows Joe Knowledge Base

These days a Modern Windows Joe (MWJ) needs to know more than just .NET programming. And knowing .NET programming requires more knowledge than just syntax and keywords. Here are some CONCEPT areas that Windows Joe needs to be fully familiar with:

DATABASES
COMPUTER SECURITY, including DATABASE SECURITY
NETWORKING PROTOCOLS
DIRECTORY SERVICES

These topics can be classified as the "broader body of knowledge" (BBOK) required by a Windows Joe/.NET programmer. Additionally, the following WINDOWS SYSADMIN skills are useful:

How do you administer a Windows Server? (e.g. what commands can you, or might you, want to run on a domain controller)
How do you administer Scheduled Tasks?
How do you administer a Database?
How do you maintain an Active Directory install?

TOOLCHAINS (e.g. for continuous integration, unit testing).

Recognised Security Tomes and Resultant Concepts

Recognised security tomes include:

Bruce Shneier's Applied Cryptography

and "The Rainbow Series" which include requirements for systems that process sensitive information:

The Orange Book - nickname for the TCSEC (Trusted Computer System Evaluation Criteria), mandates a Security Policy to be defined for the computer system. The security policy must be "explicit, well-defined and enforced".

An interesting concept that the Orange Book refers to is the distinction between Mandatory and Discretionary Access Control. Mandatory Access Control impose limitations on "subjects and objects" whereas Discretionary Access Control is more focused on individual user access needs (and access control based on the "groups" to which they belong). The Orange Book doesn't discuss specific implementation abstractions of these concepts though.

The Rainbow Books came out of a recommendation by a Task Force set up in 1967 to analyse computer security safeguards to protect sensitive information. These concerns relate not just to building secure systems, but evaluating and auditing them as well. The Orange Book addresses these dual concerns.

There is also a set of Compact Disc format specifications also known as "The Rainbow Books" (including the 1988 CD-ROM format specification, 1993 VCD Specification).

Role-Based Access Control (RBAC)

A computer systems concept, RBAC (or role-based access control) is a system of restricting access to computer resources (also known as role-based security).

SQL Server Security - Unleashed

What you Will Learn

What server principals are
What types of server principals there are
What schema to query to access the "principals" list!

The Low Down on SQL Server Security

An average Windows Joe needs to know something about databases, and SQL Server databases in particular. But you can't claim to be a database know-it-all without knowing "un peu" of SQL database security, in particular the concepts of Principals and Securables.

A great book to accelerate your learning about SQL Server Security is "SQL Server (2008 R2) Unleashed" from SAMS Publishing (famous for their "Unleashed" series and "How To" books). The concepts are well-presented and can save you time before diving into specific details strewn across the MSDN jungle.

Speaking of concepts, let's introduce the most basic ones; requestors of resources, resources and permissions. Turns out, these concepts have a rather different terminology in the SQL Server worldspace.

1. A Requestor of a SQL Server Resource is henceforth known as a Principal.  These principals may be Windows users, SQL Server users and so forth.

2. A SQL Server resource is henceforth known as a Securable.

3. Permissions link Principals with Securables.

But you can't know-it-all about SQL Server databases without having some tools to practice with. For this, the SQL Server 2008 R2 Management Studio is an excellent choice.

Some simple queries to get you "synced" with the SQL Serve Security spirit:

1. select * from sys.server_principals

This so-called "catalog view" in SQL Server (nothing more than a "window on metadata") identifies all "server-level" principals and what type they are; an example would be the "sa" account which has type "SQL_LOGIN" (and incidentally cannot be removed). Other types include WINDOWS_LOGIN (self explanatory!), WINDOWS_GROUP and SERVER_ROLE. All are types of PRINCIPALS in a SQL Server database.

However, there is another, less documented type of "server-level" principal, the CERTIFICATE_MAPPED_LOGIN. Some systems use digital certificates as an additional means of authenticating users.

Wednesday, 8 May 2013

log4net

log4net is a port of log4j, part of the broader Apache Logging Services project (incorporating log4php and log4cxx).

Tuesday, 30 April 2013

Remove Hyperlinks from Excel 2010 Worksheet (Hint: Eraser Dropdown)

Select the cells with the offending hyperlinks. Click the Home tab in the Ribbon, and the Editing subsection $(or Editing "Group"). The Ribbon is made of groups e.g. Font, Alignment, Number, Editing. Click the "Eraser Dropdown"and select "Clear Formats" (NOTE: NOT Clear All as this will delete the hyperlink text as well).

Thursday, 25 April 2013

Simply Snassie - The Story of Strong Named Assemblies in .NET

Quick Question: What is a strong-named assembly (Snassie, or SNA) and why do you need it?

Do you know the answer? Read the next section to find out more!

Strong named assembly (SNA) = Assembly SIGNED with a STRONG NAME

A Strong-named assembly is simply an assembly - SIGNED with a strong name (containing amongst other things, a digital signature). Perhaps a more apposite name might have been, Strong SIGNED assembly (SSA).  SNA in this context should not be confused with IBM's SNA (Systems Network Architecture, a protocol stack for networking, introduced in 1974).

STRONG NAME may contain Culture Information, and WILL contain PUBLIC KEY and DSig

The strong name is like the "unique id" for the assembly; comprised of its text name, version number, culture information (if applicable) plus public key and digital signature. Think of it as a STRONG character name in a movie, like Dr Hans Zarkov, or Ming the Merciless, in the Flash Gordon movie (1980), and the digital signature being a component of the strong name e.g. simply Hans, or Ming.

By the way, I generally don't sign my assemblies. Why do I need to understand strong-named assemblies?

As it turns out, reading MSDN articles on .NET Security won't make a load of sense if you don't know what strong-named assemblies are. Further, at some point, you are bound to encounter an exception somewhere or other that requires you to understand what Snassies are from A-Z.

What other things do I need to know about SNAs?

A strong-named assembly can only reference other strong-named assemblies.

Remind me how digital signatures work.

A digital signature verifies the integrity of data passed from generator to recipient (a.k.a. the "verifier"). The verifier has access to the sender's public key.

What's the underlying algorithm for generating signatures in this SN infrastructure.

Strong names require public key cryptography. This begs the question: Quelle Algorithme?  Currently, the SN implementation used the RSA public key algorithm and the SHA-1 hash algorithm (SHA=Secure Hash Algorithm).

Tuesday, 16 April 2013

The Programmers Automation Cost-Benefit Decision

One of the daily decisions programmers confront is whether it is worth automating certain mundane tasks, particularly with regards to systems support. The upfront time expense in automation may bring long run benefits, but may delay short term projects. If the latter, then serious thought has to be given to whether automation should be attempted, with mindfulness not to put important deliverables "at risk". Oftentimes, many desirable automations must be put on the back-burner to achieve higher priority deliverables. These projects can then be picked up opportunistically during any "idle time" that may arise.

Keeping Pace with the New C++ and the Expanding Lexicon of Lvalues

Reading the "Standards committee" papers is one way (open-std.org) to keep in touch. The latest draft standard can be found in pdf format here.

One example of how things change is the new nomenclature of lvalues and rvalues.

In TCPL, an lvalue is simply "something on the left-hand-side of an assignment".

In C++0x, semantics change.

A glvalue is now a "generalised lvalue" denoted either an "lvalue" or an "xvalue".

An lvalue now means a function or an object, and an xvalue is an object near the end of its lifetime (short for "eXpiring Value").

An "rvalue" now means, more precisely, an xvalue, a temporary object (or sub-object of the same such) or a value not associated with an object.

A "prvalue" is an "rvalue" that is not an "xvalue".

The Sooner you Begin Coding the Later You Finish

Some managers pressure programmers to begin coding too early. This can result in the wrong thing being built and huge wastage in terms of wrong coding and rework. As Bjarne states: "the most important thing in software development is to be clear about what you are trying to build".

Sunday, 14 April 2013

ISO 3166 Country Codes for Programmers

Two letter standard country codes are given by the ISO 3166-1 alpha-2 standard.

US - USA
GB - UK (taken from United Kingdom of Great Britain and Northern Ireland)
GG - Guernsey
JE - Jersey
GI - Gibraltar

66 is the 11th triangular number, 31 is prime. Alpha-2 standard is used in BICs (Bank Identifier Codes) and ISINs (International Securities Identifying Number).

The Castle Project

Castle is an umbrella for various open source projects in .NET, the most recognised one being Windsor. It's an IOC container. It also includes nVelocity, a .NET fork of the Velocity template engine.

Tuesday, 9 April 2013

System.dll versus mscorlib.dll

The difference - mscorlib is tightly bound to the CLR whereas System.dll is not. The CLR and mscorlib must be versioned together.

You've got your basic data structures (such as Dictionaries) and threading constructs defined within mscorlib. It's an integral part of the CLR.

Getting Timings in C#: System.Diagnostics.Stopwatch

Use System.Diagnostics.Stopwatch to measure run times.

You can create a Stopwatch amazingly using the StartNew static method that actually returns a Stopwatch object. This also sets the elapsed time property to zero.

When you want to stop the Stopwatch, all you do is call Stop, which tells the Stopwatch to stop measuring elapsed time.

You can get the elapsed time by calling Elapsed which returns a TimeSpan object or ElapsedMilliseconds which returns the milliseconds elapsed as a long data type (which is just "syntactic sugar" for a System.Int64).

Wednesday, 27 March 2013

What is a CLSID?

A CLSID is a globally unique identifier that identifies a COM class object.

Thursday, 21 March 2013

Advanced Resharper

Find implementation of an interface

Cntrl-E-H

ints, shorts and so forth

Saving Space

int - 32 bit
short - 16 bit
ushort - 16 bit unsigned short

Restart a Computer in Remote Desktop

shutdown -r -t 0 -f

-t time to wait
-f force
-r restart

Debugging Multithreaded C# Applications

You need:

Debug -> Windows -> Threads.

Note that the Threads Debug window is not available in Visual Studio Express Edition.

Does Python have any place in the .NET programming maelstrom?

Good for prototyping on paper; reasoning things out - especially very complex or mathematical algorithms - good short and clear syntax. Best language for algorithm expression. But for mainstream development, stick to C# (or C++ for specific purposes).

System.Threading.ManualResetEvents

Implement blocking waits

Used to notify one or more threads that an event has occurred.

WaitOne(timespan) - blocks current thread until it receives a signal within the timeout interval.

Resharper and Visual Studio Shortcuts

Find Usages

What's the FASTEST way to do "Find Usages" in Visual Studio?

Shift F12 (Resharper)
Cntrl-K Cntrl-R (Visual Studio shortcut)

MSVC shortcut is quicker. You can type: Cntrl K and Cntrl R, or just Cntrl-K-R (3 keypresses).

Go to next member

Alt-UP, Alt-DOWN (Resharper)

Find Type 

Cntrl-T (Resharper)

Find File or Folder  

Cntrl-Shift-T (Resharper)

Duplicate a Line

Cntrl-D

Tuesday, 19 March 2013

IIS 7s Managed Module Architecture

IIS 7 (and above) has its functionality divided into managed modules (a.k.a. assemblies). The assembly can contain .NET code or Win32 code ("native code"). Functionality can be extended by creating custom managed modules.

The Future of ISAPI in IIS version 7.0 and Above

ASP.NET applications now run completely in IIS 7.0 without using ISAPI extensions that run in an "ISAPI process" - although this is still supported when running a web application  in "Classic Mode" (rather than "integrated pipeline" mode). "Classic Mode" can be used for compatibility with older applications.

Good Books to learn Microsoft Web Technology

"ASP in a Nutshell" (published in 2000 by O'Reilly) is a good introduction to the "pre-.NET" web programming era. Certainly it is worth reading just to know the concepts that led to more fancy ASP.NET and all the other technologies that followed.

"Professional IIS 7.0" (published in 2008 by Wrox) is an awesome introduction to the new features in IIS 7.0 and what sets this ground-up rewrite apart from previous versions of Microsoft's flagship web server product.

Building Better IIS Servers using ISAPI Filters

What are they used for?

ISAPI Filters are simply DLLs (ISAPI stands for Internet Server API - Microsoft's answer to CGI applications).

How are they written?

ISAPI Filters are used to modify and expand the functionality of IIS. Both ISAPI filters and extensions are developed in C++.

How do they work?

Suppose you have an HTTP transaction between the browser and IIS. Several events may be generated in this process. Some of the these events may be subscribed to by "filters". Filters will be applied in the order of priority. If the event relates to the filter, IIS knows that it has to invoke the HttpFilterProc entry point. The filter can then do some custom processing.

Notable Examples

ASP technology is implemented as an ISAPI filter (DLL that gets loaded up into the same memory space as IIS).

Related Tangent: What EXACTLY do we mean by CGI? CGI stands for Common Gateway Interface. It's a method for for web server software to delegate generation of web content to executable files. A variation called FastCGI is implemented by a number of web servers such as Apache, Cherokee and IIS.

Saturday, 16 March 2013

BITS, BFE and other "Standard" Windows Services

BITS is a Windows service, that stands for Background Intelligent Transfer Service. This helps to transfer files in the background using idle network bandwidth. It is used by Windows update and Internet Explorer.

BFE is the Base Filtering Engine which manages firewall and IPsec (Internet Protocol security) policies. Stopping or disabling the BFE service will significantly reduce system security.

Related Tangent: What is IPsec? It's a suite of protocols for authenticating and encrypting information at the IP packet level. Developed in conjunction with IPv6. Its major application is in Virtual Private Networks.

IIS_WPG Group

The IIS_WPG user group is new in IIS 6.0. This provides the minimum set of privileges and permissions needed to start a worker process on a web server.

If a worker process is not in the IIS_WPG group, or have the equivalent permissions, that process will not start.

Tuesday, 12 March 2013

NTFS Debunked

It's been a while since Windows Joe talked about NTFS. Today, "Win-Joe" debunks the complex jargon surrounding this file system technology.

The NTFS technology was preceded by a system called FAT (File Allocation Table).

You need this to understand output from CHKDSK (outputs file system integrity status).

USN JOURNAL

Update Sequence Number Journal.  Records changes on NTFS volumes.

The above must be explained. NTFS is a journaling file system which means changes are recorded in a journal (typically a circular log in a dedicated area of the file system).

Sunday, 10 March 2013

Chemical Processes as Analogies for Software Design

We analyse two physical/chemical processes as useful idiomatic templates for programming.

Decanting
Filtration e.g. filter paper -> semi-permeable membrane placed perpendicular to liquid or air flow.  Tea bags are also filters.

Wednesday, 20 February 2013

Respect for Base Libraries

Always in projects look for opportunities to build up a strong set of base libraries. Even if you are writing throwaway code, may be some one-off testing application that tests something you've built, if there are some functions that can be "outsourced" to a base library, take the opportunity to do so. That way, your base libraries will mature and develop until all application development becomes a trivial task.

Friday, 8 February 2013

Storing C# Strings in an Oracle Database

This is not an Oracle blog, and Windows Joe has no intention of turning it into such. However, since Oracle coding is occasionally required by the Windows programmer, occasional clarifications on the aforementioned technology are sometimes warranted.

In addition, such posts may be of interest to database enthusiasts wanting to refresh the basics.

One such, is the popular newbie question (and also asked by experienced bods who haven't touched Oracle in a long time) is what datatype to use for string data?

VARCHAR - not to be used. Why - because Oracle says so. It may work, but is not recommended.
VARCHAR2 - the recommended way to store strings (or more precisely, VARIABLE LENGTH character strings).
CHAR - for fixed length character strings.Using this type to store variable length strings is a waste of space.

So in 95% of cases, you need a VARCHAR2 to represent strings in an Oracle database.

If in Doubt, Write It Out

One can borrow this adage from mathematical problem solving, to solving difficult programming tasks.

Sometimes a task is difficult not because it is intellectually difficult per se, but due to the fact that it requires tracking of very precise details e.g. when writing code to transform one peculiar date format to another data format. In this case, the visualisation of the data may be different, but also be semantically different e.g. if going from a super-precise representation (say, one which captures picoseconds) to one which has lower information content (e.g. rounding to nearest second).

In this case, explicitly writing out the various layers of the problem in a Word document may be your best bet to programming an accurate solution quickly and effectively.

Note: pico = 10^-12 (next notch up from nano = 10^-9).

Learning the MAXIMUM from Every Implementation Task

Software is REPLETE with tasks that can be classified as "mere implementation". In these tasks, there is no sophisticated algorithmic development, no calculations of time or space complexity. There is just the coding: which might be C#, might be SQL, or something else. Maybe you've done a dozen similar implementations. But there is always more that can be learned, for example, reviewing how the task, once accomplished, fits into the greater whole. Not seeing the task as a task, but a component of a greater whole. REMEMBER, the whole is greater than the sum of its parts (Aristotle, Metaphysica).

The Art of Remote Desktop


Logging Another User Off

Log in to another remote desktop machine ON THE SAME DOMAIN:

quser /server:[server name]
logoff [session id] /server:[server name]

quser will return the USERNAME, SESSIONNAME and ID (Session Id) which you can use in the logoff command.

View tasks on another machine

tasklist /S [server name]

Tuesday, 5 February 2013

Where is Sort on the Crazy Excel Ribbon?

It's on the Data tab (just after Page Layout and Formulas). You will see a Sort icon which looks like a box with A|Z Z|A written on it. It's in a "frame" in the Ribbon called "Sort & Filter".

Thursday, 31 January 2013

How to I put a Unicode Character in my C# String?

Answer: Use a Unicode character ESCAPE SEQUENCE - representing a SINGLE Unicode character. C# uses a 16 bit character encoding for Unicode code points. BACKSLASH U.

Unicode codes are all here. To use in C#, lower-case the U and remove the + sign.

Example:

public static string sigma = '\u03C3'.ToString();

Maths requires use of "Greek and Coptic" character subset of Unicode, Coptic being an adapted Greek alphabet that was being used in Egypt.

Saturday, 19 January 2013

What is Software Science? Let's ask Sedgewick.

What's the latest book on software science you have recently read?

Wait - first off, what IS software science?

If you had to teach a course called software science to cover the more scientific aspects of modern computing, what would it include? Probably the following:
  • basic algorithmic knowledge, like how to analyse an algorithm (time complexity and space complexity - yes this is still important, e.g. when programming for small devices) and the classic algorithms like quicksort and bubblesort, what their characteristics are
  • basic knowledge on audio compression technology like MP3 and Ogg Vorbis and the underlying concepts
  • working knowledge of maths underneath RSA and other cryptographic protocols and algorithms (prime numbers, number theory)
  • basic computational physics for use in programming physics engines and ray tracers used in game development
What are the "great tomes" of software science?

Consider the first category of "basic algorithmic knowledge". Robert Sedgewick's 1983 tome simply-named "Algorithms" is always a firm favourite with students, and even covers a bit of linear programming as well (albeit under "Advanced Topics). There is also a fantastic book called "Computer Algorithms C++" by Ellis Horowitz (University of Southern California) and Sartaj Sahni (University of Florida) and Rajasekaran Florida) published in 1996, which delves quite nicely into parallel algorithms also, which is getting more fashionable with the whole Google map-reduce malarkey.

Caveat: Sedgewick says you probably need about a year's worth of programming experience to get the most out of his book.

In terms of audio and multimedia technology (one of the areas of computer science strongly influenced by maths and more traditional engineering disciplines, like electronics engineering) most of the information can be gleaned from the web but there are of course books available too. One such is Digital Audio Signal Processing, Udo Zolzer, Wiley, 2008 (the book has been described as "useful" but not very accessible).

For RSA, Shneier's Applied Cryptography is a must (highly praised by Dr. Dobbs Journal when it first came out). For computational physics, try: David Eberly's Game Physics, 2003. To get the most out of this book, you really need to get psyched about mastering Newtonian and Lagrangian dynamics.

Ogg Vorbis Sound Files

What are Ogg Vorbis sounds files a.k.a. .ogg files? Ogg Vorbis is an audio compression format comparable to MP3. Ogg is a container format for audio, video and metadata maintained by xiph.org. Vorbis is the specific audio compression scheme used.

According to the Vorbis technical specification, the codec is based on the Modified Discrete Cosine Transform (MDCT) which is also used in the MP3 format. Vorbis is, however, computationally simpler than MP3 but requires more working memory.

Wednesday, 16 January 2013

WPF Docking with Avalon Dock

Avalon Dock brings docking to W-P-F - Awesome! Check it out on CodePlex - Microsoft's free open source project hosting site!

Wednesday, 9 January 2013

Four Octets - Demystifying Networking Jargon

An octet is basically 8 bits. The term is used in telecommunications, particularly when referring to IP addresses. An IPv4 address is referred to as "four octets", usually represented by decimal values from 0 to 255, for example: 255.255.255.255 (the highest representable IPv4 address). This is known as "dotted-decimal" notation. Maximum number of addresses is 2^32 or 256^4 = 4.29 billion.

TCP/IP Concepts for Windows Programmers

Everybody claiming to be a Windows Joe should know the basic concepts of TCP/IP.

The TCP/IP "Reference Model"

The TCP/IP "reference model" was based on an older "reference model" known as the OSI Reference Model, which was, in comparison, very complicated, made up of seven layers from the Application to the Physical layer. TCP/IP came and it was simpler: declaring Application, Transport, Internet and Host-to-Network as the four major layers. Understanding the reference model, gives you more idea of the relationship between TCP and IP.

Details of TCP/IP including Three-Way Handshake

After all, that's how the Internet works!  The Internet works thanks to two protocols working in partnership. The first, Transmission Control Protocol, is what establishes the "virtual connection" between two endpoints and ensures smooth data transfer. TCP, if you will, is the "taxi driver" that takes data from A to B.

You can get a sense of round-trip time for TCP using traceroute, or in Windows, tracert. You will notice that TCP is not optimised for performance but for reliability.

A three-way handshake is what initialises the TCP connection (SYN, SYN-ACK and ACK).

What is the relationship between TCP and IP?  The TCP information is transported in IP datagrams, which at the receiver end get processed by IP software and sent to TCP software for "demultiplexing" and further processing. If TCP is the Airway Bill, then IP are the boxes being shipped. Again, refer back to the TCP/IP reference model for renewed conceptual clarity.

TCP Offload Engines and Gigabit Ethernet

One bit of jargon that's gone into fore is "TCP Offload Engine". TCP, being a fairly CPU-intensive protocol, has been embraced by certain network interface cards (NICs) to offload the processing from the main CPU(s). It is used in high-speed network interfaces, such as Gigabit Ethernet (GbE) for moving data at a BILLION BITS PER SECOND.