Wednesday, May 29, 2013

DMZ (demilitarized zone)

  • DMZ (demilitarized zone)
In computer security, a DMZ (sometimes referred to as a perimeter network) is a physical or logical subnetwork that contains and exposes an organization's external-facing services to a larger untrusted network, usually the Internet. The purpose of a DMZ is to add an additional layer of security to an organization's local area network (LAN); an external attacker only has access to equipment in the DMZ, rather than any other part of the network. The name is derived from the term "demilitarized zone", an area between nation states in which military action is not permitted.

Services in the DMZ

Any service that is being provided to users on the external network can be placed in the DMZ. The most common of these services are:

    Web servers
    Mail servers
    FTP servers
    VoIP servers

Web servers that communicate with an internal database require access to a database server, which may not be publicly accessible and may contain sensitive information. The web servers can communicate with database servers either directly or through an application firewall for security reasons.

E-mail messages and particularly the user database are confidential information, so they are typically stored on servers that cannot be accessed from the Internet (at least not in an insecure manner), but can be accessed from the SMTP[clarify] servers that are exposed to the Internet.
The mail server inside the DMZ passes incoming mail to the secured/internal mail servers. It also handles outgoing mail.

For security, legal compliance[clarify] and monitoring reasons, in a business environment, some enterprises install a proxy server within the DMZ. This has the following consequences:

    Obliges the internal users (usually employees) to use the proxy to get Internet access.
    Allows the company to reduce Internet access bandwidth requirements because some of the web content may be cached by the proxy server.
    Simplifies the recording and monitoring of user activities and block content violating acceptable use policies.

A reverse proxy server, like a proxy server, is an intermediary, but is used the other way around. Instead of providing a service to internal users wanting to access an external network, it provides indirect access for an external network (usually the Internet) to internal resources. For example, a back office application access, such as an email system, could be provided to external users (to read emails while outside the company) but the remote user would not have direct access to their email server. Only the reverse proxy server can physically access the internal email server. This is an extra layer of security, which is particularly recommended when internal resources need to be accessed from the outside. Usually such a reverse proxy mechanism is provided by using an application layer firewall as they focus on the specific shape of the traffic rather than controlling access to specific TCP and UDP ports as a packet filter firewall does.



Architecture
There are many different ways to design a network with a DMZ. Two of the most basic methods are with a single firewall, also known as the three legged model, and with dual firewalls.

Single firewall
A single firewall with at least 3 network interfaces can be used to create a network architecture containing a DMZ. The external network is formed from the ISP to the firewall on the first network interface, the internal network is formed from the second network interface, and the DMZ is formed from the third network interface. The firewall becomes a single point of failure for the network and must be able to handle all of the traffic going to the DMZ as well as the internal network. The zones are usually marked with colors -for example, purple for LAN, green for DMZ, red for Internet (with often another color used for wireless zones).



Dual firewall
A more secure approach is to use two firewalls to create a DMZ. The first firewall (also called the "front-end" firewall) must be configured to allow traffic destined to the DMZ only. The second firewall (also called "back-end" firewall) allows only traffic from the DMZ to the internal network.
This setup is considered more secure since two devices would need to be compromised. There is even more protection if the two firewalls are provided by two different vendors, because it makes it less likely that both devices suffer from the same security vulnerabilities.


http://en.wikipedia.org/wiki/DMZ_%28computing%29


  • DMZ (demilitarized zone)
In a typical DMZ configuration for a small company, a separate computer (or host in network terms) receives requests from users within the private network for access to Web sites or other companies accessible on the public network. The DMZ host then initiates sessions for these requests on the public network. However, the DMZ host is not able to initiate a session back into the private network. It can only forward packets that have already been requested

http://searchsecurity.techtarget.com/definition/DMZ


  • Network Ingress/Egress Controls Explained

One of the longstanding problems with the SELinux network access controls was that they lacked any ability to control packets at the network interface level, limiting our ability to provide access control based on the physical network and making it impossible to provide access control for forwarded packets
The network ingress/egress controls were designed to solve these problems by placing SELinux network access controls at the network interface level.

The new ingress/egress controls are fairly simple: each packet entering the system must pass an ingress access control and each packet leaving the system must pass an egress access control. Forwarded packets must also pass an additional forwarding access control
https://paulmoore.livejournal.com/2128.html

What are Access Control Lists?
ACLs are a network filter utilized by routers and some switches to permit and restrict data flows into and out of network interfaces. When an ACL is configured on an interface, the network device analyzes data passing through the interface, compares it to the criteria described in the ACL, and either permits the data to flow or prohibits it.

Why Do We Use Access Control Lists?
The primary reason is to provide a basic level of security for the network.
ACLs are not as complex and in depth of protection as stateful firewalls, but they do provide protection on higher speed interfaces where line rate speed is important and firewalls may be restrictive
ACLs are also used to restrict updates for routing from network peers and can be instrumental in defining flow control for network traffic

When do we use Access Control Lists?
they do offer a significant amount of firewall capability
ACLs should be placed on external routers to filter traffic against less desirable networks and known vulnerable protocols.



