Docsity

IP Addresses and TCP/IP in CSCE 515: Computer Network Programming - Prof. W. Xu, Study notes of Computer Science

Toggle sidebar
bg1
CSCE 515:
Computer Network
Programming
TCP/IP
Wenyuan Xu
Department of Computer Science and
Engineering
University of South Carolina
IP โ€“ Network Layer
CSCE515 โ€“ Computer Network Programming
IP Datagrams
๎š„IP is the network layer
๎š…packet delivery service (host-to-host).
๎š…translation between different data-link
protocols.
CSCE515 โ€“ Computer Network Programming
IP Datagram
VERS HL
Fragment Offset
Total LengthService
Datagram ID FLAG
TTL Protocol Header Checksum
Source Address
Destination Address
Options (if any)
Data
1 byte1 byte 1 byte 1 byte
CSCE515 โ€“ Computer Network Programming
IP Addresses
๎š„IP addresses are not the same as the underlying
data-link (MAC) addresses. WHY?
๎š„IP is a network layer - it must be capable of
providing communication between hosts on
different kinds of networks (different data-link
implementations).
๎š„The address must include information about
what network the receiving host is on. This is
what makes routing feasible.
CSCE515 โ€“ Computer Network Programming
IP Addresses
๎š„IP addresses are logical addresses (not
physical)
๎š„32 bits.
๎š…IP Addresses are usually shown in dotted decimal
notation: 1.2.3.4
๎š„Includes a network ID and a host ID.
๎š„Every host must have a unique IP address.
๎š„IP addresses are assigned by a central authority
(American Registry for Internet Numbers for North
America).
๎š…http://www.iana.org/ipaddress/ip-addresses.htm
pf3
pf4
pf5
pf8
pf9
pfa

Partial preview of the text

Download IP Addresses and TCP/IP in CSCE 515: Computer Network Programming - Prof. W. Xu and more Study notes Computer Science in PDF only on Docsity!

CSCE 515:

Computer Network

Programming

TCP/IP

Wenyuan Xu Department of Computer Science and Engineering University of South Carolina

IP โ€“ Network Layer

CSCE515 โ€“ Computer Network Programming

IP Datagrams

ย„ IP is the network layer

packet delivery service (host-to-host).

translation between different data-link protocols.

CSCE515 โ€“ Computer Network Programming

IP Datagram

VERS HL Fragment Offset

Service Total Length Datagram ID FLAG TTL Protocol Header Checksum Source Address Destination Address Options (if any)

Data

1 byte 1 byte 1 byte 1 byte

CSCE515 โ€“ Computer Network Programming

IP Addresses

ย„ IP addresses are not the same as the underlying data-link (MAC) addresses. WHY?

ย„ IP is a network layer - it must be capable of providing communication between hosts on different kinds of networks (different data-link implementations).

ย„ The address must include information about what network the receiving host is on. This is what makes routing feasible. CSCE515 โ€“ Computer Network Programming

IP Addresses

ย„ IP addresses are logical addresses (not physical) ย„ 32 bits.

IP Addresses are usually shown in dotted decimal notation: 1.2.3. ย„ Includes a network ID and a host ID. ย„ Every host must have a unique IP address. ย„ IP addresses are assigned by a central authority ( American Registry for Internet Numbers for North America).

http://www.iana.org/ipaddress/ip-addresses.htm

CSCE515 โ€“ Computer Network Programming

The four for mats of IP Addresses

0 NetID

10

(^110) NetID

(^1110) Multicast Address

HostID

NetID HostID

HostID

ClassClass A A

BB

CC

DD

8 bits 8 bits 8 bits 8 bits

CSCE515 โ€“ Computer Network Programming

Class A z 128 possible network IDs z over 16M host IDs per network ID

Class A Class A z 128 possible network IDs z over 16M host IDs per network ID

Class B Class B z16K possible network IDs z64K host IDs per network ID

Class C Class C zover 2 million possible network IDs zabout 256 host IDs per network ID

CSCE515 โ€“ Computer Network Programming

Network and Host IDs

ย„ A Network ID is assigned to an organization by a global authority.

ย„ Host IDs are assigned locally by a system administrator.

ย„ Both the Network ID and the Host ID are used for routing.

CSCE515 โ€“ Computer Network Programming

IP Addresses

