CMPE 401 - Computer Interfacing

Assignment #3 Solutions

Due: In the CMPE 401 assignment box at 15:45 on Monday, Nov. 3, 2008


  1. In your own words, briefly explain what is meant by "busy waiting" and "interrupt-driven" synchronization of data transfers. What are the major advantages and disadvantages of each method compared to one another?

    [4 marks] "Busy waiting" is the synchronization technique where a CPU repeatedly checks the status of some device (e.g., a bit in a status register) to determine whether or not an event has occured. If the event has not yet occurred, then the CPU simply checks the status again. If the event is indeed found to have occurred, then the CPU exits the busy wait software loop and proceeds to the next step of processing.

    [4 marks] "Interrupt-driven synchronization" is the technique where the CPU continues to execute normally scheduled code and relies on a hardware-based interrupt handling mechanism (provided today in virtually all CPUs) to react to the activation of an interrupt signal whenever that signal occurs. Interrupt handling involves saving the state of the currently running program (so that it can be restarted later) and then the causing the CPU to begin executing the appropriate Interrupt Service Routine.

    [4 marks] Advantages of busy waiting: It is a simple and purely software-based method, and no special hardware is required. Busy waiting software is generally easy to design and debug. It may be an efficient technique too if the CPU has nothing else better to do before the desired status event occurs. Disadvantages of busy waiting: While in the busy wait loop the CPU is prevented from doing any other work. The CPU will get stuck or "hung" inside the loop if the desired event never occurs and no timeout mechanism is provided.

    [4 marks] Advantages of interrupt-driven synchronization: This method provides very fast response to events and is efficient in its use of CPU time since the CPU does not waste any time servicing the event before the event occurs. The ISR code is available in one place for all other software in the system to use (via interrupts). This last point increases code modularity and simplifies code design and maintenance. Disadvantages of interrupt-driven synchronization: Interrupt-driven code can be tricky to debug since interrupt handling occurs at a time that is difficult to predict or in complex scenarios that may be difficult to recreate.

  2. On slide 7-13 of the lecture notes, the transport layer peer entities in the two systems are shown interacting directly using the Layer 4 Protocol. In contrast, the network layer entities in the two systems are shown interacting with an intermediate box labelled "Communication Network" according to the Layer 3 protocol. What is this diagram illustrating by showing the Layers 3 and 4 in these different ways?

    [8 marks] Layer 4 protocols, such as the TCP and UDP transport protocols, provide end-to-end mechanisms such as flow control, error detection and packet retransmission. All processing occurs in the layer 4 entities at the two end nodes of a communication path; no layer 4 processing occurs in the tandem nodes that lie in between the two end nodes. This is why the layer 4 entities are shown in slide 7-13 as if they were linked together directly.

    [8 marks] Layer 3 protocols, such as the IP internetworking protocol, provide node-to-node control of packets travelling through the underlying physical network(s). The Layer 3 entity in each node along a packet's route through the network must process the Layer 3 overhead of the packet (header and/or trailer) to determine whether or not the packet has arrived at the destination node, and if not, to determine what the next immediate node should be along the packet's route. This is indicated in slide 7-3 by showing the end nodes connected to the "Communication Network", which includes all of the nodes in the network apart from the end nodes.

  3. In your own words, briefly explain how routers and bridges are used to join up subnetworks into larger data networks. Be sure to clearly explain the difference between routers and bridges.

    Both routers and bridges are used to join up smaller networks as subnetworks of larger networks. They differ in the amount of processing that they are capable of performing on the data packets that they handle.

    [8 marks] "Bridges" are used to join two or more subnetworks that have the same Layer 1, 2 and 3 protocols (e.g. Ethernet to Ethernet). Bridges often have the ability to perform filtering operations on the packet, deciding whether or not to forward a packet between the subnetworks depending on the packet's source and/or destination addresses. This filtering capability makes bridges a useful tool for containing local traffic within a subnetwork, or for keeping unnecessary traffic outside of a subnetwork.

    [8 marks] "Routers" are used to join up two subnetworks that might differ in their Level 3 protocol (e.g. Ethernet to FDDI optical ring). A router typically has the ability to reformat packets to accommodate packet structure differences in the subnetworks. Routers have the ability examine the addresses in the IP packet header and then make decisions about which router the packet should be sent to next on its journey to the destination node.

  4. Hubs are often preferred to connect a small number of nodes together into a subnet. Separate 10BASE-T twisted pair cables are used to connect each node to the hub. This is a different topology from the original Ethernet standard, which envisaged all nodes in a subnet being connected together over a shared 10BASE5 coaxial cable. Why is the hubbed or star topology generally preferred over the original Ethernet topology?

    [8 marks] The hubbed subnetwork topology is usually preferred over the original shared cable topology for two main reasons: (1) twisted pair cabling and the associated cable connectors are cheaper than coaxial cable and its connectors; (2) the hubbed topology is more modular in that nodes can be added or deleted without requiring changes to the wiring or electrical termination associated with any other nodes.

  5. Briefly describe the differences between the User Datagram Protocol (UDP) and the Transmission Control Protocol (TCP). Using resources on the Internet or other references, determine four application-level protocols that are most commonly run over UDP. In each case, briefly justify why each of those four upper layer protocols uses UDP as opposed to TCP.

    [6 marks] The "User Datagram Protocol" and "Transmission Control Protocol" are both Layer 4 transport protocols that operate to control the end-to-end transfer of data packets over a data network. UDP is a connectionless protocol that does not attempt to define a lasting route between the two end nodes. UDP adds a simple header to the application payload, including a source port number, a destination port number, a segment (UDP packet) length, and an optional segment checksum. If the checksum is provided, then most errors in the segment will be detected. No recovery or packet transmission mechanism is provided by UPD: any errors will cause the entire segment to be discarded without further action. No mechanism is provided to ensure that the segments are received at the destination node in the same order that they were sent from the source node.

    [6 marks] TCP is a connection-oriented protocol that ensures the reliable delivery of a stream of ordered bytes travelling in both directions between the source and destination nodes. To be able to provide this service, TCP adds a longer header to the application payload than does UDP. Like the UDP header, the TCP header includes source and destination port numbers. A segment length is not provided (this length could be obtained by subtracting the IP header length from the total IP datagram length). A mandatory segment checksum is provided to detect most errors in the segment, including the enclosed application payload. A sequence number and an acknowledgement number are provided to keep track of the successful transport of bytes across the connection from end-to-end. The sequence number allows a receiving node to determine if the received bytes are in the correct order and that no bytes were lost in transmission. The acknowledgement number provides feedback to a transmitting node that allows it to determine now many bytes have made it successfully to the other end, and thus allows the transmitting node to decide whether or not bytes need to be retransmitted. Various other fields are provided in the TCP header to support other functions (e.g. a maximum segment length field, a signal to end a connection, a signal to reset a connection, etc.)

    [8 marks] Some important application protocols that use UDP include:

  6. In a client-server interaction, the port numbers on the servers are usually standardized (e.g. HTTP uses port 80 on the server) whereas the port numbers on the clients can be assigned more freely to any unused port numbers. Briefly explain why the server port numbers are standardized in this way.

    [8 marks] The port numbers for standard services on a server node should be standardized to simplify the process of setting up a call. If a nonstandard port number is used on the client, then all potential clients will need to be informed of the port number to use. The client port number for a connection is less critical since it becomes apparent to the server as soon as it starts to receive messages from the client (n.b., the client's port number is included in the TCP header). The client port number can be selected as desired for each call.

  7. Some application-level protocols (e.g. FTP) use separate TCP connections to communicate data information and control/status information, whereas other protocols (e.g. TELNET) use a single channel for both data and control/status information. In your own words briefly describe important advantages and disadvantages of these two methods?

    [8 marks] Advantages of using one TCP connection:

    [8 marks] Disadvantages of using one TCP connection: