CS-328 A Networking Primer Internet Programming TCP/IP CS-328
OSI Network Model 7 6 5 4 3 2 1 Application Layer Presentation 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. CS-328
LANs 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 CS-328
2 Peers Connected Together PC NIC NIC PC 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) CS-328
LAN ethernet ethernet ethernet HUB STAR Topology ethernet ethernet CS-328
Ethernet (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 CS-328
Ethernet Cable CS-328
An internetwork LAN LAN LAN LAN WAN LA LAN LAN LAN CS-328
Internetworks 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 CS-328
TCP/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 CS-328
Layering Network protocols are usually developed in layers TCP/IP protocol suite is a combination of a set of protocols operating at the various layers CS-328
TCP/IP Layers Application Telnet, FTP, SMTP.... Transport TCP, UDP Network IP, ICMP,IGMP Link device driver and interface card ARP/RARP CS-328
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) CS-328
NetworkLayer 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) CS-328
Transport 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 CS-328
Application 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 CS-328
TCP and UDP TCP UDP reliable data flow connection based 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 CS-328
TCP 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 (one’s 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 CS-328
TCP 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 seq=x Receive SYN segment Send SYN seq=y, ACK x+1 Receive SYN + ACK segment Send ACK y+1 Receive ACK Segment CS-328
TCP Connection - Closing Network Messages Send FIN seq=x Receive FIN segment Send ACK x+1 Receive ACK segment Send FIN ,ACK seq=x+1 Receive FIN + ACK segment Send ACK y+1 Receive ACK Segment CS-328
Client/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 CS-328
IP Routing and protocol conv. FTP Protocol FTP Client FTP Server TCP Protocol TCP TCP Router IP Protocol IP Protocol IP IP IP Ethernet driver Ethernet driver Token ring driver Token ring Driver Ethernet Token Ring CS-328
A Clearer Picture User Process User Process User Process User Process Application TCP UDP Transport ICMP IP IGMP Network Hardware Interface ARP RARP Link media CS-328
Internet 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 CS-328
Class A 0.0.0.0 thru 127.255.255.255 7 bits 24 bits netid hostid netid hostid CS-328
Class B 128.0.0.0 thru 191.255.255.255 14 bits 16 bits 10 netid hostid CS-328
Class C 192.0.0.0 thru 223.255.255.255 21 bits 8 bits 110 netid hostid CS-328
Class D 224.0.0.0 thru 239.255.255.255 28 bits 1110 multicast group id CS-328
Class E 240.0.0.0 thru 247.255.255.255 27 bits 11110 reserved for future use CS-328
IPv6 (IPng) 128 bit number 3 types of addresses 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 protocol’s 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. CS-328
IPv6 Text representation of Addresses Preferred form: x:x:x:x:x:x:x:x where each x represents a 4 hexadecimal digit 16-bit piece of the address FEDC:BA89:7654:3210:FEDC:BA98:7654:3210 1080:0:0:0:8:800:200C:417A 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 x:x:x:x:x:x:d.d.d.d where x represents high order 6 pieces of IPV6 address and the 4 d’s represent the IPv4 address CS-328
IPv4 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 0000…………………………………………0000 0000 IPv4 address For nodes that are IPv4 only (do not support IPv6) use: IPv4-mapped IPv6 address 80 bits 16bits 32 bits 0000…………………………………………0000 FFFF IPv4 address CS-328
Domain 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) CS-328
Encapsulation user data Application App.Hdr user data Transport TCP Hdr App.Hdr user data Network IP Hdr TCP Hdr App.Hdr user data Link ethernet hdr ethernet trailer IP Hdr TCP Hdr App.Hdr user data ethernet frame CS-328
Ports 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” CS-328
Well 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 CS-328
Java 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. CS-328
Java 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) CS-328