networking by jaiho157


									Q.No.-1: Write a program to simulate a 4/4, 8/8 switch or a link State Router. Ans:BRIDGES:-

Bridges interconnect Ethernet segments. Most bridges today support filtering and forwarding, as well as Spanning Tree Algorithm. The IEEE 802.1D specification is the standard for bridges. During initialization, the bridge learns about the network and the routes. Packets are passed onto other network segments based on the MAC layer. Each time the bridge is presented with a frame, the source address is stored. The bridge builds up a table which identifies the segment to which the device is located on. This internal table is then used to determine which segment incoming frames should be forwarded to. The size of this table is important, especially if the network has a large number of workstations/servers. The advantages of bridges are:  

increase the number of attached workstations and network segments since bridges buffer frames, it is possible to interconnect different segments which use different MAC protocols since bridges work at the MAC layer, they are transparent to higher level protocols by subdividing the LAN into smaller segments, overall reliability is increased and the network becomes easier to maintain

The disadvantages of bridges are:

the buffering of frames introduces network delays

 

bridges may overload during periods of high traffic bridges which combine different MAC protocols require the frames to be modified before transmission onto the new segment. This causes delays


Ethernet switches increase network performance by decreasing the amount of extraneous traffic on individual network segments attached to the switch. They also filter packets a bit like a router does. In addition, Ethernet switches work and function like bridges at the MAC layer, but instead of reading the entire incoming Ethernet frame before forwarding it to the destination segment, usually only read the destination address in the frame before retransmitting it to the correct segment. In this way, switches forward frames faster than bridges, offering less delays through the network, hence better performance. When a packet arrives, the header is checked to determine which segment the packet is destined for, and then its forwarded to that segment. If the packet is destined for the same segment that it arrives on, the packet is dropped and not retransmitted. This prevents the packet being "broadcasted" onto unnecessary segments, reducing the traffic. Switches divide the network into smaller collision domains [a collision domain is a group of workstations that contend for the same bandwidth]. Each segment into the switch has its own collision domain (where the bandwidth is competed for by workstations in that segment). As packets arrive at the switch, it looks at the MAC address in the header, and decides which segment to forward the packet to. Higher protocols like IPX and TCP/IP are buried deep inside the packet, so are invisible to the switch. Once the destination segment has been determined, the packet is forwarded without delay.

Each segment attached to the switch is considered to be a separate collision domain. However, the segments are still part of the same broadcast domain [a broadcast domain is a group of workstations which share the same network subnet, in TCP/IP this is defined by the subnet mask]. Broadcast packets which originate on any segment will be forwarded to all other segments (unlike a router). On some switches, it is possible to disable this broadcast traffic.

Packets are only passed to the network segment they are destined for. They work similar to bridges and switches in that they filter out unnecessary network traffic and remove it from network segments. Routers generally work at the protocol level. Routers were devised in order to separate networks logically. Most routers can also perform bridging functions. A major feature of routers, because they can filter packets at a protocol level, is to act as a firewall. This is essentially a barrier, which prevents unwanted packets either entering or leaving designated areas of the network. A router works at the Network Layer or higher, by looking at information embedded within the data field, like a TCP/IP address, then forwards the frame to the appropriate segment upon which the destination computer resides. Summary of Router features:       

use dynamic routing operate at the protocol level remote administration and configuration via SNMP support complex networks the more filtering done, the lower the performance provides security segment networks logically broadcast storms can be isolated

Firewalls:A firewall is a means of protecting a corporate network from outside abuse. In the very early days of the development of the motor car, the engine compartment was isolated from the passengers by use of steel plates. In the event of a fire or explosion, this prevented damage to the passenger by helping to limit the spread of flames or prevent engine parts from flying to the passenger area. In technical terms, a firewall is a router that restricts Internet access by only allowing access to certain host computers (and specified services on those host computers) within the organisation. Of course, a firewall not only protects outside intruders accessing internal corporate computers, but it can also prevent internal employees from accessing the Internet!

Q.No.-2:Linux Utilities for (a) Network Administrator
        

Creation, modification and deletion of user accounts Generate daily reports from log files Monitor system activity and perform auditing Ensure sufficient dish space exists and ensure file system integrity is maintained Install, configure and remove software packages as required Perform daily maintenance tasks, monitoring mail, print and other applications Start and shutdown the system Perform backups Install, mount and configure peripheral devices such as terminals and disk drives