One of the most common methods in this case is to setup a DMZ, or de-militarized buffer zone in your network. This architecture is normally implemented with two separate network devices.

The most exterior router provides access to all outside network connections. This router usually has less restrictive ACLs, but provides larger protection access blocks to areas of the global routing tables that you wish to restrict.
This router should also protect against well known protocols that you absolutely do not plan to allow access into or out of your network
ACLs here should be configured to restrict network peer access and can be used in conjunction with the routing protocols to restrict updates and the extent of routes received from or sent to network peers.

The DMZ is where most IT professionals place systems which need access from the outside. The most common examples of these are web servers, DNS servers, and remote access or VPN systems.

The internal router of a DMZ contains more restrictive ACLs designed to protect the internal network from more defined threats.
ACLs here are often configured with explicit permit and deny statements for specific addresses and protocol services.


As you can see from this diagram, ingress traffic flows from the network into the interface and egress flows from the interface to the network.
ACLs start with a source address first in their configuration and destination second
As you configure an ACL on the ingress of a network interface it is important to recognize that all local network or hosts should be seen as sources here, and the exact opposite for the egress interface.

the implementation of ACLs on the interface of a router that faces an external network
the ingress side is coming from the outside network and those addresses are considered to be sources, while all internal network addresses are destinations
the egress side, your internal network addresses are now source addresses and the external addresses are now destinations.

https://www.pluralsight.com/blog/it-ops/access-control-list-concepts

What is a DMZ? (Demilitarized Zone)

  • Honeypots, the simplest technology, work by tricking a hacker into thinking that they succeeded in infiltrating a system, when in reality the perpetrator reached the 'honeypot', which mimics the target server and provides the hacker with fake 'trophy' information while at the same time studying the behavior of the hacker and logging its IP address for law enforcement authorities to persecute

Honeyd, for instance, can create multiple different honeypots, called virtual honeypots.
Traditionally, a honeypot was a physical computer which simulated the operating system of the real server, but which was actually safely positioned outside the firewall
Honeyd's invention of the virtual honeypot was a huge advancement because as a result, a company could have multiple honeypot traps covering all unused or unauthorized IP addresses, and not just one, which they hoped the attacker would choose

When a hacker attempts to connect to an IP address that a company doesn't authorize, Honeyd "takes over" that IP address using ARP spoofing (modifying the source IP address number in the communications packet) and assigns a virtual honeypot for the hacker to interact with. If the hacker probed a different unused IP, Honeyd would assign a different virtual honeypot with perhaps a different operating system or applications to remain realistic



Heat seeking honeypots will contain a module identifying web pages that hackers find "trendy", and which are commonly attacked
This module uses a series of algorithms to "search logs of the Bing search engine to identify queries used by attackers"
The program then mimics the web page at a location near the target server, interacts with the hacker "without manually setting up the actual software that is targeted"
In some versions of this technology, the program "trains" itself to act like the targeted website by employing natural language processing to "generate responses to attacker requests"

Researchers at the Pacific Northwest National Laboratory are building a reasoning framework called CHAMPION, which acts within a network and identifies potential attackers. The laboratory employs behavioral psychologists to determine which factors are most likely to prompt an employee to launch an attack against his own company
Then, CHAMPION combines data such as email traffic, calendars, and evaluation reports into a set of observations falling into four categories: employee role patterns, psychosocial patterns, policy violation patterns, and web access patterns
It then compares these observations to a database of indicators, and it labels individuals that fit the description of an attacker as dangerous

One of the most recurring themes in the field of decoy-based cyber security is targeting human error, rather than computer error, which occurs much less often.

http://www.pitt.edu/~cdv16/trends.htm


The DMZ or the Demilitarized Zone in a network refers to a segment of a network in which we place all the servers that need to be accessible from the internet
In either of these scenarios, whether we have only one firewall in a three-legged design or we have two back-to-back firewalls in the other design, our DMZ is going to be placed behind only one firewall
But the question is what if there was a pretty critical server placed in the DMZ and we needed more than one layer of security in order to protect it? What if one of our firewalls which is placed in the front is a pretty old one and not capable of doing a very good logging and auditing of the kind of attacks on the DMZ?
In such cases, we need to come up with another design and combine the back-to-back and three-legged firewall designs to create something that satisfies our needs for better security of DMZ
In this scenario let’s say both of our firewalls are Forefront TMG 2010 and one of them acts as the front-end firewall connecting from one side to the Internet and from the other side to the back-end TMG.

The back-end firewall is going to be a three-legged firewall with:

    One leg connecting to the LAN
    One leg connecting to the DMZ
    One leg leg connecting to the front-end TMG



The DMZ is placed behind two firewalls: The front-end TMG and the back-end TMG and if the user is going to reach the DMZ from the internet, he will have to pass through two firewalls
The LAN is also behind two firewalls and therefor better protected
Do you want to consider putting honeypots in your network? The network segment between the firewalls is the best place… The hackers expect the DMZ servers to be there

http://blog.windowsserversecurity.com/tag/back-to-back-firewall/

  • Heat-seeking honeypots

Specifically, we present heat-seeking honeypots that actively attract attackers, dynamically generate and deploy honeypot pages, then analyze logs to identify attack patterns.

