5-IP Address and Subnetting subnet mask

Embed Size (px)

DESCRIPTION

ip and subnet maskeasy to understand tutorial for anyone

Citation preview

  • 5/20/2018 5-IP Address and Subnetting subnet mask

    1/36

    IP Address and Subnetting

  • 5/20/2018 5-IP Address and Subnetting subnet mask

    2/36

    IP Address Basic

    What is an IP address

    IP stand for internet protocol. IP is the main protocol responsible for

    routing packet across network including the internet. Today IP version 4

    (IPv4) is mostly responsible for the routing of packets on modern

    network. IP version 6 (IPv6) will soon evolve as the primary protocol as

    the primary protocol for this purpose on the internet as all IPv4

    addresses has been allocated.

    An IP address is a way to identify a host on a network that

    communicates using IP protocol. It is a 32-bit number

    example: 11000000 10101000 00000000 00000001

    Because there are 32 bits in an IP address, and each bit can be either a 0

    or a 1, we have a 232possible IPv4 addresses (about 4.2 billion)

  • 5/20/2018 5-IP Address and Subnetting subnet mask

    3/36

    Dotted Decimal Format

    The 32 bits IP address is tipically viewed in a "dotted decimal"

    format. The IP address is devided into 8-bit octets.

    Example: Binary IP address: 11000000101010000000000000000001

    [ octet 1 ][ octet 2 ][ octet 3 ][ octet 4 ]

    Binary address to octets: 11000000 10101000 00000000 00000001

    Example: Dotted Decimal IP Address: 192.168.0.1

    Dotted decimal to binary conversion

    Convert each 8 bit octet into binary number

    Binary to dotted decimal conversion

    Devide your 32 bits into 4 8-bit octets

    Convert each 8-bit octet from binary to decimal

  • 5/20/2018 5-IP Address and Subnetting subnet mask

    4/36

    Subnet Mask

    Each IP address is made up into 2 different pieces.

    Network portion

    Define the network address - What network to route to?

    Host portion

    Define hosts on that specific network

    A subnet mask is also a 32 bits number that tell the router which bitof the IP address are for the network portion and which bit are for

    the host portion.

    Subnet mask is also a binary number but is also communicated in

    dotted decimal format or CIDR format

    Example subnet mask: 11111111.11111111.11111111.00000000

    Subnet mask in dotted decimal: 255.255.255.0

  • 5/20/2018 5-IP Address and Subnetting subnet mask

    5/36

    Subnet Mask

    Subnet mask example

    IP: 192.168.1.1

    Subnet mask: 255.255.255.0

    determine the host portion and network portion for this network

  • 5/20/2018 5-IP Address and Subnetting subnet mask

    6/36

    IP Address Classes

    Originally the entire IP address range was broken down into 5 classes: A, B,

    C, D, E

    The class of an IP address was determined by the first octet in the IP

    address.

    Each class has a default subnet mask

    When calculating hosts IP addresses, 2 IP addresses are decreased

    because they cannot be assigned to hosts i.e. the first IP of a network isnetwork number and the last IP is reserved for Broadcast IP.

    ClassMSB of 1st

    octet1st Octet Mask Format

    A 0 1 - 127 255.0.0.0 n.h.h.h

    B 10 128 - 191 255.255.0.0 n.n.h.h

    C 110 192 - 223 255.255.255.0 n.n.n.h

    D 1110 224 - 239 Multicast Multicast

    E - 240 - 255 Experimental Experimental

  • 5/20/2018 5-IP Address and Subnetting subnet mask

    7/36

    Private IP Address Space

    RFC 1918 defines IP address ranges on private network

    These IP addresses is not routable on the global internet and are

    used inside private network.

    IP address class terminology is rarely used in the industry anymore

    because of the introduction of the classless interdimain routing(CIDR)

    Network Mask Range

    10.0.0.0 255.0.0.0 10.0.0.0 - 10.255.255.255

    172.16.0.0 255.240.0.0 172.16.0.0 - 172.31.255.255

    192.168.0.0 255.255.0.0 192.168.0.0 - 192.168.255.255

  • 5/20/2018 5-IP Address and Subnetting subnet mask

    8/36

    CIDR Notation

    Traditionally subnet masks are determined by the IP address class,

    so there were only three subnet mask you would see. For class A,B,and C network

    To preserve IP address space, use them more efficiently, and help

    reduce burdon on global routing table, classless interdomain routing

    was born (CIDR).

    CIDR is used for IP address aggregation and specifies the subnet

    mask in a different notation.

    The CIDR notation list the network followed by a "/" followed by the

    number of the subnet mask bits

    Example: 192.168.0.0 / 16

    Example: 220.140.10.0 / 25

    Example: 8.8.8.8 / 30

  • 5/20/2018 5-IP Address and Subnetting subnet mask

    9/36

    CIDR Notation

    In Class A, only the first octet is used as Network identifier and rest

    of three octets are used to be assigned to Hosts (i.e. 16777214Hosts per Network). To make more subnet in Class A, bits from Host

    part are borrowed and the subnet mask is changed accordingly.

    For example, if one MSB (Most Significant Bit) is borrowed from host

    bits of second octet and added to Network address, it creates two

    Subnets (21=2) with (223-2) 8388606 Hosts per Subnet.

    The Subnet mask is changed accordingly to reflect subnetting.

    Given below is a list of all possible combination of Class A subnets:

  • 5/20/2018 5-IP Address and Subnetting subnet mask

    10/36

    CIDR Notation

  • 5/20/2018 5-IP Address and Subnetting subnet mask

    11/36

    CIDR Notation

    Example

    What is the Network ID, Broadcast Address, First Usable IP, and Last

    Usable IP on the subnetwork that the node 192.168.1.15/26 belongs to?

  • 5/20/2018 5-IP Address and Subnetting subnet mask

    12/36

    Subnet a network

    Subnet Chart

    Example : Assume you own the 199.1.2.0 network. You need to create 16

    subnets and you will need no more than 12 host on each subnet.

  • 5/20/2018 5-IP Address and Subnetting subnet mask

    13/36

    Subnet a network

    Step 1

    Find out how many bits you need to borrow by powers of 2 (starting with

    21) from the most left bit until you reach the number of subnets you

    need.

    Draw an imaginary line to the right of the last bit you borrow.

    The subnet mask you need is the one to the left of the line

    To make sure you have the right amount of host for each network, you

    can count by powers of two (starting with 21) from the right most bit untilyou reach the number of hosts you need.

  • 5/20/2018 5-IP Address and Subnetting subnet mask

    14/36

    Subnet a network

    Step 2

    Obtain the network addresses by starting with the 0 network, which is

    always the first (199.1.2.0) and adding the bit value that correspond to the

    mask.

    for this example that tells us the second network is 199.1.2.16

    Continue to increment by this bit value to obtaine all the network addresses.

    199.1.2.0

    199.1.2.16

    199.1.2.32

    199.1.2.48

    199.1.2.64

    199.1.2.80

    199.1.2.96 ..... and so on

  • 5/20/2018 5-IP Address and Subnetting subnet mask

    15/36

    Subnet a network

    Step 3

    Once you see the network addresses, it's easy to determine the

    broadcast addresses and the valid host addresses for each subnet

    For example

    the last address on the 199.1.2.0 network has to be 199.1.2.15 because

    199.1.2.16 is the next network address

    since it's the last address, 199.1.2.15 is the broadcast address.

    All addresses between 199.1.2.0 to 199.1.2.15 are the host address for the

    network. (199.1.2.1 - 199.1.2.14)

  • 5/20/2018 5-IP Address and Subnetting subnet mask

    16/36

    Subnet a network

    Example :

    XYZ company would like to subnet its network so that there are 5 separate

    subnets. They will need 25 computers in each subnet. Complete each of the

    following.

    NOTE: If you create more than 5 subnets, list the extra ones too.

    Subnet Network Address Host Addresses Broadcast Address

    Subnet Mask : 255.255.255.___

    1st subnet 192.168.162.___ 192.168.162.___ - 192.168.162.___ 192.168.162.___

    2nd subnet 192.168.162.___ 192.168.162.___ - 192.168.162.___ 192.168.162.___

    3rd subnet 192.168.162.___ 192.168.162.___ - 192.168.162.___ 192.168.162.___

    4th subnet 192.168.162.___ 192.168.162.___ - 192.168.162.___ 192.168.162.___

    5th subnet 192.168.162.___ 192.168.162.___ - 192.168.162.___ 192.168.162.___

    6th subnet ?

    ?

  • 5/20/2018 5-IP Address and Subnetting subnet mask

    17/36

    Subnet a network

    Exercise

    KKK Sdn Bhd is wholly owned Malaysia company. In line with its expansion plan, thecompany is to be restructured to 8 department

    IT Department ( 5 hosts )

    Sales Department ( 4 hosts )

    Management Department ( 6 hosts )

    Services Department ( 8 hosts )

    Human Resource Department ( 7 hosts )

    Engineering Department ( 9 hosts )

    Supervision Department (3 hosts )

    Maintenance Department ( 5 hosts )

    As a consultant,you are required to design a C Class sub-network to be used by KKK SdnBhd

    Determine the subnet addresses for each department

    Identify the IP addresses assignment for each host

    Determine the broadcast addresses being used by each departmen

  • 5/20/2018 5-IP Address and Subnetting subnet mask

    18/36

    IPv4 OSI Model

    International Standard Organization has a well-defined Model for

    Communication Systems known as Open System Interconnection,or OSI Model. This layered model is a conceptualized view of how

    one system should communicate with the other, using various

    protocols defined in each layer.

    Further, each layer is designated to a well-defined part ofcommunication system

    For example

    The Physical layer defines all the components of physical nature, i.e. wires,

    frequencies, pulse codes, voltage transmission etc. of a communication

    system.

  • 5/20/2018 5-IP Address and Subnetting subnet mask

    19/36

    IPv4 OSI Model

  • 5/20/2018 5-IP Address and Subnetting subnet mask

    20/36

    IPv4 OSI Model

    Application Layer (Layer-7):

    This is where the user application sits who needs to transfer databetween or among hosts. For example: HTTP, file transfer application(FTP) and electronic mail etc.

    Presentation Layer (Layer-6): This layer helps to understand data representation in one form on a host

    to other host in their native representation. Data from the sender isconverted to on-the-wire data (general standard format) and at thereceivers end it is converted to the native representation of the receiver.

    Session Layer (Layer-5): This layer provides session management capabilities between hosts.

    For example if some host needs a password verification for access and

    if credentials are provided then for that session password verificationdoes not happen again. This layer can assist in synchronization, dialogcontrol and critical operation management (e.g., an online banktransaction)

  • 5/20/2018 5-IP Address and Subnetting subnet mask

    21/36

    IPv4 OSI Model

    Transport Layer (Layer-4):

    This layer provides end to end data delivery between/among hosts. Thislayer takes data from above layer and breaks it into smaller units calledSegments and then gives it to Network layer for transmission.

    Network Layer (Layer-3): This layer helps to uniquely identify hosts beyond the subnets and

    defines the path which the packets will follow or be routed to reach thedestination.

    Data Link Layer (Layer-2): This layer takes the raw transmission data (signal, pulses etc.) from

    Physical Layer and makes Data Frames and sends that to upper layerand vice versa. This layer also checks any transmission errors and sort

    it out accordingly.

    Physical Layer (Layer-1): This layer deals with hardware technology and actual communication

    mechanism like signaling, voltage, cable type and length etc.

  • 5/20/2018 5-IP Address and Subnetting subnet mask

    22/36

    IPv4 TCP/IP Model

    Majorly of the internet uses a protocol suite called the Internet

    Protocol Suite also known as TCP/IP protocol suite. Because thetwo major protocols in this suites are TCP (Transmission Control

    Protocol) and IP (Internet Protocol), this is commonly termed as

    TCP/IP Protocol suite.

    This protocol suite has its own reference model which it follows overthe internet.

    In contrast with OSI model, this model of protocols contains less

    layers.

  • 5/20/2018 5-IP Address and Subnetting subnet mask

    23/36

    IPv4 TCP/IP Model

  • 5/20/2018 5-IP Address and Subnetting subnet mask

    24/36

    Internet Protocol Version 4 (IPv4)

    Internet Protocol is one of the major protocol in TCP/IP protocols

    suite. This protocol works at Network layer of OSI model and atInternet layer of TCP/IP model.

    Thus this protocol has the responsibility of identification of hostsbased upon their logical addresses and to route data

    between/among them over the underlying network.

    IP provides a mechanism to uniquely identify host by IP addressingscheme.

    IP uses best effort delivery it does not guarantee that packets would be delivered to destined host but itwill do its best to reach the destination. Internet Protocol version 4 uses 32-bit logical address

  • 5/20/2018 5-IP Address and Subnetting subnet mask

    25/36

    IPv4 Packet Structure

    Internet Protocol being a layer-3 protocol (OSI) takes data

    Segments from layer-4 (Transport) and divides it into whats calledpacket. IP packet encapsulates data unit received from above layer

    and adds its own header information.

    The encapsulated data is referred to as IP Payload. IP header

    contains all the necessary information to deliver the packet at the

    other end.

  • 5/20/2018 5-IP Address and Subnetting subnet mask

    26/36

    IPv4 Packet Structure

  • 5/20/2018 5-IP Address and Subnetting subnet mask

    27/36

    IPv4 Packet Structure

    Version:

    Version no. of Internet Protocol used (e.g. IPv4) IHL: Internet Header Length,

    Length of entire IP header

    DSCP: Differentiated Services Code Point, This is Type of Service.

    ECN: Explicit Congestion Notification,

    carries information about the congestion seen in the route. Total Length: Length of entire IP Packet

    (including IP header and IP Payload)

    Identification: If IP packet is fragmented during the transmission, all the fragments contain

    same identification no. to identify original IP packet they belong to.

    Flags: As required by the network resources, if IP Packet is too large to handle

    these flags tell that if they can be fragmented or not. In this 3 -bit flag, theMSB is always set to 0.

  • 5/20/2018 5-IP Address and Subnetting subnet mask

    28/36

    IPv4 Packet Structure

    Fragment Offset:

    This offset tells the exact position of the fragment in the original IP Packet. Time to Live:

    To avoid looping in the network, every packet is sent with some TTL valueset, which tells the network how many routers (hops) this packet can cross.

    At each hop, its value is decremented by one and when the value reacheszero, the packet is discarded.

    Protocol: Tells the Network layer at the destination host, to which Protocol this packet

    belongs to, i.e. the next level Protocol. For example protocol number ofICMP is 1, TCP is 6 and UDP is 17.

    Header Checksum: This field is used to keep checksum value of entire header which is then

    used to check if the packet is received error-free.

    Source Address: 32-bit address of the Sender (or source) of the packet.

    Destination Address: 32-bit address of the Receiver (or destination) of the packet.

  • 5/20/2018 5-IP Address and Subnetting subnet mask

    29/36

    IPv4 Packet Structure

    Example of IP header from an IP packet received at destination :

    4500 003c 1c46 4000 4006 b1e6 ac10 0a63 ac10 0a0c

    '45 corresponds to the first two fields in the header

    4 corresponds to the IP version and 5 corresponds to the header length.

    '00 corresponds to TOS or the type of service. This value of TOS indicated normal operation.

    '003c' corresponds to total length field of IP header. In this case the total length of IP packet is 60.

    '1c46' corresponds to the identification field.

  • 5/20/2018 5-IP Address and Subnetting subnet mask

    30/36

    IPv4 Packet Structure

    4500 003c 1c46 4000 4006 b1e6 ac10 0a63 ac10 0a0c

    '4000 can be divided into two bytes.

    (divided into 3 bits and 13 bits respectively)

    correspond to the flags and fragment offset of IP header fields.

    '4006 can be divided into 40 and 06.

    40 corresponds to the TTL field

    06 corresponds to the protocol field of the IP header. 06 indicates thatthe protocol is TCP.

    b1e6 corresponds to the checksum which is set at the source

    this field will be set to zero while computing the checksum at destinationend.

    ac10 and 0a0c correspond to the source IP address and thedestination IP address in the IP header.

  • 5/20/2018 5-IP Address and Subnetting subnet mask

    31/36

    Error Detection (Checksum)

    A check sum is basically a value that is computed from data packet

    to check its integrity (check on whether the data received is errorfree or not).

    This is because while traveling on network a data packet can

    become corrupt and there has to be a way at the receiving end to

    know that data is corrupted or not.

    At the source side The checksum is calculated and set in header as a field

    At the destination side

    the checksum is again calculated and crosschecked with the existing

    checksum value in header to see if the data packet is OK or not.

    IP header checksum is : 16 bit ones complement of the onescomplement sum of all 16 bit words in the header

  • 5/20/2018 5-IP Address and Subnetting subnet mask

    32/36

    Error Detection (Checksum)

    Calculating Checksum:

    4500 003c 1c46 4000 4006 b1e6 ac10 0a63 ac10 0a0c

    Step1: Convert all these values in binary

    4500 -> 0100010100000000

    003c -> 0000000000111100

    1c46 -> 0001110001000110

    4000 -> 0100000000000000

    4006 -> 0100000000000110

    0000 -> 0000000000000000

    Note that the checksum is set to zero since we are computing checksum atdestination end

    ac10 -> 1010110000010000

    0a63 -> 0000101001100011

    ac10 -> 1010110000010000

    0a0c -> 0000101000001100

  • 5/20/2018 5-IP Address and Subnetting subnet mask

    33/36

    Error Detection (Checksum)

    Step 2: Add these binary values one by one

    4500 -> 0100010100000000

    003c -> 0000000000111100

    453C -> 0100010100111100 /// First result

    453C -> 0100010100111100 // First result plus next 16-bit word.

    1c46 -> 0001110001000110

    6182 -> 0110000110000010 // Second result.

    6182 -> 0110000110000010 // Second result plus next 16-bit word.

    4000 -> 0100000000000000

    A182 -> 1010000110000010 // Third result.

    A182 -> 1010000110000010 // Third result plus next 16-bit word.

    4006 -> 0100000000000110

    E188 -> 1110000110001000 // Fourth result.

  • 5/20/2018 5-IP Address and Subnetting subnet mask

    34/36

    Error Detection (Checksum)

    E188 -> 1110000110001000 // Fourth result plus next 16-bit word.

    AC10 -> 101011000001000018D98 -> 11000110110011000 // One odd bit (carry), add that odd bit to the result as we need to

    keep the checksum in 16 bits.

    18D98 -> 11000110110011000

    8D99 -> 1000110110011001 // Fifth result

    8D99 -> 1000110110011001 // Fifth result plus next 16-bit word.

    0A63 -> 0000101001100011

    97FC -> 1001011111111100 // Sixth result

    97FC -> 1001011111111100 // Sixth result plus next 16-bit word.

    AC10 -> 1010110000010000

    1440C -> 10100010000001100 // Again a carry, so we add it (as done before)

    1440C -> 10100010000001100

    440D -> 0100010000001101 // This is seventh result

    440D -> 0100010000001101 //Seventh result plus next 16-bit word

    0A0C -> 00001010000011004E19 -> 0100111000011001 // Final result.

  • 5/20/2018 5-IP Address and Subnetting subnet mask

    35/36

    Error Detection (Checksum)

    Step 3: ones compliment of final result to obtain the checksum.

    4E19 -> 0100111000011001

    B1E6 ->1011000111100110 // CHECKSUM

    compare the checksum with the one obtained in the packet

    same value of checksum means IP headers integrity was not lost.

  • 5/20/2018 5-IP Address and Subnetting subnet mask

    36/36

    Error Detection (Checksum)

    Example:

    4500 0514 42a2 2140 8001 ____ c0a8 0003 c0a8 0001

    Determine the checksum for the received data