How do you log on as an administrator? There are two ways that you can log on as a system administrator. If you are already logged on as a user, you can use the su (substitute user) utility to assume the administrator identity. $ su Password ###### #_ When you are logged in as a system administrator, the system prompt changes to #. The other way you can log on as a system administrator is to use the special administrator account, named root. Login: root Password ####### _

The/etc directory and system administrators:This directory contains important system files, user and group account information, and special scripts that configure the system. Some of these are shown below and will be discussed later in greater detail.
/etc/adduser.conf /etc/bootptab /etc/crontab /etc/fstab /etc/group /etc/inittab /etc/passwd /etc/motd /etc/mtab /etc/ftpusers /etc/printcap /etc/resolv.conf Specifies default configuration for creating user accounts Holds computer names and IP addresses for remote booting workstations List of jobs to be executed List of filesystems to mount when UNIX boots List of groups Lists the processes that are started when UNIX boots The password file, usernames, passwords, group membership, shell Message of the day List of currently mounted filesystems

Setting up user accounts:A system administrator is responsible for creating, modifying and deleting user accounts. When a user account is created, an entry is made in the /etc/passwd file. When a group account is created, an entry is made in the /etc/group file. /etc/passwd This plain text file holds information about users, such as their logon name and home directory. Each user has a separate line of information (a record) in the /etc/passwd file. Each field of the user record is separated by colons.

Thefollowing table illustrates the purpose of each field of a user record. logon_name:encrypted_password:userid:groupid:user_name: home_directory:shell brownbr:jwrt#4de:1154:101:Brian Brown:/user/brownbr:/bin/sh Each user must have a unique ID and belong to a group that is defined in the /etc/group file Example of adding a user using adduser:luni:/etc# adduser --ingroup bc bloggsjo Adding user bloggsjo... Adding new user bloggsjo (1161) with group bc. Creating home directory /user/bloggsjo. Copying files from /etc/skel Changing password for bloggsjo Enter the new password (minimum of 5, maximum of 8 characters) Please use a combination of upper and lower case letters and numbers. New password: **** Re-enter new password: **** Password changed. Changing the user information for bloggsjo Enter the new value, or press return for the default Full Name []: Joe Bloggs Room Number []: Work Phone []: Home Phone []: Other []:

Is the information correct? [y/n] y luni:/etc# luni:/etc# passwd bloggsjo Changing password for bloggsjo Enter the new password (minimum of 5, maximum of 8 characters) Please use a combination of upper and lower case letters and numbers. New password: Re-enter new password: Password changed. luni:/etc# To retire a user account involves removing their account record from /etc/passwd and deleting their home directory $ wall Hello there. This is the system administrator. Please logout. The system is being shutdown in 5 minutes. ctrl-d $ Cron:This program is started automatically (from the file /etc/init.d/cron) when the system enters multi-user mode. cron searches for crontab files in /var/spool/cron/crontabs and if found, loads them into memory ready for execution. Any crontab files are updated or removed using the crontab command.
cron also reads /etc/crontab and the files in /etc/cron.d. Every minute, cron is activated and examines all stored crontab

files, checking each command to see if it should be run in the current minute.

If a command is executed, the output is sent to the owner of the crontab file. Programs can be scheduled to run daily (/etc/cron.daily), weekly (/etc/cron.weekly)or monthly (/etc/cron.monthly). Finer control, such as every hour, or minute is also possible.
$ shutdown -g0 $ df and du init

This command, used only by the system itself and system administrators, changes the runlevel of the system. The runlevel is a mode of operation, such as single user or multiuser mode. The init command accepts the following arguments
S 0-6 Single user mode, used for maintenance Runlevel to boot into 0 = halt the system 1 = single user mode 2 = multiuser mode 6 = reboot the system Emergency, boot directly into a single user shell without running any other startup scripts


An example (do not type this command):$ init 1 $mail joe < message

 Booting hardware info. Stores at o /bin/dmesg and o /var/log/mesg

 kudzu utility maintains database of detected and configured h/w o /etc/sysconfig/hwconf

 hwbrowser o GUI utility for detected hardwares  File System o Ext3 : ext2 + journalizing for quick recovery from crashing  Ordered (default, journals only meta data)  Journaled (journals data as well as meta-data)  Writeback (allows a quicker fsck) o Minix : mostly used for floppy disks o msdos o Mkfs : mkfs –t ext2 /dev/hda2  Installation o Using GUI tool ANACONDA o Use Kickstart for quick installation  Boot Loader o GRUB (Grand Unified Bootloader) o LILO  Firewall Setup (at the time of installation) o High (block all connection to your machine except those needed to get an IP address using DHCP or to block connections to your machine) o Medium (allows privileged workgroup) o No Firewall o Firewall rules are written to /etc/sysconfig/iptables  System configuration are configured at /etc/sysconfig/ o /etc/sysconfig/network

