Archive for the ‘What is?’ Category

What is Active and Passive FTP?

September 7, 2008

What is FTP?
File Transfer Protocol (FTP) is a network protocol used to transfer data from one computer to another through a network, such as the Internet. FTP is a file transfer protocol for exchanging and manipulating files over any TCP-based computer network. A FTP client may connect to a FTP server to manipulate files on that server. As there are many FTP client and server programs available for different operating systems, FTP is a popular choice for exchanging files independent of the operating systems involved.

What is Active and Passive FTP?
The Basics
FTP is a TCP based service exclusively. There is no UDP component to FTP. FTP is an unusual service in that it utilizes two ports, a ‘data’ port and a ‘command’ port (also known as the control port). Traditionally these are port 21 for the command port and port 20 for the data port. The confusion begins however, when we find that depending on the mode, the data port is not always on port 20.

Active FTP
In active mode FTP the client connects from a random unprivileged port (N > 1023) to the FTP server’s command port, port 21. Then, the client starts listening to port N+1 and sends the FTP command PORT N+1 to the FTP server. The server will then connect back to the client’s specified data port from its local data port, which is port 20.
From the server-side firewall’s standpoint, to support active mode FTP the following communication channels need to be opened:

  • FTP server’s port 21 from anywhere (Client initiates connection)
  • FTP server’s port 21 to ports > 1023 (Server responds to client’s control port)
  • FTP server’s port 20 to ports > 1023 (Server initiates data connection to client’s data port)
  • FTP server’s port 20 from ports > 1023 (Client sends ACKs to server’s data port)

When drawn out, the connection appears as follows:

In step 1, the client’s command port contacts the server’s command port and sends the command PORT 1027. The server then sends an ACK back to the client’s command port in step 2. In step 3 the server initiates a connection on its local data port to the data port the client specified earlier. Finally, the client sends an ACK back as shown in step 4.
The main problem with active mode FTP actually falls on the client side. The FTP client doesn’t make the actual connection to the data port of the server–it simply tells the server what port it is listening on and the server connects back to the specified port on the client. From the client side firewall this appears to be an outside system initiating a connection to an internal client–something that is usually blocked.

Passive FTP
In order to resolve the issue of the server initiating the connection to the client a different method for FTP connections was developed. This was known as passive mode, or PASV, after the command used by the client to tell the server it is in passive mode.
In passive mode FTP the client initiates both connections to the server, solving the problem of firewalls filtering the incoming data port connection to the client from the server. When opening an FTP connection, the client opens two random unprivileged ports locally (N > 1023 and N+1). The first port contacts the server on port 21, but instead of then issuing a PORT command and allowing the server to connect back to its data port, the client will issue the PASV command. The result of this is that the server then opens a random unprivileged port (P > 1023) and sends the PORT P command back to the client. The client then initiates the connection from port N+1 to port P on the server to transfer data.
From the server-side firewall’s standpoint, to support passive mode FTP the following communication channels need to be opened:

  • FTP server’s port 21 from anywhere (Client initiates connection)
  • FTP server’s port 21 to ports > 1023 (Server responds to client’s control port)
  • FTP server’s ports > 1023 from anywhere (Client initiates data connection to random port specified by server)
  • FTP server’s ports > 1023 to remote ports > 1023 (Server sends ACKs (and data) to client’s data port)

When drawn, a passive mode FTP connection looks like this:

In step 1, the client contacts the server on the command port and issues the PASV command. The server then replies in step 2 with PORT 2024, telling the client which port it is listening to for the data connection. In step 3 the client then initiates the data connection from its data port to the specified server data port. Finally, the server sends back an ACK in step 4 to the client’s data port.
While passive mode FTP solves many of the problems from the client side, it opens up a whole range of problems on the server side. The biggest issue is the need to allow any remote connection to high numbered ports on the server. Fortunately, many FTP daemons, including the popular WU-FTPD allow the administrator to specify a range of ports which the FTP server will use. The second issue involves supporting and troubleshooting clients which do (or do not) support passive mode. As an example, the command line FTP utility provided with Solaris does not support passive mode, necessitating a third-party FTP client, such as ncftp.