In our design, the heat-seeking honeypots have four components. The first component is to identify which types of Web services the attackers are actively targeting. The second component is to automatically set up Web pages that match attackers’ interests. The third component advertises
honeypot pages to the attackers.  When the honeypot receives traffic from attackers, it uses a sandboxed environment to log all accesses. Finally, the fourth component embodies methods to distinguish attacks from normal users and crawler visits, and to perform attack study

Comparing honeypots
we look at how effective different honeypot
setups are in terms of attracting attackers.

1.Web  server:
Here, we have just a Web server (in
our case, Apache) running on a machine that can be
publicly accessed on the Internet. The machine has no
hostname, so the only way to access the machine is by
its IP address. There are no hyperlinks pointing to the
server, so it is not in the index of any search engine or
crawler.

2.Vulnerable software:
We install four commonly targeted Web applications, as described in Section 3.2 (a).
The application pages are accessible on the Internet,
and there are links to them on public Web sites. There-
fore, they are crawled and indexed by the search engines.

3.Heat-seeking honeypot pages:
These pages are generated by option (b) as described in Section 3.2. They
are simple HTML pages, wrapped in a small PHP
script which performs logging.  Similar to software
pages, the honeypot pages are also crawled and indexed by search engines

https://www.microsoft.com/en-us/research/wp-content/uploads/2011/03/paper-1.pdf
  • the release of Symantec Decoy Server, a "honeypot" intrusion detection system (IDS) that detects, contains and monitors unauthorized access and system misuse as it happens. As a complement to host- and network-based IDS, Symantec Decoy Server diverts attacks from key resources while also providing early detection of internal and external attacks.
 "Honeypots supplement security solutions such as firewalls and other intrusion detection systems, providing advanced decoy technology and early detection sensors. In addition to the forensic elements, honeypots can be used as a tool for reducing false positives,"
 Symantec Decoy Server is not signature-based, so it automatically detects unknown attacks without any need for security signature updates or dynamic policy configurations. It also detects both host- and network-based attacks, unauthorized use of passwords and server access for increased network protection.
 Once a decoy server has been attacked, it covertly monitors the activities of an attacker in real-time using Session Replay, a live session analysis tool. Sessions may be recorded and played back for further analysis to help organizations understand the tools and tactics used against them.
 Symantec Decoy Server provides early detection of threats and enables attack diversion and confinement by actually becoming the target of the attack. The decoy sensor acts like a fully functioning server and can simulate email traffic between users in the organization to mirror the appearance of a live mail server.
 http://www.symantec.com/region/au_nz/press/au_030701c.html

  •  A honeypot is a system that's put on a network so it can be probed and attacked.

 There are two types of honeypots:
 Research: For example, the Honeynet Project is a volunteer, nonprofit security research organization that uses honeypots to collect information on cyberthreats.
 Production: production honeypots are being recognized for the detection capabilities they can provide and for the ways they can supplement both network- and host-based intrusion protection.

 A low-interaction system offers limited activity; in most cases, it works by emulating services and operating systems.
 high-interaction honeypots involve real operating systems and applications, and nothing is emulated


 Advantages of honeypots
 Too much data: One of the common problems with the traditional IDS is that it generates a huge amount of alerts. In contrast,  honeypots collect data only when someone is interacting with them.

 False positives: Perhaps the biggest drawback of an IDS is that so many of the alerts generated are false.Honeypots sidestep this problem because any activity with them is, by definition, unauthorized.

 False negatives:  IDS technologies can also have difficulty identifying unknown attacks or behavior. Again, any activity with a honeypot is anomalous, making new or previously unknown attacks stand out

 Resources: An IDS requires resource-intensive hardware to keep up with an organization's network traffic. According to Lance Spitzner, founder of the Honeynet Project, a single Pentium computer with 128MB of RAM can be used to monitor millions of IP addresses.

 Encryption: more and more attackers are using encryption as well. That blinds an IDS's ability to monitor the network traffic. With a honeypot, it doesn't matter if an attacker is using encryption; the activity will still be captured


 https://www.computerworld.com/article/2573345/security0/honeypots--the-sweet-spot-in-network-security.html


  •  "Prevention is ideal, but detection is a must."

 The functionality of honeypots is so diverse that it has been a challenge to define exactly what a honeypot is: honeypots serve many different purposes for different organizations.
 Generally, a honeypot is an information system resource whose value lies in unauthorized or illicit use of that resource.
 In fact, its value lies in its being misused.


    A dedicated server
    A simulated system or state machine like deception tool kit[4] or KFSsensor[5]
    A service on a selected host, like Tiny Honeypot that listens to ports not in legitimate use[6]
    A virtual server, such as the original honeynet[7] and most other honeypots
    A single file with special attributes which is sometimes called a honeytoken[8] or any number of other possibilities

The value in a honeypot is derived from the lack of any authorized activity to the resource. A honeypot resource is never meant for legitimate use; therefore, any use of the honeypot resource is illegitimate and accidental, or hostile in nature.

