CN - 200303105838 5 54
CN - 200303105838 5 54
303105255                                                                                                 Page 5
                                                                          Faculty of Engineering & Technology
                                                                       Subject Name: Computer Network
                                                                          Subject Code:303105255
                                                                          B.Tech: CSE 2nd Year 4th Semester
                                                 Annexure No :
       Step1: Select pcs and switches(29050-24) then connect pcs to switches with straight-through(straight
       wire) and switches to switches with crossover(dashed wired) .
       Step2: Connect them as shown in the image above. Also give them a proper IP address.
        Step3: Pass a message and check simulation.
 2. MESH
       A mesh topology is a network setup where each computer and network device is interconnected
 with one another. This topology setup allows for most transmissions to be distributed even if one of the
 connections goes down. It is a topology commonly used for wireless networks.
303105255                                                                                                   Page6
                                                                           Faculty of Engineering & Technology
                                                                        Subject Name: Computer Network
                                                                           Subject Code: 303105255
                                                                           B.Tech: CSE 2nd Year 4th Semester
                                                  Annexure No :
       Step1: Connect the pcs and switches to one another as shown in image above. Make sure to connect
       the switches to switches with crossover wires and pc to switches withstraight-through.
       Step2: Connect them as shown in the image above. Also give them a proper IP address.
       Step3: Pass a message and check simulation.
       3. Star
        A star topology is a topology for a Local Area Network (LAN) in which all nodes are individually
    connected to a central connection point, like a hub or a switch. A star takes more cable than e.g. a bus,
    but the benefit is that if a cable fails, only one node will be brought down.
303105255                                                                                                   Page 7
                                                                       Faculty of Engineering & Technology
                                                                    Subject Name: Computer Network
                                                                       Subject Code: 303105255
                                                                       B.Tech: CSE 2nd Year 4th Semester
                                               Annexure No :
       Step1: Connect the pcs and switches to one another as shown in image above. Make sure to connect
       pcs to switch with straight through wires.
       Step2: Connect them as shown in the image above. Also give them a proper IP address.
       Step3: Pass a message and check simulation.
 3. BUS
       A bus topology is a topology for a Local Area Network (LAN) in which all the nodes are connected
    to a single cable. The cable to which the nodes connect is called a "backbone". If the backbone is
303105255                                                                                                Page 8
                                                                         Faculty of Engineering & Technology
                                                                      Subject Name: Computer Network
                                                                         Subject Code: 303105255
                                                                         B.Tech: CSE 2nd Year 4th Semester
                                                Annexure No :
     broken, the entire segment fails.
     Step1: Connect the pcs and switches to one another as shown in image above. Make sure to connect pcs
     to switch with straight through wires and switches to one another with crossover.
     Step2: Connect them as shown in the image above. Also give them a proper IP address.
     Step3: Pass a message and check simulation.
 4. TREE
       A tree topology is a special type of structure where many connected elements are arranged like the
    branches of a tree. For example, tree topologies are frequently used to organize the computers in a
    corporate network, or the information in a database.
303105255                                                                                                   Page 9
                                                                        Faculty of Engineering & Technology
                                                                     Subject Name: Computer Network
                                                                        Subject Code: 303105255
                                                                        B.Tech: CSE 2nd Year 4th Semester
                                                Annexure No :
      Step1: Connect the pcs and switches to one another as shown in image above. Make sure to connect pcs
      to switch with straight through wires and switches to one another with crossover.
      Step2: Connect them as shown in the image above. Also give them a proper IP address.
 5.   HYBRID
          A hybrid topology is a type of network topology that uses two or more differing network
       topologies. These topologies can include a mix of bus topology, mesh topology, ring topology,
       star topology, and tree topology.
303105255                                                                                               Page10
                                                                       Faculty of Engineering & Technology
                                                                    Subject Name: Computer Network
                                                                       Subject Code:303105255
                                                                       B.Tech: CSE 2nd Year 4th Semester
                                               Annexure No :
       Step1: Connect the pcs and switches to one another as shown in image above. Make sure to connect the
       switches to switches with crossover wires and pc to switches with straight-through.
