Objectives| Introduction| What is a Network?| TCP/IP and the Internet| Names and Addresses| Name Resolution| Routing| Network Services| Some Useful Commands| Conclusions| Review Questions
Characteristics of a network include
Diagram 12.1.LANs and WANs.
TCP/IP is the protocol used by the Internet, a network of networks spread throughout the world connecting two million machines with over twenty million users. It is not necessary to be connected to the Internet to use TCP/IP. (However being able to connect to the Internet is one of the advantages of using TCP/IP.)
TCP/IP is an example of a layered communications suite. The advantage of this layered approach is that the protocols at higher levels can safely assume that the lower level protocols will carry out their responsibilities. For example TCP does not need to know anything about the hardware being used because it is hidden by the layers below it.
Diagram 12.2. Four Layers of TCP/IP.
TCP/IP uses four layers
Serial line internet protocol (SLIP) and Point to Point Protocol (PPP) are two protocols that allow TCP/IP to be run over serial lines and modems.
A TCP connection is like a telephone connection. Before any information is sent the two ends connect and make a channel (sometimes referred to as a stream) and all information sent between the two hosts is sent down that stream. TCP performs checks that make sure that all the information sent down the channel actually arrives at the destination in the same order as it was sent.
UDP is like the postal service in that all information is sent in individual messages (called packets or datagrams). These datagrams do not always take the same route when going from one point to another.
UDP is an unreliable, connectionless protocol. TCP is a reliable, connection oriented transport protocol.
UDP is used to send small infrequent messages while TCP is used in situations where large amounts of information must be transferred safely.
Protocol Full Name Purpose SMTP Simple Mail Transfer Protocol defines the format of mail messages and the commands used to send and receive mail messages Telnet telnet defines a protocol used to login remotely to other machines on the network TFTP FTP (Trivial) File Transfer Protocol protocol for transferring files between two machines TCP Transmission Control Protocol a connection oriented, reliable, full-duplex byte stream service UDP User Datagram Protocol connectionless, unreliable datagram service IP Internet Protocol ensures that individual datagrams get to their destination ICMP Internet Control Message Protocol used to send the error/control messages for the TCP/IP software ARP/RARP (Reverse) Address Resolution Protocol performs the translation from Internet addresses to ethernet addresses (specific to hardware) Table 12.1. Some of the Internet Protocols.
Diagram 12.2 includes RFC numbers that correspond to the different protocols. If you have access to the Internet you can anonymously ftp RFCs from a number of well-known sites (including archie.au).
RFCs can and often are very technical and hard to understand unless you are familiar with the area (the RFC for ftp is about 80 pages long).
TCP/IP provides two types of unique identifier for every host
Since IP is the protocol designed to route information to a particular host this address is sometimes referred to as the IP address.
Every machine on a network must have a unique IP addresses. When setting up a LAN this can be reasonably simple and IP addresses can be assigned by the Systems Administrator.
However the Internet is classed as one network so every machine on the Internet must have a unique IP address. IP addresses for a LAN are assigned by a central authority to ensure that no two machines have the same address.
This central authority generally does not (currently) hand out individual IP addresses. A site will usually apply for a network address (for example, CQU's network address is 138.77). This network address provides you with a set of IP addresses that can be used for the entire LAN. There are currently three types of network address being handed out. The type of network addresses assigned depends on the size of a site.
There are three network address classes that are assigned to sites, classes A, B and C (there are two others but they aren't normally used). Each class has a maximum number of machines that can be connected. Table 12.2 lists the types of network addresses and their characteristics.
The current problem with Internet addressing is that there isn't a network class for sites that have more than 254 hosts but less than 64,000 hosts (mainly medium size companies).
Address Class Value first byte Number of Hosts A 1 to 126 16 million B 128 to 191 64,000 C 192 to 223 254 Table 12.2. IP Address Classes.The Central Queensland University has been assigned the Class B address 138.77. Any machine that has an IP address starting with 138.77 is part of the University network.
Some network addresses are reserved for specific purposes
A host name under TCP/IP follows the format hostname.site.domain.country.
Domain Purpose edu Educational institution (University, etc) com Commercial company gov Government department org Non-profit organization Table 12.3. Example Domain Names. Country Code Country nothing United States au Australia uk United Kingdom in India ca Canada fr France de Germany ch Switzerland no Norway se Sweden nz New Zealand Table 12.4. Example Country Codes.jasper.cqu.edu.au is a fully qualified name and uniquely identifies the machine jasper on the CQU campus to the entire Internet. There cannot be another machine called jasper at CQU. However there could be another machine called jasper at James Cook University in Townsville (its name would be jasper.jcu.edu.au). A fully qualified name must be unique.
It is not always necessary to specify a fully qualified name. If a user on aldur (see Diagram 12.3) enters the command telnet jasper it will be assumed that because it isn't fully qualified the user means the machine jasper within the current domain (cqu.edu.au).
The TCP/IP software performs name resolution. It accepts the name jasper.cqu.edu.au and then resolves that into the machine's IP address. There are two methods that can be used to perform this translation from hostname to IP address
127.0.0.1 localhost loopback 138.77.36.29 aldur aldur.cqu.edu.au 138.77.1.1 jasper jasper.cqu.edu.au 138.77.37.28 pol pol.cqu.edu.auWhen a user on aldur enters the command telnet jasper.cqu.edu.au the software first looks in the hosts file for an entry for jasper. If it finds an entry it obtains jasper's IP address and then can execute the command.
If it can't find an entry for a machine there are two options
For example:
How does an administrator in Rockhampton, Australia know when a small company in Bolivia goes bankrupt and all its machines are sold and are no longer on the net?.
DNS is a hierarchical hostname management system that allows each site (or part of a site) to maintain its own IP address information without having to inform some central site.
Instead each network maintains its own authoritative name server that can perform the translation from hostname to IP address for that network. If a local machine changes its IP address then only the local name server is updated. Other sites will know how to contact the networks name server by using the DNS.
For example:
At CQU the Mathematics & Computing Department might maintain a name server for its network (kknuth). Up the hierarchy CQU may contain a name server for the entire University (jasper). jasper would now that the name server for the Maths & Computing network is kknuth. jasper would not know anything about the Maths & Computing network.
Moving further up there might be a name server for all the Queensland Universities that would know the name servers for each individual Queensland University.
If someone on a machine at Queensland University types the command telnet aldur.cqu.edu.au the user's machine must obtain the IP address for aldur.cqu.edu.au before it can carry out the command. It will do this using the following steps
A machine specifies its name server in the file /etc/resolv.conf. The resolv.conf file for aldur might contain
nameserver 138.77.36.1 # Maths & Computing nameserver nameserver 138.77.1.1 # CQU name serverNotice that the machines in the resolv.conf file are specified by their IP address and not their hostnames?
Exercise 12.1. You are logged into the machine pol.cqu.edu.au and you enter the command telnet sunsite.unc.edu but you get a message host not found. What might have gone wrong (there are a number of reasons)?
TCP/IP is based on a model in which smaller individual networks are connected together to form larger networks. Diagram 12.3. is a small section of the network at the Central Queensland University.
The CQU campus is divided into a number of separate networks (LANs) all using ethernet. Each separate network has its own network number. For example the Maths & Computing Department network is 138.77.36. All machines in the Department have IP addresses that start with 138.77.36.
Each individual network is limited to 254 machines because two of the numbers 0 and 255 are reserved for broadcast addresses.
Any machine on an ethernet LAN can send information straight to another machine on that LAN. When a machine places a packet on an ethernet network every host on that LAN can see that information. However they will ignore it unless it is specifically addressed for them (or they have been programmed to look at everything).
Diagram 12.3. Part of the CQU Campus Network.
For example when the machine aldur (138.77.36.29) from diagram 12.3 wants to send some information to the machine 138.77.36.1 it places the packets on the ethernet. All the machines on the LAN will see the information but only 138.77.36.1 will accept the information.
Figure 12.1. Security Problem with Ethernet.
How does information find its way from one machine to another? It is obvious that every machine connected to the Internet CANNOT know about the address or the route to every other machine.
The gateway machine is basically the connection from one network to another. It is convention that the gateway machine (it might be a computer or a purpose built device) be the first machine on the network. For example the gateway machine for the Maths & Computing LAN is 138.77.36.1.
If a user on aldur wants to send some information to the machine pol it would place the information onto the ethernet with an address 138.77.37.28 (after already going through the name/address translation scheme outlined above). All the machines on the LAN would ignore the packet (because of the address) except the gateway machine. It would see that the information is meant for another network.
The gateway machine would pick that packet up and place it onto the outside net (in this case the campus fibre backbone). All the machines connected here would ignore it except the gateway machine for the 138.77.37 network that would recognise the address as one of its own. The gateway machine 138.77.37.1 would then place the packet onto the ethernet for the 138.77.37 network and the machine with the corresponding address (pol) would recognise it and snaffle it.
The process works the same way if you are sending information across the world.
Exercise 12.2. What would happen if a user on aldur wanted to send information to the machine sunsite.unc.edu?
Every ethernet card has built into it a 48 bit address (called an Ethernet address or a Media Access Control address). The high 24 bits of the address are used to assign a unique number to manufacturers of ethernet addresses and the low 24 bits are assigned to individual ethernet cards made by the manufacturer.
Every packet of information sent on ethernet contains a source and destination MAC address. If the card in your machine recognises the destination MAC as its own it passes the packet to the protocol in the next layer (refer to Diagram 12.2).
ARP, the address resolution protocol, maintains tables of translations between IP address and Ethernet address. These tables are dynamic and are added to as different machines are contacted. UNIX supplies a command arp that can be used to examine these tables. arp -a will list the current entries. Refer to your manual pages for more information.
For example:
bash$ arp -a Address HW type HW address Flags 138.77.37.1 10Mbps Ethernet 00:00:0C:03:79:2F C bash$ telnet bertha . . bash$ arp -a Address HW type HW address Flags 138.77.37.1 10Mbps Ethernet 00:00:0C:03:79:2F C 138.77.37.37 10Mbps Ethernet 00:40:F6:60:4D:A4 CExercise 12.3. If you are connected to a LAN use the arp command to examine the tables of your machine.
Exercise 12.4. Use a command to connect to a machine not listed in the tables and reexamine the arp tables to see if it has been added.
The provision of network services like ftp, telnet, e-mail and others relies on three different components
For example:
Diagram 12.4. Example telnet Connection.
aldur$ telnet jasper ....login procedure onto jasper jasper$ netstat | grep aldur Active Internet connections these two header lines have been added for understanding Proto Recv-Q Send-Q Local Address Foreign Address (state) tcp 0 0 jasper.telnet aldur.cqu.EDU.AU.1467 ESTABLIS back on aldur aldur$ netstat Active Internet connections Proto Recv-Q Send-Q Local Address Foreign Address (state) tcp 0 0 aldur.cqu.EDU.AU.1467 jasper.cqu.EDU.A.telne ESTABLIS
Different protocols use predefined ports on which they listen for incoming calls. For example if you telnet to another machine your machine first contacts the process listening on port 23 of the remote machine to negotiate the connection. Table 12.5. lists some of the other well known ports.
Port Number Purpose 20 ftp-data 21 ftp 23 telnet 25 smtp (mail) 119 nntp (network news) Table 12.5. Reserved Ports.Which port is used by which protocol is stored in the file /etc/services. Each line in the services file is of the format service-name port/protocol aliases, where service-name is the official name, port is the port number that it listens on, protocol is the transport protocol it uses and aliases is a list of alternate names.
For example:
The following are extracts from an example /etc/services file echo 7/tcp echo 7/udp discard 9/tcp sink null discard 9/udp sink null systat 11/tcp users daytime 13/tcp daytime 13/udp ftp-data 20/tcp ftp 21/tcp telnet 23/tcp smtp 25/tcp mail nntp 119/tcp usenet # Network News Transfer ntp 123/tcp # Network Time ProtocolYou should see the similarities between the numbers listed in this listing and those in Table 12.5.
Daemon Name Purpose inetd Internet services daemon used to manage most of the TCP/IP daemons. Configured using the /etc/inetd.conf file rwhod periodically sends information to every other host on the network about who is logged in, how long they've been logged in etc. (used by the rwho and ruptime commands) routed maintains dynamic routing information named used by the DNS to contact other machines (see previous section) timed used to ensure that the system clocks on all machines are synchronised nfsd handles requests for the network file system biod used by NFS clients to do read ahead and write behind smtpd accepts incoming mail messages telnetd accepts incoming telnet requests Table 12.6. Various Internet Daemons.For a particular protocol to work there must be a daemon running that is listening to the specified port to accept the information. There are two ways in which a daemon might be started
service-name socket-type protocol flags user server_program args
service-name corresponds to the name of the network service and is the same as the one listed in /etc/services. user is the username to run the program as. The following is from the inetd.conf file of one machine.
ftp stream tcp nowait root /usr/sbin/in.ftpd in.ftpd telnet stream tcp nowait root /usr/sbin/in.telnetd in.telnetd nntp stream tcp nowait root /usr/public/bin/nntpd nntpdWhenever the machine receives a request on a port the inetd daemon will examine the inetd.conf file to determine the program that should be executed to respond to the request. For example a request on port number 21 (taken from the /etc/services file) will be identified as a telnet request and the program to run for telnet is /usr/sbin/in.telnetd (taken from the /etc/inetd.conf file).
Exercise 12.5. The smtp protocol is used to handle electronic mail messages. Examine the entry for smtp in the /etc/services file. smtp must have a daemon program running to respond to requests. Find out where it is started on your machine.
The format of these Internet protocols is laid down in documents referred to as request for comments (RFCs). Each protocol will have its own RFC that describes it. RFCs are available off the network from a number of anonymous ftp sites including archie.au and ftp.lcs.mit.edu.
Some of these protocols smtp, ftp and nntp, are text based. They make use of simple text based commands to perform their duty. Table 12.7. contains a list of the commands that smtp understands.
Command Purpose HELO hostname startup and give your hostname MAIL FROM:sender-address start transaction from sender RCPT TO:recipient-address name recipient for message VRFY address verify deliverability of address EXPN address expand mailing list address DATA start text of mail message RSET reset state, drop transaction NOOP do nothing DEBUG [level] set debugging level, default 1 HELP produce a help message QUIT close SMTP connection Table 12.7. SMTP Commands.When transferring a mail message the two daemons will connect and carry out a conversation using the above commands. Since these are straight text commands it is possible for a user to pretend to be a daemon.
For example: The following is the start of an example conversation between a smtp daemon and a normal user. The text in this font are explanations.
bash$ telnet aldur 25 connect to the smtp port (see /etc/services) Trying 138.77.36.29 ... Connected to aldur.cqu.edu.au. Escape character is '^]'. 220 aldur.cqu.edu.au Amix Smail3.1.28.1 #2 ready at Sun, 28 Aug 94 12:04 EST helo aldur tell the machine who I am (the name of another machine not a user) 250 aldur.cqu.edu.au Hello aldur mail from: god@heaven.com this is who the mail is coming from 250It doesn't take a genius to see the application some immature or morally corrupt people might use this "feature" for.... Sender Okay data I want to enter some data which is the message 503 Need RCPT (recipient) can't do that yet, have to tell it who to send the message to rcpt: david@aldur 500 Command unrecognized oops, typed it wrong rcpt to: david@aldur 250 ... Recipient Okay data 354 Enter mail, end with "." on a line by itself You have been a naughty boy type in the message . 250 Mail accepted quit bye, bye 221 aldur.cqu.edu.au closing connection Connection closed by foreign host.
The above example makes use of a "useful" feature of the telnet command. By default the format for telnet is telnet hostname. When executed like this it connects to port 23 of the remote host since that is where the telnet daemon is listening. However it is possible to tell telnet to connect to another port using the format
telnet hostname port-numberExercise 12.6. Try doing the same task for ftpas was done above for smtp. What is the port number for the ftp daemon?
For example:
bash$ netstat Active Internet connections Proto Recv-Q Send-Q Local Address Foreign Address (state) tcp 0 0 aldur.cqu.EDU.AU.login jasper.cqu.EDU.A.1018 ESTABLISHED tcp 0 0 aldur.cqu.EDU.AU.1796 *.* LISTEN tcp 0 0 aldur.cqu.EDU.AU.ftp aldur.cqu.EDU.AU.1794 CLOSE_WAIT tcp 0 0 aldur.cqu.EDU.AU.1794 aldur.cqu.EDU.AU.ftp FIN_WAIT_2 tcp 0 0 aldur.cqu.EDU.AU.1025 *.* LISTEN tcp 0 0 aldur.cqu.EDU.AU.2767 *.* LISTEN tcp 0 0 aldur.cqu.EDU.AU.liste *.* LISTEN tcp 0 0 aldur.cqu.EDU.AU.print *.* LISTEN udp 0 0 localhost.domain *.* udp 0 0 aldur.cqu.EDU.AU.domai *.*
For example:
display statistics every 5 seconds
bash$ netstat 5 input (aen0) output input (Total) output packets errs packets errs colls packets errs packets errs colls 0 273435 275709 0 273435 274 273435 275983 0 273435 0 1 1 0 1 0 1 1 0 1 0 1 1 0 1 0 1 1 0 1 0 1 1 0 1 0 1 1 0 1
Exercise 12.8. Use the ping command to test a connection to a destination machine. Try to get both output formats discussed above (if you are not on a network try pinging the local host).
12.2. People are unable to telnet to the machine hades. The machine is connected to the network, turned on and every other network service is working. What could be wrong?
12.3. What is the purpose of TCP and UDP?
12.4. Explain how the hostname aldur might be resolved to its IP address.
12.5. Explain the relationship between the files /etc/services and /etc/inetd.conf
12.6. What are the four layers used by TCP/IP?
David Jones (author)