CS计算机代考程序代写 FTP database dns algorithm 11 Computer Networks

11 Computer Networks

Networks
• To connect two computers together one requires only a point-point cable with a channel for each direction.
– Such a cable would be attached to an I/O port on each machine supported by device drivers and communication software.
• When there are many machines, however, this can’t work.
• Instead we use a computer or data network which connects the end-systems or hosts with a communications medium or subnet.
– The medium allows any pair of hosts to communicate and supports many simultaneous conversations.
– Connection to a network is through specialised I/O device called a network interface (NIC).
• Networks are often classified by size:
– A local area network (LAN) has a subnet of limited size, both in distance covered and number of hosts. May be owned by an organisation of any type.
– A wide area network (WAN) has a subnet of national or even global size with very large numbers of hosts, usually owned by a telecommunications organisation.
• An inter-network is a group of LANs and WANs which are connected together in such a way that data can cross the whole group.
• The Internet is a global internetwork consisting of tens of millions of networks and billions of users.
Systems and Networks 12. Computer Networks 2

Packets
• For transmission over a network, big data messages are broken into chunks of limited size called protocol data units (PDUs).
– The PDUs used on the Internet are called IP packets.
– The PDUs used on LANs are called frames.
– Different networks have different size limits called their maximum transmission unit (MTU).
– The commonest MTU used on the Internet is 1500 bytes.
• Each PDU consists of a chunk of data (the cargo) preceded by a header containing information to help the network deliver it correctly.
– This information is generically known as PCI (protocol control information).
– Some PDUs also have a trailer of PCI at the end.
– Adding PCI to a chunk of data is called encapsulation.
• Data errors are much more common on networks than inside computers.
– To protect against this a header (or trailer) will usually include some kind of error check, often called a checksum or cyclic redundancy check (CRC).
• If there is an error the PDU is discarded.
– In some situations (e.g. when transferring a file) the sender will be asked to send another copy.
– In other situations re-sending doesn’t make sense (e.g. streaming music or video).
• Error control is one of the major reasons for limiting PDU size. Why?
Systems and Networks 12. Computer Networks 3

Switched and Broadcast Subnets
• In a switched subnet the medium is a collection of specialised devices called (switching) nodes connected by point-point links.
• The most familiar switched networks are wired Ethernets with nodes called Ethernet switches and PDUs called frames.
• Nodes receive PDUs and forward them, either to another switch closer to the destination or to the destination itself.
• Not all networks use a switched subnet. Some use a broadcast medium such that every host sees any message sent. E.g wireless LANs and satellite networks
• Each NIC on each host must have an unambiguous host address.
– Switches use host addresses to direct PDUs to the correct target.
– In broadcast net, addresses are used to accept or reject PDUs
Host
Nodes
Link
Transmitted message goes to all destinations
Broadcast Medium
• The Internet is also a switched structure (like top diagram) but the links can themselves be networks and the switches are internet or IP routers.
• Some of the constituent “links” on the Internet are themselves switched networks while others may be wireless LANs, others satellite networks etc.
– There are still some point-point links between routers (e.g. long-distance trunk lines, undersea cables etc). Systems and Networks 12. Computer Networks 4
Hosts
Hosts only accept message if address recognised

Circuit and Packet Switching
• Ethernet switches and IP routers store data before forwarding but in some switched networks nodes do not store data.
• There are two approaches to delivering data in a switched network, circuit switching and packet switching.
• In circuit switching, a complete path set up through nodes from initiating host to destination. PDUs flow along this path with no storage at nodes. Path is kept alive until one host closes it.
– Propagation delays are predictable and limited
– Switch and link resources are used by a path even when there is no data.
– Originally developed for the telephone network where nodes are called exchanges.
• In packet-switching, PDUs are sent from one node to next (a hop), stored temporarily (buffered) at each and then forwarded on next hop until destination is reached.
• In both cases many high level conversations are carried across each link at same time. This is called multiplexing. Capacity of the link is thus shared.
– In packet-switching packets from different conversations are interleaved.
• Packets are also used in broadcast networks but are sent directly from source to destination.
• The Internet is packet switched. Here the nodes are the IP routers
Systems and Networks 12. Computer Networks 5