303105255                                                                                              Page11
                                                                          Faculty of Engineering & Technology
                                                                       Subject Name: Computer Network
                                                                          Subject Code:303105255
                                                                          B.Tech: CSE 2nd Year 4th Semester
                                                 Annexure No :
                                             PRACTICAL: 2
AIM: To understand the features of wireshark as a packet capture tool and understand encapsulation of
information. Also study effect of few network commands
2.1 Purpose:
The main objective of the proposed experiment is to give exposure of wire-shark tool to students so can learn
to monitor transmission packets being sent in Wi-Fi and LAN environments.
2.3 TOOLS/SOFTWARE:
Wireshark
303105255                                                                                                 Page 12
                                                                           Faculty of Engineering & Technology
                                                                        Subject Name: Computer Network
                                                                           Subject Code:303105255
                                                                           B.Tech: CSE 2nd Year 4th Semester
                                                  Annexure No :
                                               PRACTICAL: 3
AIM: To study behavior of generic devices used for networking: (Cisco packet tracer)
DESCRIPTION:
Web server in Cisco packet trace
                                                   Figure 3.1
       In this lesson we will learn about how to create first web server on cisco packet tracer that can be
        apply on real time web server.
       So we are taking few PCs and one web server and one switch for connecting all devices. Make sure
        all devices should be connected by straight through cable because for connecting different devices,
        straight through cable is required. Assign IPs to each end device (server and PCs) of single network
        with subnet mask It can different as per your choice.
       Then go in server>services>http in that enable http and https modes.In that go to index.html and edit
        .In that write the message you want… At the end click on save.and close it .
       Then we go PC1 and in that we select desktop and we write the IP address of server and click on
        enter.You can see the message which you wrote in server message.
303105255                                                                                                  Page 13
                                                                        Faculty of Engineering & Technology
                                                                     Subject Name: Computer Network
                                                                        Subject Code:303105255
                                                                        B.Tech: CSE 2nd Year 4th Semester
                                                  Annexure No :
                                                    Figure 3.2
       If you want to see that your connection is proper or not then you want to click on your pc then
        desktop>command prompt and in that you need to write ping 190.0.0.1(IT_address). And give enter.
Figure 3.3
Use of switch
A switch is used in a wired network to connect to other devices using Ethernet cables. The switch allows each
connected device to talk to the others. Wireless-only networks do not use switches because devices such as
wireless routers and adapters communicate directly with one another.
303105255                                                                                               Page14
                                                                         Faculty of Engineering & Technology
                                                                      Subject Name: Computer Network
                                                                         Subject Code:303105255
                                                                         B.Tech: CSE 2nd Year 4th Semester
                                                Annexure No :
Figure 3.4
       Connect multiple hosts: Normally, a switch provides a large number of ports for cable connections,
        allowing for star topology routing. It is usually used to connect multiple PCs to the network.
       Forwards a message to a specific host: Like a bridge, a switch uses the same forwarding or filtering
        logic on each port. When any host on the network or a switch sends a message to another host on
        the same network or the
       ame switch, the switch receives and decodes the frames to read the physical (MAC) address portion
        of the message.
       Manage traffic: A switch in networking can manage traffic either coming into or exiting the network
        and can connect devices like computers and access points with ease.
       Keep electrical signal undistorted: When a switch forwards a frame, it regenerates an undistorted
        square electrical signal.
       Increase LAN bandwidth: A switch divides a LAN into multiple collision domains with independent
        broadband, thus greatly increasing the bandwidth of the LAN.
Use of hub
A hub is a physical layer networking device which is used to connect multiple devices in a network. They are
generally used to connect computers in a LAN.
303105255                                                                                                Page15
                                                                          Faculty of Engineering & Technology
                                                                       Subject Name: Computer Network
                                                                          Subject Code:303105255
                                                                          B.Tech: CSE 2nd Year 4th Semester
                                                 Annexure No :
