0% found this document useful (0 votes)
21 views10 pages

CN

The document describes how to check the IP configuration of a computer using the ipconfig command in both manual and automatic modes. It also shows examples of using ping to test connectivity to the local host and other devices on the network with valid and invalid IP addresses. The key information provided is how to use ipconfig to view current IP settings and ping to test basic network connectivity between hosts.

Uploaded by

api-26221489
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
21 views10 pages

CN

The document describes how to check the IP configuration of a computer using the ipconfig command in both manual and automatic modes. It also shows examples of using ping to test connectivity to the local host and other devices on the network with valid and invalid IP addresses. The key information provided is how to use ipconfig to view current IP settings and ping to test basic network connectivity between hosts.

Uploaded by

api-26221489
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOC, PDF, TXT or read online on Scribd

/* (Binary Countdown) */

#include<stdio.h>
#include<conio.h>
#define size 30

void main()
{
char a[size];
char *str;
int i=0,j=0;
int w=0;
int x=0;
int y=0;
int z=0;
int count=0;
for(i=0;i<=size;i++)
{
a[i]='\0';
}
clrscr();
printf("\nEnter the 4-bit address of station A:");
scanf("%s",&(*str));
j=0;
for(i=0;i<4;i++)
{
a[i]=*(str+j);
j++;
}
count=j;
j=0;
printf("\nEnter the 4-bit address of station B:");
scanf("%s",&(*str));
j=0;
for(i=4;i<(count+count);i++)
{
a[i]=*(str+j);
j++;
}
count+=j;
j=0;
printf("\nEnter the 4-bit address of station C:");
scanf("%s",&(*str));
j=0;
for(i=8;i<(count+count);i++)
{
a[i]=*(str+j);
j++;
}
count+=j;
j=0;
printf("\nEnter the 4-bit address of station D:");
scanf("%s",&(*str));
j=0;
for(i=12;i<(count+count);i++)
{
a[i]=*(str+j);
j++;
}
for(i=0;i<4;i++)
{
if (a[i]=='1')
++w;
}
for(i=4;i<8;i++)
{
if(a[i]=='1')
++x;
}
for(i=8;i<12;i++)
{
if(a[i]=='1')
++y;
}
for(i=12;i<16;i++)
{
if(a[i]=='1')
++z;
}
if(w>=x && w>=y && w>=z)
printf("\nA station will transmit");
if(x>=w && x>=y && x>=z)
printf("\nB station will transmit");
if(y>=w && y>=x && y>=z)
printf("\nC station will transmit");
if(z>=w && z>=x && z>=y)
printf("\nD station will transmit");
getch();
}

OUTPUT:

Enter the 4-bit address of station A:1111

Enter the 4-bit address of station B:0111

Enter the 4-bit address of station C:0011

Enter the 4-bit address of station D:0001

A station will transmit


/* (Bit-stuffing) */

#include<stdio.h>
#include<conio.h>
#define size 100

void main()
{
char a[size],b[size],*str;
int i=0,j=0,k=0;
int len=0;
clrscr();
for(i=0;i<=size;i++)
{
a[i]='\0';
b[i]='\0';
}
i=0;
printf("\nEnter the data:");
scanf("%s",&(*str));
while(*(str+j)!='\0')
{
a[i]=*(str+j);
i++;
j++;
}
i=0;
while(a[i]!='\0')
{
if(a[i]=='1')
{
++len;
if(len==5)
{
b[k]=a[i];
k++;
b[k]='0';
len=0;
goto xy;
}
b[k]=a[i];
xy:
i++;
k++;
}
if(a[i]=='0')
{
len=0;
b[k]=a[i];
i++;
k++;
}
}
printf("\nThe data that will be transmitted is:");
for(i=0;b[i]!='\0';i++)
printf("%c",b[i]);
for(i=0;i<=size;i++)
a[i]='\0';
k=0;
len=0;
i=0;
while(b[i]!='\0')
{
if(b[i]=='1')
{
++len;
if(len==5)
{
a[k]=b[i];
k++;
i+=2;
a[k]=b[i];
len=0;
goto xy1;
}
a[k]=b[i];
xy1:
i++;
k++;
}
if(b[i]=='0')
{
a[k]=b[i];
len=0;
i++;
k++;
}
}
printf("\nThe data at the receiver is:");
for(i=0;a[i]!='\0';i++)
printf("%c",a[i]);
getch();
}

OUTPUT:

Enter the data:1101111011111011

The data that will be transmitted is:11011110111110011

The data at the receiver is:1101111011111011


// IP ADDRESS
import [Link].*;

public class InetDemo


{
public static void main(String args[])
{
try
{
InetAddress host =[Link]();
[Link]("The IP Address of the local host is:"+host);
host=[Link](args[0]);
[Link]("The IP address of "+args[0]+"is "+host);
}
catch(UnknownHostException ex)
{
[Link]("There has been som error "+ex);
}
}
}

OUTPUT:

I:\javaprj\bin>javac [Link]

I:\javaprj\bin>java InetDemo
The IP Address of the local host is:cado-1985comp/[Link]
Exception in thread "main" [Link]
at [Link]([Link])
// URL
import [Link].*;
import [Link].*;

