Follow us on facebook

Showing posts with label Linux Notes. Show all posts
Showing posts with label Linux Notes. Show all posts

Wednesday, 29 May 2013

IP Header Format Tutorial pdf

IP Header Format

Unlike the post office, a router or computer cannot determine the size of a package without additional information. A person can look at a letter or box and determine how big it is, but a router cannot. Therefore, additional information is required at the IP layer, in addition to the source and destination IP addresses. Figure 3-12 is a logical representation of the information that is used at the IP layer to enable the delivery of electronic data. This information is called a header, and is analogous to the addressing information on an envelope. A header contains the information required to route data on the Internet, and has the same format regardless of the type of data being sent. This is the same for an envelope where the address format is the same regardless of the type of letter being sent.


                                                                  IP Header Tutorial

Download Link

Tuesday, 21 May 2013

Network Address Translation tuturial ppt

Short form of NAT is Network Address Translation, an Internet standard that enables a local-area network (LAN) to use one set of IP addresses for internal traffic and a second set of addresses for external traffic. A NAT box located where the LAN meets the Internet makes all necessary IP address translations.

Network Address Translator serves three main purposes:
Provides a type of firewall by hiding internal IP addresses

1.Enables a company to use more internal IP addresses. Since they're used internally only, there's no possibility of conflict with IP addresses used by other companies and organizations.

2.Allows a company to combine multiple ISDN connections into a single Internet connection.

3.Network Address Translation, an Internet standard that enables a local-area network (LAN) to use one set of IP addresses for internal traffic and a second set of addresses for external traffic. A Network Address Translator box located where the LAN meets the Internet makes all necessary IP address translations.

NAT ppt Download Link

Network Address Translation tutorial


What is NAT (Network Address Translation)?

Using NAT with NETGEAR products, accessing the Internet, the addresses on your LAN are substituted for a single WAN IP address. This lets your computers share one IP address from your ISP. It also makes your network more secure, since traffic to and from the Internet now goes through your router's address substitution process, blocking direct access to your local IP addresses. Unless you use port forwarding, port triggering, or a DMZ, your computers are not reachable from the Internet (unless one of your computers requests it, of course!)


HOW IT WoRKS


Network Address Translation translates and IP address used in a network to another IP address known within another network. A NAT table is maintained for global to local and local to mapping of IP’s. NAT can be statically defined or dynamically translate from a pool of addresses. The NAT router is responsible for translating traffic coming and leaving the network. NAT prevents malicious activity initiated by outside hosts from reaching local hosts by being dependent on a machine on the local network to initiate any connection to hosts on the other side of the router.
NAT is like the receptionist in a large office. Let's say you have left instructions with the receptionist not to forward any calls to you unless you request it. Later on, you call a potential client and leave a message for them to call you back. You tell the receptionist that you are expecting a call from this client and to put them through.
The client calls the main number to your office, which is the only number the client knows. When the client tells the receptionist who they are looking for, the receptionist checks a lookup table that matches up the person's name and extension. The receptionist knows that you requested this call, therefore the receptionist forwards the caller to your extension.
Developed by Cisco, Network Address Translation is used by a device (firewall, router or computer) that sits between an internal network and the rest of the world. NAT has many forms and can work in several ways:
  • Static NAT – Mapping an unregistered IP address to a registered IP address on a one-to-one basis. Particularly useful when a device needs to be accessible from outside the network.
In static NAT, the computer with the IP address of 192.168.32.10 will always translate to 213.18.123.110:

  • Dynamic NAT – Maps an unregistered IP address to a registered IP address from a group of registered IP addresses. Dynamic NAT also establishes a one-to-one mapping between unregistered and registered IP address, but the mapping could vary depending on the registered address available in the pool, at the time of communication.
In dynamic NAT, the computer with the IP address of 192.168.32.10 will translate to the first available address in the range from 213.18.123.100 to 213.18.123.150:


A NAT example

If a small business is using the 192.168.0.0 network ID for its intranet and has been granted the public address of w1.x1.y1.z1 by its Internet service provider (ISP), then network address translation (NAT) maps all private addresses on 192.168.0.0 to the IP address of w1.x1.y1.z1. If multiple private addresses are mapped to a single public address, NAT uses dynamically chosen TCP and UDP ports to distinguish one intranet location from another.
Note
  • The use of w1.x1.y1.z1 and w2.x2.y2.z2 is intended to represent valid public IP addresses as allocated by the Internet Assigned Numbers Authority (IANA) or an ISP.
The following illustration shows an example of using NAT to transparently connect an intranet to the Internet.

If a private user at 192.168.0.10 uses a Web browser to connect to the Web server at w2.x2.y2.z2, the user's computer creates an IP packet with the following information:
  • Destination IP address: w2.x2.y2.z2
  • Source IP address: 192.168.0.10
  • Destination port: TCP port 80
  • Source port: TCP port 5000
This IP packet is then forwarded to the NAT protocol, which translates the addresses of the outgoing packet to the following:
  • Destination IP address: w2.x2.y2.z2
  • Source IP address: w1.x1.y1.z1
  • Destination port: TCP port 80
  • Source port: TCP port 1025
The NAT protocol keeps the mapping of {192.168.0.10, TCP 1025} to {w1.x1.y1.z1, TCP 5000} in a table.
The translated IP packet is sent over the Internet. The response is sent back and received by the NAT protocol. When received, the packet contains the following public address information:
  • Destination IP address: w1.x1.y1.z1
  • Source IP address: w2.x2.y2.z2
  • Destination port: TCP port 1025
  • Source port: TCP port 80
