Welcome, Guest: Register On Nairaland / LOGIN! / Trending / Recent / New
Stats: 3,162,225 members, 7,849,802 topics. Date: Tuesday, 04 June 2024 at 09:58 AM

Networking Involves Programming But Not Otherwise? - Programming - Nairaland

Nairaland Forum / Science/Technology / Programming / Networking Involves Programming But Not Otherwise? (2090 Views)

I want to learn programming but hate mathematics / I'm Learning Programming But... How Can I Code (as In ... In Real Life)??? / I Want To Learn Programming But Tutorials Are Unhelpful (2) (3) (4)

(1) (Reply) (Go Down)

Networking Involves Programming But Not Otherwise? by prodam(m): 9:47pm On Mar 12, 2012
At any level, Networking experts can never do without programming but a programmer can be a guru without the knowledge of networking.

what would one call the configration of a router, the pinging of an IP address, the assigning of IP address by the DHCP and a host of other networking activities.they all involved programming in one way or the other.

On the other hand, I am yet to see the reason why a programmer would network two or more computers in order to get a real-time(core programming) job done.

however, I may be proved wrong right away

this would justify the respect for programming..It is made for the exceptionals indeed..
Re: Networking Involves Programming But Not Otherwise? by kodewrita(m): 10:12pm On Mar 12, 2012
As an assignment to aid your development, please read about tcp and socket programming.

If all you do is build websites, you won't appreciate the full inter connectedness of information technology.

The dude in charge of networking facebook's many servers is a guru on a completely different level from your average code monkey. Same for the guys in charge of the site's many database schemas.

Humility is one of the surest keys to greatness
Re: Networking Involves Programming But Not Otherwise? by csharpjava(m): 10:17pm On Mar 12, 2012
A router and other networking devices would not have been available without network programmers. This area of programming is called TCP, UDP, Client Socket and Server Socket programming. Here is an advance ping application and the C# code for it


/*
C# Network Programming
by Richard Blum

Publisher: Sybex
ISBN: 0782141765
*/
using System;
using System.Drawing;
using System.Net;
using System.Net.Sockets;
using System.Text;
using System.Threading;
using System.Windows.Forms;

