CS-‐51Introduction to Computer
NetworkingSpring 2016
Instructor: David [email protected]
(650) 223-‐3312
CS-‐51 Week 2 – Addresses and Layers
• Review and questions• Reminder about website– http://www.stanford.edu/group/csp/cs51– Slides from Current (and previous) week
CS-‐51 Week 2
• Goals this week– Questions– Review Week 1– addresses, addresses, addresses• …….. And Subnets
– Layering – deconstructing the internet into constituent layers
CS-‐51 Week 2
Week 1 History + building blocks (Conceptual) Building blocks
Week2
Review Week 1 then:addresses, addresses,
addresses … and subnets -‐-‐-‐ and a demonstration
Network Layers
Week3 TCP/IP/UDPAddress Acquisition,NAT, DCHP, ARP
Week4 Physical Media DNS – Domain Name Service
Week5 Routers and Switches Security
Week6 Web Service Questions from final
Week7 Practical examples Questions, answers.
CS-‐51 Week 2• Last week – conceptual understanding -‐ like riding a Harley
thru the New York Metropolitan Museum– There is this internet thingy …
• A collection of networks that are interconnected where each network consists of one or more hosts
• It facilitates data exchange data between application programs (executing on those hosts)
• Data is encapsulated in packets using binary coding– 11010101..111, etc.
• All information is sliced up and transported as a stream of one or more packets
• Every computer interfacehas an IP (Internet Protocol) address• Computers may have more than one interface (i.e. more that one IP address, i.e. belong to more than one network)
• Certain computers act as go-‐betweens between networks. These computers are called routers or gateways.
The Internet
CS51 – Week2
• An internet is a Collection of Networks
N N
NNN
N
R
RR R=
R = Router
CS-‐51 Week2-‐review
• How is the data transmitted between applications organized?– All data is reduced to binary form and sent in data units called packets.
– Data > max packet size is fragmented into smaller packets; may happen anywhere along path
Packet 3 Packet 2 Packet 1App 1 App 2
CS-‐51 Week 2 -‐ review
• IP packet length = 20 -‐ 65535
APPAPP
CS-‐51 Week 2-‐ reviewSet of one or more application programs communicating via numbered ports (source, destination)
Source port
Destination port Source port
Destination port
TCP or UDPIP layer
Link Layer
Physical Layer
TCP or UDPIP layer
Link Layer
Physical Layer
TCP Exchange
Physical Medium
MAC Exchange
IP Exchange
Application
Transport
Network (IP)Network Interface
Physical
CS-‐51 Week 2Term Example
Binary number 101010 .. 110001000001 1000010 2
000011 3
000100 4
000101 5
000110 6
000111 7
001000 8IP address 10100 … 0001 32/128 digits long – IPv4/IPV6
IP address consists of (Network number, host number)
Network A.B.C.D/x X digits for network, 32 – x digits for host (128-‐x, IPV6) e.g. 198.51.110/24 means 32-‐42 = 8 bits for host
Example of address 198.51.110.4
CS-‐51 Week 2Term Example
Binary number 101010 .. 110001000001 1000010 2
000100 4
001000 8
010000 16
100000 32
1000000 64
10000000 128
CS-‐51 Week 2 -‐ review
• Binary numbers cont. ..,• IPv4 Addresses: 32-‐bit binary number represented as four
decimal numbers separated by “ . “• Each decimal number represents 8 bits
– E.g. 134.79.48.10 represents– 134 = 128x1+64x0+32x0+16x0+8x0+4x1+2x1+1x0 = 10000110– 79 = 128x0+64x1+32x0+16x0+8x1+4x1+2x1+1x1 = 01001111– 48 = 128x0+64x0+32x1+16x1+8x1+4x0+2x0+1x0 = 00110000– 10 = 128x0+64x0+32x0+16x0+8x1+4x0+2x1+1x0 = 00001010– i.e 10000110010011110011000000001010
CS-‐51 Week 2-‐review
• Applications in the same host can exchange packets without them leaving the computer.– Special IP address ‘loopback’, 127.0.0.1
• When packets are exchanged between applications on different computers, they must exit and enter via a network interface card often called a NIC (Network Interface Card) card and they are conveyed by the local network (LAN) to another host or gateway.
CS-‐51 Week 2-‐review
• When the packet destination is on another network, it is forwarded to a special node called a gateway/routerwhich has access to other networks. This gateway/router forwards the packet in a direction which advances it towards its destination.
CS51 – Week 2 -‐ Addresses
• Addresses, addresses, addresses – and subnets– Three kinds:
• IP addresses– Internet Protocol (IP) addresses -‐ identify source and destination interfaces on the Internet
• MAC – Machine Access Control, also called physical addresses -‐ identify source and destination interfaces on the same network
• Port Numbers– Identify (logical) streams identify source and destination between applications
CS51 – Week 2 -‐ Addresses
• When a packet arrives what determines which application program should receive it?
• When a packet is sent, how is the receiving application identified?
• ANSWER: Port Numbers– TCP + UDP packets specify port numbers which allows the operating system to direct packets to the correct application
– In any host, the source port is unique – usually dym
CS51 – Week 2 -‐ Addresses
• The concept of well known ports– There is a maintained list of well known ports.• See Wikipedia page on well known port numbers
• Firewalls and port numbers– Ports are used to identify which applications may receive or send packets
– Port scanning
CS51 – Week 2 -‐ Addresses
• MAC (physical) addresses• How do they get from host to host on the same network?1. they are sent from a network interface on the
host to an interface on a different host2. The network interface places them on a physical
media3. Nearly all interfaces have a physical address, e.g.
Ethernet4. MAC addresses include a broadcast address:
FF:FF:FF:FF:FF:FF. e.g. to perform ARP.
CS51 – Week 2 -‐ Addresses• IP (Internet Protocol) addresses
• How does the Internet know where to forward packets?• Each interface connected to the network has an internet
address (an IP address) consisting of two numbers:– The number of the network– The number of the destination host in the network.
• 32 bits long (IPv4)• Some addresses allocated for special purposes
– Multicast– Experimentation-‐ Loopback (127/8)
CS51 – Week 2 -‐ Addresses• New Terminology:• Instead of ‘network’ use ‘prefix’• Instead of ‘host’ use ‘suffix’• Why?– Historical
• Classfull addressing– Class A, 0xxxxxx,yyyyyyyyyyyyyyyyyyyyyyyy– Class B, 10xxxxxxxxxxxx,yyyyyyyyyyyyyyyy– Class C, 110xxxxxxx,yyyyyyyyyyyyyyyyyyyyyyyy– Mulicast, 1110xxxxxxxxxxxxxxxxxxxxxxxxxxxx– Experimental 1111yyyyyyyyyyyyyyyyyyyyyyyyyyyy
• CIDR Classless Inter-‐domain Routing– Dividing line between network and host no longer fixed
CS51 – Week 2 -‐ Addresses
• Review:– An IP address is the address of a network interface card (NIC) on a NODE on a network.
H
H
H
H
H H
H
H
H
HRouter
10.1.1.0/24 10.1.2.0/24
H
H
H
H
H10.1.3.0/24
10.1.1.2
10.1.3.2
10.1.2.210.1.1.1 10.1.2.1
10.1.3.1
CS51 – Week 2 -‐ Addresses
• Types of IPv4 addresses (prefix, suffix)– This computer ( all 0’s, all 0’s)– Unicast (network, host)– Network (network, all 0’s)– Broadcast local ( all 1s, all 1’s)– Broadcast to a network (network, all 1’s)– Loopback (127/8, any)
CS51 – Week 2 -‐ Addresses
• New concept: The subnet– A network that has been subdivided into smaller networks by co-‐opting part of the host number part of the IP address
– E.g. 134.79/16
CS51 – Week 2 -‐ Addresses
Network
S
S
SS
S
S
=
• A Network seen from the ‘inside’ is often a collection of subnets.
R
R
R
S = Subnet
CS51 – Week 2 -‐ Addresses• A Network/Subnet
S
H
HH
H
H H H H
=, or, or
H = Host
CS51 – Week 2 -‐ Addresses
CS51 – Week 2 -‐ Addresses
• Subnet masksIP addr. 10001110101000110101010100010100Subnet mask:11111111111111110000000000000000Host addr.: 10001110101000110000000000000000
CS51 – Week 2
• BREAK / Demo
CS-‐51 Week 2 -‐ Layers• Network Layers
• Purpose of using network layers– Descriptive tool
• Build concepts around layered approach– Guide line for implementation– Separation of Function
• Allow functions to be replaced independently of other layers– Assumptions
• Layers can be separated• Functionality ends up in the right place• Suggests that network architecture is not recursive
CS-‐51 Week 2 -‐ Layers
• Layering– Remember: in computer networks, programs talk to other programs over the network. Therefore the network’s job is to facilitate transporting data between programs.
– How is this organized?• The functionality of the network is subdivided into ‘layers’• Corresponding layers communicate with each other using agreed upon protocols
– Network models, OSI vs. TCP/IP
CS-‐51 Week 2 -‐ Layers• Layering-‐ breaking the Internet down into component parts
Application
Transport
Network
Network Interface
Physical
Application
Transport
Network
Network Interface
PhysicalPhysical Medium – wired, radio, optical, air
MAC layer, MAC addresses
Internet Protocol -‐ IP addresses
TCP, UDP, etc – PORT NUMBERS
CS-‐51 Week 2 -‐ LayersISO REFERENCE MODEL TCP/IP REFERENCE MODEL
Application Application
TransportPresentation
Session
Transport Network
Network
Data LinkNetwork Interface
PhysicalPhysical
www,ftp,video,telephoy,remote massage
TCP,UDP,RDP,RTP, etc.
IP,ICMP
Network Interface
Ethernet, frame relay,FDDI, optical fiber,WiFi, microwave, etc.
CS-‐51 Week 2 -‐ LayersThe Post Office vs The Internet -‐ example of encapsulation
Component Post Office The Internet
Unit of transmission Envelope Packet
Medium Paper Electrical, optical, radio links
Symbols The written lexicon 1’s and 0’s
Address -‐ origin Return Address Source Address
Address -‐ destination Receiver’s address Destination Address
Sender/Receiver Person Application Prog.
Sender/Receiver Location
Building Computer/Host
Receiver Recipient’s name Destination Port
Sender Sender’s name Source Port
APPAPP
CS-‐51 Week 2-‐ reviewSet of one or more application programs communicating via numbered ports (source, destination)
Source port
Destination port Source port
Destination port
TCP or UDPIP layer
Link Layer
Physical Layer
TCP or UDPIP layer
Link Layer
Physical Layer
TCP Exchange
Physical Medium
MAC Exchange
IP Exchange
Application
Transport
Network (IP)Network Interface
Physical
Tools:ping – bounce one or more packets off the
destination-‐ very helpful diagnostic-‐ ping stands for Packet INternet Groper
(possibly – not confirmed in the source code)-‐ example of ICMP ‘echo request’ and ‘echo reply’
traceroute – ask every router on path to destination to reply – uses TTL
nslookup – domain name resolutiondigg -‐ domain name resolution (newer)
CS 51 – Week 2
• ping• traceroute–Windows: Start-‐>CMD-‐>tracert, NSLOOKUP
• nslookup
Please play with and familiarize yourself with these utilities during the week.
CS-‐51 Week 2 – Packets, Protocols
• Tools– tcpdump -‐-‐ provides a means of translating dumps of packets captured from the network• Available to Mac users using terminal
CS-‐51 Week 2
• END Week2