Figure 3.5
A hub has many ports in it. A computer which intends to be connected to the network is plugged in to one of
these ports. When a data frame arrives at a port, it is broadcast to every other port, without considering
whether it is destined for a particular destination or not.
When a Hub receives data from one of the connected devices, it passes data to all the other ports without
checking for the destination device except the port through which it receives the data. Below figure, shows
the working of a HUB.
                                                  Figure 3.6
Consider, Device A want to send data to device D. When device A sends data, the hub receives it through
one port and transfer the data to all the other connected devices instead of passing it to only
device D. This feature of hub leads to congestion and extends the collision domain. So, it is considered as an
inefficient device and needs more bandwidth for working.
303105255                                                                                                 Page16
                                                                     Faculty of Engineering & Technology
                                                                  Subject Name: Computer Network
                                                                     Subject Code:303105255
                                                                     B.Tech: CSE 2nd Year 4th Semester
                                            Annexure No :
Figure 3.7
                    HUB                                        SWITCH
        A hub operates on the physical         A switch operates on the data link layer.
         layer.
      Hubs perform frame floodingthat          It performs broadcast, then the unicast and
         can be unicast, multicast, or           multicast as needed.
         broadcast.
      Just a singular domain ofcollision       Varied ports have separate collision
         is present in a hub.                    domains.
      Transmission mode is Half-duplex.        Transmission mode is Full duplex.
      Hubs operates as a Layer 1 devices       Network switches help you to operate at
         per the OSI model.                      Layer 2 of the OSImodel.
      To connect a network ofpersonal          Allow connecting multiple devices and
         computers should be joined              ports.
         through a central hub.
      Uses electrical signal orbits.           Uses frame & packet
       Does not offer Spanning-Tree.         Multiple Spanning-Tree is possible
      Collisions occur mostly in setups      No collisions occur in a full-duplex switch.
         using hubs.
      Hub is a passive device.                 A switch is an active device
      A network hub can't store MAC            Switches use CAM (Content Accessible
         addresses.                              Memory) that can be accessed by ASIC
                                                 (Application Specific Integrated Chips).
       Not an intelligent device.           Intelligent device.
        Its speed is up to 10 Mbps.          10/100 Mbps, 1 Gbps, 10 Gbps
       Does not use software.                Has software for administration
303105255                                                                                            Page 17
                                                                           Faculty of Engineering & Technology
                                                                        Subject Name: Computer Network
                                                                           Subject Code:303105255
                                                                           B.Tech: CSE 2nd Year 4th Semester
                                                  Annexure No :
303105255                                                                                                    Page 18
                                                                             Faculty of Engineering & Technology
                                                                          Subject Name: Computer Network
                                                                             Subject Code:303105255
                                                                             B.Tech: CSE 2nd Year 4th Semester
                                                   Annexure No :
Copper straight through wire:
This is a standard Ethernet cable that is used to connect two devices that operate in different layers of the OSI
model (such as hub to router and switch to PC). It can be used with Ethernet, Fast Ethernet and Gigabit
Ethernet port types.
Copper cross over wire:
This Ethernet cable connects devices operating in the same OSI layer (such as hub to hub, PC to PC, PC to
router, and PC to printer). This cable can also be used with Ethernet, Fast Ethernet and Gigabit Ethernet port .
Phone:-
The mobile phone network enables wireless communication using mobile devices, such as mobile phones,
smart phones or tablets. Mobile phone networks provide the necessary infrastructure and are operated by
mobile phone providers.
Automatically choose connection wire:
 Connections can be made automatically by choosing the connection type shown below. Router links will be
