Title: CSCE 515: Computer Network Programming
1CSCE 515Computer Network Programming
- Chin-Tser Huang
- huangct_at_cse.sc.edu
- University of South Carolina
2Layer 7 Application
Each Layer 7 protocol specifies how one
particular application uses a network. Each
protocol specifies how an application on one
machine makes request and how the application on
another machine responds.
Application
Presentation
Session
Transport
Network
Data link
Physical
3Layer 6 Presentation
Layer 6 protocols specify how to represent data.
They are used to translate from the
representation on one computer to the
representation on another computer.
Application
Presentation
Session
Transport
Network
Data link
Physical
4Layer 5 Session
Layer 5 protocols specify how to establish a
communication session with a remote system,
including specifications for security details
such as authentication using passwords.
Application
Presentation
Session
Transport
Network
Data link
Physical
5Layer 4 Transport
Layer 4 protocols specify how to provide reliable
data transfer for different applications.
Application
Presentation
Session
Transport
Network
Data link
Physical
6Layer 3 Network
Layer 3 protocols specify how addresses are
assigned and how packets are forwarded between
networks.
Application
Presentation
Session
Transport
Network
Data link
Physical
7Layer 2 Data Link
Layer 2 protocols specify how to organize data
into frames and how to transmit frames over a
network.
Application
Presentation
Session
Transport
Network
Data link
Physical
8Layer 1 Physical
Application
Layer 1 protocols specify details of interacting
with network hardware.
Presentation
Session
Transport
Network
Data link
Physical
9Origin of Internet
- In the 60s, US DoD funded ARPANET for testing
new network technologies - ARPANET was later extended to the Internet
- Protocol suite used with Internet is Transmission
Control Protocol/Internet Protocol (TCP/IP)
10TCP/IP Model in Internet
OSI model
TCP/IP model
Application
Application
Presentation
Session
Transport
Transport
Network
Network
Data link
Link
Physical
11Transport Layer
- Protocol TCP, UDP
- TCP provides a reliable flow of data between two
hosts including mechanism of connection setup,
congestion control, and retransmission - UDP provides a simpler service which is unreliable
12Client-Server Model
- Assume one side of communication is client, and
the other side is server - Server waits for a client request to arrive
- Server processes the client request and sends the
response back to the client - Iterative or concurrent
13Port Number
- TCP and UDP identify applications by 16-bit port
numbers - Some servers are assigned well-known port number
- For example, ftp is port 21 and telnet is port 23
- Clients usually use ephemeral port numbers
between 1024 and 5000
14Network Layer
- Protocol IP, ICMP, IGMP
- Assign addresses to hosts on the Internet
- Determine how to forward messages over the
Internet
15Internet Address
- Every interface on the Internet has a unique
address - In IPv4 every address is 32-bit, while in IPv6
every address is 128-bit - Usually specified with dotted-decimal notation
written as 4 decimal numbers, one for each byte - hadar.cse.sc.edu 129.252.130.109
16Classes of Network
- Every network belongs to one of five classes,
based on first byte in its address
7
24
hostid
0
netid
Class A
14
16
hostid
1
0
netid
Class B
21
8
hostid
1
1
0
netid
Class C
28
1
1
1
0
multicast group ID
Class D
1
1
1
1
reserved
Class E
17Ranges for Different Classes
- Class A 0.0.0.0 to 127.255.255.255
- Class B 128.0.0.0 to 191.255.255.255
- Class C 192.0.0.0 to 223.255.255.255
- Class D 224.0.0.0 to 239.255.255.255
- Class E 240.0.0.0 to 255.255.255.255
18Domain Name System (DNS)
- Dotted-decimal addresses are both hard to
remember and meaningless - Use a structured name for each host
- For example, hadar.cse.sc.edu
- DNS is a distributed database providing mapping
between IP addresses and hostnames
19Header Encapsulation
- An application sends messages down the protocol
stack - Each layer adds information to a message by
prepending an extra header
20Header Encapsulation
Application
User data
Transport layer header
Network layer header
Transport
Network
Link layer header
Link
21Application Programming Interface (API)
- A set of operations available to an application
programmer - Two popular APIs
- Sockets developed at Berkeley
- X/Open Transport Interface (XTI) developed by
ATT - We will focus on sockets
22What Is a Socket?
- An API between applications and network protocol
software provided by the OS - Provide following functions
- Define an abstract endpoint for communication
- Initiate and accept a connection
- Send and receive data
- Terminate a connection gracefully
23Elements of a Socket
- Each socket can be uniquely identified by
- Source IP address
- Source port number
- Destination IP address
- Destination port number
- An end-to-end protocol (TCP or UDP)
24Types of Sockets
- Two different types of sockets
- Stream sockets
- Datagram sockets
25Stream Sockets
- Also known as connection-oriented socket
- Use TCP
- Provide reliable, connected networking service
- Error free no out-of-order packets
- Applications telnet, ssh, http
26Datagram Sockets
- Also known as connectionless socket
- Use UDP
- Provide unreliable, best-effort networking
service - Packets may be lost may arrive out of order
- Applications streaming audio/video
27Next Class
- Socket programming in Java
- Read JNP Ch. 14, 16