What is Cohesion and Coupling?

August 26, 2008

Cohesion of a single component is the affinity between different units of the module. High cohesion is expected during designing application architecture.

Coupling between components is their degree of mutual interdependence. Low coupling is expected during design application architecture. Low coupling makes components behave as plug-n-play devices.

  • size: Number of connections between routines
  • intimacy: The directness of the connection between routines
  • visibility: The prominence of the connection between routines
  • flexibility: The ease of changing the connections between routines

Following are the types of Cohesion observed during the design phase:

  • Coincidental Cohesion: (Worst) Module elements are unrelated.
  • Logical Cohesion: Elements perform similar activities as selected from outside module.
  • Temporal Cohesion: Operations related only by general time performed (i.e. initialization() or FatalErrorShutdown()).
  • Procedural Cohesion: Elements involved in different but sequential activities, each on different data. This can be divided into several functions as required.
  • Communicational Cohesion : Unrelated operations except need same data or input.
  • Sequential Cohesion : operations on same data in significant order; output from one function is input to next (pipeline).
  • Informational Cohesion: a module performs a number of actions, each with its own entry point, with independent code for each action, all performed on the same data structure.
  • Functional Cohesion: all elements contribute to a single, well-defined task, i.e. a function that performs exactly one operation.

Following are the types of Coupling observed during design phase:

  • Content/Pathological Coupling: (worst) When a module uses/alters data in another .
  • Control Coupling: 2 modules communicating with a control flag (first tells second what to do via flag).
  • Common/Global-data Coupling: 2 modules communicating via global data.
  • Stamp/Data-structure Coupling: Communicating via a data structure passed as a parameter. The data structure holds more information than the recipient needs.
  • Data Coupling: (best) Communicating via parameter passing. The parameters passed are only those that the recipient needs.
  • No data coupling: independent modules.

More information at:

What is Obsessive-Compulsive Disorder (OCD)?

August 8, 2008

Obsessive-Compulsive Disorder (OCD), is an anxiety disorder characterised by unwanted or intrusive thoughts(obsessions) which leads to repetitive behaviors or mental acts (compulsions)that the person feels driven to perform in response to an obsession to get relieved from anxiety.

For example:
If people are obsessed with germs or dirt, they may develop a compulsion to wash their hands over and over again repeatedly upto the level of distress.
Many people have doubt that the door is locked or not; they may develop a compulsion to check repeatedly if it is locked or not.

These are some situations encounterd by normal people also but the difference is that people with OCD perform their rituals several times even though doing so interferes with daily life till they feel the repetition distressing.

What is Delusion?

August 7, 2008

A delusion is a belief that is clearly false (non bizarre) ;due to abnormality in the affected person’s content of thought. The false belief is not due to person’s cultural or religious background or his or her level of intelligence. It is the degree to which the person is convinced that the belief is true. A person with a delusion will hold firmly to the belief regardless of contrary evidence. Some delusions are:

Delusion of control: This is a false belief that another person, group of people, or external force controls one’s thoughts, feelings, impulses, or behavior. A person may describe, for instance, the experience that aliens actually make him or her move in certain ways and that the person affected has no control over the bodily movements.

Delusional jealousy: A person with this delusion falsely believes that his or her spouse or lover is having an affair. This delusion stems from pathological jealousy and the person often gathers “evidence” and confronts the spouse about the nonexistent affair.

Delusion of guilt or sin: This is a false feeling of remorse or guilt of delusional intensity. A person may, for example, believe that he or she has committed some horrible crime and should be punished severely. Another example is a person who is convinced that he or she is responsible for some disaster (such as fire, flood, or earthquake) with which there can be no possible connection.