https://www.sans.edu/cyber-research/security-laboratory/article/honeypots-guide


  • In the field of computer security, honeytokens are honeypots that are not computer systems.

Honeytokens are fictitious words or records that are added to legitimate databases.
They allow administrators to track data in situations they wouldn't normally be able to track, such as cloud-based networks.
If data is stolen, honeytokens allow administrators to identify who it was stolen from or how it was leaked. If there are three locations for medical records, different honey tokens in the form of fake medical records could be added to each location. Different honeytoken would be in each set of records.
https://en.wikipedia.org/wiki/Honeytoken


  •  A honeytoken is a data or a computing resource that exists for the purpose of alerting you when someone accesses it. This type of a honeypot could take many forms, such as a user account that no one should use, a file that no one should access and a link on which no one should click.

https://zeltser.com/honeytokens-canarytokens-setup/
  •  At least one domain name. If you want to enabled PDF-opening tracking, at least two domains.

Internet-facing Docker host. You can install Docker on a Linux host quickly
 https://github.com/thinkst/canarytokens-docker

Saturday, May 18, 2013

Non-RAID drive architectures

  • The Basics of JBOD
While partitioning chops single drives into smaller logical volumes, JBOD combines drives into larger logical volumes.
https://blog.storagecraft.com/jbod-care/




  • JBOD

JBOD (Just a bunch of disks or Just a bunch of drives) is when a number of drives are used, but are not in a RAID configuration.
The drives may be handled as separate logical volumes, or they may be combined into a single logical volume using a system like LVM.
http://en.wikipedia.org/wiki/Non-RAID_drive_architectures


  • Use Disk Utility to Create a JBOD RAID Array

A JBOD RAID set or array, also known as a concatenated or spanning RAID, is one of the many RAID levels supported by OS X and Disk Utility. JBOD (Just a Bunch Of Disks) is not actually a recognized RAID level, but Apple and most other vendors who create RAID-related products have chosen to include JBOD support with their RAID tools.

JBOD allows you to create a large virtual disk drive by concatenating two or more smaller drives together. The individual hard drives that make up a JBOD RAID can be of different sizes and manufacturers. The total size of the JBOD RAID is the combined total of all the individual drives in the set.

There are many uses for JBOD RAID, but it’s most often used to expand the effective size of a hard drive, just the thing if you find yourself with a file or folder that is getting too large for the current drive. You can also use JBOD to combine smaller drives to serve as a slice for a RAID 1 (Mirror) set.

No matter what you call it - JBOD, concatenated or spanning - this RAID type is all about creating larger virtual disks

http://macs.about.com/od/usingyourmac/ss/raidjbod.htm



  • JBOD:

A JBOD (Just a Bunch of Drives) is a drive enclosure that accommodates multiple disk drives. These drives are interfaced through a common backplane and are accessed through JBOD controllers that provide either the Fiber Channel bypass or SAS expander functionality. The JBOD enclosures attach to a managing RAID system, thus providing an easy means to quickly expand array capacity to many folds.
http://www.surveon.com/support/RAID.asp



  • JBOD means the individual disks are presented (to a server) with no amalgamation, pooling or structure applied. The term is in widespread use, especially in the context of computers that have software volume management, such as LVM (AIX, HP-UX, Linux), DiskSuite (Solaris), ZFS (Solaris), Veritas Volume Manager (UNIXes), Windows, and so-on.

