How data packets travel source to destination over the network

Understanding How Data Packets Travel Across the Network When troubleshooting IP networks over Ethernet it helps to understand how packets travel across the network.

Packets use two different mechanisms to get from point A to Point B, or from the source to the destination. IP addresses and MAC addresses.

The MAC address is the layer 2 address that represents the specific hardware that is connected to the wire. The IP address is the layer 3 address that represents the logical identity of the device on the network.

MAC Address Most every computer today has some sort of network interface card (NIC) either built-in or installed on the computer.
Every NIC is created with a hardware number permanently "burned" into it.

This permanent hardware number is known as the MAC (Media Access Control). MAC addresses are 48 bits in length and are usually displayed as a 12 digit hexadecimal number.
MM:MM:MM:HH:HH:HH
The first 24 bits (or 6 digits) represent the manufacturer of the NIC. The last 24 bits (6 digits) are a unique identifier that represents the Host or the card itself. No two MAC identifiers are alike.IP Address The IP address is the logical address that is associated with the MAC for a particular device. IP addresses (IPv4) are a 32 bit (12 digit) number representing 4 binary octets.Both an IP and a MAC are needed for data to travel across an Ethernet network.

The ARP Protocol When a computer sends data over the network, it first needs to find which route it must take. Will the packet stay on the network or does it need to leave the network. The computer first determines this by comparing the subnet mask to the destination ip address.

Once this destination is known, Address Resolution Protocol (ARP) is used to find the next hop on the network. ARP's job is to basically discover andassociate IP addresses to the physical MAC.
For a packet that has a destination on another network, ARP is used to find the MAC of the gateway router. An ARP packet is sent to the gateway router asking for it's MAC. The router reply's back to the computer with it's mac address. The computer will then forward the packet directly to the mac address of the gateway router.

When the gateway router receives the packet it will remove it's mac address as the destination and replace it with
the mac address of the next hop router. It will also replace the source computer's mac address with it's own mac address. This happens at each route along the way until the packet reaches it's destination.

1 comment:

  1. //Sample Cisco Interview Questions
    #include
    #include
    using namespace std;
    class sample
    {
    public:
    sample(){cout<
    using namespace std;
    class sample
    {
    public:
    sample(){cout<<"constr"<
    #include
    #include
    void reverseStringBetter(char* str);
    int main()
    {
    char str[]="123456";
    int i, j;

    i=j=0;
    j=strlen(str)-1;

    for (i=0; i
    #include
    #include
    void func(char a,char b);
    int main()
    {
    //signed unsigned char
    func(127,128);
    printf("\n");
    return 0;
    }
    void func(char a,char b)
    {
    printf("%d and %d",a,b);//127, -128
    //printf("%d and %d",a,b);//127, 128//if unsigned char
    }
    */
    //find and replace own
    #include
    #include
    #include
    static void fr(char *, char *, char *);
    int main()
    {
    //char *str="Hello india How are you india";//seg fault diff between char a[]=<94>Hello<94> and char *p=<94>Hello<94>
    char str[]="Hello india How are you india";//now indivisual characters can be changed

    char *org="india";
    char *replace="INDIA";
    fr(str,org,replace);
    printf("str=%s\n",str);
    return 0;
    }

    static void fr(char *str, char *org, char *replace)
    {
    printf("%s %s %s\n",str,org,replace);
    char *s=str;
    char *o=org;
    char *r=replace;

    //char *tmp2;//seg fault
    char *tmp1=(char*)malloc(strlen(str)+1);
    char *tmp2;
    tmp2=tmp1;

    while(*s)
    {
    if(strncmp(s,org,strlen(org))==0)
    {
    strcpy(tmp1,replace);
    s=s+strlen(org);
    tmp1=tmp1+strlen(replace);
    }
    else
    {
    *tmp1++=*s++;
    }
    }
    *tmp1='\0';
    //printf("replaced string is:=%s\n",tmp1);
    strcpy(str,tmp2);//seg fault if str was char* and not char[]
    }
    /*
    Hello india How are you india india INDIA
    replaced string is:=Hello INDIA How are you INDIA

    */

    ReplyDelete