Sunday 25 March 2012

Basic of Network Protocol

ARP

When a device needs to send an IP packet to another device on the local network, the IP software will first check to see if it knows the hardware address associated with the destination IP address. If it founds then the sender simply transmit the data to the destination. However, if the destination system's hardware address is not known then the IP software has to locate  it before any data can be sent. at this point, IP will call on ARP to locate the hardware address of the destination system.
ARP achieves this task by issuing a low level broadcast onto the network, equesting that the system that is using the specified IP address respond with its hardware address. if the destination system is powered up and on the network, it will see this broadcast (As will all  of the other devices on the local network), and it will return an ARP response back to the original system. not that the response is not broadcast back of the network. but is instead sent directly to the requesting device.

ARP structure

ARP packets work at the data-link layer, the same as IP packets. As such, ARP packets are completely separate from IP packets; they even have a different protocol  ID of 0806, instead of 0800 as used with IP.ARP packets contain several fields, although only five of them are actually used to proved ARP's functionality.
Field Usage
Source Hardware address The hardware address of the sender's device
Source IP address The network address of the senders device
Destination Hardware address The hardware address of the receiver's device (when this field is unknown ARP set it to all-zero)
Destination IP address The network address of the reciver's device
Message-Type Indicates whether the current ARP packets is a request or a response to a request

ARP Request

When a device is sending ARP request, it fills in three of the four address-related fields, providing its own hardware and IP address, as well as the IP address of the target. the destination hardware address is yet unknown so that field is filled with zeros. In addition it will set the message type to indicate that the current  packet is an ARP request, and then broadcast the request onto the local network for all devices to see

ARP Reply

All of the local devices should monitor the network for ARP broadcasts, and when ever they see a request for themselves they should generate a response packet and send it back to the requesting system. The response packet will consist of the local device's IP address of the original sender. The response will also be marked as as such, with the message-type field indicating that the current packet is an ARP response. the new ARP packet is then unicast directly to the original requester, where it is received and processed.

Friday 2 March 2012

Mysql Restore and Backup

1. Getting backup of a MySQL database using mysqldump.

Use following command line for taking backup of your MySQL database using mysqldump utility.

mysqldump –-user [user name] –-password=[password] [database name] > [dump file]
 
or
mysqldump –u[user name] –p[password] [database name] > [dump file]

Example:





mysqldump –-user root –-password=myrootpassword db_test > db_test.sql
 
or
 
mysqldump –uroot –pmyrootpassword db_test > db_test.sql

2. Backup multiple databases in MySQL.


mysqldump –u[user name] –p[password] [database name 1] [database name 2] .. > [dump file]
Example:

mysqldump –-user root –-password=myrootpassword db_test db_second db_third > db_test.sql

3. Backup all databases in MySQL.


shell> mysqldump –u[user name] –p[password] –all-databases > [dump file]

4. Backup a specific table in MySQL.



shell> mysqldump --user [username] --password=[password] [database name] [table name] \
> /tmp/sugarcrm_accounts_contacts.sql
Example:


shell> mysqldump --user root --password=myrootpassword db_test customers \
> db_test_customers.sql

5. Restoring MySQL database.

The mysqldump utility is used only to take the MySQL dump. To restore the database from the dump file that you created in previous step, use mysql command.


shell> mysql --u [username] --password=[password] [database name] < [dump file]
Example:

shell> mysql --user root --password=myrootpassword new_db < db_test.sql