Network(Layer( - University of California, Santa Cruz ·  · 2015-04-02......

101
Network Layer Brad Smith Spring 2015 CE 151 Advanced Networks 1

Transcript of Network(Layer( - University of California, Santa Cruz ·  · 2015-04-02......

Network  Layer  

Brad  Smith  

Spring  2015   CE  151  -­‐  Advanced  Networks   1  

Administra@via  

•  Any  problems  with  the  VMs?  

•  This  week  –  Sec@ons  today  @  4pm,  tomorrow  @  11am(?)  

•  Next  week  –  Link-­‐layer  lecture  next  Tuesday  (end  of  longest  run  of  lectures!)  –  Read  the  “End-­‐to-­‐End  Argument”  paper  –  Network  layer  quiz  on  Thursday...  remember,  review  orange  slides!  

Spring  2015   CE  151  -­‐  Advanced  Networks   2  

Internet  Background  •  The  ARPAnet  was  the  first  packet-­‐switched  network.  •  It’s  success  led  to  the  Internet  •  The  ARPAnet  architecture  

–  Homogeneous  switches  •  Interface  Message  Processors  (IMPs)  

–  Heterogeneous  hosts  –  The  Network  Control  Protocol  (NCP)  implemented  conserva@ve  error,  flow,  

and  conges@on  control  •  Hop-­‐by-­‐hop.  •  Stop-­‐and-­‐Wait.  

•  New  technical  challenges  –  Rou@ng.  –  Error,  flow,  and  conges@on  control  across  a  network.  

•  Link-­‐layer  (layer  2)  network  from  today’s  perspec9ve.  

Spring  2015   CE  151  -­‐  Advanced  Networks   3  

The  ARPAnet  

Spring  2015   CE  151  -­‐  Advanced  Networks   4  

HOST

Host-IMP IMP-IMP

HOST

Host-Host (NCP)

IMP

IMP

IMP

IMP

application application

Goals  of  the  Internet  •  New,  diverse  network  technologies  

–  LANs  (e.g  Ethernet)  –  DARPA  packet  radio  network  (PRNET)  –  DARPA  satellite  network  (SATNET)  

•  Internet  goal  –  Interconnec@on  of  diverse  networks,  which  we  call  subnets  

•  Minimal-­‐service  network  model  

•  Vint  Cerf  and  Robert  Kahn  -­‐  “A  Protocol  for  Packet  Network  Interconnec@on”  (May,  1974)  

Spring  2015   CE  151  -­‐  Advanced  Networks   5  

Minimal-­‐Service  Network  Model  •  New  concepts  

–  “Gateway”  interconnects  dissimilar  networks.  –  Internet-­‐level  host  addressing  

•  New  func@onality  –  Best-­‐effort  rou@ng.  –  NCP  upgraded  

•  End-­‐to-­‐end  error,  flow,  and  conges@on  control  •  Sliding-­‐window  error,  flow,  and  conges@on  control  •  Called  Transmission  Control  Protocol  (TCP)  

Spring  2015   CE  151  -­‐  Advanced  Networks   6  

The  Internet  Architecture  

Spring  2015   CE  151  -­‐  Advanced  Networks   7  

G

G

G G

SUBNET

SUBNET

SUBNET

SUBNET A

B

TCP

TCP

Evolu@on  of  TCP/IP  •  TCP  originally  meant  to  replace  NCP  

•  Problems  –  Monolithic  func@onality  –  Reliable  delivery  a  host-­‐host  issue  

•  Move  from  smart  network  to  smart  hosts  …  “End-­‐to-­‐end  Principle”  

•  TCP  split  into  TCP/IP  –  Internet  Protocol  (IP)  

•  Best-­‐effort  rou@ng  •  Internet  level  addressing  

–  Transmission  Control  Protocol  (TCP)    •  New,  end-­‐to-­‐end  error,  flow,  and  conges@on  control  

•  What  is  the  minimal  set  of  func@onality  needed  to  construct  an  internet?  

Spring  2015   CE  151  -­‐  Advanced  Networks   8  

End-­‐to-­‐End  Principle  

“If a function can completely and correctly be implemented only with the knowledge and help of the application end-points of a

communication system, then the function should not be implemented in the communication system itself (although

sometimes it may be useful to implement an incomplete version of the function in the communication system as a performance

enhancement).”

“End-to-End Arguments in System Design” by Saltzer, Reed, and Clark (‘84)

Spring  2015   CE  151  -­‐  Advanced  Networks   9  

End-­‐to-­‐End  Principle  •  Avoids  impac@ng  applica@ons  that  don’t  need  this  func@on.  

•  Reduces  complexity  of  the  network…  –  Dumb  network,  smart  end-­‐points…  reverse  of  the  telephone  system!  

•  Overall,  improves  efficiency  and  reliability  of  the  network.  

•  E.g.  Transport  func@ons…  –  End-­‐points  must  be  involved  to  ensure  data  makes  it  to  the  process  

(corrup@on  in  the  end-­‐system)  –  Therefore  no  transport  func@onality  in  the  network.  

•  Reasonable  interpreta@on…  for  func@ons  requiring  end-­‐point  involvement  –  Think  twice  before  implemen@ng  in  the  network  –  Jus@fy  as  a  performance  enhancement  –  Do  not  impose  a  burden  on  applica@ons  that  don’t  require  it  –  E.g.  very  lossy  (wireless)  links  –  Doesn’t  need  to  be  heavy-­‐weight…  can  depend  on  end-­‐to-­‐end  mechanisms  

Spring  2015   CE  151  -­‐  Advanced  Networks   10  

Evolu@on  of  TCP/IP  •  TCP  originally  meant  to  replace  NCP  

•  Problems  –  Monolithic  func@onality  –  Reliable  delivery  a  host-­‐host  issue  

•  Move  from  smart  network  to  smart  hosts  …  “End-­‐to-­‐end  Principle”  

•  TCP  split  into  TCP/IP  –  Internet  Protocol  (IP)  

•  Best-­‐effort  rou@ng  •  Internet  level  addressing  

–  Transmission  Control  Protocol  (TCP)    •  New,  end-­‐to-­‐end  error,  flow,  and  conges@on  control  

•  What  is  the  minimal  set  of  func@onality  needed  to  construct  an  internet?  

Spring  2015   CE  151  -­‐  Advanced  Networks   11  

Internet  Architecture  Following  pos@ng  from  Dave  Crocker  (early  Internet  par@cipant)  to  the  “end2end-­‐interest”  mailing  list  (4/11/13):    

Here's  a  comment  that  I  sent  earlier  today,  to  a  non-­‐technical  person  who  is  aware  of  the  overall  Internet  @meline,  but  I  believe  does  not  understand  what  is  dis@nc@ve  about  Internet  'architecture'.    I'm  curious  about  reac@ons  on  this  list,  and  any  possible  improvements  -­‐-­‐  including  complete  replacement  -­‐-­‐  but  more  importantly  I'm  interested  in  filling  in  the  details:    

The  original  use  of  the  term  Internet  was  to  describe  a  dis;nc;ve  technical  design  for  a  distributed,  scalable  data  exchange  fabric.    Its  design  characteris;cs  differ  drama;cally  from  those  of  its  predecessor,  the  Arpanet,  and  from  other  related  efforts.    

That's  what  I  sent.    To  prime  the  pump  for  the  detail:    

By  saying  'fabric'  I  meant  to  dis;nguish  the  mechanism  for  moving  raw  data  from  the  applica;ons  that  used  it.    What  I'd  class  as  dis;nc;ve  were  •  the  TCP/IP  separa9on,  •  the  remarkably  modest  func9onality  of  IP,  even  to  the  point  of  moving  it's  control  plane  to  the  

next  level  up  with  ICMP,  and  •  con9nuing  with  modest  expecta9ons  the  layer  below  (which  made  it  possible  to  operate  over  

any  medium  including  birds.)  This  is  usually  characterized  as  moving  robustness  to  the  edges.  

Spring  2015   CE  151  -­‐  Advanced  Networks   12  

Review  •  IP  goals  

–  interconnect  diverse  network  technologies,  making  minimal  assump@ons  of  the  underlying  networks  

–  implement  the  minimal  set  of  func@onality  needed  to  construct  an  internet…  in  this  sense  IP  is  the  waist  of  the  network  protocol  stack  hourglass  

•  IP  implements  a  datagram,  packet-­‐switched  model  of  communica@ons.  

•  Packet-­‐switch  communica@on  involves  transmission  of  digital  data  –  in  packets  –  no  resource  reserva@on...  use  sta@s@cal  mul@plexing  to  share  a  channel  

Spring  2015   CE  151  -­‐  Advanced  Networks   13  

Review  •  End-­‐to-­‐End  Principle  

–  If  a  func@on  requires  end-­‐point  involvement  to  implement  the  func@on  completely  and  correctly,  then  only  implement  in  the  end-­‐points!  

•  Avoids  impac@ng  network  applica@ons  that  don’t  need  this  func@on  •  Reduces  complexity  of  the  network...  dumb  network,  smart  end-­‐points.  Reverse  of  

the  telephone  system!  •  Overall,  improves  efficiency  and  reliability  of  the  network.  

–  Reasonable  interpreta@on...  if  a  func@on  requires  involvement  of  end-­‐points...  •  Think  twice  before  implemen@ng  it  in  the  network  •  Only  jus@fica@on  is  as  a  performance  enhancement  •  Do  not  impose  a  burden  on  applica@ons  that  don’t  require  it  •  E.g.  very  lossy  (wireless)  links  

Spring  2015   CE  151  -­‐  Advanced  Networks   14  

Reading  Review  

•  “End-­‐to-­‐End  Arguments  in  System  Design”  –  Salzer,  Reed,  Clark  –  How  does  the  reliable  file  transfer  problem  mo@vate  the  end-­‐to-­‐end  

principle?  

–  What  is  the  primary  reason  for  excep@ons  to  the  end-­‐to-­‐end  principle?  

–  What  is  a  common  problem  with  implemen@ng  a  performance-­‐enhancement  in  the  communica@on  channel?  

–  Why  is  it  open  acceptable  to  implement  a  weak  version  of  end-­‐to-­‐end  services  as  an  excep@on  to  the  end-­‐to-­‐end  principle  (i.e.  outside  the  end-­‐nodes)?  

Spring  2015   CE  151  -­‐  Advanced  Networks   15  

Evolu@on  of  TCP/IP  •  TCP  originally  meant  to  replace  NCP  

•  Problems  –  Monolithic  func@onality  –  Reliable  delivery  a  host-­‐host  issue  

•  Move  from  smart  network  to  smart  hosts  …  “End-­‐to-­‐end  Principle”  

•  TCP  split  into  TCP/IP  –  Internet  Protocol  (IP)  

•  Best-­‐effort  rou@ng  •  Internet  level  addressing  

–  Transmission  Control  Protocol  (TCP)    •  New,  end-­‐to-­‐end  error,  flow,  and  conges@on  control  

•  What  is  the  minimal  set  of  func@onality  needed  to  construct  an  internet?  

Spring  2015   CE  151  -­‐  Advanced  Networks   16  

Receive  an  IP  datagram  

IP  Datagram  Processing  1.  IP  header  valida@on  2.  Process  op@ons  in  IP  header  3.  Parsing  the  des@na@on  IP  

address    

4.  Rou@ng  table  lookup  5.  Decrement  TTL    6.  Perform  fragmenta@on  (if  

necessary)  

7.  Calculate  checksum  8.  Transmit  to  next  hop  9.  Send  ICMP  packet  (if  necessary)  

AMAZING!!!!  

Spring  2015   CE  151  -­‐  Advanced  Networks   17  

Receive  an  IP  datagram  

IP  Datagram  Processing  1.  IP  header  valida@on  2.  Process  op@ons  in  IP  header  3.  Parsing  the  des@na@on  IP  

address    

4.  Rou@ng  table  lookup  5.  Decrement  TTL    6.  Perform  fragmenta@on  (if  

necessary)  

7.  Calculate  checksum  8.  Transmit  to  next  hop  9.  Send  ICMP  packet  (if  necessary)  

IP  header  processing  

Spring  2015   CE  151  -­‐  Advanced  Networks   18  

Receive  an  IP  datagram  

IP  Datagram  Processing  1.  IP  header  valida@on  2.  Process  op@ons  in  IP  header  3.  Parsing  the  des@na@on  IP  

address    

4.  Rou@ng  table  lookup  5.  Decrement  TTL    6.  Perform  fragmenta@on  (if  

necessary)  

7.  Calculate  checksum  8.  Transmit  to  next  hop  9.  Send  ICMP  packet  (if  necessary)  

IP  header  processing  

Rou@ng  

Spring  2015   CE  151  -­‐  Advanced  Networks   19  

Receive  an  IP  datagram  

IP  Datagram  Processing  1.  IP  header  valida@on  2.  Process  op@ons  in  IP  header  3.  Parsing  the  des@na@on  IP  

address    

4.  Rou@ng  table  lookup  5.  Decrement  TTL    6.  Perform  fragmenta@on  (if  

necessary)  

7.  Calculate  checksum  8.  Transmit  to  next  hop  9.  Send  ICMP  packet  (if  necessary)  

IP  header  processing  

Rou@ng  

Address  Resolu@on  Protocol  

Spring  2015   CE  151  -­‐  Advanced  Networks   20  

Receive  an  IP  datagram  

IP  Datagram  Processing  1.  IP  header  valida@on  2.  Process  op@ons  in  IP  header  3.  Parsing  the  des@na@on  IP  

address    

4.  Rou@ng  table  lookup  5.  Decrement  TTL    6.  Perform  fragmenta@on  (if  

necessary)  

7.  Calculate  checksum  8.  Transmit  to  next  hop  9.  Send  ICMP  packet  (if  necessary)  

IP  header  processing  

Address  Resolu@on  Protocol  

Rou@ng  

Internet  Control  Message  Protocol  

Spring  2015   CE  151  -­‐  Advanced  Networks   21  

IP  -­‐  Orienta@on  •  IP  (Internet  Protocol)  is  a  Network  Layer  Protocol.  •  IP’s  current  version  is  Version  4  (IPv4).  •  It  is  specified  in  RFC  791.  •  IPv6  is  being  deployed  now…  

NetworkLayer

Link Layer

IP

ARP NetworkAccess

Media

ICMP IGMP

TransportLayer

TCP UDP

Spring  2015   CE  151  -­‐  Advanced  Networks   22  

IP:  The  waist  of  the  hourglass    •  IP  is  the  waist  of  the  hourglass  of  

the  Internet  protocol  architecture  

•  Mul@ple  higher-­‐layer  protocols  •  Mul@ple  lower-­‐layer  protocols  

•  Only  one  protocol  at  the  network  layer.  

•  Minimum  func@onality  to  construct  an  internet  

Spring  2015   CE  151  -­‐  Advanced  Networks   23  

Applications

HTTP FTP SMTP

TCP UDP

IP

Data link layer protocols

Physical layer protocols

Highest  Layer  Hop-­‐by-­‐Hop  Protocol  •  IP  is  the  highest  layer  protocol  which  is  implemented  at  both  routers  and  

hosts  (hop-­‐by-­‐hop)  

Spring  2015   CE  151  -­‐  Advanced  Networks   24  

Application

TCP

IP

Data Link

Application

TCP

IP

NetworkAccess

Application protocol

TCP protocol

IP protocol IP protocol

DataLink

DataLink

IP

DataLink

DataLink

IP

DataLink

DataLink

DataLink

IP protocol

RouterRouter HostHost

IP  Service  •  Delivery  service  of  IP  is  minimal…  packet-­‐switched  communica@on  model  

–  Data  sent  in  packets  –  Sta9s9cal  mul9plexing  (best-­‐effort…  packets  can  be  dropped  or  delivered  out  

of  order)  

•  IP  implements  datagram  flavor  of  packet-­‐switching  

•  Dis@nguishing  characteris@c  of  datagram  is  it  is  connec@onless  –  Routes  computed  on  an  event-­‐driven  basis  (topology  changes)  –  Forwarding  decisions  done  per  packet  –  Different  packets  in  the  same  flow  may  follow  different  paths  –  No  per-­‐flow  state  is  required  –  Think  telegram  

•  What  is  the  other  form  of  packet-­‐switching?  

Spring  2015   CE  151  -­‐  Advanced  Networks   25  

IP  Service  •  Virtual-­‐circuit  

•  How  is  virtual-­‐circuit  different  from  datagram?  

•  Dis@nguishing  characteris@c  of  virtual-­‐circuit  is  it  is  connec@on-­‐oriented  –  Route  computa@on  and  forwarding  decisions  done  once/flow  –  Requires  per-­‐flow  state  –  Think  telephone-­‐call  without  bandwidth  reserva@ons  

•  Consequences  of  datagram  model    –  Higher  layer  protocols  have  to  deal  with  losses  or  with  duplicate  packets  

•  Hmmm…  more  accurately,  I  would  say  this  is  a  consequence  of  packet-­‐switching  

–  Packets  may  be  delivered  out-­‐of-­‐sequence  

Spring  2015   CE  151  -­‐  Advanced  Networks   26  

IP  Service  •  IP  supports  the  following  services:  

–  one-­‐to-­‐one      (unicast)  –  one-­‐to-­‐all        (broadcast)  –  one-­‐to-­‐several    (mul@cast)  

•  IP  mul@cast  also  supports  a  many-­‐to-­‐many  service.    •  IP  mul@cast  requires  support  of  other  protocols  (IGMP,  mul@cast  rou@ng)  •  Anycast?  

Spring  2015   CE  151  -­‐  Advanced  Networks   27  

unicast broadcast multicast

Review  •  Dis@nguishing  characteris@cs  of  packet-­‐switched  communica@on  

–  Data  transmiqed  in  packets  –  Sta@s@cal  mul@plexing  (best-­‐effort  -­‐  packets  can  be  dropped  or  delivered  out  of  order)  

•  Packet-­‐switching  comes  in  two  flavors  –  virtual-­‐circuit  -­‐  connec@on  oriented  

•  route  once/flow  •  per-­‐flow  forwarding  state  

–  datagram  –  connec@onless  •  routes  computed  on  event  driven-­‐basis  •  per-­‐des@na@on  forwarding  state  

•  Consequences  of  packet-­‐switching  –  higher  layer  protocols  have  to  deal  with  losses  or  with  duplicate  packets  –  with  datagram  model,  packets  may  be  delivered  out  of  sequence  

Spring  2015   CE  151  -­‐  Advanced  Networks   28  

Review  •  4  classes  of  services  

–  Unicast  –  Broadcast  –  Mul@cast  –  Anycast  

 

Spring  2015   CE  151  -­‐  Advanced  Networks   29  

Administra@via  •  Any  problems  with  the  VMs?  

•  301a  access  •  Ethernet  summit  

•  This  week  –  Sec@ons  tomorrow  @  Noon  

•  Next  week  –  Link-­‐layer  lecture  next  Tuesday  –  First  lab  due  Monday  –  Read  the  “End-­‐to-­‐End  Argument”  paper  and  Chs  1  &  7  of  Dordal  –  Network  layer  quiz  on  Thursday...  remember,  review  orange  slides!  

Spring  2015   CE  151  -­‐  Advanced  Networks   30  

Review  •  IP  goals  

–  interconnect  diverse  network  technologies,  making  minimal  assump@ons  of  the  underlying  networks  

–  implement  the  minimal  set  of  func@onality  needed  to  construct  an  internet…  in  this  sense  IP  is  the  waist  of  the  network  protocol  stack  hourglass  

•  IP  implements  a  datagram,  packet-­‐switched  model  of  communica@ons.  

•  Packet-­‐switch  communica@on  involves  transmission  of  digital  data  –  in  packets  –  no  resource  reserva@on...  use  sta@s@cal  mul@plexing  to  share  a  channel  

•  best-­‐effort  -­‐  packets  can  be  dropped  or  delivered  out  of  order  

Spring  2015   CE  151  -­‐  Advanced  Networks   31  

Review  •  Consequences  of  packet-­‐switching  

–  higher  layer  protocols  have  to  deal  with  losses  or  with  duplicate  packets  –  with  datagram  model,  packets  may  be  delivered  out  of  sequence  

•  End-­‐to-­‐end  Principal  

•  Packet-­‐switching  comes  in  two  flavors  –  virtual-­‐circuit  -­‐  connec@on  oriented  

•  route  once/flow  •  per-­‐flow  forwarding  state  

–  datagram  –  connec@onless  •  routes  computed  on  event  driven-­‐basis  •  per-­‐des@na@on  forwarding  state  

•  4  classes  of  services:  Unicast,  Broadcast,  Mul@cast,  Anycast  

Spring  2015   CE  151  -­‐  Advanced  Networks   32  

Receive  an  IP  datagram  

IP  Datagram  Processing  1.  IP  header  valida@on  2.  Process  op@ons  in  IP  header  3.  Parsing  the  des@na@on  IP  

address    

4.  Rou@ng  table  lookup  5.  Decrement  TTL    6.  Perform  fragmenta@on  (if  

necessary)  

7.  Calculate  checksum  8.  Transmit  to  next  hop  9.  Send  ICMP  packet  (if  necessary)  

AMAZING!!!!  

Spring  2015   CE  151  -­‐  Advanced  Networks   33  

Receive  an  IP  datagram  

IP  Datagram  Processing  1.  IP  header  valida@on  2.  Process  op@ons  in  IP  header  3.  Parsing  the  des@na@on  IP  

address    

4.  Rou@ng  table  lookup  5.  Decrement  TTL    6.  Perform  fragmenta@on  (if  

necessary)  

7.  Calculate  checksum  8.  Transmit  to  next  hop  9.  Send  ICMP  packet  (if  necessary)  

IP  header  processing  

Address  Resolu@on  Protocol  

Rou@ng  

Internet  Control  Message  Protocol  

Spring  2015   CE  151  -­‐  Advanced  Networks   34  

IP  Datagram  Format  

Spring  2015   CE  151  -­‐  Advanced  Networks   35  

ECNversion headerlength DS total length (in bytes)

Identification Fragment offset

source IP address

destination IP address

options (0 to 40 bytes)

payload

4 bytes

time-to-live (TTL) protocol header checksum

bit # 0 15 23 248 317 16

0 MF

DF

IP  Header  Fields  •  Version  (4  bits):  current  version  is  4.  •  Header  length  (4  bits):  

–  Length  of  IP  header,  in  mul@ples  of  4  bytes  –  20  bytes  ≤  Header  Length  ≤  (24-­‐1)  *  4  =  60  bytes  

•  Service  field  (1  byte)  –  If  first  three  bits  are  0,  interpreted  as  original  Type-­‐of-­‐Service  (TOS).  –  Otherwise  

•  6  bits:  Differen@ated  Service  (DS)  (RFC2474):  •  2  bits:  Explicit  Conges@on  No@fica@on  (ECN)  (RFC3168):  

Spring  2015   CE  151  -­‐  Advanced  Networks   36  

IP  Header  Fields  •  Total  length  (16  bits):  

–  Total  length  of  IPv4  datagram,  in  bytes.  –  20  bytes  ≤  Total  Length  ≤  216  -­‐  1  =  65535  bytes  –  Length  of  data  =  total  length  -­‐  header  length  

•  Iden@fica@on  (16  bits):  Unique  iden@fica@on  of  a  datagram  from  a  host.  Incremented  whenever  a  datagram  is  transmiqed  

•  Flags  (3    bits):    –  First  bit  always  set  to  0  –  DF  bit  (Do  not  fragment)  –  MF  bit  (More  fragments)    

 For  Fragmenta@on…  will  be  explained  later  

Spring  2015   CE  151  -­‐  Advanced  Networks   37  

IP  Header  Fields  •  Time  To  Live  (TTL)  (1  byte):    

–  Specifies  longest  paths  before  datagram  is  dropped  –  Role  of  TTL  field:  Ensure  that  packet  is  eventually  dropped  when  a  rou@ng  

loop  occurs      

 Used  as  follows:  –  Sender  sets  the  value  (e.g.,  64)  –  Each  router  decrements  the  value  by  1  –  When  the  value  reaches  0,  the  datagram  is  dropped  

•  No  TTL  in  Ethernet…  why  do  you  think  they  didn’t  include  one?  

Spring  2015   CE  151  -­‐  Advanced  Networks   38  

IP  Header  Fields  •  Protocol  (1  byte):    

–  Specifies  the  higher-­‐layer  protocol.  –  Used  for  demul@plexing  to  higher  layers.  

Spring  2015   CE  151  -­‐  Advanced  Networks   39  

IP

1 = ICMP 2 = IGMP

6 = TCP 17 = UDP

4 = IP-in-IPencapsulation

IP  Header  Fields  •  Header  checksum  (2  bytes):  Simple  16-­‐

bit  long  checksum  covers  only  header.  •  Upper  layer  protocols  cover  data  •  IP  is  highest  hop-­‐by-­‐hop  protocol;  need  

to  minimize  processing  

Spring  2015   CE  151  -­‐  Advanced  Networks   40  

IP  Header  Fields  •  Op@on  Type  

–  Copy  flag:  Indicates  if  op@on  to  be  copied  to  fragments.  –  Op@on  class:  0  =  Control,  2  =  Debug/Measurement,  rest  “Reserved”.  –  Op@on  number:  iden@fies  op@on  

•  Op@on  length:  not  present  for  Noop  and  End  of  Op@ons  •  Op@on  data:  not  present  for  NOP  and  End  of  Op@ons  

Spring  2015   CE  151  -­‐  Advanced  Networks   41  

Fragmenta@on  •  Maximum  size  of  IP  datagram  is  65535…  

–  …but  link-­‐layer  payload  limits  typically  much  smaller  •  Called  the  Maximum  Transmission  Unit  (MTU).  •  Example  MTUs:  

•  Fragment  IP  datagrams  larger  than  MTU  of  a  link.  •  Issues  

–  How  communicate  fragmenta@on  among  hops  in  a  path?  –  How  handle  paths  containing  networks  with  different  MTUs?  –  Where  is  fragmenta@on  done?  

Spring  2015   CE  151  -­‐  Advanced  Networks   42  

Fragmenta@on  -­‐  How?  •  Involves  following  fields  (plus  checksum)  

•  Iden@fica@on:  ID  and  source  IP  address  uniquely  iden@fy  datagram.  •  Flags  

–  DF:  “Don’t  fragment.”  Discard  and  send  error.  –  MF:  “More  fragments.”  More  fragments  follow.  

•  Fragment  Offset:  Offset  of  current  payload  in  original  datagram.  –  Only  13  bit  field  -­‐  gives  offset  in  units  of  8  bytes  –  Number  of  first  byte  in  payload  is  FO  *  8.  –  Size  of  all  fragments,  but  last,  must  be  mul@ple  of  8.  

Spring  2015   CE  151  -­‐  Advanced  Networks   43  

ECNversion headerlength DS total length (in bytes)

Identification Fragment offset

time-to-live (TTL) protocol header checksum

0 MF

DF

Fragmenta@on  -­‐  How?  

•  Total  length:  Total  length  of  the  current  fragment.  •  Constraints  of  fragmenta@on  

–  Fragmenta@on  can  be  done  at  the  sender  or  at  intermediate  routers  –  The  same  datagram  can  be  fragmented  several  @mes.  –  Reassembly  of  original  datagram  is  only  done  at  des@na@on  hosts!!  

•  Why?  

•  How  determine  if  a  datagram  is  a  fragment?  –  FO  ≠  0  or…  –  MF  flag  is  set  

Spring  2015   CE  151  -­‐  Advanced  Networks   44  

ECNversion headerlength DS total length (in bytes)

Identification Fragment offset

time-to-live (TTL) protocol header checksum

0 MF

DF

•  Explana@on  •  What  does  FO  =  0  mean?  This  is  the  first  fragment.  •  What  does  MF  =  0  mean?  This  is  the  last  fragment.  •  What  does  ((FO  =  0)  and  (MF  =  0))  mean?  This  is  both  the  first  and  last  fragment  -­‐>  

this  is  the  only  fragment  -­‐>  this  is  the  original  packet  (i.e.  not  a  fragment).  NOTE:  this  is  the  only  way  to  not  be  a  fragment.  

•  So  a  packet  is  a  fragment  if  !((FO  =  0)  and  (MF  =  0))  <-­‐>  ((FO  ≠  0)  or  (MF  ≠  0))  

Fragmenta@on  Example  

Spring  2015   CE  151  -­‐  Advanced  Networks   45  

Fragmenta@on  Example  •  Example  where  last  fragment  is  not  mul@ple  of  8.  

Spring  2015   CE  151  -­‐  Advanced  Networks   46  

IP datagram

Router

Fragment 2Fragment 3

MTU: 1000MTU: 4000

Fragment 1

Header length: 20Total length: 2400

Identification: 0xa428DF flag: 0MF flag: 0

Fragment offset: 0

Header length: 20Total length: 996

Identification: 0xa428DF flag: 0MF flag: 1

fragment offset: 0

Header length: 20Total length: 996

Identification: 0xa428DF flag: 0MF flag: 1

Fragment offset: 122

Header length: 20Total length: 448

Identification: 0xa428DF flag: 0MF flag: 0

Fragment offset: 244

Why  calculate  checksum  @  each  hop?  

•  Fields  will  change…  –  TTL  –  Fragmenta@on  informa@on  –  Header  length  –  Others..?  

Spring  2015   CE  151  -­‐  Advanced  Networks   47  

Review  •  IP  headers…  

–  Checksum  only  covers  header  to  minimize  hop-­‐by-­‐hop  processing  •  Assumes  upper  layer  protocols  cover  data  

–  Checksum  must  be  recalculated  at  each  hop  •  IP  header  fields  change…  TTL,  Fragmenta@on  informa@on,  Header  length  

–  Fragmenta@on  and  reassembly  •  Used  to  match  packets  to  link  MTUs  •  Fragmenta@on  can  be  done  at  any  hop  on  the  path  •  Reassembly  can  only  be  done  at  the  des@na@on  

Spring  2015   CE  151  -­‐  Advanced  Networks   48  

IP  sta@s@cs  

•  “netstat  –s  –p  ip”  

Spring  2015   CE  151  -­‐  Advanced  Networks   49  

Receive  an  IP  datagram  

IP  Datagram  Processing  1.  IP  header  valida@on  2.  Process  op@ons  in  IP  header  3.  Parsing  the  des@na@on  IP  

address    

4.  Rou@ng  table  lookup  5.  Decrement  TTL    6.  Perform  fragmenta@on  (if  

necessary)  

7.  Calculate  checksum  8.  Transmit  to  next  hop  9.  Send  ICMP  packet  (if  necessary)  

IP  header  processing  

Address  Resolu@on  Protocol  

Rou@ng  

Internet  Control  Message  Protocol  

Spring  2015   CE  151  -­‐  Advanced  Networks   50  

Forwarding  •  An  internet  is  a  collec@on  of  subnets  •  IP  implements  hop-­‐by-­‐hop  delivery  of  packets  between  hosts  in  an  

internet  •  Routers  

–  Interconnect  subnets  (broadcast  domains)  –  Forward  packets  across  an  internet  

Spring  2015   CE  151  -­‐  Advanced  Networks   51  

H1

R1 R2

R3 R4

H210.2.1.0/24

20.1.0.0/1610.1.2.0/24

10.1.0.0/24 10.3.0.0/16

20.2.1.0/28

Forwarding  vs.  Rou@ng  •  There  are  two  dis@nct  processes  to  delivering  IP  datagrams:  

–  Forwarding:  deliver  a  packet  one  hop  closer  to  des@na@on.    –  Rou@ng:  compute  forwarding  state.  

•  Forwarding,  being  in  data  plane,  must  be  done  as  fast  as  possible:  –  On  routers,  is  open  done  with  support  of  hardware  –  On  PCs,  is  done  in  kernel  of  the  opera@ng  system  

•  Rou@ng,  being  outside  data  plane,  is  less  @me-­‐cri@cal  –  On  a  PC,  rou@ng  is  done  as  a  background  process  

Spring  2015   CE  151  -­‐  Advanced  Networks   52  

Routers  •  Routers  implement  

–  Forwarding  process  –  Rou@ng  process  

•  Routers  connect  mul@ple  subnets  –  Have  an  interface  on  mul@ple  subnets  –  Forward  packets  between  subnets  

•  Receive  on  one  interface  •  Process  IP  header  •  Determine  next  hop  •  Send  out  next  hop  interface  

Spring  2015   CE  151  -­‐  Advanced  Networks   53  

H1

R1 R2

R3 R4

H210.2.1.0/24

20.1.0.0/1610.1.2.0/24

10.1.0.0/24 10.3.0.0/16

20.2.1.0/28

Forwarding  Table  •  Forwarding  table  is  the  interface  between  the  rou@ng  and  forwarding  

processes  –  Simple  mechanism  –  Implements  (poten@ally)  complex  policies  

•  Maps  des@na@on  address  to  next  hop  towards  des@na@on  

Spring  2015   CE  151  -­‐  Advanced  Networks   54  

Control

Datapath: per-packet processing

routingtable

Routingfunctions

IPForwarding

routing tablelookup

routing tableupdates

incoming IPdatagrams

outgoing IPdatagrams

routingprotocol

routingprotocol

Rou@ng  and  Forwarding  Rou@ng  func@ons  include:  

–  route  calcula@on  –  maintenance  of  the  rou@ng  table  –  execu@on  of  rou@ng  protocols  

•  On  commercial  routers    handled  by  a  single  general  purpose  processor,  called  route  processor  

IP  forwarding  is  per-­‐packet  processing  •  On  high-­‐end  commercial  routers,  IP  forwarding  is  distributed  •  Most  work  is  done  on    the  interface  cards  

Spring  2015   CE  151  -­‐  Advanced  Networks   55  

Forwarding  Tables  •  Each  router  and  each  host  maintains  a  forwarding  table  which  tells  the  

router  how  to  process  an  outgoing    packet  •  Main  columns:  

–  Des@na@on  address:  where  is  the  IP  datagram  going  to?  –  Next  hop  or  interface:  how  to  forward  the  IP  datagram?  

•  Rou@ng  tables  are  set  so  that  a  datagram  gets  closer  to  the  its  des@na@on  every  hop  

Spring  2015   CE  151  -­‐  Advanced  Networks   56  

Destination Next Hop 10.1.0.0/24 10.1.2.0/24 10.2.1.0/24 10.3.1.0/24 20.1.0.0/16 20.2.1.0/28

direct direct R4 direct R4 R4

Routing table of a host or router IP datagrams can be directly delivered (“direct”) or are sent to a router (“R4”)

Delivery  with  Forwarding  Tables  

Spring  2015   CE  151  -­‐  Advanced  Networks   57  

Destination Next Hop 10.1.0.0/24 10.1.2.0/24 10.2.1.0/24 10.3.1.0/24 20.1.0.0/16 20.2.1.0/28

direct R3 R3 R3 R3 R3

H1

R1 R2

R3 R4

H210.2.1.0/24

20.1.0.0/1610.1.2.0/24

10.1.0.0/24 10.3.0.0/16

20.2.1.0/28

20.2.1.2/28

Destination Next Hop 10.1.0.0/24 10.1.2.0/24 10.2.1.0/24 10.3.1.0/24 20.1.0.0/16 20.2.1.0/28

direct direct R4 direct R4 R4

Destination Next Hop 10.1.0.0/24 10.1.2.0/24 10.2.1.0/24 10.3.1.0/24 20.1.0.0/16 20.2.1.0/28

R3 R3 R2 direct direct R2

Destination Next Hop 10.1.0.0/24 10.1.2.0/24 10.2.1.0/24 10.3.1.0/24 20.2.0.0/16 30.1.1.0/28

R3 direct direct R3 R2 R2

Destination Next Hop 10.1.0.0/24 10.1.2.0/24 10.2.1.0/24 10.3.1.0/24 20.1.0.0/16 20.2.1.0/28

R1 R1 direct R4 direct direct

Destination Next Hop 10.1.0.0/24 10.1.2.0/24 10.2.1.0/24 10.3.1.0/24 20.1.0.0/16 20.2.1.0/28

R2 R2 R2 R2 R2 direct

to: 20.2.1.2

Processing  of  an  IP  datagram  in  IP  

Spring  2015   CE  151  -­‐  Advanced  Networks   58  

UDP TCP

Inputqueue

Lookup nexthop

RoutingProtocol

Destinationaddress local?

Staticrouting

Yes

Senddatagram

IP forwardingenabled?

No

Discard

Yes No

Demultiplex

routingtable

IP module

Data Link Layer

IP  router:  IP  forwarding  enabled  Host:  IP  forwarding  disabled    

Forwarding  Table  Lookup  •  When  a  router  or  host  needs  to  

transmit  an  IP  datagram,  it  performs  a  forwarding  table  lookup  

•  Forwarding  table  lookup:  Use  the  IP  des@na@on  address  as  a  key  to  search  the  rou@ng  table.  

•  Result  of  the  lookup  is  the  IP  address  of  a  next  hop  router,  or  the  name  of  a  network  interface  

Spring  2015   CE  151  -­‐  Advanced  Networks   59  

Destination Next Hop 10.1.0.0/24 10.1.2.0/24 10.2.1.0/24 10.3.1.0/24 20.1.0.0/16 20.2.1.0/28

direct direct R4 direct R4 R4

Forwarding  Table  Match  •  Forwarding  table  entries  composed  of:  <IP Address>”/”<network mask>  

–  E.g.  128.114.48.128/26  

•  Mask  defines  the  network  part  of  an  address  –  128.114.48.128/26 = 10000000 01110010 00110000 10xxxxxx

–  ”x”  =  don’t  care  (host  part  of  address)  

•  Forwarding  table  match  occurs  when…  –  Both  the  rou@ng  entry  and  IP  addresses  have  the  same  network  part…  –  …given  the  route’s  network  mask  

•  Example:  is  128.114.48.0/17  a  matching  route  for  128.114.122.5?  –  128.114.48.0/17  =  10000000 01110010 0xxxxxxx xxxxxxxx  –  128.114.122.5/17  =  10000000 01110010 01111010 00000101!

–  Yes.  

Spring  2015   CE  151  -­‐  Advanced  Networks   60  

Forwarding  Table  Lookup  •  What  order  used  in  considering  forwarding  table  entries?  •  Only  maqers  when  rou@ng  entries  overlap  

–  Use  128.114.0.0/16 or  128.114.48.0/17  for  128.114.128.5?  

•  128.114.128.5  matches  128.114.0.0/16  –  128.114.0.0/16  =  10000000 01110010 xxxxxxxx xxxxxxxx  –  128.114.128.5/16  =  10000000 01110010 10000000 00000101!

•  128.114.128.5  also  matches  128.114.0.0/17 –  128.114.128.0/17  =  10000000 01110010 0xxxxxxx xxxxxxxx  –  128.114.128.5/17  =  10000000 01110010 00000000 00000101!

•  Answer  is  longest  prefix  match  –  Do  comparison  in  order  of  increasing  mask  length  –  Why?  Because  it  is  useful…  

•  Also  shortest  prefix  match  doesn’t  make  sense  (never  “see”  longer  prefix)  

•  How  use?  CC-­‐NIE  example  

Spring  2015   CE  151  -­‐  Advanced  Networks   61  

Types  of  Forwarding  Table  Entries  •  Network  route  

–  Des@na@on  address  with  0  <  prefix  length  <  32    (e.g.,  10.0.2.0/24)  –  Most  entries  are  network  routes  

•  Host  route  –  Des@na@on  address  with  prefix  length  =  32  (e.g.,  10.0.1.2/32)  –  Used  to  specify  a  separate  route  for  certain  hosts  

•  Default  route    –  Des@na@on  address  with  prefix  length  =  0  (i.e.  0.0.0.0/0)  –  Matches  all  des@na@ons  –  Commonly  use  to  connect  a  company’s  edge  router  to  the  ISP  network.    

•  Special  cases  of  longest  prefix  match  

Spring  2015   CE  151  -­‐  Advanced  Networks   62  

ipcalc

•  IMO,  subnets  are  best  thought  of  as  address  ranges  •  ipcalc  calculates  these  ranges  for  you…  

% ipcalc 128.114.48.0/17 Address: 128.114.48.0 10000000.01110010.0 0110000.00000000

Netmask: 255.255.128.0 = 17 11111111.11111111.1 0000000.00000000 Wildcard: 0.0.127.255 00000000.00000000.0 1111111.11111111 =>

Network: 128.114.0.0/17 10000000.01110010.0 0000000.00000000 HostMin: 128.114.0.1 10000000.01110010.0 0000000.00000001 HostMax: 128.114.127.254 10000000.01110010.0 1111111.11111110 Broadcast: 128.114.127.255 10000000.01110010.0 1111111.11111111

Hosts/Net: 32766 Class B  

•  …address  range  of  128.114.0.1  –  127.254  •  hqp://jodies.de/ipcalc  (available  as  command  line  tool)  

Spring  2015   CE  151  -­‐  Advanced  Networks   63  

Route  Aggrega@on    •  Longest  prefix  match  algorithm  allows  aggrega@on  of  prefixes  with  

iden@cal  next  hop  address  to  a  single  entry  •  Benefits  

–  Reduces  size  of  rou@ng  tables  –  More  efficient  rou@ng  table  lookups  

Spring  2015   CE  151  -­‐  Advanced  Networks   64  

Destination Next Hop 10.1.0.0/24 10.1.2.0/24 10.2.1.0/24 10.3.1.0/24 20.0.0.0/8

R3 direct direct

R3 R2

Destination Next Hop 10.1.0.0/24 10.1.2.0/24 10.2.1.0/24 10.3.1.0/24 20.2.0.0/16 20.1.1.0/28

R3 direct direct

R3 R2 R2

Des@na@on-­‐Based  Forwarding  •  Internet  rou@ng  uses  a  single  path  per  des@na@on  •  Des@na@on-­‐based  forwarding  is  a  restricted  version  of  single-­‐path  •  A  path  through  a  node  to  a  des@na@on…  •  …must  be  an  extension  of  the  path  from  the  node  to  the  des9na9on.  •  This  is  coming  back  to  haunt  us…  

Spring  2015   CE  151  -­‐  Advanced  Networks   65  

Review  •  An  internet  is  a  collec@on  of  subnets.  •  A  subnet  is  defined  by  an  IP  prefix  (using  address/mask  nota@on)  •  IP  implements  hop-­‐by-­‐hop  delivery  of  packets  between  hosts  in  an  

internet  •  Routers  connect  subnets  and  forward  packets  across  an  internet  

–  Forwarding:  selec@on  of  packet's  next  hop,  data  plane,  fast  (in  hardware)  –  Rou@ng:  compu@ng  forwarding  state,  signaling  plane,  not  as  @me  cri@cal  

•  The  forwarding  table  is  the  interface  between  the  rou@ng  and  forwarding  processes  –  Des@na@on  –  Next  hop  

•  Forwarding  table  lookups  are  done  using  Longest  Prefix  Match  •  The  Internet  uses  des@na@on-­‐based  forwarding,  which  is  a  restricted  

version  of  single-­‐path  forwarding.  

Spring  2015   CE  151  -­‐  Advanced  Networks   66  

Receive  an  IP  datagram  

IP  Datagram  Processing  1.  IP  header  valida@on  2.  Process  op@ons  in  IP  header  3.  Parsing  the  des@na@on  IP  

address    

4.  Rou@ng  table  lookup  5.  Decrement  TTL    6.  Perform  fragmenta@on  (if  

necessary)  

7.  Calculate  checksum  8.  Transmit  to  next  hop  9.  Send  ICMP  packet  (if  necessary)  

IP  header  processing  

Address  Resolu@on  Protocol  

Rou@ng  

Internet  Control  Message  Protocol  

Spring  2015   CE  151  -­‐  Advanced  Networks   67  

Address  Resolu@on  Protocol  (ARP)  

Spring  2015   CE  151  -­‐  Advanced  Networks   68  

NetworkLayer

Link Layer

IP

ARP NetworkAccess RARP

Media

ICMP IGMP

TransportLayer

TCP UDP

Address  Resolu@on  Protocol  (ARP)  •  The  Internet  is  based  on  IP  addresses    •  Data  link  protocols  (Ethernet,  FDDI,  ATM)  may  have  different  (MAC)  addresses  •  The  ARP  and  RARP  protocols  perform  the  transla9on  between  IP  addresses  and  

MAC  layer  addresses  •  We  will  discuss  ARP  for  broadcast  LANs,  par@cularly  Ethernet  LANs  

Spring  2015   CE  151  -­‐  Advanced  Networks   69  

RARP

Ethernet MACaddress(48 bit)

ARPIP address(32 bit)

Driver-­‐level  IP  Packet  Processing  

Spring  2015   CE  151  -­‐  Advanced  Networks   70  

loopbackDriver

IP Input

Put on IPinput queue

ARPdemultiplex

Ethernet Frame

Ethernet

IP destination of packet= local IP address ?

IP destination = multicastor broadcast ?

IP Output

Put on IPinput queue

No: get MACaddress withARP

ARPPacket

IP datagram

No

Yes

YesEthernet

Driver

Address  Transla@on  with  ARP  ARP  Request:  

Argon  broadcasts  an  ARP  request  to  all  sta@ons  on  the  network:  “What  is  the  hardware  address  of  Router137?”  

Spring  2015   CE  151  -­‐  Advanced  Networks   71  

Argon128.143.137.144

00:a0:24:71:e4:44

Router137128.143.137.1

00:e0:f9:23:a8:20

ARP Request:What is the MAC addressof 128.143.71.1?

Address  Transla@on  with  ARP  ARP  Reply:  

Router  137  unicasts  an  ARP  reply  to  with  its  hardware  address.  

Spring  2015   CE  151  -­‐  Advanced  Networks   72  

Argon128.143.137.144

00:a0:24:71:e4:44

Router137128.143.137.1

00:e0:f9:23:a8:20

ARP Reply:The MAC address of 128.143.71.1is 00:e0:f9:23:a8:20

ARP  Packet  Format  

Spring  2015   CE  151  -­‐  Advanced  Networks   73  

Destinationaddress

6

ARP Request or ARP Reply

28

Sourceaddress

6 2

CRC

4

Type0x8060 Padding

10

Ethernet II header

Hardware type (2 bytes)

Hardware addresslength (1 byte)

Protocol addresslength (1 byte) Operation code (2 bytes)

Target hardware address*

Protocol type (2 bytes)

Source hardware address*

Source protocol address*

Target protocol address*

* Note: The length of the address fields is determined by the corresponding address length fields

Example  •  ARP  Request  from  Argon:      

Source  hardware  address:    00:a0:24:71:e4:44  Source  protocol  address:    128.143.137.144  Target  hardware  address:    00:00:00:00:00:00  Target  protocol  address:    128.143.137.1  

•  ARP  Reply  from  Router137:      Source  hardware  address:    00:e0:f9:23:a8:20  Source  protocol  address:    128.143.137.1    Target  hardware  address:    00:a0:24:71:e4:44 Target  protocol  address:    128.143.137.144  

Spring  2015   CE  151  -­‐  Advanced  Networks   74  

ARP  Cache  •  Since  sending  an  ARP  request/reply  for  each  IP  datagram  is  

inefficient,  hosts  maintain  a  cache  (ARP  Cache)  of  current  entries.  The  entries  expire  aper  20  minutes.  

•  Contents  of  the  ARP  Cache  (“arp  –a”):  (128.143.71.37)  at  00:10:4B:C5:D1:15  [ether]  on  eth0  (128.143.71.36)  at  00:B0:D0:E1:17:D5  [ether]  on  eth0  (128.143.71.35)  at  00:B0:D0:DE:70:E6  [ether]  on  eth0  (128.143.136.90)  at  00:05:3C:06:27:35  [ether]  on  eth1  (128.143.71.34)  at  00:B0:D0:E1:17:DB  [ether]  on  eth0  (128.143.71.33)  at  00:B0:D0:E1:17:DF  [ether]  on  eth0  

Spring  2015   CE  151  -­‐  Advanced  Networks   75  

Other  ARP  Uses  •  What  happens  if  an  ARP  Request  is  made  for  a  non-­‐exis@ng  host?  

Several  ARP  requests  are  made  with  increasing  @me  intervals  between  requests.  Eventually,  ARP  gives  up.    

•  What  if  a  host  sends  an  ARP  Request  for  its  own  IP  address?  

The  other  machines  respond  (gratuitous  ARP)  as  if  it  was  a  normal  ARP  request.    This  is  useful  for  detec@ng  if  an  IP  address  has  already  been  assigned.    

•  Similarly,  what  if  a  host  sends  an  ARP  Reply  with  its  own  MAC  address?  

The  other  machines  accept  the  new  MAC  address  for  the  host  (also  called  a  gratuitous  ARP).  This  is  useful  for  moving  IP  addresses  to  new  NICs.    

Spring  2015   CE  151  -­‐  Advanced  Networks   76  

Proxy  ARP  •  Proxy  ARP:  Host  or  router  responds  to  ARP  Request  that  arrives  from  one  

of  its  connected  networks  for  a  host  that  is  on  another  of  its  connected  networks.  

Spring  2015   CE  151  -­‐  Advanced  Networks   77  

128.143.137.1/1600:e0:f9:23:a8:20 128.143.71.1/24

128.143.0.0/16Subnet

128.143.71.0/24Subnet

Router137

ARP Request:What is the MAC addressof 128.143.71.21?

128.143.137.144/16 128.143.171.21/2400:20:af:03:98:28

Argon Neon

ARP Reply:The MAC address of128.143.71.21 is00:e0:f9:23:a8:20

Review  •  The  Address  Resolu@on  Protocol  translates  from  IP  to  MAC  addresses.  

•  ARP  works  by  –  Broadcas@ng  ARP  Requests  for  an  IP  address  –  Unicas@ng  an  ARP  Reply  with  the  MAC  address  to  the  requestor.  –  ARP  Requests  are  repeated  un@l  a  Reply  is  received  or  ARP  @mes  out.  

•  Hosts  maintain  an  ARP  cache  to  limit  the  need  for  ARP  queries  for  every  packet  sent  

•  Gratuitous  ARP  are  ARP  Request/Replies  that  are  issued  for  other  than  standard  ARP  purposes  –  Gratuitous  ARP  Requests  detect  if  an  IP  address  is  in  use  –  Gratuitous  ARP  Replies  can  be  used  to  move  an  IP  address  to  a  new  NIC  

•  Routers  can  be  configured  to  issue  Proxy  ARP  Replies  to  ARP  Requests  on  one  of  its  interfaces  for  hosts  on  another  interface  

Spring  2015   CE  151  -­‐  Advanced  Networks   78  

Receive  an  IP  datagram  

IP  Datagram  Processing  1.  IP  header  valida@on  2.  Process  op@ons  in  IP  header  3.  Parsing  the  des@na@on  IP  

address    

4.  Rou@ng  table  lookup  5.  Decrement  TTL    6.  Perform  fragmenta@on  (if  

necessary)  

7.  Calculate  checksum  8.  Transmit  to  next  hop  9.  Send  ICMP  packet  (if  necessary)  

IP  header  processing  

Address  Resolu@on  Protocol  

Rou@ng  

Internet  Control  Message  Protocol  

Spring  2015   CE  151  -­‐  Advanced  Networks   79  

Overview  •  IP  relies  on  several  other  protocols  to  perform  necessary  control  and  

rou@ng  func@ons:  –  Control  func@ons  (ICMP)  –  Mul@cast  signaling  (IGMP)  –  Se}ng  up  rou@ng  tables  (RIP,  OSPF,  BGP,  PIM,  …)  

Spring  2015   CE  151  -­‐  Advanced  Networks   80  

Control

Routing

ICMP IGMP

RIP OSPF BGP PIM

Overview  •  The  Internet  Control  Message  Protocol  (ICMP)  is  a  helper  protocol  that  

supports  IP  with  facility  for    –  Simple  queries  –  Error  repor9ng  

•  Defined  in  RFC  792.  •  Conceptually  ICMP  is  a  part  of  IP…  •  …however  is  implemented  “on  top”  of  IP  •  ICMP  messages  are  encapsulated  in  IP  datagrams:  

Spring  2015   CE  151  -­‐  Advanced  Networks   81  

IP header ICMP message

IP payload

ICMP  message  format  4  byte  header:  •  Type  (1  byte):  type  of  ICMP  message  •  Code  (1  byte):  subtype  of  ICMP  message  •  Checksum  (2  bytes):  similar  to  IP  header  checksum.  Checksum  is  calculated  over  

en@re  ICMP  message  •  Each  ICMP  messages  is  at  least  8  bytes  long  

–  If  there  is  no  addi@onal  data,  there  are  4  bytes  set  to  zero.  

Spring  2015   CE  151  -­‐  Advanced  Networks   82  

additional informationor

0x00000000

type code checksum

bit # 0 15 23 248 317 16

ICMP  Query  messages  ICMP  query:    •  Request  sent  by  host  to  a  router  or  host  •  Reply  sent  back  to  querying  host  

Spring  2015   CE  151  -­‐  Advanced  Networks   83  

Host

ICMP Request

Host or router

ICMP Reply

Example  of  a  Query:  “ping”  •  Each  Ping  is  translated  into  an  ICMP  Echo  Request  •  The  Ping’ed  host  responds  with  an  ICMP  Echo  Reply  •  Addi@onal  informa@on:  Iden@fier,  Sequence  #,  Data  •  Source  and  des@na@on  addresses  swapped,  type  code  changed  to  0,  

checksum  recomputed.  

Spring  2015   CE  151  -­‐  Advanced  Networks   84  

Host or

Router

ICMP ECHO REQUEST Host or

router

ICMP ECH

O REPLY

ICMP  Router  Solicita@on/Adver@sement  

•  Aper  bootstrapping,  a  host  broadcasts  an  ICMP  router  solicita@on.  

•  In  response,  routers  send  an  ICMP  router  adver@sement  message  

•  Also,  routers  periodically  broadcast  ICMP  router  adver@sement  

 This  is  some@mes  called  the  Router  Discovery  Protocol  

Spring  2015   CE  151  -­‐  Advanced  Networks   85  

Ethernet

H1

R1 R2

ICMP routeradvertisement

ICMP routeradvertisement

ICMP routeradvertisement

Example  of  ICMP  Queries  Type/Code    Descrip@on    

 8/0        Echo  Request    0/0        Echo  Reply  

 

 13/0      Timestamp  Request    14/0    Timestamp  Reply      

 

 10/0      Router  Solicita@on    9/0      Router  Adver@sement  

Spring  2015   CE  151  -­‐  Advanced  Networks   86  

       The  ping  command            uses  Echo  Request/          Echo  Reply  

ICMP  Error  messages  •  ICMP  error  messages  report  error  condi@ons    •  Typically  sent  when  a  datagram  is  discarded  •  Error  message  is  open  passed  from  ICMP  to  the  applica@on  program  

Spring  2015   CE  151  -­‐  Advanced  Networks   87  

Host

IP datagram

Host or router

ICMP ErrorMessage

IP datagramis discarded

ICMP  Error  messages  •  ICMP  error  messages  include  the  complete  IP  header  and  the  

first  8  bytes  of  the  payload  (typically:  UDP,  TCP)  

Spring  2015   CE  151  -­‐  Advanced  Networks   88  

Unused (0x00000000)

IP header ICMP header IP header 8 bytes of payload

ICMP Message

from IP datagram that triggered the error

type code checksum

Manipulate  Rou@ng  table  with  ICMP  

•  When  a  router  detects  that  an  IP  datagram  should  have  gone  to  a  different  router,  the  router  (here  R2)    –  forwards  the  IP  datagram  to  the  correct  router  –  sends    an  ICMP  redirect  message  to  the  host  

•  Host  uses  ICMP  message  to  update  its  rou@ng  table  

Spring  2015   CE  151  -­‐  Advanced  Networks   89  

Destination Next Hop 10.1.0.0/24 …

R2

Destination Next Hop 10.1.0.0/24 …

R1

Ethernet

H1

R1 R2

(1) IP datagram

R1

(2) IP datagram(3) ICMP redirect

Example:  ICMP  Port  Unreachable  •  RFC  792:  If,  in  the  des@na@on  host,  the  IP  module  cannot  deliver  the  

datagram  because  the  indicated  protocol  module  or  process  port  is  not  ac@ve,  the  des@na@on  host  may  send  a  des@na@on  unreachable  message  to  the  source  host.  

•  Scenario:    

Spring  2015   CE  151  -­‐  Advanced  Networks   90  

Client

Request a service at a port 80

Server

No process is waiting at port 80

Port

Unreacha

ble

Example  of  an  Error:  traceroute  •  Send  UDP  datagram  to  des@na@on  with  IP  TTL  of  1.  •  Wait  for  ICMP  TE  message  to  get  IP  address  of  router  (source).  •  Increase  TTL  and  repeat.  •  Des@na@on  iden@fied  by  use  of  high  UDP  port  resul@ng  in  ICMP  Port  

Unreachable  message.  •  Addi@onal  informa@on  (for  both  messages):    

–  Internet  Header  –  64  bits  of  original  datagram  

•  Demo  

%  tcpdump  –nv  host  cas01.ucsc.edu  or  icmp  %  traceroute  –n  cas01.ucsc.edu    

Spring  2015   CE  151  -­‐  Advanced  Networks   91  

Frequent  ICMP  Error  message  

Spring  2015   CE  151  -­‐  Advanced  Networks   92  

Type Code Description 3

0–15 Destination

unreachable Notification that an IP datagram could not be forwarded and was dropped. The code field contains an explanation.

5 0–3 Redirect Informs about an alternative route for the datagram and should result in a routing table update. The code field explains the reason for the route change.

11 0, 1 Time exceeded

Sent when the TTL field has reached zero (Code 0) or when there is a timeout for the reassembly of segments (Code 1)

12 0, 1 Parameter problem

Sent when the IP header is invalid (Code 0) or when an IP header option is missing (Code 1)

Some  subtypes  of  the  “Des@na@on  Unreachable”  

Spring  2015   CE  151  -­‐  Advanced  Networks   93  

Code Description Reason for Sending 0 Network

Unreachable No routing table entry is available for the destination network.

1 Host Unreachable

Destination host should be directly reachable, but does not respond to ARP Requests.

2 Protocol Unreachable

The protocol in the protocol field of the IP header is not supported at the destination.

3 Port Unreachable

The transport protocol at the destination host cannot pass the datagram to an application.

4 Fragmentation Needed and DF Bit Set

IP datagram must be fragmented, but the DF bit in the IP header is set.

Review  •  ICMP  provides  two  basic  services:  

–  Network  queries  –  Error  repor@ng  

•  Func@on  of  an  ICMP  message  determined  by  Type  and  Code  fields.  •  For  network  queries  

–  Type  field  defines  matching  Request/Reply  types  –  Code  field  is  0  –  Addi@onal  informa@on  field  used  for  parameters  

•  For  error  repor@ng  –  Type  field  iden@fies  general  class  of  errors  –  Code  field  iden@fies  specific  error  –  Typically  sent  when  a  datagram  is  discarded  –  Include  IP  header  and  first  8  bytes  of  payload  (UDP  or  TCP  data)  

Spring  2015   CE  151  -­‐  Advanced  Networks   94  

DHCP  

•  Acronym  for  remembering  DHCP  sequence?  – DORK  

•  Discover  -­‐  broadcast  •  Offer  -­‐  unicast  •  Request  -­‐  broadcast  •  acK  -­‐  unicast  

Spring  2015   CE  151  -­‐  Advanced  Networks   95  

E2  506  or  194??  

Spring  2015   CE  151  -­‐  Advanced  Networks   96  

Extra  Slides  

Spring  2015   CE  151  -­‐  Advanced  Networks   97  

Longest  Prefix  Match  •  Given  forwarding  table  

•  (1)  128.114.48.0/17  •  (2)  128.114.48.0/20  •  (3)  128.114.48.0/22  •  (4)  0/0  

•  Which  entry  is  chosen  for  des@na@on:  128.114.122.5  •  Answer:  #1  •  Explana@on  (remember  bit  values:  128  64  32  16  8  4  2  1)  

–  10000000 01110010 0xxxxxxx xxxxxxxx    =  128.114.48.0/17  (0.0  –  127.255)  –  10000000 01110010 0011xxxx xxxxxxxx!  =  128.114.48.0/20  (48.0  –  63.255)  –  10000000 01110010 001100xx xxxxxxxx!  =  128.114.48.0/22  (48.0  –  51.255)  –  10000000 01110010 01111010 00000101!  =  128.114.122.5  

Spring  2015   CE  151  -­‐  Advanced  Networks   98  

Longest  Prefix  Match  •  Given  forwarding  table  

•  (1)  128.114.48.0/17  •  (2)  128.114.48.0/20  •  (3)  128.114.48.0/22  •  (4)  0/0  

•  Which  entry  is  chosen  for  des@na@on:  128.114.50.2  •  Answer:  ??  •  Explana@on  (remember  bit  values:  128  64  32  16  8  4  2  1)  

–  10000000 01110010 0xxxxxxx xxxxxxxx    =  128.114.48.0/17  (0.0  –  127.255)  –  10000000 01110010 0011xxxx xxxxxxxx!  =  128.114.48.0/20  (48.0  –  63.255)  –  10000000 01110010 001100xx xxxxxxxx!  =  128.114.48.0/22  (48.0  –  51.255)  

Spring  2015   CE  151  -­‐  Advanced  Networks   99  

Longest  Prefix  Match  •  Given  forwarding  table  

•  (1)  128.114.48.0/17  •  (2)  128.114.48.0/20  •  (3)  128.114.48.0/22  •  (4)  0/0  

•  Which  entry  is  chosen  for  des@na@on:  128.114.50.2  •  Answer:  #3  •  Explana@on  (remember  bit  values:  128  64  32  16  8  4  2  1)  

–  10000000 01110010 0xxxxxxx xxxxxxxx    =  128.114.48.0/17  (0.0  –  127.255)  –  10000000 01110010 0011xxxx xxxxxxxx!  =  128.114.48.0/20  (48.0  –  63.255)  –  10000000 01110010 001100xx xxxxxxxx!  =  128.114.48.0/22  (48.0  –  51.255)  –  10000000 01110010 00110010 00000000!  =  128.114.50.2  

Spring  2015   CE  151  -­‐  Advanced  Networks   100  

Longest  Prefix  Match  •  Given  forwarding  table  

•  (1)  128.114.48.0/17  •  (2)  128.114.48.0/20  •  (3)  128.114.48.0/22  •  (4)  0/0  

•  Which  entry  is  chosen  for  des@na@on:  128.114.52.10  •  Answer:  #2  •  Explana@on  (remember  bit  values:  128  64  32  16  8  4  2  1)  

–  10000000 01110010 0xxxxxxx xxxxxxxx    =  128.114.48.0/17  (0.0  –  127.255)  –  10000000 01110010 0011xxxx xxxxxxxx!  =  128.114.48.0/20  (48.0  –  63.255)  –  10000000 01110010 001100xx xxxxxxxx!  =  128.114.48.0/22  (48.0  –  51.255)  –  10000000 01110010 00110100 00001010!  =  128.114.52.10  

•  Give  an  example  of  an  address  that  would  use  (4)…  the  default  route.  

Spring  2015   CE  151  -­‐  Advanced  Networks   101