Delusion of mind being read: This is a false belief that other people can know one’s thoughts. This is different from thought broadcasting in that the person does not believe that his or her thoughts are heard aloud.

There is a subtle difference between illusion and delusion.

What is hallucination?

May 9, 2008

A hallucination is the brain’s reception of a false sensory input. This essentially means that the person having a hallucination is experiencing an event through one of their senses that is not occurring in the real world. This can be through any of the senses. When auditory hallucinations are examined, the most common are hearing one’s own thoughts as if they were being spoken aloud, followed by hearing one’s name being called by a voice when alone.

Common hallucinations include:

  • Feeling a crawling sensation on the skin
  • Hearing voices when no one has spoken
  • Seeing patterns, lights, beings, or objects that aren’t there

Hallucinations related to smell or taste are rare.

There are many causes of hallucinations, including:

  • Being drunk or high, or coming down from such drugs as marijuana, LSD, cocaine or crack, heroin, and alcohol
  • Fever, especially in children and the elderly
  • Sensory problem, such as blindness or deafness
  • Severe illness, including liver failure, kidney failure, and brain cancer
  • Some psychiatric disorders, such as schizophrenia, psychotic depression, and post-traumatic stress disorder

All of us some time or the other experience hallucination in our life…

What are Anti-Patterns?

March 24, 2008

A pattern is a common solution to a problem that occurs in many different contexts. It provides a general solution that may be specialized for a given context. Patterns capture expert knowledge about “best practices” in software design in a form that allows that knowledge to be reused and applied in the design of many different types of software. Patterns address the problem of “reinventing the wheel.”

In computer science, anti-patterns are specific repeated practices that appear initially to be beneficial, but ultimately result in bad consequences that outweigh the hoped-for advantages. They are known as anti-patterns because their use (or misuse) produces negative consequences. Anti-patterns document common mistakes made during software development as well as their solutions.

There must be at least two key elements present to formally distinguish an actual anti-pattern:

· Some repeated pattern of action, process or structure that initially appears to be beneficial, but ultimately produces more bad consequences than beneficial results, and

· A refactored solution that is clearly documented, proven in actual practice and repeatable.

Avoiding anti-patterns requires diagnosing them as early as possible in the software life-cycle. The concept of anti-patterns is readily applied to engineering in general.

Some of the Classic Anti-Patterns are:

Organizational anti-patterns

§ I told you so: When the ignored warning of an expert proves justified, and this becomes the focus of attention.

§ Mushroom management: Keeping employees uninformed and misinformed (kept in the dark and fed manure).

§ Design by committee: The result of having many contributors to a design, but no unifying vision.

Project management anti-patterns

§ Smoke and mirrors: Demonstrating how unimplemented functions will appear.

§ Software bloat: Allowing successive versions of a system to demand ever more resources.

Analysis anti-patterns

§ Retro-specification: To write the Technical/Functional specification after the project has already gone live.

§ Napkin specification: The Functional/Technical specification is given to the Development team on a napkin (i.e., informally, and with insufficient detail) which is fundamentally equivalent to having no specification at all.

General design anti-patterns

§ Re-coupling: Introducing unnecessary object dependency.

§ Gas factory: An unnecessarily complex design.

§ Interface bloat: Making an interface so powerful that it is extremely difficult to implement Stovepipe system: A barely maintainable assemblage of ill-related components.

Object-oriented design anti-patterns

§ Singletonitis: The overuse of the singleton pattern.

§ BaseBean: Inheriting functionality from a utility class rather than delegating to it.

§ Call super: Requiring subclasses to call a superclass’s overridden method.

§ Poltergeists: Objects whose sole purpose is to pass information to another object.

§ Yet Another Damn Layer: Adding unnecessary layers to a program, library or framework. This became popular after the first book on programming patterns.

Programming anti-patterns

§ Accidental complexity: Introducing unnecessary complexity into a solution.

§ Coding by exception: Adding new code to handle each special case as it is recognized.

§ Magic strings: Including literal strings in code, for comparisons, as event types etc.

