IP Addresses 32bits by nak14542

VIEWS: 94 PAGES: 12

									                      LAYER 2 in TCP/IP Suite: NETWORK LAYER
                              4. Application-HTTP, FTP, SMTP
                              3. Transport – TCP, UDP
                                                             ICMP
                              2. Network Layer – IP, ARP
                              1. Link Layer – Ethernet

The most important function of this layer is Routing (Protocol: IP).

This note includes the following topics:
   1. IP
   2. Subnetting
   3. ARP
   4. ICMP
   5. IP Fragmentation

IP: Internet Protocol
Packet Format:


Payload Options        D.IP S.IP Check_         ULP     TTL     Flags    ID    Total  TOS   Header   Version
                       Addr Addr sum                                           Length

variable Variable      32b   32b     16b        8b      8b      16b      16b   16b   8b     4b       4b


                                                     Header

                                                              Typical Header

IP Addresses: 32bits

An IP Address is 4 bytes or 1 octet number
It is divided into two parts

NetID(Org. ID)         HostID(Comp. ID)

Variable Dividing Point
X, Y, Z

IP Address: 4 bytes
               X                    Y                    Z
Generally you want the right side to be larger.

Organization Size     Division point      NetID Field Size       HostID Field Size   Class
Large                 X                   1B                     3B                  A
Medium                Y                   2B                     2B                  B
Small                 Z                   3B                     1B                  C


Algorithm/Procedure to determine what class an address is (i.e. where the dividing line is)

Given an Address:

1. Check the first byte
       if the 1st bit of the 1st byte is 0, it is class A addr.
       Else if the 2nd bit of the 1st byte is 0, it is class B addr.
       Else if the 3rd bit of the 1st byte is 0, it is class C addr.



  1st byte             2nd byte            3rd byte             4th byte
 11010001        X    10100011       Y    00100111      Z      01000101
                      Net ID                                    HostID
     209          .     163          .        37         .         69

Dotted Decimal Notation: Express each byte in decimal form and separate bytes with dots. To do that you
convert it from binary to decimal.


Class      # of usable NetID’s     # of usable HostID’s       Range of Values
A          2^7-2=126               2^24-2=4M+                 1 through 126
B          2^14=16000+             65,534                     128 through 191
C          2^21                    254                        192 through 223


These numbers are derived from manipulating the bytes of an IP address according to the class.

Class A, the 1st byte is used to determine its NetID. In 1 byte there are 8 bits, so you use the formula that was
given earlier for 2^7 possible choices; 2^7-2 usable choices. 2^7 because the first bit is always fixed at 1.
In networking as a rule of thumb (not always true) all 0’s and all 1’s are reserved numbers. That is where the -2
comes from. The remaining 3 bytes have 24 bits in them so to get the number of HostID’s you would do 2^24-
2.

It is important to know the hostID and the NetID for routers to distinguish where a packet goes. It will look at
the NetID and send it to the appropriate organization, then from there it will reach the computer it needs to go
to.
SUBNETTING
Example: UH System 129.7.164.85
Class B
129.7=NetID
164.85=HostID

NetID almost functions like a LAN, however LAN’s only cover a mile in radius. The University of Houston has
at least 6 different campuses and they are in different geographic locations. What these campuses do are link
their routers to the main campus router, and the main campus router is linked to the Houston Node. However,
each campus cannot have a different NetID, so they use another ID technique which is sub-netting.

The HostID of the machine is split into two parts, the subnetID, and Actual HostID

                                    HostID
128            .   7            .   104             .   231
NetID                               SubnetID            Act.ID
UH System                           CL Campus           Computer

You can pick the subnetID and the Actual Host ID anyway you like. However, you must communicate to the
router how you designed the network. For that a subnet Mask is used.

What is a subnet mask?
It is a 4 byte number whose bits are set to:
     - Bits of the subnet mask which coincide with the netID bits are set to 1
     - Bits of the subnet mask which coincide with the subnetID are also set to 1
     - Bits of the subnet mask which coincide with the Actual host ID are set to 0.

