school of information technologies network layer nets 3303/3603 week 4
Post on 19-Dec-2015
213 views
TRANSCRIPT
![Page 1: School of Information Technologies Network Layer NETS 3303/3603 Week 4](https://reader030.vdocuments.us/reader030/viewer/2022032800/56649d2b5503460f94a010d5/html5/thumbnails/1.jpg)
School of Information Technologies
Network Layer
NETS 3303/3603
Week 4
![Page 2: School of Information Technologies Network Layer NETS 3303/3603 Week 4](https://reader030.vdocuments.us/reader030/viewer/2022032800/56649d2b5503460f94a010d5/html5/thumbnails/2.jpg)
School of Information Technologies
Problem: Link Delay Test
• Develop a UDP-based client/server system to test the round-trip delay (RTD)
• PDA is chosen to be the server, which passively open a well-known port
• Upon receiving an array of bytes, it just echo’s the bytes
![Page 3: School of Information Technologies Network Layer NETS 3303/3603 Week 4](https://reader030.vdocuments.us/reader030/viewer/2022032800/56649d2b5503460f94a010d5/html5/thumbnails/3.jpg)
School of Information Technologies
Link Client• Gets the host to connect and
number of link probes to send from command line
• Create a serialised object with current time and send to server using ObjectOutputStream
• Waits for echoed object from server• To find link RTD
– Extracted object’s time is subtracted from current time
public class Timestamp implements Serializable{
private long time;
public Timestamp(){ time =
System.currentTimeMillis();}public long getTime(){
return time;}public String toString(){ return new Long(time).toString();}
}
![Page 4: School of Information Technologies Network Layer NETS 3303/3603 Week 4](https://reader030.vdocuments.us/reader030/viewer/2022032800/56649d2b5503460f94a010d5/html5/thumbnails/4.jpg)
School of Information Technologies
while (probes > 0) {dSocket = new DatagramSocket();
time = new Timestamp(); // object to send!bos = new ByteArrayOutputStream();oos = new ObjectOutputStream(bos);oos.writeObject(time);
mBuff = bos.toByteArray();
outPkt = new DatagramPacket(mBuff, mBuff.length, host, PORT);dSocket.send(outPkt);
inPkt = new DatagramPacket(mBuff, mBuff.length);dSocket.receive(inPkt);
ois = new ObjectInputStream(new ByteArrayInputStream(inPkt.getData()));try{
time = (Timestamp)ois.readObject();}catch (ClassNotFoundException e) {}System.out.println("RTT is => "+ (System.currentTimeMillis()- time.getTime())");probes--;
}
![Page 5: School of Information Technologies Network Layer NETS 3303/3603 Week 4](https://reader030.vdocuments.us/reader030/viewer/2022032800/56649d2b5503460f94a010d5/html5/thumbnails/5.jpg)
School of Information Technologies
Test Output$ java LinkRttClient
Enter host name: pda-wifi
Enter required probes: 10RTT is => 2105 msRTT is => 43 msRTT is => 31 msRTT is => 56 msRTT is => 34 msRTT is => 57 msRTT is => 32 msRTT is => 56 msRTT is => 33 msRTT is => 69 ms
Terminating link delay test...
![Page 6: School of Information Technologies Network Layer NETS 3303/3603 Week 4](https://reader030.vdocuments.us/reader030/viewer/2022032800/56649d2b5503460f94a010d5/html5/thumbnails/6.jpg)
School of Information Technologies
Lesson Outline
• intro• IP addresses• subnetting• routing/algorithms/architecture• ARP
![Page 7: School of Information Technologies Network Layer NETS 3303/3603 Week 4](https://reader030.vdocuments.us/reader030/viewer/2022032800/56649d2b5503460f94a010d5/html5/thumbnails/7.jpg)
School of Information Technologies
Fundamental, IPv4
• fundamental TCP/IP protocol
• RFC 791, other related RFCs– Inet checksum, rfc 1071, 1141, 1624– path mtu, rfc 1191– ip datagram reassembly, rfc 815– rfc 1122, communications
![Page 8: School of Information Technologies Network Layer NETS 3303/3603 Week 4](https://reader030.vdocuments.us/reader030/viewer/2022032800/56649d2b5503460f94a010d5/html5/thumbnails/8.jpg)
School of Information Technologies
Fundamental idea
• ip implements an ip logical network on top of different kinds of network technologies where ip address is endpoint
• hw is hidden by network layer (except for a few things like MTU)
![Page 9: School of Information Technologies Network Layer NETS 3303/3603 Week 4](https://reader030.vdocuments.us/reader030/viewer/2022032800/56649d2b5503460f94a010d5/html5/thumbnails/9.jpg)
School of Information Technologies
what does IP do (and not do?)
• sends and recvs packets to/from ip addresses - ip datagrams
• no retries, doesn’t promise reliable delivery– packets due to various reasons may be lost, duplicated,
delayed, delivered out of order, or corrupted
• best effort - don’t lose them on purpose but only when nets busy => resources unavailable
![Page 10: School of Information Technologies Network Layer NETS 3303/3603 Week 4](https://reader030.vdocuments.us/reader030/viewer/2022032800/56649d2b5503460f94a010d5/html5/thumbnails/10.jpg)
School of Information Technologies
IP functions
• route packets– routing: process of determining path for data– ip routes packets when they come from
• transport layer (down stack)• link layer (up stack) - we are router and forward pkts
• fragmentation accrd. to link-layer MTU• handle ip options• send/recv ICMP error and control messages
![Page 11: School of Information Technologies Network Layer NETS 3303/3603 Week 4](https://reader030.vdocuments.us/reader030/viewer/2022032800/56649d2b5503460f94a010d5/html5/thumbnails/11.jpg)
School of Information Technologies
IP address• 32 bits, “dotted-decimal” notation
– 1.2.3.4, big-endian byte order, 0..255 is range
– associated with interface, not machine
• if machine > 1 i/f, then multi-homed– if multi-homed, not necessarily router
• ip address in UNIX assigned to i/f with#ifconfig ed0 inet 131.253.1.2 netmask 255.255.255.0
![Page 12: School of Information Technologies Network Layer NETS 3303/3603 Week 4](https://reader030.vdocuments.us/reader030/viewer/2022032800/56649d2b5503460f94a010d5/html5/thumbnails/12.jpg)
School of Information Technologies
Example Of Dotted DecimalNotation
• A 32-bit number in binary– 10000000 00001010 00000010 00000011
• The same 32-bit number expressed in dotted decimal notation– 128 . 10 . 2 . 3
![Page 13: School of Information Technologies Network Layer NETS 3303/3603 Week 4](https://reader030.vdocuments.us/reader030/viewer/2022032800/56649d2b5503460f94a010d5/html5/thumbnails/13.jpg)
School of Information Technologies
IP address structure• each address has structure in it: (network, host)• Host may be divided further into (subnet, host)• subnet mask used to determine subnet part
– operation: ipaddress & subnet mask
– (more later)
![Page 14: School of Information Technologies Network Layer NETS 3303/3603 Week 4](https://reader030.vdocuments.us/reader030/viewer/2022032800/56649d2b5503460f94a010d5/html5/thumbnails/14.jpg)
School of Information Technologies
IP Address Conventions
• When used to refer to a network– Host field contains all 0 bits
• Broadcast on the local wire– Network and host fields both contain all 1 bits
• Directed broadcast: broadcast on specific (possibly remote) network– Host field contains all 1 bits
– a packet is sent to all computers on a network
![Page 15: School of Information Technologies Network Layer NETS 3303/3603 Week 4](https://reader030.vdocuments.us/reader030/viewer/2022032800/56649d2b5503460f94a010d5/html5/thumbnails/15.jpg)
School of Information Technologies
Limited Broadcast
• All 1’s (255.255.255.255)
• Broadcast limited to local network only (no forwarding)
• Useful for bootstrapping
![Page 16: School of Information Technologies Network Layer NETS 3303/3603 Week 4](https://reader030.vdocuments.us/reader030/viewer/2022032800/56649d2b5503460f94a010d5/html5/thumbnails/16.jpg)
School of Information Technologies
IP address problems
• assigning class by first bits means class A takes 1/2 of range, class B 1/4, class C 1/8, etc.
• problems with this setup– class assignment is wasteful
– ip host addresses not necessarily utilized well
– too many networks in core routers
– running out of ip addresses ??
![Page 17: School of Information Technologies Network Layer NETS 3303/3603 Week 4](https://reader030.vdocuments.us/reader030/viewer/2022032800/56649d2b5503460f94a010d5/html5/thumbnails/17.jpg)
School of Information Technologies
Question
• How can we minimize the number of assigned network prefixes (especially class B) without abandoning the 32-bit addressing scheme?
• Subnet addressing
• Proxy ARP (later)
![Page 18: School of Information Technologies Network Layer NETS 3303/3603 Week 4](https://reader030.vdocuments.us/reader030/viewer/2022032800/56649d2b5503460f94a010d5/html5/thumbnails/18.jpg)
School of Information Technologies
Subnetting• subnet - use single IP network address to
hide multiple physical nets• subnet notion converts (net, host) into
slightly more hierarchical (net, subnet, host)
• associate subnet mask with i/f ip address• Example, class B, one byte of subnet: ip
= 148.1.1.0 subnet=255.255.255.0
![Page 19: School of Information Technologies Network Layer NETS 3303/3603 Week 4](https://reader030.vdocuments.us/reader030/viewer/2022032800/56649d2b5503460f94a010d5/html5/thumbnails/19.jpg)
School of Information Technologies
Choice Of Subnet Size
• How should host portion of address be divided?– Depends on topology at site and number of hosts per
network
• Each physical network is assigned 32-bit address mask
• One bits in mask cover network prefix plus zero or more bits of suffix portion
• Logical and between mask and destination IP address extracts the prefix and subnet portions
![Page 20: School of Information Technologies Network Layer NETS 3303/3603 Week 4](https://reader030.vdocuments.us/reader030/viewer/2022032800/56649d2b5503460f94a010d5/html5/thumbnails/20.jpg)
School of Information Technologies
Subnettingsubnetting functions:• 1. you can subnet an ip address and split it up on
separate networks across routers (conserve address space)
• 2. you hide your routing structure from remote routers, thus reducing routes in their routing tables
if (dest ip addr & subnet mask) == (my ip addr & subnet mask)dest is on same subnet
elsedifferent subnet (send pkt to router)
![Page 21: School of Information Technologies Network Layer NETS 3303/3603 Week 4](https://reader030.vdocuments.us/reader030/viewer/2022032800/56649d2b5503460f94a010d5/html5/thumbnails/21.jpg)
School of Information Technologies
Example Network
![Page 22: School of Information Technologies Network Layer NETS 3303/3603 Week 4](https://reader030.vdocuments.us/reader030/viewer/2022032800/56649d2b5503460f94a010d5/html5/thumbnails/22.jpg)
School of Information Technologies
Fixed-length Subnet Masks
• Organization uses same mask on all networks• Advantages
– Uniformity
– Ease of debugging / maintenance
• Disadvantages– Number of nets fixed for entire organization
– Size of physical nets fixed for entire organization
![Page 23: School of Information Technologies Network Layer NETS 3303/3603 Week 4](https://reader030.vdocuments.us/reader030/viewer/2022032800/56649d2b5503460f94a010d5/html5/thumbnails/23.jpg)
School of Information Technologies
IP encapsulation
![Page 24: School of Information Technologies Network Layer NETS 3303/3603 Week 4](https://reader030.vdocuments.us/reader030/viewer/2022032800/56649d2b5503460f94a010d5/html5/thumbnails/24.jpg)
School of Information Technologies
IP Header
![Page 25: School of Information Technologies Network Layer NETS 3303/3603 Week 4](https://reader030.vdocuments.us/reader030/viewer/2022032800/56649d2b5503460f94a010d5/html5/thumbnails/25.jpg)
School of Information Technologies
Routing
• routing - the process of choosing a path over which to send datagrams
• hosts and routers route• input: ip destination address• output: next hop ip address and internally an
interface to send it out• routing does not change ip dest address
![Page 26: School of Information Technologies Network Layer NETS 3303/3603 Week 4](https://reader030.vdocuments.us/reader030/viewer/2022032800/56649d2b5503460f94a010d5/html5/thumbnails/26.jpg)
School of Information Technologies
How configure routing table
• static routes - by hand, on unix with % route to_dest via_next_hop
• dynamically via routing protocol daemon, routed or gated on UNIX, protocols=RIP/OSPF/BGP
![Page 27: School of Information Technologies Network Layer NETS 3303/3603 Week 4](https://reader030.vdocuments.us/reader030/viewer/2022032800/56649d2b5503460f94a010d5/html5/thumbnails/27.jpg)
School of Information Technologies
View routing table
• unix host– % netstat -rn
• n is for NO dns, else you may cause DNS queries
• Linux– % route -n
• cisco router– (router) show ip route
![Page 28: School of Information Technologies Network Layer NETS 3303/3603 Week 4](https://reader030.vdocuments.us/reader030/viewer/2022032800/56649d2b5503460f94a010d5/html5/thumbnails/28.jpg)
School of Information Technologies
Routing table
• entries logically (destination, mask, via gateway, metric/s)
• destination - network or host address• mask - subnet mask for dst address• via gateway - next hop (maybe router)• metric/s - depends on routing table algorithm and
dynamic routing protocols
![Page 29: School of Information Technologies Network Layer NETS 3303/3603 Week 4](https://reader030.vdocuments.us/reader030/viewer/2022032800/56649d2b5503460f94a010d5/html5/thumbnails/29.jpg)
School of Information Technologies
SOME possible kinds of routes
• host, 210.1.3.21/32 (to specific host)• subnet, 131.253.1.0/24 (to specific subnet)• network, 131.253.0.0/16 (to specific net)• default route - normally the router on a net, send it
here when nothing else matches– expressed internally as 0.0.0.0
• note: host route to default route – most specific to least specific
![Page 30: School of Information Technologies Network Layer NETS 3303/3603 Week 4](https://reader030.vdocuments.us/reader030/viewer/2022032800/56649d2b5503460f94a010d5/html5/thumbnails/30.jpg)
School of Information Technologies
Manual route entries
• on FreeBSD unix host:% route add default 204.1.2.3
(default route)
% route add 1.1.1.1 2.2.2.2• 2.2.2.2 is the next-hop router for 1.1.1.1
• we must have direct connection to 2.2.2.2 (i/f must be on same subnet and must exist)
% ifconfig ed0 2.2.2.1 (our i/f must exist)
![Page 31: School of Information Technologies Network Layer NETS 3303/3603 Week 4](https://reader030.vdocuments.us/reader030/viewer/2022032800/56649d2b5503460f94a010d5/html5/thumbnails/31.jpg)
School of Information Technologies
ARP, The problem
• problem: how does ip address get mapped to ethernet address?
• 2 machines on same enet can only communicate if they know MAC/hw addr
• Applications only use Internet addresses• solutions:
– configure addresses by hand (ouch!)– encode in IP address (48 bits in 32?)– dynamic mapping
![Page 32: School of Information Technologies Network Layer NETS 3303/3603 Week 4](https://reader030.vdocuments.us/reader030/viewer/2022032800/56649d2b5503460f94a010d5/html5/thumbnails/32.jpg)
School of Information Technologies
Consequence
• Protocol software needs a mechanism that maps an IP address to equivalent hardware address
• Known as address resolution problem
![Page 33: School of Information Technologies Network Layer NETS 3303/3603 Week 4](https://reader030.vdocuments.us/reader030/viewer/2022032800/56649d2b5503460f94a010d5/html5/thumbnails/33.jpg)
School of Information Technologies
Dynamic Binding
• Needed when hardware addresses are large (e.g., Ethernet)
• Allows computer A to find computer B’s hardware address– A starts with B’s IP address– A knows B is on the local network
• Technique: broadcast query and obtain response• Note: dynamic binding only used across one
network at a time
![Page 34: School of Information Technologies Network Layer NETS 3303/3603 Week 4](https://reader030.vdocuments.us/reader030/viewer/2022032800/56649d2b5503460f94a010d5/html5/thumbnails/34.jpg)
School of Information Technologies
ARP• rfc 826• host A, wants to resolve IP addr B,
– send BROADCAST arp request– get UNICAST arp reply from B
• ethernet (or MAC) specific, although protocol designed to be extensible
• implemented in driver, not IP• intended for LAN
![Page 35: School of Information Technologies Network Layer NETS 3303/3603 Week 4](https://reader030.vdocuments.us/reader030/viewer/2022032800/56649d2b5503460f94a010d5/html5/thumbnails/35.jpg)
School of Information Technologies
Refinements
• Cannot afford to send ARP request for each packet
• Solution– Maintain a table of binding
• OS will cache arp replies in arp cache (ip , MAC, 20 minute timeout)– don’t need to do arp on every packet
![Page 36: School of Information Technologies Network Layer NETS 3303/3603 Week 4](https://reader030.vdocuments.us/reader030/viewer/2022032800/56649d2b5503460f94a010d5/html5/thumbnails/36.jpg)
School of Information Technologies
% arp -a (SunOs)# arp -abanshee.cs.pdx.edu (131.252.20.128) at 0:0:a7:0:2d:a0pdx-gwy.cs.pdx.edu (131.252.20.1) at 0:0:c:0:f9:17longshot.cs.pdx.edu (131.252.20.129) at 8:0:11:1:44:68walt-suncs.cs.pdx.edu (131.252.21.2) at 8:0:20:e:21:25walt-cs.cs.pdx.edu (131.252.20.2) at 8:0:20:e:21:25connor.cs.pdx.edu (131.252.21.179) at 0:0:c0:c5:57:10dazzler.cs.pdx.edu (131.252.21.132) at 8:0:11:1:12:82sprite.cs.pdx.edu (131.252.21.133) at 8:0:11:1:12:e7
(DNS name,ip address,Ethernet address)
![Page 37: School of Information Technologies Network Layer NETS 3303/3603 Week 4](https://reader030.vdocuments.us/reader030/viewer/2022032800/56649d2b5503460f94a010d5/html5/thumbnails/37.jpg)
School of Information Technologies
Arp command, functions
• ping someone and learn MAC address
• for debugging
• delete out of date ARP entry (you changed the IP address, and you don’t want to wait, OR somebody mucked up)
![Page 38: School of Information Technologies Network Layer NETS 3303/3603 Week 4](https://reader030.vdocuments.us/reader030/viewer/2022032800/56649d2b5503460f94a010d5/html5/thumbnails/38.jpg)
School of Information Technologies
ARP header
![Page 39: School of Information Technologies Network Layer NETS 3303/3603 Week 4](https://reader030.vdocuments.us/reader030/viewer/2022032800/56649d2b5503460f94a010d5/html5/thumbnails/39.jpg)
School of Information Technologies
Header details
• header format is not fixed, somewhat dynamic (not used though)
• hw type, ethernet == 1• protocol type, ip = 0x800• hwlen, 6 (MAC), plen 4 (ip)• operation: (used by rarp too)
– 1: arp request, 2: arp reply– 3: rarp request, 4: rarp reply
![Page 40: School of Information Technologies Network Layer NETS 3303/3603 Week 4](https://reader030.vdocuments.us/reader030/viewer/2022032800/56649d2b5503460f94a010d5/html5/thumbnails/40.jpg)
School of Information Technologies
More Details
• sender hw addr, 6 bytes– the answer, if reply
• sender ip: 4 bytes• target hw address: 6 bytes
– 0 in request
• target ip: 4 bytes
![Page 41: School of Information Technologies Network Layer NETS 3303/3603 Week 4](https://reader030.vdocuments.us/reader030/viewer/2022032800/56649d2b5503460f94a010d5/html5/thumbnails/41.jpg)
School of Information Technologies
Proxy ARP
• Allow two physical networks to share a single IP prefix
• Arrange special system to answer ARP requests and forward datagrams between networks
• Hosts think they are on same network
![Page 42: School of Information Technologies Network Layer NETS 3303/3603 Week 4](https://reader030.vdocuments.us/reader030/viewer/2022032800/56649d2b5503460f94a010d5/html5/thumbnails/42.jpg)
School of Information Technologies
Proxy ARP pros, cons
• pros– same network numbers– transparent to hosts– no change in IP routing tables
• cons– does not generalize to complex topology– can drive you nuts -- debugging– not simple and not secure
![Page 43: School of Information Technologies Network Layer NETS 3303/3603 Week 4](https://reader030.vdocuments.us/reader030/viewer/2022032800/56649d2b5503460f94a010d5/html5/thumbnails/43.jpg)
School of Information Technologies
Summary
• IP is a best-effort network
• Main IP functions– Routing, fragmentation, some error-handling
• Subnetting provide hierarchy => CIDR!
• ARP maps IP to hardware address