o /etc/sysconfig/clock o /etc/sysconfig/init (b) Network Security:Why security: High User knowledge of IT sys.  Theft , Sabotage, Misuse, Hacking  Version Control Problems  Unrestricted Access  Systems / Network Failure  Lack of documentation  Virus  Natural calamity Management concerns: Market reputation  Business continuity  Disaster recovery  Business loss  Loss of confidential data  Loss of customer confidence  Legal liability  Cost of security Security measures: Technical  Procedural  Physical  Logical  Personnel  Management

Q.No.-3:Analysis and Trouble-shooting of LAN using Cable Tester, a mini SNMP console, encoding of the bits on the media and detecting collisions in Ethernet Wiring. Ans:Continuity Tests:-

The first test you will perform is a continuity test. This tests to ensure that there is electrical continuity (unbroken path) along the entire cable. It looks like,

First, remove the terminators at each end of the cable segment. Set the meter to resistance (or continuity test if it has one). Under a continuity test, the meter sends a signal along one lead. This travels down one wire of the coaxial cable, reaching the other end. At the far end, because it is shorted to the other lead by the screwdriver, the signal travels back along the other wire of the coaxial cable. When it arrives back at the meter, the meter knows that the cable is okay.
Resistance and Termination Tests:-

Now switch the meter to read resistance (we will be reading values of about 0-50 ohms, so set the range appropriately). Apply a terminator resistor to the each end of the cable. Diagramatically, it looks like,

Apply the meter to take a reading on the middle T-connector. Electrically, the circuit looks like,

Now, the golden rule of resistance in parallel is that the resultant resistance is R = (R1 * R2) / (R1 + R2) So, where the two resistors are equal, this gives a value of the value of one of the resistors. In our case, this is equal to 25. Remove one of the terminators. This simulates a missing or faulty terminator. Take a resistance reading again. Replace the terminator so that the cable is correctly terminated at each end. Now disconnect the cable from one side of one of the end T-connectors. This will simulate a cable break somewhere in the cable. Take a resistance reading again.
Taouble-shooting of LAN:-

In LAN's we deal with voltages (electrical signals) which are generally very small (less than 5volts peak to peak). The differences between no signal and signal can be less than 1 volt. In fact, noise voltages can even be interpreted as signals. This is one reason why the cabling media must be protected from noise sources and be free from induced noise voltages.

Because a LAN comprises many components, its often difficult to decide where to start finding the problem. However, there are a few basic rules we can learn which will point us in the right direction, with the aim of minimizing downtime. Information is vital for troubleshooting. You need access to
       

cable layouts cable type, location of terminators, splices, repeaters etc workstation location network interface card types, settings workstation information (screen type, memory, software configurations) knowledge of basic network topologies (star, ring, bus) knowledge of basic troubleshooting procedures (good/bad measurements) past history (recent changes, is fault repeatable)


Cable generates 90% of all LAN faults. Needless to say, cabling at installation time should be certified in writing, along with test results detailing the measurements taken. The major problems associated with cable are,
     

shorts and open circuits extraneous voltages, noise, ground loops excessive cable lengths (lets add just one more workstation) poor termination's, connectors wrong type of cable incorrectly installed to begin with

Ethernet systems use a BUS topology. This describes the manner in which the various hardware equipment of the LAN is interconnected.

   

each workstation is attached to a single cable thread each end of the cable is terminated in 50 ohms connections to PC's are made via T connectors signals are received by all workstations

However, bus systems do have drawbacks,
    

a cable fault will take down the entire LAN a faulty workstation will take down the entire LAN there are limits on the number of workstations there are limits on the length of cable workstations must be a minimum distance apart

Bus Topology DONT'S:        

mix different cable types mix 75 ohm and 50 ohm T connectors or terminators solder connectors run cable near power cables, or air conditioning units, or lighting earth the cable in more than one place mix different ethernet network card types exceed cable distances or workstation limits bend or trample the cable run spurs or drop cables from a T connector

Bus Topology DO'S:     

use a single cable type (RG58AU) one type of network card 50 ohm T connectors from a single supplier ground the cable at one end only keep the cable away from noise sources observe cable and workstation limits


The basic instruments for fault finding are

   

multimeter (resistance, continuity and voltage) suitable when the network is NOT ALIVE time domain reflectometer TDR visual inspection software diagnostics

Where do you start?