Why use a subnet mask?
Subnet Masks used to “tell” router how long the subnet field is.

To design a subnet mask you have to take into consideration how many computers are going to be on the
network.

16bits (2 Bytes) to work with from the IP address. The first 2 were used for the NetID.
A     B    C      D    E     F    G     H     I     J     K     L     M N         O    P


To design a good one for UofH which has 6 campuses. Assuming no growth….
Divide at point C to allow 2^3-2 usable choices for the campus.

3 bit subnet  6 usable for subnets which should cover the 6 campuses
13 bit AHID(actual host ID)  2^13-2=8000+
      Example 1:

      UH system with 3 bit subnet field
      Subnet Mask in bits (NOT AN ADDRESS):

1     1   1     1   1   1   1       1   1     1   1   1   1   1       1       1   1     1   0   0   0   0   0       0   0   0   0   0   0   0   0
255                                 255                                       244                                   0


      Example2:

      Assume another UH Subnet Design with
      With…

      SM=255.255.248.0

      How long is the subnet field?
      - Convert to binary
      - Remember that this is a class B IP (128.7.                )
      Answer is 5 bits (yellow)

      1     1   1   1   1   1   1         1   1   1   1   1   1       1   1         1   1   1   1   1   0   0   0       0   0   0   0   0   0   0   0
      255                                 255                                       248                                 0


      Example 3:

      Class C address with SM=255.255.255.224
      How long is the subnet field?
         - Write in Binary First

      Answer = 3 bits
      Since it’s class C, the first 3 bytes are used for the NetID
      1     1   1   1   1   1   1         1   1   1   1   1   1       1   1         1   1   1   1   1   1   1   1       1   1   1   0   0   0   0   0
      255                                 255                                       255                                 224


      Example 4:

      A computer has an IP address of 169.172.234.52
      And a subnet mask of 255.255.252.0

      Answer the following:
      What is the network ID?
      169.172 (Class B, first 2 bytes are network ID)
      Subnet ID?
232.0
Actual Host ID?
2.52
How many subnet field bits?
6 bits (the first 16 bits were the the netID)
How many usable subnets?
2^6-2=up to 62 subnets

Step 1: Convert IP Address Covert Subnet mask to Binary
IP address: 10101001 10101100 11101010 00110100
Subnet Mask: 11111111 11111111 11111100 00000000

Step 2: AND operation
Take these two binaries and do a logical AND operation. The result of comparing the two is 1 if both bits from
the IP and Subnet mask is 1


IP addr.      10101001      10101100       11101010    00110100
Subnet        11111111      11111111       11111100    00000000
Result        10101001      10101100       11101000    00000000

Step 3: Convert the result back to the decimal
169.172.232.0

169                    172                       232               0
                 Network ID                                   Subnet ID


Step 4: Find AHID
SID + AHID = HID
AHID=HID-SID

234.52     HID
232.0      SID
2.52       Subtract these two to this


Example 5:

IP Addr= 102.78.250.117
Mask = 255.255.192.0
Same Questions as the previous

IP               01100110            01001110          11111010           01110101
Subnet           11111111            11111111          11000000           00000000
Result           01100110            01001110          11000000           00000000
                102                78                 192                 0
                NetID              Subnet ID

NetID=102 (Class A)
SID = 78.192.0
AHID= 0.58.117
Bits Used = 10
Usable Subnets = 2^10-2

78.250.117     HostID (Given at the top)
78.192.0       Subnet ID
0.58.117       AHID

Example 6:
IP Addr: 208.216.164.241
Mask 255.255.255.224
Same questions as previous

IP              11010000           11011000           10100100            11110001
Subnet          11111111           11111111           11111111            11100000
Result          11010000           11011000           10100100            11100000
                208                216                164                 224
                NetID                                                      SID