Spanning or concatenation is an additional configuration that can be applied by volume managers to combine JBODs into larger logical volumes or LUNs (logical unit numbers
http://searchstorage.techtarget.com/definition/JBOD



JBOD (Just a Bunch of Disks)
JBOD is not one of the numbered RAID levels. Unlike a concatenated array, the disks of JBOD appear as individual hard disks, instead of one single large disk. JBOD accurately describes the underlying physical structure that all RAID structures rely upon. When a hardware RAID controller is used, it normally defaults to JBOD configuration for attached disks.

http://www.sansdigital.com/raid-diagrams.html




  • RAID JBOD


JBOD RAID description

JBOD (Just a bundle of disks) is a tie of hard drives, strictly speaking, it is not a RAID array. Though some disks can be united in one logical section with help of OS or with hardware using RAID controller which supports the function of JBOD array build. Usually files are recorded sequentially to the end of the disk, then writing goes on to next HHD. Such data organization does not require any special equipment, as it was said above, and it can be implemented by means of OS or third-party software. Although, when one of the drives fails system is breaking down and data recovery from JBOD array in necessary.
JBOD Recovery

In case of JBOD disk array failure we should detect sequence of drives. This is not hard if JBOD array has just two storages, but task becomes more complicated if the array has three or more drives. In this case it is necessary to analyze file allocation table to determine the addressing of the file or directory, and then performing necessary calculations we can quite easily prioritize disks in the array. In addition, we should mention that in some cases when one or several drives of JBOD array failed and could not be recovered, the information from damaged JBOD was still available, though partially.

http://www.hardmaster.info/eng/articles/raid-array-data-recovery.html




  • Concatenation may be thought of as the reverse of partitioning. Whereas partitioning takes one physical drive and creates two or more logical drives, JBOD uses two or more physical drives to create one logical drive.


Concatenation is sometimes used to turn several odd-sized drives into one larger useful drive, which cannot be done with RAID 0. For example, JBOD could combine 3 GB, 15 GB, 5.5 GB, and 12 GB drives into a logical drive at 35.5 GB, which is often more useful than the individual drives separately.

In the diagram to the right, data are concatenated from the end of disk 0 (block A63) to the beginning of disk 1 (block A64); end of disk 1 (block A91) to the beginning of disk 2 (block A92). If RAID 0 were used, then disk 0 and disk 2 would be truncated to 28 blocks, the size of the smallest disk in the array (disk 1) for a total size of 84 blocks.

Concatenation is one of the uses of the Logical Volume Manager in Linux, which can be used to create virtual drives spanning multiple physical drives and/or partitions.
http://www.raidrecoverylabs.com/standard_raid_levels/





  • JBOD RAID Explained


Unlike raid, JBOD takes a bunch of drives or disks and turns them into one large partition. Also, there is no redundancy offered by JBOD. Thus, the disadvantage is that unlike RAID arrays, the whole JBOD arrays fails if there is a failure of one disk in the array. In simple words, JBOD can be thought of as the opposite of partitioning. In case you are using JBOD you will find that there is no fault tolerance, no improvement in performance unlike the raid technology.

What are the advantages of JBOD over RAID?

    There is no wastage of data in the drive. There is no loss in the capacity as JBOD array lets you to combine the individual disks into one single large unit. For instance, a 10GB drive and a 40GB drive would add up to form a 50 GB volume of JBOD while only 30GB of RAID zero array. The advantage however is relatively smaller these days since drives are cheap in cost.
    There is easier recovery during disaster. In a RAID volume, data on each disk is destroyed since all the files are striped in it, but if the same drive in the JBOD set of array dies then there is easier recovery of files on the other drives. Thus, JBOD recovery in such instances is better than RAID data recovery.

JBOD and RAID levels:

There are several disadvantages of JBOD though as compared to the RAID levels. It is hence considered to be a cheaper option for a RAID system.

    JBOD does not offer redundancy unlike the raid technology.
    There is no increase in the performance of the system using JBOD array unlike RAID which betters the performance and offers higher reliability.
    JBOD lacks fault tolerance.
    Unlike RAID recovery, JBOD recovery can be a bit tougher.

JBOD-RAID recovery:

There are various categories of software available to recover your JBOD. You can get file recovery after a virus attack or a sudden shut down of the system, system crash, etc. In case of accidental deletion of files on your file system, you can use utilities that are available over the Internet. You can easily obtain a quick and an effective solution to restore all the files that you have lost.


http://www.raidrecoveryonline.com/jbod_raid/

  • the differences between four types of disk storage: Just a Bunch of Disks (JBOD), Direct Attached Storage (DAS), Network Attached Storage (NAS), and Storage Area Networks (SANs).
JBOD is a collection of disks in a box presented to the OS either as a single volume or a combination of drives as larger logical volumes. However, there’s no support for RAID fault tolerance or performance optimization.
https://www.petri.com/storage-tip-understanding-difference-jbod-das-nas-sans

  • Non-RAID drive architectures

JBOD: Just a bunch of disks; an array of drives, each of which is accessed directly as an independent drive.
SPAN or BIG: a simple concatenation of multiple drives. Such a concatenation is sometimes also called JBOD, but this usage is proscribed in careful use due to ambiguity with the alternative meaning just cited
MAID: a system using hundreds to thousands of hard drives for nearline storage
http://en.wikipedia.org/wiki/Non-RAID_drive_architectures

KVM

  • KVM

A KVM switch (with KVM being an abbreviation for "keyboard, video and mouse") is a hardware device that allows a user to control multiple computers from one or more[1] keyboard, video monitor and mouse. Although multiple computers are connected to the KVM, typically a smaller number of computers can be controlled at any given time. Modern devices have also added the ability to share other peripherals like USB devices and audio.
https://en.wikipedia.org/wiki/KVM_switch


  • What is KVMoIP?

KVMoIP (Keyboard, Video, Mouse) over IP allows IT administrators to remotely manage their UK dedicated box even when their usual remote access software (SSH, RDP, VNC etc) is no longer functioning. As long as the dedi server is powered on and can get past BIOS post, administrators will have full BIOS-level access.
https://www.racksrv.com/portal/knowledgebase/10/What-is-KVMoIP.html


  • The Dell Remote Access Controller or DRAC is an out-of-band management platform on certain Dell servers. The platform may be provided on a separate expansion card, or integrated into the main board; when integrated, the platform is referred to as iDRAC.

It uses mostly separate resources to the main server resources, and provides a browser-based or command-line interface (or both) for managing and monitoring the server hardware
https://en.wikipedia.org/wiki/Dell_DRAC



Tuesday, April 23, 2013

What will happen if we don’t override the hashcode method?



  • What will happen if we don’t override the hashcode method?


If two objects are same then they must return same value in hashcode() and equals() method whenever invoked.
It is not necessary that two different object must have different hashcode values. it might be possible that they share common hash bucket.

JVM assigns unique hashcode value to each object when they are created in memory
if developers don’t override the hashcode method then there is no way the two object returns same hashcode value.

equals() method is used to compare objects that they are having same value or not but why should we override the hashcode method ?
The answer to the question is for the hash technique based data structures like HashMap and HashTable.

every object is placed in Hash bucket depending on the hashcode they have
It is not necessary that every different object must have different hashcode
hashcode is used to narrow the search result

When we try to insert any key in HashMap first it checks whether any other object present with same hashcode and
if yes then it checks for the equals() method.
If two objects are same then HashMap will not add that key
instead it will replace the old value by new one.

http://shivasoft.in/blog/java/what-is-the-need-to-override-hashcode-and-equals-method/

Wednesday, April 17, 2013

Software design document



  • Software design document

A software design document (SDD) is a written description of a software product, that a software designer writes in order to give a software development team an overall guidance of the architecture of the software project.
There are two kinds of design documents called HLDD (high-level design document) and LLDD (low-level design document).
https://en.wikipedia.org/wiki/Software_design_document

Statement of work



  • Statement of work

A statement of work (SOW) is a formal document that captures and defines the work activities, deliverables, and timeline a vendor must execute in performance of specified work for a client. The SOW usually includes detailed requirements and pricing, with standard regulatory and governance terms and conditions.
https://en.wikipedia.org/wiki/Statement_of_work

Frameworx (NGOSS)



  • Frameworx (NGOSS)

Frameworx, formerly known as NGOSS or "New Generation Operations Systems and Software" is the TeleManagement Forum’s programme to provide ways to help Communication Service Providers to manage their business.
Frameworx includes a set of principles and technical deliverables.



2 Principles
    2.1 Separation of Business Process from Component Implementation
    2.2 Loosely Coupled Distributed System
    2.3 Shared Information Model
    2.4 Common Communications Infrastructure
    2.5 Contract defined interfaces


3 Technical Deliverables
    3.1 Process Model
    3.2 Shared Information Model
    3.3 Lifecycle Model
    3.4 Contract Specifications
    3.5 Telecom Application Map

https://en.wikipedia.org/wiki/Frameworx

Monday, April 15, 2013

Disk Performance Calculation



  • A disk is double interleaved, as in the figure bellow. 

It has 8 sectors of 512 bytes per track, and a rotation rate of 300 rpm

a)How long does it take to read all the sectors of a
track in order, assuming the arm is already
correctly positioned , and 1/2 rotation is needed to
get a sector 0 under the head?
b) What's the data rate?
c) Now repeat the problem for a non-interleaved disk with the same characteristics
d) How much does the data rate degrade due to interleaving?