red or not active until you correctly configure the interfaces.
Coaxial wire:
The coaxial cable used to connect the Cisco uBR7200 series universal broadband routers at the headend
should be very high-quality cable because imperfections that do not visibly affect video transmissions can
significantly affect digital data transmissions. In particular, poor insulation, improperly installed additional
outlets, the condition and length of the cable’s center conductor, and the quality of the cable can negatively
affect the connectivity and performance of the cable access router for digital data transmission
Sniffer:
I have assignment that i need to create full "Network", using all device like switch, hub, server ..etc.The problem
that i force that i need to use "Sniffer" its first time to me using that device. I need help how can i configure or
connect the Sniffer with my network, Because i search on internet i don't find anythings about configure or
connect sniffer on packet tracer.
Smart device:
A smart device is an electronic device, generally connected to other devices or networks via different
wireless protocols such as Bluetooth, Zigbee, NFC, Wi-Fi, LiFi, 5G, etc., that can operate to some extent
interactively and autonomously.
Mcu-pt board:
Components are physical objects that connect to microcontroller (MCU-PT) or single boarded computers
(SBC-PT). They typically does not have a network interface and rely on the MCU-PT or SBC-PT for
network access. These are simple devices that only communicate through their analog or digital slots.
303105255                                                                                                     Page19
                                                                     Faculty of Engineering & Technology
                                                                  Subject Name: Computer Network
                                                                     Subject Code:303105255
                                                                     B.Tech: CSE 2nd Year 4th Semester
                                                  Annexure No :
                                      PRACTICAL 4
AIM : Data link layer (error detection).
#include<stdio.h>
int dataatrec[10],c,c1,c2,c3,i;
scanf("%d",&data[0]);
   scanf("%d",&data[1]);
   scanf("%d",&data[2]);
scanf("%d",&data[4]);
printf("%d",data[i]);
303105255                                                                                            Page20
                                                                  Faculty of Engineering & Technology
                                                               Subject Name: Computer Network
                                                                  Subject Code:303105255
                                                                  B.Tech: CSE 2nd Year 4th Semester
                                               Annexure No :
   printf("\n\nEnter received data bits one by one\n");
   for(i=0;i<7;i++)
        scanf("%d",&dataatrec[i]);