NetID=208.216.164.0 (Class C)
SID=224
AHID = 17
Number of bits used=3
Number of subnets=2^3-2=6

241      HostID
224      SubnetID
17       Actual Host ID (AHID)

Examples to do at home:
68.235.212.175
255.252.0.0

163.238.249.211
255.255.255.128

216.74.231.253
255.255.255.240


This whole process is the subnet mask because it masks out the parts that we are interested in.
Subnet Design
Paper Project will be based on this

A company has 5 offices in Clear Lake, Alvin, Pasadena, La Porte, Texas City. It is assigned an IP address of
208.216.164.____.

-Design a subnet mask
-Allocate addresses to computers in each city
-Assign an address to each router in each city (default gateway)
-Determine Broadcast address for each city
-Determine Subnet address of each city
-Give the network topology/connectivity diagram

Subnet Mask=?
       - Determine how many bits needed in the subnet field
       - Since you have at least 5 locations you can use 3 bits (8 possible, 6 usable)
Subnet Mask = 255.255.255.224 (Class C, 224 is what 3 bits are next to each other)

Table in Excel…

Transmission:
Unicast  one to one
Multicast  one to many
Broadcast  one to all

If all bits in an AHID are set to 1’s would mean broadcast to ALL machines.

If all bits in an AHID are 0’s means “THIS” It means this computer.
ARP – Address Resolution Protocol
Ethernet Address is 6 bytes long and they are used in hexadecimal

Assume A wants to send a packet to D

An ARP Request is sent out before the packet on a broadcast destination to ask which computer has the
hardware address of a specific IP. Every computer reads the contents of the ARP message, the computer with
the specific hardware address will respond back, then the computer that originally sent the ARP message will
sent the packet through.

ARP is used for mapping Address to the H/W

Broadcast Ethernet = When all AHID’s are set to one, in hexadecimal all the AHID’s are set to F.

Computers keep an ARP table or ARP Cache that looks something like this…

ARP Cache IP Addr.                            H/W Addr.
208.216.164.36                                C95b74ab372f


First 3 bites of an Ethernet address are always the manufacturing ID
This table is only temporary. If the computer stops talking to the one it had an Ethernet address for more than 10
minutes or so it will get rid of the cache.

arp -a will give you the arp cache

ipconfig will give you the ip configuration of the machine you are working on

ICMP: Internet Control Message Protocol
Used for two key purposes: error reporting and debugging.

Some ICMP Message Types:
 Time exceeded
 Echo Request
 Echo Reply
 Destination Unreachable

Echo Request Messages are used to see if a computer is actually responded to communication and it also
measures how long it takes for the packet to travel from point a to point b.

Packet Internet Groper - PING is a program that will allow computer X to send an echo request to computer
Y, and if successful, computer Y will respond and send echo response back.
When a computer continually sends an arp request over the network, and the destination computer does not
respond it will give up.

ping -n 1 129.7.164.1 this means send echo request once...

C. Lake
208.216.164.33 = Computer A
208.216.164.46= Computer B
208.216.164.62 = Router

Is the target he same subnet as the source?
         If yes – then send directly
         If no – send the packet to default gateway

Source 129.7.162.136
       255.255.248.0

Target 129.7.166.85

Source Subnet ID =? Target Subnet ID
Yes = Direct
No = Default Gateway

To answer the question if they are on the same subnet you do the following:

Use the subnet ID of the first one, and use the ip of the destination, convert to binary and use AND comparison.

Subnetting waste addresses

208.216.164.___ 5 cities + future city

In subnets where 32, 64, 96, 128, 160, 192

6 subnets
30 addresses in each subnet
180 addresses total

If no subnetting, you can get all addresses in the last byte, you would get 254. So if you get 180 addresses with
subnetting and 254 without subnetting, you are wasting 74 addresse.