300 rpm means that one complete turn
takes (60 sec * 1000 ms) / 300 rpm = 200 ms
Thus one sector needs 200 ms / 8 = 25 ms
To read all the sectors in order the head has to
go over 22 sectors starting from sector 0 (0-
3-6-1-4-7-2-5-0-3-6-1-4-7-2-5-0-3-6-1-4-7)
what takes 22*25 ms = 550 ms

a) 550 ms + 200 ms / 2 = 650 ms
Effective access time = seek time + latency time +
data transfer time = 0 + 200 ms / 2 + 550 ms = 650
ms, thus
b) data rate = (8 * 512 bytes / 650 ms) * 1000 ms/sec
˜ 6302 bytes / sec
c) read all the sectors: 8*25 ms + 200 ms / 2 = 300 ms
data rate = (8 * 512 bytes / 300 ms) * 1000 ms/sec =
13653 bytes / sec
d) the difference in data rate is 13653 bytes / sec –
6302 bytes / sec = 7351 bytes / sec

http://disi.unitn.it/~ilya/Download/os_course/input_output_lab.pdf




  • Disk Performance


Given the following Disk Parameters:
– Average seek time is 5 ms
– Disk spins at 10,000 RPM
– Transfer rate is 40 MB/sec

What is Average Disk read or write time for a 512-byte Sector?

Ave. seek + ave. rot delay + transfer time + controller overhead
5 ms + 0.5/(10000 RPM/60) + 0.5 KB/40 MB/s + 0.1 ms
 5 + 3 + 0.13 + 0.1 = 8.23 ms

 http://meseec.ce.rit.edu/eecc551-winter2003/551-exam-review-winter2003.pdf




  • Performance Example

How long does it take to read a 512 byte block from the disk?
How long does it take to read two 512 byte blocks from the disk?
http://williams.comp.ncat.edu/comp375/disk.pdf


  • Disk Performance Example


• Calculate time to read 512-byte sector for a disk.
Average seek time is 5ms,
the transfer rate is 40 MB/sec,
it rotates at 10,000 RPM, and
the controller overhead is 0.1 ms.
• Disk latency = average seek time +
average rotational delay + transfer time +
controller overhead

= 5 ms+ 0.5 * 1/(10000 RPM) + 512 B / (40 MB/s) + 0.1 ms
=5+3+0.013+0.1=8.11ms

https://docs.google.com/presentation/d/1zBhbZZoejmApfDjDkBvYg50DJ_4Aoq4EzGB_e_AYeLU/edit#slide=id.p5




  1. Disk Performance