Ethernet
• Wired Ethernet is commonest type of switched network (especially in the LANs).
• All Ethernets use the Ethernet protocol which specifies frames with maximum data cargo of 1500
bytes, a header with source and destination Ethernet (aka a MAC) addresses and trailer with a CRC.
• All devices with an Ethernet interface have an Ethernet address per interface.
– These are 48-bits long and are wired into a device at its manufacture.
• Within the Ethernet, switches forward frames towards the correct (local) destination.
– Ethernet addresses do not allow the sending of data beyond the local network. • To send data beyond a local network, it must be placed into an IP packet.
– An IP packet has a header but no trailer
• For IP packet to cross an Ethernet, it must be encapsulated in an Ethernet frame
– The IP packet (including its PCI) is the data inside the frame. The overall layout is:
– Ethernet is not concerned with what is in the frame, only on delivering it across the local network.
– The Ethernet header is transmitted first on the wire and the trailer last
– This is a single hop for the IP packet (across one network)
– If the frame is delivered to a router the packet is extracted from the frame (the Ethernet PCI is discarded); router then decides on next hop (across the next network) on its path.
– If an Ethernet frame is found to have a bad CRC, it is discarded. It is not sent again
– The Ethernet protocol has no means of detecting if a frame is lost.
Ethernet Header
IP Header
IP Data
Ethernet Trailer
Systems and Networks 12. Computer Networks 6

The Communications System
• Networks must deliver useful applications: web, email, file transfer, music streaming,video conferencing etc.
– These may have different communication requirements of reliability, delays etc.
– As with I/O handling in an OS, we do not want user applications handling hardware directly “or reinventing the wheel”.
• The communications system (CS) has much the same role in managing and simplifying access to the network that the OS has with local hardware.
– The CS offers many services to applications, offloading routine tasks (just like an OS).
– CS handles transmission, PDU formation, routing, reliability etc. (all offloaded from apps).
– CS software and hardware is distributed across hosts & nodes, each cooperating with all others.
– A computer’s local portion of an Internet-compatible CS is usually integrated with the OS.
• To simplify implementation the CS is usually constructed as a series of software layers.
– Each layer has its own specific purpose and its own protocols (a protocol specifies PDU structure and
types, PCI layout and role, rules of exchange etc)
– E.g Ethernet is a typical protocol of the lowest layer and IP of the layer above that.
– PDUs of a layer are carried inside those of the layer below (e.g. IP inside Ethernet)
– Using layers means a protocol can be changed (modified or rewritten) at a time without affecting other layers, so long as the services offered are kept the same.
Systems and Networks 12. Computer Networks 7

Layering on the Internet
• Different comms systems have different sets of layers called comms architectures.
• The Internet architecture is used across the Internet and is the most important. It has 4 layers from top to bottom, named as follows.
– Application Layer: this layer supports user applications (e.g HTTP, email protocols etc.)
– Transport Layer: this layer breaks down large messages and implements as much reliability as
required. It’s major protocols are TCP and UDP (see later)
– Network (or IP) Layer (this layer is about IP packets and routing across the Internet)
– Network Access Layer (this layer is about getting data across local networks, e.g. Ethernet)
• Each layer offers services to the layer above, adds to the services of the layer below.
– The application layer offers services to user processes.
– PDUs of each layer are carried inside (encapsulated in) those of the layer below.
• Ethernet and IP are unreliable protocols in that if a frame or IP packet is lost, this is not fixed by either of them.
• However in a layered system a higher level protocol can still be reliable even though it is carried by unreliable IP (and hence Ethernet)
– It numbers and checksums its PDUs and can tell if one has been lost or damaged.
– It can then ask its counterpart at the sender to resend the missing data.
– This is sent in a completely new IP packet
Systems and Networks 12. Computer Networks 8