is the entire LAN down, all users affected o scan cable, measure resistance, noise o check to see if server running, LOAD MONITOR, TRACK ON some users affected o check to see if PC can still run DOS o run NIC diagnostics o any recent changes

Any other problems are generally configuration faults, particularly in the way in which the network has been configured or managed. These are problems like
 

inability to run certain applications can't access certain files or directories

Often problems are sporadic and intermittent in nature. Faults can be linked to external activity (the cable deriving noise voltages via lift motors etc). With intermittent faults, it is important to obtain information about
    

which users noticed it first what were they doing when it failed has this happened before is it repeatable is there any difference between this and the last time

The trouble-shooter must know the hardware and software configurations of the various workstations and servers on the

network. These details should be filled out and kept in folders. Included should be cable layouts, access points, cable distances, workstation locations etc. Remember that INFORMATION is the key. The more you know about the system, the easier your job will be. We always recommend to any new Network Manager that the first thing they do is fully document the entire LAN, both software and hardware.

HARDWARE :o Cabling, Connectors, Cable, MAU's o Workstations, keyboards, base units, monitors, drives memory, PSU, NIC and peripherals, mice etc o Servers o Bridges/Routers o Printers o Power Supply
SOFTWARE :o o o o o


Lan NOS and workstation shell Application Software Incorrect Configurations Access rights, drive mappings Data Integrity, backups



Help Desk  first level of repair  interacts with user to determine nature of problem  uses a standard battery of questions

o o o

logs details of problem  initiates repair by solving problem or passing on  Tracks problems passed on to experts  Does not require high degree of expertise  Requires access to database of problems and solutions  information of users system required Front Line Experts - Hardware and Software On-Call Experts - Cablers, In-house Consultants Installers/Trouble-shooters/LAN Authorized Agents

HELP DESK, TYPlCAL QUESTlONS TO ASK:         

Location of users machine. contact name and number Machine configuration, memory, drivers, monitor type etc DOS Version, Network NOS type and revision number What happened, time and date, can it be repeated? Are other network users affected? Can computer run DOS as standalone Do other users experience the same problem? Were there any recent changes to the computer or network What solutions have you tried to solve the problem? (reset, power-off/on), another machine, user account) Is this something new or have you tried this before?


connectors and terminators crimps, splices, bends noise, voltages and ground loops shorts and open circuits exceeding cable and workstation limits




ohm-meter o tests resistance of cable, presence of terminators, open and short circuits o limited use on live network time domain reflectometer o tests for cable imperfections, shorts and open circuits, impedance mismatches volt-meter o tests for voltage, -1.7v on ethernet means streaming NIC


divide and conquer split the cable segment in half, and take a measurement on both halves. This should isolate the fault into one half. Repeat the process till the fault is found.

TDR Testing

The TDR sends electrical pulses down a cable. Some of the pulse energy is reflected by connectors, cable imperfections and terminations. This reflected energy is measured by the TDR and displayed in graphical form. Cable have TWO important characteristics for TDR measurements.
 

impedance velocity of propagation (VP)

Impedance is a measure of the AC resistance of the cable, whereas Velocity of propagation is a measure of the speed at which signals travel down the cable, relative to the speed of light. Impedance is important for determining cable imperfections and bad connections and terminations. A cable which is un terminated will reflect all the transmitted energy back to the TDR, whereas a correctly terminated cable will reflect none. The amplitude (strength) of the reflected energy (how much of the original pulse) determines the severity of the fault.

Simple Network Management Protocol (SNMP):-

This provides a means for managing a network environment. Each host, router or gateway running SNMP can be interrogated for information related to the network. Examples of information are
   

host names packets transmitted and received errors routing information

Q.No.-4:Use of PING, traces route, ICMP for typical jobs of Network Administration. Ans:Ping This command sends an echo request to a host. It is a diagnostic tool for testing whether a host can be found. When the request reaches the host, it is sent back to the originator. Examples ping ; send an echo request to host ping ; ping host at IP address
c:\winnt\system32> Ping Pinging [] with 32 bytes of data: Reply from bytes=32 time<10ms TTL=128 Reply from bytes=32 time<10ms TTL=128 Reply from bytes=32 time<10ms TTL=128 Reply from bytes=32 time<10ms TTL=128 netstat

This command displays the network status of the local host. It provides information about the TCP connections, packet statistics, memory buffers and socket information.