Average Disk Access Time= average rotation time+ average seek time+data transfer time+controller overhead time.

For a disk with 7200RPM, the average rotation time= 0.5 rotations/7200RPM= 0.00415 sec

What is the average time to read/write a 512 byte sector for a typical disk:

average seeek time=9ms,
data transfer rate is 4MB/s,
RPM=7200,
controller overhead=1 ms.
Assume no queueing delay.

Ans: 9ms+(0.5/(7200/60))*1000 ms+0.5KB/4.0MB/s+1ms=9+4.15+0.125+1=14.3 ms.
http://cs.uccs.edu/~cs520/S99ch6.PDF



How does Assembly Code run on a microprocessor?


every program that is run on a computer is being executed inside the processor
The microprocessor or Central Processing Unit (CPU) is the heart of the computer
it is the piece of hardware that carries out the tasks or instructions sent to it by the user or operating system

 A program is a set of instructions that are written in a higher-level language, like C/C++ and Java, and translated to a lower-level language by the compiler to assembly and then object or machine code, 1’s and 0’s
 assembler and compiler maps the human readable instructions to machine code, in order to be read by the computer.

 the only language the computer hardware, including the processor, understands is Machine Language

 To code in machine language directly would be problematic and very confusing, so programmers invented a lower-level language called assembly language. Assembly language is just machine language translated to a human readable format that is standardized.

 Just like English there are many different types of assembly languages and each one is specific to the processor it is running on

 The simplest and widely used assembly language is MIPS.
 The MIPS architecture uses only three formats to organize its 128 different types of instructions.
 In a 32-bit architecture each instruction is 32 bits wide and the first six bits (opcode) represent the instruction the processor needs to execute.


 There are three stages in the cycle of the programs execution: Fetch, Decode, and Execute

 The first stage, Fetch, fetches the current instruction from the memory and stores it into the PC or program counter.
 In the decode stage, the instruction is decoded so the processor knows what to do
 The last stage, execute, executes the current decoded instruction.

 This cycle then repeats after PC is incremented by 4, to load the next instruction.
 Once all instructions are done executing the program is done executing.

 http://www.personal.psu.edu/scb5156/assignment5.html

Binary Arithmetic Operations



  • Rules of Binary Addition


0 + 0 = 0
0 + 1 = 1
1 + 0 = 1
1 + 1 = 0, and carry 1 to the next more significant bit
For example,

00011010 + 00001100 = 00100110                1  1 carries
  0  0  0  1  1  0  1  0   =   26(base 10)
+ 0  0  0  0  1  1  0  0
   =   12(base 10)
  0  0  1  0  0  1  1  0   =   38(base 10)


00010011 + 00111110 = 01010001         1  1  1  1  1 carries
  0  0  0  1  0  0  1  1   =   19(base 10)
+ 0  0  1  1  1  1  1  0
   =   62(base 10)
  0  1  0  1  0  0  0  1   =   81(base 10)
Note:  The rules of binary addition (without carries) are the same as the truths of the XOR gate.

http://academic.evergreen.edu/projects/biophysics/technotes/misc/bin_math.htm#add



  • Binary Subtraction Examples

It's almost exactly the same as decimal subtraction except that when you need to borrow, you borrow 2 instead of 10.

Here are some examples of binary subtraction. These are computed without regard to the word size, hence there can be no sense of "overflow" or "underflow". Work the columns right to left subtracting in each column. If you must subtract a one from a zero, you need to “borrow” from the left, just as in decimal subtraction.

http://sandbox.mc.edu/~bennet/cs110/pm/sub.html

two's complement

  • two's complement is the way every computer I know of chooses to represent integers. To get the two's complement negative notation of an integer, you write out the number in binary. You then invert the digits, and add one to the result.


Suppose we're working with 8 bit quantities (for simplicity's sake) and suppose we want to find how -28 would be expressed in two's complement notation. First we write out 28 in binary form.

00011100
Then we invert the digits. 0 becomes 1, 1 becomes 0.

11100011
Then we add 1.

11100100
That is how one would write -28 in 8 bit binary.



Example 2

Now suppose we want to subtract 12 from 69. Now, 69 - 12 = 69 + (-12). To get the negative of 12 we take its binary representation, invert, and add one.

0000 0000 0000 0000 0000 0000 0000 1100
Invert the digits.

1111 1111 1111 1111 1111 1111 1111 0011
And add one.

1111 1111 1111 1111 1111 1111 1111 0100
The last is the binary representation for -12. As before, we'll add the two numbers together.

1111 1111 1111 1111 1111 1111 1    1
Carry Row
  0000 0000 0000 0000 0000 0000 0100 0101
(69)
+ 1111 1111 1111 1111 1111 1111 1111 0100
(-12)
  0000 0000 0000 0000 0000 0000 0011 1001
(57)

We result in 57, which is 69-12.

Example 3

Lastly, we'll subtract 69 from 12. Similar to our operation in example 2, 12 - 69 = 12 + (- 69). The two's complement representation of 69 is the following. I assume you've had enough illustrations of inverting and adding one.

