Title: CS328 A Networking Primer
1CS-328 A Networking Primer
- Internet Programming
- TCP/IP
2OSI Network Model
7
Application Layer
Provides the interface to a set of network-wide
services. Provides such services as file
transfer access and management, document
and Message interchange, job transfer, etc.
6
Presentation Layer
Provides a syntax independent message interchange
service. Provides for data representation
conversion and syntax negotiation.
5
Session Layer
Provides the control structure for communication
between applications. Establishes, manages, and
terminates sessions between applications.
4
Transport Layer
Provides a message transfer facility independent
of underlying network. Provides for end-to-end
message transfer. Deals with connection
management, fragmentation, flow control, error
control.
3
Network Layer
Breaks data into information packets. Provides a
virtual packet carrying end-to-end
connection. Deals with routing, addressing, call
setup, buffering, and flow control.
2
Data Link Layer
Breaks data into information frames. Provides a
data link that is free of undetected transmission
errors. Deals with framing, data transparency,
error control, flow control
1
Physical Layer
Deals with bits. Provides a virtual bit
pipe. Provides for the transmission of bit
streams over physical medium. Deals with
mechanical, electrical, functional, procedural
aspects of medium.
3LANs
- Local Area Networks
- Layers 1 and 2 of the OSI model
- A collection of peer computers connected together
with a common wire protocol - Ethernet
- Token Ring
- for the purpose of local communications
- Printer sharing
- File sharing
- Usually connected together in the same
geographical area - Each host identified by its Media Access Control
(MAC) address
42 Peers Connected Together
S
S
PC
NIC
PC
NIC
R
R
Crossover Cable
Peer Connections like this are ok for connecting
two computers together, connecting additional
computers together requires the creation of a
Local Area Network (LAN)
5LAN
ethernet
ethernet
ethernet
HUB
STAR Topology
ethernet
ethernet
6Ethernet (CSMA/CD)
- Polite Human Communication
- Listen before speaking, if someone else is
speaking wait for them to finish - While speaking, if someone else starts speaking,
stop speaking - This collision detection
- Carrier Sense Multi Access w/Collision Detection
- Carrier Sense is how you tell if someone else is
already talking - While sending, listen to the receive if you hear
someone a collision is occurring so hold off and
try later
7Ethernet Cable
8An internetwork
LAN
LA
LAN
LAN
LAN
9Internetworks
- A network of networks
- Hubs let you build LANs
- To join LANs into a WAN requires a device that
works at the Network Layer of the OSI model to
bridge the multiple networks - This is usually an IP Router
- Could also be a Switch or a Bridge
10TCP/IP
- Transmission Control Protocol and Internet
Protocol (TCP/IP) - software suite that enables a single, standards
based approach to communications for a
heterogeneous wide area network
11Layering
- Network protocols are usually developed in layers
- TCP/IP protocol suite is a combination of a set
of protocols operating at the various layers
12TCP/IP Layers
Application
Telnet, FTP, SMTP....
Transport
TCP, UDP
Network
IP, ICMP,IGMP
Link
device driver and interface card ARP/RARP
13 Link Layer
- Handles all of the details of physically
connecting a machine to the network - network card
- device driver for the card
- operating system
- Protocols
- Address Resolution Protocol (ARP)
- Reverse Address resolution Protocol (RARP)
14NetworkLayer
- handles the movements of packets around the
network - routing takes place in the network layer
- protocols
- Internet Protocol (IP)
- Internet Control Message Protocol (ICMP)
- Internet Group Management Protocol (IGMP)
15Transport Layer
- provides a flow of data between two hosts for the
application layer - Transmission Control Program (TCP)
- Reliable Delivery System
- User Datagram Protocol (UDP)
- also known as Unreliable Datagram Protocol
16Application Layer
- handles details of the particular application
- common applications
- Telnet for remote login
- File Transfer Protocol (FTP)
- Simple Mail Transfer Protocol (SMTP)
- Simple Network Management (Protocol)
- Ping
- DateTime
17TCP and UDP
- TCP
- reliable data flow
- receipt acknowledgement
- packet sizing
- timeouts
- checksuming
- connection based
- telephone metaphor
- call another host
- caller knows if answered
- UDP
- sends datagrams (packets) fast
- no guarantees
- connectionless
- mailbox metaphor
- datagram is a letter
- put letter into mailbox
- hope someone picks it up
18TCP Frame
- 16 bit Source Port number
- 16 bit Destination Port Number
- 32 bit Sequence Number
- 32 bit Acknowledgement Number
- 4 bit Data Offset
- 6 bit reserved
- 1 bit Urgent Flag (URG)
- 1 bit Acknowledgement Field is valid (ACK)
- 1 bit Push Function (PSH)
- 1 bit Reset connection (RST)
- 1 bit Synchronized sequence numbers (SYN)
- 1 bit No more data from sender (FIN)
- 16 bit Window field ( of bytes sender is willing
to accept) - 16 bit checksum (ones complement sum of all 16
bit words in the header and data) - 16 bit urgent pointer (add to sequence of this
segment, this pointer to last octet of urgent
data - options -
- padding
- data
19TCP Connection - Establish
- TCP establishes a connection between two hosts by
performing a 3-way handshake, this will establish
a virtual connection between the two hosts
Host 1
Host 2
Network Messages
Send SYN seqx
Receive SYN segment Send SYN seqy, ACK x1
Receive SYN ACK segment Send ACK y1
Receive ACK Segment
20TCP Connection - Closing
Network Messages
Send FIN seqx
Receive FIN segment Send ACK x1
Send FIN ,ACK seqx1
Receive ACK segment
Receive FIN ACK segment Send ACK y1
Receive ACK Segment
21Client/Server and TCP/IP
FTP Protocol
FTP Client
FTP Server
TCP Protocol
TCP
TCP
IP Protocol
IP
IP
Ethernet Protocol
Ethernet driver
Ethernet driver
Ethernet
22IP Routing and protocol conv.
FTP Protocol
FTP Client
FTP Server
TCP Protocol
TCP
TCP
Router
IP Protocol
IP Protocol
IP
IP
IP
Ethernet driver
Token ring Driver
Ethernet driver
Token ring driver
Ethernet
Token Ring
23A Clearer Picture
User Process
User Process
User Process
User Process
Application
TCP
UDP
Transport
IP
ICMP
IGMP
Network
Hardware Interface
ARP
RARP
Link
media
24Internet Addresses (IPv4)
- 32 bit number
- written as 4 decimal numbers seperated by periods
(dotted decimal notation) - Five classes of internet addresses
- class A thru class E
- netid are issued by InterNIC (Internet Network
Information Center) also registers domain names
25Class A
0.0.0.0 thru 127.255.255.255
7 bits
24 bits
0
netid
hostid
26Class B
128.0.0.0 thru 191.255.255.255
14 bits
16 bits
10
netid
hostid
27Class C
192.0.0.0 thru 223.255.255.255
21 bits
8 bits
110
netid
hostid
28Class D
224.0.0.0 thru 239.255.255.255
28 bits
1110
multicast group id
29Class E
240.0.0.0 thru 247.255.255.255
27 bits
11110
reserved for future use
30IPv6 (IPng)
- 128 bit number
- written as 8 decimal numbers separated by colons
- 3 types of addresses
- Unicast - a packet sent to a unicast address is
delivered to the interface identified by that
address - Anycast - an identifier for a set of
interfaces(typically belonging to different
nodes). A packet sent to an anycast address is
delivered to one of the interfaces identified by
the address (the nearest identified by the
routing protocols measure of distance) - Multicast - An identifier for a set of interfaces
( typically belonging to different nodes). A
packet sent to a multicast address will be
delivered to all interfaces identified by that
address.
31IPv6 Text representation of Addresses
- Preferred form
- xxxxxxxx
- where each x represents a 4 hexadecimal digit
16-bit piece of the address - FEDCBA8976543210FEDCBA9876543210
- 10800008800200C417A
- note - leading zeros are not required
- note- pieces consisting of all zero bits may be
shown as - Alternative form
- sometimes used in mixed IPv4 and IPv6
environments - xxxxxxd.d.d.d
- where x represents high order 6 pieces of IPV6
address and the 4 ds represent the IPv4 address
32IPv4 to IPv6 transition
For tunneling IPV6 packets through an IPv4
infrastructure use
IPv4-compatible IPv6 address (special IPv6
unicast address that contain the IPv4 address)
80 bits
16bits
32 bits
00000000 0000 IPv4 address
For nodes that are IPv4 only (do not support
IPv6) use
IPv4-mapped IPv6 address
80 bits
16bits
32 bits
00000000 FFFF IPv4 address
33Domain Name System (DNS)
- Distributed database
- provides translation between IP addresses and
hostnames (and vice-versa) - Most TCPIP Applications can use either way of
identifying a host (i.e. by host name or IP
address)
34Encapsulation
user data
Application
user data
App.Hdr
Transport
user data
App.Hdr
TCP Hdr
Network
user data
App.Hdr
TCP Hdr
IP Hdr
Link
ethernet hdr
ethernet trailer
user data
App.Hdr
TCP Hdr
IP Hdr
ethernet frame
35Ports and Sockets
- mean the same thing, part of a buffering scheme
- implemented at transport layer (TCP/UDP)
- 16 bit number in the TCP or UDP header (32767
connection possible) - ports 1 thru 1023 reserved for well known ports
36Well Known Ports
- ports used for common TCP/IP applications
- TCP port 7 - Echo
- TCP port 20 - FTP-Data
- TCP port 21 - FTP-Commands
- TCP port 23 - telnet
- UDP port 67 - BOOTP (Server)
- UDP port 68 - BOOTP (Client)
- UDP port 69 - TFTP
- etc
37Java and sockets
- supports both TCP and UDP sockets
- also multicast under RMI
- provided both ends of a TCP application
connection (i.e. client and server facilities) - java.net
- also provides URL connections
- can be used to implement almost any existing
internet protocol.
38Java Sockets
- create a socket
- create an input stream
- create an output stream
- connect the inputstream to the socket
- connect the output stream to the socket
- reading and writing the stream transfers data
between the two hosts (local and remote)