$ netstat Active Internet connections (w/o servers) Proto Recv-Q Send-Q Local Address Foreign Address State tcp 0 126 ESTABLISHED tcp 0 0 ESTABLISHED tcp 0 0 ESTABLISHED Active UNIX domain sockets (w/o servers) Proto RefCnt Flags Type State I-Node Path unix 2 [ ] STREAM 830794 /dev/log unix 2 [ ] STREAM CONNECTED 830793 unix 1 [ ] STREAM 830746 unix 2 [ ] STREAM 830697 /dev/log unix 2 [ ] STREAM CONNECTED 830696 unix 2 [ ] STREAM 830680 /dev/log unix 2 [ ] STREAM CONNECTED 830679 $ Route:-

This command manually manipulates the network routing tables which are used to connect to other hosts. Example route add net 1 ; add a new network accessible via the gateway ; and there is one metric hop to this destination

This command lists all the connections (links) between the current computer and the destination computer.
c:\winnt\system32> tracert Tracing route to [] over a maximum of 30 hops: 1 <10 ms 10 ms <10 ms

2 <10 ms 10 ms <10 ms [] 3 430 ms 90 ms 411 ms 4 81 ms 40 ms 60 ms 5 60 ms 60 ms 60 ms [] 6 * 1783 ms 1442 ms [] 7 90 ms 90 ms 80 ms [] 8 100 ms 140 ms 231 ms [] Trace complete. Route:-

This command manually manipulates the network routing tables which are used to connect to other hosts.
Examples:-route add net 1 ; add a new network accessible via the gateway and ; there is one metric hop to this destination The Internet Control Message Protocol (ICMP):-

ICMP packets contain information about failures on the network, such as inoperative nodes and gateways, packet congestion etc. The IP software interprets ICMP messages. ICMP messages often travel across many networks to reach their destination, so they are encapsulated in the data portion of an IP datagram.
The Internet Protocol (IP):-This defines the format of the packets

and how to handle them when sending or receiving. The form of the packets is called an IP datagram.

Q.No.-5: Write a C programme in TCP/IP for simulation of an Internet Chatting. Ans:Sockets:-

A socket is an end to end communication link between a server and a client application. This allows applications to be network aware, and send and receive data via a network. Interface details vary from computer to computer. The examples given in this section have been tested under LINIX Debian v2.1. Sockets use a destination address and port number to communicate with another application. Each connection uses a specific port number, some of which are reserved (see /etc/services). Application programs written by users should take care not to existing port numbers that are already bound to running applications. UDP is also Datagram and stream sockets The datagram protocol, also known as UDP, is connectionless. This means that each time a datagram (a packet of data to a destination) is sent, the socket and destination computers address must be included. There is a limit unreliable, as there is no guarantee that the datagram sent will arrive in the same order at the destination. The stream protocol, also known as TCP, is connection orientated. This requires a connection to be established between the sender and receiver. One of the sockets listens for a connection request (the server), the other socket asks for a connection (the client). When the server accepts the connection request from the client, data can then be sent between the server and client.

In TCP there is no limit on the amount of data that can be transmitted. TCP is also a reliable protocol, in that data is received in the same order in which it was sent. Include Files:The files to include in application programs that define sockets and the various calls associated with them are sys/types.h sys/socket.h netinet/in.h arpa/inet.h The following examples apply to the example code that appears later. For more detailed information on each of the system calls, please refer to the online manual. Creating a socket:The socket() call creates a socket on demand. The format is int s; s = socket( AF_INET, SOCK_DGRAM, 0 ); /* specify TCP/IP and use datagrams */ If the socket was not created, -1 is returned to indicate an error. When a socket is created, it is in an unconnected state. An application program normally uses the system call connect() to bind a destination address to the socket and place it into a connected state. recvfrom(), sendto() and sendmsg() allow udp as they require the destination address to be specified as part of the call. Setting up a destination address and port number:An application program creates a variable of type struct

sockaddr_in, then assigns the destination address and port number to this variable. In sending or receiving data on the socket connection, this variable is passed as a parameter. struct sockaddr_in server; /* set up server name and port number */ server.sin_family = AF_INET; /* use TCP/IP */ server.sin_port = 800; /* specify port 800 */ server.sin_addr.s_addr = inet_addr(""); Binding the destination address:Rather than specify the destination address in each call, the destination address can be bound to the socket. /* set up the server connection side */ server.sin_family = AF_INET; /* use TCP/IP */ server.sin_port = 0; /* use first available port */ server.sin_addr.s_addr = INADDR_ANY; if( bind( s, &server, sizeof(server) ) < 0 ) { perror("Error, socket not bound."); exit(3); }