The NAT protocol checks its translation table and maps the public addresses to private addresses and forwards the packet to the computer at 192.168.0.10. The forwarded packet contains the following address information:
  • Destination IP address: 192.168.0.10
  • Source IP address: w2.x2.y2.z2
  • Destination port: TCP port 5000
  • Source port: TCP port 80
For outgoing packets from the NAT protocol, the source IP address (a private address) is mapped to the ISP allocated address (a public address), and the TCP/UDP port numbers are mapped to a different TCP/UDP port number.
For incoming packets to the NAT protocol, the destination IP address (a public address) is mapped to the original intranet address (a private address), and the TCP/UDP port numbers are mapped back to their original TCP/UDP port numbers.
Note
  • Packets that contain the IP address only in the IP header are properly translated by NAT. Packets that contain the IP address within the IP payload may not be properly translated by NAT.


IPC, Encryption & Decryption



Definition Of Inter-Process Communication
In computing programs, we need some medium of communication that will facilitate communication between the different processes. Processes can make use of the kernel of the operating system in order to communicate between the different processes all of whom share a unique space in the memory.
Different Mechanisms Of Communication
A number of different mechanisms can be used for the function of communication between processes. Different application programs may require different modes of communication. There are a few basic mechanisms that Unix-based operating systems like Linux use to allow message exchange between different processes. These are as follows:
·        Pipes
·        Semaphores
·        Shared Memory
·        Message Queues

Pipes:Pipes are communication devices through which messages flow in only a single direction. A couple of file descriptors is present in a pipe that indicate at a pipe inode and then the file descriptors are returned via the filedes. In case of the file descriptor pair, filedes[0] is used for reading whereas filedes[1] is used for writing.
In pipes, data once read from the read descriptor cannot be read once more. Another feature of the pipe is that if data is written continuously into the write descriptor, these data will be readable only in the order in which these data was written.   
When a pipe system call is invoked a pair of file descriptors is created. A pipe is implemented within the file system by the kernel. When the pipe system call is made, the kernel allocates free inodes and creates a pair of file descriptors and also the corresponding entries in the file table which the kernel makes use of. The kernel ensures that the two descriptors are for reading and writing.
FIFOs: FIFOs(First In, First Out) are much likes pipes in their operations. FIFOs have an access point, which is actually a file within a file system. Unlike pipes which last for only the life-cycle in which they are created, FIFOs last throughout the life-cycle of the system.         

SemaphoresSemaphores used in process communication are user mode versions of kernel semaphores. They operate as standard blocking devices and can be used to monitor the availability of system resources like the shared memory segments.
Shared MemoryShared memory is a System V IPC mechanism that allows message exchange between processes if they share the virtual address space. Any process sharing the memory can read or write to it.


Message QueuesMessage queues allow different processes to communicate with each other by exchanging messages or short blocks of data.
Sockets: Sockets allow different computers connected to a network exchange data through the network. They can also be used to communicate between processes within the same computing system.  

MORE EXPLANATION
PIPE
A pipe is a way to connect the output of one program to the input of another program without any temporary file.
Pipe Defined as:
"A pipe is nothing but a temporary storage place where the output of one command is stored and then passed as the input for second command. Pipes are used to run more than two commands ( Multiple commands) from same command line."
Syntax:
command1 | command2

semaphore

In programming, especially in Unix systems, semaphores are a technique for coordinating or synchronizing activities in which multiple processes compete for the same operating system resources. A semaphore is a value in a designated place in operating system (or kernel) storage that each process can check and then change. Depending on the value that is found, the process can use the resource or will find that it is already in use and must wait for some period before trying again. Semaphores can be binary (0 or 1) or can have additional values
.

What is Shared Memory?

Shared memory (SHM) is another method of interprocess communication (IPC) whereby 2 or more processes share a single chunk of memory to communicate.

Message Queues:

The basic idea of a message queue is a simple one.
Two (or more) processes can exchange information via access to a common system message queue. Process must share a common key in order to gain access to the queue in the first place (subject to other permissions.

Encryption & Decryption in Linux
ccrypt is a utility for encrypting and decrypting files and streams. It was designed as a replacement for the standard unix crypt utility, which is notorious for using a very weak encryption algorithm. ccrypt is based on the Rijndael cipher, which is the U.S. government's chosen candidate for the Advanced Encryption Standard (AES, see http://www.nist.gov/aes). This cipher is believed to provide very strong security.
Unlike unix crypt, the algorithm provided by ccrypt is not symmetric, i.e., one must specify whether to encrypt or decrypt. The most common way to invoke ccrypt is via the commands ccencrypt and ccdecrypt. There is also a ccat command for decrypting a file directly to the terminal, thus reducing the likelihood of leaving temporary plaintext files around. In addition, there is a compatibility mode for decrypting legacy unix crypt files. An emacs mode is also supplied for editing encrypted text files.
Encryption and decryption depends on a keyword (or key phrase) supplied by the user. By default, the user is prompted to enter a keyword from the terminal. Keywords can consist of any number of characters, and all characters are significant (although ccrypt internally hashes the key to 256 bits). Longer keywords provide better security than short ones, since they are less likely to be discovered by exhaustive search.

MODES

ccrypt can operate in five different modes. If more than one mode is specified, the last one specified takes precedence. The aliases ccencrypt, ccdecrypt, and ccat are provided as a convenience; they are equivalent to ccrypt -e, ccrypt -d, and ccrypt -c, respectively.
-e, --encrypt
Encrypt. This is the default mode. If filename arguments are given, encrypt the files and append the suffix .cpt to their names. Otherwise, run as a filter.
-d, --decrypt
Decrypt. If filename arguments are given, decrypt the files and strip the suffix .cpt from the filenames, if present. Otherwise, run as a filter.


Encrypting the file (password.txt)


To see the contents of Encrypted file


To find any particulat text use GREP command


To decrypt the file