c1=dataatrec[6]^dataatrec[4]^dataatrec[2]^dataatrec[0];
c2=dataatrec[5]^dataatrec[4]^dataatrec[1]^dataatrec[0];
c3=dataatrec[3]^dataatrec[2]^dataatrec[1]^dataatrec[0];
c=c3*4+c2*2+c1 ;
if(c==0) {
else {
for(i=0;i<7;i++)
printf("%d",data[i]);
        for(i=0;i<7;i++)
          printf("%d",dataatrec[i]);
303105255                                                                                         Page21
                                                Faculty of Engineering & Technology
                                             Subject Name: Computer Network
                                                Subject Code: 203105256
                                                B.Tech: CSE 2nd Year 4th Semester
                             Annexure No :
if(dataatrec[7-c]==0)
dataatrec[7-c]=1;
      else
dataatrec[7-c]=0;
for (i=0;i<7;i++) {
printf("%d",dataatrec[i]);
}
}
OUTPUT :
303105255                                                                       Page 22
                                                                         Faculty of Engineering & Technology
                                                                      Subject Name: Computer Network
                                                                         Subject Code:303105255
                                                                         B.Tech: CSE 2nd Year 4th Semester
                                                 Annexure No :
                                                PRACTICAL: 5
DESCRIPTION:
STEP 1: Make a network
       Connect the pcs and switches shown in the below figure.Give IP address.
       Connect pcs to switches with copper straight through and connect switches to one another with copper
        cross over.
303105255                                                                                                Page23
                                                                      Faculty of Engineering & Technology
                                                                   Subject Name: Computer Network
                                                                      Subject Code: 203105256
                                                                      B.Tech: CSE 2nd Year 4th Semester
                                               Annexure No :
    
     Write the foll. commands conf t>vlan 10> name yellow>exit as shown below.
To see the vlan the command used is >show vlan brief. The output of the command is below,
303105255                                                                                             Page 24
                                                                   Faculty of Engineering & Technology
                                                                Subject Name: Computer Network
                                                                   Subject Code: 203105256
                                                                   B.Tech: CSE 2nd Year 4th Semester
                                            Annexure No :
                                             Figure 5.3
STEP 3: Configure TRUNK MODE.
303105255                                                                                          Page 25
                                                                    Faculty of Engineering & Technology
                                                                 Subject Name: Computer Network
                                                                    Subject Code: 203105256
                                                                    B.Tech: CSE 2nd Year 4th Semester
                                             Annexure No :
Figure 5.4
303105255                                                                                           Page 26
                                                                     Faculty of Engineering & Technology
                                                                  Subject Name: Computer Network
                                                                     Subject Code: 203105256
                                                                     B.Tech: CSE 2nd Year 4th Semester
                                                 Annexure No :
Figure 5.5
Figure 5.6
303105255                                                                                            Page 27
                                                              Faculty of Engineering & Technology
                                                           Subject Name: Computer Network
                                                              Subject Code: 203105256
                                                              B.Tech: CSE 2nd Year 4th Semester
                                           Annexure No :
Figure 5.7
303105255                                                                                     Page 28
                               Faculty of Engineering & Technology
                            Subject Name: Computer Network
                               Subject Code: 203105256
                               B.Tech: CSE 2nd Year 4th Semester
            Annexure No :
303105255                                                      Page 29
                                                                         Faculty of Engineering & Technology
                                                                      Subject Name: Computer Network
                                                                         Subject Code:303105255
                                                                         B.Tech: CSE 2nd Year 4th Semester
                                                Annexure No :
                                              PRACTICAL: 6
                                AIM: TO STUDY ABOUT Wireless LAN.
WLAN: - A wireless LAN (WLAN) is a wireless computer network that links two or more devices using
wireless communication to form a local area network (LAN) within a limited area such as a home, school,
computer laboratory, campus, or office building. This gives users the ability to move around within the area
and remain connected to the network. Through a gateway, a WLAN can also provide a connection to the
wider Internet.
 First create a wired topology between router, switch and pc to send message by wired communication. As
Shown below. Provide IP address to pc and to router also.
303105255                                                                                                Page30
                                                                        Faculty of Engineering & Technology
                                                                     Subject Name: Computer Network
                                                                        Subject Code: 203105256
                                                                        B.Tech: CSE 2nd Year 4th Semester
                                               Annexure No :
Go to Router configuration and then to the fast Ethernet port on which switch is connected then provide
their IP address to it and turn on the port status as shown below.
We need access point to connect the other devices wirelessely and give WEP key and SSID to access point to
secure the network.
303105255                                                                                               Page 31
                                                                         Faculty of Engineering & Technology
                                                                      Subject Name: Computer Network
                                                                         Subject Code: 203105256
                                                                         B.Tech: CSE 2nd Year 4th Semester
                                                 Annexure No :
Take another pc then go the physical device view. First turn off the computer then change the existing
module with WMP300N which is used to connect device wireless.
303105255                                                                                                Page 32
                                                                        Faculty of Engineering & Technology
                                                                     Subject Name: Computer Network
                                                                        Subject Code: 203105256
                                                                        B.Tech: CSE 2nd Year 4th Semester
                                                Annexure No :
Now go to PC Wireless setting then click on connect tab and select the SSID which you provided to access
point after that provide WEP key and then connect it.
303105255                                                                                               Page 33
                                                                        Faculty of Engineering & Technology
                                                                     Subject Name: Computer Network
                                                                        Subject Code: 203105256
                                                                        B.Tech: CSE 2nd Year 4th Semester
                                                Annexure No :
303105255                                                                                               Page 34
                                                                           Faculty of Engineering & Technology
                                                                        Subject Name: Computer Network
                                                                           Subject Code: 203105256
                                                                           B.Tech: CSE 2nd Year 4th Semester
                                                Annexure No :
Now go to wireless configuration give WEP key and SSID then close it.
303105255                                                                                                  Page 35
                                                                          Faculty of Engineering & Technology
                                                                       Subject Name: Computer Network
                                                                          Subject Code: 203105256
                                                                          B.Tech: CSE 2nd Year 4th Semester
                                                 Annexure No :
Take smartphone to go IP configuration and provide IP address to it and set router’s IP as the default
gateway of smartphone.
303105255                                                                                                 Page 36
                                                                         Faculty of Engineering & Technology
                                                                      Subject Name: Computer Network
                                                                         Subject Code: 203105256
                                                                         B.Tech: CSE 2nd Year 4th Semester
                                                Annexure No :
Then go to Wireless Configuration setting give WEP key and SSID of access point then close it.
303105255                                                                                                Page 37
                                                              Faculty of Engineering & Technology
                                                           Subject Name: Computer Network
                                                              Subject Code: 203105256
                                                              B.Tech: CSE 2nd Year 4th Semester
                                           Annexure No :
303105255                                                                                     Page 38
                               Faculty of Engineering & Technology
                            Subject Name: Computer Network
                               Subject Code: 203105256
                               B.Tech: CSE 2nd Year 4th Semester
            Annexure No :
303105255                                                      Page 39
                               Faculty of Engineering & Technology
                            Subject Name: Computer Network
                               Subject Code: 203105256
                               B.Tech: CSE 2nd Year 4th Semester
            Annexure No :
303105255                                                      Page 40
                                                                      Faculty of Engineering & Technology
                                                                   Subject Name: Computer Network
                                                                      Subject Code: 203105256
                                                                      B.Tech: CSE 2nd Year 4th Semester
                                              Annexure No :
Take a Printer and go to physical device view change existing module with WMP300N.
303105255                                                                                             Page 41
                               Faculty of Engineering & Technology
                            Subject Name: Computer Network
                               Subject Code: 203105256
                               B.Tech: CSE 2nd Year 4th Semester
            Annexure No :
303105255                                                      Page 42
                                           Faculty of Engineering & Technology
                                        Subject Name: Computer Network
                                           Subject Code: 203105256
                                           B.Tech: CSE 2nd Year 4th Semester
                        Annexure No :
Checking connection :
303105255                                                                  Page 43
                               Faculty of Engineering & Technology
                            Subject Name: Computer Network
                               Subject Code: 203105256
                               B.Tech: CSE 2nd Year 4th Semester
            Annexure No :
303105255                                                      Page 44
                                                                         Faculty of Engineering & Technology
                                                                      Subject Name: Computer Network
                                                                         Subject Code:303105255
                                                                         B.Tech: CSE 2nd Year 4th Semester
                                                Annexure No :
                                               Practical 7
AIM: Internetworking with routers: Design a three or four simple networks (with 3 to 4 hosts) and connect via
Router. Perform simulation and trace how routing is done in packet transmission
OUTPUT
303105255                                                                                                Page45
                                                                           Faculty of Engineering & Technology
                                                                        Subject Name: Computer Network
                                                                           Subject Code:303105255
                                                                           B.Tech: CSE 2nd Year 4th Semester
                                                 Annexure No :
                                                 Practical 8
AIM: Implementation of SUBNETTING:
Design multiple subnet with suitable number of hosts.
 Make a plan to assign static IP addressing across all subnet to explain implementation of SUBNETTING .
A subnetwork or subnet is a logical subdivision of an IP network.
 The practice of dividing a network into two or more networks is called subnetting.
Subnetting is the process of stealing bits from the HOST part of an IP address in order to divide the larger
network into smaller sub-networks called subnets. After subnetting, we end up with
NETWORK SUBNET HOST fields.
8.1 Purpose:
The main objective of the proposed experiment is to divide multiple networks using the concept ofsubnetting and
super-netting.
Output:
303105255                                                                                                  Page46
                                                                        Faculty of Engineering & Technology
                                                                     Subject Name: Computer Network
                                                                        Subject Code:303105255
                                                                        B.Tech: CSE 2nd Year 4th Semester
                                                Annexure No :
                                               Practical 9
AIM: Routing at Network Layer: Simulate Static and Dynamic Routing Protocol
Configuration using CISCO Packet Tracer.
9.1 Purpose:
The main objective of the proposed experiment is to implement static and dynamic routing protocolusing serial
and parallel routing connections. It also gives an opportunity to students to learn serialand parallel router
configuration in multiple network environment
FLOWCHART
Static
Static routing is a form of routing that occurs when a router uses a manually-configured routing entry,
rather than information from dynamic routing traffic
303105255                                                                                                 Page47
                                                                         Faculty of Engineering & Technology
                                                                      Subject Name: Computer Network
                                                                         Subject Code:303105255
                                                                         B.Tech: CSE 2nd Year 4th Semester
                                                Annexure No :
Dynamic
Dynamic routing, static routes are fixed and do not change if the network is changed or reconfigured.
303105255                                                                                                Page 48
                                                                        Faculty of Engineering & Technology
                                                                     Subject Name: Computer Network
                                                                        Subject Code:303105255
                                                                        B.Tech: CSE 2nd Year 4th Semester
                                                Annexure No :
                                               Practical-10
AIM: Experiment on Transport Layer: Implement echo client server using TCP/UDP sockets.
10.1 Purpose:
The main objective of the proposed experiment is to initiate communication between client and server
nodes using echo client and echo server. Utilize both TCP and UDP sockets in the proposed
experiment.
303105255                                                                                               Page49
                                                                                 Faculty of Engineering & Technology
                                                                              Subject Name: Computer Network
                                                                                 Subject Code:303105255
                                                                                 B.Tech: CSE 2nd Year 4th Semester
                                                       Annexure No :
 int n;
 char msg[50];
socklen_t clen;
bzero(&servaddr, sizeof(servaddr));
listen(listenfd,5);
#include<stdio.h>
303105255                                                                                                      Page 50
                                                                                Faculty of Engineering & Technology
                                                                             Subject Name: Computer Network
                                                                                Subject Code:303105255
                                                                                B.Tech: CSE 2nd Year 4th Semester
                                                        Annexure No :
#include<netinet/in.h>
#include<sys/socket.h> int
main() { int sockfd,n; char
msg[50],msg1[50];
socklen_t slen,len;
struct sockaddr_in servaddr;
bzero(&servaddr,sizeof(servaddr));
servaddr.sin_family = AF_INET;
servaddr.sin_port = htons(8888);
inet_pton(AF_INET,"127.0.0.1", &servaddr.sin_addr);
sockfd=socket(AF_INET,SOCK_STREAM,0);
 slen = sizeof(servaddr);
connect(sockfd,(struct sockaddr *) &servaddr, slen);
 printf("\nEnter the string that u wanna send to server:");
 scanf("%s",&msg);
OUTPUT:-
303105255                                                                                                       Page51
                                                                                 Faculty of Engineering & Technology
                                                                              Subject Name: Computer Network
                                                                                 Subject Code:303105255
                                                                                 B.Tech: CSE 2nd Year 4th Semester
                                                      Annexure No :
int main()
{
 int sockfd,n; char msg[50]; socklen_t len; struct sockaddr_in
servaddr,cliaddr;
sockfd=socket(AF_INET,SOCK_DGRAM,0);
303105255                                                                                                        Page52
                                                                                   Faculty of Engineering & Technology
                                                                                Subject Name: Computer Network
                                                                                   Subject Code:303105255
                                                                                   B.Tech: CSE 2nd Year 4th Semester
                                                       Annexure No :
sockaddr *) &cliaddr,len); exit(0);
    return 0;
}
 sockfd=socket(AF_INET,SOCK_DGRAM,0); len
 = sizeof(servaddr);
 printf("\nEnter the string that u wanna send to server:"); scanf("%s",msg);
 msg1[n]='\0'; printf("\nThe received string from the server is '%s'\n\n",msg1); exit(0); return
0;
}
303105255                                                                                                          Page53
                               Faculty of Engineering & Technology
                            Subject Name: Computer Network
                               Subject Code:303105255
                               B.Tech: CSE 2nd Year 4th Semester
            Annexure No :
303105255 Page 54