1111 1111 1111 1111 1111 1111 1011 1011
So we add this number to 12.
111  
Carry Row
  0000 0000 0000 0000 0000 0000 0000 1100
(12)
+ 1111 1111 1111 1111 1111 1111 1011 1011
(-69)
  1111 1111 1111 1111 1111 1111 1100 0111
(-57)

This results in 12 - 69 = -57, which is correct.

http://www.cs.cornell.edu/~tomf/notes/cps104/twoscomp.html





  • Arithmetic operations


Addition
Adding two's-complement numbers requires no special processing if the operands have opposite signs: the sign of the result is determined automatically. For example, adding 15 and −5:
 11111 111   (carry)
  0000 1111  (15)
+ 1111 1011  (−5)
==================
  0000 1010  (10)
This process depends upon restricting to 8 bits of precision; a carry to the (nonexistent) 9th most significant bit is ignored, resulting in the arithmetically correct result of 1010.

http://en.wikipedia.org/wiki/Two's_complement






  • Calculation of 2's Complement


To calculate the 2's complement of an integer, invert the binary equivalent of the number by changing all of the ones to zeroes and all of the zeroes to ones (also called 1's complement), and then add one.

For example,

0001 0001(binary 17)      1110 1111(two's complement -17)

NOT(0001 0001) = 1110 1110  (Invert bits)
1110 1110 + 0000 0001 = 1110 1111  (Add 1)


2's Complement Addition

Two's complement addition follows the same rules as binary addition.

For example,

5 + (-3)  =  2    0000 0101 = +5
+ 1111 1101
 = -3
  0000 0010 = +2



 2's Complement Subtraction

Two's complement subtraction is the binary addition of the minuend to the 2's complement of the subtrahend (adding a negative number is the same as subtracting a positive one).

For example,

7 - 12  =  (-5)    0000 0111 = +7
+ 1111 0100
 = -12
  1111 1011 = -5



2's Complement Multiplication
Two's complement multiplication follows the same rules as binary multiplication.


2's Complement Division
Two's complement division is repeated 2's complement subtraction. The 2's complement of the divisor is calculated, then added to the dividend. For the next subtraction cycle, the quotient replaces the dividend. This repeats until the quotient is too small for subtraction or is zero, then it becomes the remainder. The final answer is the total of subtraction cycles plus the remainder
http://academic.evergreen.edu/projects/biophysics/technotes/program/2s_comp.htm#calculate



  • two's complement notation
If you have -30, and want to represent it in 2's complement,

you take the binary representation of 30
0000 0000 0000 0000 0000 0000 0001 1110

Invert the digits.
1111 1111 1111 1111 1111 1111 1110 0001

And add one.
1111 1111 1111 1111 1111 1111 1110 0010


Suppose we're working with 8 bit quantities
suppose we want to find how -28 would be expressed in two's complement notation

First we write out 28 in binary form.
00011100

Then we invert the digits. 0 becomes 1, 1 becomes 0.
11100011

Then we add 1.
11100100

That is how one would write -28 in 8 bit binary.


Two's Complement
Begin with the number in one's complement.
Add 1 if the number is negative

12 would be represented as 00001100 and -12 as 11110100.

To verify this, let's subtract 1 from 11110100, to get 11110011. If we flip the bits, we get 00001100, or 12 in decimal.

http://www.math.grin.edu/~rebelsky/Courses/152/97F/Readings/student-binary#sign

Flip Flops



  • In the electronics world, a flip-flop is a type of circuit that contains two states and are often used to store state information. By sending a signal to the flip-flop, the state can be changed. In sequential logic, it is the basic element of storage. Flip-flops are used in a number of electronics, including computers and communications equipment.

http://www.computerhope.com/jargon/f/flipflop.htm


  • In electronics, a flip-flop or latch is a circuit that has two stable states and can be used to store state information. 

The circuit can be made to change state by signals applied to one or more control inputs and will have one or two outputs. It is the basic storage element in sequential logic. Flip-flops and latches are a fundamental building block of digital electronics systems used in computers, communications, and many other types of systems.

http://en.wikipedia.org/wiki/Flip-flop_(electronics)#Flip-flop_types



  • Flip-flops are heavily used for digital data storage and transfer and are commonly used in banks called "registers" for the storage of binary numerical data.

http://hyperphysics.phy-astr.gsu.edu/hbase/electronic/flipflop.html

Flip Flops basics:
•Storage elements for synchronous circuits (what is synchronous?)
•Typical configurations:
•SR (set_reset)
•D
•JK
•T (toggle)
http://www.engr.uky.edu/~elias/lectures/ln_13.pdf

Sunday, April 14, 2013

Associative array



  • Associative array

In computer science, an associative array, map, or dictionary is an abstract data type composed of a collection of  pairs, such that each possible key appears at most once in the collection.

The dictionary problem is the task of designing a data structure that implements an associative array. A standard solution to the dictionary problem is a hash table; in some cases it is also possible to solve the problem using directly addressed arrays, binary search trees, or other more specialized structures

Associative arrays have many applications including such fundamental programming patterns as memoization and the decorator pattern.

http://en.wikipedia.org/wiki/Associative_array