IP Addresses
• The PDUs sent across the Internet are IP packets and these are switched by the IP routers that join networks together.
• The definition of IP packet PCI and the rules governing it form the Internet Protocol (IP itself). The current version is IPv4 but there is a new version, IPv6, which is increasingly common. Here we assume IPv4.
• All NICs on the Internet have an IP address which is globally unique. In IPv4 this address is 32-bits long and is sometimes called an IP number.
– Traditionally IP addresses are quoted in dotted decimal notation. The 4 bytes, starting from the most significant are turned into their decimal equivalents and separated by dots
– E.g. 82D1F08016 becomes 130.209.240.128 (exercise: turn this into binary!)
– The most significant bits of an IP address (the network number) identifies the network a device is currently attached to, while the lower (host number) identifies the device (NIC) on that network.
– The split between network number and host number depends on the network in question.
• The network number of a destination address is used by IP routers to choose how to forward a packet.
• Each network on the Internet has a pool of IP addresses (a big network needs more so has a longer host number). When a NIC is attached to a new network, it is given one the network’s addresses:
– Thus the IP address of a device is soft , i.e. changes when it is moved from one network to another
• Note that each NIC has an IP address and an Ethernet address.
– Ethernet addresses go into frame headers; IP addresses into packet headers.
– Ethernet addresses allow local delivery (e.g. to a local IP router); IP addresses allow global delivery.
– Ethernet addresses do not change wherever a device goes: they are hard addresses.
Systems and Networks 12. Computer Networks 9

IP Routing
• An IP packet can be up to 64Kbytes but most commonly no more than1.5Kbytes (so it can easily fit in one Ethernet frame) . It usually has a header of 20 bytes (including a source and destination IP address).
• IP packets are sent independently, even if they come from the same data and may follow different routes. The IP layer may therefore deliver transport layer PDUs to the destination transport layer in the wrong order. The transport layer can fix this.
• IP packets cross the Internet by hopping from one router to the next across links.
– The IP layer uses the network access layer to get packets across links between neighbouring routers.
– Although up to now we have assumed this layer will be wired Ethernet, there are other possibilities (e.g wireless LAN, point-point links).
• IP packets hop from source host to a nearby IP router, then between IP routers until the destination is reached.
• At each hop the IP packet crosses a different network.
• In order to cross a network an IP packet must be placed inside one of that network’s PDUs and then sent locally to the next router or the final host.
– E.g On an Ethernet, each IP packet is inserted (as data) into an Ethernet frame
• IP routers use the destination IP address to decide on next hop by looking up a local forwarding table computed by a
routing algorithm.
– While the routing decisions are made, packets are temporarily held in router memory and then forwarded
– Queues for outgoing links form at nodes and so delays can be unpredictable (worse when network is busy).
– Packets from the same message are reassembled at the destination by the transport layer.
Systems and Networks 12. Computer Networks 10

The Transport Layer
• The IP layer can deliver chunks of data (but unreliably), to any host on the Internet.
• The layer above it, the transport layer breaks down big blocks of data at the source
(fragmentation) and reassembles them at the destination.
• To this, once a chunk has been formed, the transport layer uses a transport protocol and
adds a header of its own to form a PDU called a segment.
• The segment is then passed to the IP layer where it is encapsulated in an IP packet.
• Thus a more detailed version of the diagram on slide 6 is as follows:
• There are two important transport layer protocols: Transmission Control Protocol (TCP) and User Datagram Protocol (UDP).
– TCP is used by applications that want reliable transport (e.g to transfer a file or web page) where all bits are accurately transferred.
– UDP is used where re-transmission isn’t useful
Ethernet Header
IP Header
Transport Header
Transport Data
Ethernet Trailer
Systems and Networks 12. Computer Networks 11

TCP and UDP
• TCP adds reliable capabilities to basic IP packet transfer as follows:
– TCP communications is based on connections between two application processes that stay in existence for a period of time.
– Special control segments are used to setup and close connections.
– TCP numbers all segments on any connection so it can tell if one is lost (or duplicated).
– It reorders segments on a connection if IP delivers them in the wrong order.
– It checksums all data and verifies each chunk on arrival.
– It acknowledges segments received correctly.
– Acknowledgements are also control segments and are returned in IP packets.
– Segments not acknowledged are automatically resent.
• UDP has no concept of a connection.
– There is no numbering, no reordering and no resending.
– Useful where data correctness is less important than timeliness (e.g. short interactions with databases; streaming, Voice over IP telephony etc.).
• However an application can add its own connection and other features to UDP with yet another protocol (application level), just as TCP adds these features to IP
– A reason to do this would be if the application wasn’t happy with how TCP does these things.
Systems and Networks 12. Computer Networks 12