Sending data to the socket connection:There are five possible system calls that an application program can use to send data to a socket. They are send(), sendto(), sendmsg(), write() and writev(). The following code fragment sends data to the port.

char buf[32]; strcpy( buf, "Hello" ); sendto( s, buf, sizeof(buf)+1, 0, &server, sizeof(server)); Receiving data from the socket connection:The following code fragment receives data from the port. char buf[32]; int s, client_address_size; struct sockaddr_in client, server; if( recvfrom( s, buf, sizeof(buf), 0, (struct sockaddr *) &client, &client_address_size) < 0 ) { perror("Error getting data from socket connection."); exit( 4 ); } Closing the socket connection:When the application program is finished, the socket connection should be closed. close( s ); Example UDP Client Program:This client program establishes a socket connection and sends the message "Hello" to the server application. /* rem invoke with a.out portnum */ #include <string.h> #include <stdlib.h> #include <sys/types.h> #include <sys/socket.h> #include <netinet/in.h>

#include <arpa/inet.h> main( argc, argv) int argc; char **argv; { int s; unsigned short port; struct sockaddr_in server; char buf[32]; /* argv[1] is internet address of server argv[2] is port number Convert the port from ascii to integer and then from host byte order to network byte order using htons() */ port = htons( atoi( argv[2] )); /* create datagram socket using UDP */ printf("Creating datagram socket.\n"); s = socket(AF_INET, SOCK_DGRAM, 0); if( s == -1 ) printf("Socket was not created.\n"); else printf("Socket created successfully.\n"); /* set up the server name */ server.sin_family = AF_INET; server.sin_port = port;

server.sin_addr.s_addr = inet_addr( argv[1] ); strcpy( buf, "Hello" ); printf("Sending data to the socket.\n"); sendto( s, buf, (strlen(buf)+1), 0, &server, sizeof(server ) ); printf("Data has been sent to the socket\n"); printf("Closing the socket connection.\n"); close(s); printf("Socket closed.\n"); }

Example UDP Server Program:This server program establishes a socket connection and receives data from a client application. /* server program, run this first */ #include <string.h> #include <stdlib.h> #include <sys/types.h> #include <sys/socket.h> #include <netinet/in.h> #include <arpa/inet.h> main() { int sockint, s, namelen, client_address_size; struct sockaddr_in client, server; char buf[32]; /* create datagram socket using UDP */

printf("Creating datagram socket.\n"); s = socket(AF_INET, SOCK_DGRAM, 0); if( s == -1 ) printf("Socket was not created.\n"); else printf("Socket created successfully.\n"); /* set up the server name */ server.sin_family = AF_INET; server.sin_port = 0; /* use first available port number */ server.sin_addr.s_addr = INADDR_ANY; if( bind(s, &server, sizeof( server )) < 0 ) { printf("Error binding server.\n"); exit(3); } /* find out what port was assigned */ namelen = sizeof( server ); if( getsockname( s, (struct sockaddr *) &server, &namelen) < 0 ) { perror("getsockname()\n"); exit(3); } printf("The assigned port is %d\n", ntohs( server.sin_port)); /* receive message on socket s in buf */ client_address_size = sizeof( client ); printf("Waiting for a message to arrive.\n");

if( recvfrom(s, buf, sizeof(buf), 0, (struct sockaddr *) &client, &client_address_size) < 0 ) { printf("recvfrom()\n"); exit(4); } /* print the message */ printf("Data has been sent to the socket\n"); printf("The message was\n"); printf("%s\n", buf ); printf("Closing the socket connection.\n"); close(s); printf("Socket closed.\n"); }
Compiling and running the example programs Type the following commands. $ cd $HOME $ mkdir sockets $ cd sockets $ mkdir udp $ cd udp $ cp /etc/demo/socket/client1.c client1.c $ cp /etc/demo/socket/server1.c server1.c $ cc client1.c $ cp a.out client1.out $ cc server1.c $ cp a.out server1.out

The command sequence first establishes a subdirectory where the examples and programs will be stored. The sample programs are then copied into this new directory. After compiling the client program, the executable file is copied to a.out because this will be

lost when the server program is compiled. After typing all the commands about, the client application is stored in client1.out and the server application in server1.out The server application is started first. You will be required to have two telnet sessions running at the same time, one in which you can run the server application, the other in which you will run the client application.
Run the server program by typing the following command $ server1.out Write down the port number and TCP/IP address that the server application is using. Leave the current telnet session running. Start another telnet session and login to the computer. Type the following commands (but replace IP_ADDRESS and PORT with the values displayed by the server application). $ cd sockets/udp $ client1.out IP_ADDRESS PORT The echo program

