Добавил:
Upload Опубликованный материал нарушает ваши авторские права? Сообщите нам.
Вуз: Предмет: Файл:
PZ.doc
Скачиваний:
169
Добавлен:
11.05.2015
Размер:
458.75 Кб
Скачать

Заключение

В данном курсовом проекте согласно техническому заданию была спроектирована информационно-вычислительная сеть. Перед проектированием сначала было определенно количество узлов сети и способы их связи между собой и источниками информации, а так же параметры и места размещения каналов связи и т.п.

Выбор структуры при проектировании основывался на том, чтобы обеспечить оптимальную топологическую структуру по всем критериям, хотя самым главным критерием оптимизации в моем курсовом проекте являлась стоимость сети.

В ходе проделанной работы были выбраны: сетевое оборудование, среды передачи данных, конфигурации рабочих станций и серверов сети, сетевые протоколы, сетевая операционная система; размещение сетевого оборудования в учебных корпусах. Были рассмотрены такие: важные и интересные вопросы, как удаленный доступ к сети, подключение локальных информационных систем к глобальным сетям типа Internet.

Список использованных источников

  1. «Компьютерные сети. Принципы, технологии, протоколы.» /Олифер, В.Г., Олифер, Н.А./ СПб.:Питер, 2002.-384c.

  2. «Компьютерные сети» /Танненбаум, Э./ – СПб.:Питер, 2002. – 459c.

  3. «Защита компьютерной информации». /Анин, Б./ – СПб.: БЧВ, 2000. -384c.

  4. «Вычислительные системы, сети и телекоммуникации.» /Пятибратов, М.Д./ – ФИС, 1998. – 279с.

  5. «TCP/IP. Архитектура, протоколы, реализация.» /Фейт, С., Лори, М./ СПб : БЧВ, 2000. – 562с.

  6. «Сети ЭВМ: протоколы, стандарты, интерфейсы.» /Блэк, Ю./ М.: Мир, 1990. – 321с.

  7. «Стандарты по локальным вычислительным сетям: Справочник» /Под ред. Шерба, В.К., Киреичев, В.М., Самойленко, С.И./ М.: Радио и связь, 1990 – 356c.

  8. «Проектирование распределенных информационно-вычислительных систем.» / Решетняк, В.Н., Гузик, В.Ф., Сидоренко, В.Г./ Учеб. пособие. Таганрог: ТРТУ, 1996. – 284c.

Приложение А – Листинг программы

Исходные коды

//---------------------------------------------------------------------------

using System;

using System.Collections.Generic;

using System.ComponentModel;

using System.Data;

using System.Drawing;

using System.Text;

using System.Windows.Forms;

using Microsoft.DirectX.DirectSound;

using System.IO;

using System.Threading;

using System.Net.Sockets;

using System.Net;

using g711audio;

namespace VoiceChat