Transport Ports
• IP only identifies the host to which data will be delivered but in a multitasking system communication is conducted by individual processes with others.
• Support for multiple processes on a single host engaging using the comms system for different conversations through a single network interface is a fundamental feature of the transport layer
• TCP and UDP identify the target application process on the target host using transport ports.
– Unlike hardware I/O ports these ports are software structures.
• There are 65536 alternative TCP ports (and 65536 UDP ports) on each host to which applications can attach.
• Each transport port has a 16-bit sub-addresses called a port number to do this. UDP and TCP headers each contain source and destination port numbers.
– Whenever an application wants to use the comms system to communicate it is allocated a port number by the transport layer.
– To specify a target process elsewhere on the Internet it must know the IP address and the port number that process is using.
• On the Internet, communications is often asymmetrical between a client and a server.
– For example in accessing a web page the client is a browser and the server holds the page.
• Certain port numbers are reserved for common application servers to help clients find them. These are said to be well-known ports and most are below 1000.
– E.g Port 80 is reserved for web servers.
• A client that wishes to contact a server can pick any free port in the range up to 65535.
Systems and Networks 12. Computer Networks 13

Application Layer
• The transport layer offers applications a service to send messages of any size across the Internet.
– The transport layer will accept a buffer of data and divide it into chunks which it sends using the services of the IP layer. Each segment forms the data of a single IP packet.
– A TCP connection is an association between ports on 2 hosts. Segments stream in both directions and transport is reliable.
– UDP offers no connections or reliability but still breaks up the data buffer and supports ports.
• Applications can access the transport layer directly but there are some common higher level protocols that the comms system can support to prevent “reinvention of the wheel”.
• This is the role of the application layer (AL) layer which offers services to user applications with specialised protocols like HTTP for web access, FTP for file transfer, SMTP for email etc.
• Users can write programs to implement new applications which use these protocols rather than reimplementing them and using the transport layer directly.
• Most application layer protocols work on a client-server model.
• Client-server is asymmetrical. The Internet also supports symmetrical peer-peer communication.
– This is like client-client comms.
– Commonly used for file distribution (e.g. BitTorrent)
– Peers can’t use well-known ports so other ways are needed to let them find each other.
Systems and Networks 12. Computer Networks 14

Names and Addresses
• To specify where to find a target process on the Internet we need the IP address of its host and the port number it is connected to.
– If a process isn’t attached to a port on its host it can’t communicate.
– There’s no need to say whether TCP or UDP will be used. Receiving host can work that out.
– The dotted decimal notation is extended to represent such a combination by writing e.g. 130.209.240.128:80
• The Internet is administratively divided into naming domains which can be subdomains or child domains of larger parent domains. These domains are hierarchically structured and are named according to the domain naming system (DNS).
• A DNS name looks like this: dcs.gla.ac.uk where the master domain is uk; ac is the academic subdomain of uk, gla is the GU subdomain of ac; and dcs is the SoCS subdomain of gla.
• Each host is also given a human-readable (text name) and then has a fully qualified domain name (FQDN) written as hostname.domain-name
– E.g the host with name hawaii has DNS name hawaii.dcs.gla.ac.uk
• Users generally work with DNS names but the comms system needs IP numbers.
• When a name is input to an application it can convert or resolve it to an IP number by using an Internet service called DNS lookup. This is supported by interlinked DNS servers positioned in each naming domain, each holding a database of mappings of local names to IP addresses. These are accessed via an application layer DNS service with suitable calls that processes can use.
– An application wishing to resolve a name uses the comms system to submit a DNS query to its local domain DNS server. This is usually a short request-reply interaction that uses UDP.
– If the local server can resolve the query, it replies directly to the client; if not it passes it up to the DNS server in its parent domain and so on until it gets an answer.
• When using an FQDN to contact a remote host a port can be added (e.g. hawaii.dcs.gla.ac.uk:80) but often the application will assume a default port, depending on its nature (e.g. a browser will assume port 80 unless explicitly over-ridden).
Systems and Networks 12. Computer Networks 15