This example program reads from stdin and writes to stdout using getchar() and putchar(). #include <stdio.h> main() /* type1.c a simple program to echo stdin to stdout */ { int c; printf("Please begin typing. To finish, type 'F'\n"); c = getchar(); while( c != 'F' ) { putchar(c); c = getchar(); } }

What we shall develop now is to modify the existing client1.c and server1.c programs so that client2 sends the typed data to server2, which displays it on stdout. Type the following commands $ cd $HOME $ cd sockets/udp $ cp client1.c client2.c $ cp server1.c server2.c Modify the file client2.c so that it reads data from stdin and sends the data to the socket connection. This should continue whilst an 'F' is not typed. When an F is typed, the F should be sent to the socket and the program should then close the socket and terminate (see listing ?? for psuedo code example). Modify the file server2.c so that it reads data from the socket connection and displays this on stdout. If an F is read, the F is displayed, then the socket is closed and the server application terminates (see listing ?? for psuedo code example). After compiling the client program, copy the file a.out to client2.out. After compiling the server program, copy the file a.out to server2.out. Test the program and demonstrate it working to your lab supervisor. Print out your modified copies of client2.c and server2.c and attach them to this workbooklet.

Q.No.-6:Assessing the slowness of a network response time and throughput of a network for basic services of E-mail using mine,FTP, Telnet, http. Ans:File Transfer (FTP):-

FTP stands for file transfer protocol. It is a means of transferring files between computers of different types on the Internet. Standard commands are used to connect to computers which hold files. These computers are called ftp servers. When you logon to an ftp server, you need to supply a username and password. Most ftp servers allow users to use an account called anonymous, which allow users to logon using this account with limited access. When users logon to an ftp server using the account anonymous, it is usual for them to use their email address as the password. The features of ftp are,
    

ftp servers exist to provide a storage place for useful files and programs users can logon to these servers and download the files to their local computer you have to know the server name and whereabouts the file is located (subdirectory and filename) it is command driven using commands like open, bye, get it is hard to see the general structure or layout of any ftp server [would be nice to have a roadmap or hierarchical diagram of the directory tree]

Changing to another directory on the ftp server:In this step, you will change to another directory on the ftp server in preparation for downloading a specific file. Type the command cd public to change to the public directory. Type the command dir to display the files in the public directory. Type the command pwd to find our what directory you are in. Changing the local directory where you will store transferred files:In this section you will change the directory where transferred files are stored on your computer. On Windows based computers, the default directory where the ftp program stores downloaded files is normally the directory from which the ftp program starts.
Closing the connection to the ftp server say ….. bye

Telnet:Telnet is a service that allows a user to login and run programs on a remote server on the Internet. This requires a user account (name and password) on the telnet server. On the user computer, a telnet client application is run. The general features of telnet are
    

you must logon using a specific account and password you run programs on the host computer program output is seen on your own computer it is interactive you must know the commands and what programs are available

Q.No.7:Use of modern Search Engines, their advanced applications by successive quarry refinement etc. Ans:What is a search engine?

A search engine is a means of searching for information that can be found on the Internet. For example, when accessing a search engine you might specify that you want to search for information about "Polar Bears", in which case the search engine would return all the URL's it knows about that has information about Polar Bears. How does a search engine know where the information is? There are a number of ways a search engine can know about where information is to be found. Firstly, a search engine can list information by keywords or page titles. These keywords or titles (subject categories) can either be submitted by user's that provide information on the Internet, or can be extracted by accessing web pages and extracting the page title and keywords from the header of the web page. This keyword extraction relies on the appropriate HTML code in the header of the web page (it is called a meta-tag). The advantage is that it quicker to index information and less traffic is involved (only headers are requested from web sites, the entire web document is NOT read). The second method a search engine can use relies upon reading every page it knows about (usually pages are submitted for inclusion by web authors). This technique involves the use of programs called 'spiders' or 'web robots'

that request every page then extracts all words from the content of the page and stores these words in a large database. Not all search engines are the same. Some use keyword extraction via meta-tags whilst other use keywords via page content indexing. Obviously content indexing is a much better method because you are more likely to find specific information. However, this method has a number of problems. One is the sheer size of the resultant database and number of pages involved (which means a lot of traffic, and it might take two weeks to fully search all those pages). As the size of the WWW continues to grow this becomes more and more difficult. Keeping the database up-to-date is a serious problem. It is common to find that pages returned by a search engine have in fact since been moved or deleted.
How does a search engine work?

