Lab #9

profilefadoo
LabCH19.pdf

© Dmitriy Shironosov/ShutterStock, Inc.

LABORATORY

■■ Study■how■networks■route■packets■to■various■destination■hosts. ■■ Learn■how■networks■ensure■reliable■delivery.

■Software■needed: ■ 1)■ Apps■from■the■Lab■Manual■website: a)■ TCP/IP■(TCP■IP.jar) b)■ Network■Routing■(Network■Routing.jar)

19

OBJECTIVES

REFERENCES

Networking

© Jones & Bartlett Learning, LLC NOT FOR SALE OR DISTRIBUTION

208 | Laboratory 19

BACKGROUND This lab explores the basic concepts of networking, elaborating on two specific aspects of computer networking. Review these topics from your textbook, lecture notes, or online resources:

■ Computer networks, packet switching, routers, network topologies: ring, star ■ Network protocols, TCP/IP, IP addresses

ACTIVITY ❯ Part 1

Though we tend to take networks for granted (except when they’re down!), they are surprisingly complicated. Setting one up involves much more than just running a wire between two computers. Not only must the machines agree on a whole series of protocols and identifying conventions before any communication can happen, but the wire itself is subject to seemingly malevolent forces working to corrupt the fragile data traveling through it!

The TCP/IP protocol suite is a whole system of software, protocols, and management decisions. At its heart are several protocols that break messages into packets and send them from source computers to destination computers. In this activity, we will see a simplified form of TCP (Transmission Control Protocol) as it reliably sends a message to a destination computer.

Start the TCP/IP app. This app simulates a reliable connection, which means that a big message is correctly sent in its entirety from source to destination. If anything goes wrong, the software makes heroic attempts to recover the information. While it is impossible to absolutely guarantee that the message will arrive intact, the networking software can make it very likely that it will be delivered correctly.

In this app, there are only two hosts, or nodes, numbered 0 and 1. Host 0 is a computer that is trying to send your message to host 1. You will play the role of one of those malevolent forces of nature, damaging and even destroying data packets. Will the software recover the data properly and save the day? Let’s hope so!

© Jones & Bartlett Learning, LLC NOT FOR SALE OR DISTRIBUTION

Networking | 209

Click on the Example button, which inserts a message into the Your message text area. Click Run, and then Send a message. Host 0 moves the message to the To be sent area and proceeds to “packetize” it into 10-character packets. Here you can see the first 10 characters—A very lon (the two spaces are part of the count)—moving slowly in a packet across the wire.

What exactly does the DAT 1 0 144 in the packet mean? This is the packet’s header and contains crucial information. First, DAT identifies the type of packet being sent. There are three types of packets: DAT for “data,” ACK for “acknowledgment,” and NAK for “negative acknowledgment.” We will talk more about these in a minute.

Next in the header comes the destination address, which is 1. Though this seems a bit silly in a two-node network, bigger networks obviously require a destination address. The number 0, which appears next, is the sequence number. As messages are broken into packets, each packet is assigned a number: 0 in the first packet, 1 in the second packet, and so forth. If any packet were to arrive out of order, the destination computer could examine these sequence numbers and reassemble the message in the correct order. After all, if part of the message were scrambled, the meaning could change completely. (“You owe us $1000” means something quite different than “You owe us 000$1.”)

Finally, 144 is the checksum, which alerts the destination computer that the packet was damaged. This app uses an extremely simple checksum algorithm, merely taking the ASCII value of each character in the packet, adding these together, and performing modulo 256 (keep the remainder after dividing by 256) so that the checksum is always between 0 and 255, inclusive. This checksum algorithm was actually used in some early protocols, but it is prone to serious problems. Today more advanced ones are used, most notably the cyclic redundancy code. We’d tell you how it works, but that would change our lab into an advanced mathematics class!

© Jones & Bartlett Learning, LLC NOT FOR SALE OR DISTRIBUTION

210 | Laboratory 19

After the first packet arrives at host 1, it sends back an ACK packet to acknowledge that the data arrived successfully. The type of the packet is ACK; the destination is 0 (host 0), and the sequence number that it sends back is 1, meaning that it expects host 0 to send it a packet with the sequence number 1 next. Finally, there is no real data in an ACK packet, so the checksum is 0. This explains why the header is ACK 0 1 0.

Networks are always contending with the forces of chaos that can corrupt the data being sent: noise on the line, equipment failures, and other sorts of mayhem. So let’s wreak havoc on our poor little network and see what happens. Select Damage packets that are touched from the pull-down menu. You can do this while the app is sending packets.

As a packet comes sliding along the wire, click on it. This should somehow corrupt the data. For example, the s below turned into the Japanese yen symbol!

What does host 1 do when this packet arrives? How does it even know that the packet is damaged? It recomputes the checksum using the data it receives, and it matches the checksum in the header with the recomputed one. They don’t match this time, so host 1 sends host 0 a NAK packet with the same sequence number. This tells host 0 that the packet was corrupted and needs to be resent.

When host 0 gets the NAK, it resends the packet. Various status messages appear in the large text area at the bottom of the app, explaining what is going on. © Jones & Bartlett Learning, LLC

NOT FOR SALE OR DISTRIBUTION

Networking | 211

Now let’s experiment with more ways to make life difficult. Select Delete packets that are touched from the pull-down menu. When another packet comes along, click on it with your mouse and it should disappear.

Packets that do not even arrive pose a bigger challenge than ones that are damaged. How does host 1 ever know that a packet is missing? Actually, it doesn’t, but host 0 is looking for an ACK or NAK packet in response to each DAT packet that it sends. So if one never arrives, host 0 assumes the packet is lost, and it sends the packet again.