{

public partial class VoiceChat : Form

{

private CaptureBufferDescription captureBufferDescription;

private AutoResetEvent autoResetEvent;

private Notify notify;

private WaveFormat waveFormat;

private Capture capture;

private int bufferSize;

private CaptureBuffer captureBuffer;

private UdpClient udpClient; //Listens and sends data on port 1550, used in synchronous mode.

private Device device;

private SecondaryBuffer playbackBuffer;

private BufferDescription playbackBufferDescription;

private Socket clientSocket;

private bool bStop; //Flag to end the Start and Receive threads.

private IPEndPoint otherPartyIP; //IP of party we want to make a call.

private EndPoint otherPartyEP;

private volatile bool bIsCallActive; //Tells whether we have an active call.

private Vocoder vocoder;

private byte[] byteData = new byte[1024]; //Buffer to store the data received.

private volatile int nUdpClientFlag; //Flag used to close the udpClient socket.

public VoiceChat()

{

InitializeComponent();

Initialize();

}

/*

* Initializes all the data members.

*/

private void Initialize()

{

try

{

device = new Device();

device.SetCooperativeLevel(this, CooperativeLevel.Normal);

CaptureDevicesCollection captureDeviceCollection = new CaptureDevicesCollection();

DeviceInformation deviceInfo = captureDeviceCollection[0];

capture = new Capture(deviceInfo.DriverGuid);

short channels = 1; //Stereo.

short bitsPerSample = 16; //16Bit, alternatively use 8Bits.

int samplesPerSecond = 22050; //11KHz use 11025 , 22KHz use 22050, 44KHz use 44100 etc.

//Set up the wave format to be captured.

waveFormat = new WaveFormat();

waveFormat.Channels = channels;

waveFormat.FormatTag = WaveFormatTag.Pcm;

waveFormat.SamplesPerSecond = samplesPerSecond;

waveFormat.BitsPerSample = bitsPerSample;

waveFormat.BlockAlign = (short)(channels * (bitsPerSample / (short)8));

waveFormat.AverageBytesPerSecond = waveFormat.BlockAlign * samplesPerSecond;

captureBufferDescription = new CaptureBufferDescription();

captureBufferDescription.BufferBytes = waveFormat.AverageBytesPerSecond / 5;//approx 200 milliseconds of PCM data.

captureBufferDescription.Format = waveFormat;

playbackBufferDescription = new BufferDescription();

playbackBufferDescription.BufferBytes = waveFormat.AverageBytesPerSecond / 5;

playbackBufferDescription.Format = waveFormat;

playbackBuffer = new SecondaryBuffer(playbackBufferDescription, device);

bufferSize = captureBufferDescription.BufferBytes;

bIsCallActive = false;

nUdpClientFlag = 0;

//Using UDP sockets

clientSocket = new Socket(AddressFamily.InterNetwork, SocketType.Dgram, ProtocolType.Udp);

EndPoint ourEP = new IPEndPoint(IPAddress.Any, 1450);

//Listen asynchronously on port 1450 for coming messages (Invite, Bye, etc).

clientSocket.Bind(ourEP);

//Receive data from any IP.

EndPoint remoteEP = (EndPoint)(new IPEndPoint(IPAddress.Any, 0));

byteData = new byte[1024];

//Receive data asynchornously.

clientSocket.BeginReceiveFrom(byteData,

0, byteData.Length,

SocketFlags.None,

ref remoteEP,

new AsyncCallback(OnReceive),

null);

}

catch (Exception ex)

{

MessageBox.Show(ex.Message, "VoiceChat-Initialize ()", MessageBoxButtons.OK, MessageBoxIcon.Error);

}

}

private void btnCall_Click(object sender, EventArgs e)

{

Call();

}

private void Call()

{

try

{

//Get the IP we want to call.

otherPartyIP = new IPEndPoint(IPAddress.Parse(txtCallToIP.Text), 1450);

otherPartyEP = (EndPoint)otherPartyIP;

//Get the vocoder to be used.

if (cmbCodecs.SelectedText == "A-Law")

{

vocoder = Vocoder.ALaw;

}

else if (cmbCodecs.SelectedText == "u-Law")

{

vocoder = Vocoder.uLaw;

}

else if (cmbCodecs.SelectedText == "None")

{

vocoder = Vocoder.None;

}

//Send an invite message.

SendMessage(Command.Invite, otherPartyEP);

}

catch (Exception ex)

{

MessageBox.Show(ex.Message, "VoiceChat-Call ()", MessageBoxButtons.OK, MessageBoxIcon.Error);

}

}

private void OnSend(IAsyncResult ar)

{

try

{

clientSocket.EndSendTo (ar);

}

catch (Exception ex)

{

MessageBox.Show(ex.Message, "VoiceChat-OnSend ()", MessageBoxButtons.OK, MessageBoxIcon.Error);

}

}

/*

* Commands are received asynchronously. OnReceive is the handler for them.

*/

private void OnReceive(IAsyncResult ar)

{

try

{

EndPoint receivedFromEP = new IPEndPoint(IPAddress.Any, 0);

//Get the IP from where we got a message.

clientSocket.EndReceiveFrom(ar, ref receivedFromEP);

//Convert the bytes received into an object of type Data.

Data msgReceived = new Data(byteData);

//Act according to the received message.

switch (msgReceived.cmdCommand)

{

//We have an incoming call.

case Command.Invite:

{

if (bIsCallActive == false)

{

//We have no active call.

//Ask the user to accept the call or not.

if (MessageBox.Show("Call coming from " + msgReceived.strName + ".\r\n\r\nAccept it?",

"VoiceChat", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)

{

SendMessage(Command.OK, receivedFromEP);

vocoder = msgReceived.vocoder;

otherPartyEP = receivedFromEP;

otherPartyIP = (IPEndPoint)receivedFromEP;

InitializeCall();

}

else

{

//The call is declined. Send a busy response.

SendMessage(Command.Busy, receivedFromEP);

}

}

else

{

//We already have an existing call. Send a busy response.

SendMessage(Command.Busy, receivedFromEP);

}

break;

}

//OK is received in response to an Invite.

case Command.OK:

{

//Start a call.

InitializeCall();

break;

}

//Remote party is busy.

case Command.Busy:

{

MessageBox.Show("User busy.", "VoiceChat", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);

break;

}

case Command.Bye:

{

//Check if the Bye command has indeed come from the user/IP with which we have

//a call established. This is used to prevent other users from sending a Bye, which

//would otherwise end the call.

if (receivedFromEP.Equals (otherPartyEP) == true)

{

//End the call.

UninitializeCall();

}

break;

}

}

byteData = new byte[1024];

//Get ready to receive more commands.

clientSocket.BeginReceiveFrom(byteData, 0, byteData.Length, SocketFlags.None, ref receivedFromEP, new AsyncCallback(OnReceive), null);

}

catch (Exception ex)

{

MessageBox.Show(ex.Message, "VoiceChat-OnReceive ()", MessageBoxButtons.OK, MessageBoxIcon.Error);

}

}

/*

* Send synchronously sends data captured from microphone across the network on port 1550.

*/

private void Send()

{

try

{

//The following lines get audio from microphone and then send them

//across network.

captureBuffer = new CaptureBuffer(captureBufferDescription, capture);

CreateNotifyPositions();

int halfBuffer = bufferSize / 2;

captureBuffer.Start(true);

bool readFirstBufferPart = true;

int offset = 0;

MemoryStream memStream = new MemoryStream(halfBuffer);

bStop = false;

while (!bStop)

{

autoResetEvent.WaitOne();

memStream.Seek(0, SeekOrigin.Begin);

captureBuffer.Read(offset, memStream, halfBuffer, LockFlag.None);

readFirstBufferPart = !readFirstBufferPart;

offset = readFirstBufferPart ? 0 : halfBuffer;

//TODO: Fix this ugly way of initializing differently.

//Choose the vocoder. And then send the data to other party at port 1550.

if (vocoder == Vocoder.ALaw)

{

byte[] dataToWrite = ALawEncoder.ALawEncode(memStream.GetBuffer());

udpClient.Send(dataToWrite, dataToWrite.Length, otherPartyIP.Address.ToString (), 1550);

}

else if (vocoder == Vocoder.uLaw)

{

byte[] dataToWrite = MuLawEncoder.MuLawEncode(memStream.GetBuffer());

udpClient.Send(dataToWrite, dataToWrite.Length, otherPartyIP.Address.ToString(), 1550);

}

else

{

byte[] dataToWrite = memStream.GetBuffer();

udpClient.Send(dataToWrite, dataToWrite.Length, otherPartyIP.Address.ToString(), 1550);

}

}

}

catch (Exception ex)

{

MessageBox.Show(ex.Message, "VoiceChat-Send ()", MessageBoxButtons.OK, MessageBoxIcon.Error);

}

finally

{

captureBuffer.Stop();

//Increment flag by one.

nUdpClientFlag += 1;

//When flag is two then it means we have got out of loops in Send and Receive.

while (nUdpClientFlag != 2)

{ }

//Clear the flag.

nUdpClientFlag = 0;

//Close the socket.

udpClient.Close();

}

}

/*

* Receive audio data coming on port 1550 and feed it to the speakers to be played.

*/

}.

Приложение Б – Схема алгоритма

У

Соседние файлы в предмете [НЕСОРТИРОВАННОЕ]