class URLDemo
{
public static void main(String args[])
throws
MalformedURLException
{
URL url=new URL("[Link]
[Link](url);
String protocol=[Link]();
int port=[Link]();
String file=[Link]();
[Link] .println("File used : "+file);
[Link]("protocol used : "+protocol);
[Link]("port used: "+port);

try
{
URLConnection urlcon=[Link]();
String ct=[Link]();
[Link]("The content type of this html page is "+ct);
long exp=[Link]();
[Link]("Expiration : "+exp);
int len=[Link]();
[Link]("The length of the content is: "+len);
InputStream ip=[Link]();
boolean flag=true;
while(flag)
{
int a=[Link] ();
if (a==-1)
{
flag=false;
}
else
{
char c=(char)a;
[Link](c);
}
}
[Link]();
}
catch(Exception e)
{
[Link]("There has been some Error "+e);
}
}
}

OUTPUT:

I:\javaprj\bin>javac [Link]
I:\javaprj\bin>java URLDemo
[Link]
File used :
protocol used : http
port used: -1
The content type of this html page is null
Expiration : 0
The length of the content is: -1
There has been some Error [Link]: [Link]

I:\javaprj\bin>java InetDemo
The IP Address of the local host is:cado-1985comp/[Link]
Exception in thread "main" [Link]
at [Link]([Link])
A)Using Manualy :

C:\>ipconfig

Windows 2000 IP Configuration

Ethernet adapter Local Area Connection:

Connection-specific DNS Suffix . :


IP Address. . . . . . . . . . . . : [Link]
Subnet Mask . . . . . . . . . . . : [Link]
Default Gateway . . . . . . . . . : [Link]

C:\>ipconfig/all

Windows 2000 IP Configuration

Host Name . . . . . . . . . . . . : c7-12


Primary DNS Suffix . . . . . . . :
Node Type . . . . . . . . . . . . : Broadcast
IP Routing Enabled. . . . . . . . : No
WINS Proxy Enabled. . . . . . . . : No

Ethernet adapter Local Area Connection:

Connection-specific DNS Suffix . :


Description . . . . . . . . . . . : Realtek RTL8139(A)-based PCI Fast
Ethernet Adapter
Physical Address. . . . . . . . . : 00-0B-6A-BD-FD-66
DHCP Enabled. . . . . . . . . . . : No
IP Address. . . . . . . . . . . . : [Link]
Subnet Mask . . . . . . . . . . . : [Link]
Default Gateway . . . . . . . . . : [Link]
DNS Servers . . . . . . . . . . . :

B)Using Automaticaly

C:\>ipconfig

Windows 2000 IP Configuration

Ethernet adapter Local Area Connection:

Connection-specific DNS Suffix . :


IP Address. . . . . . . . . . . . : [Link]
Subnet Mask . . . . . . . . . . . : [Link]
Default Gateway . . . . . . . . . :

C:\>ipconfig/all
Windows 2000 IP Configuration

Host Name . . . . . . . . . . . . : c7-12


Primary DNS Suffix . . . . . . . :
Node Type . . . . . . . . . . . . : Broadcast
IP Routing Enabled. . . . . . . . : No
WINS Proxy Enabled. . . . . . . . : No

Ethernet adapter Local Area Connection:

Connection-specific DNS Suffix . :


Description . . . . . . . . . . . : Realtek RTL8139(A)-based PCI Fast
Ethernet Adapter
Physical Address. . . . . . . . . : 00-0B-6A-BD-FD-66
DHCP Enabled. . . . . . . . . . . : Yes
Autoconfiguration Enabled . . . . : Yes
IP Address. . . . . . . . . . . . : [Link]
Subnet Mask . . . . . . . . . . . : [Link]
Default Gateway . . . . . . . . . :
DHCP Server . . . . . . . . . . . : [Link]
DNS Servers . . . . . . . . . . . :

C:\>ping localhost

Pinging c7-12 [[Link]] with 32 bytes of data:

Reply from [Link]: bytes=32 time<10ms TTL=128


Reply from [Link]: bytes=32 time<10ms TTL=128
Reply from [Link]: bytes=32 time<10ms TTL=128
Reply from [Link]: bytes=32 time<10ms TTL=128

Ping statistics for [Link]:


Packets: Sent = 4, Received = 4, Lost = 0 (0% loss),
Approximate round trip times in milli-seconds:
Minimum = 0ms, Maximum = 0ms, Average = 0ms

C:\>ping [Link]

Pinging [Link] with 32 bytes of data:

Reply from [Link]: bytes=32 time<10ms TTL=128


Reply from [Link]: bytes=32 time<10ms TTL=128
Reply from [Link]: bytes=32 time<10ms TTL=128
Reply from [Link]: bytes=32 time<10ms TTL=128

Ping statistics for [Link]:


Packets: Sent = 4, Received = 4, Lost = 0 (0% loss),
Approximate round trip times in milli-seconds:
Minimum = 0ms, Maximum = 0ms, Average = 0ms
-------------------------------------------------------
C:\>ping [Link]

Pinging [Link] with 32 bytes of data:

Reply from [Link]: bytes=32 time<10ms TTL=128


Reply from [Link]: bytes=32 time<10ms TTL=128
Reply from [Link]: bytes=32 time<10ms TTL=128
Reply from [Link]: bytes=32 time<10ms TTL=128

Ping statistics for [Link]:


Packets: Sent = 4, Received = 4, Lost = 0 (0% loss),
Approximate round trip times in milli-seconds:
Minimum = 0ms, Maximum = 0ms, Average = 0ms
-------------------------------------------------------
C:\>ping [Link]

Pinging [Link] with 32 bytes of data:

Request timed out.


Request timed out.
Request timed out.
Request timed out.

Ping statistics for [Link]:


Packets: Sent = 4, Received = 0, Lost = 4 (100% loss),
Approximate round trip times in milli-seconds:
Minimum = 0ms, Maximum = 0ms, Average = 0ms
-------------------------------------------------------

You might also like