The host won’t wait forever to receive the ACK or NAK packet. It sets a timer on each packet and if nothing arrives before the timer counts down to 0, it times out and resends the packet.

Of course, all of this assumes that everything, including the hosts and the software, is working correctly to catch any errors that may occur. As you can imagine, there are about a million things that can happen to foul up this pretty picture, and we will explore some of them in the exercise. But suppose the packets are temporarily held up somehow. They aren’t lost, but the timer goes off anyway. What does host 1 do when it gets a duplicate packet? And does it send another ACK? Yikes! This networking is rapidly spinning out of control! Scientists who designed the Internet had to think about all these possibilities and decide how to handle them. Fortunately, they found reliable solutions so today we can sit in the comfort of our homes and travel the entire world with our fingertips.

© Jones & Bartlett Learning, LLC NOT FOR SALE OR DISTRIBUTION

212 | Laboratory 19

❯ Part 2 The second app simulates how computers route packets to their final destinations. Routing is enormously complicated because there are so many variables. We will see some of this unexpected complexity as we watch this app.

Start the Network Routing app. Let’s go for the most complex example right away. Select Example 5 from the pull-down menu.

Each blue disk represents a node, or a computer in the network. The lines between nodes are telecommunication lines, perhaps telephone wires or Ethernet cables. Each node has its own IP address, a 32-bit number that is always represented as four octets separated by dots.

In this app, the lines are “full duplex,” which means that packets can flow in either direction between the two connected hosts. This isn’t always the case in the real world, but many lines are full duplex.

You can move the nodes around on the screen by dragging them. Their attached lines move with them. You can even add new nodes. To make a new node, double-click on any open space and the app places a blue dot there with the unusable address of 0.0.0.0. You are expected to change that right away!

To change the characteristics of a node, double-click on the node and a new window appears:

© Jones & Bartlett Learning, LLC NOT FOR SALE OR DISTRIBUTION

Networking | 213

This window displays status information in the right column, showing packets that this node has received and some statistics. At the top are three fields that you can change, the first being the IP address of the node. You can also customize the message you want to send, and you can add the address of the recipient. If the Destination node field is blank, no messages will be sent by this node. More than one node can send and receive messages at the same time when this app runs.

The connection and routing tables below these fields are the focus of this app’s study. The connection table lists the IP addresses of nodes that directly connect to this node. Most networks assume, quite logically, that two nodes can find each other and send packets if they are directly connected. It is when nodes are not directly connected to their destinations that things get interesting!

The purpose of the routing table is to tell the node what to do when it is not directly connected to the destination node. For example, if node X wants to send a packet to node Y, which is not directly connected, it must send the packet to node Z instead, and node Z then assumes the responsibility of getting it to node Y. Hopefully, Z will not mistakenly send it back to X! If so, a routing loop would occur and the packet would travel the wires endlessly, like the Flying Dutchman. This prospect so worried early developers of TCP/IP that they put a timer on each packet so that it would just evaporate after going through too many nodes.

The routing table has two columns. The first column lists the destination, and the second lists the next hop. The next hop must be a directly connected node. There are also a number of special cases that can shorten routing tables. If the word “DEFAULT” appears in the routing table, then the node merely sends packets to the first node in the directly connected table. This works nicely for leaf nodes, which connect to only one other node, but won’t work for a complex topology, or the configuration of the network.

Most of the time, nodes with two or more connections need to explicitly list all distant nodes, along with the next hop. However, this quickly gets tedious and requires too much work to update, as many new nodes are added. One possible alternative is to list some of the destination/next hop pairs, and leave the others unspecified. The Network Routing app lets you do this by putting an asterisk in the destination column, as shown below for the ring network (Example 3):

© Jones & Bartlett Learning, LLC NOT FOR SALE OR DISTRIBUTION

214 | Laboratory 19

Finally, what can we do if the network is under attack and the routing table is now obsolete due to out-of-commission routers? Early TCP/IP developers worried about this, too, and came up with the “hot potato algorithm.” This app allows you to type “HOT POTATO” in the routing table. Nothing else is needed. Hot potato works this way: When a packet comes in, the node makes a random guess as to which directly connected node will get the packet to its final destination, and it sends it to that next hop. This may not work and it may result in routing loops, but it just might do the trick, too. Imagine a bunch of people on the beach around a campfire passing around a hot sweet potato wrapped in aluminum foil. As they energetically toss it to one another, there is a good chance that it will end up in the hands (or lap) of someone who wants to eat it!

There are many other routing algorithms that were designed with various emergencies or unusual conditions in mind. One such algorithm is called “flooding,” in which every packet is copied to every outgoing wire, not just to one random one, as in hot potato.

What happens in the Internet, which is built on TCP/IP? What routing algorithms are used? The local area networks that attach to the Internet often use specialized routing algorithms. For example, Ethernet is like a telephone where everyone can hear everyone else’s calls. So when the phone rings, or a new packet comes in, each computer listens to the beginning of the packet to see if it is meant for them.

The backbone network that manages the long-distance, high-volume traffic on the Internet uses several dynamic routing protocols. In such systems, nodes change their routing tables from time to time as they are forwarding packets. Unlike the “Network Routing” app, in which you, the network administrator, decide once and for all what the routing table for node X is, dynamic routing systems measure the characteristics of the traffic and the attached lines, and adjust their routing tables so that packets will flow most efficiently through the entire system. This sounds daunting, and it is, kind of like continuously adjusting the timing on all traffic lights so that cars on the streets get to their destinations in the least amount of time. While the system isn’t perfect, it’s worked on the Internet for over 40 years.

© Jones & Bartlett Learning, LLC NOT FOR SALE OR DISTRIBUTION