public class AdvPing : Form
{
private static int pingstart, pingstop, elapsedtime;
private static TextBox hostbox, databox;
private static ListBox results;
private static Thread pinger;
private static Socket sock;

public AdvPing()
{
Text = "Advanced Ping Program";
Size = new Size(400, 380);

Label label1 = new Label();
label1.Parent = this;
label1.Text = "Enter host to ping:";
label1.AutoSize = true;
label1.Location = new Point(10, 30);

hostbox = new TextBox();
hostbox.Parent = this;
hostbox.Size = new Size(200, 2 * Font.Height);
hostbox.Location = new Point(10, 55);

results = new ListBox();
results.Parent = this;
results.Location = new Point(10, 85);
results.Size = new Size(360, 18 * Font.Height);

Label label2 = new Label();
label2.Parent = this;
label2.Text = "Packet data:";
label2.AutoSize = true;
label2.Location = new Point(10, 330);

databox = new TextBox();
databox.Parent = this;
databox.Text = "test packet";
databox.Size = new Size(200, 2 * Font.Height);
databox.Location = new Point(80, 325);

Button sendit = new Button();
sendit.Parent = this;
sendit.Text = "Start";
sendit.Location = new Point(220,52);
sendit.Size = new Size(5 * Font.Height, 2 * Font.Height);
sendit.Click += new EventHandler(ButtonSendOnClick);

Button stopit = new Button();
stopit.Parent = this;
stopit.Text = "Stop";
stopit.Location = new Point(295,52);
stopit.Size = new Size(5 * Font.Height, 2 * Font.Height);
stopit.Click += new EventHandler(ButtonStopOnClick);

Button closeit = new Button();
closeit.Parent = this;
closeit.Text = "Close";
closeit.Location = new Point(300, 320);
closeit.Size = new Size(5 * Font.Height, 2 * Font.Height);
closeit.Click += new EventHandler(ButtonCloseOnClick);

sock = new Socket(AddressFamily.InterNetwork, SocketType.Raw, ProtocolType.Icmp);
sock.SetSocketOption(SocketOptionLevel.Socket, SocketOptionName.ReceiveTimeout, 3000);
}

void ButtonSendOnClick(object obj, EventArgs ea)
{
pinger = new Thread(new ThreadStart(sendPing));
pinger.IsBackground = true;
pinger.Start();
}

void ButtonStopOnClick(object obj, EventArgs ea)
{
pinger.Abort();
}

void ButtonCloseOnClick(object obj, EventArgs ea)
{
sock.Close();
Close();
}

void sendPing()
{
IPHostEntry iphe = Dns.Resolve(hostbox.Text);
IPEndPoint iep = new IPEndPoint(iphe.AddressList[0], 0);
EndPoint ep = (EndPoint)iep;
ICMP packet = new ICMP();
int recv, i = 1;

packet.Type = 0x08;
packet.Code = 0x00;
Buffer.BlockCopy(BitConverter.GetBytes(1), 0, packet.Message, 0, 2);
byte[] data = Encoding.ASCII.GetBytes(databox.Text);
Buffer.BlockCopy(data, 0, packet.Message, 4, data.Length);
packet.MessageSize = data.Length + 4;
int packetsize = packet.MessageSize + 4;

results.Items.Add("Pinging " + hostbox.Text);
while(true)
{
packet.Checksum = 0;
Buffer.BlockCopy(BitConverter.GetBytes(i), 0, packet.Message, 2, 2);
UInt16 chcksum = packet.getChecksum();
packet.Checksum = chcksum;

pingstart = Environment.TickCount;
sock.SendTo(packet.getBytes(), packetsize, SocketFlags.None, iep);
try
{
data = new byte[1024];
recv = sock.ReceiveFrom(data, ref ep);
pingstop = Environment.TickCount;
elapsedtime = pingstop - pingstart;
results.Items.Add("reply from: " + ep.ToString() + ", seq: " + i +
", time = " + elapsedtime + "ms"wink;
} catch (SocketException)
{
results.Items.Add("no reply from host"wink;
}
i++;
Thread.Sleep(3000);
}
}

public static void Main()
{
Application.Run(new AdvPing());
}
}
class ICMP
{
public byte Type;
public byte Code;
public UInt16 Checksum;
public int MessageSize;
public byte[] Message = new byte[1024];

public ICMP()
{
}

public ICMP(byte[] data, int size)
{
Type = data[20];
Code = data[21];
Checksum = BitConverter.ToUInt16(data, 22);
MessageSize = size - 24;
Buffer.BlockCopy(data, 24, Message, 0, MessageSize);
}

public byte[] getBytes()
{
byte[] data = new byte[MessageSize + 9];
Buffer.BlockCopy(BitConverter.GetBytes(Type), 0, data, 0, 1);
Buffer.BlockCopy(BitConverter.GetBytes(Code), 0, data, 1, 1);
Buffer.BlockCopy(BitConverter.GetBytes(Checksum), 0, data, 2, 2);
Buffer.BlockCopy(Message, 0, data, 4, MessageSize);
return data;
}

public UInt16 getChecksum()
{
UInt32 chcksm = 0;
byte[] data = getBytes();
int packetsize = MessageSize + 8;
int index = 0;

while ( index < packetsize)
{
chcksm += Convert.ToUInt32(BitConverter.ToUInt16(data, index));
index += 2;
}
chcksm = (chcksm >> 16) + (chcksm & 0xffff);
chcksm += (chcksm >> 16);
return (UInt16)(~chcksm);
}
}

Re: Networking Involves Programming But Not Otherwise? by prodam(m): 10:39pm On Mar 12, 2012
@kodewrita:

I guess you are mixing things up or something. this is because the points you actually brought even support my statement.

you talked about network programming.

from wikipedia:

Computer network programming involves writing computer programs that enable processes to communicate with each other across a computer network.

this implies that in a network environment, programs are written to enable computers to communicate with each other.

@csharpjava: the code you posted shows the principle or logic behind the pinging of an address, thereby burtressing my advocacy that networking in general stands on programming

okay, more simpler: codes are inevitable in networking but networking concept can be left out in programming.

thanks all the same
Re: Networking Involves Programming But Not Otherwise? by csharpjava(m): 10:56pm On Mar 12, 2012
prodam: @kodewrita:
@csharpjava: the code you posted shows the principle or logic behind the pinging of an address, thereby burtressing my advocacy that networking in general stands on programming
okay, more simpler: codes are inevitable in networking but networking concept can be left out in programming.

The concept, architecture and the code implementation are all the work of senior network programmers.
Re: Networking Involves Programming But Not Otherwise? by cbainfo: 11:10am On Mar 13, 2012
@OP,
the two scenarios you have painted have no basis to pitch one against the other. they both operate on mutually exclusive fields, their roles are separate & one cannot be given the responsibility of the other, though they both might be working in the same office or project, but their levels of involvement & objective in the project are separate. the network guy could be both a programmer & hardware networking person. likewise the other guy is both a programmer & software networking expert, since the codes he works with are networking libraries, though his coding seems more one-dimensional.

1 Like

Re: Networking Involves Programming But Not Otherwise? by lordZOUGA(m): 12:36pm On Mar 13, 2012
this argument is to what end?
Re: Networking Involves Programming But Not Otherwise? by Bossman(m): 2:45pm On Mar 14, 2012
Actually networking and programming are two different things. And because you know one does not necessarily mean you can do the other.

1 Like

(1) (Reply)

Programming School/training Firm For A Young Graduate In Lagos/lekki-ajah Axis / Go And Study Your Algo And DS / Cbn Online\mobile Payment License

(Go Up)

Sections: politics (1) business autos (1) jobs (1) career education (1) romance computers phones travel sports fashion health
religion celebs tv-movies music-radio literature webmasters programming techmarket

Links: (1) (2) (3) (4) (5) (6) (7) (8) (9) (10)

Nairaland - Copyright © 2005 - 2024 Oluwaseun Osewa. All rights reserved. See How To Advertise. 28
Disclaimer: Every Nairaland member is solely responsible for anything that he/she posts or uploads on Nairaland.