ย„ IP Addresses are usually shown in dotted decimal notation: 1.2.3.4 00000001 00000010 00000011 00000100 ย„ cse.sc.edu is 129.252.138. 10000001 11111100 10001010 00001000

CSE has a class B networkCSE has a class B networkCSE has a class B networkCSE has a class B network

CSCE515 โ€“ Computer Network Programming

Host and Network Addresses

ย„ A single network interface is assigned a single IP address called the host address.

ย„ A host may have multiple interfaces, and therefore multiple host addresses.

ย„ Hosts that share a network all have the same IP network address (the network ID).

CSCE515 โ€“ Computer Network Programming

Special IP addresses

ย„ An IP broadcast addresses has a host ID of all 1s.

ย„ An IP address that has a host ID of all 0s is called a network address and refers to an entire network.

ย„ localhost: 127.0.0.

CSCE515 โ€“ Computer Network Programming

Routing table

ย„ Destination IP address. Either host address or a network address ย„ IP address of the next hop Router ย„ Flags ย„ Network interface

ย„ /sbin/route Destination129.252.130.0 (^) *Gateway Genmask255.255.255.0 FlagsU Metric 0 Ref 0 Use 0 Ifaceeth loopback * 255.0.0.0 U 0 0 0 lo default SWG130.cse.sc.edu 0.0.0.0 UG 1 0 0 eth

2007 CSCE515 โ€“ Computer Network Programming CSCE515 โ€“ Computer Network Programming

Mapping IP Addresses to Hardware

Addresses

ย„ IP Addresses are not recognized by hardware. ย„ If we know the IP address of a host, how do we find out the hardware address? ย„ The process of finding the hardware address of a host given the IP address is called Address Resolution Address Resolution

CSCE515 โ€“ Computer Network ProgrammingCSCE515 โ€“ Computer Network Programming

ARP

ย„ The Address Resolution Protocol is used by a sending host when it knows the IP address of the destination but needs the Ethernet (or whatever) address.

ย„ ARP is a broadcast protocol - every host on the network receives the request.

ย„ Each host checks the request against itโ€™s IP address - the right one responds.

EthernetD. addrEthernetS. addr type Ethernet header

Ethernet addrSender SenderIP addr Ethernet addrTarget TargetIP addr 28 byte ARP request/reply

op

CSCE515 โ€“ Computer Network Programming

ARP conversation

HEY - Everyone please listen! Will 128.213.1.5 please send me his/her Ethernet address?

Hi Green! Iโ€™m 128.213.1.5, and my Ethernet address is 87:A2:15:35:02:C

not me

CSCE515 โ€“ Computer Network ProgrammingCSCE515 โ€“ Computer Network Programming

Exampleโ€“ Proxy ARP

H E H E H E H E H H5E5 E 129.252.138.3 129.252.138.4 129.252.138.

129.252.138.

Proxy ARP

EthernetD. addrEthernetS. addr type Ethernet header

Ethernet addrSender SenderIP addr Ethernet addrTarget TargetIP addr 28 byte ARP request/reply

op

129.252.138.

CSCE515 โ€“ Computer Network ProgrammingCSCE515 โ€“ Computer Network Programming

Exampleโ€“ routing

H E H E H E H E H H5E5 E 129.252.138.10 129.252.138.40 129.252.10.

129.252.10.

EthernetD. addrEthernetS. addr size Ethernet header

S. IP addr (^) IP addr.D. IP header

Data

129.252.138.

CSCE515 โ€“ Computer Network Programming

Reverse Address Resolution

ย„ The process of finding out the IP address of a host given a hardware address is called Reverse Address ResolutionReverse Address Resolution

ย„ Reverse address resolution is needed by diskless workstations when booting (which used to be quite common).

CSCE515 โ€“ Computer Network Programming

RARP conversation HEY - Everyone please listen! My Ethernet address is 22:BC:66:17:01:75. Does anyone know my IP address?

Hi Green! Your IP address is 128.213.1.17.

not me

CSCE515 โ€“ Computer Network Programming

Services provided by IP

ย„ Connectionless Delivery (each datagram is treated individually).

ย„ Unreliable (delivery is not guaranteed).

ย„ Fragmentation / Reassembly (based on hardware MTU).

ย„ Routing.

ย„ Error detection.

CSCE515 โ€“ Computer Network Programming

IP Datagram

VERS HL Fragment Offset

Service Fragment Length Datagram ID FLAG TTL Protocol Header Checksum Source Address Destination Address Options (if any)