When they tell the search engine to start the search (by pressing "enter" or clicking on a specific button), the search engine invokes a program that queries its database (a collection of all the web pages it has access to). The results are returned to the user as a number of possible URL's. Often, these will be ranked in priority or success rate, with higher values meaning more likely to contain the information you request (what it really means is that it contains more occurrences of the key words you were searching for compared to other documents). Basic Search Queries:Simple queries involve you specifying a keyword or multiple keywords. The more specific you can be the better, choosing

words carefully. For instance, the keyword "polar" will also return occurrences of the words "polars" and "polarity". Your query is entered into the search dialog box of the form associated with the search engine, and pressing the enter key (or clicking on an icon called "go" or "search" will instruct the search engine to begin looking at its database for matches. 4.7.1 By Keyword:Keyword searching is popular where you are looking for specific information. As an example, lets say we want to find out when christopher columbus discovered America. Typical keywords we could use are "Columbus", "America" and "discover". Note that in this instance I have not used the keyword "Christopher".

The reason for this is that when you use keywords, the search engine returns all pages containing that keyword. So, in the above example, we get returned all pages containing any of the keywords. This means any page containing Columbus, or the keyword America, or the keyword discover. This is really not what we want. We want all pages that contain all three keywords, so we should modify the query to specify that all three words are required. 4.7.2 Keywords and the AND operator:In the previous example, any page containing any of the keywords was returned. This time, using the AND keyword, we can specify the query as

This will restrict the search so that all three keywords must occur in each returned article. 4.7.3 By Phrase:Lets take the example that you remember a phrase someone once said, but you have forgotten who said it. Searching by phrase looks for the exact occurrence of words in articles of the database. The phrase is enclosed in double quotes. The following example searches for the phrase "Now is the time of our"

4.7.4 Using the NOT operator:-

Once you have a number of returns to your query, you might look at these results and determine that the search engine is including other pages that have a common element which you do not want. For example, in our search on Columbus, the search engine might be returning a large number of results that contain items for sale and museums. In this case, we want to restrict our query further. To do this we can use the NOT operator to specify keywords that are to be excluded, this eliminated these unwanted results.

Tip:Use lowercase in search phrases. Most search engines will return both upper and lowercase results if you use lowercase. If you use uppercase, only uppercase matches will be returned. 4.8 Advanced Search Queries:Most search engines allow advanced search options. These allow you to sort the results, specify dates and exclude more

results. The following information specifically applies to altavista, but some other search engines support these options. 4.8.1 Using the + operator:The + operator works in the same manner as the AND operator, meaning that the word or phrase must occur in order for the reference to be returned by the search engine.

4.8.2 Using the – operator:-

The - operator works in the same manner as the NOT operator, meaning that the word or phrase must not occur in order for the reference to be returned by the search engine.

4.8.3 Excluding certain domains:In our search for information about Columbus, we might decide it is a good idea to restrict our search to only servers that are educational in nature. Thus we can specify that only servers in the .edu domain need to be searched (as this is more likely where the information will be found).

4.8.4 Looking for URL links:There are times when we might want to know who is linked to our pages. We can do this by using the link operator, as illustrated below. This example searches for all links that have the words "smac/csware.htm" anywhere in a URL link.

Q.No.8:To identify and implement some most recent popular RFC (Rquest for Comments)’s. Ans:A Request For Comment is a document that contains information about a protocol (a set of rules for exchanging information, like TCP/IP) or policy associated with the Internet. A new RFC can be developed by an individual, group or company. The new RFC outlines how the new service will work, and is placed on the Internet for public comment. If it is accepted by an Internet Standards Committee, then the RFC is implemented. The Request for Comments (RFCs):The Requests for Comments (RFC) document series is a set of technical and organizational notes about the Internet (originally the ARPANET), beginning in 1969. Memos in the RFC series discuss many aspects of computer networking, including protocols, procedures, programs, and concepts, as well as meeting notes, opinions, and sometimes humor. The official specification documents of the Internet Protocol suite that are defined by the Internet Engineering Task Force (IETF) and the Internet Engineering Steering Group (IESG ) are recorded and published as standards track RFCs. As a result, the RFC publication process plays an important role in the Internet standards process. RFCs must first be published as Internet Drafts.

The RFC-Editor:The RFC Editor is the publisher of the RFCs and is responsible for the final editorial review of the documents. The RFC Editor also maintains a master file of RFCs called the "RFC Index", which can be searched online. For nearly 30 years, The RFC Editor was Jon Postel; today the RFC Editor is a small group funded by the

To top