Docsity

Network Programming With TCP IP-Network and System Administration-Lecture Slides, Slides of Network and System Administration

Partial preview of the text

Download Network Programming With TCP IP-Network and System Administration-Lecture Slides and more Slides Network and System Administration in PDF only on Docsity!

UNIX

Network Programming

with TCP/IP

UNIX

Network Programming

with TCP/IP

UNIX

Network Programming with TCP/IP

UNIX Network Programmingwith TCP/IP

UNIX

Network Programming with TCP/IP

UNIX Network Programming with TCP/IP

Short Course Notes

Alan Dix © 1996

http://www.hiraeth.com/alan/tutorials

UNIX

Network Programming with TCP/IP

Course

Outline

Alan Dix http://www.hcibook.com/alan

Session 1 Internet Basics Session 2 First Code Session 3 Standard Applications

Session 4 Building Clients Session 5 Servers I Session 6 Servers II Session 7 Security

Three interrelated aspects:

m TCP/IP protocol suite

m standard Internet applications

m coding using UNIX sockets API

UNIX TCP/IP^ Short Course Notes Alan Dix © 1996 1

UNIX

Network Programming

with TCP/IP

UNIX

Network Programming

with TCP/IP

UNIX

Network Programming with TCP/IP

UNIX Network Programmingwith TCP/IP

UNIX

Network Programming

Session 1 with TCP/IP

Internet Basics

UNIX

Network Programming with TCP/IP

Session 1

Alan Dix http://www.hcibook.com/alan

  • origins
  • internets and the Internet
  • protocol layers
  • addressing
  • common applications

+ using them

  • TCP and UDP
  • port numbers
  • APIs

+ information calls

UNIX TCP/IP^ Short Course Notes Alan Dix © 1996 1

internets and the Internet

an internet is

a collection of

  • interconnected networks
  • (possibly different) e.g. X25, AppleTalk

the Internet is

a particular internet which

  • uses the TCP/IP protocols
  • is global
  • is hardware and network independent
  • is non-proprietary in addition
  • supports commonly used applications
  • publicly available standards (RFCs)

the Internet is not (just) the web!

UNIX TCP/IP^ Short Course Notes Alan Dix © 1996 3

Characteristics of the Internet

To communicate you need:

  • continuous connection
  • common language
  • means of addressing

UNIX TCP/IP^ Short Course Notes Alan Dix © 1996 4

Protocols – the Language of the Internet

electrical signals

low-level networks (e.g. ethernet)

IP layer (end-to-end)

TCP/UDP layer

application protocols (e.g. FTP, telnet, http) application user interfaces (e.g. Fetch, mosaic)

OSI

ICMP (control and routing)

Physical

Link

Transport

Network

Session, Presentation, Application

routers

end-points

TCP/IP

Standardisation:

  • RFC (request for comments) and DoD MIL

RFCs also include (defined but not required):

  • PPP, ethernet packaging, etc.
  • FTP and other protocols

UNIX TCP/IP^ Short Course Notes Alan Dix © 1996 6

Addressing

J. C. T. Jennings, Linbury Court School, Dunhambury, Sussex, England, Europe, Eastern Hemisphere, Earth, near Moon, Solar System, Space, near More Space†

Without addresses can only broadcast

Four types of address:

¬ location independent e.g. personal names physical location e.g. letter addresses ® logical location e.g. organisational hierarchy ¯ route based e.g. old email addresses

Two kinds of Internet address:

IP address – type (sort of) e.g. 161.12.188. domain name – type ® e.g. zeus.hud.ac.uk

† (^) extract from Jennings Goes to School, Anthony Buckeridge, Collins, 1950.

UNIX TCP/IP^ Short Course Notes Alan Dix © 1996 7

Domain names

  • human readable names

..... or at least ASCII!

  • Heirarchical (roughly organisational)

zeus.hud.ac.uk uk – United Kingdom ac – academic hud – huddersfield zeus – local machine N.B. USA is implicit – cs.washington.edu

  • Decentralised administration
  • Mapping

from name to IP address

  • domain name servers also reverse mapping
  • C API :

gethostbyname – name → IP address gethostbyaddr – IP address → name

UNIX TCP/IP^ Short Course Notes Alan Dix © 1996 9

Common applications

  • FTP (file transfer protocol)
  • SMTP (simple mail transfer protocol)
  • telnet (remote logins)
  • rlogin (simple remote login between UNIX machines)
  • World Wide Web (built on http)
  • NFS (network filing system – originally for SUNs)
  • TFTP (trivial file transfer protocol – used for booting)
  • SNMP (simple network management protocol)

h In each case protocols are defined

h User interfaces depend on platform (where relevant)

UNIX TCP/IP^ Short Course Notes Alan Dix © 1996 10

Network communications

Communication can be:

  • Connectionless m address every message

h like letters

  • Connection based m use address to establish a fixed link m send each message using the link

h like telephone

N.B. both need an address

⇒ some sort of system address book

or, publicly known addresses

UNIX TCP/IP^ Short Course Notes Alan Dix © 1996 12

Network communications – 2

Other issues:

  • Reliability

Do all messages arrive? Do they arrive in the right order?

  • Buffering

effects responsiveness hides potential deadlock

  • Messages or byte-stream

sent: write 1 (len=26): “abcde....vwxyz” write 2 (len=10): “0123456789” received: read 1 (len=20): “abcde....qrst” read 2 (len=16): “uvwxyz012...89”

⇒ fixed length messages or prefix with length

UNIX TCP/IP^ Short Course Notes Alan Dix © 1996 13

TCP & UDP

Both

  • built on top of IP
  • addressed using port numbers

process to process

(on UNIX platforms)

TCP

  • connection based
  • reliable
  • byte stream

used in: FTP, telnet, http, SMTP

UDP

  • connectionless
  • unreliable
  • datagram (packet based)

used in: NFS, TFTP

UNIX TCP/IP^ Short Course Notes Alan Dix © 1996 15

Port numbers

  • 16 bit integers
  • unique within a machine
  • to connect need IP address + port no

TCP

  • connection defined by IP address & port of server

+ IP address & port of client

UNIX

  • port < 1023 – root only
  • used for authentication (e.g. rlogin)

How do you find them?

4 well known port numbers

UNIX TCP/IP^ Short Course Notes Alan Dix © 1996 16