Data

1 byte 1 byte 1 byte 1 byte

CSCE515 โ€“ Computer Network Programming

IP Datagram Fragmentation

ย„ Each fragment (packet) has the same structure as the IP datagram.

ย„ IP specifies that datagram reassembly is done only at the destination (not on a hop- by-hop basis).

ย„ If any of the fragments are lost - the entire datagram is discarded (and an ICMP message is sent to the sender).

CSCE515 โ€“ Computer Network Programming

IP Flow Control & Error Detection

ย„ If packets arrive too fast - the receiver discards excessive packets and sends an ICMP message to the sender (SOURCE QUENCH). ย„ If an error is found (header checksum problem) the packet is discarded and an ICMP message is sent to the sender.

CSCE515 โ€“ Computer Network Programming

TCP UDP

IP

802.

Process Layer

Transport Layer

Network Layer

Data-Link Layer

Process Process

ICMP, ARP & RARP

CSCE515 โ€“ Computer Network Programming

UDP User Datagram Protocol

ย„ UDP is a transport protocol

communication between processes

ย„ UDP uses IP to deliver datagrams to the right host. ย„ UDP uses ports to provide communication services to individual processes.

CSCE515 โ€“ Computer Network Programming

Ports

ย„ TCP/IP uses an abstract destination point called a protocol port. ย„ Ports are identified by a positive integer. ย„ Operating systems provide some mechanism that processes use to specify a port.

CSCE515 โ€“ Computer Network Programming

Ports

Host AHost A Host BHost B

Process

Process

Process

Process

Process

Process

CSCE515 โ€“ Computer Network Programming

UDP

ย„ Datagram Delivery ย„ Connectionless ย„ Unreliable ย„ Minimal Source Port Destination Port Length Checksum

Data

UDP Datagram FormatUDP Datagram Format

The term datagram is also used to describe the unit of transfer of UDP!

CSCE515 โ€“ Computer Network Programming

TCP

Transmission Control Protocol

ย„ TCP is an alternative transport layer protocol supported by TCP/IP. ย„ TCP provides:

Connection-oriented

Reliable

Full-duplex

Byte-Stream

CSCE515 โ€“ Computer Network Programming

Connection-Oriented

ย„ Connection oriented means that a virtual connection is established before any user data is transferred.

ย„ If the connection cannot be established - the user program is notified (finds out).

ย„ If the connection is ever interrupted - the user program(s) is finds out there is a problem.

CSCE515 โ€“ Computer Network Programming

Reliable

ย„ Reliable means that every transmission of data is acknowledged by the receiver.

ย„ If the sender does not receive acknowledgement within a specified amount of time, the sender retransmits the data.

Reliable does not mean that things don't go wrong, it means that we find out when things go wrong.

CSCE515 โ€“ Computer Network Programming

Byte Stream

ย„ Stream means that the connection is treated as a stream of bytes.

ย„ The user application does not need to package data in individual datagrams (as with UDP). Somebody needs to do this since IP is delivering all the data, it's just that the application layer doesn't need to do this! CSCE515 โ€“ Computer Network Programming

Buffering

ย„ TCP is responsible for buffering data and determining when it is time to send a datagram.

ย„ It is possible for an application to tell TCP to send the data it has buffered without waiting for a buffer to fill up.

CSCE515 โ€“ Computer Network Programming

Full Duplex

ย„ TCP provides transfer in both directions (over a single virtual connection).

ย„ To the application program these appear as 2 unrelated data streams, although TCP can piggyback control and data communication by providing control information (such as an ACK) along with user data.

CSCE515 โ€“ Computer Network Programming

TCP Ports

ย„ Interprocess communication via TCP is achieved with the use of ports (just like UDP).

ย„ UDP ports have no relation to TCP ports (different name spaces).

CSCE515 โ€“ Computer Network Programming

Hmmmmm. TCP or UDP?

ย„ Electronic commerce?

ย„ Video server?

ย„ File transfer?

ย„ Email?

ย„ Chat groups?

ย„ Robotic surgery controlled remotely over a network?

2007 CSCE515 โ€“ Computer Network ProgrammingCSCE515 โ€“ Computer Network Programming

Assignment & Next time

ย„ Reading:

TI 3,4,5,6,17 **

TCP/IP FAQ

ย„ Next Lecture:

Sockets Programming API