Find out how many will be wasted if SM=255.255.255.240
IP Fragmentation
MTU – Maximum Transmission Units; Used for payload size of link layer frame. Essentially the maximum
payload size a frame can carry = MTU

The maximum payload size of an Ethernet frame is 1500 bytes. MTU of Ethernet
Different link layer protocols have different MTU sizes. Think of it as a truck

Token Ring MTU = 4500 bytes

Example 1:
LANS use shared links, WANs use dedicated links.

Ethernet MTU = 1500 bytes
WAN MTU = 1008 bytes (assumed for this example)

Computer X is trying to send a packet across the WAN.

Packet is encapsulated into an Ethernet Frame. Consider the Ethernet frame as your truck.

Once the truck reaches the router and tries to send it across the WAN, it can’t because the maximum payload
size on the WAN is 1008 bytes. So fragmentation is used. The frame is split into 2 separate frames so it can fit.
Reassembly occurs at the end point.

Review the IP header:

Flags and Packet ID are related to fragmentation.
       - Packet ID, every packet ID is assigned a unique ID.
       - Flags field is a 16 bit field.

F    R      A     G    M E         N    T      A     T      I     O      N     Don’t    More      Reserved
            O     F    F     S     E    T                                      Fragment Fragments
(13 bits used for fragmentation offset)

Pretty much the header fields are the same in the fragmented packets with the exception of a few fields.

Original Packet Relevant fields
       - Assume Packet ID=43
       - DF = 0
       - MF = 0 (non-fragmented packets)

Packet:
Payload (1480 bytes)                                                         Header (20 bytes)
Byte 1479 ….              ….          Byte 2       Byte 1       Byte 0

Count the bytes of the payload starting from 0 all the way to 1479
Byte 0 through 987 is going to go into the first fragment, and the rest is going to go into the second fragment
because the WAN has an MTU of 1008.

After Fragmentation

Packet 1 Relevant Fields
       Packet ID = 0
       Don’t Fragment = 0
       More Fragments = 1 (means more fragments to follow)
       Fragmentation offset = 0 (This is 0 because the first byte is 0)

Packet 2 Relevant Fields
       Packet ID =0
       Don’t Fragment = 0
       More Fragments = 0 (no more fragments to follow)
       Fragmentation offset = 988 (essentially identifies the sequential first byte of each packet according to
       the original packet. Where it fits in the original packet)

Example 2
Refinement# 1

Fragmentation occurs at 8-byte boundaries.

Can’t just take a packet and divide it wherever, you have to break it up where it divisible by 8 bytes
Payloads should have a byte count that is divisible by 8.

Going to back our previous example….
Is 988 divisible by 8? No
What is the closest number which is smaller than 988 that is divisible by 8? 984

Since this is the case, the first packet is fragmented from 0 to 984. The second packet is 984 to1479.

Refinement# 2

Fragmentation offset is measured in unit of 8- byte word.

After the second refinement the numbers will change. So instead of writing 984 is divided by 8 and converted
into 123. This is programmed into the fragmentation offset.

Fragmentation can occur at a router or it can occur at the source.

Ping: The data part of ICMP message is randomly picked numbers. It sends random data and the destination
echos back.

Say if you ping a computer with a 2000 byte buffer. This is where fragmentation occurs at the source.
If you set the DF field to 1, the routers cannot fragment the packet all they can do is drop and send an ICMP
message.

Example 3
Assume the MTU on the WAN is 512 now

Packet Payload = 492 bytes max

1st Packet PID= 43 DF=0 MF=0 Fragmentation offset = 0 (Packet Carries 488 bytes)
2nd Packet PID=43 DF=0 MF=1 Fr. Offset = 61 (Packet Carries 488 bytes)
3rd Packet PID=43 DF=0 MF=1 Fr. Offset = 122 (“ “     “ “)
4th Packet PID=43 DF=0 MD=1 Fr. Offset=183(“ “      “ “)

Total bytes is 1464

Exercise
2nd MTU=256 bytes

								
To top