§ Monkey work: Term for any general repeated support code required within projects which suffer from poor code reuse and design. Is often avoided and rushed, hence open to errors and can quickly become a Bug magnet.

§ Wrapping wool in cotton: Commonly observed when framework methods are contained in single line methods in wrapper classes which provide no useful abstraction.

Testing anti-patterns

§ Hostile testing: Antagonizing practical development solutions and workflow with over-testing procedures or over-scheduling test runs.

§ Meta-testing: Overdesigning testing procedures until it is necessary to test them, also known as “watchmen’s watchmen”.

§ Moving target: Continuously change design and/or implementation in order to escape established testing procedures.

§ Slave testing: Conditioning testers by means of black-mail or corruption to satisfy the stakeholders urge to flag positive compliance.

What are software Design Patterns?

March 21, 2008

A design pattern in software engineering is a general reusable solution to a commonly occurring problem in software design. Patterns originated as an architectural concept by Christopher Alexander (1977/79).
Some of the design patterns used in the software industry are listed below:

Creational patterns

Abstract Factory
Provide an interface for creating families of related or dependent objects without specifying their concrete classes.

Factory method
Define an interface for creating an object, but let subclasses decide which class to instantiate. Factory Method lets a class defer instantiation to subclasses.

Separate the construction of a complex object from its representation so that the same construction process can create different representations.

Lazy initialization
Tactic of delaying the creation of an object, the calculation of a value, or some other expensive process until the first time it is needed.

Object pool
Avoid expensive acquisition and release of resources by recycling objects that are no longer in use.

Specify the kinds of objects to create using a prototypical instance, and create new objects by copying this prototype.

Ensure a class only has one instance, and provide a global point of access to it.

Structural patterns

Convert the interface of a class into another interface clients expect. Adapter lets classes work together that couldn’t otherwise because of incompatible interfaces.

Decouple an abstraction from its implementation so that the two can vary independently.

Compose objects into tree structures to represent part-whole hierarchies. Composite lets clients treat individual objects and compositions of objects uniformly.

Attach additional responsibilities to an object dynamically. Decorators provide a flexible alternative to subclassing for extending functionality.

Provide a unified interface to a set of interfaces in a subsystem. Facade defines a higher-level interface that makes the subsystem easier to use.

Use sharing to support large numbers of fine-grained objects efficiently.

Provide a surrogate or placeholder for another object to control access to it.

Behavioral patterns

Chain of responsibility
Avoid coupling the sender of a request to its receiver by giving more than one object a chance to handle the request. Chain the receiving objects and pass the request along the chain until an object handles it.

Encapsulate a request as an object, thereby letting you parameterize clients with different requests, queue or log requests, and support undoable operations.

Given a language, define a representation for its grammar along with an interpreter that uses the representation to interpret sentences in the language.

Provide a way to access the elements of an aggregate object sequentially without exposing its underlying representation.

Define an object that encapsulates how a set of objects interact. Mediator promotes loose coupling by keeping objects from referring to each other explicitly, and it lets you vary their interaction independently.

Without violating encapsulation, capture and externalize an object’s internal state so that the object can be restored to this state later.

Define a one-to-many dependency between objects so that when one object changes state, all its dependents are notified and updated automatically.

Define a many-to-many as well as one-to-many dependency between objects so that when one object changes state, all its dependents are notified and updated automatically.

Allow an object to alter its behavior when its internal state changes. The object will appear to change its class.

Define a family of algorithms, encapsulate each one, and make them interchangeable. Strategy lets the algorithm vary independently from clients that use it.

Recombinable Business logic in a boolean fashion.

Template method
Define the skeleton of an algorithm in an operation, deferring some steps to subclasses. Template Method lets subclasses redefine certain steps of an algorithm without changing the algorithm’s structure.

Represent an operation to be performed on the elements of an object structure. Visitor lets you define a new operation without changing the classes of the elements on which it operates.

