UDP broadcast is a technique that allows sending UDP datagram from a single source to all computers in a LAN. In order to send a UDP datagram addressed to all computers in the local area network it needs to be sent to a special address called the Broadcast address.
Monday, 10 September 2018
[worked] Udp Send / Receive
Sender
unit UnitUDPClientAndroid;
interface
uses
System.SysUtils, System.Types, System.UITypes, System.Classes, System.Variants,
FMX.Types, FMX.Controls, FMX.Forms, FMX.Graphics, FMX.Dialogs,
IdBaseComponent, IdComponent, IdUDPBase, IdUDPClient,
FMX.Controls.Presentation, FMX.StdCtrls;
type
TForm1 = class(TForm)
Button1: TButton;
IdUDPClient1: TIdUDPClient;
procedure Button1Click(Sender: TObject);
procedure FormCreate(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
{$R *.fmx}
procedure TForm1.Button1Click(Sender: TObject);
begin
with IdUDPClient1 do
begin
Host := '192.168.0.5';
Port := 69;
send('filename.txt');
end;
end;
procedure TForm1.FormCreate(Sender: TObject);
begin
IdUDPClient1.Active := true;
end;
end.
// -----------------------------------------------------------------------------------------------------------
Receiver
unit UnitServer;
interface
uses
System.SysUtils, System.Types, System.UITypes, System.Classes, System.Variants,
FMX.Types, FMX.Controls, FMX.Forms, FMX.Graphics, FMX.Dialogs, IdComponent,
IdIPWatch, IdBaseComponent, IdUDPBase, IdUDPServer, FMX.Controls.Presentation,
FMX.ScrollBox, FMX.Memo, IdGlobal, IdSocketHandle;
type
TForm1 = class(TForm)
IdUDPServer1: TIdUDPServer;
IdIPWatch1: TIdIPWatch;
Memo1: TMemo;
procedure FormCreate(Sender: TObject);
procedure IdUDPServer1UDPRead(AThread: TIdUDPListenerThread;
const AData: TIdBytes; ABinding: TIdSocketHandle);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
MyUDPMessage : String;
implementation
{$R *.fmx}
procedure TForm1.FormCreate(Sender: TObject);
begin
Memo1.Lines.Add(IdIPWatch1.LocalIP);
Form1.IdUDPServer1.DefaultPort := 69;
Form1.IdUDPServer1.Active := True;
Form1.IdUDPServer1.OnUDPRead := IdUDPServer1UDPRead;
end;
procedure TForm1.IdUDPServer1UDPRead(AThread: TIdUDPListenerThread;
const AData: TIdBytes; ABinding: TIdSocketHandle);
begin
MyUDPmessage := BytesToString(AData);
Memo1.Lines.Add(MyUDPMessage);
end;
end.
unit UnitUDPClientAndroid;
interface
uses
System.SysUtils, System.Types, System.UITypes, System.Classes, System.Variants,
FMX.Types, FMX.Controls, FMX.Forms, FMX.Graphics, FMX.Dialogs,
IdBaseComponent, IdComponent, IdUDPBase, IdUDPClient,
FMX.Controls.Presentation, FMX.StdCtrls;
type
TForm1 = class(TForm)
Button1: TButton;
IdUDPClient1: TIdUDPClient;
procedure Button1Click(Sender: TObject);
procedure FormCreate(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
{$R *.fmx}
procedure TForm1.Button1Click(Sender: TObject);
begin
with IdUDPClient1 do
begin
Host := '192.168.0.5';
Port := 69;
send('filename.txt');
end;
end;
procedure TForm1.FormCreate(Sender: TObject);
begin
IdUDPClient1.Active := true;
end;
end.
// -----------------------------------------------------------------------------------------------------------
Receiver
unit UnitServer;
interface
uses
System.SysUtils, System.Types, System.UITypes, System.Classes, System.Variants,
FMX.Types, FMX.Controls, FMX.Forms, FMX.Graphics, FMX.Dialogs, IdComponent,
IdIPWatch, IdBaseComponent, IdUDPBase, IdUDPServer, FMX.Controls.Presentation,
FMX.ScrollBox, FMX.Memo, IdGlobal, IdSocketHandle;
type
TForm1 = class(TForm)
IdUDPServer1: TIdUDPServer;
IdIPWatch1: TIdIPWatch;
Memo1: TMemo;
procedure FormCreate(Sender: TObject);
procedure IdUDPServer1UDPRead(AThread: TIdUDPListenerThread;
const AData: TIdBytes; ABinding: TIdSocketHandle);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
MyUDPMessage : String;
implementation
{$R *.fmx}
procedure TForm1.FormCreate(Sender: TObject);
begin
Memo1.Lines.Add(IdIPWatch1.LocalIP);
Form1.IdUDPServer1.DefaultPort := 69;
Form1.IdUDPServer1.Active := True;
Form1.IdUDPServer1.OnUDPRead := IdUDPServer1UDPRead;
end;
procedure TForm1.IdUDPServer1UDPRead(AThread: TIdUDPListenerThread;
const AData: TIdBytes; ABinding: TIdSocketHandle);
begin
MyUDPmessage := BytesToString(AData);
Memo1.Lines.Add(MyUDPMessage);
end;
end.
UDP
用户数据报协议(英语:User Datagram Protocol,縮寫為UDP),又稱使用者資料包協定,是一个简单的面向数据报的传输层协议,正式規範為RFC 768。
在TCP/IP模型中,UDP为网络层以上和应用层以下提供了一个简单的接口。UDP只提供数据的不可靠传递,它一旦把应用程序发给网络层的数据发送出去,就不保留数据备份(所以UDP有时候也被认为是不可靠的数据报协议)。UDP在IP数据报的头部仅仅加入了复用和数据校验(字段)。
UDP首部字段由4个部分组成,其中两个是可选的。各16bit的來源端口和目的端口用来标记发送和接受的应用进程。因为UDP不需要应答,所以來源端口是可选的,如果來源端口不用,那么置为零。在目的端口后面是长度固定的以字节为单位的长度域,用来指定UDP数据报包括数据部分的长度,长度最小值为8byte。首部剩下地16bit是用来对首部和数据部分一起做校驗和(Checksum)的,这部分是可选的,但在实际应用中一般都使用这一功能。
由于缺乏可靠性且屬於非連接導向協定,UDP应用一般必须允许一定量的丢包、出错和复制貼上。但有些应用,比如TFTP,如果需要则必须在应用层增加根本的可靠机制。但是绝大多数UDP应用都不需要可靠机制,甚至可能因为引入可靠机制而降低性能。流媒體(串流技術)、即时多媒体游戏和IP电话(VoIP)一定就是典型的UDP应用。如果某个应用需要很高的可靠性,那么可以用传输控制协议(TCP协议)来代替UDP。
由于缺乏拥塞控制(congestion control),需要基于网络的机制来减少因失控和高速UDP流量负荷而导致的拥塞崩溃效应。换句话说,因为UDP发送者不能够检测拥塞,所以像使用包队列和丢弃技术的路由器这样的网络基本设备往往就成为降低UDP过大通信量的有效工具。数据报拥塞控制协议(DCCP)设计成通过在诸如流媒体类型的高速率UDP流中,增加主机拥塞控制,来减小这个潜在的问题。
典型网络上的众多使用UDP协议的关键应用一定程度上是相似的。这些应用包括域名系统(DNS)、简单网络管理协议(SNMP)、动态主机配置协议(DHCP)、路由信息协议(RIP)和某些影音串流服務等等。
在TCP/IP模型中,UDP为网络层以上和应用层以下提供了一个简单的接口。UDP只提供数据的不可靠传递,它一旦把应用程序发给网络层的数据发送出去,就不保留数据备份(所以UDP有时候也被认为是不可靠的数据报协议)。UDP在IP数据报的头部仅仅加入了复用和数据校验(字段)。
UDP首部字段由4个部分组成,其中两个是可选的。各16bit的來源端口和目的端口用来标记发送和接受的应用进程。因为UDP不需要应答,所以來源端口是可选的,如果來源端口不用,那么置为零。在目的端口后面是长度固定的以字节为单位的长度域,用来指定UDP数据报包括数据部分的长度,长度最小值为8byte。首部剩下地16bit是用来对首部和数据部分一起做校驗和(Checksum)的,这部分是可选的,但在实际应用中一般都使用这一功能。
由于缺乏可靠性且屬於非連接導向協定,UDP应用一般必须允许一定量的丢包、出错和复制貼上。但有些应用,比如TFTP,如果需要则必须在应用层增加根本的可靠机制。但是绝大多数UDP应用都不需要可靠机制,甚至可能因为引入可靠机制而降低性能。流媒體(串流技術)、即时多媒体游戏和IP电话(VoIP)一定就是典型的UDP应用。如果某个应用需要很高的可靠性,那么可以用传输控制协议(TCP协议)来代替UDP。
由于缺乏拥塞控制(congestion control),需要基于网络的机制来减少因失控和高速UDP流量负荷而导致的拥塞崩溃效应。换句话说,因为UDP发送者不能够检测拥塞,所以像使用包队列和丢弃技术的路由器这样的网络基本设备往往就成为降低UDP过大通信量的有效工具。数据报拥塞控制协议(DCCP)设计成通过在诸如流媒体类型的高速率UDP流中,增加主机拥塞控制,来减小这个潜在的问题。
典型网络上的众多使用UDP协议的关键应用一定程度上是相似的。这些应用包括域名系统(DNS)、简单网络管理协议(SNMP)、动态主机配置协议(DHCP)、路由信息协议(RIP)和某些影音串流服務等等。
Thursday, 23 August 2018
Wednesday, 22 August 2018
VoiceChat with FireMonkey XE6 (Delphi XE6) on Win, Android
https://www.youtube.com/watch?v=oa2x7V4y3h0
Delphi中UDP协议通讯
http://jicai.blog.163.com/blog/static/2619879200801091439624/
https://blog.csdn.net/csdnmyaccp_s2/article/details/52541946
Tuesday, 21 August 2018
Wednesday, 15 August 2018
Berastagi
Berastagi (Dutch: Brastagi), meaning "rice store", is a town and district of Karo Regency situated on a crossroads on the main route linking the Karo highlands of Northern Sumatra to the coastal city of Medan.
Berastagi town is located around 66 kilometers (41 miles) south of
Medan and about 1,300 meters (4300 feet) above sea level. The village
rose to significance when Dutch settlers in Sumatra opened a boarding school there in the 1920s.
What transportation options are there available (buses, shared taxi, taxi, or else)?
What transportation options are there available (buses, shared taxi, taxi, or else)?
https://www.tripsavvy.com/things-to-do-at-lake-toba-1458263
https://wikitravel.org/en/Lake_Toba
https://www.backpackers.com.tw/forum/archive/index.php/t-805583.html
https://travel.qunar.com/p-pl5221631
http://ephilip721.blogspot.com/2018/03/blog-post.html
As far as I know there are two possible ways to get to Lake Toba from Medan.
Further info: SAMPRI buses are the local public buses that seem to be the most 'official' ones. The price is fixed and told straight-forward, no need for bargaining. At some point shortly after starting the journey (on our way to Banyak islands) the bus drivr stops at a booth where you purchase your ticket and get a receipt with price and stamp.
- The easiest way to do this journey is to travel on a tourist minibus. It is a bit more expensive than the public transport option but it also gets you faster to your destination and you do not have to worry about transfering buses, finding the right one, waiting for it to leave, etc. You will travel by road from Medan to Parapat, you catch the bus from the Pinang Baris bus station in Medan. The price should be around 90,000 Rp. From Parapat you will be dropped off at the port, from where you will take a ferry to Palau Samosir, the island in the middle of the lake. The ferry costs 15'000 Rp. We were actually travelling from Bukit Lawang to Samosir island. We took the tourist bus for 230.000 Rps. The bus left from Bukit Lawang at 8.30 am and arrived at Medan at around 11.00 am. After a short break we continued on the road, reaching Berastagi at 1.30pm. After another break we then headed to Parapat, another 3 hr drive, so we arrived there at 5pm. Then we had to wait for the ferry. The ferry ticket was included in the total price we paid. To go from Bukit Lawang to Berastagi, same journey costs 170,000 Rps.
- There is another way to reach Danau Toba by using public transport. We did not go for this option, so I do not know the prices, but it is definitely cheaper than the above option. It is also a bit more complicated to reach the destination, timewise. You can take a public bus from Medan to Berastagi, from there catch an opelet to Kabanjahe, then transfer to a bus to Pematangsiantar and then to another bus heading to Parapat.
Further info: SAMPRI buses are the local public buses that seem to be the most 'official' ones. The price is fixed and told straight-forward, no need for bargaining. At some point shortly after starting the journey (on our way to Banyak islands) the bus drivr stops at a booth where you purchase your ticket and get a receipt with price and stamp.
https://www.tripsavvy.com/things-to-do-at-lake-toba-1458263
https://wikitravel.org/en/Lake_Toba
https://www.backpackers.com.tw/forum/archive/index.php/t-805583.html
https://travel.qunar.com/p-pl5221631
http://ephilip721.blogspot.com/2018/03/blog-post.html
Wednesday, 8 August 2018
IM即时通讯实现原理
QQ就是使用UDP协议进行发送和接收消息的。当你的机器安装了OICQ以后,实际上,你既是服务端(Server),又是客户端(Client)。当你登录OICQ时,你的OICQ作为Client连接到腾讯公司的主服务器上,当你看谁在线时,你的OICQ又一次作为Client从QQ Server上读取在线网友名单。当你和你的OICQ伙伴进行聊天时,如果你和对方的连接比较稳定,你和他的聊天内容都是以UDP的形式,在计算机之间传 送。如果你和对方的连接不是很稳定,QQ服务器将为你们的聊天内容进行中转。其他的即时通信软件原理与此大同小异。
https://www.cnblogs.com/dubo-/p/5586036.html
Subscribe to:
Posts (Atom)
zomok E-commerce system plan. Choose your online ordering system. No-risk 30 day free trial. Then USD 9/month. No credit card required.
zomok E-commerce system plan. Choose your online ordering system. No-risk 30 day free trial. Then USD 9/month. No credit card required. h...
-
DePauhGarden BabaCuisineBatuKawan ShunkaBatuKawan YenBatuKawan PanPanBatuKawan CheongfatttzeCafeMangga Iramadining AkkasCurryHouse Restauran...
-
Complete TFTP Server example, using Indy components There are not many good TFTP server examples out there, so I wrote this example of...