VIDYA PRATISHTHAN’S COLLEGE OF ENGINEERING (Affiliated to University of Pune, Approved by AICTE New Delhi & Govt. of Maharashtra) Vidyanagari, Baramati Dist. Pune Advance Computer Network Laboratory Lab Manual Department of Information Technology B.E (IT) Prepared By: Manik.K.Chavan (M.Tech Computer Engineering) Assistant Professor Information Technology Department Experiment: 01 NETWORK SOCKET PROGRAMMING AIM: - Implementing Client /Server model using Stream Socket (Connection oriented Socket). THEORY: Sockets provide the communication mechanism between two computers using TCP. A client program creates a socket on its end of the communication and attempts to connect that socket to a server.When the connection is made, the server creates a socket object on its end of the communication. The client and server can now communicate by writing to and reading from the socket.The java.net.Socket class represents a socket, and the java.net.ServerSocket class provides a mechanism for the server program to listen for clients and establish connections with them. Types of Internet Sockets: There are two types of Internet socket: 1) Stream socket : stream sockets are also called connection oriented sockets. 2) Datagram socket : Datagram sockets are called connectionless sockets. Stream sockets are reliable two-way connected communication streams. If you output two items into the socket in the order "1, 2", they will arrive in the order "1, 2" at the opposite end. They will also be error free. Telnet application and HTTP protocol uses stream sockets. Stream sockets use a protocol called "The Transmission Control Protocol"(TCP). TCP makes sure your data arrives sequentially and error-free. Datagram sockets are also called connectionless sockets. They are unreliable. If you send a datagram, it may arrive arrive out of order. A simple Server Program in Java The steps for creating a simple server program are: 1. Open the Server Socket: ServerSocket server = new ServerSocket( PORT ); 2. Wait for the Client Request: Socket client = server.accept(); 3. Create I/O streams for communicating to the client DataInputStream is = new DataInputStream(client.getInputStream()); DataOutputStream os = new DataOutputStream(client.getOutputStream()); 4. Perform communication with client Receive from client: String line = is.readLine(); Send to client: os.writeBytes("Hello\n"); 5. Close socket: client.close(); A simple Client Program in Java The steps for creating a simple client program are: 1. Create a Socket Object: Socket client = new Socket(server, port_id); 2. Create I/O streams for communicating with the server. is = new DataInputStream(client.getInputStream()); os = new DataOutputStream(client.getOutputStream()); 3. Perform I/O or communication with the server: Receive data from the server: String line = is.readLine(); Send data to the server: os.writeBytes("Hello\n"); 4. Close the socket when done: client.close(); Experiment: 2 NETWORK SOCKET PROGRAMMING AIM: Implementing Client /Server model using Datagram socket (connectionless Sockets). THEORY: Datagram packets are used to implement a connectionless packet delivery service supported by the UDP protocol. Each message is transferred from source machine to destination based on information contained within that packet. That means, each packet needs to have destination address and each packet might be routed differently, and might arrive in any order. Packet delivery is not guaranteed. Some popular applications are built using UDP: DNS, NFS and SNMP for example. Unlike Stream sockets, the client does not establish a connection with server. Instead, the client just sends a datagram to the server using the sendto function, which requires the address of the destination (the server) as a parameter. Similarly the server does not accept a connection from a client. Instead the server just calls the Recvfrom function, which waits until data arrives from some client. Recvfrom returns the protocol address of the client, along with the datagram, so the server can send a response to the correct client. ELEMENTARY OF DATAGRAM (UDP) SOCKET: Java supports datagram communication through the following classes: • DatagramPacket • DatagramSocket The class DatagramPacket contains several constructors that can be used for creating packet object. One of them is: DatagramPacket(byte[] buf, int length, InetAddress address,int port); This constructor is used for creating a datagram packet for sending packets of length length to the specified port number on the specified host. The message to be transmitted is indicated in the first argument. The key methods of DatagramPacket class are: byte[] getData() Returns the data buffer. int getLength() Returns the length of the data to be sent or the length of the data received. void setData(byte[] buf) Sets the data buffer for this packet. void setLength(int length) Sets the length for this packet. The class DatagramSocket supports various methods that can be used for transmitting or receiving data a datagram over the network. The two key methods are: void send(DatagramPacket p) Sends a datagram packet from this socket. void receive(DatagramPacket p) Receives a datagram packet from this socket. Experiment: 3 ATM Networks AIM: find the technical specifications of ATM switch, and then compare the ATM technology or service with the technology such as Ethernet. THEORY: 1) What is ATM? Asynchronous Transfer Mode (ATM) is a technology designed for the high-speed transfer of voice, video, and data through public and private networks using cell relay technology. ATM is an International Telecommunication Union Telecommunication Standardization Sector (ITU-T) standard. Ongoing work on ATM standards is being done primarily by the ATM Forum, which was jointly founded by Cisco Systems, NET/ADAPTIVE, Northern Telecom, and Sprint in 1991. A cell switching and multiplexing technology, ATM combines the benefits of circuit switching (constant transmission delay, guaranteed capacity) with those of packet switching (flexibility, efficiency for intermittent traffic). To achieve these benefits, ATM uses the following features: Fixed-size cells, permitting more efficient switching in hardware than is possible with variable-length packets Connection-oriented service, permitting routing of cells through the ATM network over virtual connections, sometimes called virtual circuits, using simple connection identifiers Asynchronous multiplexing, permitting efficient use of bandwidth and interleaving of data of varying priority and size The combination of these features allows ATM to provide different categories of service for different data requirements and to establish a service contract at the time a connection is set up. This means that a virtual connection of a given service category can be guaranteed a certain bandwidth, as well as other traffic parameters, for the life of the connection. 1.1 ATM Basics To understand how ATM can be used, it is important to have a knowledge of how ATM packages and transfers information. The following sections provide brief descriptions of the format of ATM information transfer and the mechanisms on which ATM networking is based. 1.2 ATM Cell Basic Format The basic unit of information used by ATM is a fixed-size cell consisting of 53 octets, or bytes. The first 5 bytes contain header information, such as the connection identifier, while the remaining 48 bytes contain the data, or payload (see Figure 1-1). Because the ATM switch does not have to detect the size of a unit of data, switching can be performed efficiently. The small size of the cell also makes it well suited for the transfer of real-time data, such as voice and video. Such traffic is intolerant of delays resulting from having to wait for large data packets to be loaded and forwarded. Figure 1.1 ATM Cell Basic Format The ATM standards groups have defined two header formats. The User-Network Interface (UNI) header format is defined by the UNI specification, and the Network-Node Interface (NNI) header format is defined by the NNI specification. The UNI specification defines communications between ATM endpoints (such as workstations and routers) and ATM switches in private ATM networks. The format of the UNI cell header is shown in Figure B-1. Figure B-1: UNI Header Format The UNI header consists of the following fields: GFC—4 bits of generic flow control that can be used to provide local functions, such as identifying multiple stations that share a single ATM interface. The GFC field is typically not used and is set to a default value. VPI—8 bits of virtual path identifier, which is used, in conjunction with the VCI, to identify the next destination of a cell as it passes through a series of ATM switches on its way to its destination. VCI—16 bits of virtual channel identifier, which is used, in conjunction with the VPI, to identify the next destination of a cell as it passes through a series of ATM switches on its way to its destination. PT—3 bits of payload type. The first bit indicates whether the cell contains user data or control data. If the cell contains user data, the second bit indicates congestion, and the third bit indicates whether the cell is the last in a series of cells that represent a single AAL5 frame. CLP—1 bit of congestion loss priority, which indicates whether the cell should be discarded if it encounters extreme congestion as it moves through the network. HEC—8 bits of header error control, which is a checksum calculated only on the header itself. The NNI specification defines communications between ATM switches. The format of the NNI header is shown in Figure B-2. Figure B-2: NNI Header Format The GFC field is not present in the format of the NNI header. Instead, the VPI field occupies the first 12 bits, which allows ATM switches to assign larger VPI values. With that exception, the format of the NNI header is identical to the format of the UNI header. 2) 3) 4) 5) ATM architecture ATM layers IP over ATM Comparison of ATM technology with Ethernet technology Experiment No. 4 Wireless Networks AIM: - Capture and study the wireless frames that are exchanged between wireless host and the access point. Theory: 1) Introduction What is wireless networking? How does it work? A wireless network uses radio signals or microwaves to broadcast data and information. Rather than being transmitted through traditional coaxial, CAT5 Ethernet or other standard wired methods, the data is beamed out over the airwaves. Wireless networks offer advantages for some. Users with personal digital assistant (PDA) handhelds such as Palm Pilots, wifi enabled cell phones, or users with laptops can use wireless technology to allow them the convenience to move about while maintaining their network connectivity. Another pro is the ability for users to network desktop computers at various locations without having to deal with the hassle or expense of running a wired connection to that spot. There are some cons as well. First, most wired networks operate at 100mbps, and many organizations have upgraded to the newer standard of 1gbps. In contrast, a large percentage of wireless networks operate at 11mbps, roughly equivalent to the old wired speed of 10mbps. Most wireless network equipment available today is compatible with both 802.11b and the faster 802.11g which operates at speeds up to 54mbps. There is also a new, emerging wireless network standard, 802.11n, which theoretically increases both the speed and the range of the wireless network. Wireless network speeds are affected by obstructions such as walls and floors. Most wireless network equipment, for consumers in particular, also operates in the 2.4Ghz frequency range. This is the same range as other household devices such as cordless phones, baby monitors, etc. The interference from these devices, as well as microwave ovens and other electrical interference can greatly impact the range, speed and quality of your wireless network. 2) 3) 4) 5) 6) 7) 8) Architecture 802.11 Frame format Wireless network protocols. Bluetooth (802.15.1), Wi-Fi (802.11), WiMAX (802.16) Screenshots of captured frames using CommView Report for Lab X-1: Wireless Networks Part I 1 Management frame captured: 2 Control frame captured: 3 Data frame captured: 4 Frame numbers of association frames: 5 Frame numbers of beacon frames: 6 Frame numbers of probe frames: 7 Frame numbers of RTS frames: 8 Frame numbers of CTS frames: 9 Frame numbers of ACK frames: Part II 1 a. Hexadecimal value of FC: Significance of difference bits: b. Duration of the frame: c. Number of addresses in the frame: Which entity does each address define? d. Hexadecimal value of FCS field: 2 Are answers to question 1 verified by the information in the detail pane lane? Part III 1 a. Hexadecimal value of FC: Significance of difference bits: b. Duration of the frame: c. Number of addresses in the frame: Which entity does each address define? d. Hexadecimal value of FCS field: 5 Are answers to question 1 verified by the information in the detail pane lane? Part IV 1 a. Hexadecimal value of FC: Significance of difference bits: b. Duration of the frame: c. Number of addresses in the frame: Which entity does each address define? d. Hexadecimal value of FCS field: 5 Are answers to question 1 verified by the information in the detail pane lane? 9) Advantages and disadvantages of wireless networks Experiment NO. 05 BGP Configuration AIM: - The aim of this exercise is to configure BGP among the routers (Routers R1–R3). Theory: 1) Introduction BGP (Border Gateway Protocol) is the core routing protocol of the Internet. It is described as a path vector protocol as BGP does not use traditional IGP (OSPF, EIGRP, RIP) metrics, but makes routing decisions based on path, network policies and/or rule sets. It maintains a table of IP networks or 'prefixes' which designate network reachability among autonomous systems (AS). 2) Write the appropriate interfaces and the addresses are to be assigned like in the table below: Interface FE0/3/0 FE0/3/1 Router 1 Router 2 Router 3 192.168.10.254/25 192.168.20.254/25 192.168.30.254/25 192.168.11.254/25 192.168.21.254/25 192.168.31.254/25 Laboratory Tasks 1) Configure each router interface with the appropriate IP address. 2) Configure BGP and establish sessions with the appropriate peers. 3) Enter the appropriate commands so that BGP advertises all directly connected networks. 4) Ensure that your router is learning routes from your peers. 5) Ensure that other routers are learning routes that are being advertised from your router. 6) Connect your workstation into your switch and configure it with an appropriate IP address. Verify that you can ping another group's workstation (or at least one of their "internal" router interfaces). 7) Try using traceroute and see if you can discover what path your packets are taking between workstations. 8) Record your router's running configuration - you'll need this for the next lab! You might also want to save the current configuration as the startup configuration... 9) Try to identify the AS Path that your router uses for each Autonomous System. 3) Commands : (explanation of only used commands with syntax) Example: show ip route show ip bgp show ip bgp summary show ip bgp neighbor show ip bgp paths show ip bgp [network address] 4) Screenshots : Sample BGP network 5) Router WAN1 configuration : interface ip address ! router bgp no neighbor 156.12.1.5 remote-as 10000 156.12.1.6 bgp Serial0/0/0 255.255.255.252 65000 log-neighbor-changes synchronization Router ISP1 configuration : interface ip ! interface ip ! interface ip ! interface ip clock address 156.100.1.1 Loopback0 255.255.255.0 address 156.100.2.1 Loopback1 255.255.255.0 156.100.4.1 Loopback2 255.255.254.0 address address 156.12.1.5 rate Serial0/0/0 255.255.255.252 500000 ! router bgp no neighbor network network network ! bgp 156.12.1.6 156.100.4.0 156.100.2.0 156.100.1.0 10000 log-neighbor-changes synchronization remote-as 65000 mask 255.255.254.0 mask 255.255.255.0 mask 255.255.255.0 Experiment No. 6 Discovering IPv6 using Wireshark Objective: Discovering of IPv6 using Wireshark and do the comparative study of the header format of IPv4 and IPv6 Theory: Theory includes brief description of each of the following concepts: 1. Why IPv6? 2. IPv6 packet format(explain each field in detail) 3. Comparison between IPv4 and IPv6 headers 4. Extensions and options 5. Security 6. Features of IPV6 7. API for IPv6 8. Screenshots of IPv6 header format using Wireshark Figure 1, “Detail of IPv6 Router Advertisement in Wireshark” shows the screenshot simililar to what you should see, showing the details of a single router advertisement. Right now we’re going to discuss what is significant in this packet. Here is a brief explanation of the most important parts of the router advertisement, from top to bottom in the packet details view. 1. IPv6 Source In the packet shown, this is the “link-local unicast” address of Radv. We can confirm this by logging into Radv as mal and running ifconfig. (note that your Radv will have a different MAC address from ours) and seeing that the IPv6 address has a MAC address embedded inside of it[17]. Figure 1. Detail of IPv6 Router Advertisement in Wireshark Wireshark showing the full details of a single IPv6 Router Advertisement. 2. IPv6 Destination ff02::1 is a well-known address commonly called the “all-hosts link-local multicast address”. Every host on the local network (the “local link”, which is everything up to the first router) will be listening for traffic sent to this address. 3. Internet Control Message Protocol v6 (ICMPv6) Type ICMPv6 is a management protocol that is very important to the running of IPv6. As such, there are many different types of messages it could transmit. To identify the type of message being transmitted, the Type field is used. Here, type 134 identifies this message as being a Router advertisement. 4. ICMPv6 Flags The “Managed” address config flag specifies whether “Stateful configuration” is to be used. Stateful configuration would typically be understood to mean DHCPv6 (we learn about DHCP in a later lab, but we’ll ignore DHCPv6 in this paper). On most networks, this flag would not be set, meaning that the host should use “StateLess Address AutoConfiguration” (SLAAC). 5. The “Other” stateful config flag means that nodes on this link (local network) should use Stateful configuration (DHCPv6) for things other than address assignment. Thus, if you don’t use Stateful configuration for address assignment, you can still use it to advertise other information (such as information about DNS services, but we learn about DNS later in this course). For example, in the capture we saw on our own network, we saw M=0 and O=0, meaning “Not managed” and “Not other”. So we don’t use stateful configuration (such as DHCPv6) to try and get an address (instead we just use SLAAC), and neither do we use stateful configuration to find out other, non-address information about the network (eg. DNS settings, which host to send log messages to, and a wide range of other possibilities, some of which we mention further in the lab on DHCP). These “M” and “O” bits (Managed and Other) are important for understanding how IPv6 address assignment works. The remaining flags are not important for what we are aiming to understand today. 6. ICMPv6 Option (Prefix information) There can be a number of optional components to a router advertisement. The most common would be an option advertising what “prefix(es)” are used on this link. A prefix is very much like a network address: in SLAAC, a set of addresses is formed by taking each prefix and adding the interface’s EUI-64 host ID (typically formed by the MAC address). Note that there can be multiple “Prefix information” options included in a router advertisement. An interface can use multiple prefixes to generate multiple IPv6 addresses. 7. ICMPv6 Prefix length Somewhat self-explanatory, it tells us that this particular prefix is a /64 (remember that IPv6 addresses are 128-bit). With SLAAC, all advertised prefixes are /64, which makes this particular entry rather less interesting. We’ll come back to it when we see the Prefix. 8. ICMPv6 Flags The only flag we wish to draw to your attention here is the Autonomous Configuration flag (shown as “auto” in the screenshot). Recall that there can be multiple prefixes included in a router advertisement: only the ones marked with this “auto” flag get SLAAC addresses. This is on by default. 9. ICMPv6 Prefix This is the key piece of data in this announcement. Coupled with the prefix length we saw earlier, we see that this the prefix being advertised is fd6b:4104:35ce::/64. Viewed uncompressed, so you can see exactly how long the prefix is in relation to the whole address: fd6b:4104:35ce:0000:0000:0000:0000:0000 network bits ↤ ↦ host bits 10. ICMPv6 Source link-layer address option This option simply communicates the router’s MAC address to the hosts on the link, so they can pre-cache it in their “neighbour cache” (this is like ARP, although IPv6 doesn’t use ARP but something similar which we don’t want to get into right now). Having it included here means we don’t have to have an extra round-trip on the network to figure out the link-layer (MAC) address of the router, which reduces delay. So that’s a router advertisement, seen during steady-state whereby nothing particularly interesting is happening such as a new host appearing on the link. Let’s now repeat the capture and this time we shall see everything that happens when an interface comes up. 11. Resize the Wireshark display so that the packet list area takes up most of the room. Start a new live capture in Wireshark; you may discard your previous capture. When it has started capturing, from a terminal window, run as root the command ifconfig eth0 down, which will “down” the interface “eth0”, basically disabling it and removing any information that relates to it, such as routing table entries. Now remember what the last packet was that is currently shown in Wireshark’s packet list area. When you bring the interface back up with ifconfig eth0 up, you should see several packets arrive in the window. Stop the capture and save it, you will need it later in the assessment. Take a screenshot of the packet list showing the new packets. Experiment No. 7 Setting Up Ad Hoc Wireless Network in Windows XP Objective: to learn how to set up an Ad Hoc wireless network in windows XP. Theory: 1. Introduction to ad hoc networks 2. DSDV: Routing over a Multihop Wireless Network of Mobile Computers 3. DSR: The Dynamic Source Routing Protocol for Multihop Wireless Ad Hoc Networks 4. Cluster Based Networks 5. Screenshots of configuration of ad hoc network on windows XP 6. Limitation and application areas of wireless AD Hoc networks Setting Up Ad Hoc Wireless Network in Windows XP An ad hoc network is a temporary connection between computers and devices used for a specific purpose, such as sharing documents during a meeting or playing multiple-player computer games. You can also temporarily share an Internet connection with other people on your ad hoc network, so those people don’t have to set up their own Internet connections. Ad hoc networks can only be wireless, so you must have a wireless network adapter installed in your computer to set up or join an ad hoc network. Host Computer Configuration Steps: 1) Let’s start with the configuration, here I will choose one computer to start the configuration, right click wireless adapter and then click properties. Note: Please enable this host computer's ad hoc configuration on ICS host computer if you want to use Microsoft's Internet Connection Sharing feature. 2) Wireless Network Connection Properties will appear. Click Wireless Networks tab, here I tick Use Windows to configure my wireless network settings. After that click Advanced button. Note: You can also use the configuration tool provided by wireless adapter manufacturers to configure ad hoc wireless network. 3) Advanced window will appear. Select Computer-to-computer (ad hoc) networks only option. Click Close at last. Note: Don’t tick Automatically connect to non-preferred networks in order to ease the configuration. 4) After that, click Add to add new ad hoc wireless network. 5) Name your ad hoc network, here I use home-adhoc. Try to use open authentication without encryption first. After tested it works well, only proceed to enable WPA or WEP encryption. Click OK at last. 6) Now you will see your created ad hoc network (PC card icon) in preferred networks list. Wooo.. You have finished configuring this host computer. Client Computer Configuration 1) On other client computers, you only need to set its wireless adapter to use Windows to configure its network settings and enable Computer-to-computer (ad-hoc) networks only. Simply follow step 2 and 3 on host computer configuration above to get it done. 2) You then right click wireless adapter to view available wireless networks, you will see your ad hoc wireless network, proceed to connect to it. At this stage, you should be able to connect to this ad hoc wireless network!!! Have fun… :o) Note: If you have Internet Connection Sharing enabled on host computer, you can just set each client computer to obtain an IP address automatically, then these computers should be able to access Internet. Experiment No. 8 Study of Multi Protocol Label Switching (MPLS) Objective: Study of Multi Protocol Label Switching (MPLS) Theory: 1. Drawbacks of Traditional IP Routing Routing protocols are used to distribute Layer 3 routing information. Forwarding is based on the destination address only. Routing lookups are performed on every hop. 2. Drawbacks of Traditional IP Routing: Traditional IP Forwarding • Every router may need full Internet routing information (more than 100,000 routes). • Destination-based routing lookup is needed on every hop. 3. Drawbacks of Traditional IP Routing: IP over ATM • Layer 2 devices have no knowledge of Layer 3 routing information—virtual circuits must be manually established. • Layer 2 topology may be different from Layer 3 topology, resulting in suboptimal paths and link use. • Even if the two topologies overlap, the hub-and-spoke topology is usually used because of easier management. 4. Drawbacks of Traditional IP Routing: Traffic Engineering • Most traffic goes between large sites A and B, and uses only the primary link. • Destination-based routing does not provide any mechanism for load balancing across unequal paths. • Policy-based routing can be used to forward packets based on other parameters, but this is not a scalable solution. 5. Basic MPLS Concepts MPLS is a new forwarding mechanism in which packets are forwarded based on labels. Labels usually correspond to IP destination networks (equal to traditional IP forwarding). Labels can also correspond to other parameters, such as QoS or source address. MPLS was designed to support forwarding of other protocols as well. 6. Basic MPLS Concepts Example • Only edge routers must perform a routing lookup. • Core routers switch packets based on simple label lookups and swap labels. 7. MPLS vs. IP over ATM • Layer 2 devices are IP-aware and run a routing protocol. • There is no need to manually establish virtual circuits. • MPLS provides a virtual full mesh topology. 8. Traffic Engineering with MPLS • Traffic can be forwarded based on other parameters (QoS, source, and so on). • Load sharing across unequal paths can be achieved. 9. MPLS Architecture MPLS has two major components: Control plane: Exchanges Layer 3 routing information and labels; contains complex mechanisms to exchange routing information, such as OSPF, EIGRP, ISIS, and BGP, and to exchange labels; such as LDP, and RSVP. Data plane: Forwards packets based on labels; has a simple forwarding engine Router functionality is divided into two major parts: the control plane and the data plane 10. MPLS Labels • MPLS technology is intended to be used anywhere regardless of Layer 1 media and Layer 2 protocol. • MPLS uses a 32-bit label field that is inserted between Layer 2 and Layer 3 headers (Frame-mode MPLS). • MPLS over ATM uses the ATM header as the label (cell-mode MPLS). 11. MPLS Labels: Label Format MPLS uses a 32-bit label field that contains the following information: • 20-bit label • 3-bit experimental field • 1-bit bottom-of-stack indicator • 8-bit TTL field 12. MPLS Labels: Frame-Mode MPLS 13. Label Switch Routers • LSR primarily forwards labeled packets (label swapping). • Edge LSR primarily labels IP packets and forwards them into the MPLS domain, or removes labels and forwards IP packets out of the MPLS domain. 14. Label Switch Routers: Architecture of LSRs • LSRs, regardless of the type, perform these functions: – Exchange routing information – Exchange labels – Forward packets (LSRs and edge LSRs) or cells (ATM LSRs and ATM edge LSRs) • The first two functions are part of the control plane. • The last function is part of the data plane. 15. Label Switch Routers: Architecture of Edge LSRs ************************************