Single-serving visitor
Optimize the implementation of a visitor that is allocated, used only once, and then deleted.

Hierarchical visitor
Provide a way to visit every node in a hierarchical data structure such as a tree.

What is active directory?

January 11, 2008

Active Directory (AD) is an implementation of LDAP directory services by Microsoft for use primarily in Windows environments. Its main purpose is to provide central authentication and authorization services for Windows based computers. Active Directory also allows administrators to assign policies, deploy software, and apply critical updates to an organization. Active Directory stores information and settings in a central database. Active Directory networks can vary from a small installation with a few hundred objects, to a large installation with millions of objects.Microsoft Active Directory provides a directory service that allows organizations to administer their networked resources. The networked resources include users, computers etc. Thus it acts as a central store for users in a particular network. This store can be used for authentication purpose. Applications can request the active directory service for user authentication.

A sample code to authenticate a user against the active directory.

/// <summary>
/// int: Interactive Logon.
/// </summary>
public const int LOGON32_LOGON_INTERACTIVE = 2;
/// <summary>
/// int: Default Provider.
/// </summary>
public const int LOGON32_PROVIDER_DEFAULT = 0;
/// <summary>
/// int: Network Logon.
/// </summary>
public const int LOGON32_LOGON_NETWORK = 3;

/// <summary>
/// LogonUser is a Windows API, which is used to logon a win user.
/// </summary>
/// <param name=”lpszUserName”>string: User Name.</param>
/// <param name=”lpszDomain”>string: Domain name.</param>
/// <param name=”lpszPassword”>string: Password.</param>
/// <param name=”dwLogonType”>int: Logon Type.</param>
/// <param name=”dwLogonProvider”>int: Logon provider.</param>
/// <param name=”phToken”>ref IntPtr: Logon Token.</param>
/// <returns>int: Status of the user logon.</returns>
/// <remarks>Use to Logon the user to Windows network.</remarks> [DllImport(“advapi32.dll”, CharSet = CharSet.Auto, SetLastError = true)]
public static extern int LogonUser(String lpszUserName, String lpszDomain, String lpszPassword, int dwLogonType, int dwLogonProvider, ref IntPtr phToken);

/// <summary>
/// This method authenticates the user agains the current domain
/// and returns a boolean value.
/// </summary>
/// <returns>bool: Indicating whether the authentication
/// is successfull.</returns>
public bool AuthenticateUser()
string _domainName;
IntPtr _token = IntPtr.Zero;
_domainName = Environment.GetEnvironmentVariable(“USERDOMAIN”);
//LogonUser to check Windows Logon.
int _intResult LogonUser(“USER_NAME”, _domainName, “PASSWORD”,

return Convert.ToBoolean(_intResult); ;

What is LINQ ?

December 19, 2007

LINQ is Language Integrated Query. LINQ is an integrated part of Orcas. LINQ has a great power of querying on any source of data, data source could be the collections of objects, database or XML files. We can easily retrieve data from any object that implements the IEnumerable interface. Microsoft basically divides LINQ into three areas and that are give below.

1. LINQ to Object {Queries performed against the in-memory data}
2. LINQ to ADO.Net
3. LINQ to SQL (formerly DLinq) {Queries performed against the relation database only Microsoft SQL Server Supported}
4. LINQ to DataSet {Supports queries by using ADO.NET data sets and data tables}
5. LINQ to Entities {Microsoft ORM solution}
6. LINQ to XML (formerly XLinq) { Queries performed against the XML source}

LINQ to XML (XLINQ): Sample

Sample.xml will contain the following:

<title>LINQ Sample</title>
<article>This is a sample XLinq source.</article>

C# code to query the xml:
//Load the xml into XDocument.
XDocument sample = XDocument.Load(“sample.xml”);
//Query the XML document.
XElement samplexElement = new XElement(“feed”,
from b in sample.Element(“feed”).Elements(“entry”)
select new XElement
//Display the XML.